Compare commits

...

2 Commits

5 changed files with 111 additions and 4 deletions

View File

@ -12,6 +12,11 @@ namespace BankBusinessLogic.OfficePackage
{ {
public MemoryStream CreateOperatorDoc(PdfInfo info) public MemoryStream CreateOperatorDoc(PdfInfo info)
{ {
if (info.Transfers == null)
{
throw new ArgumentNullException("Данные для отчёта отсутсвуют!", nameof(info.Transfers));
}
CreatePdf(info); CreatePdf(info);
CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center });
CreateParagraph(new PdfParagraph { Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); CreateParagraph(new PdfParagraph { Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center });

View File

@ -17,6 +17,6 @@ namespace BankBusinessLogic.OfficePackage.HelperModels
public DateTime DateTo { get; set; } public DateTime DateTo { get; set; }
public List<ReportTransferCurrencyPurchaseViewModel> Transfers { get; set; } = new(); public List<ReportTransferCurrencyPurchaseViewModel>? Transfers { get; set; } = new();
} }
} }

View File

@ -101,12 +101,14 @@ namespace OperatorApp.Controllers
{ {
if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password)) if (string.IsNullOrEmpty(login) || string.IsNullOrEmpty(password))
{ {
throw new Exception("Введите логин и пароль"); Response.WriteAsync($"<script language=\"javascript\">alert('Input login and password!');window.location.replace('/Home/Enter');</script>");
return;
} }
APIClient.Operator = _operatorLogic.ReadElement(new OperatorSearchModel { Login = login, Password = password }); APIClient.Operator = _operatorLogic.ReadElement(new OperatorSearchModel { Login = login, Password = password });
if (APIClient.Operator == null) if (APIClient.Operator == null)
{ {
throw new Exception("Неверный логин/пароль"); Response.WriteAsync($"<script language=\"javascript\">alert('Wrong login or password!');window.location.replace('/Home/Enter');</script>");
return;
} }
Response.Redirect("Index"); Response.Redirect("Index");
} }
@ -329,5 +331,17 @@ namespace OperatorApp.Controllers
Response.Redirect("/"); Response.Redirect("/");
} }
} }
public IActionResult ViewReport(DateTime dateFrom, DateTime dateTo)
{
if (APIClient.Operator == null)
{
Response.WriteAsync($"<script language=\"javascript\">alert('You need to login!');window.location.replace('/Home/Enter');</script>");
return Redirect("/Home/Enter");
}
ViewBag.DateFrom = dateFrom.ToShortDateString();
ViewBag.DateTo = dateTo.ToShortDateString();
return View(_reportLogic.GetTransferPurchase(new ReportBindingModel { DateFrom=dateFrom, DateTo = dateTo }));
}
} }
} }

View File

@ -7,7 +7,7 @@
<div class="text-center"> <div class="text-center">
<h2 class="display-4">Создание отчёта</h2> <h2 class="display-4">Создание отчёта</h2>
</div> </div>
<form method="post"> <form asp-action="ViewReport" method="get">
<div class="row"> <div class="row">
<div class="col-4">C:</div> <div class="col-4">C:</div>
<div class="col-8"> <div class="col-8">

View File

@ -0,0 +1,88 @@
@using BankContracts.ViewModels
@model List<ReportTransferCurrencyPurchaseViewModel>
@{
ViewData["Title"] = "View Report";
}
<div class="text-center">
<h1 class="display-4">Отчёт о зачислениях</h1>
<h1 class="display4">C @ViewBag.DateFrom по @ViewBag.DateTo</h1>
</div>
<div class="text-center">
@{
if (Model == null)
{
<h3 class="display-4">Авторизируйтесь</h3>
return;
}
<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>
Зачисление №@item.TransferId
</td>
<td>
@Html.DisplayFor(modelItem => item.TransferDate)
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
@foreach (var purchase in item.Purchases){
<tr>
<td>
</td>
<td>
</td>
<td>
Закупка №@purchase.Id
</td>
<td>
@Html.DisplayFor(modelItem => purchase.Amount)
</td>
<td>
@Html.DisplayFor(modelItem => purchase.CurrencyName)
</td>
<td>
@Html.DisplayFor(modelItem => purchase.PurchaseDate)
</td>
</tr>
}
}
</tbody>
</table>
}
</div>