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 8aabfd9..4e82080 100644 --- a/LawFirm/LawFirmBusinessLogic/BusinessLogics/OrderLogic.cs +++ b/LawFirm/LawFirmBusinessLogic/BusinessLogics/OrderLogic.cs @@ -12,10 +12,17 @@ namespace LawFirmBusinessLogic.BusinessLogics { private readonly ILogger _logger; private readonly IOrderStorage _orderStorage; - public OrderLogic(ILogger logger, IOrderStorage orderStorage) + private readonly IShopLogic _shopLogic; + private readonly IDocumentStorage _documentStorage; + public OrderLogic(ILogger logger, + IOrderStorage orderStorage, + IShopLogic shopLogic, + IDocumentStorage documentStorage) { _logger = logger; _orderStorage = orderStorage; + _shopLogic = shopLogic; + _documentStorage = documentStorage; } public bool CreateOrder(OrderBindingModel model) { @@ -47,7 +54,20 @@ namespace LawFirmBusinessLogic.BusinessLogics return false; } model.Status = newStatus; - if (model.Status == OrderStatus.Готов) model.DateImplement = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc); + if (model.Status == OrderStatus.Готов) + { + + model.DateImplement = DateTime.SpecifyKind(DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc), DateTimeKind.Utc); + var document = _documentStorage.GetElement(new() { Id = viewModel.DocumentId }); + if (document == null) + { + throw new ArgumentNullException(nameof(document)); + } + if (!_shopLogic.AddDocuments(document, viewModel.Count)) + { + throw new Exception($"AddDocuments operation failed - нет места"); + } + } else { model.DateImplement = viewModel.DateImplement; @@ -56,7 +76,7 @@ namespace LawFirmBusinessLogic.BusinessLogics if (_orderStorage.Update(model) == null) { model.Status--; - _logger.LogWarning("Update operation failed"); + _logger.LogWarning("Change status operation failed"); return false; } return true; diff --git a/LawFirm/LawFirmBusinessLogic/BusinessLogics/ReportLogic.cs b/LawFirm/LawFirmBusinessLogic/BusinessLogics/ReportLogic.cs index 403b878..4a45426 100644 --- a/LawFirm/LawFirmBusinessLogic/BusinessLogics/ReportLogic.cs +++ b/LawFirm/LawFirmBusinessLogic/BusinessLogics/ReportLogic.cs @@ -13,13 +13,18 @@ namespace LawFirmBusinessLogic.BusinessLogics 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, - AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, - AbstractSaveToPdf saveToPdf) + public ReportLogic(IDocumentStorage documentStorage, + IBlankStorage blankStorage, + IOrderStorage orderStorage, + IShopStorage shopStorage, + AbstractSaveToExcel saveToExcel, + AbstractSaveToWord saveToWord, + AbstractSaveToPdf saveToPdf) { _documentStorage = documentStorage; _blankStorage = blankStorage; @@ -27,6 +32,7 @@ namespace LawFirmBusinessLogic.BusinessLogics _saveToExcel = saveToExcel; _saveToWord = saveToWord; _saveToPdf = saveToPdf; + _shopStorage = shopStorage; } /// /// Получение списка компонент с указанием, в каких изделиях используются @@ -90,7 +96,7 @@ namespace LawFirmBusinessLogic.BusinessLogics { FileName = model.FileName, Title = "Список бланков", - Blanks = _blankStorage.GetFullList() + Documents = _documentStorage.GetFullList() }); } /// @@ -121,5 +127,72 @@ namespace LawFirmBusinessLogic.BusinessLogics 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/BusinessLogics/ShopLogic.cs b/LawFirm/LawFirmBusinessLogic/BusinessLogics/ShopLogic.cs new file mode 100644 index 0000000..1310740 --- /dev/null +++ b/LawFirm/LawFirmBusinessLogic/BusinessLogics/ShopLogic.cs @@ -0,0 +1,210 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.BusinessLogicsContracts; +using LawFirmContracts.SearchModels; +using LawFirmContracts.StoragesContracts; +using LawFirmContracts.ViewModels; +using LawFirmDataModels.Models; +using Microsoft.Extensions.Logging; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LawFirmBusinessLogic.BusinessLogics +{ + public class ShopLogic : IShopLogic + { + private readonly ILogger _logger; + private readonly IShopStorage _shopStorage; + public ShopLogic(ILogger logger, IShopStorage shopStorage) + { + _logger = logger; + _shopStorage = shopStorage; + } + public List? ReadList(ShopSearchModel? model) + { + _logger.LogInformation("ReadList. ShopName: {ShopName}. Id: {Id}", model?.ShopName, model?.Id); + var list = model == null ? _shopStorage.GetFullList() : _shopStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count: {Count}", list.Count); + return list; + } + public ShopViewModel? ReadElement(ShopSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. ShopName: {ShopName}. Id: {Id}", model.ShopName, model.Id); + var element = _shopStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("ReadElement element not found"); + return null; + } + _logger.LogInformation("ReadElement find. Id: {Id}", element.Id); + return element; + } + public bool Create(ShopBindingModel model) + { + CheckModel(model); + if (_shopStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(ShopBindingModel model) + { + CheckModel(model); + if (_shopStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(ShopBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id: {Id}", model.Id); + if (_shopStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(ShopBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.ShopName)) + { + throw new ArgumentNullException("Нет названия магазина", nameof(model.ShopName)); + } + _logger.LogInformation("Shop. ShopName:{0}. Address:{1}. Id:{2}", + model.ShopName, model.Address, model.Id); + var element = _shopStorage.GetElement(new ShopSearchModel + { + ShopName = model.ShopName + }); + if (element != null && element.Id != model.Id && element.ShopName == model.ShopName) + { + throw new InvalidOperationException("Магазин с таким названием уже есть"); + } + } + + public bool AddDocument(ShopSearchModel model, IDocumentModel document, int count) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (count <= 0) + { + throw new ArgumentException("Количество документов должно быть больше 0", nameof(count)); + } + _logger.LogInformation("AddDocument. ShopName:{ShopName}. Id:{Id}", model.ShopName, model.Id); + var element = _shopStorage.GetElement(model); + if (element == null) + { + _logger.LogWarning("AddDocument element not found"); + return false; + } + if (element.Capacity - element.ShopDocuments.Select(x => x.Value.Item2).Sum() < count) + { + throw new ArgumentNullException("В магазине не хватает места", nameof(count)); + } + + if (element.ShopDocuments.TryGetValue(document.Id, out var pair)) + { + element.ShopDocuments[document.Id] = (document, count + pair.Item2); + _logger.LogInformation("AddDocument. Added {count} {document} to '{ShopName}' shop", + count, document.DocumentName, element.ShopName); + } + else + { + element.ShopDocuments[document.Id] = (document, count); + _logger.LogInformation("AddDocument. Added {count} new document {document} to '{ShopName}' shop", + count, document.DocumentName, element.ShopName); + } + _shopStorage.Update(new() + { + Id = element.Id, + Address = element.Address, + ShopName = element.ShopName, + DateOpen = element.DateOpen, + Capacity = element.Capacity, + ShopDocuments = element.ShopDocuments + }); + return true; + } + public bool AddDocuments(IDocumentModel model, int count) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (count <= 0) + { + throw new ArgumentException("Количество документов должно быть больше 0", nameof(count)); + } + _logger.LogInformation("AddDocuments. ShopName:{ShopName}. Id:{Id}", model.DocumentName, model.Id); + var allFreeQuantity = _shopStorage.GetFullList().Select(x => x.Capacity - x.ShopDocuments.Select(x => x.Value.Item2).Sum()).Sum(); + if (allFreeQuantity < count) + { + _logger.LogWarning("AddTravels operation failed."); + return false; + } + foreach (var shop in _shopStorage.GetFullList()) + { + int freeQuantity = shop.Capacity - shop.ShopDocuments.Select(x => x.Value.Item2).Sum(); + if (freeQuantity <= 0) + { + continue; + } + if (freeQuantity < count) + { + if (!AddDocument(new() { Id = shop.Id }, model, freeQuantity)) + { + _logger.LogWarning("AddDocuments operation failed."); + return false; + } + count -= freeQuantity; + } + else + { + if (!AddDocument(new() { Id = shop.Id }, model, count)) + { + _logger.LogWarning("AddDocuments operation failed."); + return false; + } + count = 0; + } + if (count == 0) + { + return true; + } + } + _logger.LogWarning("AddDocuments operation failed."); + return false; + } + public bool SellDocuments(IDocumentModel model, int count) + { + return _shopStorage.SellDocuments(model, count); + } + } +} diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index 0b5443c..2a94ed8 100644 --- a/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -71,11 +71,81 @@ namespace LawFirmBusinessLogic.OfficePackage } SaveExcel(info); } - /// - /// Создание excel-файла - /// - /// - protected abstract void CreateExcel(ExcelInfo 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); /// /// Добавляем новую ячейку в лист /// diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToPdf.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToPdf.cs index b63d08a..c28d73a 100644 --- a/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToPdf.cs +++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToPdf.cs @@ -3,6 +3,7 @@ using LawFirmBusinessLogic.OfficePackage.HelperEnums; using LawFirmBusinessLogic.OfficePackage.HelperModels; using System.Collections.Generic; using System.Linq; +using System.Text; namespace LawFirmBusinessLogic.OfficePackage { @@ -48,11 +49,48 @@ namespace LawFirmBusinessLogic.OfficePackage }); SavePdf(info); } - /// - /// Создание doc-файла - /// - /// - protected abstract void CreatePdf(PdfInfo 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); /// /// Создание параграфа с текстом /// diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToWord.cs index 49afb71..fb7a8f5 100644 --- a/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -18,12 +18,12 @@ namespace LawFirmBusinessLogic.OfficePackage JustificationType = WordJustificationType.Center } }); - foreach (var blank in info.Blanks) + foreach (var blank in info.Documents) { CreateParagraph(new WordParagraph { Texts = new List<(string, WordTextProperties)> { - (blank.BlankName + " - ", new WordTextProperties { Size = "24", Bold=true}), + (blank.DocumentName + " - ", new WordTextProperties { Size = "24", Bold=true}), (blank.Price.ToString(), new WordTextProperties { Size = "24", }) }, TextProperties = new WordTextProperties @@ -35,17 +35,54 @@ namespace LawFirmBusinessLogic.OfficePackage } SaveWord(info); } - /// - /// Создание doc-файла - /// - /// - protected abstract void CreateWord(WordInfo info); - /// - /// Создание абзаца с текстом - /// - /// - /// - protected abstract void CreateParagraph(WordParagraph paragraph); + 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); /// /// Сохранение файла /// diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs index 36f00bc..ffd6610 100644 --- a/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs +++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs @@ -6,11 +6,9 @@ namespace LawFirmBusinessLogic.OfficePackage.HelperModels { public string FileName { get; set; } = string.Empty; public string Title { get; set; } = string.Empty; - public List DocumentBlanks - { - get; - set; - } = new(); - } + + public List DocumentBlanks { get; set; } = new(); + public List ShopDocuments { get; set; } = new(); + } } diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs index 8d442b1..602ace5 100644 --- a/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs +++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs @@ -9,5 +9,6 @@ namespace LawFirmBusinessLogic.OfficePackage.HelperModels 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/WordInfo.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/WordInfo.cs index c75881d..f6efb4a 100644 --- a/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/WordInfo.cs +++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/HelperModels/WordInfo.cs @@ -6,6 +6,7 @@ namespace LawFirmBusinessLogic.OfficePackage.HelperModels { public string FileName { get; set; } = string.Empty; public string Title { get; set; } = string.Empty; - public List Blanks { get; set; } = new(); - } + public List Documents { get; set; } = new(); + public List Shops { get; set; } = new(); + } } diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/Implements/SaveToWord.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/Implements/SaveToWord.cs index 0047c30..31da6e3 100644 --- a/LawFirm/LawFirmBusinessLogic/OfficePackage/Implements/SaveToWord.cs +++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/Implements/SaveToWord.cs @@ -72,7 +72,59 @@ namespace LawFirmBusinessLogic.OfficePackage.Implements properties.AppendChild(paragraphMarkRunProperties); return properties; } - protected override void CreateWord(WordInfo info) + 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); diff --git a/LawFirm/LawFirmContracts/BindingModels/OrderBindingModel.cs b/LawFirm/LawFirmContracts/BindingModels/OrderBindingModel.cs index b4f2473..fb7e7fe 100644 --- a/LawFirm/LawFirmContracts/BindingModels/OrderBindingModel.cs +++ b/LawFirm/LawFirmContracts/BindingModels/OrderBindingModel.cs @@ -11,7 +11,7 @@ namespace LawFirmContracts.BindingModels public int Count { get; set; } public double Sum { get; set; } public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; - public DateTime DateCreate { get; set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc); + public DateTime DateCreate { get; set; } = DateTime.SpecifyKind(DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc), DateTimeKind.Utc); public DateTime? DateImplement { get; set; } } } diff --git a/LawFirm/LawFirmContracts/BindingModels/ShopBindingModel.cs b/LawFirm/LawFirmContracts/BindingModels/ShopBindingModel.cs new file mode 100644 index 0000000..c8bb4cd --- /dev/null +++ b/LawFirm/LawFirmContracts/BindingModels/ShopBindingModel.cs @@ -0,0 +1,19 @@ +using LawFirmDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LawFirmContracts.BindingModels +{ + public class ShopBindingModel : IShopModel + { + public string ShopName { get; set; } = string.Empty; + public string Address { get; set; } = string.Empty; + public DateTime DateOpen { get; set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc); + public int Capacity { get; set; } + public Dictionary ShopDocuments { get; set; } = new(); + public int Id { get; set; } + } +} diff --git a/LawFirm/LawFirmContracts/BusinessLogicsContracts/IReportLogic.cs b/LawFirm/LawFirmContracts/BusinessLogicsContracts/IReportLogic.cs index d285ec6..296e1a1 100644 --- a/LawFirm/LawFirmContracts/BusinessLogicsContracts/IReportLogic.cs +++ b/LawFirm/LawFirmContracts/BusinessLogicsContracts/IReportLogic.cs @@ -11,26 +11,31 @@ namespace LawFirmContracts.BusinessLogicsContracts /// /// List GetDocumentBlank(); - /// - /// Получение списка заказов за определенный период - /// - /// - /// - List GetOrders(ReportBindingModel model); + List GetShopDocuments(); + List GetGroupedByDateOrders(); + /// + /// Получение списка заказов за определенный период + /// + /// + /// + List GetOrders(ReportBindingModel model); /// /// Сохранение компонент в файл-Word /// /// void SaveBlanksToWordFile(ReportBindingModel model); - /// - /// Сохранение компонент с указаеним продуктов в файл-Excel - /// - /// - void SaveDocumentBlankToExcelFile(ReportBindingModel model); - /// - /// Сохранение заказов в файл-Pdf - /// - /// - void SaveOrdersToPdfFile(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/BusinessLogicsContracts/IShopLogic.cs b/LawFirm/LawFirmContracts/BusinessLogicsContracts/IShopLogic.cs new file mode 100644 index 0000000..60c4985 --- /dev/null +++ b/LawFirm/LawFirmContracts/BusinessLogicsContracts/IShopLogic.cs @@ -0,0 +1,24 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.SearchModels; +using LawFirmContracts.ViewModels; +using LawFirmDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LawFirmContracts.BusinessLogicsContracts +{ + public interface IShopLogic + { + List? ReadList(ShopSearchModel? model); + ShopViewModel? ReadElement(ShopSearchModel model); + bool Create(ShopBindingModel model); + bool Update(ShopBindingModel model); + bool Delete(ShopBindingModel model); + bool AddDocuments(IDocumentModel model, int count); + bool SellDocuments(IDocumentModel model, int count); + bool AddDocument(ShopSearchModel model, IDocumentModel document, int count); + } +} diff --git a/LawFirm/LawFirmContracts/SearchModels/ShopSearchModel.cs b/LawFirm/LawFirmContracts/SearchModels/ShopSearchModel.cs new file mode 100644 index 0000000..fa7522f --- /dev/null +++ b/LawFirm/LawFirmContracts/SearchModels/ShopSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LawFirmContracts.SearchModels +{ + public class ShopSearchModel + { + public int? Id { get; set; } + public string? ShopName { get; set; } + } +} diff --git a/LawFirm/LawFirmContracts/StoragesContracts/IShopStorage.cs b/LawFirm/LawFirmContracts/StoragesContracts/IShopStorage.cs new file mode 100644 index 0000000..4fb68eb --- /dev/null +++ b/LawFirm/LawFirmContracts/StoragesContracts/IShopStorage.cs @@ -0,0 +1,23 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.SearchModels; +using LawFirmContracts.ViewModels; +using LawFirmDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LawFirmContracts.StoragesContracts +{ + public interface IShopStorage + { + List GetFullList(); + List GetFilteredList(ShopSearchModel model); + ShopViewModel? GetElement(ShopSearchModel model); + ShopViewModel? Insert(ShopBindingModel model); + ShopViewModel? Update(ShopBindingModel model); + ShopViewModel? Delete(ShopBindingModel model); + bool SellDocuments(IDocumentModel model, int count); + } +} 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/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/LawFirmContracts/ViewModels/ShopViewModel.cs b/LawFirm/LawFirmContracts/ViewModels/ShopViewModel.cs new file mode 100644 index 0000000..cf48275 --- /dev/null +++ b/LawFirm/LawFirmContracts/ViewModels/ShopViewModel.cs @@ -0,0 +1,26 @@ +using LawFirmDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LawFirmContracts.ViewModels +{ + public class ShopViewModel : IShopModel + { + [DisplayName("Название магазина")] + public string ShopName { get; set; } = string.Empty; + + [DisplayName("Адрес магазина")] + public string Address { get; set; } = string.Empty; + + [DisplayName("Дата открытия")] + public DateTime DateOpen { get; set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc); + [DisplayName("Вместимость магазина")] + public int Capacity { get; set; } + public Dictionary ShopDocuments { get; set; } = new(); + public int Id { get; set; } + } +} diff --git a/LawFirm/LawFirmDataModel/Models/IShopModel.cs b/LawFirm/LawFirmDataModel/Models/IShopModel.cs new file mode 100644 index 0000000..4049c17 --- /dev/null +++ b/LawFirm/LawFirmDataModel/Models/IShopModel.cs @@ -0,0 +1,14 @@ +using LawFirmDataModels; +using LawFirmDataModels.Models; + +namespace LawFirmDataModels.Models +{ + public interface IShopModel : IId + { + string ShopName { get; } + string Address { get; } + DateTime DateOpen { get; } + public int Capacity { get; } + Dictionary ShopDocuments { get; } + } +} diff --git a/LawFirm/LawFirmDatabaseImplement/Implements/ShopStorage.cs b/LawFirm/LawFirmDatabaseImplement/Implements/ShopStorage.cs new file mode 100644 index 0000000..f751325 --- /dev/null +++ b/LawFirm/LawFirmDatabaseImplement/Implements/ShopStorage.cs @@ -0,0 +1,156 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.SearchModels; +using LawFirmContracts.StoragesContracts; +using LawFirmContracts.ViewModels; +using LawFirmDatabaseImplement.Models; +using LawFirmDataModels.Models; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LawFirmDatabaseImplement.Implements +{ + public class ShopStorage : IShopStorage + { + public ShopViewModel? GetElement(ShopSearchModel model) + { + if (string.IsNullOrEmpty(model.ShopName) && + !model.Id.HasValue) + { + return null; + } + using var context = new LawFirmDatabase(); + return context.Shops + .Include(x => x.Documents) + .ThenInclude(x => x.Document) + .FirstOrDefault(x => (!string.IsNullOrEmpty(model.ShopName) && + x.ShopName == model.ShopName) || + (model.Id.HasValue && x.Id == + model.Id)) + ?.GetViewModel; + } + + public List GetFilteredList(ShopSearchModel model) + { + if (string.IsNullOrEmpty(model.ShopName)) + { + return new(); + } + using var context = new LawFirmDatabase(); + return context.Shops + .Include(x => x.Documents) + .ThenInclude(x => x.Document) + .Where(x => x.ShopName.Contains(model.ShopName)) + .ToList() + .Select(x => x.GetViewModel) + .ToList(); + } + + public List GetFullList() + { + using var context = new LawFirmDatabase(); + return context.Shops.Include(x => x.Documents) + .ThenInclude(x => x.Document) + .ToList() + .Select(x => x.GetViewModel) + .ToList(); + } + + public ShopViewModel? Insert(ShopBindingModel model) + { + using var context = new LawFirmDatabase(); + var newProduct = Shop.Create(context, model); + if (newProduct == null) + { + return null; + } + context.Shops.Add(newProduct); + context.SaveChanges(); + return newProduct.GetViewModel; + } + + public ShopViewModel? Update(ShopBindingModel model) + { + using var context = new LawFirmDatabase(); + using var transaction = context.Database.BeginTransaction(); + try + { + var shop = context.Shops.FirstOrDefault(rec => + rec.Id == model.Id); + if (shop == null) + { + return null; + } + shop.Update(model); + context.SaveChanges(); + shop.UpdateDocuments(context, model); + transaction.Commit(); + return shop.GetViewModel; + } + catch + { + transaction.Rollback(); + throw; + } + } + public ShopViewModel? Delete(ShopBindingModel model) + { + using var context = new LawFirmDatabase(); + var element = context.Shops + .Include(x => x.Documents) + .FirstOrDefault(rec => rec.Id == model.Id); + if (element != null) + { + context.Shops.Remove(element); + context.SaveChanges(); + return element.GetViewModel; + } + return null; + } + public bool SellDocuments(IDocumentModel model, int count) + { + using var context = new LawFirmDatabase(); + using var transaction = context.Database.BeginTransaction(); + try + { + List shopsWithDocument = context.Shops.Include(x => x.Documents).ThenInclude(x => x.Document).Where(x => x.Documents.Any(x => x.DocumentId == model.Id)).ToList(); + foreach (var shop in shopsWithDocument) + { + int carInShopCount = shop.ShopDocuments[model.Id].Item2; + if (count - carInShopCount >= 0) + { + count -= carInShopCount; + context.ShopDocuments.Remove(shop.Documents.FirstOrDefault(x => x.DocumentId == model.Id)!); + shop.ShopDocuments.Remove(model.Id); + } + else + { + shop.ShopDocuments[model.Id] = (model, carInShopCount - count); + count = 0; + shop.UpdateDocuments(context, new() + { + Id = shop.Id, + ShopDocuments = shop.ShopDocuments + }); + } + if (count == 0) + { + context.SaveChanges(); + transaction.Commit(); + return true; + } + } + transaction.Rollback(); + return false; + } + catch + { + transaction.Rollback(); + throw; + } + } + } +} diff --git a/LawFirm/LawFirmDatabaseImplement/LawFirmDatabase.cs b/LawFirm/LawFirmDatabaseImplement/LawFirmDatabase.cs index ba0238a..9dc139a 100644 --- a/LawFirm/LawFirmDatabaseImplement/LawFirmDatabase.cs +++ b/LawFirm/LawFirmDatabaseImplement/LawFirmDatabase.cs @@ -22,6 +22,9 @@ namespace LawFirmDatabaseImplement public virtual DbSet Documents { set; get; } public virtual DbSet DocumentBlanks { set; get; } public virtual DbSet Orders { set; get; } + public virtual DbSet Shops { set; get; } + public virtual DbSet ShopDocuments { set; get; } + } public virtual DbSet Clients { set; get; } } } diff --git a/LawFirm/LawFirmDatabaseImplement/Migrations/20230424233004_lab3hard.Designer.cs b/LawFirm/LawFirmDatabaseImplement/Migrations/20230424233004_lab3hard.Designer.cs new file mode 100644 index 0000000..53c3c1b --- /dev/null +++ b/LawFirm/LawFirmDatabaseImplement/Migrations/20230424233004_lab3hard.Designer.cs @@ -0,0 +1,248 @@ +// +using System; +using LawFirmDatabaseImplement; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace LawFirmDatabaseImplement.Migrations +{ + [DbContext(typeof(LawFirmDatabase))] + [Migration("20230424233004_lab3hard")] + partial class lab3hard + { + /// + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "7.0.3") + .HasAnnotation("Relational:MaxIdentifierLength", 63); + + NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder); + + modelBuilder.Entity("LawFirmDatabaseImplement.Models.Blank", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BlankName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.ToTable("Blanks"); + }); + + modelBuilder.Entity("LawFirmDatabaseImplement.Models.Document", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("DocumentName") + .IsRequired() + .HasColumnType("text"); + + b.Property("Price") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.ToTable("Documents"); + }); + + modelBuilder.Entity("LawFirmDatabaseImplement.Models.DocumentBlank", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("BlankId") + .HasColumnType("integer"); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("DocumentId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("BlankId"); + + b.HasIndex("DocumentId"); + + b.ToTable("DocumentBlanks"); + }); + + modelBuilder.Entity("LawFirmDatabaseImplement.Models.Order", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("DateCreate") + .HasColumnType("timestamp with time zone"); + + b.Property("DateImplement") + .HasColumnType("timestamp with time zone"); + + b.Property("DocumentId") + .HasColumnType("integer"); + + b.Property("Status") + .HasColumnType("integer"); + + b.Property("Sum") + .HasColumnType("double precision"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.ToTable("Orders"); + }); + + modelBuilder.Entity("LawFirmDatabaseImplement.Models.Shop", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("text"); + + b.Property("Capacity") + .HasColumnType("integer"); + + b.Property("DateOpen") + .HasColumnType("timestamp with time zone"); + + b.Property("ShopName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Shops"); + }); + + modelBuilder.Entity("LawFirmDatabaseImplement.Models.ShopDocument", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("DocumentId") + .HasColumnType("integer"); + + b.Property("ShopId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("ShopId"); + + b.ToTable("ShopDocuments"); + }); + + modelBuilder.Entity("LawFirmDatabaseImplement.Models.DocumentBlank", b => + { + b.HasOne("LawFirmDatabaseImplement.Models.Blank", "Blank") + .WithMany("DocumentBlanks") + .HasForeignKey("BlankId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LawFirmDatabaseImplement.Models.Document", "Document") + .WithMany("Blanks") + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Blank"); + + b.Navigation("Document"); + }); + + modelBuilder.Entity("LawFirmDatabaseImplement.Models.Order", b => + { + b.HasOne("LawFirmDatabaseImplement.Models.Document", "Document") + .WithMany("Orders") + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + }); + + modelBuilder.Entity("LawFirmDatabaseImplement.Models.ShopDocument", b => + { + b.HasOne("LawFirmDatabaseImplement.Models.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LawFirmDatabaseImplement.Models.Shop", "Shop") + .WithMany("Documents") + .HasForeignKey("ShopId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("Shop"); + }); + + modelBuilder.Entity("LawFirmDatabaseImplement.Models.Blank", b => + { + b.Navigation("DocumentBlanks"); + }); + + modelBuilder.Entity("LawFirmDatabaseImplement.Models.Document", b => + { + b.Navigation("Blanks"); + + b.Navigation("Orders"); + }); + + modelBuilder.Entity("LawFirmDatabaseImplement.Models.Shop", b => + { + b.Navigation("Documents"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/LawFirm/LawFirmDatabaseImplement/Migrations/20230424233004_lab3hard.cs b/LawFirm/LawFirmDatabaseImplement/Migrations/20230424233004_lab3hard.cs new file mode 100644 index 0000000..10e8a3e --- /dev/null +++ b/LawFirm/LawFirmDatabaseImplement/Migrations/20230424233004_lab3hard.cs @@ -0,0 +1,79 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +#nullable disable + +namespace LawFirmDatabaseImplement.Migrations +{ + /// + public partial class lab3hard : Migration + { + /// + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateTable( + name: "Shops", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + ShopName = table.Column(type: "text", nullable: false), + Address = table.Column(type: "text", nullable: false), + DateOpen = table.Column(type: "timestamp with time zone", nullable: false), + Capacity = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_Shops", x => x.Id); + }); + + migrationBuilder.CreateTable( + name: "ShopDocuments", + columns: table => new + { + Id = table.Column(type: "integer", nullable: false) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn), + ShopId = table.Column(type: "integer", nullable: false), + DocumentId = table.Column(type: "integer", nullable: false), + Count = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ShopDocuments", x => x.Id); + table.ForeignKey( + name: "FK_ShopDocuments_Documents_DocumentId", + column: x => x.DocumentId, + principalTable: "Documents", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_ShopDocuments_Shops_ShopId", + column: x => x.ShopId, + principalTable: "Shops", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateIndex( + name: "IX_ShopDocuments_DocumentId", + table: "ShopDocuments", + column: "DocumentId"); + + migrationBuilder.CreateIndex( + name: "IX_ShopDocuments_ShopId", + table: "ShopDocuments", + column: "ShopId"); + } + + /// + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropTable( + name: "ShopDocuments"); + + migrationBuilder.DropTable( + name: "Shops"); + } + } +} diff --git a/LawFirm/LawFirmDatabaseImplement/Migrations/LawFirmDatabaseModelSnapshot.cs b/LawFirm/LawFirmDatabaseImplement/Migrations/LawFirmDatabaseModelSnapshot.cs index 7dd321c..bd149ac 100644 --- a/LawFirm/LawFirmDatabaseImplement/Migrations/LawFirmDatabaseModelSnapshot.cs +++ b/LawFirm/LawFirmDatabaseImplement/Migrations/LawFirmDatabaseModelSnapshot.cs @@ -151,6 +151,59 @@ namespace LawFirmDatabaseImplement.Migrations b.ToTable("Orders"); }); + modelBuilder.Entity("LawFirmDatabaseImplement.Models.Shop", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Address") + .IsRequired() + .HasColumnType("text"); + + b.Property("Capacity") + .HasColumnType("integer"); + + b.Property("DateOpen") + .HasColumnType("timestamp with time zone"); + + b.Property("ShopName") + .IsRequired() + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("Shops"); + }); + + modelBuilder.Entity("LawFirmDatabaseImplement.Models.ShopDocument", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("integer"); + + NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id")); + + b.Property("Count") + .HasColumnType("integer"); + + b.Property("DocumentId") + .HasColumnType("integer"); + + b.Property("ShopId") + .HasColumnType("integer"); + + b.HasKey("Id"); + + b.HasIndex("DocumentId"); + + b.HasIndex("ShopId"); + + b.ToTable("ShopDocuments"); + }); + modelBuilder.Entity("LawFirmDatabaseImplement.Models.DocumentBlank", b => { b.HasOne("LawFirmDatabaseImplement.Models.Blank", "Blank") @@ -189,6 +242,25 @@ namespace LawFirmDatabaseImplement.Migrations b.Navigation("Document"); }); + modelBuilder.Entity("LawFirmDatabaseImplement.Models.ShopDocument", b => + { + b.HasOne("LawFirmDatabaseImplement.Models.Document", "Document") + .WithMany() + .HasForeignKey("DocumentId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LawFirmDatabaseImplement.Models.Shop", "Shop") + .WithMany("Documents") + .HasForeignKey("ShopId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("Document"); + + b.Navigation("Shop"); + }); + modelBuilder.Entity("LawFirmDatabaseImplement.Models.Blank", b => { b.Navigation("DocumentBlanks"); @@ -205,6 +277,11 @@ namespace LawFirmDatabaseImplement.Migrations b.Navigation("Orders"); }); + + modelBuilder.Entity("LawFirmDatabaseImplement.Models.Shop", b => + { + b.Navigation("Documents"); + }); #pragma warning restore 612, 618 } } diff --git a/LawFirm/LawFirmDatabaseImplement/Models/Shop.cs b/LawFirm/LawFirmDatabaseImplement/Models/Shop.cs new file mode 100644 index 0000000..9ffc0cc --- /dev/null +++ b/LawFirm/LawFirmDatabaseImplement/Models/Shop.cs @@ -0,0 +1,108 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.ViewModels; +using LawFirmDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LawFirmDatabaseImplement.Models +{ + public class Shop : IShopModel + { + public int Id { get; set; } + [Required] + public string ShopName { get; set; } = string.Empty; + [Required] + public string Address { get; set; } = string.Empty; + [Required] + public DateTime DateOpen { get; set; } + [Required] + public int Capacity { get; set; } + + private Dictionary? _shopDocuments = null; + + [NotMapped] + public Dictionary ShopDocuments + { + get + { + if (_shopDocuments == null) + { + _shopDocuments = Documents + .ToDictionary(rec => rec.DocumentId, + rec => (rec.Document as IDocumentModel, + rec.Count)); + } + return _shopDocuments; + } + } + [ForeignKey("ShopId")] + public virtual List Documents { get; set; } = new(); + public static Shop Create(LawFirmDatabase context, ShopBindingModel model) + { + return new Shop() + { + Id = model.Id, + ShopName = model.ShopName, + Address = model.Address, + DateOpen = model.DateOpen, + Capacity = model.Capacity, + Documents = model.ShopDocuments.Select(x => new ShopDocument + { + Document = context.Documents.First(y => y.Id == x.Key), + Count = x.Value.Item2 + }).ToList() + }; + } + + public void Update(ShopBindingModel model) + { + ShopName = model.ShopName; + Address = model.Address; + DateOpen = model.DateOpen; + Capacity = model.Capacity; + } + + public ShopViewModel GetViewModel => new() + { + Id = Id, + ShopName = ShopName, + Address = Address, + DateOpen = DateOpen, + Capacity = Capacity, + ShopDocuments = ShopDocuments + }; + + public void UpdateDocuments(LawFirmDatabase context, ShopBindingModel model) + { + var shopDocuments = context.ShopDocuments.Where(rec => rec.ShopId == model.Id).ToList(); + if (shopDocuments != null && shopDocuments.Count > 0) + { + context.ShopDocuments.RemoveRange(shopDocuments.Where(rec => !model.ShopDocuments.ContainsKey(rec.DocumentId))); + context.SaveChanges(); + foreach (var updateDocument in shopDocuments) + { + updateDocument.Count = model.ShopDocuments[updateDocument.DocumentId].Item2; + model.ShopDocuments.Remove(updateDocument.DocumentId); + } + context.SaveChanges(); + } + var shop = context.Shops.First(x => x.Id == Id); + foreach (var id in model.ShopDocuments) + { + context.ShopDocuments.Add(new ShopDocument + { + Shop = shop, + Document = context.Documents.First(x => x.Id == id.Key), + Count = id.Value.Item2 + }); + context.SaveChanges(); + } + _shopDocuments = null; + } + } +} diff --git a/LawFirm/LawFirmDatabaseImplement/Models/ShopDocument.cs b/LawFirm/LawFirmDatabaseImplement/Models/ShopDocument.cs new file mode 100644 index 0000000..e4527f4 --- /dev/null +++ b/LawFirm/LawFirmDatabaseImplement/Models/ShopDocument.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LawFirmDatabaseImplement.Models +{ + public class ShopDocument + { + public int Id { get; set; } + + [Required] + public int ShopId { get; set; } + + [Required] + public int DocumentId { get; set; } + + [Required] + public int Count { get; set; } + + public virtual Document Document { get; set; } = new(); + + public virtual Shop Shop { get; set; } = new(); + } +} diff --git a/LawFirm/LawFirmFileImplement/DataFileSingleton.cs b/LawFirm/LawFirmFileImplement/DataFileSingleton.cs index 82effda..cffef75 100644 --- a/LawFirm/LawFirmFileImplement/DataFileSingleton.cs +++ b/LawFirm/LawFirmFileImplement/DataFileSingleton.cs @@ -9,11 +9,13 @@ namespace LawFirmFileImplement private readonly string BlankFileName = "Blank.xml"; private readonly string OrderFileName = "Order.xml"; private readonly string DocumentFileName = "Document.xml"; - private readonly string ClientFileName = "Client.xml"; + private readonly string ShopFileName = "Shop.xml"; - public List Blanks { get; private set; } + public List Blanks { get; private set; } + private readonly string ClientFileName = "Client.xml"; public List Orders { get; private set; } public List Documents { get; private set; } + public List Shops { get; private set; } public List Clients { get; private set; } public static DataFileSingleton GetInstance() @@ -27,7 +29,8 @@ namespace LawFirmFileImplement public void SaveBlanks() => SaveData(Blanks, BlankFileName, "Blanks", x => x.GetXElement); public void SaveDocuments() => SaveData(Documents, DocumentFileName, "Documents", x => x.GetXElement); public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement); - public void SaveClients() => SaveData(Clients, OrderFileName, "Clients", x => x.GetXElement); + public void SaveShops() => SaveData(Shops, ShopFileName, "Shops", x => x.GetXElement); + public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement); private DataFileSingleton() { @@ -35,8 +38,9 @@ namespace LawFirmFileImplement Documents = LoadData(DocumentFileName, "Document", x => Document.Create(x)!)!; Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!; Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!; - } - private static List? LoadData(string filename, string xmlNodeName, + Shops = LoadData(ShopFileName, "Shop", x => Shop.Create(x)!)!; + } + private static List? LoadData(string filename, string xmlNodeName, Func selectFunction) { if (File.Exists(filename)) diff --git a/LawFirm/LawFirmFileImplement/Implements/ShopStorage.cs b/LawFirm/LawFirmFileImplement/Implements/ShopStorage.cs new file mode 100644 index 0000000..156ac44 --- /dev/null +++ b/LawFirm/LawFirmFileImplement/Implements/ShopStorage.cs @@ -0,0 +1,129 @@ + +using LawFirmContracts.BindingModels; +using LawFirmContracts.SearchModels; +using LawFirmContracts.StoragesContracts; +using LawFirmContracts.ViewModels; +using LawFirmDataModels.Models; +using LawFirmFileImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LawFirmFileImplement.Implements +{ + public class ShopStorage : IShopStorage + { + private readonly DataFileSingleton source; + + public ShopStorage() + { + source = DataFileSingleton.GetInstance(); + } + + public ShopViewModel? GetElement(ShopSearchModel model) + { + if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue) + { + return null; + } + return source.Shops + .FirstOrDefault(x => (!string.IsNullOrEmpty(model.ShopName) && x.ShopName == model.ShopName) || (model.Id.HasValue && x.Id == model.Id))?.GetViewModel; + } + + public List GetFilteredList(ShopSearchModel model) + { + if (string.IsNullOrEmpty(model.ShopName)) + { + return new(); + } + /*return source.Shops + .Where(x => x.ShopName.Contains(model.ShopName)) + .Select(x => x.GetViewModel) + .ToList();*/ + return source.Shops + .Where(x => x.ShopName.Contains(model.ShopName)) + .Select(x => x.GetViewModel) + .ToList(); + } + + public List GetFullList() + { + return source.Shops.Select(x => x.GetViewModel).ToList(); + } + + public ShopViewModel? Insert(ShopBindingModel model) + { + model.Id = source.Shops.Count > 0 ? source.Shops.Max(x => x.Id) + 1 : 1; + var newShop = Shop.Create(model); + if (newShop == null) + { + return null; + } + source.Shops.Add(newShop); + source.SaveShops(); + return newShop.GetViewModel; + } + + public ShopViewModel? Update(ShopBindingModel model) + { + var shop = source.Shops.FirstOrDefault(x => x.Id == model.Id); + if (shop == null) + { + return null; + } + shop.Update(model); + source.SaveShops(); + return shop.GetViewModel; + } + public ShopViewModel? Delete(ShopBindingModel model) + { + var shop = source.Shops.FirstOrDefault(x => x.Id == model.Id); + if (shop != null) + { + source.Shops.Remove(shop); + source.SaveShops(); + return shop.GetViewModel; + } + return null; + } + public bool SellDocuments(IDocumentModel model, int count) + { + int availableQuantity = source.Shops.Select(x => x.ShopDocuments.FirstOrDefault(y => y.Key == model.Id).Value.Item2).Sum(); + if (availableQuantity < count) + { + return false; + } + var shops = source.Shops.Where(x => x.ShopDocuments.ContainsKey(model.Id)); + foreach (var shop in shops) + { + int countInCurrentShop = shop.ShopDocuments[model.Id].Item2; + if (countInCurrentShop <= count) + { + shop.ShopDocuments[model.Id] = (shop.ShopDocuments[model.Id].Item1, 0); + count -= countInCurrentShop; + } + else + { + shop.ShopDocuments[model.Id] = (shop.ShopDocuments[model.Id].Item1, countInCurrentShop - count); + count = 0; + } + Update(new ShopBindingModel + { + Id = shop.Id, + ShopName = shop.ShopName, + Address = shop.Address, + DateOpen = shop.DateOpen, + ShopDocuments = shop.ShopDocuments, + Capacity = shop.Capacity + }); + if (count == 0) + { + return true; + } + } + return false; + } + } +} diff --git a/LawFirm/LawFirmFileImplement/Models/Order.cs b/LawFirm/LawFirmFileImplement/Models/Order.cs index 718ef74..c91352a 100644 --- a/LawFirm/LawFirmFileImplement/Models/Order.cs +++ b/LawFirm/LawFirmFileImplement/Models/Order.cs @@ -14,7 +14,7 @@ namespace LawFirmFileImplement.Models public int Count { get; private set; } public double Sum { get; private set; } public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; - public DateTime DateCreate { get; private set; } = DateTime.Now; + public DateTime DateCreate { get; private set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc); public DateTime? DateImplement { get; private set; } public static Order? Create(OrderBindingModel? model) { diff --git a/LawFirm/LawFirmFileImplement/Models/Shop.cs b/LawFirm/LawFirmFileImplement/Models/Shop.cs new file mode 100644 index 0000000..b8d1a9f --- /dev/null +++ b/LawFirm/LawFirmFileImplement/Models/Shop.cs @@ -0,0 +1,108 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.ViewModels; +using LawFirmDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; + +namespace LawFirmFileImplement.Models +{ + public class Shop : IShopModel + { + public int Id { get; private set; } + public string ShopName { get; private set; } = string.Empty; + public string Address { get; private set; } = string.Empty; + public DateTime DateOpen { get; private set; } + public int Capacity { get; private set; } + public Dictionary DocumentsCount = new(); + public Dictionary? _documents = null; + public Dictionary ShopDocuments + { + get + { + if (_documents == null) + { + var source = DataFileSingleton.GetInstance(); + _documents = DocumentsCount.ToDictionary( + x => x.Key, + y => ((source.Documents.FirstOrDefault(z => z.Id == y.Key) as IDocumentModel)!, + y.Value) + ); + } + return _documents; + } + } + public static Shop? Create(ShopBindingModel? model) + { + if (model == null) + { + return null; + } + return new Shop() + { + Id = model.Id, + ShopName = model.ShopName, + Address = model.Address, + DateOpen = model.DateOpen, + Capacity = model.Capacity, + DocumentsCount = model.ShopDocuments.ToDictionary(x => x.Key, x => x.Value.Item2) + }; + } + public static Shop? Create(XElement element) + { + if (element == null) + { + return null; + } + return new Shop() + { + Id = Convert.ToInt32(element.Attribute("Id")!.Value), + ShopName = element.Element("ShopName")!.Value, + Address = element.Element("Address")!.Value, + DateOpen = Convert.ToDateTime(element.Element("DateOpening")!.Value), + Capacity = Convert.ToInt32(element.Element("Capacity")!.Value), + DocumentsCount = element.Element("Documents")!.Elements("Document") + .ToDictionary( + x => Convert.ToInt32(x.Element("Key")?.Value), + x => Convert.ToInt32(x.Element("Value")?.Value)) + }; + } + public void Update(ShopBindingModel? model) + { + if (model == null) + { + return; + } + ShopName = model.ShopName; + Address = model.Address; + DateOpen = model.DateOpen; + Capacity = model.Capacity; + DocumentsCount = model.ShopDocuments.ToDictionary(x => x.Key, x => x.Value.Item2); + _documents = null; + + } + public ShopViewModel GetViewModel => new() + { + Id = Id, + ShopName = ShopName, + Address = Address, + DateOpen = DateOpen, + Capacity = Capacity, + ShopDocuments = ShopDocuments + }; + public XElement GetXElement => new("Shop", + new XAttribute("Id", Id), + new XElement("ShopName", ShopName), + new XElement("Address", Address), + new XElement("DateOpening", DateOpen.ToString()), + new XElement("Capacity", Capacity.ToString()), + new XElement("Documents", DocumentsCount.Select(x => + new XElement("Document", + new XElement("Key", x.Key), + new XElement("Value", x.Value))) + .ToArray())); + } +} diff --git a/LawFirm/LawFirmListImplement/DataListSingleton.cs b/LawFirm/LawFirmListImplement/DataListSingleton.cs index d3cd78a..cfaaa5b 100644 --- a/LawFirm/LawFirmListImplement/DataListSingleton.cs +++ b/LawFirm/LawFirmListImplement/DataListSingleton.cs @@ -10,12 +10,15 @@ namespace LawFirmListImplement public List Documents { get; set; } public List Clients { get; set; } + public List Shops { get; set; } + private DataListSingleton() { Blanks = new List(); Orders = new List(); Documents = new List(); Clients = new List(); + Shops = new List(); } public static DataListSingleton GetInstance() { diff --git a/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs b/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs index 6d7f85c..e0cc32b 100644 --- a/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs +++ b/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs @@ -29,13 +29,20 @@ namespace LawFirmListImplement.Implements { 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 || - model.DateFrom <= order.DateCreate && - order.DateCreate <= model.DateTo || - model.ClientId.HasValue && - order.ClientId == model.ClientId) + if (order.Id == model.Id) { result.Add(GetViewModel(order)); } diff --git a/LawFirm/LawFirmListImplement/Implements/ShopStorage.cs b/LawFirm/LawFirmListImplement/Implements/ShopStorage.cs new file mode 100644 index 0000000..c1b39ff --- /dev/null +++ b/LawFirm/LawFirmListImplement/Implements/ShopStorage.cs @@ -0,0 +1,118 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.SearchModels; +using LawFirmContracts.StoragesContracts; +using LawFirmContracts.ViewModels; +using LawFirmDataModels.Models; +using LawFirmListImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LawFirmListImplement.Implements +{ + public class ShopStorage : IShopStorage + { + private readonly DataListSingleton _source; + + public ShopStorage() + { + _source = DataListSingleton.GetInstance(); + } + + public ShopViewModel? GetElement(ShopSearchModel model) + { + if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue) + { + return null; + } + foreach (var shop in _source.Shops) + { + if ((!string.IsNullOrEmpty(model.ShopName) && shop.ShopName == model.ShopName) || (model.Id.HasValue && shop.Id == model.Id)) + { + return shop.GetViewModel; + } + } + return null; + } + + public List GetFilteredList(ShopSearchModel model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.ShopName)) + { + return result; + } + foreach (var shop in _source.Shops) + { + if (shop.ShopName.Contains(model.ShopName)) + { + result.Add(shop.GetViewModel); + } + } + return result; + } + + public List GetFullList() + { + var result = new List(); + foreach (var shop in _source.Shops) + { + result.Add(shop.GetViewModel); + } + return result; + } + + public ShopViewModel? Insert(ShopBindingModel model) + { + model.Id = 1; + foreach (var shop in _source.Shops) + { + if (model.Id <= shop.Id) + { + model.Id = shop.Id + 1; + } + } + var newShop = Shop.Create(model); + if (newShop == null) + { + return null; + } + _source.Shops.Add(newShop); + return newShop.GetViewModel; + } + + public ShopViewModel? Update(ShopBindingModel model) + { + foreach (var shop in _source.Shops) + { + if (shop.Id == model.Id) + { + shop.Update(model); + return shop.GetViewModel; + } + } + return null; + } + + public ShopViewModel? Delete(ShopBindingModel model) + { + for (int i = 0; i < _source.Shops.Count; ++i) + { + if (_source.Shops[i].Id == model.Id) + { + var element = _source.Shops[i]; + _source.Shops.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + + public bool SellDocuments(IDocumentModel model, int count) + { + throw new NotImplementedException(); + } + } +} diff --git a/LawFirm/LawFirmListImplement/Models/Order.cs b/LawFirm/LawFirmListImplement/Models/Order.cs index f7d2f57..de7dfd2 100644 --- a/LawFirm/LawFirmListImplement/Models/Order.cs +++ b/LawFirm/LawFirmListImplement/Models/Order.cs @@ -13,7 +13,7 @@ namespace LawFirmListImplement.Models public int Count { get; private set; } public double Sum { get; private set; } public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; - public DateTime DateCreate { get; private set; } = DateTime.Now; + public DateTime DateCreate { get; private set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc); public DateTime? DateImplement { get; private set; } public static Order? Create(OrderBindingModel? model) { diff --git a/LawFirm/LawFirmListImplement/Models/Shop.cs b/LawFirm/LawFirmListImplement/Models/Shop.cs new file mode 100644 index 0000000..4703cc8 --- /dev/null +++ b/LawFirm/LawFirmListImplement/Models/Shop.cs @@ -0,0 +1,59 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.ViewModels; +using LawFirmDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace LawFirmListImplement.Models +{ + public class Shop : IShopModel + { + public string ShopName { get; set; } = string.Empty; + + public string Address { get; set; } = string.Empty; + public DateTime DateOpen { get; set; } + public int Capacity { get; private set; } + public int Id { get; set; } + public Dictionary ShopDocuments { get; private set; } = new Dictionary(); + + public static Shop? Create(ShopBindingModel? model) + { + if (model == null) + { + return null; + } + return new Shop() + { + Id = model.Id, + ShopName = model.ShopName, + Address = model.Address, + DateOpen = model.DateOpen, + ShopDocuments = model.ShopDocuments + }; + } + + public void Update(ShopBindingModel? model) + { + if (model == null) + { + return; + } + ShopName = model.ShopName; + Address = model.Address; + DateOpen = model.DateOpen; + ShopDocuments = model.ShopDocuments; + } + + public ShopViewModel GetViewModel => new() + { + Id = Id, + ShopName = ShopName, + Address = Address, + DateOpen = DateOpen, + ShopDocuments = ShopDocuments + }; + } +} diff --git a/LawFirm/LawFirmView/FormAddDocument.Designer.cs b/LawFirm/LawFirmView/FormAddDocument.Designer.cs new file mode 100644 index 0000000..c2e9891 --- /dev/null +++ b/LawFirm/LawFirmView/FormAddDocument.Designer.cs @@ -0,0 +1,151 @@ +namespace LawFirmView +{ + partial class FormAddDocument + { + /// + /// 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.labelShop = new System.Windows.Forms.Label(); + this.labelDocument = new System.Windows.Forms.Label(); + this.labelCount = new System.Windows.Forms.Label(); + this.comboBoxShop = new System.Windows.Forms.ComboBox(); + this.comboBoxDocument = new System.Windows.Forms.ComboBox(); + this.numericUpDownCount = new System.Windows.Forms.NumericUpDown(); + this.ButtonSave = new System.Windows.Forms.Button(); + this.ButtonCancel = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).BeginInit(); + this.SuspendLayout(); + // + // labelShop + // + this.labelShop.AutoSize = true; + this.labelShop.Location = new System.Drawing.Point(10, 23); + this.labelShop.Name = "labelShop"; + this.labelShop.Size = new System.Drawing.Size(54, 15); + this.labelShop.TabIndex = 0; + this.labelShop.Text = "Магазин"; + // + // labelDocument + // + this.labelDocument.AutoSize = true; + this.labelDocument.Location = new System.Drawing.Point(10, 57); + this.labelDocument.Name = "labelDocument"; + this.labelDocument.Size = new System.Drawing.Size(61, 15); + this.labelDocument.TabIndex = 1; + this.labelDocument.Text = "Документ"; + // + // labelCount + // + this.labelCount.AutoSize = true; + this.labelCount.Location = new System.Drawing.Point(10, 95); + this.labelCount.Name = "labelCount"; + this.labelCount.Size = new System.Drawing.Size(72, 15); + this.labelCount.TabIndex = 2; + this.labelCount.Text = "Количество"; + // + // comboBoxShop + // + this.comboBoxShop.FormattingEnabled = true; + this.comboBoxShop.Location = new System.Drawing.Point(97, 23); + this.comboBoxShop.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.comboBoxShop.Name = "comboBoxShop"; + this.comboBoxShop.Size = new System.Drawing.Size(323, 23); + this.comboBoxShop.TabIndex = 3; + // + // comboBoxDocument + // + this.comboBoxDocument.FormattingEnabled = true; + this.comboBoxDocument.Location = new System.Drawing.Point(97, 57); + this.comboBoxDocument.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.comboBoxDocument.Name = "comboBoxDocument"; + this.comboBoxDocument.Size = new System.Drawing.Size(323, 23); + this.comboBoxDocument.TabIndex = 4; + // + // numericUpDownCount + // + this.numericUpDownCount.Location = new System.Drawing.Point(97, 90); + this.numericUpDownCount.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.numericUpDownCount.Name = "numericUpDownCount"; + this.numericUpDownCount.Size = new System.Drawing.Size(323, 23); + this.numericUpDownCount.TabIndex = 5; + // + // ButtonSave + // + this.ButtonSave.Location = new System.Drawing.Point(244, 125); + this.ButtonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.ButtonSave.Name = "ButtonSave"; + this.ButtonSave.Size = new System.Drawing.Size(82, 22); + this.ButtonSave.TabIndex = 6; + this.ButtonSave.Text = "Сохранить"; + this.ButtonSave.UseVisualStyleBackColor = true; + this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // ButtonCancel + // + this.ButtonCancel.Location = new System.Drawing.Point(338, 125); + this.ButtonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.ButtonCancel.Name = "ButtonCancel"; + this.ButtonCancel.Size = new System.Drawing.Size(82, 22); + this.ButtonCancel.TabIndex = 7; + this.ButtonCancel.Text = "Отмена"; + this.ButtonCancel.UseVisualStyleBackColor = true; + this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // FormAddDocument + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(430, 155); + this.Controls.Add(this.ButtonCancel); + this.Controls.Add(this.ButtonSave); + this.Controls.Add(this.numericUpDownCount); + this.Controls.Add(this.comboBoxDocument); + this.Controls.Add(this.comboBoxShop); + this.Controls.Add(this.labelCount); + this.Controls.Add(this.labelDocument); + this.Controls.Add(this.labelShop); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.Name = "FormAddDocument"; + this.Text = "Добавление документа"; + this.Load += new System.EventHandler(this.FormAddDocument_Load); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Label labelShop; + private Label labelDocument; + private Label labelCount; + private ComboBox comboBoxShop; + private ComboBox comboBoxDocument; + private NumericUpDown numericUpDownCount; + private Button ButtonSave; + private Button ButtonCancel; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormAddDocument.cs b/LawFirm/LawFirmView/FormAddDocument.cs new file mode 100644 index 0000000..10ad81f --- /dev/null +++ b/LawFirm/LawFirmView/FormAddDocument.cs @@ -0,0 +1,108 @@ +using Microsoft.Extensions.Logging; +using LawFirmContracts.BusinessLogicsContracts; +using LawFirmContracts.SearchModels; + +namespace LawFirmView +{ + public partial class FormAddDocument : Form + { + private readonly ILogger _logger; + private readonly IDocumentLogic _logicDocument; + private readonly IShopLogic _logicShop; + public FormAddDocument(ILogger logger, IDocumentLogic logicDocument, IShopLogic logicShop) + { + InitializeComponent(); + _logger = logger; + _logicDocument = logicDocument; + _logicShop = logicShop; + } + + private void FormAddDocument_Load(object sender, EventArgs e) + { + _logger.LogInformation("Загрузка списка документов для пополнения"); + try + { + var list = _logicDocument.ReadList(null); + if (list != null) + { + comboBoxDocument.DisplayMember = "DocumentName"; + comboBoxDocument.ValueMember = "Id"; + comboBoxDocument.DataSource = list; + comboBoxDocument.SelectedItem = null; + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка документов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + _logger.LogInformation("Загрузка списка магазинов для пополнения"); + try + { + var list = _logicShop.ReadList(null); + if (list != null) + { + comboBoxShop.DisplayMember = "ShopName"; + comboBoxShop.ValueMember = "Id"; + comboBoxShop.DataSource = list; + comboBoxShop.SelectedItem = null; + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка магазинов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(numericUpDownCount.Text)) + { + MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxDocument.SelectedValue == null) + { + MessageBox.Show("Выберите документ", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxShop.SelectedValue == null) + { + MessageBox.Show("Выберите магазин", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Пополнение магазина"); + try + { + var operationResult = _logicShop.AddDocument(new ShopSearchModel + { + Id = Convert.ToInt32(comboBoxShop.SelectedValue) + }, + _logicDocument.ReadElement(new DocumentSearchModel() + { + Id = Convert.ToInt32(comboBoxDocument.SelectedValue) + })!, Convert.ToInt32(numericUpDownCount.Text)); + if (!operationResult) + { + throw new Exception("Ошибка при пополнении магазина. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка создания заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/LawFirm/LawFirmView/FormAddDocument.resx b/LawFirm/LawFirmView/FormAddDocument.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/LawFirm/LawFirmView/FormAddDocument.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file 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 3db9a21..f11ceb8 100644 --- a/LawFirm/LawFirmView/FormMain.Designer.cs +++ b/LawFirm/LawFirmView/FormMain.Designer.cs @@ -28,201 +28,275 @@ /// private void InitializeComponent() { - 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.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.menuStrip1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); - this.SuspendLayout(); - // - // menuStrip1 - // - this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.справочникиToolStripMenuItem, + 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.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.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.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.Text = "menuStrip1"; - // - // справочники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 = "Справочники"; - // - // бланкиToolStripMenuItem - // - this.бланкиToolStripMenuItem.Name = "бланкиToolStripMenuItem"; - this.бланкиToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.бланкиToolStripMenuItem.Text = "Бланки"; - this.бланкиToolStripMenuItem.Click += new System.EventHandler(this.BlanksToolStripMenuItem_Click); - // - // документыToolStripMenuItem - // - this.документыToolStripMenuItem.Name = "документыToolStripMenuItem"; - this.документыToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.документыToolStripMenuItem.Text = "Документы"; - this.документыToolStripMenuItem.Click += new System.EventHandler(this.DocumentsToolStripMenuItem_Click); - // - // клиентыToolStripMenuItem - // - this.клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem"; - this.клиентыToolStripMenuItem.Size = new System.Drawing.Size(180, 22); - this.клиентыToolStripMenuItem.Text = "Клиенты"; - this.клиентыToolStripMenuItem.Click += new System.EventHandler(this.ClientsToolStripMenuItem_Click); - // - // отчеты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(60, 20); - this.отчетыToolStripMenuItem.Text = "Отчеты"; - // - // списокКомпонентовToolStripMenuItem - // - this.списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem"; - this.списокКомпонентовToolStripMenuItem.Size = new System.Drawing.Size(218, 22); - this.списокКомпонентовToolStripMenuItem.Text = "Список компонентов"; - this.списокКомпонентовToolStripMenuItem.Click += new System.EventHandler(this.DocumentsReportToolStripMenuItem_Click); - // - // компонентыПоИзделиямToolStripMenuItem - // - this.компонентыПоИзделиямToolStripMenuItem.Name = "компонентыПоИзделиямToolStripMenuItem"; - this.компонентыПоИзделиямToolStripMenuItem.Size = new System.Drawing.Size(218, 22); - this.компонентыПоИзделиямToolStripMenuItem.Text = "Компоненты по изделиям"; - this.компонентыПоИзделиямToolStripMenuItem.Click += new System.EventHandler(this.DocumentBlanksReportToolStripMenuItem_Click); - // - // списокЗаказовToolStripMenuItem - // - this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; - this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(218, 22); - this.списокЗаказовToolStripMenuItem.Text = "Список заказов"; - this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.OrdersReportToolStripMenuItem_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.Name = "dataGridView"; - this.dataGridView.ReadOnly = true; - this.dataGridView.RowTemplate.Height = 25; - this.dataGridView.Size = new System.Drawing.Size(566, 411); - this.dataGridView.TabIndex = 1; - // - // buttonCreateOrder - // - 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); - // - // buttonTakeOrderInWork - // - 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); - // - // 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.buttonUpdate); - this.Controls.Add(this.buttonIssuedOrder); - this.Controls.Add(this.buttonOrderReady); - this.Controls.Add(this.buttonTakeOrderInWork); - this.Controls.Add(this.buttonCreateOrder); - this.Controls.Add(this.dataGridView); - this.Controls.Add(this.menuStrip1); - this.MainMenuStrip = this.menuStrip1; - this.Name = "FormMain"; - this.Text = "Юридическая фирма"; - this.Load += new System.EventHandler(this.FormMain_Load); - this.menuStrip1.ResumeLayout(false); - this.menuStrip1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); + this.menuStrip1.Location = new System.Drawing.Point(0, 0); + this.menuStrip1.Name = "menuStrip1"; + 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 + // + 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 + // + 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.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.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.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + 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.RowHeadersWidth = 51; + this.dataGridView.RowTemplate.Height = 29; + this.dataGridView.Size = new System.Drawing.Size(816, 332); + this.dataGridView.TabIndex = 6; + // + // ButtonAddDocument + // + 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); + // + // ButtonSellDocument + // + 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(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 = "LawFirm"; + this.Load += new System.EventHandler(this.FormMain_Load); + this.menuStrip1.ResumeLayout(false); + this.menuStrip1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); } #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 ToolStripMenuItem списокКомпонентовToolStripMenuItem; private ToolStripMenuItem компонентыПоИзделиямToolStripMenuItem; private ToolStripMenuItem списокЗаказовToolStripMenuItem; 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 17877f7..69f3bd9 100644 --- a/LawFirm/LawFirmView/FormMain.cs +++ b/LawFirm/LawFirmView/FormMain.cs @@ -1,8 +1,15 @@ -using LawFirmBusinessLogic.BusinessLogics; +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 @@ -12,14 +19,15 @@ namespace LawFirmView private readonly ILogger _logger; private readonly IOrderLogic _orderLogic; private readonly IReportLogic _reportLogic; - - public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic) + public FormMain(ILogger logger, IOrderLogic orderLogic,IReportLogic reportlogic) { InitializeComponent(); _logger = logger; _orderLogic = orderLogic; - _reportLogic = reportLogic; + _reportLogic = reportlogic; + } + private void FormMain_Load(object sender, EventArgs e) { LoadData(); @@ -36,7 +44,7 @@ namespace LawFirmView dataGridView.Columns["DocumentId"].Visible = false; dataGridView.Columns["ClientId"].Visible = false; } - _logger.LogInformation("Загрузка прошла успешно"); + _logger.LogInformation("Загрузка заказов"); } catch (Exception ex) { @@ -44,6 +52,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)); @@ -53,6 +80,7 @@ namespace LawFirmView LoadData(); } } + private void ButtonTakeOrderInWork_Click(object sender, EventArgs e) { if (dataGridView.SelectedRows.Count == 1) @@ -61,14 +89,7 @@ namespace LawFirmView _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); try { - var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel{ - Id = id, - DocumentId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["DocumentId"].Value), - Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), - Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), - Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), - DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()) - }); + var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id}); if (!operationResult) { throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); @@ -78,11 +99,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) @@ -91,18 +113,10 @@ namespace LawFirmView _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); try { - var operationResult = _orderLogic.FinishOrder(new OrderBindingModel - { - Id = id, - DocumentId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["DocumentId"].Value), - Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), - Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), - Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), - DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()) - }); + var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id }); if (!operationResult) { - throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + throw new Exception("Ошибка при сохранении.Дополнительная информация в логах."); } LoadData(); } @@ -113,25 +127,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, - DocumentId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["DocumentId"].Value), - Status = Enum.Parse(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()), - Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value), - Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()), - DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()) - }); + var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id}); if (!operationResult) { throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); @@ -142,65 +147,101 @@ 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) - { - form.ShowDialog(); - } - } - private void DocumentsReportToolStripMenuItem_Click(object sender, EventArgs -e) + private void DocumentsToolStripMenuItem_Click(object sender, EventArgs e) { 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); + _reportLogic.SaveBlanksToWordFile(new ReportBindingModel { FileName = dialog.FileName }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); } } - private void DocumentBlanksReportToolStripMenuItem_Click(object sender, - EventArgs e) + + private void documentBlanksToolStripMenuItem_Click(object sender, EventArgs e) { - var service = - Program.ServiceProvider?.GetService(typeof(FormReportDocumentBlanks)); + var service = Program.ServiceProvider?.GetService(typeof(FormReportDocumentBlanks)); if (service is FormReportDocumentBlanks form) { form.ShowDialog(); } } - private void OrdersReportToolStripMenuItem_Click(object sender, EventArgs e) + + private void ordersToolStripMenuItem_Click(object sender, EventArgs e) { - var service = - Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + 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) + { + form.ShowDialog(); + } + } + + private void ButtonAddDocument_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormAddDocument)); + if (service is FormAddDocument 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); + } + } private void ClientsToolStripMenuItem_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormViewClients)); diff --git a/LawFirm/LawFirmView/FormReportGroupedOrders.Designer.cs b/LawFirm/LawFirmView/FormReportGroupedOrders.Designer.cs new file mode 100644 index 0000000..cbccadd --- /dev/null +++ b/LawFirm/LawFirmView/FormReportGroupedOrders.Designer.cs @@ -0,0 +1,86 @@ +namespace LawFirmView +{ + partial class FormReportGroupedOrders + { + /// + /// 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.panel = new System.Windows.Forms.Panel(); + this.buttonToPdf = new System.Windows.Forms.Button(); + this.buttonMake = new System.Windows.Forms.Button(); + this.panel.SuspendLayout(); + this.SuspendLayout(); + // + // panel + // + this.panel.Controls.Add(this.buttonToPdf); + this.panel.Controls.Add(this.buttonMake); + this.panel.Dock = System.Windows.Forms.DockStyle.Top; + this.panel.Location = new System.Drawing.Point(0, 0); + this.panel.Name = "panel"; + this.panel.Size = new System.Drawing.Size(800, 44); + this.panel.TabIndex = 0; + // + // buttonToPdf + // + this.buttonToPdf.Location = new System.Drawing.Point(171, 12); + this.buttonToPdf.Name = "buttonToPdf"; + this.buttonToPdf.Size = new System.Drawing.Size(160, 29); + this.buttonToPdf.TabIndex = 1; + this.buttonToPdf.Text = "Сохранить в pdf"; + this.buttonToPdf.UseVisualStyleBackColor = true; + this.buttonToPdf.Click += new System.EventHandler(this.ButtonToPdf_Click); + // + // buttonMake + // + this.buttonMake.Location = new System.Drawing.Point(12, 12); + this.buttonMake.Name = "buttonMake"; + this.buttonMake.Size = new System.Drawing.Size(141, 29); + this.buttonMake.TabIndex = 0; + this.buttonMake.Text = "Сформировать"; + this.buttonMake.UseVisualStyleBackColor = true; + this.buttonMake.Click += new System.EventHandler(this.ButtonMake_Click); + // + // FormReportGroupedOrders + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.panel); + this.Name = "FormReportGroupedOrders"; + this.Text = "Заказы по дате"; + this.panel.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private Panel panel; + private Button buttonMake; + private Button buttonToPdf; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormReportGroupedOrders.cs b/LawFirm/LawFirmView/FormReportGroupedOrders.cs new file mode 100644 index 0000000..bbce8cd --- /dev/null +++ b/LawFirm/LawFirmView/FormReportGroupedOrders.cs @@ -0,0 +1,81 @@ +using Microsoft.Extensions.Logging; +using Microsoft.Reporting.WinForms; +using LawFirmContracts.BindingModels; +using LawFirmContracts.BusinessLogicsContracts; +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 +{ + public partial class FormReportGroupedOrders : Form + { + private readonly ReportViewer reportViewer; + + private readonly ILogger _logger; + + private readonly IReportLogic _logic; + + public FormReportGroupedOrders(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + reportViewer = new ReportViewer + { + Dock = DockStyle.Fill + }; + reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportGroupedOrders.rdlc", FileMode.Open)); + Controls.Clear(); + Controls.Add(reportViewer); + Controls.Add(panel); + } + + private void ButtonMake_Click(object sender, EventArgs e) + { + try + { + var dataSource = _logic.GetGroupedByDateOrders(); + var source = new ReportDataSource("DataSetOrders", dataSource); + reportViewer.LocalReport.DataSources.Clear(); + reportViewer.LocalReport.DataSources.Add(source); + + reportViewer.RefreshReport(); + _logger.LogInformation("Загрузка списка заказов сгрупированных по дате"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка заказов сгрупированных по дате"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonToPdf_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + _logic.SaveGroupedByDateOrders(new ReportBindingModel + { + FileName = dialog.FileName, + }); + _logger.LogInformation("Сохранение списка заказов сгрупированных по дате"); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения списка заказов сгрупированных по дате"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } +} diff --git a/LawFirm/LawFirmView/FormReportGroupedOrders.resx b/LawFirm/LawFirmView/FormReportGroupedOrders.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/LawFirm/LawFirmView/FormReportGroupedOrders.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormReportShopDocuments.Designer.cs b/LawFirm/LawFirmView/FormReportShopDocuments.Designer.cs new file mode 100644 index 0000000..5864870 --- /dev/null +++ b/LawFirm/LawFirmView/FormReportShopDocuments.Designer.cs @@ -0,0 +1,108 @@ +namespace LawFirmView +{ + partial class FormReportShopDocuments + { + /// + /// 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.ShopColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.DocumentColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.CountColumn = 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(145, 29); + this.ButtonSaveToExcel.TabIndex = 0; + this.ButtonSaveToExcel.Text = "Сохранить в excel"; + this.ButtonSaveToExcel.UseVisualStyleBackColor = true; + this.ButtonSaveToExcel.Click += new System.EventHandler(this.ButtonSaveToExcel_Click); + // + // dataGridView + // + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.ShopColumn, + this.DocumentColumn, + this.CountColumn}); + this.dataGridView.Dock = System.Windows.Forms.DockStyle.Bottom; + this.dataGridView.Location = new System.Drawing.Point(0, 64); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowHeadersWidth = 51; + this.dataGridView.RowTemplate.Height = 29; + this.dataGridView.Size = new System.Drawing.Size(504, 417); + this.dataGridView.TabIndex = 1; + // + // ShopColumn + // + this.ShopColumn.HeaderText = "Магазин"; + this.ShopColumn.MinimumWidth = 6; + this.ShopColumn.Name = "ShopColumn"; + this.ShopColumn.Width = 125; + // + // DocumentColumn + // + this.DocumentColumn.HeaderText = "Документ"; + this.DocumentColumn.MinimumWidth = 6; + this.DocumentColumn.Name = "DocumentColumn"; + this.DocumentColumn.Width = 125; + // + // CountColumn + // + this.CountColumn.HeaderText = "Количество"; + this.CountColumn.MinimumWidth = 6; + this.CountColumn.Name = "CountColumn"; + this.CountColumn.Width = 125; + // + // FormReportShopDocuments + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(504, 481); + this.Controls.Add(this.dataGridView); + this.Controls.Add(this.ButtonSaveToExcel); + this.Name = "FormReportShopDocuments"; + this.Text = "Магазины и документы"; + this.Load += new System.EventHandler(this.FormReportShopDocuments_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private Button ButtonSaveToExcel; + private DataGridView dataGridView; + private DataGridViewTextBoxColumn ShopColumn; + private DataGridViewTextBoxColumn DocumentColumn; + private DataGridViewTextBoxColumn CountColumn; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormReportShopDocuments.cs b/LawFirm/LawFirmView/FormReportShopDocuments.cs new file mode 100644 index 0000000..25a5c58 --- /dev/null +++ b/LawFirm/LawFirmView/FormReportShopDocuments.cs @@ -0,0 +1,79 @@ +using Microsoft.Extensions.Logging; +using LawFirmContracts.BindingModels; +using LawFirmContracts.BusinessLogicsContracts; +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 +{ + public partial class FormReportShopDocuments : Form + { + private readonly ILogger _logger; + + private readonly IReportLogic _logic; + + public FormReportShopDocuments(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormReportShopDocuments_Load(object sender, EventArgs e) + { + try + { + var dict = _logic.GetShopDocuments(); + if (dict != null) + { + dataGridView.Rows.Clear(); + foreach (var elem in dict) + { + dataGridView.Rows.Add(new object[] { elem.ShopName, "", "" }); + foreach (var listElem in elem.Documents) + { + dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 }); + } + dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount }); + dataGridView.Rows.Add(Array.Empty()); + } + } + _logger.LogInformation("Загрузка списка загруженности магазина"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка загруженности магазина"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonSaveToExcel_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + _logic.SaveShopDocumentToExcelFile(new ReportBindingModel + { + FileName = dialog.FileName + }); + _logger.LogInformation("Сохранение списка загруженности магазина"); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения списка загруженности магазина"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } +} diff --git a/LawFirm/LawFirmView/FormReportShopDocuments.resx b/LawFirm/LawFirmView/FormReportShopDocuments.resx new file mode 100644 index 0000000..8c7ffcf --- /dev/null +++ b/LawFirm/LawFirmView/FormReportShopDocuments.resx @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + + True + + + True + + + True + + \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormSellDocuments.Designer.cs b/LawFirm/LawFirmView/FormSellDocuments.Designer.cs new file mode 100644 index 0000000..898d107 --- /dev/null +++ b/LawFirm/LawFirmView/FormSellDocuments.Designer.cs @@ -0,0 +1,120 @@ +namespace LawFirmView +{ + partial class FormSellDocuments + { + /// + /// 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.ButtonCancel = new System.Windows.Forms.Button(); + this.comboBoxDocuments = new System.Windows.Forms.ComboBox(); + this.numericUpDownCount = new System.Windows.Forms.NumericUpDown(); + this.labelDocument = new System.Windows.Forms.Label(); + this.labelCount = new System.Windows.Forms.Label(); + this.ButtonSave = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).BeginInit(); + this.SuspendLayout(); + // + // ButtonCancel + // + this.ButtonCancel.Location = new System.Drawing.Point(266, 153); + this.ButtonCancel.Name = "ButtonCancel"; + this.ButtonCancel.Size = new System.Drawing.Size(94, 29); + this.ButtonCancel.TabIndex = 1; + this.ButtonCancel.Text = "Отмена"; + this.ButtonCancel.UseVisualStyleBackColor = true; + this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // comboBoxDocuments + // + this.comboBoxDocuments.FormattingEnabled = true; + this.comboBoxDocuments.Location = new System.Drawing.Point(144, 38); + this.comboBoxDocuments.Name = "comboBoxDocuments"; + this.comboBoxDocuments.Size = new System.Drawing.Size(216, 28); + this.comboBoxDocuments.TabIndex = 2; + // + // numericUpDownCount + // + this.numericUpDownCount.Location = new System.Drawing.Point(144, 102); + this.numericUpDownCount.Name = "numericUpDownCount"; + this.numericUpDownCount.Size = new System.Drawing.Size(216, 27); + this.numericUpDownCount.TabIndex = 3; + // + // labelDocument + // + this.labelDocument.AutoSize = true; + this.labelDocument.Location = new System.Drawing.Point(34, 38); + this.labelDocument.Name = "labelDocument"; + this.labelDocument.Size = new System.Drawing.Size(69, 20); + this.labelDocument.TabIndex = 4; + this.labelDocument.Text = "Документ"; + // + // labelCount + // + this.labelCount.AutoSize = true; + this.labelCount.Location = new System.Drawing.Point(34, 109); + this.labelCount.Name = "labelCount"; + this.labelCount.Size = new System.Drawing.Size(90, 20); + this.labelCount.TabIndex = 5; + this.labelCount.Text = "Количество"; + // + // ButtonSave + // + this.ButtonSave.Location = new System.Drawing.Point(144, 153); + this.ButtonSave.Name = "ButtonSave"; + this.ButtonSave.Size = new System.Drawing.Size(94, 29); + this.ButtonSave.TabIndex = 6; + this.ButtonSave.Text = "Сохранить"; + this.ButtonSave.UseVisualStyleBackColor = true; + this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // FormSellDocuments + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(373, 194); + this.Controls.Add(this.ButtonSave); + this.Controls.Add(this.labelCount); + this.Controls.Add(this.labelDocument); + this.Controls.Add(this.numericUpDownCount); + this.Controls.Add(this.comboBoxDocuments); + this.Controls.Add(this.ButtonCancel); + this.Name = "FormSellDocuments"; + this.Text = "Продажа документов"; + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownCount)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + private Button ButtonCancel; + private ComboBox comboBoxDocuments; + private NumericUpDown numericUpDownCount; + private Label labelDocument; + private Label labelCount; + private Button ButtonSave; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormSellDocuments.cs b/LawFirm/LawFirmView/FormSellDocuments.cs new file mode 100644 index 0000000..7934bb8 --- /dev/null +++ b/LawFirm/LawFirmView/FormSellDocuments.cs @@ -0,0 +1,86 @@ +using Microsoft.Extensions.Logging; +using LawFirmContracts.BusinessLogicsContracts; +using LawFirmContracts.ViewModels; +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 +{ + public partial class FormSellDocuments : Form + { + private readonly ILogger _logger; + private readonly IShopLogic _shopLogic; + private readonly IDocumentLogic _documentLogic; + private readonly List? _listDocument; + public FormSellDocuments(ILogger logger, IShopLogic shopLogic, IDocumentLogic documentLogic) + { + InitializeComponent(); + _logger = logger; + _shopLogic = shopLogic; + _documentLogic = documentLogic; + _listDocument = documentLogic.ReadList(null); + if (_listDocument != null) + { + comboBoxDocuments.DisplayMember = "DocumentName"; + comboBoxDocuments.ValueMember = "Id"; + comboBoxDocuments.DataSource=_listDocument; + comboBoxDocuments.SelectedItem = null; + } + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + if (comboBoxDocuments.SelectedValue == null) + { + MessageBox.Show("Выберите документ", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(numericUpDownCount.Text)) + { + MessageBox.Show("Заполните количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Продажа документов"); + try + { + var document = _documentLogic.ReadElement(new() + { + Id = (int)comboBoxDocuments.SelectedValue + }); + if (document == null) + { + throw new Exception("Документ не найден. Дополнительная информация в логах."); + } + var operationResult = _shopLogic.SellDocuments( + model: document, + count: (int)numericUpDownCount.Value + ); + if (!operationResult) + { + throw new Exception("Ошибка при продаже документа. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения документа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/LawFirm/LawFirmView/FormSellDocuments.resx b/LawFirm/LawFirmView/FormSellDocuments.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/LawFirm/LawFirmView/FormSellDocuments.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormShop.Designer.cs b/LawFirm/LawFirmView/FormShop.Designer.cs new file mode 100644 index 0000000..aaa3e36 --- /dev/null +++ b/LawFirm/LawFirmView/FormShop.Designer.cs @@ -0,0 +1,219 @@ +namespace LawFirmView +{ + partial class FormShop + { + /// + /// 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.labelShop = new System.Windows.Forms.Label(); + this.labelAddress = new System.Windows.Forms.Label(); + this.labelDate = new System.Windows.Forms.Label(); + this.textBoxName = new System.Windows.Forms.TextBox(); + this.textBoxAddress = new System.Windows.Forms.TextBox(); + this.dateTimePickerDateOpen = new System.Windows.Forms.DateTimePicker(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.ID = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.DocumentName = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ButtonSave = new System.Windows.Forms.Button(); + this.ButtonCancel = new System.Windows.Forms.Button(); + this.numericUpDownCapacity = new System.Windows.Forms.NumericUpDown(); + this.labelCapacity = new System.Windows.Forms.Label(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownCapacity)).BeginInit(); + this.SuspendLayout(); + // + // labelShop + // + this.labelShop.AutoSize = true; + this.labelShop.Location = new System.Drawing.Point(10, 16); + this.labelShop.Name = "labelShop"; + this.labelShop.Size = new System.Drawing.Size(54, 15); + this.labelShop.TabIndex = 0; + this.labelShop.Text = "Магазин"; + // + // labelAddress + // + this.labelAddress.AutoSize = true; + this.labelAddress.Location = new System.Drawing.Point(156, 16); + this.labelAddress.Name = "labelAddress"; + this.labelAddress.Size = new System.Drawing.Size(40, 15); + this.labelAddress.TabIndex = 1; + this.labelAddress.Text = "Адрес"; + // + // labelDate + // + this.labelDate.AutoSize = true; + this.labelDate.Location = new System.Drawing.Point(375, 16); + this.labelDate.Name = "labelDate"; + this.labelDate.Size = new System.Drawing.Size(87, 15); + this.labelDate.TabIndex = 2; + this.labelDate.Text = "Дата открытия"; + // + // textBoxName + // + this.textBoxName.Location = new System.Drawing.Point(10, 33); + this.textBoxName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.textBoxName.Name = "textBoxName"; + this.textBoxName.Size = new System.Drawing.Size(140, 23); + this.textBoxName.TabIndex = 3; + // + // textBoxAddress + // + this.textBoxAddress.Location = new System.Drawing.Point(156, 33); + this.textBoxAddress.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.textBoxAddress.Name = "textBoxAddress"; + this.textBoxAddress.Size = new System.Drawing.Size(216, 23); + this.textBoxAddress.TabIndex = 4; + // + // dateTimePickerDateOpen + // + this.dateTimePickerDateOpen.Location = new System.Drawing.Point(375, 33); + this.dateTimePickerDateOpen.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.dateTimePickerDateOpen.Name = "dateTimePickerDateOpen"; + this.dateTimePickerDateOpen.Size = new System.Drawing.Size(123, 23); + this.dateTimePickerDateOpen.TabIndex = 5; + // + // dataGridView + // + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.ID, + this.DocumentName, + this.Count}); + this.dataGridView.Location = new System.Drawing.Point(10, 58); + this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowHeadersWidth = 51; + this.dataGridView.RowTemplate.Height = 29; + this.dataGridView.Size = new System.Drawing.Size(623, 248); + this.dataGridView.TabIndex = 6; + // + // ID + // + this.ID.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.ID.HeaderText = "ID"; + this.ID.MinimumWidth = 6; + this.ID.Name = "ID"; + this.ID.Visible = false; + // + // DocumentName + // + this.DocumentName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.DocumentName.HeaderText = "DocumentName"; + this.DocumentName.MinimumWidth = 6; + this.DocumentName.Name = "DocumentName"; + // + // Count + // + this.Count.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.Count.HeaderText = "Count"; + this.Count.MinimumWidth = 6; + this.Count.Name = "Count"; + // + // ButtonSave + // + this.ButtonSave.Location = new System.Drawing.Point(429, 310); + this.ButtonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.ButtonSave.Name = "ButtonSave"; + this.ButtonSave.Size = new System.Drawing.Size(97, 22); + this.ButtonSave.TabIndex = 7; + this.ButtonSave.Text = "Сохранить"; + this.ButtonSave.UseVisualStyleBackColor = true; + this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // ButtonCancel + // + this.ButtonCancel.Location = new System.Drawing.Point(551, 310); + this.ButtonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.ButtonCancel.Name = "ButtonCancel"; + this.ButtonCancel.Size = new System.Drawing.Size(82, 22); + this.ButtonCancel.TabIndex = 8; + this.ButtonCancel.Text = "Отмена"; + this.ButtonCancel.UseVisualStyleBackColor = true; + this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // numericUpDownCapacity + // + this.numericUpDownCapacity.Location = new System.Drawing.Point(504, 33); + this.numericUpDownCapacity.Name = "numericUpDownCapacity"; + this.numericUpDownCapacity.Size = new System.Drawing.Size(120, 23); + this.numericUpDownCapacity.TabIndex = 9; + // + // labelCapacity + // + this.labelCapacity.AutoSize = true; + this.labelCapacity.Location = new System.Drawing.Point(504, 16); + this.labelCapacity.Name = "labelCapacity"; + this.labelCapacity.Size = new System.Drawing.Size(134, 15); + this.labelCapacity.TabIndex = 10; + this.labelCapacity.Text = "Вместимость магазина"; + // + // FormShop + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(648, 338); + this.Controls.Add(this.labelCapacity); + this.Controls.Add(this.numericUpDownCapacity); + this.Controls.Add(this.ButtonCancel); + this.Controls.Add(this.ButtonSave); + this.Controls.Add(this.dataGridView); + this.Controls.Add(this.dateTimePickerDateOpen); + this.Controls.Add(this.textBoxAddress); + this.Controls.Add(this.textBoxName); + this.Controls.Add(this.labelDate); + this.Controls.Add(this.labelAddress); + this.Controls.Add(this.labelShop); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.Name = "FormShop"; + this.Text = "Магазин"; + this.Load += new System.EventHandler(this.FormShop_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.numericUpDownCapacity)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Label labelShop; + private Label labelAddress; + private Label labelDate; + private TextBox textBoxName; + private TextBox textBoxAddress; + private DateTimePicker dateTimePickerDateOpen; + private DataGridView dataGridView; + private Button ButtonSave; + private Button ButtonCancel; + private DataGridViewTextBoxColumn ID; + private DataGridViewTextBoxColumn DocumentName; + private DataGridViewTextBoxColumn Count; + private NumericUpDown numericUpDownCapacity; + private Label labelCapacity; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormShop.cs b/LawFirm/LawFirmView/FormShop.cs new file mode 100644 index 0000000..1414e03 --- /dev/null +++ b/LawFirm/LawFirmView/FormShop.cs @@ -0,0 +1,124 @@ +using LawFirmContracts.BusinessLogicsContracts; +using LawFirmContracts.SearchModels; +using LawFirmDataModels.Models; +using Microsoft.Extensions.Logging; +using LawFirmContracts.BindingModels; + +namespace LawFirmView +{ + public partial class FormShop : Form + { + private readonly ILogger _logger; + private readonly IShopLogic _logic; + private int? _id; + private Dictionary _shopDocuments; + public int Id { set { _id = value; } } + public FormShop(ILogger logger, IShopLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + _shopDocuments = new Dictionary(); + } + + private void FormShop_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + _logger.LogInformation("Загрузка магазина"); + try + { + var view = _logic.ReadElement(new ShopSearchModel + { + Id = _id.Value + }); + if (view != null) + { + textBoxName.Text = view.ShopName; + textBoxAddress.Text = view.Address.ToString(); + dateTimePickerDateOpen.Text = view.DateOpen.ToString(); + numericUpDownCapacity.Value = view.Capacity; + _shopDocuments = view.ShopDocuments ?? new Dictionary(); + LoadData(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки магазина"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void LoadData() + { + _logger.LogInformation("Загрузка документов магазина"); + try + { + if (_shopDocuments != null) + { + dataGridView.Rows.Clear(); + foreach (var element in _shopDocuments) + { + dataGridView.Rows.Add(new object[] { element.Key, element.Value.Item1.DocumentName, element.Value.Item2 }); + } + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки документов магазина"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(textBoxAddress.Text)) + { + MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(dateTimePickerDateOpen.Text)) + { + MessageBox.Show("Заполните дату", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение магазина"); + try + { + var model = new ShopBindingModel + { + Id = _id ?? 0, + ShopName = textBoxName.Text, + Address = textBoxAddress.Text, + DateOpen = DateTime.SpecifyKind(DateTime.Parse(dateTimePickerDateOpen.Text), DateTimeKind.Utc), + Capacity = (int)numericUpDownCapacity.Value, + ShopDocuments = _shopDocuments + }; + var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information); + DialogResult = DialogResult.OK; + Close(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения магазина"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/LawFirm/LawFirmView/FormShop.resx b/LawFirm/LawFirmView/FormShop.resx new file mode 100644 index 0000000..c9ecac1 --- /dev/null +++ b/LawFirm/LawFirmView/FormShop.resx @@ -0,0 +1,69 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormShops.Designer.cs b/LawFirm/LawFirmView/FormShops.Designer.cs new file mode 100644 index 0000000..0dd8b7e --- /dev/null +++ b/LawFirm/LawFirmView/FormShops.Designer.cs @@ -0,0 +1,123 @@ +namespace LawFirmView +{ + partial class FormShops + { + /// + /// 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.dataGridView = new System.Windows.Forms.DataGridView(); + this.ButtonAdd = new System.Windows.Forms.Button(); + this.ButtonUpd = new System.Windows.Forms.Button(); + this.ButtonDel = new System.Windows.Forms.Button(); + this.ButtonRef = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // dataGridView + // + this.dataGridView.BackgroundColor = System.Drawing.Color.White; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left; + this.dataGridView.Location = new System.Drawing.Point(0, 0); + this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowHeadersWidth = 51; + this.dataGridView.RowTemplate.Height = 29; + this.dataGridView.Size = new System.Drawing.Size(552, 338); + this.dataGridView.TabIndex = 0; + // + // ButtonAdd + // + this.ButtonAdd.Location = new System.Drawing.Point(586, 25); + this.ButtonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.ButtonAdd.Name = "ButtonAdd"; + this.ButtonAdd.Size = new System.Drawing.Size(93, 36); + this.ButtonAdd.TabIndex = 1; + this.ButtonAdd.Text = "Создать"; + this.ButtonAdd.UseVisualStyleBackColor = true; + this.ButtonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // ButtonUpd + // + this.ButtonUpd.Location = new System.Drawing.Point(586, 76); + this.ButtonUpd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.ButtonUpd.Name = "ButtonUpd"; + this.ButtonUpd.Size = new System.Drawing.Size(93, 36); + this.ButtonUpd.TabIndex = 2; + this.ButtonUpd.Text = "Изменить"; + this.ButtonUpd.UseVisualStyleBackColor = true; + this.ButtonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); + // + // ButtonDel + // + this.ButtonDel.Location = new System.Drawing.Point(586, 124); + this.ButtonDel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.ButtonDel.Name = "ButtonDel"; + this.ButtonDel.Size = new System.Drawing.Size(93, 36); + this.ButtonDel.TabIndex = 3; + this.ButtonDel.Text = "Удалить"; + this.ButtonDel.UseVisualStyleBackColor = true; + this.ButtonDel.Click += new System.EventHandler(this.ButtonDel_Click); + // + // ButtonRef + // + this.ButtonRef.Location = new System.Drawing.Point(586, 172); + this.ButtonRef.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.ButtonRef.Name = "ButtonRef"; + this.ButtonRef.Size = new System.Drawing.Size(93, 36); + this.ButtonRef.TabIndex = 4; + this.ButtonRef.Text = "Обновить"; + this.ButtonRef.UseVisualStyleBackColor = true; + this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click); + // + // FormShops + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(700, 338); + this.Controls.Add(this.ButtonRef); + this.Controls.Add(this.ButtonDel); + this.Controls.Add(this.ButtonUpd); + this.Controls.Add(this.ButtonAdd); + this.Controls.Add(this.dataGridView); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.Name = "FormShops"; + this.Text = "Магазины"; + this.Load += new System.EventHandler(this.FormShops_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private DataGridView dataGridView; + private Button ButtonAdd; + private Button ButtonUpd; + private Button ButtonDel; + private Button ButtonRef; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormShops.cs b/LawFirm/LawFirmView/FormShops.cs new file mode 100644 index 0000000..ed08f38 --- /dev/null +++ b/LawFirm/LawFirmView/FormShops.cs @@ -0,0 +1,104 @@ +using Microsoft.Extensions.Logging; +using LawFirmContracts.BindingModels; +using LawFirmContracts.BusinessLogicsContracts; + +namespace LawFirmView +{ + public partial class FormShops : Form + { + private readonly ILogger _logger; + private readonly IShopLogic _logic; + public FormShops(ILogger logger, IShopLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormShops_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + try + { + var list = _logic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["ShopDocuments"].Visible = false; + dataGridView.Columns["ShopName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Загрузка магазинов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки магазинов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShop)); + if (service is FormShop form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormShop)); + if (service is FormShop form) + { + form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Удаление магазина"); + try + { + if (!_logic.Delete(new ShopBindingModel + { + Id = id + })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления документов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} diff --git a/LawFirm/LawFirmView/FormShops.resx b/LawFirm/LawFirmView/FormShops.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/LawFirm/LawFirmView/FormShops.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/LawFirm/LawFirmView/LawFirmView.csproj b/LawFirm/LawFirmView/LawFirmView.csproj index 5904c43..099e484 100644 --- a/LawFirm/LawFirmView/LawFirmView.csproj +++ b/LawFirm/LawFirmView/LawFirmView.csproj @@ -28,6 +28,9 @@ + + Always + Always diff --git a/LawFirm/LawFirmView/Program.cs b/LawFirm/LawFirmView/Program.cs index 9573b35..471be88 100644 --- a/LawFirm/LawFirmView/Program.cs +++ b/LawFirm/LawFirmView/Program.cs @@ -39,10 +39,12 @@ namespace LawFirmView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -57,9 +59,15 @@ namespace LawFirmView services.AddTransient(); services.AddTransient(); services.AddTransient(); + 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 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Count + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Sum + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.74083cm + + + + + true + true + + + + + =Fields!Date.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + true + + + + + + true + true + + + + + =Fields!Count.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Sum.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSetOrders + 1.87537cm + 4.83399cm + 1.48166cm + 11.62988cm + 1 + + + + + + true + true + + + + + Итого: + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!Sum.Value, "DataSetOrders") + + + 2pt + 2pt + 2pt + 2pt + + + + 2in +