Все странички закончены (вроде)
This commit is contained in:
parent
d30bf4f7ec
commit
ca728baeca
269
CarCenter/CarCenterWorkerApp/Views/Home/CreateOrder.cshtml
Normal file
269
CarCenter/CarCenterWorkerApp/Views/Home/CreateOrder.cshtml
Normal file
@ -0,0 +1,269 @@
|
||||
@using CarCenterContracts.ViewModels;
|
||||
@using CarCenterDataModels.Enums;
|
||||
|
||||
@model OrderViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "CreateOrder";
|
||||
ViewBag.Presales = Model.OrderPresales;
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание заказа</h2>
|
||||
</div>
|
||||
<form id="orderForm" method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Тип оплаты:</div>
|
||||
<div class="col-8">
|
||||
<select name="PaymentType" id="PaymentType" value="@Model.PaymentType">
|
||||
@foreach (var value in Enum.GetValues(typeof(PaymentType)))
|
||||
{
|
||||
<option value="@value">@value</option>
|
||||
}
|
||||
</select>
|
||||
<span id="PaymentTypeError" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">ФИО покупателя:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="BuyerFCS" id="BuyerFCS" value="@Model.BuyerFCS" />
|
||||
<span id="BuyerFCSError" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Сумма:</div>
|
||||
<div class="col-8"><input type="text" id="sum" name="sum" readonly /></div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div>Предпродажные работы</div>
|
||||
<div class="table-responsive-lg">
|
||||
<table id="presalesTable" class="display">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID предпродажной</th>
|
||||
<th> </th>
|
||||
<th>Стоимость</th>
|
||||
<th> </th>
|
||||
<th>Удалить</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var presale in ViewBag.Presales)
|
||||
{
|
||||
<tr data-presale-id="@presale.Value.Id">
|
||||
<td>
|
||||
<input type="hidden" name="presaleIds" value="@presale.Value.Id" />@presale.Value.Id
|
||||
</td>
|
||||
<th> </th>
|
||||
<td class="presale-price" data-price="@presale.Value.Price">@presale.Value.Price</td>
|
||||
<th> </th>
|
||||
<td><button type="button" class="deletePresale" data-bundling-id="@presale.Value.Id">Удалить</button></td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<select id="presaleSelect" class="form-control">
|
||||
<option value="">Выберите работу</option>
|
||||
@foreach (var presale in ViewBag.AllPresales)
|
||||
{
|
||||
<option value="@presale.Id" data-price="@presale.Price">Комплектация @presale.Id</option>
|
||||
}
|
||||
</select>
|
||||
<button type="button" id="addPresale" class="btn btn-secondary">Добавить комплектацию</button>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div>Машины</div>
|
||||
<div class="table-responsive-lg">
|
||||
<table id="carsTable" class="display">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID машины</th>
|
||||
<th> </th>
|
||||
<th>Стоимость</th>
|
||||
<th> </th>
|
||||
<th>Удалить</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var car in ViewBag.Cars)
|
||||
{
|
||||
<tr data-car-id="@car.Value.Id">
|
||||
<td>
|
||||
<input type="hidden" name="carIds" value="@car.Value.Id" />@car.Value.Id
|
||||
</td>
|
||||
<th> </th>
|
||||
<td class="car-price" data-price="@car.Value.Price">@car.Value.Price</td>
|
||||
<th> </th>
|
||||
<td><button type="button" class="deleteCar" data-car-id="@car.Value.Id">Удалить</button></td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<select id="carSelect" class="form-control">
|
||||
<option value="">Выберите машину</option>
|
||||
@foreach (var car in ViewBag.AllCars)
|
||||
{
|
||||
<option value="@car.Id" data-price="@car.Price">Комплектация @car.Id</option>
|
||||
}
|
||||
</select>
|
||||
<button type="button" id="addCar" class="btn btn-secondary">Добавить комплектацию</button>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Сумма:</div>
|
||||
<div class="col-8"><input type="text" id="sum" name="sum" readonly /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8"></div>
|
||||
<div class="col-4"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
<script src="https://cdn.datatables.net/1.11.3/js/jquery.dataTables.js"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
function updateSum() {
|
||||
var sum = 0;
|
||||
$('#presalesTable tbody tr').each(function () {
|
||||
var pricebd = $(this).find('.presale-price').data('price');
|
||||
sum += parseFloat(pricebd);
|
||||
});
|
||||
$('#carsTable tbody tr').each(function () {
|
||||
var pricecar = $(this).find('.car-price').data('price');
|
||||
sum += parseFloat(pricecar);
|
||||
});
|
||||
$('#sum').val(sum.toFixed(2));
|
||||
}
|
||||
|
||||
$(document).on('click', '.deleteCar', function () {
|
||||
var row = $(this).closest('tr');
|
||||
row.remove();
|
||||
updateSum();
|
||||
});
|
||||
$(document).on('click', '.deletePresale', function () {
|
||||
var row = $(this).closest('tr');
|
||||
row.remove();
|
||||
updateSum();
|
||||
});
|
||||
$('#addPresale').click(function () {
|
||||
var selectedPresale = $('#presaleSelect option:selected');
|
||||
if (selectedPresale.val()) {
|
||||
var presaleId = selectedPresale.val();
|
||||
var exists = false;
|
||||
$('#presalesTable tbody tr').each(function () {
|
||||
if ($(this).data('presale-id') == presaleId) {
|
||||
exists = true;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (exists) {
|
||||
alert('Эта работа уже добавлена.');
|
||||
return;
|
||||
}
|
||||
|
||||
var presaleName = selectedPresale.text();
|
||||
var presalePrice = selectedPresale.data('price');
|
||||
|
||||
var newRow = `
|
||||
<tr data-presale-id="${presaleId}">
|
||||
<td>
|
||||
<input type="hidden" name="presaleIds" value="${presaleId}" />
|
||||
${presaleId}
|
||||
</td>
|
||||
<th> </th>
|
||||
<td class="presale-price" data-price="${presalePrice}">${presalePrice}</td>
|
||||
<th> </th>
|
||||
<td><button type="button" class="deletePresale" data-presale-id="${presaleId}">Удалить</button></td>
|
||||
</tr>
|
||||
`;
|
||||
$('#presalesTable tbody').append(newRow);
|
||||
|
||||
$('.deletePresale').off('click').on('click', function () {
|
||||
var row = $(this).closest('tr');
|
||||
row.remove();
|
||||
updateSum();
|
||||
});
|
||||
|
||||
$('#presaleSelect').val('');
|
||||
|
||||
updateSum();
|
||||
} else {
|
||||
alert('Выберите работу для добавления');
|
||||
}
|
||||
});
|
||||
$('#addCar').click(function () {
|
||||
var selectedCar = $('#carSelect option:selected');
|
||||
if (selectedCar.val()) {
|
||||
var carId = selectedCar.val();
|
||||
var exists = false;
|
||||
$('#carsTable tbody tr').each(function () {
|
||||
if ($(this).data('car-id') == carId) {
|
||||
exists = true;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (exists) {
|
||||
alert('Эта машина уже добавлена.');
|
||||
return;
|
||||
}
|
||||
|
||||
var carName = selectedCar.text();
|
||||
var carPrice = selectedCar.data('price');
|
||||
|
||||
var newRow = `
|
||||
<tr data-car-id="${carId}">
|
||||
<td>
|
||||
<input type="hidden" name="carIds" value="${carId}" />
|
||||
${carId}
|
||||
</td>
|
||||
<th> </th>
|
||||
<td class="car-price" data-price="${carPrice}">${carPrice}</td>
|
||||
<th> </th>
|
||||
<td><button type="button" class="deleteCar" data-car-id="${carId}">Удалить</button></td>
|
||||
</tr>
|
||||
`;
|
||||
$('#carsTable tbody').append(newRow);
|
||||
|
||||
$('.deleteCar').off('click').on('click', function () {
|
||||
var row = $(this).closest('tr');
|
||||
row.remove();
|
||||
updateSum();
|
||||
});
|
||||
|
||||
$('#carSelect').val('');
|
||||
|
||||
updateSum();
|
||||
} else {
|
||||
alert('Выберите машину для добавления');
|
||||
}
|
||||
});
|
||||
|
||||
$('#orderForm').submit(function (event) {
|
||||
var PaymentType = $('#PaymentType').val();
|
||||
var BuyerFCS = $('#BuyerFCS').val();
|
||||
var isValid = true;
|
||||
|
||||
$('#PaymentTypeError').text('');
|
||||
$('#BuyerFCSError').text('');
|
||||
var totalCars = $('#carsTable tbody tr').length;
|
||||
if (totalCars == 0) {
|
||||
alert('Пожалуйста, добавьте хотя бы одну машину.');
|
||||
isValid = false;
|
||||
}
|
||||
var totalPresales = $('#presalesTable tbody tr').length;
|
||||
if (totalPresales == 0) {
|
||||
alert('Пожалуйста, добавьте хотя бы одну работу.');
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (!isValid) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
updateSum();
|
||||
});
|
||||
</script>
|
||||
|
94
CarCenter/CarCenterWorkerApp/Views/Home/IndexOrder.cshtml
Normal file
94
CarCenter/CarCenterWorkerApp/Views/Home/IndexOrder.cshtml
Normal file
@ -0,0 +1,94 @@
|
||||
@using CarCenterContracts.ViewModels;
|
||||
|
||||
@model List<OrderViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Orders";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Покупки</h1>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
<p>
|
||||
<a asp-action="CreateOrder" asp-route-id="0">Создать покупку</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Номер
|
||||
</th>
|
||||
<th>
|
||||
Тип оплаты
|
||||
</th>
|
||||
<th>
|
||||
Статус оплаты
|
||||
</th>
|
||||
<th>
|
||||
Дата оплаты
|
||||
</th>
|
||||
<th>
|
||||
ФИО покупателя
|
||||
</th>
|
||||
<th>
|
||||
Имя работника
|
||||
</th>
|
||||
<th>
|
||||
Сумма
|
||||
</th>
|
||||
<th>
|
||||
Изменить покупку
|
||||
</th>
|
||||
<th>
|
||||
Удалить покупку
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Id)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.PaymentType)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.PaymentStatus)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.PaymentDate)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.BuyerFCS)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.WorkerName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.Sum)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-action="CreateOrder" asp-route-id="@item.Id" class="btn btn-primary">Изменить</a>
|
||||
</td>
|
||||
<td>
|
||||
<form method="post">
|
||||
<input type="text" title="id" name="id" value="@item.Id" hidden="hidden" />
|
||||
<input type="submit" class="btn btn-danger" value="Удалить" />
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
@ -1,47 +0,0 @@
|
||||
@using CarCenterContracts.ViewModels;
|
||||
@using CarCenterDataModels.Enums;
|
||||
@{
|
||||
ViewData["Title"] = "OrderCreate";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание покупки</h2>
|
||||
</div>
|
||||
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-4">Тип оплаты:</div>
|
||||
<div class="col-8">
|
||||
<select name="orderType" id="orderType">
|
||||
@foreach (var value in Enum.GetValues(typeof(PaymentType)))
|
||||
{
|
||||
<option value="@value">@value</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Имя покупателя:</div>
|
||||
<div class="col-8"><input type="text" name="buyerFCS" id="buyerFCS" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8">Предпродажные работы:</div>
|
||||
<!--Без реализации логики четко не ясно что тут писать-->
|
||||
<select id="presale" name="presale" class="form-control" asp-items="@(new SelectList(@ViewBag.Presales,"Id"))"></select>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8">Машины:</div>
|
||||
<!--Без реализации логики четко не ясно что тут писать-->
|
||||
<select id="car" name="car" class="form-control" asp-items="@(new SelectList(@ViewBag.Cars,"Id"))"></select>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Сумма:</div>
|
||||
<div class="col-8"><label type="text" name="sum" id="sum" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4"></div>
|
||||
<div class="col-2"><input type="submit" value="Сохранить" class="btn btn-primary" /></div>
|
||||
<div class="col-4"></div>
|
||||
<div class="col-2"><input type="button" value="Отменить" class="btn btn-secondary" /></div>
|
||||
</div>
|
||||
</form>
|
@ -1,19 +0,0 @@
|
||||
@{
|
||||
ViewData["Title"] = "OrderDelete";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Удалить покупку</h2>
|
||||
</div>
|
||||
<form method="post">
|
||||
<div class="row">
|
||||
<div class="col-8">
|
||||
<select id="order" name="order" class="form-control" asp-items="@(new SelectList(@ViewBag.Orders,"Id"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4"></div>
|
||||
<div class="col-2"><input type="submit" value="Удалить" class="btn btn-primary" /></div>
|
||||
<div class="col-4"></div>
|
||||
<div class="col-2"><input type="button" value="Отменить" class="btn btn-secondary" /></div>
|
||||
</div>
|
||||
</form>
|
@ -1,68 +0,0 @@
|
||||
@using CarCenterContracts.ViewModels;
|
||||
@using CarCenterDataModels.Enums;
|
||||
@{
|
||||
ViewData["Title"] = "OrderUpdate";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Оновить покупку</h2>
|
||||
</div>
|
||||
|
||||
<form method="post">
|
||||
<div class="row mb-3">
|
||||
<div class="col-4">Покупка:</div>
|
||||
<div class="col-8">
|
||||
<select id="order" name="order" class="form-control" asp-items="@(new SelectList(@ViewBag.Order,"Id"))"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Тип оплаты:</div>
|
||||
<div class="col-8">
|
||||
<select name="orderType" id="orderType">
|
||||
@foreach (var value in Enum.GetValues(typeof(PaymentType)))
|
||||
{
|
||||
<option value="@value">@value</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Статус оплаты:</div>
|
||||
<div class="col-8">
|
||||
<select name="orderStatus" id="orderStatus">
|
||||
@foreach (var value in Enum.GetValues(typeof(PaymentStatus)))
|
||||
{
|
||||
<option value="@value">@value</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Имя покупателя:</div>
|
||||
<div class="col-8"><input type="text" name="buyerFCS" id="buyerFCS" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Дата оплаты:</div>
|
||||
<div class="col-8"><input type="datetime" name="paymentDate" id="paymentDate" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8">Предпродажные работы:</div>
|
||||
<!--Без реализации логики четко не ясно что тут писать-->
|
||||
<select id="presale" name="presale" class="form-control" asp-items="@(new SelectList(@ViewBag.Presales,"Id"))"></select>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-8">Машины:</div>
|
||||
<!--Без реализации логики четко не ясно что тут писать-->
|
||||
<select id="car" name="car" class="form-control" asp-items="@(new SelectList(@ViewBag.Cars,"Id"))"></select>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Сумма:</div>
|
||||
<div class="col-8"><label type="text" name="sum" id="sum" /></div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4"></div>
|
||||
<div class="col-2"><input type="submit" value="Обновить" class="btn btn-primary" /></div>
|
||||
<div class="col-4"></div>
|
||||
<div class="col-2"><input type="button" value="Отменить" class="btn btn-secondary" /></div>
|
||||
</div>
|
||||
</form>
|
@ -1,78 +0,0 @@
|
||||
@using CarCenterContracts.ViewModels
|
||||
@model List<OrderViewModel>
|
||||
@{
|
||||
ViewData["Title"] = "Orders";
|
||||
}
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Заказы</h1>
|
||||
</div>
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h2 class="display-4">Надо войти в аккаунт.</h2>
|
||||
return;
|
||||
}
|
||||
<p>
|
||||
<a class="text-decoration-none me-3 text-black h5" asp-action="Create">Создать заказ</a>
|
||||
<a class="text-decoration-none me-3 text-black h5" asp-action="Update">Изменить заказ</a>
|
||||
<a class="text-decoration-none text-black h5" asp-action="Delete">Удалить заказ</a>
|
||||
</p>
|
||||
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
Номер заказа
|
||||
</th>
|
||||
<th>
|
||||
Имя работника
|
||||
</th>
|
||||
<th>
|
||||
Тип оплаты
|
||||
</th>
|
||||
<th>
|
||||
Статус оплаты
|
||||
</th>
|
||||
<th>
|
||||
Фио покупателя
|
||||
</th>
|
||||
<th>
|
||||
Дата оплаты
|
||||
</th>
|
||||
<th>
|
||||
Сумма
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var order in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => order.Id)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => order.WorkerName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => order.PaymentType)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => order.PaymentStatus)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => order.BuyerFCS)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => order.PaymentDate)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => order.Sum)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</div>
|
Loading…
Reference in New Issue
Block a user