АААААААААААААААААААААААААААА....
Процедуры и заказы для отчетов... Хотя это совершенно неверно....
This commit is contained in:
parent
9581aaa847
commit
25b20e8f80
@ -12,7 +12,7 @@ namespace BeautyStudioContracts.SearchModels
|
||||
public string ProcedureName { get; set; } = string.Empty;
|
||||
public string ProcedureDescription { get; set; } = string.Empty;
|
||||
public int? StoreKeeperId { get; set; }
|
||||
public int? ComseticId { get; set; }
|
||||
public int? CosmeticId { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,8 @@ using BeautyStudioDataModels.Enums;
|
||||
using BeautyStudioDatabaseImplement.Models;
|
||||
using StoreKeeperWebApp.Models;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using System.Globalization;
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
|
||||
namespace StoreKeeperWebApp.Controllers
|
||||
{
|
||||
@ -94,7 +96,7 @@ namespace StoreKeeperWebApp.Controllers
|
||||
[HttpGet]
|
||||
public IActionResult CreateService(int id)
|
||||
{
|
||||
var procedures = _data.GetProcedures();
|
||||
var procedures = _data.GetProcedures(UserStoreKeeper.user.Id);
|
||||
ViewBag.AllProcedures = procedures;
|
||||
if (id != 0)
|
||||
{
|
||||
@ -107,7 +109,7 @@ namespace StoreKeeperWebApp.Controllers
|
||||
[HttpPost]
|
||||
public IActionResult CreateService(ServiceBindingModel model, int[] procedureIds)
|
||||
{
|
||||
var procedures = _data.GetProcedures();
|
||||
var procedures = _data.GetProcedures(UserStoreKeeper.user.Id);
|
||||
if (model.Id == 0)
|
||||
{
|
||||
model.DateCreate = DateTime.UtcNow;
|
||||
@ -134,7 +136,119 @@ namespace StoreKeeperWebApp.Controllers
|
||||
return View();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[HttpGet]
|
||||
public IActionResult IndexProcedure()
|
||||
{
|
||||
if (UserStoreKeeper.user != null)
|
||||
{
|
||||
var procedures = _data.GetProcedures(UserStoreKeeper.user.Id);
|
||||
return View(procedures);
|
||||
}
|
||||
return RedirectToAction("IndexNonReg");
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult IndexProcedure(int id)
|
||||
{
|
||||
_data.DeleteProcedures(id);
|
||||
return RedirectToAction("IndexProcedure");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult CreateProcedure(int id)
|
||||
{
|
||||
var services = _data.GetServices(UserStoreKeeper.user.Id);
|
||||
ViewBag.AllServices = services;
|
||||
if (id != 0)
|
||||
{
|
||||
var value = _data.GetProcedure(id);
|
||||
if (value != null)
|
||||
return View(value);
|
||||
}
|
||||
return View(new ProcedureViewModel());
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult CreateProcedure(ProcedureBindingModel model, int[] serviceIds)
|
||||
{
|
||||
var services = _data.GetServices(UserStoreKeeper.user.Id);
|
||||
for (int i = 0; i < serviceIds.Length; i++)
|
||||
{
|
||||
var service = services!.FirstOrDefault(x => x.Id == serviceIds[i])!;
|
||||
model.ProcedureServices.Add(i, service);
|
||||
}
|
||||
model.StoreKeeperId = UserStoreKeeper.user!.Id;
|
||||
bool changed = false;
|
||||
if (model.ProcedureServices.Count > 0)
|
||||
{
|
||||
if (model.Id != 0)
|
||||
{
|
||||
changed = _data.UpdateProcedures(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
changed = _data.CreateProcedure(model);
|
||||
}
|
||||
}
|
||||
if (changed)
|
||||
return RedirectToAction("IndexProcedure");
|
||||
else
|
||||
{
|
||||
ViewBag.AllServices = services;
|
||||
return View(model);
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult IndexOrder()
|
||||
{
|
||||
if (UserStoreKeeper.user != null)
|
||||
{
|
||||
var orders = _data.GetOrders(UserStoreKeeper.user.Id);
|
||||
return View(orders);
|
||||
}
|
||||
return RedirectToAction("IndexNonReg");
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult IndexOrder(int id)
|
||||
{
|
||||
_data.DeleteOrders(id);
|
||||
return RedirectToAction("IndexOrder");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult CreateOrder(int id)
|
||||
{
|
||||
var cosmetics = _data.GetCosmetics(UserStoreKeeper.user.Id);
|
||||
var procedures = _data.GetProcedures(UserStoreKeeper.user!.Id);
|
||||
ViewBag.AllCosmetics = cosmetics;
|
||||
ViewBag.AllProcedures = procedures;
|
||||
if (id != 0)
|
||||
{
|
||||
var value = _data.GetOrder(id);
|
||||
if (value != null)
|
||||
return View(value);
|
||||
}
|
||||
return View(new OrderViewModel());
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult CreateOrder(OrderBindingModel model, int[] cosmeticIds, int[] procedureIds, string Sum)
|
||||
{
|
||||
var cosmetics = _data.GetCosmetics(UserStoreKeeper.user.Id);
|
||||
for (int i = 0; i < cosmeticIds.Length; i++)
|
||||
{
|
||||
var cosmetic = cosmetics!.FirstOrDefault(x => x.Id == cosmeticIds[i])!;
|
||||
model.Cosmetics.Add(i, cosmetic);
|
||||
}
|
||||
var procedures = _data.GetProcedures(UserStoreKeeper.user!.Id);
|
||||
for (int i = 0; i < procedureIds.Length; i++)
|
||||
{
|
||||
var procedure = procedures!.FirstOrDefault(x => x.Id == procedureIds[i])!;
|
||||
model.OrderProcedures.Add(i, procedure);
|
||||
}
|
||||
model.StoreKeeperId = UserStoreKeeper.user!.Id;
|
||||
model.Sum = double.Parse(Sum, CultureInfo.InvariantCulture);
|
||||
ViewBag.AllCosmetics = cosmetics;
|
||||
return View(model);
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult IndexLaborCost()
|
||||
{
|
||||
if (UserStoreKeeper.user != null)
|
||||
|
@ -9,6 +9,7 @@ using BeautyStudioDatabaseImplement.Models;
|
||||
using System.Linq;
|
||||
using BeautyStudioDataModels.Models;
|
||||
using BeautyStudioBusinessLogic.BusinessLogic;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
|
||||
namespace StoreKeeperWebApp
|
||||
{
|
||||
@ -124,15 +125,46 @@ namespace StoreKeeperWebApp
|
||||
{
|
||||
return _cosmeticLogic.Delete(new() { Id = cosmeticId });
|
||||
}
|
||||
public List<ProcedureViewModel>? GetProcedures()
|
||||
public ProcedureViewModel? GetProcedure(int id)
|
||||
{
|
||||
return _procedureLogic.ReadElement(new() { Id = id });
|
||||
}
|
||||
public List<ProcedureViewModel>? GetProcedures(int userId)
|
||||
{
|
||||
return _procedureLogic.ReadList(null);
|
||||
return _procedureLogic.ReadList(new ProcedureSearchModel() { StoreKeeperId = userId });
|
||||
}
|
||||
public List<OrderViewModel>? GetOrders()
|
||||
public bool CreateProcedure(ProcedureBindingModel model)
|
||||
{
|
||||
return _orderLogic.ReadList(null);
|
||||
return _procedureLogic.Create(model);
|
||||
}
|
||||
public bool UpdateProcedures(ProcedureBindingModel model)
|
||||
{
|
||||
return _procedureLogic.Update(model);
|
||||
}
|
||||
public bool DeleteProcedures(int procedureId)
|
||||
{
|
||||
return _procedureLogic.Delete(new() { Id = procedureId });
|
||||
}
|
||||
public OrderViewModel? GetOrder(int id)
|
||||
{
|
||||
return _orderLogic.ReadElement(new() { Id = id });
|
||||
}
|
||||
public List<OrderViewModel>? GetOrders(int userId)
|
||||
{
|
||||
return _orderLogic.ReadList(new OrderSearchModel() { StoreKeeperId = userId });
|
||||
}
|
||||
public bool CreateOrders(OrderBindingModel model)
|
||||
{
|
||||
return _orderLogic.Create(model);
|
||||
}
|
||||
public bool UpdateOrders(OrderBindingModel model)
|
||||
{
|
||||
return _orderLogic.Update(model);
|
||||
}
|
||||
public bool DeleteOrders(int orderId)
|
||||
{
|
||||
return _orderLogic.Delete(new() { Id = orderId });
|
||||
}
|
||||
|
||||
public List<ReportServicesViewModel> GetTimeReport(DateTime? startDate, DateTime? endDate, int UserId)
|
||||
{
|
||||
var services = _serviceLogic.ReadList(new() { DateCreate = startDate, DateComplete = endDate, StoreKeeperId = UserId });
|
||||
|
226
BeautyStudio/StoreKeeperWebApp/Views/Home/CreateOrder.cshtml
Normal file
226
BeautyStudio/StoreKeeperWebApp/Views/Home/CreateOrder.cshtml
Normal file
@ -0,0 +1,226 @@
|
||||
@using BeautyStudioContracts.ViewModels;
|
||||
@using BeautyStudioDataModels.Enums;
|
||||
|
||||
@model OrderViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "CreateOrder";
|
||||
ViewBag.Procedures = Model.OrderProcedures;
|
||||
ViewBag.Cosmetics = Model.Cosmetics;
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание заказа</h2>
|
||||
</div>
|
||||
<form id="orderForm" method="post">
|
||||
<div class="container">
|
||||
<div>Процедуры</div>
|
||||
<div class="table-responsive-lg">
|
||||
<table id="proceduresTable" class="display">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID процедуры</th>
|
||||
<th> </th>
|
||||
<th>Стоимость</th>
|
||||
<th> </th>
|
||||
<th>Удалить</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var procedure in ViewBag.Procedures)
|
||||
{
|
||||
<tr data-procedure-id="@procedure.Value.Id">
|
||||
<td>
|
||||
<input type="hidden" name="procedureIds" value="@procedure.Value.Id" />@procedure.Value.Id
|
||||
</td>
|
||||
<th> </th>
|
||||
<td class="procedure-price" data-price="@procedure.Value.ProcedureCost">@procedure.Value.ProcedureCost</td>
|
||||
<th> </th>
|
||||
<td><button type="button" class="deleteProcedure" data-bundling-id="@procedure.Value.Id">Удалить</button></td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<select id="procedureSelect" class="form-control">
|
||||
<option value="">Выберите процедуру</option>
|
||||
@foreach (var procedure in ViewBag.AllProcedures)
|
||||
{
|
||||
<option value="@procedure.Id" data-price="@procedure.ProcedureCost">@procedure.ProcedureName</option>
|
||||
}
|
||||
</select>
|
||||
<button type="button" id="addProcedure" class="btn btn-secondary">Добавить процедуру</button>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="container">
|
||||
<div>Косметика</div>
|
||||
<div class="table-responsive-lg">
|
||||
<table id="cosmeticsTable" class="display">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID косметики</th>
|
||||
<th> </th>
|
||||
<th>Стоимость</th>
|
||||
<th> </th>
|
||||
<th>Удалить</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var cosmetic in ViewBag.Cosmetics)
|
||||
{
|
||||
<tr data-cosmetic-id="@cosmetic.Value.Id">
|
||||
<td>
|
||||
<input type="hidden" name="cosmeticIds" value="@cosmetic.Value.Id" />@cosmetic.Value.Id
|
||||
</td>
|
||||
<th> </th>
|
||||
<td class="cosmetic-price" data-price="@cosmetic.Value.CosmeticPrice">@cosmetic.Value.CosmeticPrice</td>
|
||||
<th> </th>
|
||||
<td><button type="button" class="deleteCosmetic" data-cosmetic-id="@cosmetic.Value.Id">Удалить</button></td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<select id="cosmeticSelect" class="form-control">
|
||||
<option value="">Выберите косметику</option>
|
||||
@foreach (var cosmetic in ViewBag.AllCosmetics)
|
||||
{
|
||||
<option value="@cosmetic.Id" data-price="@cosmetic.CosmeticPrice">@cosmetic.CosmeticName</option>
|
||||
}
|
||||
</select>
|
||||
<button type="button" id="addCosmetic" 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;
|
||||
$('#proceduresTable tbody tr').each(function () {
|
||||
var pricebd = $(this).find('.procedure-price').data('price');
|
||||
Sum += parseFloat(pricebd);
|
||||
});
|
||||
$('#cosmeticsTable tbody tr').each(function () {
|
||||
var pricecosmetic = $(this).find('.cosmetic-price').data('price');
|
||||
Sum += parseFloat(pricecosmetic);
|
||||
});
|
||||
$('#Sum').val(Sum.toFixed(2));
|
||||
}
|
||||
|
||||
$(document).on('click', '.deleteCosmetic', function () {
|
||||
var row = $(this).closest('tr');
|
||||
row.remove();
|
||||
updateSum();
|
||||
});
|
||||
$(document).on('click', '.deleteProcedure', function () {
|
||||
var row = $(this).closest('tr');
|
||||
row.remove();
|
||||
updateSum();
|
||||
});
|
||||
$('#addProcedure').click(function () {
|
||||
var selectedProcedure = $('#procedureSelect option:selected');
|
||||
if (selectedProcedure.val()) {
|
||||
var procedureId = selectedProcedure.val();
|
||||
var exists = false;
|
||||
$('#proceduresTable tbody tr').each(function () {
|
||||
if ($(this).data('procedure-id') == procedureId) {
|
||||
exists = true;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (exists) {
|
||||
alert('Эта процедура уже добавлена.');
|
||||
return;
|
||||
}
|
||||
|
||||
var procedureName = selectedProcedure.text();
|
||||
var procedurePrice = selectedProcedure.data('price');
|
||||
|
||||
var newRow = `
|
||||
<tr data-procedure-id="${procedureId}">
|
||||
<td>
|
||||
<input type="hidden" name="procedureIds" value="${procedureId}" />
|
||||
${procedureId}
|
||||
</td>
|
||||
<th> </th>
|
||||
<td class="procedure-price" data-price="${procedurePrice}">${procedurePrice}</td>
|
||||
<th> </th>
|
||||
<td><button type="button" class="deleteProcedure" data-procedure-id="${procedureId}">Удалить</button></td>
|
||||
</tr>
|
||||
`;
|
||||
$('#proceduresTable tbody').append(newRow);
|
||||
|
||||
$('.deleteProcedure').off('click').on('click', function () {
|
||||
var row = $(this).closest('tr');
|
||||
row.remove();
|
||||
updateSum();
|
||||
});
|
||||
|
||||
$('#procedureSelect').val('');
|
||||
|
||||
updateSum();
|
||||
} else {
|
||||
alert('Выберите процедуру для добавления');
|
||||
}
|
||||
});
|
||||
$('#addCosmetic').click(function () {
|
||||
var selectedCosmetic = $('#cosmeticSelect option:selected');
|
||||
if (selectedCosmetic.val()) {
|
||||
var cosmeticId = selectedCosmetic.val();
|
||||
var exists = false;
|
||||
$('#cosmeticsTable tbody tr').each(function () {
|
||||
if ($(this).data('cosmetic-id') == cosmeticId) {
|
||||
exists = true;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (exists) {
|
||||
alert('Эта косметика уже добавлена.');
|
||||
return;
|
||||
}
|
||||
|
||||
var cosmeticName = selectedCosmetic.text();
|
||||
var cosmeticPrice = selectedCosmetic.data('price');
|
||||
|
||||
var newRow = `
|
||||
<tr data-cosmetic-id="${cosmeticId}">
|
||||
<td>
|
||||
<input type="hidden" name="cosmeticIds" value="${cosmeticId}" />
|
||||
${cosmeticId}
|
||||
</td>
|
||||
<th> </th>
|
||||
<td class="cosmetic-price" data-price="${cosmeticPrice}">${cosmeticPrice}</td>
|
||||
<th> </th>
|
||||
<td><button type="button" class="deleteCosmetic" data-cosmetic-id="${cosmeticId}">Удалить</button></td>
|
||||
</tr>
|
||||
`;
|
||||
$('#cosmeticsTable tbody').append(newRow);
|
||||
|
||||
$('.deleteCosmetic').off('click').on('click', function () {
|
||||
var row = $(this).closest('tr');
|
||||
row.remove();
|
||||
updateSum();
|
||||
});
|
||||
|
||||
$('#cosmeticSelect').val('');
|
||||
|
||||
updateSum();
|
||||
} else {
|
||||
alert('Выберите косметику для добавления');
|
||||
}
|
||||
});
|
||||
|
||||
updateSum();
|
||||
});
|
||||
</script>
|
||||
|
181
BeautyStudio/StoreKeeperWebApp/Views/Home/CreateProcedure.cshtml
Normal file
181
BeautyStudio/StoreKeeperWebApp/Views/Home/CreateProcedure.cshtml
Normal file
@ -0,0 +1,181 @@
|
||||
@using BeautyStudioContracts.ViewModels;
|
||||
@using BeautyStudioDataModels.Enums;
|
||||
|
||||
@model ProcedureViewModel
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "CreateProcedure";
|
||||
ViewBag.Services = Model.ProcedureServices;
|
||||
}
|
||||
<div class="text-center">
|
||||
<h2 class="display-4">Создание процедуры</h2>
|
||||
</div>
|
||||
<form id="procedureForm" method="post">
|
||||
@if (Model.Id != 0){
|
||||
<h3 class="display-4">Авторизируйтесь</h3>
|
||||
return;
|
||||
}
|
||||
<div class="row">
|
||||
<div class="col-4">Название:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="ProcedureName" id="ProcedureName" value="@Model.ProcedureName" />
|
||||
<span id="ProcedureNameError" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Описание:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="ProcedureDescription" id="ProcedureDescription" value="@Model.ProcedureDescription" />
|
||||
<span id="ProcedureDescriptionError" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-4">Цена процедуры:</div>
|
||||
<div class="col-8">
|
||||
<input type="text" name="ProcedureCost" id="ProcedureCost" value="@Model.ProcedureCost" />
|
||||
<span id="PriceError" class="text-danger"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="container">
|
||||
<div>Услуги</div>
|
||||
<div class="table-responsive-lg">
|
||||
<table id="servicesTable" class="display">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID услуги</th>
|
||||
<th> </th>
|
||||
<th>Стоимость</th>
|
||||
<th> </th>
|
||||
<th>Удалить</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var service in ViewBag.Services)
|
||||
{
|
||||
<tr data-service-id="@service.Value.Id">
|
||||
<td>
|
||||
<input type="hidden" name="serviceIds" value="@service.Value.Id" />@service.Value.Id
|
||||
</td>
|
||||
<th> </th>
|
||||
<td class="service-price" data-price="@service.Value.ServicePrice">@service.Value.ServicePrice</td>
|
||||
<th> </th>
|
||||
<td><button type="button" class="deleteService" data-service-id="@service.Value.Id">Удалить</button></td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<select id="serviceSelect" class="form-control">
|
||||
<option value="">Выберите услугу</option>
|
||||
@foreach (var service in ViewBag.AllServices)
|
||||
{
|
||||
<option value="@service.Id" data-price="@service.ServicePrice">@service.ServiceName</option>
|
||||
}
|
||||
</select>
|
||||
<button type="button" id="addService" 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;
|
||||
$('#servicesTable tbody tr').each(function () {
|
||||
var price = $(this).find('.service-price').data('price');
|
||||
sum += parseFloat(price);
|
||||
});
|
||||
var procedurePrice = parseFloat($('#Price').val());
|
||||
if (!isNaN(procedurePrice)) {
|
||||
sum += procedurePrice;
|
||||
}
|
||||
$('#sum').val(sum.toFixed(2));
|
||||
}
|
||||
|
||||
$(document).on('click', '.deleteService', function () {
|
||||
var row = $(this).closest('tr');
|
||||
row.remove();
|
||||
updateSum();
|
||||
});
|
||||
|
||||
$('#addService').click(function () {
|
||||
var selectedService = $('#serviceSelect option:selected');
|
||||
if (selectedService.val()) {
|
||||
var serviceId = selectedService.val();
|
||||
var exists = false;
|
||||
$('#servicesTable tbody tr').each(function () {
|
||||
if ($(this).data('service-id') == serviceId) {
|
||||
exists = true;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if (exists) {
|
||||
alert('Эта услуга уже добавлена.');
|
||||
return;
|
||||
}
|
||||
|
||||
var serviceName = selectedService.text();
|
||||
var servicePrice = selectedService.data('price');
|
||||
|
||||
var newRow = `
|
||||
<tr data-service-id="${serviceId}">
|
||||
<td>
|
||||
<input type="hidden" name="serviceIds" value="${serviceId}" />
|
||||
${serviceId}
|
||||
</td>
|
||||
<th> </th>
|
||||
<td class="service-price" data-price="${servicePrice}">${servicePrice}</td>
|
||||
<th> </th>
|
||||
<td><button type="button" class="deleteService" data-service-id="${serviceId}">Удалить</button></td>
|
||||
</tr>
|
||||
`;
|
||||
$('#servicesTable tbody').append(newRow);
|
||||
|
||||
$('.deleteService').off('click').on('click', function () {
|
||||
var row = $(this).closest('tr');
|
||||
row.remove();
|
||||
updateSum();
|
||||
});
|
||||
|
||||
$('#serviceSelect').val('');
|
||||
|
||||
updateSum();
|
||||
} else {
|
||||
alert('Выберите услугу для добавления');
|
||||
}
|
||||
});
|
||||
|
||||
$('#procedureForm').submit(function (event) {
|
||||
var ProcedureDescription = $('#ProcedureDescription').val();
|
||||
var ProcedureName = $('#ProcedureName').val();
|
||||
var Price = $('#Price').val();
|
||||
var isValid = true;
|
||||
|
||||
$('#ProcedureDescriptionError').text('');
|
||||
$('#ProcedureNameError').text('');
|
||||
$('#PriceError').text('');
|
||||
var totalServices = $('#servicesTable tbody tr').length;
|
||||
if (totalServices == 0) {
|
||||
alert('Пожалуйста, добавьте хотя бы одну услугу.');
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (!isValid) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
updateSum();
|
||||
});
|
||||
</script>
|
||||
|
54
BeautyStudio/StoreKeeperWebApp/Views/Home/IndexOrder.cshtml
Normal file
54
BeautyStudio/StoreKeeperWebApp/Views/Home/IndexOrder.cshtml
Normal file
@ -0,0 +1,54 @@
|
||||
@using BeautyStudioContracts.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>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var item in Model)
|
||||
{
|
||||
<tr>
|
||||
<td>@Html.DisplayFor(modelItem => item.Id)</td>
|
||||
<td>@Html.DisplayFor(modelItem => item.PaymentDate)</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>
|
@ -0,0 +1,76 @@
|
||||
@using BeautyStudioContracts.ViewModels;
|
||||
|
||||
@model List<ProcedureViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Procedures";
|
||||
}
|
||||
|
||||
<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="CreateProcedure" asp-route-id="0">Создать процедуру</a>
|
||||
</p>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<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.ProcedureName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ProcedureDescription)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.ProcedureCost)
|
||||
</td>
|
||||
<td>
|
||||
<a asp-action="CreateProcedure" 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>
|
@ -46,6 +46,14 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Logout">Выйти из аккаунта</a>
|
||||
</li>
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="IndexProcedure">Создание процедуры (пример)</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="IndexOrder">Создание заказа (пример)</a>
|
||||
</li>
|
||||
</ul>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user