somechange
This commit is contained in:
parent
1d49b42cd6
commit
64d1c12832
@ -36,7 +36,7 @@ namespace DatabaseImplement.Implements
|
||||
}
|
||||
using var context = new FactoryGoWorkDatabase();
|
||||
if (model.DetailId.HasValue)
|
||||
return context.Workshops.Where(x => x.ProductionId.HasValue).Include(x => x.Production).Where(x => x.Production.Details.FirstOrDefault(y => y.DetailId == model.DetailId) != null).Where(x => x.UserId == model.UserId).Select(x => x.GetViewModel).ToList();
|
||||
return context.Workshops.Where(x => x.ProductionId.HasValue).Include(x => x.Production).Where(x => x.Production.Details.FirstOrDefault(y => y.DetailId == model.DetailId) != null).Select(x => x.GetViewModel).ToList();
|
||||
else if (model.DateFrom.HasValue)
|
||||
return context.Workshops.Where(x => x.UserId == model.Id).Where(x => x.DateCreate < model.DateTo && x.DateCreate > model.DateFrom).Select(x => x.GetViewModel).ToList();
|
||||
else
|
||||
|
@ -299,22 +299,35 @@ namespace ImplementerApp.Controllers
|
||||
|
||||
return View(values);
|
||||
}
|
||||
public IActionResult DetailWorkshopReport()
|
||||
[HttpGet]
|
||||
public IActionResult DetailWorkshopChoose()
|
||||
{
|
||||
List<DetailWorkshopReportViewModel> detailWorkshopReports = new List<DetailWorkshopReportViewModel>
|
||||
if (!IsLoggedIn)
|
||||
return RedirectToAction("IndexNonReg");
|
||||
var details = _data.GetDetails(UserId);
|
||||
return View(details);
|
||||
}
|
||||
[HttpPost]
|
||||
public IActionResult DetailWorkshopChoose(List<int> selectedItems, string reportType)
|
||||
{
|
||||
string value = string.Join("/", selectedItems);
|
||||
HttpContext.Session.SetString("Details", value);
|
||||
if (reportType.Equals("default"))
|
||||
return RedirectToAction("DetailWorkshopReport");
|
||||
else
|
||||
return RedirectToAction("Index"); // СДЕЛАТЬ EXCEL И WORD
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult DetailWorkshopReport()
|
||||
{
|
||||
var value = HttpContext.Session.GetString("Details");
|
||||
if (value != null)
|
||||
{
|
||||
new DetailWorkshopReportViewModel
|
||||
{
|
||||
DetailName = "Деталь X",
|
||||
WorkShops = new List<string> { "Цех 1", "Цех 2" }
|
||||
},
|
||||
new DetailWorkshopReportViewModel
|
||||
{
|
||||
DetailName = "Деталь Y",
|
||||
WorkShops = new List<string> { "Цех 3", "Цех 4" }
|
||||
}
|
||||
};
|
||||
return View(detailWorkshopReports);
|
||||
List<int> rawReports = value!.Split('/').Select(x => int.Parse(x)).ToList();
|
||||
var reports = _data.GetWorkshopReports(rawReports);
|
||||
return View(reports);
|
||||
}
|
||||
return View(new List<DetailWorkshopReportViewModel>());
|
||||
}
|
||||
public IActionResult ReportsMenu()
|
||||
{
|
||||
|
@ -14,18 +14,20 @@ namespace ImplementerApp
|
||||
private readonly IProductionLogic _productionLogic;
|
||||
private readonly IProductLogic _productLogic;
|
||||
private readonly IMachineLogic _machineLogic;
|
||||
private readonly IWorkshopLogic _workshopLogic;
|
||||
|
||||
public ImplementerData(ILogger<ImplementerData> logger, IImplementerLogic implementerLogic, IDetailLogic detailLogic, IProductionLogic productionLogic, IProductLogic productLogic, IMachineLogic machineLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_implementerLogic = implementerLogic;
|
||||
_detailLogic = detailLogic;
|
||||
_productionLogic = productionLogic;
|
||||
_productLogic = productLogic;
|
||||
_machineLogic = machineLogic;
|
||||
}
|
||||
public ImplementerData(ILogger<ImplementerData> logger, IImplementerLogic implementerLogic, IDetailLogic detailLogic, IProductionLogic productionLogic, IProductLogic productLogic, IMachineLogic machineLogic, IWorkshopLogic workshopLogic)
|
||||
{
|
||||
_logger = logger;
|
||||
_implementerLogic = implementerLogic;
|
||||
_detailLogic = detailLogic;
|
||||
_productionLogic = productionLogic;
|
||||
_productLogic = productLogic;
|
||||
_machineLogic = machineLogic;
|
||||
_workshopLogic = workshopLogic;
|
||||
}
|
||||
|
||||
public ImplementerViewModel? Login(string login, string password)
|
||||
public ImplementerViewModel? Login(string login, string password)
|
||||
{
|
||||
return _implementerLogic.ReadElement(new()
|
||||
{
|
||||
@ -130,5 +132,22 @@ namespace ImplementerApp
|
||||
}
|
||||
return detailTimeReports;
|
||||
}
|
||||
|
||||
public List<DetailWorkshopReportViewModel>? GetWorkshopReports(List<int> details)
|
||||
{
|
||||
List<DetailWorkshopReportViewModel> reports = new();
|
||||
foreach (int i in details)
|
||||
{
|
||||
DetailWorkshopReportViewModel report = new();
|
||||
var detail = _detailLogic.ReadElement(new() { Id = i });
|
||||
report.DetailName = detail!.Name;
|
||||
var workshops = _workshopLogic.ReadList(new() { DetailId = i });
|
||||
if (workshops != null)
|
||||
report.WorkShops = workshops.Select(w => w.Title).ToList();
|
||||
reports.Add(report);
|
||||
}
|
||||
return reports;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -17,11 +17,13 @@ builder.Services.AddTransient<IDetailStorage, DetailStorage>();
|
||||
builder.Services.AddTransient<IProductStorage, ProductStorage>();
|
||||
builder.Services.AddTransient<IProductionStorage, ProductionStorage>();
|
||||
builder.Services.AddTransient<IMachineStorage, MachineStorage>();
|
||||
builder.Services.AddTransient<IWorkshopStorage, WorkshopStorage>();
|
||||
builder.Services.AddTransient<IImplementerLogic, ImplementerLogic>();
|
||||
builder.Services.AddTransient<IDetailLogic, DetailLogic>();
|
||||
builder.Services.AddTransient<IProductionLogic, ProductionLogic>();
|
||||
builder.Services.AddTransient<IProductLogic, ProductLogic>();
|
||||
builder.Services.AddTransient<IMachineLogic, MachineLogic>();
|
||||
builder.Services.AddTransient<IWorkshopLogic, WorkshopLogic>();
|
||||
builder.Services.AddTransient<ImplementerData>();
|
||||
|
||||
builder.Services.AddSession(options =>
|
||||
|
54
Course/ImplementerApp/Views/Home/DetailWorkshopChoose.cshtml
Normal file
54
Course/ImplementerApp/Views/Home/DetailWorkshopChoose.cshtml
Normal file
@ -0,0 +1,54 @@
|
||||
@using Contracts.ViewModels;
|
||||
@model List<DetailViewModel>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Выбор деталей для отчета";
|
||||
}
|
||||
|
||||
<h2>Выберите детали для отчета</h2>
|
||||
|
||||
<form asp-controller="Home" asp-action="DetailWorkshopChoose" method="post" onsubmit="return validateForm()">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Select</th>
|
||||
<th>Name</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (int i = 0; i < Model.Count; i++)
|
||||
{
|
||||
<tr>
|
||||
<td>
|
||||
<input type="checkbox" name="selectedItems" value="@Model[i].Id" />
|
||||
</td>
|
||||
<td>@Model[i].Name</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
<input type="hidden" id="reportType" name="reportType" value="default" />
|
||||
<button type="submit" class="btn btn-primary" onclick="setReportType('default')">Сгенерировать отчет</button>
|
||||
<button type="submit" class="btn btn-secondary" onclick="setReportType('excel')">Сгенерировать отчет в Excel</button>
|
||||
<button type="submit" class="btn btn-secondary" onclick="setReportType('word')">Сгенерировать отчет в Word</button>
|
||||
<div id="validationMessage" style="display:none;color:red;">Пожалуйста, выберите хотя бы одну деталь.</div>
|
||||
</form>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
function validateForm() {
|
||||
var checkboxes = document.querySelectorAll('input[name="selectedItems"]:checked');
|
||||
if (checkboxes.length === 0) {
|
||||
document.getElementById('validationMessage').style.display = 'block';
|
||||
return false;
|
||||
} else {
|
||||
document.getElementById('validationMessage').style.display = 'none';
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function setReportType(type) {
|
||||
document.getElementById('reportType').value = type;
|
||||
}
|
||||
</script>
|
||||
}
|
@ -5,7 +5,7 @@
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Меню создания отчетов</h1>
|
||||
<div class="list-group">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="DetailWorkshopReport">Отчет деталь-цех</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="DetailWorkshopChoose">Отчет деталь-цех</a>
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="DetailTimeChoose">Отчет по деталям по датам</a>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user