From 93a5ffc10301a9f4f42273b8373739436d683d94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=98=D0=B3=D0=BE=D1=80=D1=8C=20=D0=93=D0=BE=D1=80=D0=B4?= =?UTF-8?q?=D0=B5=D0=B5=D0=B2?= <89176335310x@gmail.com> Date: Wed, 3 Apr 2024 20:34:51 +0400 Subject: [PATCH] maybe done --- SushiBar/SushiBar/FormMain.Designer.cs | 238 ++++--- SushiBar/SushiBar/FormMain.cs | 28 + SushiBar/SushiBar/FormMain.resx | 62 +- SushiBar/SushiBar/FormReportOrders.cs | 92 +++ .../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 | 2 + SushiBar/SushiBar/ReportOrders.rdlc | 599 ++++++++++++++++++ SushiBar/SushiBar/SushiBarView.csproj | 1 + .../OfficePackage/AbstractSaveToExcel.cs | 107 ++++ .../OfficePackage/AbstractSaveToPdf.cs | 69 ++ .../OfficePackage/AbstractSaveToWord.cs | 60 ++ .../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 | 293 +++++++++ .../OfficePackage/Implements/SaveToPdf.cs | 114 ++++ .../OfficePackage/Implements/SaveToWord.cs | 135 ++++ .../SushiBarBusinessLogic.csproj | 6 + .../BindingModels/ReportBindingModel.cs | 11 + .../BusinessLogicsContracts/IReportLogic.cs | 39 ++ .../ViewModels/ReportOrdersViewModel.cs | 15 + .../ReportSushiIngredientViewModel.cs | 11 + 35 files changed, 2436 insertions(+), 104 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/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..5d7d79d 100644 --- a/SushiBar/SushiBar/FormMain.Designer.cs +++ b/SushiBar/SushiBar/FormMain.Designer.cs @@ -28,142 +28,170 @@ /// private void InitializeComponent() { - this.menuStrip = 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.buttonUpdate = new System.Windows.Forms.Button(); - this.buttonSetToFinish = new System.Windows.Forms.Button(); - this.buttonSetToDone = new System.Windows.Forms.Button(); - this.buttonSetToWork = new System.Windows.Forms.Button(); - this.buttonCreateOrder = new System.Windows.Forms.Button(); - this.dataGridView = new System.Windows.Forms.DataGridView(); - this.menuStrip.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); - this.SuspendLayout(); + menuStrip = new MenuStrip(); + справочникиToolStripMenuItem = new ToolStripMenuItem(); + ингредиентыToolStripMenuItem = new ToolStripMenuItem(); + сушиToolStripMenuItem = new ToolStripMenuItem(); + отчетыToolStripMenuItem = new ToolStripMenuItem(); + списокСушиToolStripMenuItem = new ToolStripMenuItem(); + сушиСИнгредиентамиToolStripMenuItem = new ToolStripMenuItem(); + списокЗаказовToolStripMenuItem = new ToolStripMenuItem(); + buttonUpdate = new Button(); + buttonSetToFinish = new Button(); + buttonSetToDone = new Button(); + buttonSetToWork = new Button(); + buttonCreateOrder = new Button(); + dataGridView = new DataGridView(); + menuStrip.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); // // menuStrip // - this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.справочникиToolStripMenuItem}); - this.menuStrip.Location = new System.Drawing.Point(0, 0); - this.menuStrip.Name = "menuStrip"; - this.menuStrip.Size = new System.Drawing.Size(975, 24); - this.menuStrip.TabIndex = 0; - this.menuStrip.Text = "menuStrip1"; + menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, отчетыToolStripMenuItem }); + menuStrip.Location = new Point(0, 0); + menuStrip.Name = "menuStrip"; + menuStrip.Size = new Size(975, 24); + menuStrip.TabIndex = 0; + menuStrip.Text = "menuStrip1"; // // справочникиToolStripMenuItem // - this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.ингредиентыToolStripMenuItem, - this.сушиToolStripMenuItem}); - this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; - this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20); - this.справочникиToolStripMenuItem.Text = "Справочники"; + справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ингредиентыToolStripMenuItem, сушиToolStripMenuItem }); + справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem"; + справочникиToolStripMenuItem.Size = new Size(94, 20); + справочникиToolStripMenuItem.Text = "Справочники"; // // ингредиентыToolStripMenuItem // - this.ингредиентыToolStripMenuItem.Name = "ингредиентыToolStripMenuItem"; - this.ингредиентыToolStripMenuItem.Size = new System.Drawing.Size(148, 22); - this.ингредиентыToolStripMenuItem.Text = "Ингредиенты"; - this.ингредиентыToolStripMenuItem.Click += new System.EventHandler(this.IngredientsToolStripMenuItem_Click); + ингредиентыToolStripMenuItem.Name = "ингредиентыToolStripMenuItem"; + ингредиентыToolStripMenuItem.Size = new Size(148, 22); + ингредиентыToolStripMenuItem.Text = "Ингредиенты"; + ингредиентыToolStripMenuItem.Click += IngredientsToolStripMenuItem_Click; // // сушиToolStripMenuItem // - this.сушиToolStripMenuItem.Name = "сушиToolStripMenuItem"; - this.сушиToolStripMenuItem.Size = new System.Drawing.Size(148, 22); - this.сушиToolStripMenuItem.Text = "Суши"; - this.сушиToolStripMenuItem.Click += new System.EventHandler(this.SushiToolStripMenuItem_Click); + сушиToolStripMenuItem.Name = "сушиToolStripMenuItem"; + сушиToolStripMenuItem.Size = new Size(148, 22); + сушиToolStripMenuItem.Text = "Суши"; + сушиToolStripMenuItem.Click += SushiToolStripMenuItem_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(203, 22); + списокСушиToolStripMenuItem.Text = "Список суши"; + списокСушиToolStripMenuItem.Click += SushiListToolStripMenuItem_Click; + // + // сушиСИнгредиентамиToolStripMenuItem + // + сушиСИнгредиентамиToolStripMenuItem.Name = "сушиСИнгредиентамиToolStripMenuItem"; + сушиСИнгредиентамиToolStripMenuItem.Size = new Size(203, 22); + сушиСИнгредиентамиToolStripMenuItem.Text = "Суши с ингредиентами"; + сушиСИнгредиентамиToolStripMenuItem.Click += SushiIngredientToolStripMenuItem_Click; + // + // списокЗаказовToolStripMenuItem + // + списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; + списокЗаказовToolStripMenuItem.Size = new Size(203, 22); + списокЗаказовToolStripMenuItem.Text = "Список заказов"; + списокЗаказовToolStripMenuItem.Click += OrdersToolStripMenuItem_Click; // // buttonUpdate // - this.buttonUpdate.Location = new System.Drawing.Point(780, 314); - this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonUpdate.Name = "buttonUpdate"; - this.buttonUpdate.Size = new System.Drawing.Size(170, 58); - this.buttonUpdate.TabIndex = 12; - this.buttonUpdate.Text = "Обновить"; - this.buttonUpdate.UseVisualStyleBackColor = true; - this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click); + buttonUpdate.Location = new Point(780, 314); + buttonUpdate.Margin = new Padding(3, 2, 3, 2); + buttonUpdate.Name = "buttonUpdate"; + buttonUpdate.Size = new Size(170, 58); + buttonUpdate.TabIndex = 12; + buttonUpdate.Text = "Обновить"; + buttonUpdate.UseVisualStyleBackColor = true; + buttonUpdate.Click += ButtonRef_Click; // // buttonSetToFinish // - this.buttonSetToFinish.Location = new System.Drawing.Point(780, 252); - this.buttonSetToFinish.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonSetToFinish.Name = "buttonSetToFinish"; - this.buttonSetToFinish.Size = new System.Drawing.Size(170, 58); - this.buttonSetToFinish.TabIndex = 11; - this.buttonSetToFinish.Text = "Заказ выдан"; - this.buttonSetToFinish.UseVisualStyleBackColor = true; - this.buttonSetToFinish.Click += new System.EventHandler(this.ButtonIssuedOrder_Click); + buttonSetToFinish.Location = new Point(780, 252); + buttonSetToFinish.Margin = new Padding(3, 2, 3, 2); + buttonSetToFinish.Name = "buttonSetToFinish"; + buttonSetToFinish.Size = new Size(170, 58); + buttonSetToFinish.TabIndex = 11; + buttonSetToFinish.Text = "Заказ выдан"; + buttonSetToFinish.UseVisualStyleBackColor = true; + buttonSetToFinish.Click += ButtonIssuedOrder_Click; // // buttonSetToDone // - this.buttonSetToDone.Location = new System.Drawing.Point(780, 190); - this.buttonSetToDone.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonSetToDone.Name = "buttonSetToDone"; - this.buttonSetToDone.Size = new System.Drawing.Size(170, 58); - this.buttonSetToDone.TabIndex = 10; - this.buttonSetToDone.Text = "Заказ готов"; - this.buttonSetToDone.UseVisualStyleBackColor = true; - this.buttonSetToDone.Click += new System.EventHandler(this.ButtonOrderReady_Click); + buttonSetToDone.Location = new Point(780, 190); + buttonSetToDone.Margin = new Padding(3, 2, 3, 2); + buttonSetToDone.Name = "buttonSetToDone"; + buttonSetToDone.Size = new Size(170, 58); + buttonSetToDone.TabIndex = 10; + buttonSetToDone.Text = "Заказ готов"; + buttonSetToDone.UseVisualStyleBackColor = true; + buttonSetToDone.Click += ButtonOrderReady_Click; // // buttonSetToWork // - this.buttonSetToWork.Location = new System.Drawing.Point(780, 128); - this.buttonSetToWork.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonSetToWork.Name = "buttonSetToWork"; - this.buttonSetToWork.Size = new System.Drawing.Size(170, 58); - this.buttonSetToWork.TabIndex = 9; - this.buttonSetToWork.Text = "Отдать на выполнение"; - this.buttonSetToWork.UseVisualStyleBackColor = true; - this.buttonSetToWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click); + buttonSetToWork.Location = new Point(780, 128); + buttonSetToWork.Margin = new Padding(3, 2, 3, 2); + buttonSetToWork.Name = "buttonSetToWork"; + buttonSetToWork.Size = new Size(170, 58); + buttonSetToWork.TabIndex = 9; + buttonSetToWork.Text = "Отдать на выполнение"; + buttonSetToWork.UseVisualStyleBackColor = true; + buttonSetToWork.Click += ButtonTakeOrderInWork_Click; // // buttonCreateOrder // - this.buttonCreateOrder.Location = new System.Drawing.Point(780, 66); - this.buttonCreateOrder.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2); - this.buttonCreateOrder.Name = "buttonCreateOrder"; - this.buttonCreateOrder.Size = new System.Drawing.Size(170, 58); - this.buttonCreateOrder.TabIndex = 8; - this.buttonCreateOrder.Text = "Создать заказ"; - this.buttonCreateOrder.UseVisualStyleBackColor = true; - this.buttonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click); + buttonCreateOrder.Location = new Point(780, 66); + buttonCreateOrder.Margin = new Padding(3, 2, 3, 2); + buttonCreateOrder.Name = "buttonCreateOrder"; + buttonCreateOrder.Size = new Size(170, 58); + buttonCreateOrder.TabIndex = 8; + buttonCreateOrder.Text = "Создать заказ"; + buttonCreateOrder.UseVisualStyleBackColor = true; + buttonCreateOrder.Click += ButtonCreateOrder_Click; // // dataGridView // - this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left; - this.dataGridView.Location = new System.Drawing.Point(0, 24); - 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(755, 426); - this.dataGridView.TabIndex = 7; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Dock = DockStyle.Left; + dataGridView.Location = new Point(0, 24); + dataGridView.Margin = new Padding(3, 2, 3, 2); + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidth = 51; + dataGridView.RowTemplate.Height = 29; + dataGridView.Size = new Size(755, 426); + dataGridView.TabIndex = 7; // // FormMain // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(975, 450); - this.Controls.Add(this.buttonUpdate); - this.Controls.Add(this.buttonSetToFinish); - this.Controls.Add(this.buttonSetToDone); - this.Controls.Add(this.buttonSetToWork); - this.Controls.Add(this.buttonCreateOrder); - this.Controls.Add(this.dataGridView); - this.Controls.Add(this.menuStrip); - this.MainMenuStrip = this.menuStrip; - this.Name = "FormMain"; - this.Text = "Суши-бар"; - this.Load += new System.EventHandler(this.FormMain_Load); - this.menuStrip.ResumeLayout(false); - this.menuStrip.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(975, 450); + Controls.Add(buttonUpdate); + Controls.Add(buttonSetToFinish); + Controls.Add(buttonSetToDone); + Controls.Add(buttonSetToWork); + Controls.Add(buttonCreateOrder); + Controls.Add(dataGridView); + Controls.Add(menuStrip); + MainMenuStrip = menuStrip; + Name = "FormMain"; + Text = "Суши-бар"; + Load += FormMain_Load; + menuStrip.ResumeLayout(false); + menuStrip.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); } #endregion @@ -178,5 +206,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..f9546ef 100644 --- a/SushiBar/SushiBar/FormMain.cs +++ b/SushiBar/SushiBar/FormMain.cs @@ -9,6 +9,7 @@ namespace SushiBarView { private readonly ILogger _logger; private readonly IOrderLogic _orderLogic; + private readonly IReportLogic _reportLogic; public FormMain(ILogger logger, IOrderLogic orderLogic) { InitializeComponent(); @@ -143,5 +144,32 @@ namespace SushiBarView { LoadData(); } + private void SushiListToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SaveListSushiToWordFile(new ReportBindingModel { FileName = dialog.FileName }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + + private void SushiIngredientToolStripMenuItem_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/FormMain.resx b/SushiBar/SushiBar/FormMain.resx index 81a9e3d..6c82d08 100644 --- a/SushiBar/SushiBar/FormMain.resx +++ b/SushiBar/SushiBar/FormMain.resx @@ -1,4 +1,64 @@ - + + + diff --git a/SushiBar/SushiBar/FormReportOrders.cs b/SushiBar/SushiBar/FormReportOrders.cs new file mode 100644 index 0000000..f051362 --- /dev/null +++ b/SushiBar/SushiBar/FormReportOrders.cs @@ -0,0 +1,92 @@ +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..253ba78 --- /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.SushiName, "", "" }); + foreach (var listElem in elem.Ingredients) + { + 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..a44a6b1 --- /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.ColumnSushi = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.ColumnIngredient = 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.ColumnSushi, + this.ColumnIngredient, + 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); + // + // ColumnSushi + // + this.ColumnSushi.HeaderText = "Суши"; + this.ColumnSushi.Name = "ColumnSushi"; + this.ColumnSushi.ReadOnly = true; + this.ColumnSushi.Width = 200; + // + // ColumnIngredient + // + this.ColumnIngredient.HeaderText = "Ингредиент"; + this.ColumnIngredient.Name = "ColumnIngredient"; + this.ColumnIngredient.ReadOnly = true; + this.ColumnIngredient.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 ColumnSushi; + private DataGridViewTextBoxColumn ColumnIngredient; + 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..fa3875e 100644 --- a/SushiBar/SushiBar/Program.cs +++ b/SushiBar/SushiBar/Program.cs @@ -49,6 +49,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..4869f28 --- /dev/null +++ b/SushiBar/SushiBar/ReportOrders.rdlc @@ -0,0 +1,599 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 10791c83-cee8-4a38-bbd0-245fc17cefb3 + + + + + + SushiBarContractsViewModels + /* Local Query */ + + + + Id + System.Int32 + + + DateCreate + System.DateTime + + + SushiName + System.String + + + OrderStatus + 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 + + + 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!SushiName.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!OrderStatus.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 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 +