Emp report

This commit is contained in:
Илья Федотов 2024-07-28 13:06:28 +04:00
parent ce4076cddd
commit 20ce7a36f9
7 changed files with 143 additions and 4 deletions

View File

@ -101,7 +101,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
_logger.LogInformation($"CostItem. ID:{model.ID}.EmployeeID:{model.EmployeeID}.Name:{model.Name}.Price:{model.Price}" +
$"CostNum:{model.CostNum}");
var element = _storage.GetElement(new CostItemSearchModel { Name = model.Name });
if (element != null && element.Name == model.Name)
if (element != null && element.ID != model.ID)
{
throw new InvalidOperationException("Такая статья затрат уде есть");
}

View File

@ -12,7 +12,7 @@ namespace ElectronicsShopDataBaseImplement
optionsBuilder)
{
if (optionsBuilder.IsConfigured == false) {
optionsBuilder.UseSqlServer(@"Data Source=WIN-S7AOPVO8GAA\SQLEXPRESS;Initial Catalog=ElectronicsShopDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
optionsBuilder.UseSqlServer(@"Data Source=WIN-4HUIDGH3G02\SQLEXPRESS;Initial Catalog=ElectronicsShopDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
}
base.OnConfiguring(optionsBuilder);
}

View File

@ -287,7 +287,7 @@ namespace ElectronicsShopEmployeeApp.Controllers {
ProductName = name,
Price = Calc(costitem, productprice)
});
Response.Redirect("Index");
Response.Redirect("/Home/Index");
}
[HttpGet]
@ -314,5 +314,31 @@ namespace ElectronicsShopEmployeeApp.Controllers {
}
return product.Price + (_costItem?.Price ?? 0);
}
}
[HttpGet]
public IActionResult Report() {
if (APIEmployee.Employee == null) {
return RedirectToAction("~/Home/Index");
}
return View();
}
[HttpPost]
public void Report(DateTime DateFrom, DateTime DateTo) {
if (DateTo == DateTime.MinValue || DateFrom > DateTo) {
throw new Exception("Íåêîðåêòíî óêàçàí âðåìåííîé èíòåðâàë");
}
Response.Redirect($"ReportSearch?_datefrom={DateFrom}&_dateto={DateTo + DateTime.Now.TimeOfDay}");
}
[HttpGet]
public IActionResult ReportSearch(string _datefrom, string _dateto) {
var reports = APIEmployee.GetRequset<List<PaymeantViewModel>>($"api/client/getreport?_start={_datefrom}&_end={_dateto}");
(DateTime, DateTime, List<PaymeantViewModel>?) tuple = (DateTime.Parse(_datefrom), DateTime.Parse(_dateto), reports);
return View(tuple);
}
}
}

View File

@ -0,0 +1,26 @@
@{
ViewData["Title"] = "Report";
}
<div class="text-center">
<h2 class="display-4">Отчёты</h2>
</div>
<form method="post">
<div class="align-content-center row mb-3">
<div class="col-sm-auto">
<label>С:</label>
</div>
<div class="col-3">
<input name="DateFrom" id="datefrom" type="date" />
</div>
<div class="col-sm-auto">
<label>По:</label>
</div>
<div class="col-3">
<input name="DateTo" id="dateto" type="date" />
</div>
<div class="row">
<div class="col-8"></div>
<div class="col-4"><input type="submit" value="Cформировать отчет" class="btn btn-primary" /></div>
</div>
</div>
</form>

View File

@ -0,0 +1,83 @@
@using ElectronicsShopContracts.ViewModels
@model (DateTime, DateTime, List<PaymeantViewModel>)
@{
ViewData["Title"] = "Reports";
}
<div class="text-center">
<h1 class="row align-items-center mb-3">
<div class="text-center">
<label>Отчет по оплатам:</label>
</div>
<div class="col-sm-auto">
<label>С:</label>
</div>
<div class="col-sm-auto">
<input name="DateFrom" id="datefrom" type="text" value="@Model.Item1.Date.ToString("d")" readonly />
</div>
<div class="col-sm-auto">
<label>По:</label>
</div>
<div class="col-sm-auto">
<input name="DateTo" id="dateto" type="text" value="@Model.Item2.Date.ToString("d")" readonly />
</div>
<div class="row">
<div class="col-8">
<a class="btn btn-primary btn-sm" asp-action="CreateWordReport" style="background-color:#335a95;">Экспорт отчета в .xlsx</a>
<a class="btn btn-primary btn-sm" asp-action="CreateExcelReport" style="background-color:#04713A;">Экспорт отчета в .docx</a>
<a class="btn btn-primary btn-sm" asp-action="CreatePdfReport" asp-route-DateFrom="@Model.Item1"
asp-route-DateTo="@Model.Item2" style="background-color:#ad0d09;">отправить на Email отчет в .pdf</a>
</div>
</h1>
</div>
<div class="text-center">
@{
<table class="table">
<thead>
<tr>
<th>
Номер оплаты
</th>
<th>
Номер заказа
</th>
<th>
Статус оплаты
</th>
<th>
Сумма оплаты
</th>
<th>
Дата оплаты
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.Item3) {
<tr>
<th>
@Html.DisplayFor(modelItem => item.ID)
</th>
<th>
@Html.DisplayFor(modelItem => item.OrderID)
</th>
<th>
@Html.DisplayFor(modelItem => item.PayOption)
</th>
<th>
@Html.DisplayFor(modelItem => item.SumPayment)
</th>
<th>
@Html.DisplayFor(modelItem => item.DatePaymeant)
</th>
</tr>
}
</tbody>
</table>
}
</div>

View File

@ -34,6 +34,9 @@
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="CostItem">Статьи затрат</a>
</li>
<li class="nav-item">
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Report">Отчёты</a>
</li>
</ul>
</div>
</div>

View File

@ -46,6 +46,7 @@ namespace ElectronicsShopRestAPI.Controllers {
throw;
}
}
[HttpGet]
public ProductViewModel? GetProduct(int? _productID, int? _costitemID)
{