diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ReportLogic.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ReportLogic.cs index 2a2a232..9427451 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ReportLogic.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/BusinessLogics/ReportLogic.cs @@ -44,15 +44,15 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogics { var record = new ReportManufactureComponentViewModel { - ComponentName = component.ComponentName, - Manufactures = new List<(string, int)>(), + ManufactureName = component.ComponentName, + Components = new List<(string, int)>(), TotalCount = 0 }; foreach (var manufacture in manufactures) { if (manufacture.ManufactureComponents.ContainsKey(component.Id)) { - record.Manufactures.Add(new (manufacture.ManufactureName, manufacture.ManufactureComponents[component.Id].Item2)); + record.Components.Add(new (manufacture.ManufactureName, manufacture.ManufactureComponents[component.Id].Item2)); record.TotalCount += manufacture.ManufactureComponents[component.Id].Item2; } } @@ -77,7 +77,8 @@ namespace BlacksmithWorkshopBusinessLogic.BusinessLogics Id = x.Id, DateCreate = x.DateCreate, ManufactureName = x.ManufactureName, - Sum = x.Sum + Sum = x.Sum, + Status = Convert.ToString(x.Status) ?? string.Empty }) .ToList(); } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index 34cfe8e..fb5790a 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -36,24 +36,24 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage { ColumnName = "A", RowIndex = rowIndex, - Text = pc.ComponentName, + Text = pc.ManufactureName, StyleInfo = ExcelStyleInfoType.Text }); rowIndex++; - foreach (var manufacture in pc.Manufactures) + foreach (var components in pc.Components) { InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "B", RowIndex = rowIndex, - Text = manufacture.Manufacture, + Text = components.Item1, StyleInfo = ExcelStyleInfoType.TextWithBroder }); InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "C", RowIndex = rowIndex, - Text = manufacture.Count.ToString(), + Text = components.Count.ToString(), StyleInfo = ExcelStyleInfoType.TextWithBroder }); rowIndex++; diff --git a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToPdf.cs b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToPdf.cs index ff7ba45..6ea47a3 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToPdf.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopBusinessLogic/OfficePackage/AbstractSaveToPdf.cs @@ -24,10 +24,10 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage Text = $"с { info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); - CreateTable(new List { "2cm", "3cm", "6cm", "3cm" }); + CreateTable(new List { "2cm", "3cm", "6cm", "3cm", "3cm" }); CreateRow(new PdfRowParameters { - Texts = new List { "Номер", "Дата заказа", "Изделие", "Сумма" }, + Texts = new List { "Номер", "Дата заказа", "Изделие", "Статус", "Сумма" }, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); @@ -35,7 +35,7 @@ namespace BlacksmithWorkshopBusinessLogic.OfficePackage { CreateRow(new PdfRowParameters { - Texts = new List { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.ProductName, order.Sum.ToString() }, + Texts = new List { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.ManufactureName, order.Status, order.Sum.ToString() }, Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Left }); diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ReportManufactureComponentViewModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ReportManufactureComponentViewModel.cs index 49c3c74..04387cd 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ReportManufactureComponentViewModel.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ReportManufactureComponentViewModel.cs @@ -8,8 +8,8 @@ namespace BlacksmithWorkshopContracts.ViewModels { public class ReportManufactureComponentViewModel { - public string ComponentName { get; set; } = string.Empty; + public string ManufactureName { get; set; } = string.Empty; public int TotalCount { get; set; } - public List<(string Manufacture, int Count)> Manufactures { get; set; } = new(); + public List<(string Component, int Count)> Components { get; set; } = new(); } } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ReportOrdersViewModel.cs b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ReportOrdersViewModel.cs index e315a14..175fe7f 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ReportOrdersViewModel.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopContracts/ViewModels/ReportOrdersViewModel.cs @@ -12,5 +12,6 @@ namespace BlacksmithWorkshopContracts.ViewModels public DateTime DateCreate { get; set; } public string ManufactureName { get; set; } = string.Empty; public double Sum { get; set; } + public string Status { get; set; } = string.Empty; } } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopView/BlacksmithWorkshopView.csproj b/BlacksmithWorkshop/BlacksmithWorkshopView/BlacksmithWorkshopView.csproj index 3cf23aa..e69872b 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopView/BlacksmithWorkshopView.csproj +++ b/BlacksmithWorkshop/BlacksmithWorkshopView/BlacksmithWorkshopView.csproj @@ -15,6 +15,7 @@ + @@ -24,4 +25,10 @@ + + + Always + + + \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshopView/FormMain.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshopView/FormMain.Designer.cs index 1dd1fd6..3305b81 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopView/FormMain.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopView/FormMain.Designer.cs @@ -28,147 +28,175 @@ /// private void InitializeComponent() { - this.menuStrip1 = new System.Windows.Forms.MenuStrip(); - this.guideToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.componentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); - this.goodsToolStripMenuItem = 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.buttonRef = new System.Windows.Forms.Button(); - this.menuStrip1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); - this.SuspendLayout(); + menuStrip1 = new MenuStrip(); + guideToolStripMenuItem = new ToolStripMenuItem(); + componentsToolStripMenuItem = new ToolStripMenuItem(); + goodsToolStripMenuItem = new ToolStripMenuItem(); + отчетыToolStripMenuItem = new ToolStripMenuItem(); + componentListToolStripMenuItem = new ToolStripMenuItem(); + dataGridView = new DataGridView(); + buttonCreateOrder = new Button(); + buttonTakeOrderInWork = new Button(); + buttonOrderReady = new Button(); + buttonIssuedOrder = new Button(); + buttonRef = new Button(); + componentsManufactureToolStripMenuItem = new ToolStripMenuItem(); + orderListToolStripMenuItem = new ToolStripMenuItem(); + menuStrip1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); // // menuStrip1 // - this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); - this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.guideToolStripMenuItem}); - 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(1149, 24); - this.menuStrip1.TabIndex = 0; - this.menuStrip1.Text = "menuStrip1"; + menuStrip1.ImageScalingSize = new Size(20, 20); + menuStrip1.Items.AddRange(new ToolStripItem[] { guideToolStripMenuItem, отчетыToolStripMenuItem }); + menuStrip1.Location = new Point(0, 0); + menuStrip1.Name = "menuStrip1"; + menuStrip1.Padding = new Padding(5, 2, 0, 2); + menuStrip1.Size = new Size(1149, 24); + menuStrip1.TabIndex = 0; + menuStrip1.Text = "menuStrip1"; // // guideToolStripMenuItem // - this.guideToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.componentsToolStripMenuItem, - this.goodsToolStripMenuItem}); - this.guideToolStripMenuItem.Name = "guideToolStripMenuItem"; - this.guideToolStripMenuItem.Size = new System.Drawing.Size(87, 20); - this.guideToolStripMenuItem.Text = "Справочник"; + guideToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem, goodsToolStripMenuItem }); + guideToolStripMenuItem.Name = "guideToolStripMenuItem"; + guideToolStripMenuItem.Size = new Size(87, 20); + guideToolStripMenuItem.Text = "Справочник"; // // componentsToolStripMenuItem // - this.componentsToolStripMenuItem.Name = "componentsToolStripMenuItem"; - this.componentsToolStripMenuItem.Size = new System.Drawing.Size(145, 22); - this.componentsToolStripMenuItem.Text = "Компоненты"; - this.componentsToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click); + componentsToolStripMenuItem.Name = "componentsToolStripMenuItem"; + componentsToolStripMenuItem.Size = new Size(145, 22); + componentsToolStripMenuItem.Text = "Компоненты"; + componentsToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click; // // goodsToolStripMenuItem // - this.goodsToolStripMenuItem.Name = "goodsToolStripMenuItem"; - this.goodsToolStripMenuItem.Size = new System.Drawing.Size(145, 22); - this.goodsToolStripMenuItem.Text = "Изделия"; - this.goodsToolStripMenuItem.Click += new System.EventHandler(this.GoodsToolStripMenuItem_Click); + goodsToolStripMenuItem.Name = "goodsToolStripMenuItem"; + goodsToolStripMenuItem.Size = new Size(145, 22); + goodsToolStripMenuItem.Text = "Изделия"; + goodsToolStripMenuItem.Click += GoodsToolStripMenuItem_Click; + // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentListToolStripMenuItem, componentsManufactureToolStripMenuItem, orderListToolStripMenuItem }); + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(60, 20); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // componentListToolStripMenuItem + // + componentListToolStripMenuItem.Name = "componentListToolStripMenuItem"; + componentListToolStripMenuItem.Size = new Size(218, 22); + componentListToolStripMenuItem.Text = "Список коспонентов"; + componentListToolStripMenuItem.Click += ComponentListToolStripMenuItem_Click; // // dataGridView // - this.dataGridView.AllowUserToAddRows = false; - this.dataGridView.AllowUserToDeleteRows = false; - this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView.Location = new System.Drawing.Point(10, 23); - this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.dataGridView.Name = "dataGridView"; - this.dataGridView.ReadOnly = true; - this.dataGridView.RowHeadersWidth = 51; - this.dataGridView.RowTemplate.Height = 29; - this.dataGridView.Size = new System.Drawing.Size(855, 286); - this.dataGridView.TabIndex = 1; + dataGridView.AllowUserToAddRows = false; + dataGridView.AllowUserToDeleteRows = false; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(10, 23); + dataGridView.Margin = new Padding(3, 2, 3, 2); + dataGridView.Name = "dataGridView"; + dataGridView.ReadOnly = true; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 29; + dataGridView.Size = new Size(855, 286); + dataGridView.TabIndex = 1; // // buttonCreateOrder // - this.buttonCreateOrder.Location = new System.Drawing.Point(898, 53); - this.buttonCreateOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonCreateOrder.Name = "buttonCreateOrder"; - this.buttonCreateOrder.Size = new System.Drawing.Size(216, 22); - this.buttonCreateOrder.TabIndex = 2; - this.buttonCreateOrder.Text = "Создать заказ"; - this.buttonCreateOrder.UseVisualStyleBackColor = true; - this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click); + buttonCreateOrder.Location = new Point(898, 53); + buttonCreateOrder.Margin = new Padding(3, 2, 3, 2); + buttonCreateOrder.Name = "buttonCreateOrder"; + buttonCreateOrder.Size = new Size(216, 22); + buttonCreateOrder.TabIndex = 2; + buttonCreateOrder.Text = "Создать заказ"; + buttonCreateOrder.UseVisualStyleBackColor = true; + buttonCreateOrder.Click += ButtonCreateOrder_Click; // // buttonTakeOrderInWork // - this.buttonTakeOrderInWork.Location = new System.Drawing.Point(898, 92); - this.buttonTakeOrderInWork.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; - this.buttonTakeOrderInWork.Size = new System.Drawing.Size(216, 22); - this.buttonTakeOrderInWork.TabIndex = 3; - this.buttonTakeOrderInWork.Text = "Отдать на выполнение"; - this.buttonTakeOrderInWork.UseVisualStyleBackColor = true; - this.buttonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click); + buttonTakeOrderInWork.Location = new Point(898, 92); + buttonTakeOrderInWork.Margin = new Padding(3, 2, 3, 2); + buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; + buttonTakeOrderInWork.Size = new Size(216, 22); + buttonTakeOrderInWork.TabIndex = 3; + buttonTakeOrderInWork.Text = "Отдать на выполнение"; + buttonTakeOrderInWork.UseVisualStyleBackColor = true; + buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click; // // buttonOrderReady // - this.buttonOrderReady.Location = new System.Drawing.Point(898, 129); - this.buttonOrderReady.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonOrderReady.Name = "buttonOrderReady"; - this.buttonOrderReady.Size = new System.Drawing.Size(216, 22); - this.buttonOrderReady.TabIndex = 4; - this.buttonOrderReady.Text = "Заказ готов"; - this.buttonOrderReady.UseVisualStyleBackColor = true; - this.buttonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click); + buttonOrderReady.Location = new Point(898, 129); + buttonOrderReady.Margin = new Padding(3, 2, 3, 2); + buttonOrderReady.Name = "buttonOrderReady"; + buttonOrderReady.Size = new Size(216, 22); + buttonOrderReady.TabIndex = 4; + buttonOrderReady.Text = "Заказ готов"; + buttonOrderReady.UseVisualStyleBackColor = true; + buttonOrderReady.Click += ButtonOrderReady_Click; // // buttonIssuedOrder // - this.buttonIssuedOrder.Location = new System.Drawing.Point(898, 169); - this.buttonIssuedOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonIssuedOrder.Name = "buttonIssuedOrder"; - this.buttonIssuedOrder.Size = new System.Drawing.Size(216, 22); - this.buttonIssuedOrder.TabIndex = 5; - this.buttonIssuedOrder.Text = "Заказ выдан"; - this.buttonIssuedOrder.UseVisualStyleBackColor = true; - this.buttonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click); + buttonIssuedOrder.Location = new Point(898, 169); + buttonIssuedOrder.Margin = new Padding(3, 2, 3, 2); + buttonIssuedOrder.Name = "buttonIssuedOrder"; + buttonIssuedOrder.Size = new Size(216, 22); + buttonIssuedOrder.TabIndex = 5; + buttonIssuedOrder.Text = "Заказ выдан"; + buttonIssuedOrder.UseVisualStyleBackColor = true; + buttonIssuedOrder.Click += ButtonIssuedOrder_Click; // // buttonRef // - this.buttonRef.Location = new System.Drawing.Point(898, 210); - this.buttonRef.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonRef.Name = "buttonRef"; - this.buttonRef.Size = new System.Drawing.Size(216, 22); - this.buttonRef.TabIndex = 6; - this.buttonRef.Text = "Обновить список"; - this.buttonRef.UseVisualStyleBackColor = true; - this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click); + buttonRef.Location = new Point(898, 210); + buttonRef.Margin = new Padding(3, 2, 3, 2); + buttonRef.Name = "buttonRef"; + buttonRef.Size = new Size(216, 22); + buttonRef.TabIndex = 6; + buttonRef.Text = "Обновить список"; + buttonRef.UseVisualStyleBackColor = true; + buttonRef.Click += ButtonRef_Click; + // + // componentsManufactureToolStripMenuItem + // + componentsManufactureToolStripMenuItem.Name = "componentsManufactureToolStripMenuItem"; + componentsManufactureToolStripMenuItem.Size = new Size(218, 22); + componentsManufactureToolStripMenuItem.Text = "Компоненты по изделиям"; + componentsManufactureToolStripMenuItem.Click += ComponentManufacturesToolStripMenuItem_Click; + // + // orderListToolStripMenuItem + // + orderListToolStripMenuItem.Name = "orderListToolStripMenuItem"; + orderListToolStripMenuItem.Size = new Size(218, 22); + orderListToolStripMenuItem.Text = "Список заказов"; + orderListToolStripMenuItem.Click += OrderListToolStripMenuItem_Click; // // FormMain // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(1149, 319); - 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.dataGridView); - this.Controls.Add(this.menuStrip1); - this.MainMenuStrip = this.menuStrip1; - this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.Name = "FormMain"; - this.Text = "Кузнечная мастерская"; - this.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(); - + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1149, 319); + Controls.Add(buttonRef); + Controls.Add(buttonIssuedOrder); + Controls.Add(buttonOrderReady); + Controls.Add(buttonTakeOrderInWork); + Controls.Add(buttonCreateOrder); + Controls.Add(dataGridView); + Controls.Add(menuStrip1); + MainMenuStrip = menuStrip1; + Margin = new Padding(3, 2, 3, 2); + Name = "FormMain"; + Text = "Кузнечная мастерская"; + Load += FormMain_Load; + menuStrip1.ResumeLayout(false); + menuStrip1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); } #endregion @@ -183,5 +211,9 @@ private Button buttonOrderReady; private Button buttonIssuedOrder; private Button buttonRef; + private ToolStripMenuItem отчетыToolStripMenuItem; + private ToolStripMenuItem componentListToolStripMenuItem; + private ToolStripMenuItem componentsManufactureToolStripMenuItem; + private ToolStripMenuItem orderListToolStripMenuItem; } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshopView/FormMain.cs b/BlacksmithWorkshop/BlacksmithWorkshopView/FormMain.cs index 17f8866..831d876 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopView/FormMain.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopView/FormMain.cs @@ -20,11 +20,13 @@ namespace BlacksmithWorkshopView { private readonly ILogger _logger; private readonly IOrderLogic _orderLogic; - public FormMain(ILogger logger, IOrderLogic orderLogic) + private readonly IReportLogic _reportLogic; + public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic) { InitializeComponent(); _logger = logger; _orderLogic = orderLogic; + _reportLogic = reportLogic; } private void FormMain_Load(object sender, EventArgs e) { @@ -82,8 +84,8 @@ namespace BlacksmithWorkshopView _logger.LogInformation("Заказ No {id}. Меняется статус на 'В работе'", id); try { - var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel - { + var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel + { Id = id, ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].Value), ManufactureName = dataGridView.SelectedRows[0].Cells["ManufactureName"].Value.ToString(), @@ -113,8 +115,8 @@ namespace BlacksmithWorkshopView _logger.LogInformation("Заказ No {id}. Меняется статус на 'Готов'", id); try { - var operationResult = _orderLogic.FinishOrder(new OrderBindingModel - { + var operationResult = _orderLogic.FinishOrder(new OrderBindingModel + { Id = id, ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].Value), ManufactureName = dataGridView.SelectedRows[0].Cells["ManufactureName"].Value.ToString(), @@ -146,7 +148,7 @@ namespace BlacksmithWorkshopView try { var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel - { + { Id = id, ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].Value), ManufactureName = dataGridView.SelectedRows[0].Cells["ManufactureName"].Value.ToString(), @@ -174,5 +176,35 @@ namespace BlacksmithWorkshopView { LoadData(); } + private void ComponentListToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SaveComponentsToWordFile(new ReportBindingModel { FileName = dialog.FileName }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + private void ComponentManufacturesToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportManufactureComponents)); + if (service is FormReportManufactureComponents form) + { + form.ShowDialog(); + } + } + private void OrderListToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + if (service is FormReportOrders form) + { + form.ShowDialog(); + } + } + + private void списокToolStripMenuItem_Click(object sender, EventArgs e) + { + + } } } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopView/FormReportManufactureComponents.cs b/BlacksmithWorkshop/BlacksmithWorkshopView/FormReportManufactureComponents.cs index 11fbd18..03a7666 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopView/FormReportManufactureComponents.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopView/FormReportManufactureComponents.cs @@ -33,8 +33,8 @@ namespace BlacksmithWorkshopView dataGridView.Rows.Clear(); foreach (var elem in dict) { - dataGridView.Rows.Add(new object[] { elem.ComponentName, "", "" }); - foreach (var listElem in elem.Manufactures) + dataGridView.Rows.Add(new object[] { elem.ManufactureName, "", "" }); + foreach (var listElem in elem.Components) { dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 }); } diff --git a/BlacksmithWorkshop/BlacksmithWorkshopView/FormReportOrders.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshopView/FormReportOrders.Designer.cs new file mode 100644 index 0000000..32285dd --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopView/FormReportOrders.Designer.cs @@ -0,0 +1,141 @@ +namespace BlacksmithWorkshopView +{ + partial class FormReportOrders + { + /// + /// 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.dateTimePickerTo = new System.Windows.Forms.DateTimePicker(); + this.labelTo = new System.Windows.Forms.Label(); + this.dateTimePickerFrom = new System.Windows.Forms.DateTimePicker(); + this.labelFrom = new System.Windows.Forms.Label(); + this.panel.SuspendLayout(); + this.SuspendLayout(); + // + // panel + // + this.panel.Controls.Add(this.buttonToPdf); + this.panel.Controls.Add(this.buttonMake); + this.panel.Controls.Add(this.dateTimePickerTo); + this.panel.Controls.Add(this.labelTo); + this.panel.Controls.Add(this.dateTimePickerFrom); + this.panel.Controls.Add(this.labelFrom); + this.panel.Dock = System.Windows.Forms.DockStyle.Top; + this.panel.Location = new System.Drawing.Point(0, 0); + this.panel.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.panel.Name = "panel"; + this.panel.Size = new System.Drawing.Size(1031, 40); + this.panel.TabIndex = 0; + // + // buttonToPdf + // + this.buttonToPdf.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.buttonToPdf.Location = new System.Drawing.Point(878, 8); + this.buttonToPdf.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.buttonToPdf.Name = "buttonToPdf"; + this.buttonToPdf.Size = new System.Drawing.Size(139, 27); + this.buttonToPdf.TabIndex = 5; + 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(476, 8); + this.buttonMake.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.buttonMake.Name = "buttonMake"; + this.buttonMake.Size = new System.Drawing.Size(139, 27); + this.buttonMake.TabIndex = 4; + this.buttonMake.Text = "Сформировать"; + this.buttonMake.UseVisualStyleBackColor = true; + this.buttonMake.Click += new System.EventHandler(this.ButtonMake_Click); + // + // dateTimePickerTo + // + this.dateTimePickerTo.Location = new System.Drawing.Point(237, 7); + this.dateTimePickerTo.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.dateTimePickerTo.Name = "dateTimePickerTo"; + this.dateTimePickerTo.Size = new System.Drawing.Size(163, 23); + this.dateTimePickerTo.TabIndex = 3; + // + // labelTo + // + this.labelTo.AutoSize = true; + this.labelTo.Location = new System.Drawing.Point(208, 10); + this.labelTo.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.labelTo.Name = "labelTo"; + this.labelTo.Size = new System.Drawing.Size(21, 15); + this.labelTo.TabIndex = 2; + this.labelTo.Text = "по"; + // + // dateTimePickerFrom + // + this.dateTimePickerFrom.Location = new System.Drawing.Point(37, 7); + this.dateTimePickerFrom.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.dateTimePickerFrom.Name = "dateTimePickerFrom"; + this.dateTimePickerFrom.Size = new System.Drawing.Size(163, 23); + this.dateTimePickerFrom.TabIndex = 1; + // + // labelFrom + // + this.labelFrom.AutoSize = true; + this.labelFrom.Location = new System.Drawing.Point(14, 10); + this.labelFrom.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.labelFrom.Name = "labelFrom"; + this.labelFrom.Size = new System.Drawing.Size(15, 15); + this.labelFrom.TabIndex = 0; + this.labelFrom.Text = "С"; + // + // FormReportOrders + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1031, 647); + this.Controls.Add(this.panel); + this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.Name = "FormReportOrders"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Заказы"; + this.panel.ResumeLayout(false); + this.panel.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel panel; + private System.Windows.Forms.Button buttonToPdf; + private System.Windows.Forms.Button buttonMake; + private System.Windows.Forms.DateTimePicker dateTimePickerTo; + private System.Windows.Forms.Label labelTo; + private System.Windows.Forms.DateTimePicker dateTimePickerFrom; + private System.Windows.Forms.Label labelFrom; + } +} \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshopView/FormReportOrders.cs b/BlacksmithWorkshop/BlacksmithWorkshopView/FormReportOrders.cs new file mode 100644 index 0000000..d52fd63 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopView/FormReportOrders.cs @@ -0,0 +1,95 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; +using Microsoft.Reporting.WinForms; +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 BlacksmithWorkshopView +{ + public partial class FormReportOrders : Form + { + private readonly ReportViewer reportViewer; + private readonly ILogger _logger; + private readonly IReportLogic _logic; + public FormReportOrders(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + reportViewer = new ReportViewer + { + Dock = DockStyle.Fill + }; + reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportOrders.rdlc", FileMode.Open)); + Controls.Clear(); + Controls.Add(reportViewer); + Controls.Add(panel); + } + private void ButtonMake_Click(object sender, EventArgs e) + { + if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date) + { + MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + try + { + var dataSource = _logic.GetOrders(new ReportBindingModel + { + DateFrom = dateTimePickerFrom.Value, + DateTo = dateTimePickerTo.Value + }); + var source = new ReportDataSource("DataSetOrders", dataSource); + reportViewer.LocalReport.DataSources.Clear(); + reportViewer.LocalReport.DataSources.Add(source); + var parameters = new[] { new ReportParameter("ReportParameterPeriod", + $"c {dateTimePickerFrom.Value.ToShortDateString()} по {dateTimePickerTo.Value.ToShortDateString()}") }; + reportViewer.LocalReport.SetParameters(parameters); + reportViewer.RefreshReport(); + _logger.LogInformation("Загрузка списка заказов на период {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString()); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка заказов на период"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void ButtonToPdf_Click(object sender, EventArgs e) + { + if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date) + { + MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + _logic.SaveOrdersToPdfFile(new ReportBindingModel + { + FileName = dialog.FileName, + DateFrom = dateTimePickerFrom.Value, + DateTo = dateTimePickerTo.Value + }); + _logger.LogInformation("Сохранение списка заказов на период {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(), + dateTimePickerTo.Value.ToShortDateString()); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения списка заказов на период"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } +} diff --git a/BlacksmithWorkshop/BlacksmithWorkshopView/FormReportOrders.resx b/BlacksmithWorkshop/BlacksmithWorkshopView/FormReportOrders.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshopView/FormReportOrders.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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/BlacksmithWorkshop/BlacksmithWorkshopView/Program.cs b/BlacksmithWorkshop/BlacksmithWorkshopView/Program.cs index 6d2bf49..5da750f 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopView/Program.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshopView/Program.cs @@ -54,6 +54,8 @@ namespace BlacksmithWorkshopView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshopView/ReportOrders.rdlc b/BlacksmithWorkshop/BlacksmithWorkshopView/ReportOrders.rdlc index ac6fef6..7d4495a 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshopView/ReportOrders.rdlc +++ b/BlacksmithWorkshop/BlacksmithWorkshopView/ReportOrders.rdlc @@ -1,6 +1,50 @@ 0 + + + + System.Data.DataSet + /* Local Connection */ + + 08752924-67db-41af-a51d-c726b3d364b5 + + + + + + BlacksmithWorkshopContractsViewModels + /* Local Query */ + + + + Id + System.Int32 + + + DateCreate + System.DateTime + + + ManufactureName + System.String + + + Sum + System.Decimal + + + OrderStatus + System.String + + + + BlacksmithWorkshopContracts.ViewModels + ReportOrdersViewModel + BlacksmithWorkshopContracts.ViewModels.ReportOrdersViewModel, BlacksmithWorkshopContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + @@ -25,7 +69,7 @@ ReportParameterPeriod - 1.24cm + 1cm 1cm 21cm - 0.24cm 1cm 21cm 1 @@ -77,16 +120,19 @@ - 2.5cm + 2.64288cm - 3.21438cm + 3.35726cm - 8.23317cm + 8.37605cm - 2.5cm + 2.64288cm + + + 2.83867cm @@ -191,7 +237,7 @@ - + true true @@ -207,6 +253,38 @@ + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Статус + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!OrderStatus.Value + - 4.24cm + 4cm 12cm 0.6cm 2.5cm @@ -433,7 +542,7 @@ - 4.24cm + 4cm 14.5cm 0.6cm 2.5cm @@ -449,10 +558,10 @@ - 2in + 5.72875cm