diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/ReportLogic.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/ReportLogic.cs index 60826dc..d2e650f 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/ReportLogic.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogic/ReportLogic.cs @@ -16,8 +16,6 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic //Реализация бизнес-логики отчётов public class ReportLogic : IReportLogic { - private readonly IWorkPieceStorage _workPieceStorage; - private readonly IManufactureStorage _manufactureStorage; private readonly IOrderStorage _orderStorage; @@ -29,13 +27,13 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic private readonly AbstractSaveToPdf _saveToPdf; //инициализируем поля класса через контейнер - public ReportLogic(IManufactureStorage manufactureStorage, IWorkPieceStorage - workPieceStorage, IOrderStorage orderStorage, AbstractSaveToExcel saveToExcel, + public ReportLogic(IManufactureStorage manufactureStorage, + IOrderStorage orderStorage, AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf) { _manufactureStorage = manufactureStorage; - _workPieceStorage = workPieceStorage; _orderStorage = orderStorage; + _saveToExcel = saveToExcel; _saveToWord = saveToWord; _saveToPdf = saveToPdf; @@ -57,10 +55,10 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic TotalCount = 0 }; - foreach (var workPieces in manufacture.ManufactureWorkPieces) + foreach (var workPiece in manufacture.ManufactureWorkPieces) { - record.WorkPieces.Add(new (workPieces.Value.Item1.WorkPieceName, workPieces.Value.Item2)); - record.TotalCount += workPieces.Value.Item2; + record.WorkPieces.Add(new (workPiece.Value.Item1.WorkPieceName, workPiece.Value.Item2)); + record.TotalCount += workPiece.Value.Item2; } list.Add(record); @@ -84,18 +82,18 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogic .ToList(); } - //Сохранение заготовок в файл-Word - public void SaveWorkPiecesToWordFile(ReportBindingModel model) + //Сохранение мороженных в файл-Word + public void SaveManufacturesToWordFile(ReportBindingModel model) { _saveToWord.CreateDoc(new WordInfo { FileName = model.FileName, - Title = "Список заготовок", - WorkPieces = _workPieceStorage.GetFullList() + Title = "Список изделий", + Manufactures = _manufactureStorage.GetFullList() }); } - //Сохранение заготовок с указаеним продуктов в файл-Excel + //Сохранение заготовок с указаеним изделий в файл-Excel public void SaveManufactureWorkPieceToExcelFile(ReportBindingModel model) { _saveToExcel.CreateReport(new ExcelInfo diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index 6073116..88369c5 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -43,13 +43,13 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage rowIndex++; - foreach (var (Manufacure, Count) in mwp.Manufactures) + foreach (var (WorkPiece, Count) in mwp.WorkPieces) { InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "B", RowIndex = rowIndex, - Text = Manufacure, + Text = WorkPiece, StyleInfo = ExcelStyleInfoType.TextWithBroder }); diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToWord.cs index cd69068..bc41885 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -27,12 +27,12 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage }); //заполнение абзацев текстом - foreach (var workPiece in info.WorkPieces) + foreach (var manufacture in info.Manufactures) { CreateParagraph(new WordParagraph { - Texts = new List<(string, WordTextProperties)> { (workPiece.WorkPieceName + " ", new WordTextProperties { Bold = true, Size = "24", }), - (workPiece.Cost.ToString(), new WordTextProperties { Size = "24" }) }, + Texts = new List<(string, WordTextProperties)> { (manufacture.ManufactureName + " ", new WordTextProperties { Bold = true, Size = "24", }), + (manufacture.Price.ToString(), new WordTextProperties { Size = "24" }) }, TextProperties = new WordTextProperties { Size = "24", diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/HelperModels/WordInfo.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/HelperModels/WordInfo.cs index 90fa064..85163eb 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/HelperModels/WordInfo.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/HelperModels/WordInfo.cs @@ -15,6 +15,6 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.HelperModels public string Title { get; set; } = string.Empty; //список заготовок для вывода и сохранения - public List WorkPieces { get; set; } = new(); + public List Manufactures { get; set; } = new(); } } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/Implements/SaveToExcel.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/Implements/SaveToExcel.cs index 951dc7a..e3891b4 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/Implements/SaveToExcel.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/Implements/SaveToExcel.cs @@ -17,7 +17,9 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.Implements public class SaveToExcel : AbstractSaveToExcel { private SpreadsheetDocument? _spreadsheetDocument; + private SharedStringTablePart? _shareStringPart; + private Worksheet? _worksheet; //Настройка стилей для файла @@ -28,6 +30,7 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.Implements //настройка шрифта простого текста var fonts = new Fonts() { Count = 2U, KnownFonts = true }; + var fontUsual = new Font(); fontUsual.Append(new FontSize() { Val = 12D }); fontUsual.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Theme = 1U }); @@ -68,8 +71,8 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.Implements //стиль границ ячейки - незакрашенный (для заголовка) и закрашенный var borders = new Borders() { Count = 2U }; - var borderNoBorder = new Border(); + var borderNoBorder = new Border(); borderNoBorder.Append(new LeftBorder()); borderNoBorder.Append(new RightBorder()); borderNoBorder.Append(new TopBorder()); @@ -77,26 +80,23 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.Implements borderNoBorder.Append(new DiagonalBorder()); var borderThin = new Border(); - var leftBorder = new LeftBorder() { Style = BorderStyleValues.Thin }; + var leftBorder = new LeftBorder() { Style = BorderStyleValues.Thin }; leftBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U }); var rightBorder = new RightBorder() { Style = BorderStyleValues.Thin }; - rightBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U }); var topBorder = new TopBorder() { Style = BorderStyleValues.Thin }; - topBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U }); var bottomBorder = new BottomBorder() { Style = BorderStyleValues.Thin }; - bottomBorder.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color() { Indexed = 64U }); borderThin.Append(leftBorder); diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/Implements/SaveToPdf.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/Implements/SaveToPdf.cs index a65ee9a..0bba629 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/Implements/SaveToPdf.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/Implements/SaveToPdf.cs @@ -62,10 +62,10 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.Implements { return; } + var paragraph = _section.AddParagraph(pdfParagraph.Text); paragraph.Format.SpaceAfter = "1cm"; - paragraph.Format.Alignment = - GetParagraphAlignment(pdfParagraph.ParagraphAlignment); + paragraph.Format.Alignment = GetParagraphAlignment(pdfParagraph.ParagraphAlignment); paragraph.Style = pdfParagraph.Style; } @@ -111,6 +111,7 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage.Implements row.Cells[i].Borders.Right.Width = borderWidth; row.Cells[i].Borders.Top.Width = borderWidth; row.Cells[i].Borders.Bottom.Width = borderWidth; + row.Cells[i].Format.Alignment = GetParagraphAlignment(rowParameters.ParagraphAlignment); row.Cells[i].VerticalAlignment = VerticalAlignment.Center; } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IReportLogic.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IReportLogic.cs index 04531c8..c1c5c57 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IReportLogic.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/BusinessLogicsContracts/IReportLogic.cs @@ -16,10 +16,10 @@ namespace BlacksmithWorkshopContracts.BusinessLogicsContracts //Получение списка заказов за определенный период List GetOrders(ReportBindingModel model); - //Сохранение заготовок в файл-Word - void SaveWorkPiecesToWordFile(ReportBindingModel model); + //Сохранение изделий в файл-Word + void SaveManufacturesToWordFile(ReportBindingModel model); - //Сохранение заготовок с указаеним изделий в файл-Excel + //Сохранение заготовок с указанием изделий в файл-Excel void SaveManufactureWorkPieceToExcelFile(ReportBindingModel model); //Сохранение заказов в файл-Pdf