Ура конец

This commit is contained in:
Табеев Александр 2024-05-29 22:26:31 +04:00
parent 3d4536eafa
commit ae81a01dd9
16 changed files with 178 additions and 108 deletions

View File

@ -16,7 +16,7 @@ namespace ServiceStationBusinessLogic.OfficePackage
CreateParagraph(new PdfParagraph { Text = info.Title, Style = "NormalTitle", ParagraphAligment = PdfParagraphAlignmentType.Center });
CreateParagraph(new PdfParagraph { Text = $"с {info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}", Style = "Normal", ParagraphAligment = PdfParagraphAlignmentType.Center });
CreateTable(new List<string> { "3cm", "2cm", "2cm", "2cm", "3cm", "3cm", "2cm" });
CreateTable(new List<string> { "3cm", "3cm", "3cm", "2cm", "3cm", "3cm", "2cm" });
CreateRow(new PdfRowParameters
{

View File

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using DocumentFormat.OpenXml.Drawing;
using Microsoft.AspNetCore.Mvc;
using ServiceStationContracts.BindingModels;
using ServiceStationContracts.BusinessLogicsContracts;
using ServiceStationContracts.SearchModels;
@ -208,6 +209,19 @@ namespace ServiceStationGuarantorApp.Controllers
Response.Redirect("ListSpareParts");
}
[HttpGet]
public SparePartViewModel? GetSparePart(int sparepartId)
{
if (APIGuarantor.Guarantor == null)
{
throw new Exception("Необходима авторизация");
}
var result = APIGuarantor.GetRequest<SparePartViewModel>($"api/main/getsparepart?sparepartId={sparepartId}");
if (result == null) return default;
return result;
}
[HttpGet]
public string GetSparePartsReport(DateTime dateFrom, DateTime dateTo)
{
@ -290,11 +304,11 @@ namespace ServiceStationGuarantorApp.Controllers
string table = "";
for (int i = 0; i < result.Item2.Count; i++)
{
var sparepartName = result.Item2[i].Item1;
var sparepartPrice = result.Item2[i].Item2;
var repairName = result.Item2[i].Item1;
var repairPrice = result.Item2[i].Item2;
table += "<tr>";
table += $"<td>{sparepartName}</td>";
table += $"<td>{sparepartPrice}</td>";
table += $"<td>{repairName}</td>";
table += $"<td>{repairPrice}</td>";
table += "</tr>";
}
return Tuple.Create(result.Item1, table);
@ -331,7 +345,6 @@ namespace ServiceStationGuarantorApp.Controllers
public IActionResult UpdateRepair()
{
ViewBag.Repairs = new List<RepairViewModel>();
if (APIGuarantor.Guarantor == null)
{
return RedirectToAction("Enter");
@ -430,11 +443,11 @@ namespace ServiceStationGuarantorApp.Controllers
{
return RedirectToAction("Enter");
}
return View();
return View(APIGuarantor.GetRequest<List<SparePartViewModel>>($"api/main/getsparepartlist?guarantorId={APIGuarantor.Guarantor.Id}"));
}
[HttpPost]
public void CreateWork(string WorkName, double WorkPrice)
public void CreateWork(string WorkName, double WorkPrice, int[] sparepart)
{
if (APIGuarantor.Guarantor == null)
{
@ -447,6 +460,10 @@ namespace ServiceStationGuarantorApp.Controllers
WorkPrice = WorkPrice,
Status = ServiceStationDataModels.Enums.WorkStatus.Принята
});
APIGuarantor.PostRequest("api/main/addspareparttowork", Tuple.Create(
new WorkSearchModel() { WorkName = WorkName },
sparepart
));
Response.Redirect("ListWorks");
}
@ -457,11 +474,11 @@ namespace ServiceStationGuarantorApp.Controllers
return RedirectToAction("Enter");
}
ViewBag.Works = APIGuarantor.GetRequest<List<WorkViewModel>>($"api/main/getworklist?guarantorId={APIGuarantor.Guarantor.Id}");
return View();
return View(APIGuarantor.GetRequest<List<SparePartViewModel>>($"api/main/getsparepartlist?guarantorId={APIGuarantor.Guarantor.Id}"));
}
[HttpPost]
public void UpdateWork(int work, string WorkName, double WorkPrice)
public void UpdateWork(int work, string WorkName, double WorkPrice, int[] sparepart)
{
if (APIGuarantor.Guarantor == null)
{
@ -482,6 +499,10 @@ namespace ServiceStationGuarantorApp.Controllers
GuarantorId = APIGuarantor.Guarantor.Id,
WorkPrice = WorkPrice,
});
APIGuarantor.PostRequest("api/main/addspareparttowork", Tuple.Create(
new WorkSearchModel() { Id = work },
sparepart
));
Response.Redirect("ListWorks");
}
@ -534,49 +555,6 @@ namespace ServiceStationGuarantorApp.Controllers
return View();
}
[HttpGet]
public IActionResult AddSparepartToRepair()
{
if (APIGuarantor.Guarantor == null)
{
return RedirectToAction("Enter");
}
return View(Tuple.Create(APIGuarantor.GetRequest<List<RepairViewModel>>($"api/main/getrepairlist?guarantorId={APIGuarantor.Guarantor.Id}"),
APIGuarantor.GetRequest<List<SparePartViewModel>>($"api/main/getsparepartlist?guarantorId={APIGuarantor.Guarantor.Id}")));
}
[HttpPost]
public void AddSparepartToRepair(int repair, int[] sparepart)
{
if (APIGuarantor.Guarantor == null)
{
throw new Exception("Авторизуйтесь");
}
APIGuarantor.PostRequest("api/main/addspareparttorepair", Tuple.Create(new RepairSearchModel() { Id = repair }, sparepart));
Response.Redirect("ListRepairs");
}
public IActionResult AddSparepartToWork()
{
if (APIGuarantor.Guarantor == null)
{
return RedirectToAction("Enter");
}
return View(Tuple.Create(APIGuarantor.GetRequest<List<WorkViewModel>>($"api/main/getworklist?guarantorId={APIGuarantor.Guarantor.Id}"),
APIGuarantor.GetRequest<List<SparePartViewModel>>($"api/main/getsparepartlist?guarantorId={APIGuarantor.Guarantor.Id}")));
}
[HttpPost]
public void AddSparepartToWork(int work, int[] sparepart)
{
if (APIGuarantor.Guarantor == null)
{
throw new Exception("Авторизуйтесь");
}
APIGuarantor.PostRequest("api/main/addspareparttowork", Tuple.Create(new WorkSearchModel() { Id = work }, sparepart));
Response.Redirect("ListWorks");
}
public IActionResult GetWordFile()
{
return new PhysicalFileResult(Directory.GetCurrentDirectory() + "\\Reports\\wordfile.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");

View File

@ -1,4 +1,6 @@

@using ServiceStationContracts.ViewModels
@model List<SparePartViewModel>
@{
ViewData["Title"] = "CreateRepair";
}
@ -13,6 +15,29 @@
<label>Стоимость ремонта</label>
<input type="number" min="100" step="100" id="repairPrice" placeholder="Введите стоимость ремонта" name="repairPrice" class="form-control" />
</div>
<table class="table">
<thead>
<tr>
<th scope="col">№</th>
<th scope="col">Название запчасти</th>
<th scope="col">цена запчасти</th>
</tr>
</thead>
<tbody>
@foreach (var sparepart in Model)
{
<tr>
<td class="align-middle">
<div class="form-check">
<input type="checkbox" class="form-check-input" name="sparepart[]" value="@sparepart.Id" id="@sparepart.Id">
</div>
</td>
<td class="align-middle">@Html.DisplayFor(modelItem => sparepart.SparePartName)</td>
<td class="align-middle">@Html.DisplayFor(modelItem => sparepart.SparePartPrice)</td>
</tr>
}
</tbody>
</table>
<br>
<div class="text-center pb-3">
<input type="submit" value="Сохранить" class="btn btn-outline-dark text-center w-100" />

View File

@ -1,4 +1,6 @@

@using ServiceStationContracts.ViewModels
@model List<SparePartViewModel>
@{
ViewData["Title"] = "CreateWork";
}
@ -13,6 +15,29 @@
<label>Стоимость работы</label>
<input type="number" min="100" step="100" id="workPrice" placeholder="Введите стоимость работы" name="workPrice" class="form-control" />
</div>
<table class="table">
<thead>
<tr>
<th scope="col">№</th>
<th scope="col">Название запчасти</th>
<th scope="col">Цена запчасти</th>
</tr>
</thead>
<tbody>
@foreach (var sparepart in Model)
{
<tr>
<td class="align-middle">
<div class="form-check">
<input type="checkbox" class="form-check-input" name="sparepart[]" value="@sparepart.Id" id="@sparepart.Id">
</div>
</td>
<td class="align-middle">@Html.DisplayFor(modelItem => sparepart.SparePartName)</td>
<td class="align-middle">@Html.DisplayFor(modelItem => sparepart.SparePartPrice)</td>
</tr>
}
</tbody>
</table>
<br>
<div class="text-center pb-3">
<input type="submit" value="Сохранить" class="btn btn-outline-dark text-center w-100" />

View File

@ -3,6 +3,17 @@
}
<div class="text-center">
<h1 class="display-4">Welcome</h1>
<p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
<h1 class="display-4">СТО "Руки-Крюки"</h1>
<div class="p-2">
<img src="~/images/ruki-kryuki.gif" width="200px" />
</div>
<div class="p-2">
<img src="~/images/maksimka.jpg" width="100px" />
Яковлев М.Г. Роль Исполнителя
</div>
<div class="p-2">
<img src="~/images/sasha.jpg" width="100px" />
Табеев А.П. Роль Поручителя &nbsp; &nbsp;&nbsp;
</div>
<p class="pt-4">Рады видеть вас на нашем сайте (ノ◕ヮ◕)ノ*:・゚✧</p>
</div>

View File

@ -54,10 +54,6 @@
<a asp-controller="Home" asp-action="UpdateRepair" class="btn btn-outline-dark text-center d-flex justify-content-md-center">Изменить</a>
</div>
&nbsp;
<div class="text-center">
<a asp-controller="Home" asp-action="AddSparepartToRepair" class="btn btn-outline-dark text-center d-flex justify-content-md-center">Добавить запчасть</a>
</div>
&nbsp;
<div class="text-center">
<a asp-controller="Home" asp-action="DeleteRepair" class="btn btn-outline-dark text-center d-flex justify-content-md-center">Удалить</a>
</div>

View File

@ -53,10 +53,6 @@
<a asp-controller="Home" asp-action="UpdateWork" class="btn btn-outline-dark text-center d-flex justify-content-md-center">Изменить</a>
</div>
&nbsp;
<div class="text-center">
<a asp-controller="Home" asp-action="AddSparepartToWork" class="btn btn-outline-dark text-center d-flex justify-content-md-center">Добавить запчасть</a>
</div>
&nbsp;
<div class="text-center">
<a asp-controller="Home" asp-action="DeleteWork" class="btn btn-outline-dark text-center d-flex justify-content-md-center">Удалить</a>
</div>

View File

@ -1,4 +1,6 @@

@using ServiceStationContracts.ViewModels
@model List<SparePartViewModel>
@{
ViewData["Title"] = "UpdateRepair";
}
@ -18,15 +20,39 @@
<label>Стоимость ремонта</label>
<input type="number" min="0" step="100" id="repairPrice" placeholder="Введите стоимость ремонта" name="repairPrice" class="form-control" />
</div>
<h5>Уже привязанные запчасти</h5>
<table class="table">
<thead>
<tr>
<th scope="col">Название запчасти</th>
<th scope="col">Стоимость запчасти</th>
<th scope="col">Цена запчасти</th>
</tr>
</thead>
<tbody id="table-elements">
@* тут будет код *@
</tbody>
</table>
<h5>Изменить запчасти</h5>
<table class="table">
<thead>
<tr>
<th scope="col"></th>
<th scope="col">Название запчасти</th>
<th scope="col">Цена запчасти</th>
</tr>
</thead>
<tbody>
@foreach (var sparepart in Model)
{
<tr>
<td class="align-middle">
<div class="form-check">
<input type="checkbox" class="form-check-input" name="sparepart[]" value="@sparepart.Id" id="@sparepart.Id">
</div>
</td>
<td class="align-middle">@Html.DisplayFor(modelItem => sparepart.SparePartName)</td>
<td class="align-middle">@Html.DisplayFor(modelItem => sparepart.SparePartPrice)</td>
</tr>
}
</tbody>
</table>
<br>

View File

@ -37,9 +37,8 @@
url: "/Home/GetSparePart",
data: { sparepartId: sparepart },
success: function (result) {
$('#sparepartName').val(result.item1.sparepartName);
$('#sparepartPrice').val(result.item1.sparepartPrice);
$('#table-elements').html(result.item2);
$('#sparepartName').val(result.sparePartName);
$('#sparepartPrice').val(result.sparePartPrice);
}
});
};

View File

@ -1,4 +1,7 @@
@{
@using ServiceStationContracts.ViewModels
@model List<SparePartViewModel>
@{
ViewData["Title"] = "UpdateWork";
}
@ -17,15 +20,39 @@
<label>Стоимость работы</label>
<input type="number" min="0" step="100" id="workPrice" placeholder="Введите стоимость работы" name="workPrice" class="form-control" />
</div>
<h5>Уже привязанные запчасти</h5>
<table class="table">
<thead>
<tr>
<th scope="col">Название запчасти</th>
<th scope="col">Стоимость запчасти</th>
<th scope="col">Цена запчасти</th>
</tr>
</thead>
<tbody id="table-elements">
@* тут будет код *@
</tbody>
</table>
<h5>Изменить запчасти</h5>
<table class="table">
<thead>
<tr>
<th scope="col"></th>
<th scope="col">Название запчасти</th>
<th scope="col">Цена запчасти</th>
</tr>
</thead>
<tbody>
@foreach (var sparepart in Model)
{
<tr>
<td class="align-middle">
<div class="form-check">
<input type="checkbox" class="form-check-input" name="sparepart[]" value="@sparepart.Id" id="@sparepart.Id">
</div>
</td>
<td class="align-middle">@Html.DisplayFor(modelItem => sparepart.SparePartName)</td>
<td class="align-middle">@Html.DisplayFor(modelItem => sparepart.SparePartPrice)</td>
</tr>
}
</tbody>
</table>
<br>
@ -47,7 +74,8 @@
url: "/Home/GetWork",
data: { workId: work },
success: function (result) {
$('#workName').val(result.item1.WorkName);
$('#workName').val(result.item1.workName);
$('#workPrice').val(result.item1.workPrice);
$('#table-elements').html(result.item2);
}
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@ -544,6 +544,20 @@ namespace ServiceStationRestApi.Controllers
}
}
[HttpGet]
public SparePartViewModel? GetSparePart(int sparepartId)
{
try
{
return _splogic.ReadElement(new SparePartSearchModel { Id = sparepartId });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка получения запчасти по id={Id}", sparepartId);
throw;
}
}
[HttpGet]
public Tuple<WorkViewModel, List<Tuple<string, string>>>? GetWork(int workId)
{

View File

@ -54,34 +54,6 @@ namespace ServiceStationRestApi.Controllers
}
}
[HttpPost]
public void CreateGuarantorReportToWord(ReportGuarantorBindingModel model)
{
try
{
_guarantorReportLogic.SaveDefectsToWordFile(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания отчета");
throw;
}
}
[HttpPost]
public void CreateGuarantorReportToExcel(ReportGuarantorBindingModel model)
{
try
{
_guarantorReportLogic.SaveDefectsToExcelFile(model);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания отчета");
throw;
}
}
[HttpPost]
public void CreateGuarantorReportToPdf(PdfReportBindingModel model)
{