From ce35ed8f72d8ff1d2244fdce2298fd319efcf7c8 Mon Sep 17 00:00:00 2001 From: ArtemEmelyanov Date: Wed, 22 Mar 2023 15:38:03 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BE=D0=B1=D1=80=D0=B0=D0=BD=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=D0=BB=D0=B0=D0=B1=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FishFactory/FishFactoryView.csproj | 1 + .../FishFactory/FormCanneds.Designer.cs | 31 +- .../FishFactory/FormComponents.Designer.cs | 31 +- FishFactory/FishFactory/FormMain.Designer.cs | 43 +- FishFactory/FishFactory/FormMain.cs | 38 +- .../FormReportCannedComponents.Designer.cs | 122 ++++ .../FishFactory/FormReportCannedComponents.cs | 90 +++ .../FormReportCannedComponents.resx | 60 ++ .../FishFactory/FormReportOrders.Designer.cs | 141 +++++ FishFactory/FishFactory/FormReportOrders.cs | 105 ++++ FishFactory/FishFactory/FormReportOrders.resx | 120 ++++ FishFactory/FishFactory/Program.cs | 12 +- FishFactory/FishFactory/ReportOrders.rdlc | 529 ++++++++++++++++++ .../{ => BusinessLogic}/CannedLogic.cs | 4 +- .../{ => BusinessLogic}/ComponentLogic.cs | 2 +- .../{ => BusinessLogic}/OrderLogic.cs | 2 +- .../BusinessLogic/ReportLogic.cs | 134 +++++ .../FishFactoryBusinessLogic.csproj | 2 + .../OfficePackage/AbstractSaveToExcel.cs | 103 ++++ .../OfficePackage/AbstractSaveToPdf.cs | 82 +++ .../OfficePackage/AbstractSaveToWord.cs | 58 ++ .../HelperEnums/ExcelStyleInfoType.cs | 15 + .../HelperEnums/PdfParagraphAlignmentType.cs | 15 + .../HelperEnums/WordJustificationType.cs | 14 + .../HelperModels/Excel/ExcelCellParameters.cs | 18 + .../HelperModels/Excel/ExcelInfo.cs | 20 + .../Excel/ExcelMergeParameters.cs | 15 + .../OfficePackage/HelperModels/Pdf/PdfInfo.cs | 18 + .../HelperModels/Pdf/PdfParagraph.cs | 16 + .../HelperModels/Pdf/PdfRowParameters.cs | 16 + .../HelperModels/Word/WordInfo.cs | 16 + .../HelperModels/Word/WordParagraph.cs | 14 + .../HelperModels/Word/WordTextProperties.cs | 16 + .../OfficePackage/Implements/SaveToExcel.cs | 357 ++++++++++++ .../OfficePackage/Implements/SaveToPdf.cs | 107 ++++ .../OfficePackage/Implements/SaveToWord.cs | 125 +++++ .../BindingModels/ReportBindingModel.cs | 15 + .../BusinessLogicsContracts/IReportLogic.cs | 40 ++ .../SearchModels/OrderSearchModel.cs | 2 + .../ReportCannedComponentViewModel.cs | 15 + .../ViewModels/ReportOdersViewModel.cs | 16 + .../Implements/OrderStorage.cs | 4 +- 42 files changed, 2550 insertions(+), 34 deletions(-) create mode 100644 FishFactory/FishFactory/FormReportCannedComponents.Designer.cs create mode 100644 FishFactory/FishFactory/FormReportCannedComponents.cs create mode 100644 FishFactory/FishFactory/FormReportCannedComponents.resx create mode 100644 FishFactory/FishFactory/FormReportOrders.Designer.cs create mode 100644 FishFactory/FishFactory/FormReportOrders.cs create mode 100644 FishFactory/FishFactory/FormReportOrders.resx create mode 100644 FishFactory/FishFactory/ReportOrders.rdlc rename FishFactory/FishFactoryBusinessLogic/{ => BusinessLogic}/CannedLogic.cs (98%) rename FishFactory/FishFactoryBusinessLogic/{ => BusinessLogic}/ComponentLogic.cs (98%) rename FishFactory/FishFactoryBusinessLogic/{ => BusinessLogic}/OrderLogic.cs (99%) create mode 100644 FishFactory/FishFactoryBusinessLogic/BusinessLogic/ReportLogic.cs create mode 100644 FishFactory/FishFactoryBusinessLogic/OfficePackage/AbstractSaveToExcel.cs create mode 100644 FishFactory/FishFactoryBusinessLogic/OfficePackage/AbstractSaveToPdf.cs create mode 100644 FishFactory/FishFactoryBusinessLogic/OfficePackage/AbstractSaveToWord.cs create mode 100644 FishFactory/FishFactoryBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs create mode 100644 FishFactory/FishFactoryBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs create mode 100644 FishFactory/FishFactoryBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs create mode 100644 FishFactory/FishFactoryBusinessLogic/OfficePackage/HelperModels/Excel/ExcelCellParameters.cs create mode 100644 FishFactory/FishFactoryBusinessLogic/OfficePackage/HelperModels/Excel/ExcelInfo.cs create mode 100644 FishFactory/FishFactoryBusinessLogic/OfficePackage/HelperModels/Excel/ExcelMergeParameters.cs create mode 100644 FishFactory/FishFactoryBusinessLogic/OfficePackage/HelperModels/Pdf/PdfInfo.cs create mode 100644 FishFactory/FishFactoryBusinessLogic/OfficePackage/HelperModels/Pdf/PdfParagraph.cs create mode 100644 FishFactory/FishFactoryBusinessLogic/OfficePackage/HelperModels/Pdf/PdfRowParameters.cs create mode 100644 FishFactory/FishFactoryBusinessLogic/OfficePackage/HelperModels/Word/WordInfo.cs create mode 100644 FishFactory/FishFactoryBusinessLogic/OfficePackage/HelperModels/Word/WordParagraph.cs create mode 100644 FishFactory/FishFactoryBusinessLogic/OfficePackage/HelperModels/Word/WordTextProperties.cs create mode 100644 FishFactory/FishFactoryBusinessLogic/OfficePackage/Implements/SaveToExcel.cs create mode 100644 FishFactory/FishFactoryBusinessLogic/OfficePackage/Implements/SaveToPdf.cs create mode 100644 FishFactory/FishFactoryBusinessLogic/OfficePackage/Implements/SaveToWord.cs create mode 100644 FishFactory/FishFactoryContracts/BindingModels/ReportBindingModel.cs create mode 100644 FishFactory/FishFactoryContracts/BusinessLogicsContracts/IReportLogic.cs create mode 100644 FishFactory/FishFactoryContracts/ViewModels/ReportCannedComponentViewModel.cs create mode 100644 FishFactory/FishFactoryContracts/ViewModels/ReportOdersViewModel.cs diff --git a/FishFactory/FishFactory/FishFactoryView.csproj b/FishFactory/FishFactory/FishFactoryView.csproj index 3125cd1..0566024 100644 --- a/FishFactory/FishFactory/FishFactoryView.csproj +++ b/FishFactory/FishFactory/FishFactoryView.csproj @@ -12,6 +12,7 @@ + diff --git a/FishFactory/FishFactory/FormCanneds.Designer.cs b/FishFactory/FishFactory/FormCanneds.Designer.cs index 3781656..0795a64 100644 --- a/FishFactory/FishFactory/FormCanneds.Designer.cs +++ b/FishFactory/FishFactory/FormCanneds.Designer.cs @@ -39,18 +39,20 @@ // dataGridView // this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView.Location = new System.Drawing.Point(12, 12); + this.dataGridView.Location = new System.Drawing.Point(10, 9); + 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(572, 384); + this.dataGridView.Size = new System.Drawing.Size(500, 288); this.dataGridView.TabIndex = 0; // // ButtonAdd // - this.ButtonAdd.Location = new System.Drawing.Point(590, 12); + this.ButtonAdd.Location = new System.Drawing.Point(516, 9); + this.ButtonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.ButtonAdd.Name = "ButtonAdd"; - this.ButtonAdd.Size = new System.Drawing.Size(137, 29); + this.ButtonAdd.Size = new System.Drawing.Size(120, 22); this.ButtonAdd.TabIndex = 1; this.ButtonAdd.Text = "Добавить"; this.ButtonAdd.UseVisualStyleBackColor = true; @@ -58,9 +60,10 @@ // // ButtonChange // - this.ButtonChange.Location = new System.Drawing.Point(590, 47); + this.ButtonChange.Location = new System.Drawing.Point(516, 35); + this.ButtonChange.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.ButtonChange.Name = "ButtonChange"; - this.ButtonChange.Size = new System.Drawing.Size(137, 29); + this.ButtonChange.Size = new System.Drawing.Size(120, 22); this.ButtonChange.TabIndex = 2; this.ButtonChange.Text = "Изменить"; this.ButtonChange.UseVisualStyleBackColor = true; @@ -68,9 +71,10 @@ // // ButtonRemove // - this.ButtonRemove.Location = new System.Drawing.Point(590, 82); + this.ButtonRemove.Location = new System.Drawing.Point(516, 62); + this.ButtonRemove.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.ButtonRemove.Name = "ButtonRemove"; - this.ButtonRemove.Size = new System.Drawing.Size(137, 29); + this.ButtonRemove.Size = new System.Drawing.Size(120, 22); this.ButtonRemove.TabIndex = 3; this.ButtonRemove.Text = "Удалить"; this.ButtonRemove.UseVisualStyleBackColor = true; @@ -78,9 +82,10 @@ // // ButtonUpdate // - this.ButtonUpdate.Location = new System.Drawing.Point(590, 117); + this.ButtonUpdate.Location = new System.Drawing.Point(516, 88); + this.ButtonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.ButtonUpdate.Name = "ButtonUpdate"; - this.ButtonUpdate.Size = new System.Drawing.Size(137, 29); + this.ButtonUpdate.Size = new System.Drawing.Size(120, 22); this.ButtonUpdate.TabIndex = 4; this.ButtonUpdate.Text = "Обновить"; this.ButtonUpdate.UseVisualStyleBackColor = true; @@ -88,16 +93,18 @@ // // FormCanneds // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(740, 405); + this.ClientSize = new System.Drawing.Size(648, 304); this.Controls.Add(this.ButtonUpdate); this.Controls.Add(this.ButtonRemove); this.Controls.Add(this.ButtonChange); this.Controls.Add(this.ButtonAdd); this.Controls.Add(this.dataGridView); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.Name = "FormCanneds"; this.Text = "Консервы"; + this.Load += new System.EventHandler(this.FormCanneds_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ResumeLayout(false); diff --git a/FishFactory/FishFactory/FormComponents.Designer.cs b/FishFactory/FishFactory/FormComponents.Designer.cs index 4223869..fa99832 100644 --- a/FishFactory/FishFactory/FormComponents.Designer.cs +++ b/FishFactory/FishFactory/FormComponents.Designer.cs @@ -39,18 +39,20 @@ // dataGridView // this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView.Location = new System.Drawing.Point(12, 12); + this.dataGridView.Location = new System.Drawing.Point(10, 9); + 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(572, 384); + this.dataGridView.Size = new System.Drawing.Size(500, 288); this.dataGridView.TabIndex = 0; // // ButtonAdd // - this.ButtonAdd.Location = new System.Drawing.Point(590, 12); + this.ButtonAdd.Location = new System.Drawing.Point(516, 9); + this.ButtonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.ButtonAdd.Name = "ButtonAdd"; - this.ButtonAdd.Size = new System.Drawing.Size(137, 29); + this.ButtonAdd.Size = new System.Drawing.Size(120, 22); this.ButtonAdd.TabIndex = 1; this.ButtonAdd.Text = "Добавить"; this.ButtonAdd.UseVisualStyleBackColor = true; @@ -58,9 +60,10 @@ // // ButtonChange // - this.ButtonChange.Location = new System.Drawing.Point(590, 47); + this.ButtonChange.Location = new System.Drawing.Point(516, 35); + this.ButtonChange.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.ButtonChange.Name = "ButtonChange"; - this.ButtonChange.Size = new System.Drawing.Size(137, 29); + this.ButtonChange.Size = new System.Drawing.Size(120, 22); this.ButtonChange.TabIndex = 2; this.ButtonChange.Text = "Изменить"; this.ButtonChange.UseVisualStyleBackColor = true; @@ -68,9 +71,10 @@ // // ButtonRemove // - this.ButtonRemove.Location = new System.Drawing.Point(590, 82); + this.ButtonRemove.Location = new System.Drawing.Point(516, 62); + this.ButtonRemove.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.ButtonRemove.Name = "ButtonRemove"; - this.ButtonRemove.Size = new System.Drawing.Size(137, 29); + this.ButtonRemove.Size = new System.Drawing.Size(120, 22); this.ButtonRemove.TabIndex = 3; this.ButtonRemove.Text = "Удалить"; this.ButtonRemove.UseVisualStyleBackColor = true; @@ -78,9 +82,10 @@ // // ButtonUpdate // - this.ButtonUpdate.Location = new System.Drawing.Point(590, 117); + this.ButtonUpdate.Location = new System.Drawing.Point(516, 88); + this.ButtonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.ButtonUpdate.Name = "ButtonUpdate"; - this.ButtonUpdate.Size = new System.Drawing.Size(137, 29); + this.ButtonUpdate.Size = new System.Drawing.Size(120, 22); this.ButtonUpdate.TabIndex = 4; this.ButtonUpdate.Text = "Обновить"; this.ButtonUpdate.UseVisualStyleBackColor = true; @@ -88,16 +93,18 @@ // // FormComponents // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(740, 405); + this.ClientSize = new System.Drawing.Size(648, 304); this.Controls.Add(this.ButtonUpdate); this.Controls.Add(this.ButtonRemove); this.Controls.Add(this.ButtonChange); this.Controls.Add(this.ButtonAdd); this.Controls.Add(this.dataGridView); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); this.Name = "FormComponents"; this.Text = "Компоненты"; + this.Load += new System.EventHandler(this.FormComponents_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.ResumeLayout(false); diff --git a/FishFactory/FishFactory/FormMain.Designer.cs b/FishFactory/FishFactory/FormMain.Designer.cs index 36372f2..dd2824c 100644 --- a/FishFactory/FishFactory/FormMain.Designer.cs +++ b/FishFactory/FishFactory/FormMain.Designer.cs @@ -38,6 +38,10 @@ this.компонентыToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); this.консервыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 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(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); @@ -129,7 +133,8 @@ // this.menuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20); this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.изделияToolStripMenuItem}); + this.изделияToolStripMenuItem, + this.отчетыToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Padding = new System.Windows.Forms.Padding(5, 2, 0, 2); @@ -137,6 +142,37 @@ this.menuStrip1.TabIndex = 6; 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(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.списокКомпонентовToolStripMenuItem_Click_1); + // + // компонентыПоИзделиямToolStripMenuItem + // + this.компонентыПоИзделиямToolStripMenuItem.Name = "компонентыПоИзделиямToolStripMenuItem"; + this.компонентыПоИзделиямToolStripMenuItem.Size = new System.Drawing.Size(218, 22); + this.компонентыПоИзделиямToolStripMenuItem.Text = "Компоненты по изделиям"; + this.компонентыПоИзделиямToolStripMenuItem.Click += new System.EventHandler(this.компонентыПоИзделиямToolStripMenuItem_Click_1); + // + // списокЗаказовToolStripMenuItem + // + this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; + this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(218, 22); + this.списокЗаказовToolStripMenuItem.Text = "Список заказов"; + this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.списокЗаказовToolStripMenuItem_Click_1); + // // FormMain // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -152,6 +188,7 @@ this.MainMenuStrip = this.menuStrip1; this.Name = "FormMain"; this.Text = "Рыбный завод"; + this.Load += new System.EventHandler(this.FormMain_Load); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); @@ -171,5 +208,9 @@ private ToolStripMenuItem компонентыToolStripMenuItem1; private ToolStripMenuItem консервыToolStripMenuItem; private MenuStrip menuStrip1; + private ToolStripMenuItem отчетыToolStripMenuItem; + private ToolStripMenuItem списокКомпонентовToolStripMenuItem; + private ToolStripMenuItem компонентыПоИзделиямToolStripMenuItem; + private ToolStripMenuItem списокЗаказовToolStripMenuItem; } } \ No newline at end of file diff --git a/FishFactory/FishFactory/FormMain.cs b/FishFactory/FishFactory/FormMain.cs index e310451..c31eda2 100644 --- a/FishFactory/FishFactory/FormMain.cs +++ b/FishFactory/FishFactory/FormMain.cs @@ -1,4 +1,5 @@ -using FishFactoryContracts.BindingModels; +using FishFactoryBusinessLogic.BusinessLogic; +using FishFactoryContracts.BindingModels; using FishFactoryContracts.BusinessLogicsContracts; using FishFactoryDataModels.Enums; using FishFactoryListImplement.Models; @@ -21,11 +22,13 @@ namespace FishFactoryView { 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) { @@ -176,5 +179,36 @@ namespace FishFactoryView { LoadData(); } + + private void списокКомпонентовToolStripMenuItem_Click_1(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 компонентыПоИзделиямToolStripMenuItem_Click_1(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportCannedComponents)); + if (service is FormReportCannedComponents form) + { + form.ShowDialog(); + } + } + + private void списокЗаказовToolStripMenuItem_Click_1(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + if (service is FormReportOrders form) + { + form.ShowDialog(); + } + } } } diff --git a/FishFactory/FishFactory/FormReportCannedComponents.Designer.cs b/FishFactory/FishFactory/FormReportCannedComponents.Designer.cs new file mode 100644 index 0000000..f7ce8c3 --- /dev/null +++ b/FishFactory/FishFactory/FormReportCannedComponents.Designer.cs @@ -0,0 +1,122 @@ +namespace FishFactoryView +{ + partial class FormReportCannedComponents + { + /// + /// 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.ColumnCanneds = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnComponent = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.buttonSaveToExcel = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // dataGridView + // + this.dataGridView.AllowUserToAddRows = false; + this.dataGridView.AllowUserToDeleteRows = false; + this.dataGridView.AllowUserToOrderColumns = true; + this.dataGridView.AllowUserToResizeColumns = false; + this.dataGridView.AllowUserToResizeRows = false; + this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.ColumnCanneds, + this.ColumnComponent, + this.ColumnCount}); + this.dataGridView.Dock = System.Windows.Forms.DockStyle.Bottom; + this.dataGridView.Location = new System.Drawing.Point(0, 63); + this.dataGridView.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4); + this.dataGridView.MultiSelect = false; + this.dataGridView.Name = "dataGridView"; + this.dataGridView.ReadOnly = true; + this.dataGridView.RowHeadersVisible = false; + this.dataGridView.RowHeadersWidth = 51; + this.dataGridView.Size = new System.Drawing.Size(704, 680); + this.dataGridView.TabIndex = 0; + // + // ColumnCanneds + // + this.ColumnCanneds.HeaderText = "Консервы"; + this.ColumnCanneds.MinimumWidth = 6; + this.ColumnCanneds.Name = "ColumnCanneds"; + this.ColumnCanneds.ReadOnly = true; + this.ColumnCanneds.Width = 200; + // + // ColumnComponent + // + this.ColumnComponent.HeaderText = "Компоненты"; + this.ColumnComponent.MinimumWidth = 6; + this.ColumnComponent.Name = "ColumnComponent"; + this.ColumnComponent.ReadOnly = true; + this.ColumnComponent.Width = 200; + // + // ColumnCount + // + this.ColumnCount.HeaderText = "Количество"; + this.ColumnCount.MinimumWidth = 6; + this.ColumnCount.Name = "ColumnCount"; + this.ColumnCount.ReadOnly = true; + this.ColumnCount.Width = 125; + // + // buttonSaveToExcel + // + this.buttonSaveToExcel.Location = new System.Drawing.Point(14, 13); + this.buttonSaveToExcel.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4); + this.buttonSaveToExcel.Name = "buttonSaveToExcel"; + this.buttonSaveToExcel.Size = new System.Drawing.Size(213, 36); + this.buttonSaveToExcel.TabIndex = 1; + this.buttonSaveToExcel.Text = "Сохранить в Excel"; + this.buttonSaveToExcel.UseVisualStyleBackColor = true; + this.buttonSaveToExcel.Click += new System.EventHandler(this.ButtonSaveToExcel_Click); + // + // FormReportCannedComponents + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(704, 743); + this.Controls.Add(this.buttonSaveToExcel); + this.Controls.Add(this.dataGridView); + this.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4); + this.Name = "FormReportCannedComponents"; + this.Text = "Компоненты по консервам"; + this.Load += new System.EventHandler(this.FormReportCannedComponents_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.DataGridView dataGridView; + private System.Windows.Forms.Button buttonSaveToExcel; + private DataGridViewTextBoxColumn ColumnCanneds; + private DataGridViewTextBoxColumn ColumnComponent; + private DataGridViewTextBoxColumn ColumnCount; + } +} \ No newline at end of file diff --git a/FishFactory/FishFactory/FormReportCannedComponents.cs b/FishFactory/FishFactory/FormReportCannedComponents.cs new file mode 100644 index 0000000..6c5887a --- /dev/null +++ b/FishFactory/FishFactory/FormReportCannedComponents.cs @@ -0,0 +1,90 @@ +using FishFactoryContracts.BindingModels; +using FishFactoryContracts.BusinessLogicsContracts; +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 FishFactoryView +{ + public partial class FormReportCannedComponents : Form + { + private readonly ILogger _logger; + private readonly IReportLogic _logic; + public FormReportCannedComponents(ILogger + logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormReportCannedComponents_Load(object sender, EventArgs e) + { + try + { + var dict = _logic.GetCannedComponent(); + if (dict != null) + { + dataGridView.Rows.Clear(); + foreach (var elem in dict) + { + dataGridView.Rows.Add(new object[] { elem.ComponentName, +"", "" }); + foreach (var listElem in elem.Canneds) + { + 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.SaveCannedComponentToExcelFile(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/FishFactory/FishFactory/FormReportCannedComponents.resx b/FishFactory/FishFactory/FormReportCannedComponents.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/FishFactory/FishFactory/FormReportCannedComponents.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/FishFactory/FishFactory/FormReportOrders.Designer.cs b/FishFactory/FishFactory/FormReportOrders.Designer.cs new file mode 100644 index 0000000..517e709 --- /dev/null +++ b/FishFactory/FishFactory/FormReportOrders.Designer.cs @@ -0,0 +1,141 @@ +namespace FishFactoryView +{ + 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/FishFactory/FishFactory/FormReportOrders.cs b/FishFactory/FishFactory/FormReportOrders.cs new file mode 100644 index 0000000..51846b6 --- /dev/null +++ b/FishFactory/FishFactory/FormReportOrders.cs @@ -0,0 +1,105 @@ +using FishFactoryContracts.BindingModels; +using FishFactoryContracts.BusinessLogicsContracts; +using FishFactoryView; +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 FishFactoryView +{ + 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(@"C:\Users\Admin\Desktop\RPP_Labs\Lab4\pibd-22_emelyanov_a.s._fishfactory\FishFactory\FishFactory\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 = DateTime.SpecifyKind(dateTimePickerFrom.Value, DateTimeKind.Utc), + DateTo = DateTime.SpecifyKind(dateTimePickerTo.Value, DateTimeKind.Utc) + }); + 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) + { + System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); + 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 = DateTime.SpecifyKind(dateTimePickerFrom.Value, DateTimeKind.Utc), + DateTo = DateTime.SpecifyKind(dateTimePickerTo.Value, DateTimeKind.Utc) + }); + _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); + } + } + } + } +} \ No newline at end of file diff --git a/FishFactory/FishFactory/FormReportOrders.resx b/FishFactory/FishFactory/FormReportOrders.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/FishFactory/FishFactory/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/FishFactory/FishFactory/Program.cs b/FishFactory/FishFactory/Program.cs index d9edc45..4586136 100644 --- a/FishFactory/FishFactory/Program.cs +++ b/FishFactory/FishFactory/Program.cs @@ -1,4 +1,3 @@ -using FishFactoryBusinessLogic.BusinessLogics; using FishFactoryContracts.BusinessLogicsContracts; using FishFactoryContracts.StoragesContracts; using FishFactoryView; @@ -7,6 +6,9 @@ using System; using FishFactoryDatabaseImplement.Implements; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; +using FishFactoryBusinessLogic.BusinessLogic; +using FishFactoryBusinessLogic.OfficePackage; +using FishFactoryBusinessLogic.OfficePackage.Implements; namespace ProjectFishFactory { @@ -41,6 +43,12 @@ namespace ProjectFishFactory services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -48,6 +56,8 @@ namespace ProjectFishFactory services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/FishFactory/FishFactory/ReportOrders.rdlc b/FishFactory/FishFactory/ReportOrders.rdlc new file mode 100644 index 0000000..6eefd05 --- /dev/null +++ b/FishFactory/FishFactory/ReportOrders.rdlc @@ -0,0 +1,529 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 10791c83-cee8-4a38-bbd0-245fc17cefb3 + + + + + + FishFactoryContractsViewModels + /* Local Query */ + + + + Id + System.Int32 + + + DateCreate + System.DateTime + + + CannedName + System.String + + + Sum + System.Decimal + + + + FishFactoryContracts.ViewModels + ReportOrdersViewModel + FishFactoryContracts.ViewModels.ReportOrdersViewModel, FishFactoryContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + + + + + + + true + true + + + + + =Parameters!ReportParameterPeriod.Value + + + + + + + ReportParameterPeriod + 1cm + 1cm + 21cm + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Заказы + + + + + + + 1cm + 21cm + 1 + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + 2.5cm + + + 3.21438cm + + + 8.23317cm + + + 2.5cm + + + + + 0.6cm + + + + + true + true + + + + + Номер + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Дата создания + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Изделие + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Сумма + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.6cm + + + + + true + true + + + + + =Fields!Id.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!DateCreate.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!CannedName.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Sum.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSetOrders + 2.48391cm + 0.55245cm + 1.2cm + 16.44755cm + 2 + + + + + + true + true + + + + + Итого: + + + + + + + 4cm + 12cm + 0.6cm + 2.5cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!Sum.Value, "DataSetOrders") + + + + + + + 4cm + 14.5cm + 0.6cm + 2.5cm + 4 + + + 2pt + 2pt + 2pt + 2pt + + + + 5.72875cm +