From 4e70e593b61c27dcc07417a46074a24278fac763 Mon Sep 17 00:00:00 2001 From: gg12 darfren Date: Sun, 24 Mar 2024 13:36:55 +0400 Subject: [PATCH 1/6] =?UTF-8?q?=D0=BF=D1=84=D1=84=D1=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- IceCreamShop/IceCreamShop/IceCreamShop.csproj | 10 +- .../IceCreamShop/MainForm.Designer.cs | 82 ++- IceCreamShop/IceCreamShop/MainForm.cs | 44 +- IceCreamShop/IceCreamShop/Program.cs | 8 + .../ReportIceCreamComponentForm.Designer.cs | 99 +++ .../ReportIceCreamComponentForm.cs | 95 +++ .../ReportIceCreamComponentForm.resx | 129 ++++ IceCreamShop/IceCreamShop/ReportOrders.rdlc | 600 ++++++++++++++++++ .../IceCreamShop/ReportOrdersForm.Designer.cs | 145 +++++ IceCreamShop/IceCreamShop/ReportOrdersForm.cs | 107 ++++ .../IceCreamShop/ReportOrdersForm.resx | 120 ++++ .../BusinessLogic/ReportLogic.cs | 107 ++++ .../IceCreamShopBusinessLogic.csproj | 5 +- .../OfficePackage/AbstractSaveToExcel.cs | 83 +++ .../OfficePackage/AbstractSaveToPdf.cs | 63 ++ .../OfficePackage/AbstractSaveToWord.cs | 48 ++ .../HelperEnums/ExcelStyleInfoType.cs | 15 + .../HelperEnums/PdfParagraphAlignmentType.cs | 16 + .../HelperEnums/WordJustificationType.cs | 14 + .../HelperModels/ExcelCellParameters.cs | 18 + .../OfficePackage/HelperModels/ExcelInfo.cs | 21 + .../HelperModels/ExcelMergeParameters.cs | 15 + .../OfficePackage/HelperModels/PdfInfo.cs | 18 + .../HelperModels/PdfParagraph.cs | 16 + .../HelperModels/PdfRowParameters.cs | 17 + .../OfficePackage/HelperModels/WordInfo.cs | 16 + .../HelperModels/WordParagraph.cs | 14 + .../HelperModels/WordTextProperties.cs | 16 + .../OfficePackage/Implements/SaveToExcel.cs | 339 ++++++++++ .../OfficePackage/Implements/SaveToPdf.cs | 103 +++ .../OfficePackage/Implements/SaveToWord.cs | 121 ++++ .../BindingModels/ReportBindingModel.cs | 16 + .../BusinessLogicsContracts/IReportLogic.cs | 19 + .../IceCreamShopContracts.csproj | 2 +- .../SearchModels/OrderSearchModel.cs | 2 + .../ReportIceCreamComponentViewModel.cs | 16 + .../ViewModels/ReportOrdersViewModel.cs | 19 + .../IceCreamShopDataModels.csproj | 2 +- .../IceCreamShopDatabaseImplement.csproj | 8 +- .../Implements/OrderStorage.cs | 17 +- ... 20240324075315_InitialCreate.Designer.cs} | 4 +- ...ate.cs => 20240324075315_InitialCreate.cs} | 0 .../IceCreamShopDataBaseModelSnapshot.cs | 2 +- .../IceCreamShopFileImplement.csproj | 2 +- .../IceCreamShopListImplement.csproj | 2 +- 45 files changed, 2573 insertions(+), 42 deletions(-) create mode 100644 IceCreamShop/IceCreamShop/ReportIceCreamComponentForm.Designer.cs create mode 100644 IceCreamShop/IceCreamShop/ReportIceCreamComponentForm.cs create mode 100644 IceCreamShop/IceCreamShop/ReportIceCreamComponentForm.resx create mode 100644 IceCreamShop/IceCreamShop/ReportOrders.rdlc create mode 100644 IceCreamShop/IceCreamShop/ReportOrdersForm.Designer.cs create mode 100644 IceCreamShop/IceCreamShop/ReportOrdersForm.cs create mode 100644 IceCreamShop/IceCreamShop/ReportOrdersForm.resx create mode 100644 IceCreamShop/IceCreamShopBusinessLogic/BusinessLogic/ReportLogic.cs create mode 100644 IceCreamShop/IceCreamShopBusinessLogic/OfficePackage/AbstractSaveToExcel.cs create mode 100644 IceCreamShop/IceCreamShopBusinessLogic/OfficePackage/AbstractSaveToPdf.cs create mode 100644 IceCreamShop/IceCreamShopBusinessLogic/OfficePackage/AbstractSaveToWord.cs create mode 100644 IceCreamShop/IceCreamShopBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs create mode 100644 IceCreamShop/IceCreamShopBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs create mode 100644 IceCreamShop/IceCreamShopBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs create mode 100644 IceCreamShop/IceCreamShopBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs create mode 100644 IceCreamShop/IceCreamShopBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs create mode 100644 IceCreamShop/IceCreamShopBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs create mode 100644 IceCreamShop/IceCreamShopBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs create mode 100644 IceCreamShop/IceCreamShopBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs create mode 100644 IceCreamShop/IceCreamShopBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs create mode 100644 IceCreamShop/IceCreamShopBusinessLogic/OfficePackage/HelperModels/WordInfo.cs create mode 100644 IceCreamShop/IceCreamShopBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs create mode 100644 IceCreamShop/IceCreamShopBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs create mode 100644 IceCreamShop/IceCreamShopBusinessLogic/OfficePackage/Implements/SaveToExcel.cs create mode 100644 IceCreamShop/IceCreamShopBusinessLogic/OfficePackage/Implements/SaveToPdf.cs create mode 100644 IceCreamShop/IceCreamShopBusinessLogic/OfficePackage/Implements/SaveToWord.cs create mode 100644 IceCreamShop/IceCreamShopContracts/BindingModels/ReportBindingModel.cs create mode 100644 IceCreamShop/IceCreamShopContracts/BusinessLogicsContracts/IReportLogic.cs create mode 100644 IceCreamShop/IceCreamShopContracts/ViewModels/ReportIceCreamComponentViewModel.cs create mode 100644 IceCreamShop/IceCreamShopContracts/ViewModels/ReportOrdersViewModel.cs rename IceCreamShop/IceCreamShopDatabaseImplement/Migrations/{20240318125446_InitialCreate.Designer.cs => 20240324075315_InitialCreate.Designer.cs} (98%) rename IceCreamShop/IceCreamShopDatabaseImplement/Migrations/{20240318125446_InitialCreate.cs => 20240324075315_InitialCreate.cs} (100%) diff --git a/IceCreamShop/IceCreamShop/IceCreamShop.csproj b/IceCreamShop/IceCreamShop/IceCreamShop.csproj index 0ca01d7..37d0c43 100644 --- a/IceCreamShop/IceCreamShop/IceCreamShop.csproj +++ b/IceCreamShop/IceCreamShop/IceCreamShop.csproj @@ -2,20 +2,22 @@ WinExe - net8.0-windows + net6.0-windows7.0 enable true enable - + + all runtime; build; native; contentfiles; analyzers; buildtransitive + @@ -25,4 +27,8 @@ + + + + \ No newline at end of file diff --git a/IceCreamShop/IceCreamShop/MainForm.Designer.cs b/IceCreamShop/IceCreamShop/MainForm.Designer.cs index a42cf5e..cd7a641 100644 --- a/IceCreamShop/IceCreamShop/MainForm.Designer.cs +++ b/IceCreamShop/IceCreamShop/MainForm.Designer.cs @@ -32,6 +32,10 @@ ToolStripMenu = new ToolStripMenuItem(); КомпонентыStripMenuItem = new ToolStripMenuItem(); МороженноеStripMenuItem = new ToolStripMenuItem(); + отчетыToolStripMenuItem = new ToolStripMenuItem(); + списокКомпонентовToolStripMenuItem = new ToolStripMenuItem(); + компонентыПоМороженнымToolStripMenuItem = new ToolStripMenuItem(); + списокЗаказовToolStripMenuItem = new ToolStripMenuItem(); DataGridView = new DataGridView(); CreateOrderButton = new Button(); TakeInWorkButton = new Button(); @@ -45,10 +49,11 @@ // menuStrip1 // menuStrip1.ImageScalingSize = new Size(20, 20); - menuStrip1.Items.AddRange(new ToolStripItem[] { ToolStripMenu }); + menuStrip1.Items.AddRange(new ToolStripItem[] { ToolStripMenu, отчетыToolStripMenuItem }); menuStrip1.Location = new Point(0, 0); menuStrip1.Name = "menuStrip1"; - menuStrip1.Size = new Size(1296, 28); + menuStrip1.Padding = new Padding(5, 2, 0, 2); + menuStrip1.Size = new Size(1134, 24); menuStrip1.TabIndex = 0; menuStrip1.Text = "menuStrip1"; // @@ -56,37 +61,67 @@ // ToolStripMenu.DropDownItems.AddRange(new ToolStripItem[] { КомпонентыStripMenuItem, МороженноеStripMenuItem }); ToolStripMenu.Name = "ToolStripMenu"; - ToolStripMenu.Size = new Size(117, 24); + ToolStripMenu.Size = new Size(94, 20); ToolStripMenu.Text = "Справочники"; // // КомпонентыStripMenuItem // КомпонентыStripMenuItem.Name = "КомпонентыStripMenuItem"; - КомпонентыStripMenuItem.Size = new Size(186, 26); + КомпонентыStripMenuItem.Size = new Size(148, 22); КомпонентыStripMenuItem.Text = "Компоненты"; КомпонентыStripMenuItem.Click += КомпонентыStripMenuItem_Click; // // МороженноеStripMenuItem // МороженноеStripMenuItem.Name = "МороженноеStripMenuItem"; - МороженноеStripMenuItem.Size = new Size(186, 26); + МороженноеStripMenuItem.Size = new Size(148, 22); МороженноеStripMenuItem.Text = "Мороженное"; МороженноеStripMenuItem.Click += МороженноеStripMenuItem_Click; // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокКомпонентовToolStripMenuItem, компонентыПоМороженнымToolStripMenuItem, списокЗаказовToolStripMenuItem }); + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(60, 20); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // списокКомпонентовToolStripMenuItem + // + списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem"; + списокКомпонентовToolStripMenuItem.Size = new Size(242, 22); + списокКомпонентовToolStripMenuItem.Text = "Список компонентов"; + списокКомпонентовToolStripMenuItem.Click += списокКомпонентовToolStripMenuItem_Click; + // + // компонентыПоМороженнымToolStripMenuItem + // + компонентыПоМороженнымToolStripMenuItem.Name = "компонентыПоМороженнымToolStripMenuItem"; + компонентыПоМороженнымToolStripMenuItem.Size = new Size(242, 22); + компонентыПоМороженнымToolStripMenuItem.Text = "Компоненты по мороженным"; + компонентыПоМороженнымToolStripMenuItem.Click += компонентыПоМороженнымToolStripMenuItem_Click; + // + // списокЗаказовToolStripMenuItem + // + списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; + списокЗаказовToolStripMenuItem.Size = new Size(242, 22); + списокЗаказовToolStripMenuItem.Text = "Список заказов"; + списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click; + // // DataGridView // DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - DataGridView.Location = new Point(12, 31); + DataGridView.Location = new Point(10, 23); + DataGridView.Margin = new Padding(3, 2, 3, 2); DataGridView.Name = "DataGridView"; DataGridView.RowHeadersWidth = 51; - DataGridView.Size = new Size(1007, 407); + DataGridView.Size = new Size(881, 305); DataGridView.TabIndex = 1; // // CreateOrderButton // - CreateOrderButton.Location = new Point(1025, 31); + CreateOrderButton.Location = new Point(897, 23); + CreateOrderButton.Margin = new Padding(3, 2, 3, 2); CreateOrderButton.Name = "CreateOrderButton"; - CreateOrderButton.Size = new Size(259, 29); + CreateOrderButton.Size = new Size(227, 22); CreateOrderButton.TabIndex = 2; CreateOrderButton.Text = "Создать заказ"; CreateOrderButton.UseVisualStyleBackColor = true; @@ -94,9 +129,10 @@ // // TakeInWorkButton // - TakeInWorkButton.Location = new Point(1025, 66); + TakeInWorkButton.Location = new Point(897, 50); + TakeInWorkButton.Margin = new Padding(3, 2, 3, 2); TakeInWorkButton.Name = "TakeInWorkButton"; - TakeInWorkButton.Size = new Size(259, 29); + TakeInWorkButton.Size = new Size(227, 22); TakeInWorkButton.TabIndex = 3; TakeInWorkButton.Text = "Отдать заказ в работу"; TakeInWorkButton.UseVisualStyleBackColor = true; @@ -104,9 +140,10 @@ // // ReadyButton // - ReadyButton.Location = new Point(1025, 101); + ReadyButton.Location = new Point(897, 76); + ReadyButton.Margin = new Padding(3, 2, 3, 2); ReadyButton.Name = "ReadyButton"; - ReadyButton.Size = new Size(259, 29); + ReadyButton.Size = new Size(227, 22); ReadyButton.TabIndex = 4; ReadyButton.Text = "Заказ готов"; ReadyButton.UseVisualStyleBackColor = true; @@ -114,9 +151,10 @@ // // IssuedButton // - IssuedButton.Location = new Point(1025, 136); + IssuedButton.Location = new Point(897, 102); + IssuedButton.Margin = new Padding(3, 2, 3, 2); IssuedButton.Name = "IssuedButton"; - IssuedButton.Size = new Size(259, 29); + IssuedButton.Size = new Size(227, 22); IssuedButton.TabIndex = 5; IssuedButton.Text = "Заказ выдан"; IssuedButton.UseVisualStyleBackColor = true; @@ -124,9 +162,10 @@ // // RefreshButton // - RefreshButton.Location = new Point(1025, 171); + RefreshButton.Location = new Point(897, 128); + RefreshButton.Margin = new Padding(3, 2, 3, 2); RefreshButton.Name = "RefreshButton"; - RefreshButton.Size = new Size(259, 29); + RefreshButton.Size = new Size(227, 22); RefreshButton.TabIndex = 6; RefreshButton.Text = "Обновить"; RefreshButton.UseVisualStyleBackColor = true; @@ -134,9 +173,9 @@ // // MainForm // - AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1296, 450); + ClientSize = new Size(1134, 338); Controls.Add(RefreshButton); Controls.Add(IssuedButton); Controls.Add(ReadyButton); @@ -145,6 +184,7 @@ Controls.Add(DataGridView); Controls.Add(menuStrip1); MainMenuStrip = menuStrip1; + Margin = new Padding(3, 2, 3, 2); Name = "MainForm"; Text = "Форма главная"; Load += MainForm_Load; @@ -167,5 +207,9 @@ private Button ReadyButton; private Button IssuedButton; private Button RefreshButton; + private ToolStripMenuItem отчетыToolStripMenuItem; + private ToolStripMenuItem списокКомпонентовToolStripMenuItem; + private ToolStripMenuItem компонентыПоМороженнымToolStripMenuItem; + private ToolStripMenuItem списокЗаказовToolStripMenuItem; } } \ No newline at end of file diff --git a/IceCreamShop/IceCreamShop/MainForm.cs b/IceCreamShop/IceCreamShop/MainForm.cs index 600e794..25e8dfc 100644 --- a/IceCreamShop/IceCreamShop/MainForm.cs +++ b/IceCreamShop/IceCreamShop/MainForm.cs @@ -1,4 +1,5 @@ -using IceCreamShopContracts.BindingModels; +using IceCreamShopBusinessLogic.BusinessLogic; +using IceCreamShopContracts.BindingModels; using IceCreamShopContracts.BusinessLogicsContracts; using IceCreamShopDataModels; using IceCreamShopDataModels.Enums; @@ -19,11 +20,13 @@ namespace IceCreamShop { private readonly ILogger _logger; private readonly IOrderLogic _orderLogic; - public MainForm(ILogger logger, IOrderLogic orderLogic) + private readonly IReportLogic _reportLogic; + public MainForm(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic) { InitializeComponent(); _logger = logger; _orderLogic = orderLogic; + _reportLogic = reportLogic; } private void КомпонентыStripMenuItem_Click(object sender, EventArgs e) @@ -180,5 +183,42 @@ Program.ServiceProvider?.GetService(typeof(OrderForm)); { LoadData(); } + + private void списокКомпонентовToolStripMenuItem_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 компонентыПоМороженнымToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = +Program.ServiceProvider?.GetService(typeof(ReportIceCreamComponentForm)); + if (service is ReportIceCreamComponentForm form) + { + form.ShowDialog(); + } + + } + + private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = +Program.ServiceProvider?.GetService(typeof(ReportOrdersForm)); + if (service is ReportOrdersForm form) + { + form.ShowDialog(); + } + + } } } diff --git a/IceCreamShop/IceCreamShop/Program.cs b/IceCreamShop/IceCreamShop/Program.cs index 5469e49..f98c936 100644 --- a/IceCreamShop/IceCreamShop/Program.cs +++ b/IceCreamShop/IceCreamShop/Program.cs @@ -1,4 +1,6 @@ using IceCreamShopBusinessLogic.BusinessLogic; +using IceCreamShopBusinessLogic.OfficePackage.Implements; +using IceCreamShopBusinessLogic.OfficePackage; using IceCreamShopContracts.BusinessLogicsContracts; using IceCreamShopContracts.StoragesContracts; using IceCreamShopDatabaseImplement.Implements; @@ -38,6 +40,7 @@ namespace IceCreamShop services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -46,6 +49,11 @@ namespace IceCreamShop services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } diff --git a/IceCreamShop/IceCreamShop/ReportIceCreamComponentForm.Designer.cs b/IceCreamShop/IceCreamShop/ReportIceCreamComponentForm.Designer.cs new file mode 100644 index 0000000..e89c3ec --- /dev/null +++ b/IceCreamShop/IceCreamShop/ReportIceCreamComponentForm.Designer.cs @@ -0,0 +1,99 @@ +namespace IceCreamShop +{ + partial class ReportIceCreamComponentForm + { + /// + /// 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() + { + dataGridView = new DataGridView(); + ComponentColumn = new DataGridViewTextBoxColumn(); + IceCreamColumn = new DataGridViewTextBoxColumn(); + CountColumn = new DataGridViewTextBoxColumn(); + SaveButton = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // dataGridView + // + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { ComponentColumn, IceCreamColumn, CountColumn }); + dataGridView.Location = new Point(12, 46); + dataGridView.Name = "dataGridView"; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(570, 392); + dataGridView.TabIndex = 0; + // + // ComponentColumn + // + ComponentColumn.HeaderText = "Компонент"; + ComponentColumn.Name = "ComponentColumn"; + ComponentColumn.Width = 200; + // + // IceCreamColumn + // + IceCreamColumn.HeaderText = "Мороженное"; + IceCreamColumn.Name = "IceCreamColumn"; + IceCreamColumn.Width = 200; + // + // CountColumn + // + CountColumn.HeaderText = "Количество"; + CountColumn.Name = "CountColumn"; + CountColumn.Width = 130; + // + // SaveButton + // + SaveButton.Location = new Point(12, 17); + SaveButton.Name = "SaveButton"; + SaveButton.Size = new Size(114, 23); + SaveButton.TabIndex = 1; + SaveButton.Text = "Сохранить в Excel"; + SaveButton.UseVisualStyleBackColor = true; + SaveButton.Click += SaveButton_Click; + // + // ReportIceCreamComponentForm + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(594, 450); + Controls.Add(SaveButton); + Controls.Add(dataGridView); + Name = "ReportIceCreamComponentForm"; + Text = "Компоненты по мороженным"; + Load += ReportIceCreamComponentForm_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView; + private Button SaveButton; + private DataGridViewTextBoxColumn ComponentColumn; + private DataGridViewTextBoxColumn IceCreamColumn; + private DataGridViewTextBoxColumn CountColumn; + } +} \ No newline at end of file diff --git a/IceCreamShop/IceCreamShop/ReportIceCreamComponentForm.cs b/IceCreamShop/IceCreamShop/ReportIceCreamComponentForm.cs new file mode 100644 index 0000000..d6b6e59 --- /dev/null +++ b/IceCreamShop/IceCreamShop/ReportIceCreamComponentForm.cs @@ -0,0 +1,95 @@ +using IceCreamShopContracts.BindingModels; +using IceCreamShopContracts.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 IceCreamShop +{ + public partial class ReportIceCreamComponentForm : Form + { + private readonly ILogger _logger; + private readonly IReportLogic _logic; + + public ReportIceCreamComponentForm(ILogger +logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + + } + + private void ReportIceCreamComponentForm_Load(object sender, EventArgs e) + { + try + { + var dict = _logic.GetIceCreamComponent(); + if (dict != null) + { + dataGridView.Rows.Clear(); + foreach (var elem in dict) + { + dataGridView.Rows.Add(new object[] { elem.IceCreamName, +"", "" }); + 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("Загрузка списка мороженных по компонентам"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка мороженных по компонентам"); + + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + + } + + private void SaveButton_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog + { + Filter = "xlsx|*.xlsx" + }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + _logic.SaveIceCreamComponentToExcelFile(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/IceCreamShop/IceCreamShop/ReportIceCreamComponentForm.resx b/IceCreamShop/IceCreamShop/ReportIceCreamComponentForm.resx new file mode 100644 index 0000000..c67efe4 --- /dev/null +++ b/IceCreamShop/IceCreamShop/ReportIceCreamComponentForm.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + \ No newline at end of file diff --git a/IceCreamShop/IceCreamShop/ReportOrders.rdlc b/IceCreamShop/IceCreamShop/ReportOrders.rdlc new file mode 100644 index 0000000..1712a9f --- /dev/null +++ b/IceCreamShop/IceCreamShop/ReportOrders.rdlc @@ -0,0 +1,600 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 47cb53f0-7dde-4717-ba03-866a0bc4f4dd + + + + + + IceCreamShopContractsViewModels + /* Local Query */ + + + + Id + System.Int32 + + + DateCreate + System.DateTime + + + IceCreamName + System.String + + + Sum + System.Decimal + + + OrderStatus + IceCreamShopDataModels.OrderStatus + + + + IceCreamShopContracts.ViewModels + ReportOrderViewModel + IceCreamShopContracts.ViewModels.ReportOrderViewModel, IceCreamShopContracts, 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 + + + + + + + + 0.6cm + + + + + true + true + + + + + =Fields!Id.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!DateCreate.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!IceCreamName.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!OrderStatus.Value + + + 2pt + 2pt + 2pt + 2pt + + + true + + + + + + true + true + + + + + =Fields!Sum.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 + - true diff --git a/IceCreamShop/IceCreamShopFileImplement/Implements/OrderStorage.cs b/IceCreamShop/IceCreamShopFileImplement/Implements/OrderStorage.cs index 983f9d1..c1fadf6 100644 --- a/IceCreamShop/IceCreamShopFileImplement/Implements/OrderStorage.cs +++ b/IceCreamShop/IceCreamShopFileImplement/Implements/OrderStorage.cs @@ -29,14 +29,15 @@ namespace IceCreamShopFileImplement.Implements public List GetFilteredList(OrderSearchModel model) { - if (!model.Id.HasValue) - { - return new(); - } return source.Orders - .Where(x => x.Id == model.Id) - .Select( x => AccessIceCreamStorage( x.GetViewModel)) - .ToList(); + .Where(x => ( + (!model.Id.HasValue || x.Id == model.Id) && + (!model.DateFrom.HasValue || x.DateCreate >= model.DateFrom) && + (!model.DateTo.HasValue || x.DateCreate <= model.DateTo) + ) + ) + .Select(x => x.GetViewModel) + .ToList(); } public OrderViewModel? GetElement(OrderSearchModel model) diff --git a/IceCreamShop/IceCreamShopListImplement/Implements/OrderStorage.cs b/IceCreamShop/IceCreamShopListImplement/Implements/OrderStorage.cs index d10184b..e92bd6e 100644 --- a/IceCreamShop/IceCreamShopListImplement/Implements/OrderStorage.cs +++ b/IceCreamShop/IceCreamShopListImplement/Implements/OrderStorage.cs @@ -31,13 +31,11 @@ namespace IceCreamShopListImplement.Implements model) { var result = new List(); - if (!model.Id.HasValue) - { - return result; - } foreach (var order in _source.Orders) { - if (order.Id == model.Id) + if ((!model.Id.HasValue || order.Id == model.Id) && + (!model.DateFrom.HasValue || order.DateCreate >= model.DateFrom) && + (!model.DateTo.HasValue || order.DateCreate <= model.DateTo)) { result.Add(AccessIceCreamStorage(order.GetViewModel)); } -- 2.25.1 From 1adfa6dbf06f9767987bb813ffc72904df549a3a Mon Sep 17 00:00:00 2001 From: gg12 darfren Date: Tue, 26 Mar 2024 23:04:26 +0400 Subject: [PATCH 6/6] asdasd --- .../IceCreamShopFileImplement/Implements/OrderStorage.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/IceCreamShop/IceCreamShopFileImplement/Implements/OrderStorage.cs b/IceCreamShop/IceCreamShopFileImplement/Implements/OrderStorage.cs index c1fadf6..cc185cd 100644 --- a/IceCreamShop/IceCreamShopFileImplement/Implements/OrderStorage.cs +++ b/IceCreamShop/IceCreamShopFileImplement/Implements/OrderStorage.cs @@ -36,7 +36,7 @@ model) (!model.DateTo.HasValue || x.DateCreate <= model.DateTo) ) ) - .Select(x => x.GetViewModel) + .Select(x => AccessIceCreamStorage(x.GetViewModel)) .ToList(); } -- 2.25.1