Вывод отчёта кассира на форму.

This commit is contained in:
Programmist73 2023-05-19 11:35:31 +04:00
parent 1a2939880d
commit 52e55d4da4
6 changed files with 205 additions and 37 deletions

View File

@ -59,5 +59,25 @@ namespace BankYouBankruptCashierApp
throw new Exception(result); throw new Exception(result);
} }
} }
}
//Post-запрос для получения данных
public static T? PostRequestReport<T, U>(string requestUrl, U model)
{
var json = JsonConvert.SerializeObject(model);
var data = new StringContent(json, Encoding.UTF8, "application/json");
var response = _client.PostAsync(requestUrl, data);
var result = response.Result.Content.ReadAsStringAsync().Result;
if (response.Result.IsSuccessStatusCode)
{
return JsonConvert.DeserializeObject<T>(result);
}
else
{
throw new Exception(result);
}
}
}
} }

View File

@ -19,6 +19,8 @@ namespace BankYouBankruptCashierApp.Controllers
_logger = logger; _logger = logger;
} }
#region Загрузка главной страницы
//вытаскивает через API клиента Get-запросом список его собственных заказов //вытаскивает через API клиента Get-запросом список его собственных заказов
[HttpGet] [HttpGet]
public IActionResult Index() public IActionResult Index()
@ -31,8 +33,12 @@ namespace BankYouBankruptCashierApp.Controllers
return View(APICashier.GetRequest<List<AccountViewModel>>($"/api/Account/GetAllAccounts")); return View(APICashier.GetRequest<List<AccountViewModel>>($"/api/Account/GetAllAccounts"));
} }
//изменемение ланных Get-ом #endregion
[HttpGet]
#region Обновление данных пользователя
//изменемение ланных Get-ом
[HttpGet]
public IActionResult Privacy() public IActionResult Privacy()
{ {
if (APICashier.Cashier == null) if (APICashier.Cashier == null)
@ -81,7 +87,11 @@ namespace BankYouBankruptCashierApp.Controllers
Response.Redirect("Index"); Response.Redirect("Index");
} }
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] #endregion
#region Вывод ошибок
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error() public IActionResult Error()
{ {
return View(new ErrorViewModel return View(new ErrorViewModel
@ -90,8 +100,12 @@ namespace BankYouBankruptCashierApp.Controllers
}); });
} }
//просто открытие вьюхи #endregion
[HttpGet]
#region Вход в приложение
//просто открытие вьюхи
[HttpGet]
public IActionResult Enter() public IActionResult Enter()
{ {
return View(); return View();
@ -116,8 +130,12 @@ namespace BankYouBankruptCashierApp.Controllers
Response.Redirect("Index"); Response.Redirect("Index");
} }
//просто открытие вьюхи #endregion
[HttpGet]
#region Регистрация
//просто открытие вьюхи
[HttpGet]
public IActionResult Register() public IActionResult Register()
{ {
return View(); return View();
@ -149,6 +167,10 @@ namespace BankYouBankruptCashierApp.Controllers
return; return;
} }
#endregion
#region Открытие нового счёта
//открытие счёта. Получаем и передаём список изделий во вьюху? //открытие счёта. Получаем и передаём список изделий во вьюху?
[HttpGet] [HttpGet]
public IActionResult CreateAccount() public IActionResult CreateAccount()
@ -205,17 +227,9 @@ namespace BankYouBankruptCashierApp.Controllers
Response.Redirect("Index"); Response.Redirect("Index");
} }
//для страницы "Заявки на снятие" #endregion
[HttpGet]
public IActionResult Debiting()
{
if (APICashier.Cashier == null)
{
throw new Exception("Вы как сюда попали? Суда вход только авторизованным");
}
return View(APICashier.GetRequest<List<DebitingViewModel>>($"/api/Account/FindOpenDebiting")); #region Работа с заявками на зачисление
}
//для страницы "Заявки на зачисление" //для страницы "Заявки на зачисление"
[HttpGet] [HttpGet]
@ -284,6 +298,22 @@ namespace BankYouBankruptCashierApp.Controllers
Response.Redirect("Crediting"); Response.Redirect("Crediting");
} }
#endregion
#region Работа с заявками на снятие
//для страницы "Заявки на снятие"
[HttpGet]
public IActionResult Debiting()
{
if (APICashier.Cashier == null)
{
throw new Exception("Вы как сюда попали? Суда вход только авторизованным");
}
return View(APICashier.GetRequest<List<DebitingViewModel>>($"/api/Account/FindOpenDebiting"));
}
//открытие вьюхи одобрения заявки на снятие //открытие вьюхи одобрения заявки на снятие
[HttpGet] [HttpGet]
public IActionResult CloseDebiting() public IActionResult CloseDebiting()
@ -338,7 +368,9 @@ namespace BankYouBankruptCashierApp.Controllers
Response.Redirect("Debiting"); Response.Redirect("Debiting");
} }
//получение номера запрашиваемого счёта для снятия #endregion
//получение номера запрашиваемого счёта для снятия - для работы с начислениями и списаниями
[HttpPost] [HttpPost]
public string GetAccountNumber(int id) public string GetAccountNumber(int id)
{ {
@ -371,7 +403,9 @@ namespace BankYouBankruptCashierApp.Controllers
return AccountNumber; return AccountNumber;
} }
[HttpGet] #region Работа с переводом со счёта на счёт
[HttpGet]
public IActionResult MoneyTransfers() public IActionResult MoneyTransfers()
{ {
if (APICashier.Cashier == null) if (APICashier.Cashier == null)
@ -413,7 +447,11 @@ namespace BankYouBankruptCashierApp.Controllers
Response.Redirect("Index"); Response.Redirect("Index");
} }
[HttpGet] #endregion
#region Отчёт с выборкой по счетам
[HttpGet]
public IActionResult ReportWithAccounts() public IActionResult ReportWithAccounts()
{ {
if (APICashier.Cashier == null) if (APICashier.Cashier == null)
@ -459,9 +497,11 @@ namespace BankYouBankruptCashierApp.Controllers
return View(cashWithdrawals.Concat(moneyTransfers).OrderBy(x => x.DateOperation).ToList()); return View(cashWithdrawals.Concat(moneyTransfers).OrderBy(x => x.DateOperation).ToList());
} }
#region Получение отчёта PDF #endregion
[HttpGet] #region Получение отчёта PDF
[HttpGet]
public IActionResult CreateReport() public IActionResult CreateReport()
{ {
if (APICashier.Cashier == null) if (APICashier.Cashier == null)
@ -480,26 +520,33 @@ namespace BankYouBankruptCashierApp.Controllers
} }
[HttpPost] [HttpPost]
public void CreateReport(int clientId, DateTime dateFrom, DateTime dateTo) public IActionResult CreateReport(int clientId, DateTime dateFrom, DateTime dateTo)
{ {
if (APICashier.Cashier == null) if (APICashier.Cashier == null)
{ {
throw new Exception("Не авторизованы"); throw new Exception("Не авторизованы");
} }
APICashier.PostRequest("api/Report/CreateCashierReport", new ReportSupportBindingModel() //запрашиваем список в формате вспомогательной вьюшки из-за работы select в asp net
ViewBag.Clients = APICashier.GetRequest<List<ClientViewModel>>($"/api/Client/GetAllClients").Select(x => new ClientSelectViewModel
{ {
ClientId = clientId, Id = x.Id,
FullName = x.Surname + " " + x.Name + " " + x.Patronymic
}).ToList();
return View(APICashier.PostRequestReport<ReportCashierViewModelForHTML, ReportSupportBindingModel>("api/Report/CreateCashierReport", new ReportSupportBindingModel()
{
ClientId = clientId,
DateFrom = dateFrom, DateFrom = dateFrom,
DateTo = dateTo DateTo = dateTo
}); }));
Response.Redirect("Index");
} }
#endregion #endregion
[HttpGet] #region Диаграмма
[HttpGet]
public IActionResult Diagram() public IActionResult Diagram()
{ {
if (APICashier.Cashier == null) if (APICashier.Cashier == null)
@ -530,5 +577,7 @@ namespace BankYouBankruptCashierApp.Controllers
Elements = APICashier.GetRequest<List<CashierDiagramElementsViewModel>>($"api/Account/getAccountMonthResult?cardId={accountId}") Elements = APICashier.GetRequest<List<CashierDiagramElementsViewModel>>($"api/Account/getAccountMonthResult?cardId={accountId}")
}); });
} }
}
#endregion
}
} }

View File

@ -1,4 +1,8 @@
@{ @using BankYouBankruptContracts.ViewModels;
@model ReportCashierViewModelForHTML
@{
ViewData["Title"] = "Создание отчёта"; ViewData["Title"] = "Создание отчёта";
} }
@ -30,6 +34,97 @@
<input type="submit" value="Сформировать отчёт" class="btn btn-primary" /> <input type="submit" value="Сформировать отчёт" class="btn btn-primary" />
</div> </div>
</div> </div>
<hr class="mt-5 mb-3" />
@if (Model != null)
{
<div class="row p-3 text-center">
<h4>Отчёт по выдаче наличных со счёта</h4>
<table class="table">
<thead>
<tr>
<th>
Номер операции
</th>
<th>
Номер счёта
</th>
<th>
Сумма операции
</th>
<th>
Дата операции
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.ReportCashWithdrawal)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.OperationId)
</td>
<td>
@Html.DisplayFor(modelItem => item.AccountPayeeNumber)
</td>
<td>
@Html.DisplayFor(modelItem => item.SumOperation)
</td>
<td>
@Html.DisplayFor(modelItem => item.DateComplite)
</td>
</tr>
}
</tbody>
</table>
</div>
<hr class="my-12" />
<div class="row p-3 text-center">
<h4>Отчёт по денежным переводам между счетами</h4>
<table class="table">
<thead>
<tr>
<th>
Номер операции
</th>
<th>
Номер счёта отправителя
</th>
<th>
Номер счёта получаетля
</th>
<th>
Сумма операции
</th>
<th>
Дата операции
</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model.ReportMoneyTransfer)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.OperationId)
</td>
<td>
@Html.DisplayFor(modelItem => item.AccountSenderNumber)
</td>
<td>
@Html.DisplayFor(modelItem => item.AccountPayeeNumber)
</td>
<td>
@Html.DisplayFor(modelItem => item.SumOperation)
</td>
<td>
@Html.DisplayFor(modelItem => item.DateComplite)
</td>
</tr>
}
</tbody>
</table>
</div>
}
</form> </form>
<!--@{ <!--@{

View File

@ -28,9 +28,10 @@
<input id="createReport" type="submit" value="Сформировать отчёт" class="btn btn-primary" /> <input id="createReport" type="submit" value="Сформировать отчёт" class="btn btn-primary" />
</div> </div>
</div> </div>
<hr class="mt-5 mb-3" />
@if (Model != null) @if (Model != null)
{ {
<div class="row"> <div class="row text-center">
<p>Отчёт по пополнениям</p> <p>Отчёт по пополнениям</p>
<table class="table"> <table class="table">
<thead> <thead>
@ -70,7 +71,8 @@
</tbody> </tbody>
</table> </table>
</div> </div>
<div class="row"> <hr class="my-12" />
<div class="row text-center">
<p>Отчёт по снятиям</p> <p>Отчёт по снятиям</p>
<table class="table"> <table class="table">
<thead> <thead>

View File

@ -58,17 +58,19 @@ namespace BankYouBankruptRestAPI.Controllers
//метод генерации отчёта по всем счетм клиентов //метод генерации отчёта по всем счетм клиентов
[HttpPost] [HttpPost]
public void CreateCashierReport(ReportSupportBindingModel model) public ReportCashierViewModelForHTML CreateCashierReport(ReportSupportBindingModel model)
{ {
try try
{ {
_reportCashierViewModelForHTML = _reportCashierLogic.SaveAccountsToPdfFile(new ReportBindingModel var result = _reportCashierLogic.SaveAccountsToPdfFile(new ReportBindingModel
{ {
FileName = "Отчёт_по_счетам.pdf", FileName = "Отчёт_по_счетам.pdf",
ClientId = model.ClientId, ClientId = model.ClientId,
DateFrom = model.DateFrom, DateFrom = model.DateFrom,
DateTo = model.DateTo DateTo = model.DateTo
}); });
return result;
} }
catch (Exception ex) catch (Exception ex)
{ {