client is done
This commit is contained in:
parent
e3fda489a5
commit
e9041926ab
@ -116,12 +116,7 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
|
||||
}
|
||||
|
||||
// Получение списка товаров с указанием, в какие оплаты товар входит
|
||||
public List<ReportPaymeantProductsViewModel> GetPaymeantProducts(ReportBindingModel model) {
|
||||
var paymeants = _paymeantstorage.GetFillteredList(new PaymeantSearchModel {
|
||||
ClientID = model.ClientID,
|
||||
DateFrom = model.DateFrom,
|
||||
DateTo = model.DateTo,
|
||||
});
|
||||
public List<ReportPaymeantProductsViewModel> GetPaymeantProducts(List<PaymeantViewModel> paymeants) {
|
||||
|
||||
var list = new List<ReportPaymeantProductsViewModel>();
|
||||
|
||||
@ -150,14 +145,12 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
|
||||
return list;
|
||||
}
|
||||
|
||||
public byte[]? SavePaymeantToExcelFile(ReportBindingModel model)
|
||||
public byte[]? SavePaymeantToExcelFile(List<PaymeantViewModel> paymeants)
|
||||
{
|
||||
var document = _saveToExcel.CreateReport(new ExcelInfoClient
|
||||
{
|
||||
Title = "Список оплат и товаров",
|
||||
PaymeantProducts = GetPaymeantProducts(model),
|
||||
DateFrom = model.DateFrom,
|
||||
DateTo = model.DateTo
|
||||
PaymeantProducts = GetPaymeantProducts(paymeants),
|
||||
});
|
||||
return document;
|
||||
}
|
||||
|
@ -22,27 +22,21 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
|
||||
CellToName = "C1"
|
||||
});
|
||||
|
||||
InsertCellInWorksheet(new ExcelCellParameters {
|
||||
ColumnName = "A",
|
||||
RowIndex = 2,
|
||||
Text = $"С {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}",
|
||||
StyleInfo = ExcelStyleInfoType.Title
|
||||
});
|
||||
|
||||
MergeCells(new ExcelMergeParameters {
|
||||
CellFromName = "A2",
|
||||
CellToName = "F2"
|
||||
});
|
||||
|
||||
uint rowIndex = 3;
|
||||
uint rowIndex = 2;
|
||||
foreach (var pp in info.PaymeantProducts) {
|
||||
InsertCellInWorksheet(new ExcelCellParameters {
|
||||
ColumnName = "A",
|
||||
RowIndex = rowIndex,
|
||||
Text = pp.PaymeantID.ToString(),
|
||||
Text = $"Номер оплаты: {pp.PaymeantID}",
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
rowIndex++;
|
||||
|
||||
MergeCells(new ExcelMergeParameters {
|
||||
CellFromName = $"A{rowIndex}",
|
||||
CellToName = $"B{rowIndex}"
|
||||
});
|
||||
|
||||
rowIndex++;
|
||||
foreach (var (Product, Count, CostItem, Price) in pp.Products) {
|
||||
InsertCellInWorksheet(new ExcelCellParameters {
|
||||
ColumnName = "B",
|
||||
|
@ -24,14 +24,6 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
|
||||
}
|
||||
});
|
||||
|
||||
CreateParagraph(new WordParagraph {
|
||||
Texts = new List<(string, WordTextProperties)> { ($"С {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}",
|
||||
new WordTextProperties { Bold = true, Size = "24", }) },
|
||||
TextProperties = new WordTextProperties {
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Both
|
||||
}
|
||||
});
|
||||
List<int> PaymentsID = new List<int>();
|
||||
foreach (var pr in info.Products)
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ namespace ElectronicsShopContracts.BusinessLogicContracts
|
||||
public interface IReportClientLogic
|
||||
{
|
||||
// получение списка товаров с указанием, в какие оплаты товар входит
|
||||
List<ReportPaymeantProductsViewModel>? GetPaymeantProducts(ReportBindingModel model);
|
||||
List<ReportPaymeantProductsViewModel>? GetPaymeantProducts(List<PaymeantViewModel> paymeants);
|
||||
// получения списка оплат
|
||||
List<ReportPaymeantsViewModel>? GetPaymeants(ReportBindingModel model);
|
||||
|
||||
@ -21,7 +21,7 @@ namespace ElectronicsShopContracts.BusinessLogicContracts
|
||||
byte[]? SavePaymeantToWordFile(List<PaymeantViewModel> paymeants);
|
||||
|
||||
// Сохранение отчета оплат с товарами в .excel
|
||||
byte[]? SavePaymeantToExcelFile(ReportBindingModel model);
|
||||
byte[]? SavePaymeantToExcelFile(List<PaymeantViewModel> paymeants);
|
||||
|
||||
// Отчет оплаченных товаров в .pdf
|
||||
PdfDocument SaveProductToPdfFile(ReportBindingModel model);
|
||||
|
@ -187,13 +187,19 @@ namespace ElectronicsShopRestAPI.Controllers {
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public byte[]? CreateXlsxReport (int _clientID, string DateFrom, string DateTo) {
|
||||
public byte[]? CreateXlsxReport (string _ids) {
|
||||
try {
|
||||
var document = _reportLogic.SavePaymeantToExcelFile (new ReportBindingModel {
|
||||
ClientID = _clientID,
|
||||
DateFrom = DateTime.Parse(DateFrom),
|
||||
DateTo = DateTime.Parse(DateTo)
|
||||
});
|
||||
List<PaymeantViewModel> _paymeants = new();
|
||||
|
||||
foreach (char i in _ids) {
|
||||
if (int.TryParse(i.ToString(), out int id)) {
|
||||
var paymeant = _payLogic.ReadElement(new PaymeantSearchModel { ID = id }) ?? throw new Exception("Ошибка получения данных");
|
||||
_paymeants.Add(paymeant);
|
||||
}
|
||||
}
|
||||
|
||||
var document = _reportLogic.SavePaymeantToExcelFile(_paymeants);
|
||||
|
||||
return document;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
@ -324,15 +324,18 @@ namespace ElectronicsShopUserApp.Controllers {
|
||||
}
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(ids)) {
|
||||
throw new Exception("Íåò âûáðàííûõ îïëàò");
|
||||
}
|
||||
|
||||
(List<PaymeantViewModel>, string) tuple = (paymeantsFix, ids);
|
||||
|
||||
return View(tuple);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public IActionResult CreateExcelReport(string DateFrom, string DateTo) {
|
||||
var fileMemStream = APIClient.GetRequset<byte[]>($"api/Client/CreateXlsxReport?_clientID={APIClient.Client?.ID}&DateFrom={DateFrom}&" +
|
||||
$"DateTo={DateTo}");
|
||||
public IActionResult CreateExcelReport(string ids) {
|
||||
var fileMemStream = APIClient.GetRequset<byte[]>($"api/Client/CreateXlsxReport?_ids={ids}");
|
||||
|
||||
if (fileMemStream == null) {
|
||||
throw new Exception("Îøèáêà ñîçäàíèÿ îò÷åòà");
|
||||
|
@ -12,7 +12,7 @@
|
||||
</div>
|
||||
<div class="text-end">
|
||||
<a class="btn btn-primary btn-sm" asp-action="CreateWordReport" asp-route-ids ="@Model.Item2" style="background-color:#335a95;">Экспорт отчета в .docx</a>
|
||||
<a class="btn btn-primary btn-sm" asp-action="CreateExcelReport" style="background-color:#04713A;">Экспорт отчета в .xlsx</a>
|
||||
<a class="btn btn-primary btn-sm" asp-action="CreateExcelReport" asp-route-ids="@Model.Item2" style="background-color:#04713A;">Экспорт отчета в .xlsx</a>
|
||||
</div>
|
||||
</h1>
|
||||
</div>
|
||||
|
@ -10,9 +10,9 @@
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
|
||||
<nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light border-bottom box-shadow mb-3" style="background-color:#1e2126">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Магазин электроники (Клиент)</a>
|
||||
<a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index" style="color:whitesmoke">Магазин электроники (Клиент)</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target=".navbar-collapse" aria-controls="navbarSupportedContent"
|
||||
aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
@ -20,22 +20,22 @@
|
||||
<div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
|
||||
<ul class="navbar-nav flex-grow-1">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Заказы</a>
|
||||
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="Index" style="color:whitesmoke">Заказы</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
||||
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="Privacy" style="color:whitesmoke">Личные данные</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Enter">Вход</a>
|
||||
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="Enter" style="color:whitesmoke">Вход</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Register">Регистрация</a>
|
||||
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="Register" style="color:whitesmoke">Регистрация</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Orders">Корзины</a>
|
||||
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="Orders" style="color:whitesmoke">Корзины</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Report">Отчёты</a>
|
||||
<a class="nav-link" asp-area="" asp-controller="Home" asp-action="Report" style="color:whitesmoke">Отчёты</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user