From b50c7a18f03364a610fb4a0a0f5226f98a7b8ca9 Mon Sep 17 00:00:00 2001 From: dasha Date: Fri, 10 Mar 2023 16:43:19 +0400 Subject: [PATCH 1/4] =?UTF-8?q?=D0=9D=D0=B8=D1=87=D0=B5=D0=B3=D0=BE=20?= =?UTF-8?q?=D0=BD=D0=B5=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SushiBar/SushiBar/FormMain.Designer.cs | 42 +- SushiBar/SushiBar/FormMain.cs | 31 +- SushiBar/SushiBar/FormReportOrders.cs | 91 +++ .../SushiBar/FormReportOrders.designer.cs | 141 +++++ SushiBar/SushiBar/FormReportOrders.resx | 120 ++++ .../SushiBar/FormReportSushiIngredients.cs | 70 +++ .../FormReportSushiIngredients.designer.cs | 117 ++++ .../SushiBar/FormReportSushiIngredients.resx | 60 ++ SushiBar/SushiBar/Program.cs | 11 + SushiBar/SushiBar/ReportOrders.rdlc | 529 ++++++++++++++++++ SushiBar/SushiBar/SushiBarView.csproj | 7 + .../BusinessLogics/ReportLogic.cs | 134 +++++ .../OfficePackage/AbstractSaveToExcel.cs | 107 ++++ .../OfficePackage/AbstractSaveToPdf.cs | 69 +++ .../OfficePackage/AbstractSaveToWord.cs | 57 ++ .../HelperEnums/ExcelStyleInfoType.cs | 11 + .../HelperEnums/PdfParagraphAlignmentType.cs | 11 + .../HelperEnums/WordJustificationType.cs | 9 + .../HelperModels/ExcelCellParameters.cs | 17 + .../OfficePackage/HelperModels/ExcelInfo.cs | 13 + .../HelperModels/ExcelMergeParameters.cs | 11 + .../OfficePackage/HelperModels/PdfInfo.cs | 17 + .../HelperModels/PdfParagraph.cs | 13 + .../HelperModels/PdfRowParameters.cs | 13 + .../OfficePackage/HelperModels/WordInfo.cs | 13 + .../HelperModels/WordParagraph.cs | 9 + .../HelperModels/WordTextProperties.cs | 13 + .../OfficePackage/Implements/SaveToExcel.cs | 292 ++++++++++ .../OfficePackage/Implements/SaveToPdf.cs | 114 ++++ .../OfficePackage/Implements/SaveToWord.cs | 135 +++++ .../SushiBarBusinessLogic.csproj | 4 +- .../BindingModels/ReportBindingModel.cs | 11 + .../BusinessLogicsContracts/IReportLogic.cs | 39 ++ .../SearchModels/OrderSearchModel.cs | 4 + .../ViewModels/ReportOrdersViewModel.cs | 13 + .../ReportSushiIngredientViewModel.cs | 11 + 36 files changed, 2356 insertions(+), 3 deletions(-) create mode 100644 SushiBar/SushiBar/FormReportOrders.cs create mode 100644 SushiBar/SushiBar/FormReportOrders.designer.cs create mode 100644 SushiBar/SushiBar/FormReportOrders.resx create mode 100644 SushiBar/SushiBar/FormReportSushiIngredients.cs create mode 100644 SushiBar/SushiBar/FormReportSushiIngredients.designer.cs create mode 100644 SushiBar/SushiBar/FormReportSushiIngredients.resx create mode 100644 SushiBar/SushiBar/ReportOrders.rdlc create mode 100644 SushiBar/SushiBarBusinessLogic/BusinessLogics/ReportLogic.cs create mode 100644 SushiBar/SushiBarBusinessLogic/OfficePackage/AbstractSaveToExcel.cs create mode 100644 SushiBar/SushiBarBusinessLogic/OfficePackage/AbstractSaveToPdf.cs create mode 100644 SushiBar/SushiBarBusinessLogic/OfficePackage/AbstractSaveToWord.cs create mode 100644 SushiBar/SushiBarBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs create mode 100644 SushiBar/SushiBarBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs create mode 100644 SushiBar/SushiBarBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs create mode 100644 SushiBar/SushiBarBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs create mode 100644 SushiBar/SushiBarBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs create mode 100644 SushiBar/SushiBarBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs create mode 100644 SushiBar/SushiBarBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs create mode 100644 SushiBar/SushiBarBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs create mode 100644 SushiBar/SushiBarBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs create mode 100644 SushiBar/SushiBarBusinessLogic/OfficePackage/HelperModels/WordInfo.cs create mode 100644 SushiBar/SushiBarBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs create mode 100644 SushiBar/SushiBarBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs create mode 100644 SushiBar/SushiBarBusinessLogic/OfficePackage/Implements/SaveToExcel.cs create mode 100644 SushiBar/SushiBarBusinessLogic/OfficePackage/Implements/SaveToPdf.cs create mode 100644 SushiBar/SushiBarBusinessLogic/OfficePackage/Implements/SaveToWord.cs create mode 100644 SushiBar/SushiBarContracts/BindingModels/ReportBindingModel.cs create mode 100644 SushiBar/SushiBarContracts/BusinessLogicsContracts/IReportLogic.cs create mode 100644 SushiBar/SushiBarContracts/ViewModels/ReportOrdersViewModel.cs create mode 100644 SushiBar/SushiBarContracts/ViewModels/ReportSushiIngredientViewModel.cs diff --git a/SushiBar/SushiBar/FormMain.Designer.cs b/SushiBar/SushiBar/FormMain.Designer.cs index cad392a..547f98f 100644 --- a/SushiBar/SushiBar/FormMain.Designer.cs +++ b/SushiBar/SushiBar/FormMain.Designer.cs @@ -38,6 +38,10 @@ this.buttonSetToWork = new System.Windows.Forms.Button(); this.buttonCreateOrder = new System.Windows.Forms.Button(); this.dataGridView = new System.Windows.Forms.DataGridView(); + this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.списокИнгредиентовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.ингредиентыПоСушиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.SuspendLayout(); @@ -45,7 +49,8 @@ // menuStrip // this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.справочникиToolStripMenuItem}); + this.справочникиToolStripMenuItem, + this.отчетыToolStripMenuItem}); this.menuStrip.Location = new System.Drawing.Point(0, 0); this.menuStrip.Name = "menuStrip"; this.menuStrip.Size = new System.Drawing.Size(975, 24); @@ -142,6 +147,37 @@ this.dataGridView.Size = new System.Drawing.Size(755, 426); this.dataGridView.TabIndex = 7; // + // отчеты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(198, 22); + this.списокИнгредиентовToolStripMenuItem.Text = "Список ингредиентов"; + this.списокИнгредиентовToolStripMenuItem.Click += new System.EventHandler(this.IngredientToolStripMenuItem_Click); + // + // ингредиентыПоСушиToolStripMenuItem + // + this.ингредиентыПоСушиToolStripMenuItem.Name = "ингредиентыПоСушиToolStripMenuItem"; + this.ингредиентыПоСушиToolStripMenuItem.Size = new System.Drawing.Size(198, 22); + this.ингредиентыПоСушиToolStripMenuItem.Text = "Ингредиенты по суши"; + this.ингредиентыПоСушиToolStripMenuItem.Click += new System.EventHandler(this.IngredientSushiToolStripMenuItem_Click); + // + // списокЗаказовToolStripMenuItem + // + this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; + this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(198, 22); + this.списокЗаказовToolStripMenuItem.Text = "Список заказов"; + this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.OrdersToolStripMenuItem_Click); + // // FormMain // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -178,5 +214,9 @@ private Button buttonSetToWork; private Button buttonCreateOrder; private DataGridView dataGridView; + private ToolStripMenuItem отчетыToolStripMenuItem; + private ToolStripMenuItem списокИнгредиентовToolStripMenuItem; + private ToolStripMenuItem ингредиентыПоСушиToolStripMenuItem; + private ToolStripMenuItem списокЗаказовToolStripMenuItem; } } \ No newline at end of file diff --git a/SushiBar/SushiBar/FormMain.cs b/SushiBar/SushiBar/FormMain.cs index 6255276..cf8724e 100644 --- a/SushiBar/SushiBar/FormMain.cs +++ b/SushiBar/SushiBar/FormMain.cs @@ -9,11 +9,13 @@ namespace SushiBarView { 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) { @@ -143,5 +145,32 @@ namespace SushiBarView { LoadData(); } + private void IngredientToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SaveIngredientsToWordFile(new ReportBindingModel { FileName = dialog.FileName }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + + private void IngredientSushiToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportSushiIngredients)); + if (service is FormReportSushiIngredients form) + { + form.ShowDialog(); + } + } + + private void OrdersToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + if (service is FormReportOrders form) + { + form.ShowDialog(); + } + } } } \ No newline at end of file diff --git a/SushiBar/SushiBar/FormReportOrders.cs b/SushiBar/SushiBar/FormReportOrders.cs new file mode 100644 index 0000000..d1826f7 --- /dev/null +++ b/SushiBar/SushiBar/FormReportOrders.cs @@ -0,0 +1,91 @@ +using SushiBarContracts.BindingModels; +using SushiBarContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; +using Microsoft.Reporting.WinForms; + +namespace SushiBarView +{ + public partial class FormReportOrders : Form + { + private readonly ReportViewer reportViewer; + + private readonly ILogger _logger; + + private readonly IReportLogic _logic; + + public FormReportOrders(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + reportViewer = new ReportViewer + { + Dock = DockStyle.Fill + }; + reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportOrders.rdlc", FileMode.Open)); + Controls.Clear(); + Controls.Add(reportViewer); + Controls.Add(panel); + } + + private void ButtonMake_Click(object sender, EventArgs e) + { + if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date) + { + MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + try + { + var dataSource = _logic.GetOrders(new ReportBindingModel + { + DateFrom = dateTimePickerFrom.Value, + DateTo = dateTimePickerTo.Value + }); + var source = new ReportDataSource("DataSetOrders", dataSource); + reportViewer.LocalReport.DataSources.Clear(); + reportViewer.LocalReport.DataSources.Add(source); + var parameters = new[] { new ReportParameter("ReportParameterPeriod", + $"c {dateTimePickerFrom.Value.ToShortDateString()} по {dateTimePickerTo.Value.ToShortDateString()}") }; + reportViewer.LocalReport.SetParameters(parameters); + + reportViewer.RefreshReport(); + _logger.LogInformation("Загрузка списка заказов на период {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString()); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка заказов на период"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonToPdf_Click(object sender, EventArgs e) + { + if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date) + { + MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + _logic.SaveOrdersToPdfFile(new ReportBindingModel + { + FileName = dialog.FileName, + DateFrom = dateTimePickerFrom.Value, + DateTo = dateTimePickerTo.Value + }); + _logger.LogInformation("Сохранение списка заказов на период {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString()); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка сохранения списка заказов на период"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } +} \ No newline at end of file diff --git a/SushiBar/SushiBar/FormReportOrders.designer.cs b/SushiBar/SushiBar/FormReportOrders.designer.cs new file mode 100644 index 0000000..dea389e --- /dev/null +++ b/SushiBar/SushiBar/FormReportOrders.designer.cs @@ -0,0 +1,141 @@ +namespace SushiBarView +{ + 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/SushiBar/SushiBar/FormReportOrders.resx b/SushiBar/SushiBar/FormReportOrders.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/SushiBar/SushiBar/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/SushiBar/SushiBar/FormReportSushiIngredients.cs b/SushiBar/SushiBar/FormReportSushiIngredients.cs new file mode 100644 index 0000000..33940dd --- /dev/null +++ b/SushiBar/SushiBar/FormReportSushiIngredients.cs @@ -0,0 +1,70 @@ +using SushiBarContracts.BindingModels; +using SushiBarContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; + +namespace SushiBarView +{ + public partial class FormReportSushiIngredients : Form + { + private readonly ILogger _logger; + + private readonly IReportLogic _logic; + + public FormReportSushiIngredients(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormReportSushiIngredients_Load(object sender, EventArgs e) + { + try + { + var dict = _logic.GetSushiIngredient(); + if (dict != null) + { + dataGridView.Rows.Clear(); + foreach (var elem in dict) + { + dataGridView.Rows.Add(new object[] { elem.IngredientName, "", "" }); + foreach (var listElem in elem.ListSushi) + { + 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.SaveSushiIngredientToExcelFile(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); + } + } + } + } +} \ No newline at end of file diff --git a/SushiBar/SushiBar/FormReportSushiIngredients.designer.cs b/SushiBar/SushiBar/FormReportSushiIngredients.designer.cs new file mode 100644 index 0000000..239b8f4 --- /dev/null +++ b/SushiBar/SushiBar/FormReportSushiIngredients.designer.cs @@ -0,0 +1,117 @@ +namespace SushiBarView +{ + partial class FormReportSushiIngredients + { + /// + /// 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.ColumnIngredient = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnSushi = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn(); + ((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.ColumnIngredient, + this.ColumnSushi, + this.ColumnCount}); + this.dataGridView.Dock = System.Windows.Forms.DockStyle.Bottom; + this.dataGridView.Location = new System.Drawing.Point(0, 47); + this.dataGridView.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.dataGridView.MultiSelect = false; + this.dataGridView.Name = "dataGridView"; + this.dataGridView.ReadOnly = true; + this.dataGridView.RowHeadersVisible = false; + this.dataGridView.Size = new System.Drawing.Size(616, 510); + this.dataGridView.TabIndex = 0; + // + // buttonSaveToExcel + // + this.buttonSaveToExcel.Location = new System.Drawing.Point(14, 14); + this.buttonSaveToExcel.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.buttonSaveToExcel.Name = "buttonSaveToExcel"; + this.buttonSaveToExcel.Size = new System.Drawing.Size(186, 27); + this.buttonSaveToExcel.TabIndex = 1; + this.buttonSaveToExcel.Text = "Сохранить в Excel"; + this.buttonSaveToExcel.UseVisualStyleBackColor = true; + this.buttonSaveToExcel.Click += new System.EventHandler(this.ButtonSaveToExcel_Click); + // + // ColumnIngredient + // + this.ColumnIngredient.HeaderText = "Ингредиент"; + this.ColumnIngredient.Name = "ColumnIngredient"; + this.ColumnIngredient.ReadOnly = true; + this.ColumnIngredient.Width = 200; + // + // ColumnSushi + // + this.ColumnSushi.HeaderText = "Суши"; + this.ColumnSushi.Name = "ColumnSushi"; + this.ColumnSushi.ReadOnly = true; + this.ColumnSushi.Width = 200; + // + // ColumnCount + // + this.ColumnCount.HeaderText = "Количество"; + this.ColumnCount.Name = "ColumnCount"; + this.ColumnCount.ReadOnly = true; + // + // FormReportSushiIngredients + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(616, 557); + this.Controls.Add(this.buttonSaveToExcel); + this.Controls.Add(this.dataGridView); + this.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.Name = "FormReportSushiIngredients"; + this.Text = "Ингредиенты по суши"; + this.Load += new System.EventHandler(this.FormReportSushiIngredients_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 ColumnIngredient; + private DataGridViewTextBoxColumn ColumnSushi; + private DataGridViewTextBoxColumn ColumnCount; + } +} \ No newline at end of file diff --git a/SushiBar/SushiBar/FormReportSushiIngredients.resx b/SushiBar/SushiBar/FormReportSushiIngredients.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/SushiBar/SushiBar/FormReportSushiIngredients.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/SushiBar/SushiBar/Program.cs b/SushiBar/SushiBar/Program.cs index 2c31bed..18c50cf 100644 --- a/SushiBar/SushiBar/Program.cs +++ b/SushiBar/SushiBar/Program.cs @@ -2,6 +2,8 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; using SushiBarBusinessLogic.BusinessLogics; +using SushiBarBusinessLogic.OfficePackage.Implements; +using SushiBarBusinessLogic.OfficePackage; using SushiBarContracts.BusinessLogicsContracts; using SushiBarContracts.StoragesContracts; using SushiBarDatabaseImplement.Implements; @@ -39,9 +41,16 @@ namespace SushiBarView 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(); @@ -49,6 +58,8 @@ namespace SushiBarView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } diff --git a/SushiBar/SushiBar/ReportOrders.rdlc b/SushiBar/SushiBar/ReportOrders.rdlc new file mode 100644 index 0000000..4e8c4d8 --- /dev/null +++ b/SushiBar/SushiBar/ReportOrders.rdlc @@ -0,0 +1,529 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 10791c83-cee8-4a38-bbd0-245fc17cefb3 + + + + + + SushiBarContractsViewModels + /* Local Query */ + + + + Id + System.Int32 + + + DateCreate + System.DateTime + + + SushiName + System.String + + + Sum + System.Decimal + + + + SushiBarContracts.ViewModels + ReportOrdersViewModel + SushiBarContracts.ViewModels.ReportOrdersViewModel, SushiBarContracts, 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!SushiName.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 + + + + + + 2pt + 2pt + 2pt + 2pt + + + + @@ -357,6 +396,36 @@ + + + + true + true + + + + + =Fields!OrderStatus.Value + + + 2pt + 2pt + 2pt + 2pt + + + + @@ -397,6 +466,7 @@ + @@ -413,7 +483,7 @@ 2.48391cm 0.55245cm 1.2cm - 16.44755cm + 18.94755cm 2