diff --git a/.gitignore b/.gitignore
index ca1c7a3..d15b931 100644
--- a/.gitignore
+++ b/.gitignore
@@ -398,3 +398,7 @@ FodyWeavers.xsd
# JetBrains Rider
*.sln.iml
+/LawFirm/ImplementationExtensions/LawFirmListImplement.dll
+/LawFirm/ImplementationExtensions/LawFirmFileImplement.dll
+/LawFirm/ImplementationExtensions/LawFirmDataModel.dll
+/LawFirm/ImplementationExtensions/LawFirmContracts.dll
diff --git a/LawFirm/LawFirmBusinessLogic/BusinessLogics/OrderLogic.cs b/LawFirm/LawFirmBusinessLogic/BusinessLogics/OrderLogic.cs
index c6db378..1c295c5 100644
--- a/LawFirm/LawFirmBusinessLogic/BusinessLogics/OrderLogic.cs
+++ b/LawFirm/LawFirmBusinessLogic/BusinessLogics/OrderLogic.cs
@@ -132,7 +132,7 @@ namespace LawFirmBusinessLogic.BusinessLogics
throw new ArgumentNullException("Сумма заказа должна быть больше 0",
nameof(model.Sum));
}
- _logger.LogInformation("Document. OrderID:{Id}. Sum:{Sum}. DocumentID:{DocumentID}.}",
+ _logger.LogInformation("Order. OrderID:{Id}. Sum:{Sum}. DocumentID:{DocumentID}.}",
model.Id, model.Sum, model.DocumentId);
}
}
diff --git a/LawFirm/LawFirmBusinessLogic/BusinessLogics/ReportLogic.cs b/LawFirm/LawFirmBusinessLogic/BusinessLogics/ReportLogic.cs
new file mode 100644
index 0000000..537f2f7
--- /dev/null
+++ b/LawFirm/LawFirmBusinessLogic/BusinessLogics/ReportLogic.cs
@@ -0,0 +1,197 @@
+using LawFirmBusinessLogic.OfficePackage;
+using LawFirmBusinessLogic.OfficePackage.HelperModels;
+using LawFirmContracts.BindingModels;
+using LawFirmContracts.BusinessLogicsContracts;
+using LawFirmContracts.SearchModels;
+using LawFirmContracts.StoragesContracts;
+using LawFirmContracts.ViewModels;
+
+namespace LawFirmBusinessLogic.BusinessLogics
+{
+ public class ReportLogic : IReportLogic
+ {
+ private readonly IBlankStorage _blankStorage;
+ private readonly IDocumentStorage _documentStorage;
+ private readonly IOrderStorage _orderStorage;
+ private readonly IShopStorage _shopStorage;
+
+ private readonly AbstractSaveToExcel _saveToExcel;
+ private readonly AbstractSaveToWord _saveToWord;
+ private readonly AbstractSaveToPdf _saveToPdf;
+ public ReportLogic(IDocumentStorage documentStorage,
+ IBlankStorage blankStorage,
+ IOrderStorage orderStorage,
+ IShopStorage shopStorage,
+ AbstractSaveToExcel saveToExcel,
+ AbstractSaveToWord saveToWord,
+ AbstractSaveToPdf saveToPdf)
+ {
+ _documentStorage = documentStorage;
+ _blankStorage = blankStorage;
+ _orderStorage = orderStorage;
+ _saveToExcel = saveToExcel;
+ _saveToWord = saveToWord;
+ _saveToPdf = saveToPdf;
+ _shopStorage = shopStorage;
+ }
+ ///
+ /// Получение списка компонент с указанием, в каких изделиях используются
+ ///
+ ///
+ public List GetDocumentBlank()
+ {
+ var blanks = _blankStorage.GetFullList();
+ var documents = _documentStorage.GetFullList();
+ var list = new List();
+ foreach (var document in documents)
+ {
+ var record = new ReportDocumentBlankViewModel
+ {
+ DocumentName = document.DocumentName,
+ Blanks = new List>(),
+ TotalCount = 0
+ };
+ foreach (var blank in blanks)
+ {
+ if (document.DocumentBlanks.ContainsKey(blank.Id))
+ {
+ record.Blanks.Add(new Tuple(blank.BlankName, document.DocumentBlanks[blank.Id].Item2));
+ record.TotalCount += document.DocumentBlanks[blank.Id].Item2;
+ }
+ }
+ list.Add(record);
+ }
+ return list;
+ }
+ ///
+ /// Получение списка заказов за определенный период
+ ///
+ ///
+ ///
+ public List GetOrders(ReportBindingModel model)
+ {
+ return _orderStorage.GetFilteredList(new OrderSearchModel
+ {
+ DateFrom = model.DateFrom,
+ DateTo = model.DateTo
+ })
+ .Select(x => new ReportOrdersViewModel
+ {
+ Id = x.Id,
+ DateCreate = x.DateCreate,
+ DocumentName = x.DocumentName,
+ OrderStatus = x.Status.ToString(),
+ Sum = x.Sum
+ })
+ .ToList();
+ }
+ ///
+ /// Сохранение компонент в файл-Word
+ ///
+ ///
+ public void SaveBlanksToWordFile(ReportBindingModel model)
+ {
+ _saveToWord.CreateDoc(new WordInfo
+ {
+ FileName = model.FileName,
+ Title = "Список бланков",
+ Documents = _documentStorage.GetFullList()
+ });
+ }
+ ///
+ /// Сохранение продукта с указаеним компонент в файл-Excel
+ ///
+ ///
+ public void SaveDocumentBlankToExcelFile(ReportBindingModel model)
+ {
+ _saveToExcel.CreateReport(new ExcelInfo
+ {
+ FileName = model.FileName,
+ Title = "Документы и их бланки",
+ DocumentBlanks = GetDocumentBlank()
+ });
+ }
+ ///
+ /// Сохранение заказов в файл-Pdf
+ ///
+ ///
+ public void SaveOrdersToPdfFile(ReportBindingModel model)
+ {
+ _saveToPdf.CreateDoc(new PdfInfo
+ {
+ FileName = model.FileName,
+ Title = "Список заказов",
+ DateFrom = DateTime.SpecifyKind(model.DateFrom!.Value, DateTimeKind.Utc),
+ DateTo = DateTime.SpecifyKind(model.DateTo!.Value, DateTimeKind.Utc),
+ Orders = GetOrders(model)
+ });
+ }
+
+ public List GetShopDocuments()
+ {
+ var shops = _shopStorage.GetFullList();
+
+ var list = new List();
+
+ foreach (var shop in shops)
+ {
+ var record = new ReportShopDocumentViewModel
+ {
+ ShopName = shop.ShopName,
+ Documents = new List<(string, int)>(),
+ TotalCount = 0
+ };
+ foreach (var document in shop.ShopDocuments)
+ {
+ record.Documents.Add(new(document.Value.Item1.DocumentName, shop.ShopDocuments[document.Value.Item1.Id].Item2));
+ record.TotalCount += shop.ShopDocuments[document.Value.Item1.Id].Item2;
+ }
+
+ list.Add(record);
+ }
+
+ return list;
+ }
+ public void SaveShopDocumentToExcelFile(ReportBindingModel model)
+ {
+ _saveToExcel.CreateShopReport(new ExcelInfo
+ {
+ FileName = model.FileName,
+ Title = "Заполненность магазинов",
+ ShopDocuments = GetShopDocuments()
+ });
+ }
+
+ public List GetGroupedByDateOrders()
+ {
+ return _orderStorage.GetFullList().GroupBy(x => x.DateCreate.Date)
+ .Select(x => new ReportOrdersGroupedByDateViewModel
+ {
+ Date = x.Key,
+ Count = x.Count(),
+ Sum = x.Sum(y => y.Sum)
+ })
+ .ToList();
+ }
+
+ public void SaveGroupedByDateOrders(ReportBindingModel model)
+ {
+ _saveToPdf.CreateDocWithGroupedOrders(new PdfInfo
+ {
+ FileName = model.FileName,
+ Title = "Заказы по дате",
+ GroupedOrders = GetGroupedByDateOrders(),
+ });
+ }
+
+ public void SaveShopsToWordFile(ReportBindingModel model)
+ {
+ _saveToWord.CreateShopsTable(new WordInfo
+ {
+ FileName = model.FileName,
+ Title = "Список магазинов",
+ Shops = _shopStorage.GetFullList()
+ });
+ }
+ }
+}
diff --git a/LawFirm/LawFirmBusinessLogic/LawFirmBusinessLogic.csproj b/LawFirm/LawFirmBusinessLogic/LawFirmBusinessLogic.csproj
index b0452d6..f8cbb9f 100644
--- a/LawFirm/LawFirmBusinessLogic/LawFirmBusinessLogic.csproj
+++ b/LawFirm/LawFirmBusinessLogic/LawFirmBusinessLogic.csproj
@@ -7,7 +7,9 @@
+
+
diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToExcel.cs
new file mode 100644
index 0000000..2a94ed8
--- /dev/null
+++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToExcel.cs
@@ -0,0 +1,166 @@
+using LawFirmBusinessLogic.OfficePackage.HelperEnums;
+using LawFirmBusinessLogic.OfficePackage.HelperModels;
+
+namespace LawFirmBusinessLogic.OfficePackage
+{
+ public abstract class AbstractSaveToExcel
+ {
+ ///
+ /// Создание отчета
+ ///
+ ///
+ public void CreateReport(ExcelInfo info)
+ {
+ CreateExcel(info);
+ InsertCellInWorksheet(new ExcelCellParameters
+ {
+ ColumnName = "A",
+ RowIndex = 1,
+ Text = info.Title,
+ StyleInfo = ExcelStyleInfoType.Title
+ });
+ MergeCells(new ExcelMergeParameters
+ {
+ CellFromName = "A1",
+ CellToName = "C1"
+ });
+ uint rowIndex = 2;
+ foreach (var pc in info.DocumentBlanks)
+ {
+ InsertCellInWorksheet(new ExcelCellParameters
+ {
+ ColumnName = "A",
+ RowIndex = rowIndex,
+ Text = pc.DocumentName,
+ StyleInfo = ExcelStyleInfoType.Text
+ });
+ rowIndex++;
+ foreach (var (Blanks, Count) in pc.Blanks)
+ {
+ InsertCellInWorksheet(new ExcelCellParameters
+ {
+ ColumnName = "B",
+ RowIndex = rowIndex,
+ Text = Blanks,
+ StyleInfo = ExcelStyleInfoType.TextWithBroder
+ });
+ InsertCellInWorksheet(new ExcelCellParameters
+ {
+ ColumnName = "C",
+ RowIndex = rowIndex,
+ Text = Count.ToString(),
+ StyleInfo = ExcelStyleInfoType.TextWithBroder
+ });
+ rowIndex++;
+ }
+ InsertCellInWorksheet(new ExcelCellParameters
+ {
+ ColumnName = "A",
+ RowIndex = rowIndex,
+ Text = "Итого",
+ StyleInfo = ExcelStyleInfoType.Text
+ });
+ InsertCellInWorksheet(new ExcelCellParameters
+ {
+ ColumnName = "C",
+ RowIndex = rowIndex,
+ Text = pc.TotalCount.ToString(),
+ StyleInfo = ExcelStyleInfoType.Text
+ });
+ rowIndex++;
+ }
+ SaveExcel(info);
+ }
+ public void CreateShopReport(ExcelInfo info)
+ {
+ CreateExcel(info);
+
+ InsertCellInWorksheet(new ExcelCellParameters
+ {
+ ColumnName = "A",
+ RowIndex = 1,
+ Text = info.Title,
+ StyleInfo = ExcelStyleInfoType.Title
+ });
+
+ MergeCells(new ExcelMergeParameters
+ {
+ CellFromName = "A1",
+ CellToName = "C1"
+ });
+
+ uint rowIndex = 2;
+ foreach (var ss in info.ShopDocuments)
+ {
+ InsertCellInWorksheet(new ExcelCellParameters
+ {
+ ColumnName = "A",
+ RowIndex = rowIndex,
+ Text = ss.ShopName,
+ StyleInfo = ExcelStyleInfoType.Text
+ });
+ rowIndex++;
+
+ foreach (var (Document, Count) in ss.Documents)
+ {
+ InsertCellInWorksheet(new ExcelCellParameters
+ {
+ ColumnName = "B",
+ RowIndex = rowIndex,
+ Text = Document,
+ StyleInfo = ExcelStyleInfoType.TextWithBroder
+ });
+
+ InsertCellInWorksheet(new ExcelCellParameters
+ {
+ ColumnName = "C",
+ RowIndex = rowIndex,
+ Text = Count.ToString(),
+ StyleInfo = ExcelStyleInfoType.TextWithBroder
+ });
+
+ rowIndex++;
+ }
+
+ InsertCellInWorksheet(new ExcelCellParameters
+ {
+ ColumnName = "A",
+ RowIndex = rowIndex,
+ Text = "Итого",
+ StyleInfo = ExcelStyleInfoType.Text
+ });
+ InsertCellInWorksheet(new ExcelCellParameters
+ {
+ ColumnName = "C",
+ RowIndex = rowIndex,
+ Text = ss.TotalCount.ToString(),
+ StyleInfo = ExcelStyleInfoType.Text
+ });
+ rowIndex++;
+ }
+
+ SaveExcel(info);
+ }
+ ///
+ /// Создание excel-файла
+ ///
+ ///
+ protected abstract void CreateExcel(ExcelInfo info);
+ ///
+ /// Добавляем новую ячейку в лист
+ ///
+ ///
+ protected abstract void InsertCellInWorksheet(ExcelCellParameters
+ excelParams);
+ ///
+ /// Объединение ячеек
+ ///
+ ///
+ protected abstract void MergeCells(ExcelMergeParameters excelParams);
+ ///
+ /// Сохранение файла
+ ///
+ ///
+ protected abstract void SaveExcel(ExcelInfo info);
+ }
+}
diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToPdf.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToPdf.cs
new file mode 100644
index 0000000..79f644a
--- /dev/null
+++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToPdf.cs
@@ -0,0 +1,117 @@
+using AbstractShopBusinessLogic.OfficePackage.HelperModels;
+using LawFirmBusinessLogic.OfficePackage.HelperEnums;
+using LawFirmBusinessLogic.OfficePackage.HelperModels;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace LawFirmBusinessLogic.OfficePackage
+{
+ public abstract class AbstractSaveToPdf
+ {
+ public void CreateDoc(PdfInfo info)
+ {
+ CreatePdf(info);
+ CreateParagraph(new PdfParagraph
+ {
+ Text = info.Title,
+ Style = "NormalTitle",
+ ParagraphAlignment = PdfParagraphAlignmentType.Center
+ });
+ CreateParagraph(new PdfParagraph
+ {
+ Text = $"с { info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style
+ = "Normal",
+ ParagraphAlignment = PdfParagraphAlignmentType.Center
+ });
+ CreateTable(new List { "2cm", "3cm", "6cm", "3cm", "3cm" });
+ CreateRow(new PdfRowParameters
+ {
+ Texts = new List { "Номер", "Дата заказа", "Изделие", "Статус", "Сумма" },
+ Style = "NormalTitle",
+ ParagraphAlignment = PdfParagraphAlignmentType.Center
+ });
+ foreach (var order in info.Orders)
+ {
+ CreateRow(new PdfRowParameters
+ {
+ Texts = new List { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.DocumentName, order.OrderStatus, order.Sum.ToString() },
+ Style = "Normal",
+ ParagraphAlignment = PdfParagraphAlignmentType.Left
+ });
+ }
+ CreateParagraph(new PdfParagraph
+ {
+ Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t",
+ Style = "Normal",
+ ParagraphAlignment =
+ PdfParagraphAlignmentType.Rigth
+ });
+ SavePdf(info);
+ }
+ public void CreateDocWithGroupedOrders(PdfInfo info)
+ {
+ CreatePdf(info);
+ CreateParagraph(new PdfParagraph
+ {
+ Text = info.Title,
+ Style = "NormalTitle",
+ ParagraphAlignment = PdfParagraphAlignmentType.Center
+ });
+
+ CreateTable(new List { "3cm", "3cm", "3cm" });
+
+ CreateRow(new PdfRowParameters
+ {
+ Texts = new List { "Дата", "Количество", "Сумма" },
+ Style = "NormalTitle",
+ ParagraphAlignment = PdfParagraphAlignmentType.Center
+ });
+
+ foreach (var order in info.GroupedOrders)
+ {
+ CreateRow(new PdfRowParameters
+ {
+ Texts = new List { order.Date.ToShortDateString(), order.Count.ToString(), order.Sum.ToString() },
+ Style = "Normal",
+ ParagraphAlignment = PdfParagraphAlignmentType.Left
+ });
+ }
+ CreateParagraph(new PdfParagraph
+ {
+ Text = $"Итого: {info.GroupedOrders.Sum(x => x.Sum)}\t",
+ Style = "Normal",
+ ParagraphAlignment = PdfParagraphAlignmentType.Rigth
+ });
+
+ SavePdf(info);
+ }
+ ///
+ /// Создание doc-файла
+ ///
+ ///
+ protected abstract void CreatePdf(PdfInfo info);
+ ///
+ /// Создание параграфа с текстом
+ ///
+ ///
+ ///
+ protected abstract void CreateParagraph(PdfParagraph paragraph);
+ ///
+ /// Создание таблицы
+ ///
+ ///
+ ///
+ protected abstract void CreateTable(List columns);
+ ///
+ /// Создание и заполнение строки
+ ///
+ ///
+ protected abstract void CreateRow(PdfRowParameters rowParameters);
+ ///
+ /// Сохранение файла
+ ///
+ ///
+ protected abstract void SavePdf(PdfInfo info);
+ }
+}
diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToWord.cs
new file mode 100644
index 0000000..fb7a8f5
--- /dev/null
+++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToWord.cs
@@ -0,0 +1,92 @@
+using LawFirmBusinessLogic.OfficePackage.HelperEnums;
+using LawFirmBusinessLogic.OfficePackage.HelperModels;
+using System.Collections.Generic;
+
+namespace LawFirmBusinessLogic.OfficePackage
+{
+ public abstract class AbstractSaveToWord
+ {
+ public void CreateDoc(WordInfo info)
+ {
+ CreateWord(info);
+ CreateParagraph(new WordParagraph
+ {
+ Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) },
+ TextProperties = new WordTextProperties
+ {
+ Size = "24",
+ JustificationType = WordJustificationType.Center
+ }
+ });
+ foreach (var blank in info.Documents)
+ {
+ CreateParagraph(new WordParagraph
+ {
+ Texts = new List<(string, WordTextProperties)> {
+ (blank.DocumentName + " - ", new WordTextProperties { Size = "24", Bold=true}),
+ (blank.Price.ToString(), new WordTextProperties { Size = "24", })
+ },
+ TextProperties = new WordTextProperties
+ {
+ Size = "24",
+ JustificationType = WordJustificationType.Both
+ }
+ });
+ }
+ SaveWord(info);
+ }
+ public void CreateShopsTable(WordInfo info)
+ {
+ CreateWord(info);
+ CreateParagraph(new WordParagraph
+ {
+ Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24" }) },
+ TextProperties = new WordTextProperties
+ {
+ Size = "24",
+ JustificationType = WordJustificationType.Center
+ }
+ });
+ List<(string, WordTextProperties)> shopsInfo = new()
+ {
+ { ("Название", new WordTextProperties { Bold = true, Size = "24" }) },
+ { ("Адрес", new WordTextProperties { Bold = true, Size = "24" }) },
+ { ("Дата открытия", new WordTextProperties { Bold = true, Size = "24" }) }
+ };
+ foreach (var shop in info.Shops)
+ {
+ shopsInfo.Add((shop.ShopName, new WordTextProperties { Size = "20" }));
+ shopsInfo.Add((shop.Address, new WordTextProperties { Size = "20" }));
+ shopsInfo.Add((shop.DateOpen.ToString(), new WordTextProperties { Size = "20" }));
+ }
+ CreateTable(new WordParagraph
+ {
+ Texts = shopsInfo,
+ TextProperties = new WordTextProperties
+ {
+ Size = "24",
+ JustificationType = WordJustificationType.Center
+ }
+ }, 3);
+ SaveWord(info);
+
+ }
+ ///
+ /// Создание doc-файла
+ ///
+ ///
+ protected abstract void CreateWord(WordInfo info);
+ protected abstract void CreateTable(WordParagraph paragraph, int columnCount);
+ ///
+ /// Создание абзаца с текстом
+ ///
+ ///
+ ///
+ protected abstract void CreateParagraph(WordParagraph paragraph);
+ ///
+ /// Сохранение файла
+ ///
+ ///
+ protected abstract void SaveWord(WordInfo info);
+ }
+}
diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs
new file mode 100644
index 0000000..7f16019
--- /dev/null
+++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs
@@ -0,0 +1,9 @@
+namespace LawFirmBusinessLogic.OfficePackage.HelperEnums
+{
+ public enum ExcelStyleInfoType
+ {
+ Title,
+ Text,
+ TextWithBroder
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs
new file mode 100644
index 0000000..af7b87c
--- /dev/null
+++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs
@@ -0,0 +1,10 @@
+namespace LawFirmBusinessLogic.OfficePackage.HelperEnums
+{
+ public enum PdfParagraphAlignmentType
+ {
+ Center,
+ Left,
+ Rigth
+ }
+}
+
diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs
new file mode 100644
index 0000000..21f76a9
--- /dev/null
+++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs
@@ -0,0 +1,8 @@
+namespace LawFirmBusinessLogic.OfficePackage.HelperEnums
+{
+ public enum WordJustificationType
+ {
+ Center,
+ Both
+ }
+}
diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs
new file mode 100644
index 0000000..92ae329
--- /dev/null
+++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs
@@ -0,0 +1,13 @@
+using LawFirmBusinessLogic.OfficePackage.HelperEnums;
+
+namespace LawFirmBusinessLogic.OfficePackage.HelperModels
+{
+ public class ExcelCellParameters
+ {
+ public string ColumnName { get; set; } = string.Empty;
+ public uint RowIndex { get; set; }
+ public string Text { get; set; } = string.Empty;
+ public string CellReference => $"{ColumnName}{RowIndex}";
+ public ExcelStyleInfoType StyleInfo { get; set; }
+ }
+}
diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs
new file mode 100644
index 0000000..ffd6610
--- /dev/null
+++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs
@@ -0,0 +1,14 @@
+using LawFirmContracts.ViewModels;
+
+namespace LawFirmBusinessLogic.OfficePackage.HelperModels
+{
+ public class ExcelInfo
+ {
+ public string FileName { get; set; } = string.Empty;
+ public string Title { get; set; } = string.Empty;
+
+ public List DocumentBlanks { get; set; } = new();
+ public List ShopDocuments { get; set; } = new();
+ }
+
+}
diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs
new file mode 100644
index 0000000..3fb3275
--- /dev/null
+++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs
@@ -0,0 +1,9 @@
+namespace LawFirmBusinessLogic.OfficePackage.HelperModels
+{
+ public class ExcelMergeParameters
+ {
+ public string CellFromName { get; set; } = string.Empty;
+ public string CellToName { get; set; } = string.Empty;
+ public string Merge => $"{CellFromName}:{CellToName}";
+ }
+}
diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs
new file mode 100644
index 0000000..602ace5
--- /dev/null
+++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs
@@ -0,0 +1,14 @@
+using LawFirmContracts.ViewModels;
+
+namespace LawFirmBusinessLogic.OfficePackage.HelperModels
+{
+ public class PdfInfo
+ {
+ public string FileName { get; set; } = string.Empty;
+ public string Title { get; set; } = string.Empty;
+ public DateTime DateFrom { get; set; }
+ public DateTime DateTo { get; set; }
+ public List Orders { get; set; } = new();
+ public List GroupedOrders { get; set; } = new();
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs
new file mode 100644
index 0000000..d7659ea
--- /dev/null
+++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs
@@ -0,0 +1,11 @@
+using LawFirmBusinessLogic.OfficePackage.HelperEnums;
+
+namespace LawFirmBusinessLogic.OfficePackage.HelperModels
+{
+ public class PdfParagraph
+ {
+ public string Text { get; set; } = string.Empty;
+ public string Style { get; set; } = string.Empty;
+ public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs
new file mode 100644
index 0000000..2ba2944
--- /dev/null
+++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs
@@ -0,0 +1,11 @@
+using LawFirmBusinessLogic.OfficePackage.HelperEnums;
+
+namespace AbstractShopBusinessLogic.OfficePackage.HelperModels
+{
+ public class PdfRowParameters
+ {
+ public List Texts { get; set; } = new();
+ public string Style { get; set; } = string.Empty;
+ public PdfParagraphAlignmentType ParagraphAlignment { get; set; }
+ }
+}
diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/WordInfo.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/WordInfo.cs
new file mode 100644
index 0000000..f6efb4a
--- /dev/null
+++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/WordInfo.cs
@@ -0,0 +1,12 @@
+using LawFirmContracts.ViewModels;
+
+namespace LawFirmBusinessLogic.OfficePackage.HelperModels
+{
+ public class WordInfo
+ {
+ public string FileName { get; set; } = string.Empty;
+ public string Title { get; set; } = string.Empty;
+ public List Documents { get; set; } = new();
+ public List Shops { get; set; } = new();
+ }
+}
diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs
new file mode 100644
index 0000000..2e53e33
--- /dev/null
+++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs
@@ -0,0 +1,8 @@
+namespace LawFirmBusinessLogic.OfficePackage.HelperModels
+{
+ public class WordParagraph
+ {
+ public List<(string, WordTextProperties)> Texts { get; set; } = new();
+ public WordTextProperties? TextProperties { get; set; }
+ }
+}
diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs
new file mode 100644
index 0000000..900675f
--- /dev/null
+++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs
@@ -0,0 +1,12 @@
+using LawFirmBusinessLogic.OfficePackage.HelperEnums;
+
+namespace LawFirmBusinessLogic.OfficePackage.HelperModels
+{
+ public class WordTextProperties
+ {
+ public string Size { get; set; } = string.Empty;
+ public bool Bold { get; set; }
+ public WordJustificationType JustificationType { get; set; }
+
+ }
+}
diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/Implements/SaveToExcel.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/Implements/SaveToExcel.cs
new file mode 100644
index 0000000..72668bf
--- /dev/null
+++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/Implements/SaveToExcel.cs
@@ -0,0 +1,351 @@
+using LawFirmBusinessLogic.OfficePackage.HelperEnums;
+using LawFirmBusinessLogic.OfficePackage.HelperModels;
+using DocumentFormat.OpenXml;
+using DocumentFormat.OpenXml.Office2010.Excel;
+using DocumentFormat.OpenXml.Office2013.Excel;
+using DocumentFormat.OpenXml.Packaging;
+using DocumentFormat.OpenXml.Spreadsheet;
+using DocumentFormat.OpenXml.Office2016.Excel;
+
+namespace LawFirmBusinessLogic.OfficePackage.Implements
+{
+ public class SaveToExcel : AbstractSaveToExcel
+ {
+ private SpreadsheetDocument? _spreadsheetDocument;
+ private SharedStringTablePart? _shareStringPart;
+ private Worksheet? _worksheet;
+ ///
+ /// Настройка стилей для файла
+ ///
+ ///
+ private static void CreateStyles(WorkbookPart workbookpart)
+ {
+ var sp = workbookpart.AddNewPart();
+ sp.Stylesheet = new Stylesheet();
+ 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 });
+ fontUsual.Append(new FontName() { Val = "Times New Roman" });
+ fontUsual.Append(new FontFamilyNumbering() { Val = 2 });
+ fontUsual.Append(new FontScheme() { Val = FontSchemeValues.Minor });
+ var fontTitle = new Font();
+ fontTitle.Append(new Bold());
+ fontTitle.Append(new FontSize() { Val = 14D });
+ fontTitle.Append(new DocumentFormat.OpenXml.Office2010.Excel.Color()
+ { Theme = 1U });
+ fontTitle.Append(new FontName() { Val = "Times New Roman" });
+ fontTitle.Append(new FontFamilyNumbering() { Val = 2 });
+ fontTitle.Append(new FontScheme() { Val = FontSchemeValues.Minor });
+ fonts.Append(fontUsual);
+ fonts.Append(fontTitle);
+ var fills = new Fills() { Count = 2U };
+ var fill1 = new Fill();
+ fill1.Append(new PatternFill() { PatternType = PatternValues.None });
+ var fill2 = new Fill();
+ fill2.Append(new PatternFill()
+ {
+ PatternType = PatternValues.Gray125
+ });
+ fills.Append(fill1);
+ fills.Append(fill2);
+ var borders = new Borders() { Count = 2U };
+ var borderNoBorder = new Border();
+ borderNoBorder.Append(new LeftBorder());
+ borderNoBorder.Append(new RightBorder());
+ borderNoBorder.Append(new TopBorder());
+ borderNoBorder.Append(new BottomBorder());
+ borderNoBorder.Append(new DiagonalBorder());
+ var borderThin = new Border();
+ 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);
+ borderThin.Append(rightBorder);
+ borderThin.Append(topBorder);
+ borderThin.Append(bottomBorder);
+ borderThin.Append(new DiagonalBorder());
+ borders.Append(borderNoBorder);
+ borders.Append(borderThin);
+ var cellStyleFormats = new CellStyleFormats() { Count = 1U };
+ var cellFormatStyle = new CellFormat()
+ {
+ NumberFormatId = 0U,
+ FontId
+ = 0U,
+ FillId = 0U,
+ BorderId = 0U
+ };
+ cellStyleFormats.Append(cellFormatStyle);
+ var cellFormats = new CellFormats() { Count = 3U };
+ var cellFormatFont = new CellFormat()
+ {
+ NumberFormatId = 0U,
+ FontId =
+ 0U,
+ FillId = 0U,
+ BorderId = 0U,
+ FormatId = 0U,
+ ApplyFont = true
+ };
+ var cellFormatFontAndBorder = new CellFormat()
+ {
+ NumberFormatId = 0U,
+ FontId = 0U,
+ FillId = 0U,
+ BorderId = 1U,
+ FormatId = 0U,
+ ApplyFont = true,
+ ApplyBorder = true
+ };
+ var cellFormatTitle = new CellFormat()
+ {
+ NumberFormatId = 0U,
+ FontId
+ = 1U,
+ FillId = 0U,
+ BorderId = 0U,
+ FormatId = 0U,
+ Alignment = new Alignment()
+ {
+ Vertical = VerticalAlignmentValues.Center,
+ WrapText = true,
+ Horizontal =
+ HorizontalAlignmentValues.Center
+ },
+ ApplyFont = true
+ };
+ cellFormats.Append(cellFormatFont);
+ cellFormats.Append(cellFormatFontAndBorder);
+ cellFormats.Append(cellFormatTitle);
+ var cellStyles = new CellStyles() { Count = 1U };
+ cellStyles.Append(new CellStyle()
+ {
+ Name = "Normal",
+ FormatId = 0U,
+ BuiltinId = 0U
+ });
+ var differentialFormats = new
+ DocumentFormat.OpenXml.Office2013.Excel.DifferentialFormats()
+ { Count = 0U };
+
+ var tableStyles = new TableStyles()
+ {
+ Count = 0U,
+ DefaultTableStyle =
+ "TableStyleMedium2",
+ DefaultPivotStyle = "PivotStyleLight16"
+ };
+ var stylesheetExtensionList = new StylesheetExtensionList();
+ var stylesheetExtension1 = new StylesheetExtension()
+ {
+ Uri =
+ "{EB79DEF2-80B8-43e5-95BD-54CBDDF9020C}"
+ };
+ stylesheetExtension1.AddNamespaceDeclaration("x14",
+ "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main");
+ stylesheetExtension1.Append(new SlicerStyles()
+ {
+ DefaultSlicerStyle =
+ "SlicerStyleLight1"
+ });
+ var stylesheetExtension2 = new StylesheetExtension()
+ {
+ Uri =
+ "{9260A510-F301-46a8-8635-F512D64BE5F5}"
+ };
+ stylesheetExtension2.AddNamespaceDeclaration("x15",
+ "http://schemas.microsoft.com/office/spreadsheetml/2010/11/main");
+ stylesheetExtension2.Append(new TimelineStyles()
+ {
+ DefaultTimelineStyle = "TimeSlicerStyleLight1"
+ });
+ stylesheetExtensionList.Append(stylesheetExtension1);
+ stylesheetExtensionList.Append(stylesheetExtension2);
+ sp.Stylesheet.Append(fonts);
+ sp.Stylesheet.Append(fills);
+ sp.Stylesheet.Append(borders);
+ sp.Stylesheet.Append(cellStyleFormats);
+ sp.Stylesheet.Append(cellFormats);
+ sp.Stylesheet.Append(cellStyles);
+ sp.Stylesheet.Append(differentialFormats);
+ sp.Stylesheet.Append(tableStyles);
+ sp.Stylesheet.Append(stylesheetExtensionList);
+ }
+ ///
+ /// Получение номера стиля из типа
+ ///
+ ///
+ ///
+ private static uint GetStyleValue(ExcelStyleInfoType styleInfo)
+ {
+ return styleInfo switch
+ {
+ ExcelStyleInfoType.Title => 2U,
+ ExcelStyleInfoType.TextWithBroder => 1U,
+ ExcelStyleInfoType.Text => 0U,
+ _ => 0U,
+ };
+ }
+ protected override void CreateExcel(ExcelInfo info)
+ {
+ _spreadsheetDocument = SpreadsheetDocument.Create(info.FileName,
+ SpreadsheetDocumentType.Workbook);
+ // Создаем книгу (в ней хранятся листы)
+ var workbookpart = _spreadsheetDocument.AddWorkbookPart();
+ workbookpart.Workbook = new Workbook();
+ CreateStyles(workbookpart);
+ // Получаем/создаем хранилище текстов для книги
+ _shareStringPart =
+ _spreadsheetDocument.WorkbookPart!.GetPartsOfType().Any()
+ ?
+ _spreadsheetDocument.WorkbookPart.GetPartsOfType().First()
+ :
+ _spreadsheetDocument.WorkbookPart.AddNewPart();
+ // Создаем SharedStringTable, если его нет
+ if (_shareStringPart.SharedStringTable == null)
+ {
+ _shareStringPart.SharedStringTable = new SharedStringTable();
+ }
+ // Создаем лист в книгу
+ var worksheetPart = workbookpart.AddNewPart();
+ worksheetPart.Worksheet = new Worksheet(new SheetData());
+ // Добавляем лист в книгу
+ var sheets =
+ _spreadsheetDocument.WorkbookPart.Workbook.AppendChild(new Sheets());
+ var sheet = new Sheet()
+ {
+ Id =
+ _spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
+ SheetId = 1,
+ Name = "Лист"
+ };
+ sheets.Append(sheet);
+ _worksheet = worksheetPart.Worksheet;
+ }
+ protected override void InsertCellInWorksheet(ExcelCellParameters
+ excelParams)
+ {
+ if (_worksheet == null || _shareStringPart == null)
+ {
+ return;
+ }
+ var sheetData = _worksheet.GetFirstChild();
+ if (sheetData == null)
+ {
+ return;
+ }
+ // Ищем строку, либо добавляем ее
+ Row row;
+ if (sheetData.Elements().Where(r => r.RowIndex! ==
+ excelParams.RowIndex).Any())
+ {
+ row = sheetData.Elements().Where(r => r.RowIndex! ==
+ excelParams.RowIndex).First();
+ }
+ else
+ {
+ row = new Row() { RowIndex = excelParams.RowIndex };
+ sheetData.Append(row);
+ }
+ // Ищем нужную ячейку
+ Cell cell;
+ if (row.Elements().Where(c => c.CellReference!.Value ==
+ excelParams.CellReference).Any())
+ {
+ cell = row.Elements().Where(c => c.CellReference!.Value ==
+ excelParams.CellReference).First();
+ }
+ else
+ {
+ // Все ячейки должны быть последовательно друг за другом расположены
+ // нужно определить, после какой вставлять
+ Cell? refCell = null;
+ foreach (Cell rowCell in row.Elements())
+ {
+ if (string.Compare(rowCell.CellReference!.Value,
+ excelParams.CellReference, true) > 0)
+ {
+ refCell = rowCell;
+ break;
+ }
+ }
+ var newCell = new Cell()
+ {
+ CellReference =
+ excelParams.CellReference
+ };
+ row.InsertBefore(newCell, refCell);
+ cell = newCell;
+ }
+ // вставляем новый текст
+ _shareStringPart.SharedStringTable.AppendChild(new
+ SharedStringItem(new Text(excelParams.Text)));
+ _shareStringPart.SharedStringTable.Save();
+ cell.CellValue = new
+ CellValue((_shareStringPart.SharedStringTable.Elements().Count(
+ ) - 1).ToString());
+ cell.DataType = new EnumValue(CellValues.SharedString);
+ cell.StyleIndex = GetStyleValue(excelParams.StyleInfo);
+ }
+ protected override void MergeCells(ExcelMergeParameters excelParams)
+ {
+ if (_worksheet == null)
+ {
+ return;
+ }
+ MergeCells mergeCells;
+ if (_worksheet.Elements().Any())
+ {
+ mergeCells = _worksheet.Elements().First();
+ }
+ else
+ {
+ mergeCells = new MergeCells();
+ if (_worksheet.Elements().Any())
+ {
+ _worksheet.InsertAfter(mergeCells,
+ _worksheet.Elements().First());
+ }
+ else
+ {
+ _worksheet.InsertAfter(mergeCells,
+ _worksheet.Elements().First());
+ }
+ }
+ var mergeCell = new MergeCell()
+ {
+ Reference = new StringValue(excelParams.Merge)
+ };
+ mergeCells.Append(mergeCell);
+ }
+ protected override void SaveExcel(ExcelInfo info)
+ {
+ if (_spreadsheetDocument == null)
+ {
+ return;
+ }
+ _spreadsheetDocument.WorkbookPart!.Workbook.Save();
+ _spreadsheetDocument.Close();
+ }
+ }
+}
diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/Implements/SaveToPdf.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/Implements/SaveToPdf.cs
new file mode 100644
index 0000000..e207a48
--- /dev/null
+++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/Implements/SaveToPdf.cs
@@ -0,0 +1,102 @@
+using AbstractShopBusinessLogic.OfficePackage.HelperModels;
+using LawFirmBusinessLogic.OfficePackage.HelperEnums;
+using LawFirmBusinessLogic.OfficePackage.HelperModels;
+using MigraDoc.DocumentObjectModel;
+using MigraDoc.DocumentObjectModel.Tables;
+using MigraDoc.Rendering;
+
+namespace LawFirmBusinessLogic.OfficePackage.Implements
+{
+ public class SaveToPdf : AbstractSaveToPdf
+ {
+ private Document? _document;
+ private Section? _section;
+ private Table? _table;
+ private static ParagraphAlignment
+ GetParagraphAlignment(PdfParagraphAlignmentType type)
+ {
+ return type switch
+ {
+ PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
+ PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
+ PdfParagraphAlignmentType.Rigth => ParagraphAlignment.Right,
+ _ => ParagraphAlignment.Justify,
+ };
+ }
+ ///
+ /// Создание стилей для документа
+ ///
+ ///
+ private static void DefineStyles(Document document)
+ {
+ var style = document.Styles["Normal"];
+ style.Font.Name = "Times New Roman";
+ style.Font.Size = 14;
+ style = document.Styles.AddStyle("NormalTitle", "Normal");
+ style.Font.Bold = true;
+ }
+ protected override void CreatePdf(PdfInfo info)
+ {
+ _document = new Document();
+ DefineStyles(_document);
+ _section = _document.AddSection();
+ }
+ protected override void CreateParagraph(PdfParagraph pdfParagraph)
+ {
+ if (_section == null)
+ {
+ return;
+ }
+ var paragraph = _section.AddParagraph(pdfParagraph.Text);
+ paragraph.Format.SpaceAfter = "1cm";
+ paragraph.Format.Alignment =
+ GetParagraphAlignment(pdfParagraph.ParagraphAlignment);
+ paragraph.Style = pdfParagraph.Style;
+ }
+ protected override void CreateTable(List columns)
+ {
+ if (_document == null)
+ {
+ return;
+ }
+ _table = _document.LastSection.AddTable();
+ foreach (var elem in columns)
+ {
+ _table.AddColumn(elem);
+ }
+ }
+ protected override void CreateRow(PdfRowParameters rowParameters)
+ {
+ if (_table == null)
+ {
+ return;
+ }
+ var row = _table.AddRow();
+ for (int i = 0; i < rowParameters.Texts.Count; ++i)
+ {
+ row.Cells[i].AddParagraph(rowParameters.Texts[i]);
+ if (!string.IsNullOrEmpty(rowParameters.Style))
+ {
+ row.Cells[i].Style = rowParameters.Style;
+ }
+ Unit borderWidth = 0.5;
+ row.Cells[i].Borders.Left.Width = borderWidth;
+ 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;
+ }
+ }
+ protected override void SavePdf(PdfInfo info)
+ {
+ var renderer = new PdfDocumentRenderer(true)
+ {
+ Document = _document
+ };
+ renderer.RenderDocument();
+ renderer.PdfDocument.Save(info.FileName);
+ }
+ }
+}
diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/Implements/SaveToWord.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/Implements/SaveToWord.cs
new file mode 100644
index 0000000..0bbb248
--- /dev/null
+++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/Implements/SaveToWord.cs
@@ -0,0 +1,175 @@
+using LawFirmBusinessLogic.OfficePackage.HelperEnums;
+using LawFirmBusinessLogic.OfficePackage.HelperModels;
+using DocumentFormat.OpenXml;
+using DocumentFormat.OpenXml.Packaging;
+using DocumentFormat.OpenXml.Wordprocessing;
+
+namespace LawFirmBusinessLogic.OfficePackage.Implements
+{
+ public class SaveToWord : AbstractSaveToWord
+ {
+ private WordprocessingDocument? _wordDocument;
+ private Body? _docBody;
+ ///
+ /// Получение типа выравнивания
+ ///
+ ///
+ ///
+ private static JustificationValues
+ GetJustificationValues(WordJustificationType type)
+ {
+ return type switch
+ {
+ WordJustificationType.Both => JustificationValues.Both,
+ WordJustificationType.Center => JustificationValues.Center,
+ _ => JustificationValues.Left,
+ };
+ }
+ ///
+ /// Настройки страницы
+ ///
+ ///
+ private static SectionProperties CreateSectionProperties()
+ {
+ var properties = new SectionProperties();
+ var pageSize = new PageSize
+ {
+ Orient = PageOrientationValues.Portrait
+ };
+ properties.AppendChild(pageSize);
+ return properties;
+ }
+ ///
+ /// Задание форматирования для абзаца
+ ///
+ ///
+ ///
+ private static ParagraphProperties?
+ CreateParagraphProperties(WordTextProperties? paragraphProperties)
+ {
+ if (paragraphProperties == null)
+ {
+ return null;
+ }
+ var properties = new ParagraphProperties();
+ properties.AppendChild(new Justification()
+ {
+ Val = GetJustificationValues(paragraphProperties.JustificationType)
+ });
+ properties.AppendChild(new SpacingBetweenLines
+ {
+ LineRule = LineSpacingRuleValues.Auto
+ });
+ properties.AppendChild(new Indentation());
+ var paragraphMarkRunProperties = new ParagraphMarkRunProperties();
+ if (!string.IsNullOrEmpty(paragraphProperties.Size))
+ {
+ paragraphMarkRunProperties.AppendChild(new FontSize
+ {
+ Val = paragraphProperties.Size
+ });
+ }
+ properties.AppendChild(paragraphMarkRunProperties);
+ return properties;
+ }
+ protected override void CreateTable(WordParagraph paragraph, int columnCount)
+ {
+ if (_docBody == null || paragraph == null)
+ {
+ return;
+ }
+ Table table = new();
+ TableProperties properties = new();
+ properties.AppendChild(new TableLayout { Type = TableLayoutValues.Fixed });
+ properties.AppendChild(new TableBorders
+ (
+ new TopBorder() { Val = new EnumValue(BorderValues.Single), Size = 4 },
+ new LeftBorder() { Val = new EnumValue(BorderValues.Single), Size = 4 },
+ new RightBorder() { Val = new EnumValue(BorderValues.Single), Size = 4 },
+ new BottomBorder() { Val = new EnumValue(BorderValues.Single), Size = 4 },
+ new InsideHorizontalBorder() { Val = new EnumValue(BorderValues.Single), Size = 4 },
+ new InsideVerticalBorder() { Val = new EnumValue(BorderValues.Single), Size = 4 }
+ ));
+ properties.AppendChild(new TableWidth { Type = TableWidthUnitValues.Auto });
+ table.AppendChild(properties);
+ TableGrid tableGrid = new();
+ for (int j = 0; j < columnCount; ++j)
+ {
+ tableGrid.AppendChild(new GridColumn() { Width = "3400" });
+ }
+ table.AppendChild(tableGrid);
+ for (int i = 0; i < paragraph.Texts.Count; ++i)
+ {
+ TableRow tableRow = new();
+ for (int j = 0; j < columnCount; ++j)
+ {
+ var tableParagraph = new Paragraph();
+ tableParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties));
+ var tableRun = new Run();
+ var runProperties = new RunProperties();
+ runProperties.AppendChild(new FontSize { Val = paragraph.Texts[i + j].Item2.Size });
+ if (paragraph.Texts[i + j].Item2.Bold)
+ {
+ runProperties.AppendChild(new Bold());
+ }
+ tableRun.AppendChild(runProperties);
+ tableRun.AppendChild(new Text { Text = paragraph.Texts[i + j].Item1, Space = SpaceProcessingModeValues.Preserve });
+ tableParagraph.AppendChild(tableRun);
+ TableCell cell = new();
+ cell.AppendChild(tableParagraph);
+ tableRow.AppendChild(cell);
+ }
+ i += columnCount - 1;
+ table.AppendChild(tableRow);
+ }
+ _docBody.AppendChild(table);
+ }
+ protected override void CreateWord(WordInfo info)
+ {
+ _wordDocument = WordprocessingDocument.Create(info.FileName,
+ WordprocessingDocumentType.Document);
+ MainDocumentPart mainPart = _wordDocument.AddMainDocumentPart();
+ mainPart.Document = new Document();
+ _docBody = mainPart.Document.AppendChild(new Body());
+ }
+ protected override void CreateParagraph(WordParagraph paragraph)
+ {
+ if (_docBody == null || paragraph == null)
+ {
+ return;
+ }
+ var docParagraph = new Paragraph();
+
+ docParagraph.AppendChild(CreateParagraphProperties(paragraph.TextProperties));
+ foreach (var run in paragraph.Texts)
+ {
+ var docRun = new Run();
+ var properties = new RunProperties();
+ properties.AppendChild(new FontSize { Val = run.Item2.Size });
+ if (run.Item2.Bold)
+ {
+ properties.AppendChild(new Bold());
+ }
+ docRun.AppendChild(properties);
+ docRun.AppendChild(new Text
+ {
+ Text = run.Item1,
+ Space =
+ SpaceProcessingModeValues.Preserve
+ });
+ docParagraph.AppendChild(docRun);
+ }
+ _docBody.AppendChild(docParagraph);
+ }
+ protected override void SaveWord(WordInfo info)
+ {
+ if (_docBody == null || _wordDocument == null)
+ {
+ return;
+ }
+ _docBody.AppendChild(CreateSectionProperties());
+ _wordDocument.MainDocumentPart!.Document.Save();
+ _wordDocument.Close();
+ }
+ }
+}
diff --git a/LawFirm/LawFirmContracts/BindingModels/ReportBindingModel.cs b/LawFirm/LawFirmContracts/BindingModels/ReportBindingModel.cs
new file mode 100644
index 0000000..997e322
--- /dev/null
+++ b/LawFirm/LawFirmContracts/BindingModels/ReportBindingModel.cs
@@ -0,0 +1,9 @@
+namespace LawFirmContracts.BindingModels
+{
+ public class ReportBindingModel
+ {
+ public string FileName { get; set; } = string.Empty;
+ public DateTime? DateFrom { get; set; }
+ public DateTime? DateTo { get; set; }
+ }
+}
diff --git a/LawFirm/LawFirmContracts/BusinessLogicsContracts/IReportLogic.cs b/LawFirm/LawFirmContracts/BusinessLogicsContracts/IReportLogic.cs
new file mode 100644
index 0000000..296e1a1
--- /dev/null
+++ b/LawFirm/LawFirmContracts/BusinessLogicsContracts/IReportLogic.cs
@@ -0,0 +1,41 @@
+using LawFirmContracts.BindingModels;
+using LawFirmContracts.ViewModels;
+using System.Collections.Generic;
+
+namespace LawFirmContracts.BusinessLogicsContracts
+{
+ public interface IReportLogic
+ {
+ ///
+ /// Получение списка компонент с указанием, в каких изделиях используются
+ ///
+ ///
+ List GetDocumentBlank();
+ List GetShopDocuments();
+ List GetGroupedByDateOrders();
+ ///
+ /// Получение списка заказов за определенный период
+ ///
+ ///
+ ///
+ List GetOrders(ReportBindingModel model);
+ ///
+ /// Сохранение компонент в файл-Word
+ ///
+ ///
+ void SaveBlanksToWordFile(ReportBindingModel model);
+ void SaveShopsToWordFile(ReportBindingModel model);
+ ///
+ /// Сохранение компонент с указаеним продуктов в файл-Excel
+ ///
+ ///
+ void SaveDocumentBlankToExcelFile(ReportBindingModel model);
+ void SaveShopDocumentToExcelFile(ReportBindingModel model);
+ ///
+ /// Сохранение заказов в файл-Pdf
+ ///
+ ///
+ void SaveOrdersToPdfFile(ReportBindingModel model);
+ void SaveGroupedByDateOrders(ReportBindingModel model);
+ }
+}
diff --git a/LawFirm/LawFirmContracts/SearchModels/OrderSearchModel.cs b/LawFirm/LawFirmContracts/SearchModels/OrderSearchModel.cs
index 18f7733..9d0b312 100644
--- a/LawFirm/LawFirmContracts/SearchModels/OrderSearchModel.cs
+++ b/LawFirm/LawFirmContracts/SearchModels/OrderSearchModel.cs
@@ -3,5 +3,7 @@
public class OrderSearchModel
{
public int? Id { get; set; }
+ public DateTime? DateFrom { get; set; }
+ public DateTime? DateTo { get; set; }
}
}
diff --git a/LawFirm/LawFirmContracts/ViewModels/ReportDocumentBlankViewModel.cs b/LawFirm/LawFirmContracts/ViewModels/ReportDocumentBlankViewModel.cs
new file mode 100644
index 0000000..c435fff
--- /dev/null
+++ b/LawFirm/LawFirmContracts/ViewModels/ReportDocumentBlankViewModel.cs
@@ -0,0 +1,9 @@
+namespace LawFirmContracts.ViewModels
+{
+ public class ReportDocumentBlankViewModel
+ {
+ public string DocumentName { get; set; } = string.Empty;
+ public int TotalCount { get; set; }
+ public List> Blanks { get; set; } = new();
+ }
+}
diff --git a/LawFirm/LawFirmContracts/ViewModels/ReportOrdersGroupedByDateViewModel.cs b/LawFirm/LawFirmContracts/ViewModels/ReportOrdersGroupedByDateViewModel.cs
new file mode 100644
index 0000000..2079260
--- /dev/null
+++ b/LawFirm/LawFirmContracts/ViewModels/ReportOrdersGroupedByDateViewModel.cs
@@ -0,0 +1,15 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace LawFirmContracts.ViewModels
+{
+ public class ReportOrdersGroupedByDateViewModel
+ {
+ public DateTime Date { get; set; }
+ public int Count { get; set; }
+ public double Sum { get; set; }
+ }
+}
diff --git a/LawFirm/LawFirmContracts/ViewModels/ReportOrdersViewModel.cs b/LawFirm/LawFirmContracts/ViewModels/ReportOrdersViewModel.cs
new file mode 100644
index 0000000..473996b
--- /dev/null
+++ b/LawFirm/LawFirmContracts/ViewModels/ReportOrdersViewModel.cs
@@ -0,0 +1,11 @@
+namespace LawFirmContracts.ViewModels
+{
+ public class ReportOrdersViewModel
+ {
+ public int Id { get; set; }
+ public DateTime DateCreate { get; set; }
+ public string DocumentName { get; set; } = string.Empty;
+ public string OrderStatus { get; set; } = string.Empty;
+ public double Sum { get; set; }
+ }
+}
diff --git a/LawFirm/LawFirmContracts/ViewModels/ReportShopDocumentViewModel.cs b/LawFirm/LawFirmContracts/ViewModels/ReportShopDocumentViewModel.cs
new file mode 100644
index 0000000..cc6e2ee
--- /dev/null
+++ b/LawFirm/LawFirmContracts/ViewModels/ReportShopDocumentViewModel.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace LawFirmContracts.ViewModels
+{
+ public class ReportShopDocumentViewModel
+ {
+ public string ShopName { get; set; } = string.Empty;
+
+ public int TotalCount { get; set; }
+
+ public List<(string Document, int Count)> Documents { get; set; } = new();
+ }
+}
diff --git a/LawFirm/LawFirmDatabaseImplement/Implements/DocumentStorage.cs b/LawFirm/LawFirmDatabaseImplement/Implements/DocumentStorage.cs
index 9b1ad9a..b4f94ff 100644
--- a/LawFirm/LawFirmDatabaseImplement/Implements/DocumentStorage.cs
+++ b/LawFirm/LawFirmDatabaseImplement/Implements/DocumentStorage.cs
@@ -70,17 +70,17 @@ namespace LawFirmDatabaseImplement.Implements
using var transaction = context.Database.BeginTransaction();
try
{
- var product = context.Documents.FirstOrDefault(rec =>
+ var document = context.Documents.FirstOrDefault(rec =>
rec.Id == model.Id);
- if (product == null)
+ if (document == null)
{
return null;
}
- product.Update(model);
+ document.Update(model);
context.SaveChanges();
- product.UpdateBlanks(context, model);
+ document.UpdateBlanks(context, model);
transaction.Commit();
- return product.GetViewModel;
+ return document.GetViewModel;
}
catch
{
diff --git a/LawFirm/LawFirmDatabaseImplement/Implements/OrderStorage.cs b/LawFirm/LawFirmDatabaseImplement/Implements/OrderStorage.cs
index 89e7f6d..5497e2f 100644
--- a/LawFirm/LawFirmDatabaseImplement/Implements/OrderStorage.cs
+++ b/LawFirm/LawFirmDatabaseImplement/Implements/OrderStorage.cs
@@ -36,21 +36,29 @@ namespace LawFirmDatabaseImplement.Implements
using var context = new LawFirmDatabase();
- return GetViewModel(context.Orders
+ return context.Orders
.Include(x => x.Document)
- .FirstOrDefault(x => (model.Id.HasValue && x.Id == model.Id)));
+ .FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
+ ?.GetViewModel;
}
public List GetFilteredList(OrderSearchModel model)
{
- if (!model.Id.HasValue)
+ if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue)
{
return new();
}
using var context = new LawFirmDatabase();
-
- return context.Orders
+ if (model.DateFrom.HasValue)
+ {
+ return context.Orders
+ .Include(x => x.Document)
+ .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+ return context.Orders
.Include(x => x.Document)
.Where(x => x.Id == model.Id)
.Select(x => GetViewModel(x))
diff --git a/LawFirm/LawFirmDatabaseImplement/Models/Order.cs b/LawFirm/LawFirmDatabaseImplement/Models/Order.cs
index 1f72f68..8ed70ff 100644
--- a/LawFirm/LawFirmDatabaseImplement/Models/Order.cs
+++ b/LawFirm/LawFirmDatabaseImplement/Models/Order.cs
@@ -60,8 +60,7 @@ namespace LawFirmDatabaseImplement.Models
Sum = Sum,
Status = Status,
DateCreate = DateCreate,
- DateImplement = DateImplement,
- DocumentName = Document.DocumentName
+ DateImplement = DateImplement
};
}
}
diff --git a/LawFirm/LawFirmFileImplement/Implements/OrderStorage.cs b/LawFirm/LawFirmFileImplement/Implements/OrderStorage.cs
index 0a958dc..a83a12e 100644
--- a/LawFirm/LawFirmFileImplement/Implements/OrderStorage.cs
+++ b/LawFirm/LawFirmFileImplement/Implements/OrderStorage.cs
@@ -19,11 +19,22 @@ namespace LawFirmFileImplement.Implements
}
public List GetFilteredList(OrderSearchModel model)
{
- if (!model.Id.HasValue)
- {
+ if(!model.Id.HasValue && !model.DateFrom.HasValue)
+
+ {
return new();
}
- return source.Orders.Where(x => x.Id.Equals(model.Id)).Select(x => GetViewModel(x)).ToList();
+ if (model.DateFrom.HasValue)
+ {
+ return source.Orders
+ .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
+ .Select(x => x.GetViewModel)
+ .ToList();
+ }
+ return source.Orders
+ .Where(x => x.Id.Equals(model.Id))
+ .Select(x => GetViewModel(x))
+ .ToList();
}
public OrderViewModel? GetElement(OrderSearchModel model)
{
diff --git a/LawFirm/LawFirmFileImplement/Models/Document.cs b/LawFirm/LawFirmFileImplement/Models/Document.cs
index 117f779..83afe20 100644
--- a/LawFirm/LawFirmFileImplement/Models/Document.cs
+++ b/LawFirm/LawFirmFileImplement/Models/Document.cs
@@ -11,7 +11,8 @@ namespace LawFirmFileImplement.Models
public string DocumentName { get; private set; } = string.Empty;
public double Price { get; private set; }
public Dictionary Blanks { get; private set; } = new();
- private Dictionary? _documentBlanks = null;
+ private Dictionary? _documentBlanks =
+ null;
public Dictionary DocumentBlanks
{
get
diff --git a/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs b/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs
index 73c22d4..6e3f668 100644
--- a/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs
+++ b/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs
@@ -25,11 +25,22 @@ namespace LawFirmListImplement.Implements
public List GetFilteredList(OrderSearchModel model)
{
var result = new List();
- if (!model.Id.HasValue)
+ if (!model.Id.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue)
{
return result;
}
- foreach (var order in _source.Orders)
+ if (model.DateFrom.HasValue)
+ {
+ foreach (var order in _source.Orders)
+ {
+ if (order.DateCreate >= model.DateFrom && order.DateCreate <= model.DateTo)
+ {
+ result.Add(GetViewModel(order));
+ }
+ }
+ return result;
+ }
+ foreach (var order in _source.Orders)
{
if (order.Id == model.Id)
{
diff --git a/LawFirm/LawFirmView/FormDocumentBlank.Designer.cs b/LawFirm/LawFirmView/FormDocumentBlank.Designer.cs
index dcbc492..011588d 100644
--- a/LawFirm/LawFirmView/FormDocumentBlank.Designer.cs
+++ b/LawFirm/LawFirmView/FormDocumentBlank.Designer.cs
@@ -4,7 +4,7 @@
{
///
/// Required designer variable.
- ///
+ ///
private System.ComponentModel.IContainer components = null;
///
diff --git a/LawFirm/LawFirmView/FormMain.Designer.cs b/LawFirm/LawFirmView/FormMain.Designer.cs
index 5aa99c0..4eb1204 100644
--- a/LawFirm/LawFirmView/FormMain.Designer.cs
+++ b/LawFirm/LawFirmView/FormMain.Designer.cs
@@ -28,164 +28,241 @@
///
private void InitializeComponent()
{
+ this.ButtonCreateOrder = new System.Windows.Forms.Button();
+ this.ButtonTakeOrderInWork = new System.Windows.Forms.Button();
+ this.ButtonOrderReady = new System.Windows.Forms.Button();
+ this.ButtonIssuedOrder = new System.Windows.Forms.Button();
+ this.ButtonRef = new System.Windows.Forms.Button();
this.menuStrip1 = new System.Windows.Forms.MenuStrip();
- this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.бланкиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.документыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
- this.магазиныToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.ДеталиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.ДокументыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.магазинToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.DocumentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.documentsBlanksToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.ordersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.загруженностьМагазиновToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.заказыПоДатеToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
+ this.списокМагазиновToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.dataGridView = new System.Windows.Forms.DataGridView();
- this.buttonCreateOrder = new System.Windows.Forms.Button();
- this.buttonTakeOrderInWork = new System.Windows.Forms.Button();
- this.buttonOrderReady = new System.Windows.Forms.Button();
- this.buttonIssuedOrder = new System.Windows.Forms.Button();
- this.buttonUpdate = new System.Windows.Forms.Button();
- this.buttonAddDocument = new System.Windows.Forms.Button();
- this.buttonSellDocument = new System.Windows.Forms.Button();
+ this.ButtonAddDocument = new System.Windows.Forms.Button();
+ this.ButtonSellDocument = new System.Windows.Forms.Button();
this.menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
+ // ButtonCreateOrder
+ //
+ this.ButtonCreateOrder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.ButtonCreateOrder.Location = new System.Drawing.Point(841, 44);
+ this.ButtonCreateOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.ButtonCreateOrder.Name = "ButtonCreateOrder";
+ this.ButtonCreateOrder.Size = new System.Drawing.Size(164, 22);
+ this.ButtonCreateOrder.TabIndex = 0;
+ this.ButtonCreateOrder.Text = "Создать заказ";
+ this.ButtonCreateOrder.UseVisualStyleBackColor = true;
+ this.ButtonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click);
+ //
+ // ButtonTakeOrderInWork
+ //
+ this.ButtonTakeOrderInWork.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.ButtonTakeOrderInWork.Location = new System.Drawing.Point(841, 94);
+ this.ButtonTakeOrderInWork.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.ButtonTakeOrderInWork.Name = "ButtonTakeOrderInWork";
+ this.ButtonTakeOrderInWork.Size = new System.Drawing.Size(164, 22);
+ this.ButtonTakeOrderInWork.TabIndex = 1;
+ this.ButtonTakeOrderInWork.Text = "Отдать на выполнение";
+ this.ButtonTakeOrderInWork.UseVisualStyleBackColor = true;
+ this.ButtonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click);
+ //
+ // ButtonOrderReady
+ //
+ this.ButtonOrderReady.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.ButtonOrderReady.Location = new System.Drawing.Point(841, 146);
+ this.ButtonOrderReady.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.ButtonOrderReady.Name = "ButtonOrderReady";
+ this.ButtonOrderReady.Size = new System.Drawing.Size(164, 22);
+ this.ButtonOrderReady.TabIndex = 2;
+ this.ButtonOrderReady.Text = "Заказ готов";
+ this.ButtonOrderReady.UseVisualStyleBackColor = true;
+ this.ButtonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click);
+ //
+ // ButtonIssuedOrder
+ //
+ this.ButtonIssuedOrder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.ButtonIssuedOrder.Location = new System.Drawing.Point(841, 192);
+ this.ButtonIssuedOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.ButtonIssuedOrder.Name = "ButtonIssuedOrder";
+ this.ButtonIssuedOrder.Size = new System.Drawing.Size(164, 22);
+ this.ButtonIssuedOrder.TabIndex = 3;
+ this.ButtonIssuedOrder.Text = "Заказ выдан";
+ this.ButtonIssuedOrder.UseVisualStyleBackColor = true;
+ this.ButtonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click);
+ //
+ // ButtonRef
+ //
+ this.ButtonRef.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
+ this.ButtonRef.Location = new System.Drawing.Point(841, 243);
+ this.ButtonRef.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.ButtonRef.Name = "ButtonRef";
+ this.ButtonRef.Size = new System.Drawing.Size(164, 22);
+ this.ButtonRef.TabIndex = 4;
+ this.ButtonRef.Text = "Обновить список";
+ this.ButtonRef.UseVisualStyleBackColor = true;
+ this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click);
+ //
// menuStrip1
//
+ this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.справочникиToolStripMenuItem});
+ this.ToolStripMenuItem,
+ this.отчетыToolStripMenuItem});
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
this.menuStrip1.Name = "menuStrip1";
- this.menuStrip1.Size = new System.Drawing.Size(800, 24);
- this.menuStrip1.TabIndex = 0;
+ this.menuStrip1.Padding = new System.Windows.Forms.Padding(5, 2, 0, 2);
+ this.menuStrip1.Size = new System.Drawing.Size(1015, 24);
+ this.menuStrip1.TabIndex = 5;
this.menuStrip1.Text = "menuStrip1";
//
- // справочникиToolStripMenuItem
+ // ToolStripMenuItem
//
- this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.бланкиToolStripMenuItem,
- this.документыToolStripMenuItem,
- this.магазиныToolStripMenuItem});
- this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
- this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
- this.справочникиToolStripMenuItem.Text = "Справочники";
+ this.ToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.ДеталиToolStripMenuItem,
+ this.ДокументыToolStripMenuItem,
+ this.магазинToolStripMenuItem});
+ this.ToolStripMenuItem.Name = "ToolStripMenuItem";
+ this.ToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
+ this.ToolStripMenuItem.Text = "Справочники";
//
- // бланкиToolStripMenuItem
+ // ДеталиToolStripMenuItem
//
- this.бланкиToolStripMenuItem.Name = "бланкиToolStripMenuItem";
- this.бланкиToolStripMenuItem.Size = new System.Drawing.Size(137, 22);
- this.бланкиToolStripMenuItem.Text = "Бланки";
- this.бланкиToolStripMenuItem.Click += new System.EventHandler(this.BlanksToolStripMenuItem_Click);
+ this.ДеталиToolStripMenuItem.Name = "ДеталиToolStripMenuItem";
+ this.ДеталиToolStripMenuItem.Size = new System.Drawing.Size(130, 22);
+ this.ДеталиToolStripMenuItem.Text = "Детали";
+ this.ДеталиToolStripMenuItem.Click += new System.EventHandler(this.ДеталиToolStripMenuItem_Click);
//
- // документыToolStripMenuItem
+ // ДокументыToolStripMenuItem
//
- this.документыToolStripMenuItem.Name = "документыToolStripMenuItem";
- this.документыToolStripMenuItem.Size = new System.Drawing.Size(137, 22);
- this.документыToolStripMenuItem.Text = "Документы";
- this.документыToolStripMenuItem.Click += new System.EventHandler(this.DocumentsToolStripMenuItem_Click);
+ this.ДокументыToolStripMenuItem.Name = "ДокументыToolStripMenuItem";
+ this.ДокументыToolStripMenuItem.Size = new System.Drawing.Size(130, 22);
+ this.ДокументыToolStripMenuItem.Text = "Документы";
+ this.ДокументыToolStripMenuItem.Click += new System.EventHandler(this.ДокументыToolStripMenuItem_Click);
//
- // магазиныToolStripMenuItem
+ // магазинToolStripMenuItem
//
- this.магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem";
- this.магазиныToolStripMenuItem.Size = new System.Drawing.Size(137, 22);
- this.магазиныToolStripMenuItem.Text = "Магазины";
- this.магазиныToolStripMenuItem.Click += new System.EventHandler(this.ShopToolStripMenuItem_Click);
+ this.магазинToolStripMenuItem.Name = "магазинToolStripMenuItem";
+ this.магазинToolStripMenuItem.Size = new System.Drawing.Size(130, 22);
+ this.магазинToolStripMenuItem.Text = "Магазины";
+ this.магазинToolStripMenuItem.Click += new System.EventHandler(this.МагазиныToolStripMenuItem_Click);
+ //
+ // отчетыToolStripMenuItem
+ //
+ this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
+ this.DocumentsToolStripMenuItem,
+ this.documentsBlanksToolStripMenuItem,
+ this.ordersToolStripMenuItem,
+ this.загруженностьМагазиновToolStripMenuItem,
+ this.заказыПоДатеToolStripMenuItem,
+ this.списокМагазиновToolStripMenuItem});
+ this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
+ this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(60, 20);
+ this.отчетыToolStripMenuItem.Text = "Отчеты";
+ //
+ // DocumentsToolStripMenuItem
+ //
+ this.DocumentsToolStripMenuItem.Name = "DocumentsToolStripMenuItem";
+ this.DocumentsToolStripMenuItem.Size = new System.Drawing.Size(219, 22);
+ this.DocumentsToolStripMenuItem.Text = "Список документов";
+ this.DocumentsToolStripMenuItem.Click += new System.EventHandler(this.DocumentsToolStripMenuItem_Click);
+ //
+ // documentsBlanksToolStripMenuItem
+ //
+ this.documentsBlanksToolStripMenuItem.Name = "documentsBlanksToolStripMenuItem";
+ this.documentsBlanksToolStripMenuItem.Size = new System.Drawing.Size(219, 22);
+ this.documentsBlanksToolStripMenuItem.Text = "Изделия по деталям";
+ this.documentsBlanksToolStripMenuItem.Click += new System.EventHandler(this.documentBlanksToolStripMenuItem_Click);
+ //
+ // ordersToolStripMenuItem
+ //
+ this.ordersToolStripMenuItem.Name = "ordersToolStripMenuItem";
+ this.ordersToolStripMenuItem.Size = new System.Drawing.Size(219, 22);
+ this.ordersToolStripMenuItem.Text = "Список заказов";
+ this.ordersToolStripMenuItem.Click += new System.EventHandler(this.ordersToolStripMenuItem_Click);
+ //
+ // загруженностьМагазиновToolStripMenuItem
+ //
+ this.загруженностьМагазиновToolStripMenuItem.Name = "загруженностьМагазиновToolStripMenuItem";
+ this.загруженностьМагазиновToolStripMenuItem.Size = new System.Drawing.Size(219, 22);
+ this.загруженностьМагазиновToolStripMenuItem.Text = "Загруженность магазинов";
+ this.загруженностьМагазиновToolStripMenuItem.Click += new System.EventHandler(this.ShopLoadToolStripMenuItem_Click);
+ //
+ // заказыПоДатеToolStripMenuItem
+ //
+ this.заказыПоДатеToolStripMenuItem.Name = "заказыПоДатеToolStripMenuItem";
+ this.заказыПоДатеToolStripMenuItem.Size = new System.Drawing.Size(219, 22);
+ this.заказыПоДатеToolStripMenuItem.Text = "Заказы по дате";
+ this.заказыПоДатеToolStripMenuItem.Click += new System.EventHandler(this.OrdersByDateToolStripMenuItem_Click);
+ //
+ // списокМагазиновToolStripMenuItem
+ //
+ this.списокМагазиновToolStripMenuItem.Name = "списокМагазиновToolStripMenuItem";
+ this.списокМагазиновToolStripMenuItem.Size = new System.Drawing.Size(219, 22);
+ this.списокМагазиновToolStripMenuItem.Text = "Список магазинов";
+ this.списокМагазиновToolStripMenuItem.Click += new System.EventHandler(this.ListOfShopsToolStripMenuItem_Click);
//
// dataGridView
//
- this.dataGridView.AllowUserToAddRows = false;
- this.dataGridView.AllowUserToDeleteRows = false;
- this.dataGridView.BackgroundColor = System.Drawing.Color.White;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
- this.dataGridView.Location = new System.Drawing.Point(12, 27);
+ this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
+ this.dataGridView.Location = new System.Drawing.Point(0, 24);
+ this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.dataGridView.Name = "dataGridView";
- this.dataGridView.ReadOnly = true;
- this.dataGridView.RowTemplate.Height = 25;
- this.dataGridView.Size = new System.Drawing.Size(566, 411);
- this.dataGridView.TabIndex = 1;
+ this.dataGridView.RowHeadersWidth = 51;
+ this.dataGridView.RowTemplate.Height = 29;
+ this.dataGridView.Size = new System.Drawing.Size(816, 332);
+ this.dataGridView.TabIndex = 6;
//
- // buttonCreateOrder
+ // ButtonAddDocument
//
- this.buttonCreateOrder.Location = new System.Drawing.Point(605, 27);
- this.buttonCreateOrder.Name = "buttonCreateOrder";
- this.buttonCreateOrder.Size = new System.Drawing.Size(168, 23);
- this.buttonCreateOrder.TabIndex = 2;
- this.buttonCreateOrder.Text = "Создать заказ";
- this.buttonCreateOrder.UseVisualStyleBackColor = true;
- this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click);
+ this.ButtonAddDocument.Location = new System.Drawing.Point(841, 284);
+ this.ButtonAddDocument.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.ButtonAddDocument.Name = "ButtonAddDocument";
+ this.ButtonAddDocument.Size = new System.Drawing.Size(164, 25);
+ this.ButtonAddDocument.TabIndex = 7;
+ this.ButtonAddDocument.Text = "Добавить документ";
+ this.ButtonAddDocument.UseVisualStyleBackColor = true;
+ this.ButtonAddDocument.Click += new System.EventHandler(this.ButtonAddDocument_Click);
//
- // buttonTakeOrderInWork
+ // ButtonSellDocument
//
- this.buttonTakeOrderInWork.Location = new System.Drawing.Point(605, 56);
- this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
- this.buttonTakeOrderInWork.Size = new System.Drawing.Size(168, 23);
- this.buttonTakeOrderInWork.TabIndex = 3;
- this.buttonTakeOrderInWork.Text = "Отдать на выполнение";
- this.buttonTakeOrderInWork.UseVisualStyleBackColor = true;
- this.buttonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click);
- //
- // buttonOrderReady
- //
- this.buttonOrderReady.Location = new System.Drawing.Point(605, 85);
- this.buttonOrderReady.Name = "buttonOrderReady";
- this.buttonOrderReady.Size = new System.Drawing.Size(168, 23);
- this.buttonOrderReady.TabIndex = 4;
- this.buttonOrderReady.Text = "Заказ готов";
- this.buttonOrderReady.UseVisualStyleBackColor = true;
- this.buttonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click);
- //
- // buttonIssuedOrder
- //
- this.buttonIssuedOrder.Location = new System.Drawing.Point(605, 114);
- this.buttonIssuedOrder.Name = "buttonIssuedOrder";
- this.buttonIssuedOrder.Size = new System.Drawing.Size(168, 23);
- this.buttonIssuedOrder.TabIndex = 5;
- this.buttonIssuedOrder.Text = "Заказ выдан";
- this.buttonIssuedOrder.UseVisualStyleBackColor = true;
- this.buttonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click);
- //
- // buttonUpdate
- //
- this.buttonUpdate.Location = new System.Drawing.Point(605, 143);
- this.buttonUpdate.Name = "buttonUpdate";
- this.buttonUpdate.Size = new System.Drawing.Size(168, 23);
- this.buttonUpdate.TabIndex = 6;
- this.buttonUpdate.Text = "Обновить список";
- this.buttonUpdate.UseVisualStyleBackColor = true;
- this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click);
- //
- // buttonAddDocument
- //
- this.buttonAddDocument.Location = new System.Drawing.Point(605, 172);
- this.buttonAddDocument.Name = "buttonAddDocument";
- this.buttonAddDocument.Size = new System.Drawing.Size(168, 23);
- this.buttonAddDocument.TabIndex = 7;
- this.buttonAddDocument.Text = "Добавить документ";
- this.buttonAddDocument.UseVisualStyleBackColor = true;
- this.buttonAddDocument.Click += new System.EventHandler(this.ButtonAddDocument_Click);
- //
- // buttonSellDocument
- //
- this.buttonSellDocument.Location = new System.Drawing.Point(605, 201);
- this.buttonSellDocument.Name = "buttonSellDocument";
- this.buttonSellDocument.Size = new System.Drawing.Size(168, 23);
- this.buttonSellDocument.TabIndex = 8;
- this.buttonSellDocument.Text = "Продать документ";
- this.buttonSellDocument.UseVisualStyleBackColor = true;
- this.buttonSellDocument.Click += new System.EventHandler(this.ButtonSellDocument_Click);
+ this.ButtonSellDocument.Location = new System.Drawing.Point(841, 325);
+ this.ButtonSellDocument.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+ this.ButtonSellDocument.Name = "ButtonSellDocument";
+ this.ButtonSellDocument.Size = new System.Drawing.Size(164, 22);
+ this.ButtonSellDocument.TabIndex = 8;
+ this.ButtonSellDocument.Text = "Продать документ";
+ this.ButtonSellDocument.UseVisualStyleBackColor = true;
+ this.ButtonSellDocument.Click += new System.EventHandler(this.ButtonSellDocument_Click);
//
// FormMain
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.ClientSize = new System.Drawing.Size(800, 450);
- this.Controls.Add(this.buttonSellDocument);
- this.Controls.Add(this.buttonAddDocument);
- this.Controls.Add(this.buttonUpdate);
- this.Controls.Add(this.buttonIssuedOrder);
- this.Controls.Add(this.buttonOrderReady);
- this.Controls.Add(this.buttonTakeOrderInWork);
- this.Controls.Add(this.buttonCreateOrder);
+ this.ClientSize = new System.Drawing.Size(1015, 356);
+ this.Controls.Add(this.ButtonSellDocument);
+ this.Controls.Add(this.ButtonAddDocument);
this.Controls.Add(this.dataGridView);
+ this.Controls.Add(this.ButtonRef);
+ this.Controls.Add(this.ButtonIssuedOrder);
+ this.Controls.Add(this.ButtonOrderReady);
+ this.Controls.Add(this.ButtonTakeOrderInWork);
+ this.Controls.Add(this.ButtonCreateOrder);
this.Controls.Add(this.menuStrip1);
this.MainMenuStrip = this.menuStrip1;
+ this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.Name = "FormMain";
- this.Text = "Юридическая фирма";
+ this.Text = "LawFirm";
this.Load += new System.EventHandler(this.FormMain_Load);
this.menuStrip1.ResumeLayout(false);
this.menuStrip1.PerformLayout();
@@ -197,18 +274,25 @@
#endregion
+ private Button ButtonCreateOrder;
+ private Button ButtonTakeOrderInWork;
+ private Button ButtonOrderReady;
+ private Button ButtonIssuedOrder;
+ private Button ButtonRef;
private MenuStrip menuStrip1;
- private ToolStripMenuItem справочникиToolStripMenuItem;
+ private ToolStripMenuItem ToolStripMenuItem;
+ private ToolStripMenuItem ДеталиToolStripMenuItem;
+ private ToolStripMenuItem ДокументыToolStripMenuItem;
private DataGridView dataGridView;
- private Button buttonCreateOrder;
- private Button buttonTakeOrderInWork;
- private Button buttonOrderReady;
- private Button buttonIssuedOrder;
- private Button buttonUpdate;
- private ToolStripMenuItem бланкиToolStripMenuItem;
- private ToolStripMenuItem документыToolStripMenuItem;
- private ToolStripMenuItem магазиныToolStripMenuItem;
- private Button buttonAddDocument;
- private Button buttonSellDocument;
- }
+ private ToolStripMenuItem отчетыToolStripMenuItem;
+ private ToolStripMenuItem DocumentsToolStripMenuItem;
+ private ToolStripMenuItem documentsBlanksToolStripMenuItem;
+ private ToolStripMenuItem ordersToolStripMenuItem;
+ private ToolStripMenuItem магазинToolStripMenuItem;
+ private Button ButtonAddDocument;
+ private Button ButtonSellDocument;
+ private ToolStripMenuItem загруженностьМагазиновToolStripMenuItem;
+ private ToolStripMenuItem заказыПоДатеToolStripMenuItem;
+ private ToolStripMenuItem списокМагазиновToolStripMenuItem;
+ }
}
\ No newline at end of file
diff --git a/LawFirm/LawFirmView/FormMain.cs b/LawFirm/LawFirmView/FormMain.cs
index 4b05d03..bd6bff7 100644
--- a/LawFirm/LawFirmView/FormMain.cs
+++ b/LawFirm/LawFirmView/FormMain.cs
@@ -1,7 +1,15 @@
-using LawFirmContracts.BindingModels;
+using Microsoft.Extensions.Logging;
+using LawFirmContracts.BindingModels;
using LawFirmContracts.BusinessLogicsContracts;
using LawFirmDataModels.Enums;
-using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
using System.Windows.Forms;
namespace LawFirmView
@@ -10,12 +18,16 @@ namespace LawFirmView
{
private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic;
- public FormMain(ILogger logger, IOrderLogic orderLogic)
+ private readonly IReportLogic _reportLogic;
+ public FormMain(ILogger logger, IOrderLogic orderLogic,IReportLogic reportlogic)
{
InitializeComponent();
_logger = logger;
_orderLogic = orderLogic;
+ _reportLogic = reportlogic;
+
}
+
private void FormMain_Load(object sender, EventArgs e)
{
LoadData();
@@ -31,7 +43,7 @@ namespace LawFirmView
dataGridView.DataSource = list;
dataGridView.Columns["DocumentId"].Visible = false;
}
- _logger.LogInformation("Загрузка прошла успешно");
+ _logger.LogInformation("Загрузка заказов");
}
catch (Exception ex)
{
@@ -39,6 +51,25 @@ namespace LawFirmView
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
+
+ private void ДеталиToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormBlanks));
+ if (service is FormBlanks form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void ДокументыToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormDocuments));
+ if (service is FormDocuments form)
+ {
+ form.ShowDialog();
+ }
+ }
+
private void ButtonCreateOrder_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
@@ -48,6 +79,7 @@ namespace LawFirmView
LoadData();
}
}
+
private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
@@ -56,9 +88,7 @@ namespace LawFirmView
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
try
{
- var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel{
- Id = id,
- });
+ var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id});
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
@@ -68,11 +98,12 @@ namespace LawFirmView
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка передачи заказа в работу");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
- MessageBoxIcon.Error);
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
+
}
+
private void ButtonOrderReady_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
@@ -81,13 +112,10 @@ namespace LawFirmView
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
try
{
- var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
- {
- Id = id
- });
+ var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id });
if (!operationResult)
{
- throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ throw new Exception("Ошибка при сохранении.Дополнительная информация в логах.");
}
LoadData();
}
@@ -98,20 +126,16 @@ namespace LawFirmView
}
}
}
+
private void ButtonIssuedOrder_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
- int id =
- Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
try
{
- var operationResult = _orderLogic.DeliveryOrder(new
- OrderBindingModel
- {
- Id = id
- });
+ var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id});
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
@@ -122,33 +146,46 @@ namespace LawFirmView
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
- MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
- MessageBoxIcon.Error);
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
+
}
+
private void ButtonRef_Click(object sender, EventArgs e)
{
LoadData();
}
- private void BlanksToolStripMenuItem_Click(object sender, EventArgs e)
- {
- var service = Program.ServiceProvider?.GetService(typeof(FormBlanks));
- if (service is FormBlanks form)
- {
- form.ShowDialog();
- }
- }
+
private void DocumentsToolStripMenuItem_Click(object sender, EventArgs e)
{
- var service = Program.ServiceProvider?.GetService(typeof(FormDocuments));
- if (service is FormDocuments form)
+ using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ _reportLogic.SaveBlanksToWordFile(new ReportBindingModel { FileName = dialog.FileName });
+ MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ }
+
+ private void documentBlanksToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormReportDocumentBlanks));
+ if (service is FormReportDocumentBlanks form)
{
form.ShowDialog();
}
}
- private void ShopToolStripMenuItem_Click(object sender, EventArgs e)
+ private void ordersToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders));
+ if (service is FormReportOrders form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void МагазиныToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormShops));
if (service is FormShops form)
@@ -167,14 +204,42 @@ namespace LawFirmView
}
}
- private void ButtonSellDocument_Click(object sender, EventArgs e)
- {
- var service = Program.ServiceProvider?.GetService(typeof(FormSellDocuments));
- if (service is FormSellDocuments form)
- {
- form.ShowDialog();
- LoadData();
- }
- }
- }
+ private void ButtonSellDocument_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormSellDocuments));
+ if (service is FormSellDocuments form)
+ {
+ form.ShowDialog();
+ LoadData();
+ }
+ }
+
+ private void ShopLoadToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormReportShopDocuments));
+ if (service is FormReportShopDocuments form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void OrdersByDateToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormReportGroupedOrders));
+ if (service is FormReportGroupedOrders form)
+ {
+ form.ShowDialog();
+ }
+ }
+
+ private void ListOfShopsToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
+ if (dialog.ShowDialog() == DialogResult.OK)
+ {
+ _reportLogic.SaveShopsToWordFile(new ReportBindingModel { FileName = dialog.FileName });
+ MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ }
+ }
+ }
}
diff --git a/LawFirm/LawFirmView/FormReportDocumentBlanks.Designer.cs b/LawFirm/LawFirmView/FormReportDocumentBlanks.Designer.cs
new file mode 100644
index 0000000..8bbaa31
--- /dev/null
+++ b/LawFirm/LawFirmView/FormReportDocumentBlanks.Designer.cs
@@ -0,0 +1,102 @@
+namespace LawFirmView
+{
+ partial class FormReportDocumentBlanks
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.buttonSaveToExcel = new System.Windows.Forms.Button();
+ this.dataGridView = new System.Windows.Forms.DataGridView();
+ this.ColumnBlank = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.ColumnDocument = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
+ this.SuspendLayout();
+ //
+ // buttonSaveToExcel
+ //
+ this.buttonSaveToExcel.Location = new System.Drawing.Point(12, 12);
+ this.buttonSaveToExcel.Name = "buttonSaveToExcel";
+ this.buttonSaveToExcel.Size = new System.Drawing.Size(129, 23);
+ this.buttonSaveToExcel.TabIndex = 0;
+ this.buttonSaveToExcel.Text = "Сохранить в Excel";
+ this.buttonSaveToExcel.UseVisualStyleBackColor = true;
+ this.buttonSaveToExcel.Click += new System.EventHandler(this.ButtonSaveToExcel_Click);
+ //
+ // dataGridView
+ //
+ this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
+ this.dataGridView.BackgroundColor = System.Drawing.Color.White;
+ this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
+ this.ColumnBlank,
+ this.ColumnDocument,
+ this.ColumnCount});
+ this.dataGridView.Location = new System.Drawing.Point(12, 41);
+ this.dataGridView.Name = "dataGridView";
+ this.dataGridView.RowTemplate.Height = 25;
+ this.dataGridView.Size = new System.Drawing.Size(318, 397);
+ this.dataGridView.TabIndex = 1;
+ //
+ // ColumnBlank
+ //
+ this.ColumnBlank.HeaderText = "Документ";
+ this.ColumnBlank.Name = "ColumnBlank";
+ //
+ // ColumnDocument
+ //
+ this.ColumnDocument.HeaderText = "Бланк";
+ this.ColumnDocument.Name = "ColumnDocument";
+ //
+ // ColumnCount
+ //
+ this.ColumnCount.HeaderText = "Количество";
+ this.ColumnCount.Name = "ColumnCount";
+ //
+ // FormReportDocumentBlanks
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.ClientSize = new System.Drawing.Size(342, 450);
+ this.Controls.Add(this.dataGridView);
+ this.Controls.Add(this.buttonSaveToExcel);
+ this.Name = "FormReportDocumentBlanks";
+ this.Text = "Бланки по документам";
+ this.Load += new System.EventHandler(this.FormReportDocumentBlanks_Load);
+ ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private Button buttonSaveToExcel;
+ private DataGridView dataGridView;
+ private DataGridViewTextBoxColumn ColumnBlank;
+ private DataGridViewTextBoxColumn ColumnDocument;
+ private DataGridViewTextBoxColumn ColumnCount;
+ }
+}
\ No newline at end of file
diff --git a/LawFirm/LawFirmView/FormReportDocumentBlanks.cs b/LawFirm/LawFirmView/FormReportDocumentBlanks.cs
new file mode 100644
index 0000000..b40758c
--- /dev/null
+++ b/LawFirm/LawFirmView/FormReportDocumentBlanks.cs
@@ -0,0 +1,81 @@
+using LawFirmContracts.BusinessLogicsContracts;
+using System;
+using LawFirmContracts.BindingModels;
+using LawFirmContracts.BusinessLogicsContracts;
+using Microsoft.Extensions.Logging;
+using System.Windows.Forms;
+
+namespace LawFirmView
+{
+ public partial class FormReportDocumentBlanks : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IReportLogic _logic;
+ public FormReportDocumentBlanks(ILogger logger, IReportLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+
+ private void FormReportDocumentBlanks_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ var dict = _logic.GetDocumentBlank();
+ if (dict != null)
+ {
+ dataGridView.Rows.Clear();
+ foreach (var elem in dict)
+ {
+ dataGridView.Rows.Add(new object[] { elem.DocumentName, "", "" });
+ foreach (var listElem in elem.Blanks)
+ {
+ dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
+ }
+ dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount });
+ dataGridView.Rows.Add(Array.Empty | | |
@@ -26,4 +27,13 @@
+
+
+ Always
+
+
+ Always
+
+
+
\ No newline at end of file
diff --git a/LawFirm/LawFirmView/Program.cs b/LawFirm/LawFirmView/Program.cs
index 5a24bd9..4adb0da 100644
--- a/LawFirm/LawFirmView/Program.cs
+++ b/LawFirm/LawFirmView/Program.cs
@@ -1,4 +1,6 @@
using LawFirmBusinessLogic.BusinessLogics;
+using LawFirmBusinessLogic.OfficePackage.Implements;
+using LawFirmBusinessLogic.OfficePackage;
using LawFirmContracts.BusinessLogicsContracts;
using LawFirmContracts.StoragesContracts;
using LawFirmDatabaseImplement.Implements;
@@ -42,6 +44,11 @@ namespace LawFirmView
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
+
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
services.AddTransient();
services.AddTransient();
@@ -53,7 +60,11 @@ namespace LawFirmView
services.AddTransient();
services.AddTransient();
services.AddTransient();
- services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
}
}
}
\ No newline at end of file
diff --git a/LawFirm/LawFirmView/ReportGroupedOrders.rdlc b/LawFirm/LawFirmView/ReportGroupedOrders.rdlc
new file mode 100644
index 0000000..494a170
--- /dev/null
+++ b/LawFirm/LawFirmView/ReportGroupedOrders.rdlc
@@ -0,0 +1,411 @@
+
+
+ 0
+
+
+
+ System.Data.DataSet
+ /* Local Connection */
+
+ 10791c83-cee8-4a38-bbd0-245fc17cefb3
+
+
+
+
+
+ LawFirmContractsViewModels
+ /* Local Query */
+
+
+
+ Date
+ System.DateTime
+
+
+ Count
+ System.Int32
+
+
+ Sum
+ System.Decimal
+
+
+
+ LawFirmContracts.ViewModels
+ ReportOrdersGroupedByDateViewModel
+ LawFirmContracts.ViewModels.ReportOrdersGroupedByDateViewModel, LawFirmContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
+
+
+
+
+
+
+
+
+ true
+ true
+
+
+
+
+ Заказы
+
+
+
+
+
+
+ Textbox1
+ 0.70583cm
+ 19.67885cm
+
+
+ 2pt
+ 2pt
+ 2pt
+ 2pt
+
+
+
+
+
+
+ 4.56494cm
+
+
+ 4.56494cm
+
+
+ 2.5cm
+
+
+
+
+ 0.74083cm
+
+
+
+
+ true
+ true
+
+
+
+
+ Date
+
+
+
+
+
+
+ Textbox2
+
+
+ 2pt
+ 2pt
+ 2pt
+ 2pt
+
+
+
+
+
+
+
+ true
+ true
+
+
+
+
+ Count
+
+
+
+
+
+
+ Textbox4
+
+
+ 2pt
+ 2pt
+ 2pt
+ 2pt
+
+
+
+
+
+
+
+ true
+ true
+
+
+
+
+ Sum
+
+
+
+
+
+
+ Textbox8
+
+
+ 2pt
+ 2pt
+ 2pt
+ 2pt
+
+
+
+
+
+
+
+ 0.74083cm
+
+
+
+
+ true
+ true
+
+
+
+
+ =Fields!Date.Value
+
+
+
+
+
+
+ Date
+
+
+ 2pt
+ 2pt
+ 2pt
+ 2pt
+
+
+ true
+
+
+
+
+
+ true
+ true
+
+
+
+
+ =Fields!Count.Value
+
+
+
+
+
+
+ Count
+
+
+ 2pt
+ 2pt
+ 2pt
+ 2pt
+
+
+
+
+
+
+
+ true
+ true
+
+
+
+
+ =Fields!Sum.Value
+
+
+
+
+
+
+ Sum
+
+
+ 2pt
+ 2pt
+ 2pt
+ 2pt
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ After
+
+
+
+
+
+
+ DataSetOrders
+ 1.87537cm
+ 4.83399cm
+ 1.48166cm
+ 11.62988cm
+ 1
+
+
+
+
+
+ true
+ true
+
+
+
+
+ Итого:
+
+
+
+
+
+
+ 4.0132cm
+ 11.46387cm
+ 0.6cm
+ 2.5cm
+ 2
+
+
+ 2pt
+ 2pt
+ 2pt
+ 2pt
+
+
+
+ true
+ true
+
+
+
+
+ =Sum(Fields!Sum.Value, "DataSetOrders")
+
+
+
+
+
+
+ 4.0132cm
+ 13.96387cm
+ 0.6cm
+ 2.5cm
+ 3
+
+
+ 2pt
+ 2pt
+ 2pt
+ 2pt
+
+
+
+ 2in
+
+
+ 8.08183in
+
+ 29.7cm
+ 21cm
+ 2cm
+ 2cm
+ 2cm
+ 2cm
+ 0.13cm
+
+
+
+
+
+
+ String
+ true
+ ReportParameter1
+
+
+
+
+ 4
+ 2
+
+
+ 0
+ 0
+ ReportParameterPeriod
+
+
+
+
+ Cm
+ 32707729-e749-46dd-a114-7c43e1a2a795
+
\ No newline at end of file
diff --git a/LawFirm/LawFirmView/ReportOrders.rdlc b/LawFirm/LawFirmView/ReportOrders.rdlc
new file mode 100644
index 0000000..3d5e2af
--- /dev/null
+++ b/LawFirm/LawFirmView/ReportOrders.rdlc
@@ -0,0 +1,599 @@
+
+
+ 0
+
+
+
+ System.Data.DataSet
+ /* Local Connection */
+
+ 10791c83-cee8-4a38-bbd0-245fc17cefb3
+
+
+
+
+
+ LawFirmContractsViewModels
+ /* Local Query */
+
+
+
+ Id
+ System.Int32
+
+
+ DateCreate
+ System.DateTime
+
+
+ DocumentName
+ System.String
+
+
+ OrderStatus
+ System.String
+
+
+ Sum
+ System.Decimal
+
+
+
+ LawFirmContracts.ViewModels
+ ReportOrdersViewModel
+ LawFirmContracts.ViewModels.ReportOrdersViewModel, LawFirmContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
+
+
+
+
+
+
+
+
+ true
+ true
+
+
+
+
+ =Parameters!ReportParameterPeriod.Value
+
+
+
+
+
+
+ ReportParameterPeriod
+ 1cm
+ 1cm
+ 21cm
+
+
+ Middle
+ 2pt
+ 2pt
+ 2pt
+ 2pt
+
+
+
+ true
+ true
+
+
+
+
+ Заказы
+
+
+
+
+
+
+ 1cm
+ 21cm
+ 1
+
+
+ Middle
+ 2pt
+ 2pt
+ 2pt
+ 2pt
+
+
+
+
+
+
+ 2.5cm
+
+
+ 3.21438cm
+
+
+ 8.23317cm
+
+
+ 2.5cm
+
+
+ 2.5cm
+
+
+
+
+ 0.6cm
+
+
+
+
+ true
+ true
+
+
+
+
+ Номер
+
+
+
+
+
+
+ Textbox5
+
+
+ 2pt
+ 2pt
+ 2pt
+ 2pt
+
+
+
+
+
+
+
+ true
+ true
+
+
+
+
+ Дата создания
+
+
+
+
+
+
+ Textbox1
+
+
+ 2pt
+ 2pt
+ 2pt
+ 2pt
+
+
+
+
+
+
+
+ true
+ true
+
+
+
+
+ Документ
+
+
+
+
+
+
+ Textbox3
+
+
+ 2pt
+ 2pt
+ 2pt
+ 2pt
+
+
+
+
+
+
+
+ true
+ true
+
+
+
+
+ Статус
+
+
+
+
+
+
+ Textbox2
+
+
+ 2pt
+ 2pt
+ 2pt
+ 2pt
+
+
+
+
+
+
+
+ true
+ true
+
+
+
+
+ Сумма
+
+
+
+
+
+
+ Textbox7
+
+
+ 2pt
+ 2pt
+ 2pt
+ 2pt
+
+
+
+
+
+
+
+ 0.6cm
+
+
+
+
+ true
+ true
+
+
+
+
+ =Fields!Id.Value
+
+
+
+
+
+
+ Id
+
+
+ 2pt
+ 2pt
+ 2pt
+ 2pt
+
+
+
+
+
+
+
+ true
+ true
+
+
+
+
+ =Fields!DateCreate.Value
+
+
+
+
+
+
+ DateCreate
+
+
+ 2pt
+ 2pt
+ 2pt
+ 2pt
+
+
+
+
+
+
+
+ true
+ true
+
+
+
+
+ =Fields!DocumentName.Value
+
+
+
+
+
+
+ DocumentName
+
+
+ 2pt
+ 2pt
+ 2pt
+ 2pt
+
+
+
+
+
+
+
+ true
+ true
+
+
+
+
+ =Fields!OrderStatus.Value
+
+
+
+
+
+
+ OrderStatus
+
+
+ 2pt
+ 2pt
+ 2pt
+ 2pt
+
+
+
+
+
+
+
+ true
+ true
+
+
+
+
+ =Fields!Sum.Value
+
+
+
+
+
+
+ Sum
+
+
+ 2pt
+ 2pt
+ 2pt
+ 2pt
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ After
+
+
+
+
+
+
+ DataSetOrders
+ 2.48391cm
+ 0.55245cm
+ 1.2cm
+ 18.94755cm
+ 2
+
+
+
+
+
+ true
+ true
+
+
+
+
+ Итого:
+
+
+
+
+
+
+ 4cm
+ 12cm
+ 0.6cm
+ 2.5cm
+ 3
+
+
+ 2pt
+ 2pt
+ 2pt
+ 2pt
+
+
+
+ true
+ true
+
+
+
+
+ =Sum(Fields!Sum.Value, "DataSetOrders")
+
+
+
+
+
+
+ 4cm
+ 14.5cm
+ 0.6cm
+ 2.5cm
+ 4
+
+
+ 2pt
+ 2pt
+ 2pt
+ 2pt
+
+
+
+ 5.72875cm
+
+
+ 21cm
+
+ 29.7cm
+ 21cm
+ 2cm
+ 2cm
+ 2cm
+ 2cm
+ 0.13cm
+
+
+
+
+
+
+ String
+ true
+ ReportParameter1
+
+
+
+
+ 4
+ 2
+
+
+ 0
+ 0
+ ReportParameterPeriod
+
+
+
+
+ Cm
+ 2de0031a-4d17-449d-922d-d9fc54572312
+
\ No newline at end of file
diff --git a/LawFirm/Temp.txt b/LawFirm/Temp.txt
new file mode 100644
index 0000000..5f28270
--- /dev/null
+++ b/LawFirm/Temp.txt
@@ -0,0 +1 @@
+
\ No newline at end of file