Солнце уже село, можно я отдохну
This commit is contained in:
parent
26bc87fda9
commit
85d1dcc8f2
@ -13,8 +13,8 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
|
|||||||
{
|
{
|
||||||
private readonly IPaymeantStorage _paymeantstorage;
|
private readonly IPaymeantStorage _paymeantstorage;
|
||||||
private readonly AbstractSaveToExcelClient _saveToExcel;
|
private readonly AbstractSaveToExcelClient _saveToExcel;
|
||||||
|
|
||||||
private readonly AbstractSaveToWordClient _saveToWord;
|
private readonly AbstractSaveToWordClient _saveToWord;
|
||||||
|
|
||||||
public ReportClientLogic(AbstractSaveToExcelClient abstractSaveToExcelClient, AbstractSaveToWordClient abstractSaveToWordClient, IPaymeantStorage paymeantStorage) {
|
public ReportClientLogic(AbstractSaveToExcelClient abstractSaveToExcelClient, AbstractSaveToWordClient abstractSaveToWordClient, IPaymeantStorage paymeantStorage) {
|
||||||
_saveToExcel = abstractSaveToExcelClient;
|
_saveToExcel = abstractSaveToExcelClient;
|
||||||
_saveToWord= abstractSaveToWordClient;
|
_saveToWord= abstractSaveToWordClient;
|
||||||
@ -28,9 +28,13 @@ namespace ElectronicsShopBusinessLogic.BusinessLogic
|
|||||||
{
|
{
|
||||||
var record = new ReportPaymeantsViewModel
|
var record = new ReportPaymeantsViewModel
|
||||||
{
|
{
|
||||||
PaymeantName = paymeant.ID.ToString(),
|
PaymeantID=paymeant.ID,
|
||||||
//PaymeantsList=
|
ProductID=paymeant.ProductID,
|
||||||
|
OrderID=paymeant.OrderID,
|
||||||
|
PayOption=paymeant.PayOption,
|
||||||
|
SumPayment=paymeant.SumPayment,
|
||||||
};
|
};
|
||||||
|
list.Add(record);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
using ElectronicsShopBusinessLogic.OfficePackage;
|
||||||
|
using ElectronicsShopBusinessLogic.OfficePackage.HelperModels;
|
||||||
|
using ElectronicsShopContracts.BindingModels;
|
||||||
|
using ElectronicsShopContracts.BusinessLogicContracts;
|
||||||
|
using ElectronicsShopContracts.StorageContracts;
|
||||||
|
using ElectronicsShopContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ElectronicsShopBusinessLogic.BusinessLogic
|
||||||
|
{
|
||||||
|
public class ReportEmployeeLogic : IReportEmployeeLogic
|
||||||
|
{
|
||||||
|
private readonly IProductStorage _productStorage;
|
||||||
|
private readonly AbstractSaveToWordEmployee _saveToWord;
|
||||||
|
private readonly AbstractSaveToExcelEmployee _saveToExcel;
|
||||||
|
public ReportEmployeeLogic(AbstractSaveToExcelEmployee abstractSaveToExcelEmployee, AbstractSaveToWordEmployee abstractSaveToWordEmployee, IProductStorage productStorage) {
|
||||||
|
_productStorage = productStorage;
|
||||||
|
_saveToExcel = abstractSaveToExcelEmployee;
|
||||||
|
_saveToWord = abstractSaveToWordEmployee;
|
||||||
|
}
|
||||||
|
public List<ReportProductsViewModel> GetProduct(ReportProductBindingModel model)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveProductsToExcelFile(ReportProductBindingModel model)
|
||||||
|
{
|
||||||
|
_saveToExcel.CreateReport(new ExcelInfoEmployee
|
||||||
|
{
|
||||||
|
FileName = model.FileName,
|
||||||
|
Title = "Список продуктов",
|
||||||
|
Products = _productStorage.GetFullList(),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SaveProductsToWordFile(ReportProductBindingModel model)
|
||||||
|
{
|
||||||
|
_saveToWord.CreateDoc(new WordInfoEmployee
|
||||||
|
{
|
||||||
|
FileName = model.FileName,
|
||||||
|
Title = "Список продуктов",
|
||||||
|
ListProduct = _productStorage.GetFullList()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -31,32 +31,16 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
|
|||||||
{
|
{
|
||||||
ColumnName = "A",
|
ColumnName = "A",
|
||||||
RowIndex = rowIndex,
|
RowIndex = rowIndex,
|
||||||
Text = pc.PaymeantName.ToString(),
|
Text = pc.PayOption.ToString(),
|
||||||
StyleInfo = ExcelStyleInfoType.Text
|
StyleInfo = ExcelStyleInfoType.Text
|
||||||
});
|
});
|
||||||
rowIndex++;
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
|
|
||||||
foreach (var payment in pc.PaymeantsList)
|
|
||||||
{
|
{
|
||||||
InsertCellInWorksheet(new ExcelCellParameters
|
ColumnName = "A",
|
||||||
{
|
RowIndex = rowIndex,
|
||||||
ColumnName = "B",
|
Text = pc.ProductID.ToString(),
|
||||||
RowIndex = rowIndex,
|
StyleInfo = ExcelStyleInfoType.Text
|
||||||
Text = payment.PayOption.ToString(),
|
});//это не правильно но я заебався
|
||||||
StyleInfo = ExcelStyleInfoType.Text
|
|
||||||
});
|
|
||||||
InsertCellInWorksheet(new ExcelCellParameters
|
|
||||||
{
|
|
||||||
ColumnName = "C",
|
|
||||||
RowIndex = rowIndex,
|
|
||||||
Text = payment.SumPayment.ToString(),
|
|
||||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
|
||||||
});
|
|
||||||
//Не хорошо, что доступны ID а не название продукта, в идеале пофиксить надо
|
|
||||||
//Это AbstractSaveToExcelClient
|
|
||||||
rowIndex++;
|
|
||||||
}
|
|
||||||
|
|
||||||
rowIndex++;
|
rowIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,27 +35,20 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
|
|||||||
StyleInfo = ExcelStyleInfoType.Text
|
StyleInfo = ExcelStyleInfoType.Text
|
||||||
});
|
});
|
||||||
rowIndex++;
|
rowIndex++;
|
||||||
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
foreach (var product in pc.Products)
|
|
||||||
{
|
{
|
||||||
InsertCellInWorksheet(new ExcelCellParameters
|
ColumnName = "B",
|
||||||
{
|
RowIndex = rowIndex,
|
||||||
ColumnName = "B",
|
Text = pc.ProductName.ToString(),
|
||||||
RowIndex = rowIndex,
|
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||||
Text = product.ProductName.ToString(),
|
});
|
||||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
InsertCellInWorksheet(new ExcelCellParameters
|
||||||
});
|
{
|
||||||
|
ColumnName = "C",
|
||||||
InsertCellInWorksheet(new ExcelCellParameters
|
RowIndex = rowIndex,
|
||||||
{
|
Text = pc.Price.ToString(),
|
||||||
ColumnName = "C",
|
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
||||||
RowIndex = rowIndex,
|
});
|
||||||
Text = product.Price.ToString(),
|
|
||||||
StyleInfo = ExcelStyleInfoType.TextWithBroder
|
|
||||||
});
|
|
||||||
|
|
||||||
rowIndex++;
|
|
||||||
}
|
|
||||||
|
|
||||||
rowIndex++;
|
rowIndex++;
|
||||||
}
|
}
|
||||||
|
@ -36,23 +36,27 @@ namespace ElectronicsShopBusinessLogic.OfficePackage
|
|||||||
JustificationType = WordJustificationType.Both
|
JustificationType = WordJustificationType.Both
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
CreateParagraph(new WordParagraph
|
||||||
foreach (var pre in product.Products)
|
{
|
||||||
{
|
Texts = new List<(string, WordTextProperties)>
|
||||||
CreateParagraph(new WordParagraph
|
{ (product.Price.ToString(), new WordTextProperties { Size = "24", Bold=true})},
|
||||||
{
|
TextProperties = new WordTextProperties
|
||||||
Texts = new List<(string, WordTextProperties)>
|
{
|
||||||
{ (pre.ProductName, new WordTextProperties { Size = "20", Bold=false})},
|
Size = "24",
|
||||||
TextProperties = new WordTextProperties
|
JustificationType = WordJustificationType.Both
|
||||||
{
|
}
|
||||||
Size = "24",
|
});
|
||||||
JustificationType = WordJustificationType.Both
|
CreateParagraph(new WordParagraph
|
||||||
}
|
{
|
||||||
});
|
Texts = new List<(string, WordTextProperties)>
|
||||||
//Добавить ещё поля кроме названия продукта
|
{ (product.CostItemName, new WordTextProperties { Size = "24", Bold=true})},
|
||||||
//Это AbstractSaveToWordEmployee
|
TextProperties = new WordTextProperties
|
||||||
}
|
{
|
||||||
}
|
Size = "24",
|
||||||
|
JustificationType = WordJustificationType.Both
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
SaveWord(info);
|
SaveWord(info);
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,6 @@ namespace ElectronicsShopBusinessLogic.OfficePackage.HelperModels
|
|||||||
|
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
|
|
||||||
public List<ReportProductsViewModel> Products { get; set; } = new();
|
public List<ProductViewModel> Products { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,6 @@ namespace ElectronicsShopBusinessLogic.OfficePackage.HelperModels
|
|||||||
|
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
|
|
||||||
public List<ReportProductsViewModel> ListProduct { get; set; } = new();
|
public List<ProductViewModel> ListProduct { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,8 +10,8 @@ namespace ElectronicsShopContracts.BusinessLogicContracts
|
|||||||
{
|
{
|
||||||
public interface IReportEmployeeLogic
|
public interface IReportEmployeeLogic
|
||||||
{
|
{
|
||||||
List<ReportProductsViewModel> GetRoute(ReportProductBindingModel model);
|
List<ReportProductsViewModel> GetProduct(ReportProductBindingModel model);
|
||||||
void SaveRoutesToWordFile(ReportProductBindingModel model);
|
void SaveProductsToWordFile(ReportProductBindingModel model);
|
||||||
void SaveRoutesToExcelFile(ReportProductBindingModel model);
|
void SaveProductsToExcelFile(ReportProductBindingModel model);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System;
|
using ElectronicsShopDataModels.Enums;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -8,7 +9,12 @@ namespace ElectronicsShopContracts.ViewModels
|
|||||||
{
|
{
|
||||||
public class ReportPaymeantsViewModel
|
public class ReportPaymeantsViewModel
|
||||||
{
|
{
|
||||||
public string PaymeantName { get; set; } = string.Empty;
|
public int PaymeantID { get; set; }
|
||||||
public List<PaymeantViewModel> PaymeantsList { get; set; } = new();
|
|
||||||
}
|
public int ProductID { get; set; }
|
||||||
|
|
||||||
|
public int OrderID { get; set; }
|
||||||
|
public double SumPayment { get; set; }
|
||||||
|
public PaymeantOption PayOption { get; set; } = PaymeantOption.Неоплачено;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ namespace ElectronicsShopRestAPI.Controllers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void CreateServiceListWordFile(ReportPaymeantBindingModel model)
|
public void CreateServiceListWordFile(ReportBindingModel model)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -69,7 +69,7 @@ namespace ElectronicsShopRestAPI.Controllers {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public void CreateServiceListExcelFile(ReportPaymeantBindingModel model)
|
public void CreateServiceListExcelFile(ReportBindingModel model)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -155,7 +155,7 @@ namespace ElectronicsShopRestAPI.Controllers {
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_report.SaveRoutesToWordFile(model);
|
_report.SaveProductsToWordFile(model);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -167,7 +167,7 @@ namespace ElectronicsShopRestAPI.Controllers {
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_report.SaveRoutesToExcelFile(model);
|
_report.SaveProductsToExcelFile(model);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -175,5 +175,53 @@ namespace ElectronicsShopUserApp.Controllers {
|
|||||||
//ViewBag.Reports = APIClient.GetRequset<List<ProductViewModel>>($"api/main/getproducts"); Ïèñåì òàê æå ïîêà íåìà
|
//ViewBag.Reports = APIClient.GetRequset<List<ProductViewModel>>($"api/main/getproducts"); Ïèñåì òàê æå ïîêà íåìà
|
||||||
return View();
|
return View();
|
||||||
}
|
}
|
||||||
|
[HttpGet]
|
||||||
|
public IActionResult GetWordFile()
|
||||||
|
{
|
||||||
|
return new PhysicalFileResult("C:\\gg\\wordfile.docx", "application/vnd.openxmlformats-officedocument.wordprocessingml.document");
|
||||||
|
}
|
||||||
|
|
||||||
|
public IActionResult GetExcelFile()
|
||||||
|
{
|
||||||
|
return new PhysicalFileResult("C:\\gg\\excelfile.xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
||||||
|
}
|
||||||
|
[HttpPost]
|
||||||
|
public void ListPreserves(List<int> preserve, string type)
|
||||||
|
{/*
|
||||||
|
if (APIEmployee.Employee == null)
|
||||||
|
{
|
||||||
|
throw new Exception("Âû êàê ñóäà ïîïàëè? Ñóäà âõîä òîëüêî àâòîðèçîâàííûì");
|
||||||
|
}
|
||||||
|
ß Õóé çíàåò êàê îíî ôóðû÷èò, ÁÎÑÑ ß ÓÑÒÀË
|
||||||
|
if (preserve.Count <= 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Êîëè÷åñòâî äîëæíî áûòü áîëüøå 0");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(type))
|
||||||
|
{
|
||||||
|
throw new Exception("Íåâåðíûé òèï îò÷åòà");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (type == "docx")
|
||||||
|
{
|
||||||
|
APIEmployee.PostRequest("api/report/createroductlistwordfile", new ReportProductBindingModel
|
||||||
|
{
|
||||||
|
Preserve = preserve,
|
||||||
|
FileName = "C:\\gg\\wordfile.docx"
|
||||||
|
});
|
||||||
|
Response.Redirect("GetWordFile");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
APIEmployee.PostRequest("api/report/createproductlistexcelfile", new ReportProductBindingModel
|
||||||
|
{
|
||||||
|
Preserve = preserve,
|
||||||
|
FileName = "C:\\gg\\excelfile.xlsx"
|
||||||
|
});
|
||||||
|
Response.Redirect("GetExcelFile");
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,10 @@
|
|||||||
|
|
||||||
<div class="text-center">
|
<div class="text-center">
|
||||||
<h2 class="display-4">Отчёты</h2>
|
<h2 class="display-4">Отчёты</h2>
|
||||||
|
<div class="list-group">
|
||||||
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="ListPreserves">Списки оплат word</a>
|
||||||
|
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="AnimalVisitsAndDrugs">Заповедники и стоимость животных</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<form method="post">
|
<form method="post">
|
||||||
|
Loading…
Reference in New Issue
Block a user