From 6eb6cec194ab1026cd82f2f7b80edd454473672d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=9F=D0=BE=D0=BB?= =?UTF-8?q?=D0=B5=D0=B2=D0=BE=D0=B9?= Date: Sun, 12 Mar 2023 22:48:35 +0400 Subject: [PATCH 1/2] =?UTF-8?q?=D0=91=D0=B0=D0=B7=D0=BE=D0=B2=D0=B0=D1=8F?= =?UTF-8?q?=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD?= =?UTF-8?q?=D0=B0=D1=8F=20=E2=84=964:=20=D0=93=D0=BE=D1=82=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0,=20=D0=B2=D0=BE=D0=B7=D0=BC=D0=BE=D0=B6=D0=BD=D1=8B=20?= =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8?= =?UTF-8?q?=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- FlowerShop/FlowerShop/FlowerShop.csproj | 7 + FlowerShop/FlowerShop/FormMain.Designer.cs | 46 +- FlowerShop/FlowerShop/FormMain.cs | 36 +- .../FormReportBouquetComponents.Designer.cs | 113 ++++ .../FlowerShop/FormReportBouquetComponents.cs | 79 +++ .../FormReportBouquetComponents.resx | 63 ++ .../FlowerShop/FormReportOrder.Designer.cs | 137 ++++ FlowerShop/FlowerShop/FormReportOrder.cs | 101 +++ FlowerShop/FlowerShop/FormReportOrder.resx | 60 ++ FlowerShop/FlowerShop/Program.cs | 12 + FlowerShop/FlowerShop/ReportOrders.rdlc | 600 ++++++++++++++++++ .../BusinessLogics/ReportLogic.cs | 107 ++++ .../FlowerShopBusinessLogic.csproj | 2 + .../OfficePackage/AbstractSaveToExcel.cs | 90 +++ .../OfficePackage/AbstractSaveToPdf.cs | 65 ++ .../OfficePackage/AbstractSaveToWord.cs | 46 ++ .../HelperEnums/ExcelStyleInfoType.cs | 9 + .../HelperEnums/PdfParagraphAlignmentType.cs | 9 + .../HelperEnums/WordJustificationType.cs | 8 + .../HelperModels/ExcelCellParameters.cs | 13 + .../OfficePackage/HelperModels/ExcelInfo.cs | 11 + .../HelperModels/ExcelMergeParameters.cs | 9 + .../OfficePackage/HelperModels/PdfInfo.cs | 13 + .../HelperModels/PdfParagraph.cs | 11 + .../HelperModels/PdfRowParameters.cs | 11 + .../OfficePackage/HelperModels/WordInfo.cs | 11 + .../HelperModels/WordParagraph.cs | 8 + .../HelperModels/WordTextProperties.cs | 12 + .../OfficePackage/Implements/SaveToExcel.cs | 314 +++++++++ .../OfficePackage/Implements/SaveToPdf.cs | 102 +++ .../OfficePackage/Implements/SaveToWord.cs | 113 ++++ .../BindingModels/ReportBindingModel.cs | 9 + .../BusinessLogicsContracts/IReportLogic.cs | 18 + .../SearchModels/OrderSearchModel.cs | 2 + .../ReportBouquetComponentViewModel.cs | 10 + .../ViewModels/ReportOrdersViewModel.cs | 11 + .../Implements/OrderStorage.cs | 4 +- .../Implements/OrderStorage.cs | 4 +- .../Implements/OrderStorage.cs | 7 +- 39 files changed, 2267 insertions(+), 16 deletions(-) create mode 100644 FlowerShop/FlowerShop/FormReportBouquetComponents.Designer.cs create mode 100644 FlowerShop/FlowerShop/FormReportBouquetComponents.cs create mode 100644 FlowerShop/FlowerShop/FormReportBouquetComponents.resx create mode 100644 FlowerShop/FlowerShop/FormReportOrder.Designer.cs create mode 100644 FlowerShop/FlowerShop/FormReportOrder.cs create mode 100644 FlowerShop/FlowerShop/FormReportOrder.resx create mode 100644 FlowerShop/FlowerShop/ReportOrders.rdlc create mode 100644 FlowerShop/FlowerShopBusinessLogic/BusinessLogics/ReportLogic.cs create mode 100644 FlowerShop/FlowerShopBusinessLogic/OfficePackage/AbstractSaveToExcel.cs create mode 100644 FlowerShop/FlowerShopBusinessLogic/OfficePackage/AbstractSaveToPdf.cs create mode 100644 FlowerShop/FlowerShopBusinessLogic/OfficePackage/AbstractSaveToWord.cs create mode 100644 FlowerShop/FlowerShopBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs create mode 100644 FlowerShop/FlowerShopBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs create mode 100644 FlowerShop/FlowerShopBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs create mode 100644 FlowerShop/FlowerShopBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs create mode 100644 FlowerShop/FlowerShopBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs create mode 100644 FlowerShop/FlowerShopBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs create mode 100644 FlowerShop/FlowerShopBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs create mode 100644 FlowerShop/FlowerShopBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs create mode 100644 FlowerShop/FlowerShopBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs create mode 100644 FlowerShop/FlowerShopBusinessLogic/OfficePackage/HelperModels/WordInfo.cs create mode 100644 FlowerShop/FlowerShopBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs create mode 100644 FlowerShop/FlowerShopBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs create mode 100644 FlowerShop/FlowerShopBusinessLogic/OfficePackage/Implements/SaveToExcel.cs create mode 100644 FlowerShop/FlowerShopBusinessLogic/OfficePackage/Implements/SaveToPdf.cs create mode 100644 FlowerShop/FlowerShopBusinessLogic/OfficePackage/Implements/SaveToWord.cs create mode 100644 FlowerShop/FlowerShopContracts/BindingModels/ReportBindingModel.cs create mode 100644 FlowerShop/FlowerShopContracts/BusinessLogicsContracts/IReportLogic.cs create mode 100644 FlowerShop/FlowerShopContracts/ViewModels/ReportBouquetComponentViewModel.cs create mode 100644 FlowerShop/FlowerShopContracts/ViewModels/ReportOrdersViewModel.cs diff --git a/FlowerShop/FlowerShop/FlowerShop.csproj b/FlowerShop/FlowerShop/FlowerShop.csproj index ad47413..2e0a216 100644 --- a/FlowerShop/FlowerShop/FlowerShop.csproj +++ b/FlowerShop/FlowerShop/FlowerShop.csproj @@ -15,6 +15,7 @@ + @@ -26,4 +27,10 @@ + + + Always + + + \ No newline at end of file diff --git a/FlowerShop/FlowerShop/FormMain.Designer.cs b/FlowerShop/FlowerShop/FormMain.Designer.cs index f962aca..e2c3afa 100644 --- a/FlowerShop/FlowerShop/FormMain.Designer.cs +++ b/FlowerShop/FlowerShop/FormMain.Designer.cs @@ -38,6 +38,10 @@ this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.изделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.reportsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.listOfBouquetsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.componentsByBouquetsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.listOfOrdersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.menuStrip.SuspendLayout(); this.SuspendLayout(); @@ -112,7 +116,8 @@ // this.menuStrip.ImageScalingSize = new System.Drawing.Size(24, 24); this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.справочникиToolStripMenuItem}); + this.справочникиToolStripMenuItem, + this.reportsToolStripMenuItem}); this.menuStrip.Location = new System.Drawing.Point(0, 0); this.menuStrip.Name = "menuStrip"; this.menuStrip.Padding = new System.Windows.Forms.Padding(4, 1, 0, 1); @@ -132,17 +137,48 @@ // компонентыToolStripMenuItem // this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem"; - this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(145, 22); this.компонентыToolStripMenuItem.Text = "Компоненты"; this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.componentsToolStripMenuItem_Click); // // изделияToolStripMenuItem // this.изделияToolStripMenuItem.Name = "изделияToolStripMenuItem"; - this.изделияToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.изделияToolStripMenuItem.Size = new System.Drawing.Size(145, 22); this.изделияToolStripMenuItem.Text = "Букеты"; this.изделияToolStripMenuItem.Click += new System.EventHandler(this.bouquetsToolStripMenuItem_Click); // + // reportsToolStripMenuItem + // + this.reportsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.listOfBouquetsToolStripMenuItem, + this.componentsByBouquetsToolStripMenuItem, + this.listOfOrdersToolStripMenuItem}); + this.reportsToolStripMenuItem.Name = "reportsToolStripMenuItem"; + this.reportsToolStripMenuItem.Size = new System.Drawing.Size(60, 22); + this.reportsToolStripMenuItem.Text = "Отчёты"; + // + // listOfBouquetsToolStripMenuItem + // + this.listOfBouquetsToolStripMenuItem.Name = "listOfBouquetsToolStripMenuItem"; + this.listOfBouquetsToolStripMenuItem.Size = new System.Drawing.Size(210, 22); + this.listOfBouquetsToolStripMenuItem.Text = "Список букетов"; + this.listOfBouquetsToolStripMenuItem.Click += new System.EventHandler(this.listOfBouquetsToolStripMenuItem_Click); + // + // componentsByBouquetsToolStripMenuItem + // + this.componentsByBouquetsToolStripMenuItem.Name = "componentsByBouquetsToolStripMenuItem"; + this.componentsByBouquetsToolStripMenuItem.Size = new System.Drawing.Size(210, 22); + this.componentsByBouquetsToolStripMenuItem.Text = "Компоненты по букетам"; + this.componentsByBouquetsToolStripMenuItem.Click += new System.EventHandler(this.componentsByBouquetsToolStripMenuItem_Click); + // + // listOfOrdersToolStripMenuItem + // + this.listOfOrdersToolStripMenuItem.Name = "listOfOrdersToolStripMenuItem"; + this.listOfOrdersToolStripMenuItem.Size = new System.Drawing.Size(210, 22); + this.listOfOrdersToolStripMenuItem.Text = "Список заказов"; + this.listOfOrdersToolStripMenuItem.Click += new System.EventHandler(this.listOfOrdersToolStripMenuItem_Click); + // // FormMain // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -180,5 +216,9 @@ private ToolStripMenuItem компонентыToolStripMenuItem; private ToolStripMenuItem изделияToolStripMenuItem; private Button buttonReady; + private ToolStripMenuItem reportsToolStripMenuItem; + private ToolStripMenuItem listOfBouquetsToolStripMenuItem; + private ToolStripMenuItem componentsByBouquetsToolStripMenuItem; + private ToolStripMenuItem listOfOrdersToolStripMenuItem; } } \ No newline at end of file diff --git a/FlowerShop/FlowerShop/FormMain.cs b/FlowerShop/FlowerShop/FormMain.cs index 63f690d..029452b 100644 --- a/FlowerShop/FlowerShop/FormMain.cs +++ b/FlowerShop/FlowerShop/FormMain.cs @@ -1,6 +1,6 @@ -using FlowerShopContracts.BindingModels; +using FlowerShopBusinessLogic.BusinessLogics; +using FlowerShopContracts.BindingModels; using FlowerShopContracts.BusinessLogicsContracts; -using FlowerShopDataModels.Enums; using Microsoft.Extensions.Logging; namespace FlowerShop @@ -9,12 +9,14 @@ namespace FlowerShop { private readonly ILogger _logger; private readonly IOrderLogic _orderLogic; + private readonly IReportLogic _reportLogic; - public FormMain(ILogger logger, IOrderLogic orderLogic) + public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic) { InitializeComponent(); _logger = logger; _orderLogic = orderLogic; + _reportLogic = reportLogic; } private void MainForm_Load(object sender, EventArgs e) @@ -154,5 +156,33 @@ namespace FlowerShop { LoadData(); } + + private void listOfBouquetsToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SaveBouquetsToWordFile(new ReportBindingModel { FileName = dialog.FileName }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + + private void componentsByBouquetsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportBouquetComponents)); + if (service is FormReportBouquetComponents form) + { + form.ShowDialog(); + } + } + + private void listOfOrdersToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportOrder)); + if (service is FormReportOrder form) + { + form.ShowDialog(); + } + } } } diff --git a/FlowerShop/FlowerShop/FormReportBouquetComponents.Designer.cs b/FlowerShop/FlowerShop/FormReportBouquetComponents.Designer.cs new file mode 100644 index 0000000..60aa2f5 --- /dev/null +++ b/FlowerShop/FlowerShop/FormReportBouquetComponents.Designer.cs @@ -0,0 +1,113 @@ +namespace FlowerShop +{ + partial class FormReportBouquetComponents + { + /// + /// 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.buttonSaveToExcel = new System.Windows.Forms.Button(); + this.Bouquet = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Component = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // dataGridView + // + this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.Bouquet, + this.Component, + this.Count}); + this.dataGridView.Location = new System.Drawing.Point(10, 11); + 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(679, 283); + this.dataGridView.TabIndex = 0; + // + // buttonSaveToExcel + // + this.buttonSaveToExcel.Location = new System.Drawing.Point(251, 298); + this.buttonSaveToExcel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonSaveToExcel.Name = "buttonSaveToExcel"; + this.buttonSaveToExcel.Size = new System.Drawing.Size(192, 29); + this.buttonSaveToExcel.TabIndex = 1; + this.buttonSaveToExcel.Text = "Сохранить в Excel"; + this.buttonSaveToExcel.UseVisualStyleBackColor = true; + this.buttonSaveToExcel.Click += new System.EventHandler(this.buttonSaveToExcel_Click); + // + // Bouquet + // + this.Bouquet.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.Bouquet.HeaderText = "Букет"; + this.Bouquet.MinimumWidth = 6; + this.Bouquet.Name = "Bouquet"; + // + // Component + // + this.Component.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.Component.HeaderText = "Компонент"; + this.Component.MinimumWidth = 6; + this.Component.Name = "Component"; + // + // Count + // + this.Count.HeaderText = "Количество"; + this.Count.MinimumWidth = 6; + this.Count.Name = "Count"; + this.Count.Width = 125; + // + // FormReportBouquetComponents + // + 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.buttonSaveToExcel); + this.Controls.Add(this.dataGridView); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.Name = "FormReportBouquetComponents"; + this.Text = "Компоненты по букетам"; + this.Load += new System.EventHandler(this.FormReportBouquetComponents_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private DataGridView dataGridView; + private Button buttonSaveToExcel; + private DataGridViewTextBoxColumn Bouquet; + private DataGridViewTextBoxColumn Component; + private DataGridViewTextBoxColumn Count; + } +} \ No newline at end of file diff --git a/FlowerShop/FlowerShop/FormReportBouquetComponents.cs b/FlowerShop/FlowerShop/FormReportBouquetComponents.cs new file mode 100644 index 0000000..778e4ad --- /dev/null +++ b/FlowerShop/FlowerShop/FormReportBouquetComponents.cs @@ -0,0 +1,79 @@ +using FlowerShopContracts.BindingModels; +using FlowerShopContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; + +namespace FlowerShop +{ + public partial class FormReportBouquetComponents : Form + { + private readonly ILogger _logger; + private readonly IReportLogic _logic; + + public FormReportBouquetComponents(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormReportBouquetComponents_Load(object sender, EventArgs e) + { + try + { + var dict = _logic.GetBouquetComponents(); + if (dict != null) + { + dataGridView.Rows.Clear(); + foreach (var elem in dict) + { + dataGridView.Rows.Add(new object[] { elem.BouquetName, "", "" }); + + foreach (var listElem in elem.Components) + { + dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 }); + } + + dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount }); + dataGridView.Rows.Add(Array.Empty()); + } + } + _logger.LogInformation("Loading list of bouquets by components"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error during loading list of bouquets by components"); + + 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.SaveBouquetComponentToExcelFile(new ReportBindingModel + { + FileName = dialog.FileName + }); + + _logger.LogInformation("Saving list of bouquets by components"); + + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error saving list of bouquets by components"); + + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } +} diff --git a/FlowerShop/FlowerShop/FormReportBouquetComponents.resx b/FlowerShop/FlowerShop/FormReportBouquetComponents.resx new file mode 100644 index 0000000..91a3d25 --- /dev/null +++ b/FlowerShop/FlowerShop/FormReportBouquetComponents.resx @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + \ No newline at end of file diff --git a/FlowerShop/FlowerShop/FormReportOrder.Designer.cs b/FlowerShop/FlowerShop/FormReportOrder.Designer.cs new file mode 100644 index 0000000..93c495a --- /dev/null +++ b/FlowerShop/FlowerShop/FormReportOrder.Designer.cs @@ -0,0 +1,137 @@ +namespace FlowerShop +{ + partial class FormReportOrder + { + /// + /// 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.buttonCreateToPdf = new System.Windows.Forms.Button(); + this.buttonCreateReport = new System.Windows.Forms.Button(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.dateTimePickerEnd = new System.Windows.Forms.DateTimePicker(); + this.dateTimePickerStart = new System.Windows.Forms.DateTimePicker(); + this.panel.SuspendLayout(); + this.SuspendLayout(); + // + // panel + // + this.panel.Controls.Add(this.buttonCreateToPdf); + this.panel.Controls.Add(this.buttonCreateReport); + this.panel.Controls.Add(this.label2); + this.panel.Controls.Add(this.label1); + this.panel.Controls.Add(this.dateTimePickerEnd); + this.panel.Controls.Add(this.dateTimePickerStart); + 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(3, 2, 3, 2); + this.panel.Name = "panel"; + this.panel.Size = new System.Drawing.Size(861, 60); + this.panel.TabIndex = 0; + // + // buttonCreateToPdf + // + this.buttonCreateToPdf.Location = new System.Drawing.Point(684, 11); + this.buttonCreateToPdf.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonCreateToPdf.Name = "buttonCreateToPdf"; + this.buttonCreateToPdf.Size = new System.Drawing.Size(166, 38); + this.buttonCreateToPdf.TabIndex = 5; + this.buttonCreateToPdf.Text = "PDF"; + this.buttonCreateToPdf.UseVisualStyleBackColor = true; + this.buttonCreateToPdf.Click += new System.EventHandler(this.buttonCreateToPdf_Click); + // + // buttonCreateReport + // + this.buttonCreateReport.Location = new System.Drawing.Point(491, 11); + this.buttonCreateReport.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.buttonCreateReport.Name = "buttonCreateReport"; + this.buttonCreateReport.Size = new System.Drawing.Size(166, 38); + this.buttonCreateReport.TabIndex = 4; + this.buttonCreateReport.Text = "Сформировать"; + this.buttonCreateReport.UseVisualStyleBackColor = true; + this.buttonCreateReport.Click += new System.EventHandler(this.buttonCreateReport_Click); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(323, 4); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(44, 15); + this.label2.TabIndex = 3; + this.label2.Text = "Конец:"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(76, 4); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(52, 15); + this.label1.TabIndex = 2; + this.label1.Text = "Начало:"; + // + // dateTimePickerEnd + // + this.dateTimePickerEnd.Location = new System.Drawing.Point(264, 26); + this.dateTimePickerEnd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.dateTimePickerEnd.Name = "dateTimePickerEnd"; + this.dateTimePickerEnd.Size = new System.Drawing.Size(164, 23); + this.dateTimePickerEnd.TabIndex = 1; + // + // dateTimePickerStart + // + this.dateTimePickerStart.Location = new System.Drawing.Point(23, 26); + this.dateTimePickerStart.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.dateTimePickerStart.Name = "dateTimePickerStart"; + this.dateTimePickerStart.Size = new System.Drawing.Size(164, 23); + this.dateTimePickerStart.TabIndex = 0; + // + // FormReportOrder + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(861, 338); + this.Controls.Add(this.panel); + this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); + this.Name = "FormReportOrder"; + this.Text = "Заказы"; + this.panel.ResumeLayout(false); + this.panel.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private Panel panel; + private DateTimePicker dateTimePickerEnd; + private DateTimePicker dateTimePickerStart; + private Button buttonCreateToPdf; + private Button buttonCreateReport; + private Label label2; + private Label label1; + } +} \ No newline at end of file diff --git a/FlowerShop/FlowerShop/FormReportOrder.cs b/FlowerShop/FlowerShop/FormReportOrder.cs new file mode 100644 index 0000000..ab3c6de --- /dev/null +++ b/FlowerShop/FlowerShop/FormReportOrder.cs @@ -0,0 +1,101 @@ +using FlowerShopContracts.BindingModels; +using FlowerShopContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; +using Microsoft.Reporting.WinForms; + +namespace FlowerShop +{ + public partial class FormReportOrder : Form + { + private readonly ReportViewer reportViewer; + private readonly ILogger _logger; + private readonly IReportLogic _logic; + + public FormReportOrder(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 buttonCreateReport_Click(object sender, EventArgs e) + { + if (dateTimePickerStart.Value.Date >= dateTimePickerEnd.Value.Date) + { + MessageBox.Show("Дата начала должна быть меньше даты окончания","Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + try + { + var dataSource = _logic.GetOrders(new ReportBindingModel + { + DateFrom = dateTimePickerStart.Value, + DateTo = dateTimePickerEnd.Value + }); + + var source = new ReportDataSource("DataSetOrders", dataSource); + + reportViewer.LocalReport.DataSources.Clear(); + reportViewer.LocalReport.DataSources.Add(source); + + var parameters = new[] { new ReportParameter("ReportParameterPeriod", $"c { dateTimePickerStart.Value.ToShortDateString()} по {dateTimePickerEnd.Value.ToShortDateString()}") }; + + reportViewer.LocalReport.SetParameters(parameters); + reportViewer.RefreshReport(); + + _logger.LogInformation("Loading list of order within {From}-{To}", dateTimePickerStart.Value.ToShortDateString(), dateTimePickerEnd.Value.ToShortDateString()); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error during loading list of oreder within period"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + + } + + private void buttonCreateToPdf_Click(object sender, EventArgs e) + { + if (dateTimePickerStart.Value.Date >= dateTimePickerEnd.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 = dateTimePickerStart.Value, + DateTo = dateTimePickerEnd.Value + }); + _logger.LogInformation("Saving list of orders within {From} -{To}", dateTimePickerStart.Value.ToShortDateString(), dateTimePickerEnd.Value.ToShortDateString()); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error during saving list of orders within period"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + + } +} + diff --git a/FlowerShop/FlowerShop/FormReportOrder.resx b/FlowerShop/FlowerShop/FormReportOrder.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/FlowerShop/FlowerShop/FormReportOrder.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/FlowerShop/FlowerShop/Program.cs b/FlowerShop/FlowerShop/Program.cs index 06f6572..870af77 100644 --- a/FlowerShop/FlowerShop/Program.cs +++ b/FlowerShop/FlowerShop/Program.cs @@ -1,10 +1,13 @@ using FlowerShopContracts.StoragesContracts; +using FlowerShopBusinessLogic.OfficePackage; +using FlowerShopBusinessLogic.OfficePackage.Implements; using Microsoft.Extensions.DependencyInjection; using FlowerShopDatabaseImplement.Implements; using FlowerShopBusinessLogic.BusinessLogics; using FlowerShopContracts.BusinessLogicsContracts; using NLog.Extensions.Logging; using Microsoft.Extensions.Logging; +using LawFirmBusinessLogic.OfficePackage.Implements; namespace FlowerShop { @@ -32,9 +35,16 @@ namespace FlowerShop services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -42,6 +52,8 @@ namespace FlowerShop services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/FlowerShop/FlowerShop/ReportOrders.rdlc b/FlowerShop/FlowerShop/ReportOrders.rdlc new file mode 100644 index 0000000..7cb822f --- /dev/null +++ b/FlowerShop/FlowerShop/ReportOrders.rdlc @@ -0,0 +1,600 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 10791c83-cee8-4a38-bbd0-245fc17cefb3 + + + + + + FlowerShopContractsViewModels + /* Local Query */ + + + + Id + System.Int32 + + + DateCreate + System.DateTime + + + BouquetName + System.String + + + Sum + System.Decimal + + + Status + System.String + + + + FlowerShopContracts.ViewModels + ReportOrdersViewModel + FlowerShopContracts.ViewModels.ReportOrdersViewModel, FlowerShopContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + + + + + + + true + true + + + + + =Parameters!ReportParameterPeriod.Value + + + + + + + ReportParameterPeriod + 1cm + 1cm + 21cm + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Заказы + + + + + + + 1cm + 21cm + 1 + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + 2.5cm + + + 3.21438cm + + + 8.23317cm + + + 2.5cm + + + 2.5cm + + + + + 0.6cm + + + + + true + true + + + + + Номер + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Дата создания + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Букет + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Сумма + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Статус + + + + + + 2pt + 2pt + 2pt + 2pt + + + true + + + + + + 0.6cm + + + + + true + true + + + + + =Fields!Id.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!DateCreate.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!BouquetName.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Sum.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Status.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSetOrders + 2.48391cm + 0.55245cm + 1.2cm + 18.94755cm + 2 + + + + + + true + true + + + + + Итого: + + + + + + + 4cm + 12cm + 0.6cm + 2.5cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!Sum.Value, "DataSetOrders") + + + + + + + 4cm + 14.5cm + 0.6cm + 2.5cm + 4 + + + 2pt + 2pt + 2pt + 2pt + + + + 5.72875cm +