savetoword, savetoexcel implementation
This commit is contained in:
parent
987d288f74
commit
8af62f18f3
@ -44,7 +44,7 @@ namespace FactoryBusinessLogic.BusinessLogics
|
||||
_saveToPdf.CreateStorekeeperDoc(new StorekeeperPdfInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список станков",
|
||||
Title = "Список станков за период",
|
||||
DateFrom = model.DateFrom!.Value,
|
||||
DateTo = model.DateTo!.Value,
|
||||
Machines = GetMachines(client, model)
|
||||
|
@ -16,7 +16,7 @@ namespace FactoryBusinessLogic.OfficePackage
|
||||
});
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = $"с{ info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style = "Normal",
|
||||
Text = $"с { info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
CreateTable(new List<string> { "3cm", "5cm", "5cm"});
|
||||
|
@ -21,21 +21,10 @@ namespace FactoryBusinessLogic.OfficePackage
|
||||
});
|
||||
foreach (var ppp in info.ProductPlanProductions)
|
||||
{
|
||||
var t = ppp.PlanProductions;
|
||||
List<(string, WordTextProperties)> texts = new List<(string, WordTextProperties)>
|
||||
{
|
||||
(ppp.ProductName, new WordTextProperties { Bold = true, Size = "24", })
|
||||
};
|
||||
foreach (var plan in ppp.PlanProductions)
|
||||
{
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.Append(plan.ProductionName);
|
||||
stringBuilder.Append(" — ");
|
||||
stringBuilder.Append(plan.Count.ToString());
|
||||
stringBuilder.Append(" — ");
|
||||
stringBuilder.Append(plan.Deadline.ToString());
|
||||
texts.Add((stringBuilder.ToString(), new WordTextProperties { Size = "24" }));
|
||||
}
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = texts,
|
||||
@ -45,6 +34,26 @@ namespace FactoryBusinessLogic.OfficePackage
|
||||
JustificationType = WordJustificationType.Both
|
||||
}
|
||||
});
|
||||
foreach (var plan in ppp.PlanProductions)
|
||||
{
|
||||
texts = new List<(string, WordTextProperties)>();
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
stringBuilder.Append(plan.ProductionName);
|
||||
stringBuilder.Append(" — ");
|
||||
stringBuilder.Append(plan.Count.ToString());
|
||||
stringBuilder.Append(" — ");
|
||||
stringBuilder.Append(plan.Deadline.ToString());
|
||||
texts.Add((stringBuilder.ToString(), new WordTextProperties { Size = "24" }));
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = texts,
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
JustificationType = WordJustificationType.Both
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
SaveStorekeeperWord(info);
|
||||
}
|
||||
|
@ -415,6 +415,8 @@ namespace FactoryStorekeeperApp.Controllers
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.DateFrom = datefrom;
|
||||
ViewBag.DateTo = dateto;
|
||||
var reports = storekeeperReportLogic.GetMachines(
|
||||
new ClientSearchModel
|
||||
{
|
||||
@ -446,8 +448,51 @@ namespace FactoryStorekeeperApp.Controllers
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
ViewBag.ids = products;
|
||||
var report = storekeeperReportLogic.GetPlanProductionsByProduct(products);
|
||||
return View(report);
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult CreateWord(List<int> ids)
|
||||
{
|
||||
storekeeperReportLogic.SavePlanProductionsToWordFile(
|
||||
new ReportBindingModel
|
||||
{
|
||||
FileName = "D:\\temp\\report.docx"
|
||||
},
|
||||
ids);
|
||||
return PhysicalFile("D:\\temp\\report.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Отчет по изделиям.docx");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult CreateExcel(List<int> ids)
|
||||
{
|
||||
storekeeperReportLogic.SavePlanProductionsToExcelFile(
|
||||
new ReportBindingModel
|
||||
{
|
||||
FileName = "D:\\temp\\report.xlsx"
|
||||
},
|
||||
ids);
|
||||
return PhysicalFile("D:\\temp\\report.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "Отчет по изделиям.xlsx");
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public IActionResult SendMail(DateTime datefrom, DateTime dateto)
|
||||
{
|
||||
storekeeperReportLogic.SaveMachinesToPdfFile(
|
||||
new ClientSearchModel
|
||||
{
|
||||
Id = Client.client.Id
|
||||
},
|
||||
new ReportBindingModel
|
||||
{
|
||||
DateFrom = datefrom,
|
||||
DateTo = dateto,
|
||||
FileName="D:\\temp\\report.pdf"
|
||||
});
|
||||
// TODO: implement sending
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,9 @@
|
||||
<h1 class="display-4">Список станков за период</h1>
|
||||
</div>
|
||||
|
||||
<form asp-controller="Report" method="post">
|
||||
<form asp-controller="Home" asp-action="SendMail" method="post">
|
||||
<input type="hidden" name="datefrom" readonly value="@(ViewBag.DateFrom)" />
|
||||
<input type="hidden" name="dateto" readonly value="@(ViewBag.DateTo)" />
|
||||
<button type="submit" class="btn btn-primary">Отправить отчет на почту</button>
|
||||
</form>
|
||||
|
||||
|
@ -11,9 +11,25 @@
|
||||
|
||||
<div class="d-flex">
|
||||
<form asp-controller="Home" asp-action="CreateWord" method="post">
|
||||
<div style="display: none;">
|
||||
<select name="ids" multiple>
|
||||
@foreach (var it in ViewBag.ids)
|
||||
{
|
||||
<option value="@(it)" selected="selected"></option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary me-3">Сгенерировать отчет в Word</button>
|
||||
</form>
|
||||
<form asp-controller="Home" asp-action="CreateExcel" method="post">
|
||||
<div style="display: none;">
|
||||
<select name="ids" multiple>
|
||||
@foreach (var it in ViewBag.ids)
|
||||
{
|
||||
<option value="@(it)" selected="selected"></option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary">Сгенерировать отчет в Excel</button>
|
||||
</form>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user