diff --git a/SushiBar/SushiBar/Forms/FormComponents.Designer.cs b/SushiBar/SushiBar/Forms/FormComponents.Designer.cs index 5788164..bba1970 100644 --- a/SushiBar/SushiBar/Forms/FormComponents.Designer.cs +++ b/SushiBar/SushiBar/Forms/FormComponents.Designer.cs @@ -81,7 +81,7 @@ ButtonDel.UseVisualStyleBackColor = true; ButtonDel.Click += ButtonDel_Click; // - // ButtonRef + // buttonRef // ButtonRef.Anchor = AnchorStyles.Top | AnchorStyles.Right; ButtonRef.Location = new Point(700, 117); diff --git a/SushiBar/SushiBar/Forms/FormMain.Designer.cs b/SushiBar/SushiBar/Forms/FormMain.Designer.cs index 4c70edd..e5bdff8 100644 --- a/SushiBar/SushiBar/Forms/FormMain.Designer.cs +++ b/SushiBar/SushiBar/Forms/FormMain.Designer.cs @@ -30,14 +30,22 @@ { dataGridView = new DataGridView(); menuStrip1 = new MenuStrip(); - ToolStripMenuItem = new ToolStripMenuItem(); - SushiToolStripMenuItem = new ToolStripMenuItem(); - ComponentsToolStripMenuItem = new ToolStripMenuItem(); - ButtonCreateOrder = new Button(); - ButtonTakeOrderInWork = new Button(); - ButtonOrderReady = new Button(); - ButtonIssuedOrder = new Button(); - ButtonRef = new Button(); + toolStripMenuItem = new ToolStripMenuItem(); + sushiToolStripMenuItem = new ToolStripMenuItem(); + componentsToolStripMenuItem = new ToolStripMenuItem(); + отчётыToolStripMenuItem1 = new ToolStripMenuItem(); + sushisReportToolStripMenuItem = new ToolStripMenuItem(); + componentsReportПоСушиToolStripMenuItem = new ToolStripMenuItem(); + orderReportToolStripMenuItem = new ToolStripMenuItem(); + отчётыToolStripMenuItem = new ToolStripMenuItem(); + sushisToolStripMenuItem = new ToolStripMenuItem(); + componentSushisToolStripMenuItem = new ToolStripMenuItem(); + ordersToolStripMenuItem = new ToolStripMenuItem(); + buttonCreateOrder = new Button(); + buttonTakeOrderInWork = new Button(); + buttonOrderReady = new Button(); + buttonIssuedOrder = new Button(); + buttonRef = new Button(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); menuStrip1.SuspendLayout(); SuspendLayout(); @@ -57,88 +65,136 @@ // menuStrip1 // menuStrip1.ImageScalingSize = new Size(20, 20); - menuStrip1.Items.AddRange(new ToolStripItem[] { ToolStripMenuItem }); + menuStrip1.Items.AddRange(new ToolStripItem[] { toolStripMenuItem, отчётыToolStripMenuItem1 }); menuStrip1.Location = new Point(0, 0); menuStrip1.Name = "menuStrip1"; menuStrip1.Size = new Size(1190, 28); menuStrip1.TabIndex = 1; menuStrip1.Text = "menuStrip1"; // - // ToolStripMenuItem + // toolStripMenuItem // - ToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { SushiToolStripMenuItem, ComponentsToolStripMenuItem }); - ToolStripMenuItem.Name = "ToolStripMenuItem"; - ToolStripMenuItem.Size = new Size(117, 24); - ToolStripMenuItem.Text = "Справочники"; + toolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { sushiToolStripMenuItem, componentsToolStripMenuItem }); + toolStripMenuItem.Name = "toolStripMenuItem"; + toolStripMenuItem.Size = new Size(117, 24); + toolStripMenuItem.Text = "Справочники"; // - // SushiToolStripMenuItem + // sushiToolStripMenuItem // - SushiToolStripMenuItem.Name = "SushiToolStripMenuItem"; - SushiToolStripMenuItem.Size = new Size(182, 26); - SushiToolStripMenuItem.Text = "Суши"; - SushiToolStripMenuItem.Click += SushiToolStripMenuItem_Click; + sushiToolStripMenuItem.Name = "sushiToolStripMenuItem"; + sushiToolStripMenuItem.Size = new Size(182, 26); + sushiToolStripMenuItem.Text = "Суши"; + sushiToolStripMenuItem.Click += SushiToolStripMenuItem_Click; // - // ComponentsToolStripMenuItem + // componentsToolStripMenuItem // - ComponentsToolStripMenuItem.Name = "ComponentsToolStripMenuItem"; - ComponentsToolStripMenuItem.Size = new Size(182, 26); - ComponentsToolStripMenuItem.Text = "Компоненты"; - ComponentsToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click; + componentsToolStripMenuItem.Name = "componentsToolStripMenuItem"; + componentsToolStripMenuItem.Size = new Size(182, 26); + componentsToolStripMenuItem.Text = "Компоненты"; + componentsToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click; // - // ButtonCreateOrder + // отчётыToolStripMenuItem1 // - ButtonCreateOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right; - ButtonCreateOrder.Location = new Point(998, 31); - ButtonCreateOrder.Name = "ButtonCreateOrder"; - ButtonCreateOrder.Size = new Size(180, 30); - ButtonCreateOrder.TabIndex = 2; - ButtonCreateOrder.Text = "Создать заказ"; - ButtonCreateOrder.UseVisualStyleBackColor = true; - ButtonCreateOrder.Click += ButtonCreateOrder_Click; + отчётыToolStripMenuItem1.DropDownItems.AddRange(new ToolStripItem[] { sushisReportToolStripMenuItem, componentsReportПоСушиToolStripMenuItem, orderReportToolStripMenuItem }); + отчётыToolStripMenuItem1.Name = "отчётыToolStripMenuItem1"; + отчётыToolStripMenuItem1.Size = new Size(73, 24); + отчётыToolStripMenuItem1.Text = "Отчёты"; // - // ButtonTakeOrderInWork + // sushisReportToolStripMenuItem // - ButtonTakeOrderInWork.Anchor = AnchorStyles.Top | AnchorStyles.Right; - ButtonTakeOrderInWork.Location = new Point(998, 67); - ButtonTakeOrderInWork.Name = "ButtonTakeOrderInWork"; - ButtonTakeOrderInWork.Size = new Size(180, 30); - ButtonTakeOrderInWork.TabIndex = 3; - ButtonTakeOrderInWork.Text = "Отдать на выполнение"; - ButtonTakeOrderInWork.UseVisualStyleBackColor = true; - ButtonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click; + sushisReportToolStripMenuItem.Name = "sushisReportToolStripMenuItem"; + sushisReportToolStripMenuItem.Size = new Size(243, 26); + sushisReportToolStripMenuItem.Text = "Список суши"; + sushisReportToolStripMenuItem.Click += sushisReportToolStripMenuItem_Click; // - // ButtonOrderReady + // componentsReportПоСушиToolStripMenuItem // - ButtonOrderReady.Anchor = AnchorStyles.Top | AnchorStyles.Right; - ButtonOrderReady.Location = new Point(998, 103); - ButtonOrderReady.Name = "ButtonOrderReady"; - ButtonOrderReady.Size = new Size(180, 30); - ButtonOrderReady.TabIndex = 4; - ButtonOrderReady.Text = "Заказ готов"; - ButtonOrderReady.UseVisualStyleBackColor = true; - ButtonOrderReady.Click += ButtonOrderReady_Click; + componentsReportПоСушиToolStripMenuItem.Name = "componentsReportПоСушиToolStripMenuItem"; + componentsReportПоСушиToolStripMenuItem.Size = new Size(243, 26); + componentsReportПоСушиToolStripMenuItem.Text = "Компоненты по суши"; + componentsReportПоСушиToolStripMenuItem.Click += componentsReportПоСушиToolStripMenuItem_Click; // - // ButtonIssuedOrder + // orderReportToolStripMenuItem // - ButtonIssuedOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right; - ButtonIssuedOrder.Location = new Point(998, 139); - ButtonIssuedOrder.Name = "ButtonIssuedOrder"; - ButtonIssuedOrder.Size = new Size(180, 30); - ButtonIssuedOrder.TabIndex = 5; - ButtonIssuedOrder.Text = "Заказ Выдан"; - ButtonIssuedOrder.UseVisualStyleBackColor = true; - ButtonIssuedOrder.Click += ButtonIssuedOrder_Click; + orderReportToolStripMenuItem.Name = "orderReportToolStripMenuItem"; + orderReportToolStripMenuItem.Size = new Size(243, 26); + orderReportToolStripMenuItem.Text = "Список заказов"; + orderReportToolStripMenuItem.Click += orderReportToolStripMenuItem_Click; // - // ButtonRef + // отчётыToolStripMenuItem // - ButtonRef.Anchor = AnchorStyles.Top | AnchorStyles.Right; - ButtonRef.Location = new Point(998, 175); - ButtonRef.Name = "ButtonRef"; - ButtonRef.Size = new Size(180, 30); - ButtonRef.TabIndex = 6; - ButtonRef.Text = "Обновить список"; - ButtonRef.UseVisualStyleBackColor = true; - ButtonRef.Click += ButtonRef_Click; + отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem"; + отчётыToolStripMenuItem.Size = new Size(32, 19); + // + // sushisToolStripMenuItem + // + sushisToolStripMenuItem.Name = "sushisToolStripMenuItem"; + sushisToolStripMenuItem.Size = new Size(32, 19); + // + // componentSushisToolStripMenuItem + // + componentSushisToolStripMenuItem.Name = "componentSushisToolStripMenuItem"; + componentSushisToolStripMenuItem.Size = new Size(32, 19); + // + // ordersToolStripMenuItem + // + ordersToolStripMenuItem.Name = "ordersToolStripMenuItem"; + ordersToolStripMenuItem.Size = new Size(32, 19); + // + // buttonCreateOrder + // + buttonCreateOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonCreateOrder.Location = new Point(998, 31); + buttonCreateOrder.Name = "buttonCreateOrder"; + buttonCreateOrder.Size = new Size(180, 30); + buttonCreateOrder.TabIndex = 2; + buttonCreateOrder.Text = "Создать заказ"; + buttonCreateOrder.UseVisualStyleBackColor = true; + buttonCreateOrder.Click += ButtonCreateOrder_Click; + // + // buttonTakeOrderInWork + // + buttonTakeOrderInWork.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonTakeOrderInWork.Location = new Point(998, 67); + buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; + buttonTakeOrderInWork.Size = new Size(180, 30); + buttonTakeOrderInWork.TabIndex = 3; + buttonTakeOrderInWork.Text = "Отдать на выполнение"; + buttonTakeOrderInWork.UseVisualStyleBackColor = true; + buttonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click; + // + // buttonOrderReady + // + buttonOrderReady.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonOrderReady.Location = new Point(998, 103); + buttonOrderReady.Name = "buttonOrderReady"; + buttonOrderReady.Size = new Size(180, 30); + buttonOrderReady.TabIndex = 4; + buttonOrderReady.Text = "Заказ готов"; + buttonOrderReady.UseVisualStyleBackColor = true; + buttonOrderReady.Click += ButtonOrderReady_Click; + // + // buttonIssuedOrder + // + buttonIssuedOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonIssuedOrder.Location = new Point(998, 139); + buttonIssuedOrder.Name = "buttonIssuedOrder"; + buttonIssuedOrder.Size = new Size(180, 30); + buttonIssuedOrder.TabIndex = 5; + buttonIssuedOrder.Text = "Заказ Выдан"; + buttonIssuedOrder.UseVisualStyleBackColor = true; + buttonIssuedOrder.Click += ButtonIssuedOrder_Click; + // + // buttonRef + // + buttonRef.Anchor = AnchorStyles.Top | AnchorStyles.Right; + buttonRef.Location = new Point(998, 175); + buttonRef.Name = "buttonRef"; + buttonRef.Size = new Size(180, 30); + buttonRef.TabIndex = 6; + buttonRef.Text = "Обновить список"; + buttonRef.UseVisualStyleBackColor = true; + buttonRef.Click += ButtonRef_Click; // // FormMain // @@ -146,11 +202,11 @@ AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; ClientSize = new Size(1190, 450); - Controls.Add(ButtonRef); - Controls.Add(ButtonIssuedOrder); - Controls.Add(ButtonOrderReady); - Controls.Add(ButtonTakeOrderInWork); - Controls.Add(ButtonCreateOrder); + Controls.Add(buttonRef); + Controls.Add(buttonIssuedOrder); + Controls.Add(buttonOrderReady); + Controls.Add(buttonTakeOrderInWork); + Controls.Add(buttonCreateOrder); Controls.Add(dataGridView); Controls.Add(menuStrip1); MainMenuStrip = menuStrip1; @@ -169,13 +225,21 @@ private DataGridView dataGridView; private MenuStrip menuStrip1; - private Button ButtonCreateOrder; - private Button ButtonTakeOrderInWork; - private Button ButtonOrderReady; - private Button ButtonIssuedOrder; - private Button ButtonRef; - private ToolStripMenuItem ToolStripMenuItem; - private ToolStripMenuItem SushiToolStripMenuItem; - private ToolStripMenuItem ComponentsToolStripMenuItem; + private Button buttonCreateOrder; + private Button buttonTakeOrderInWork; + private Button buttonOrderReady; + private Button buttonIssuedOrder; + private Button buttonRef; + private ToolStripMenuItem toolStripMenuItem; + private ToolStripMenuItem sushiToolStripMenuItem; + private ToolStripMenuItem componentsToolStripMenuItem; + private ToolStripMenuItem отчётыToolStripMenuItem; + private ToolStripMenuItem sushisToolStripMenuItem; + private ToolStripMenuItem componentSushisToolStripMenuItem; + private ToolStripMenuItem ordersToolStripMenuItem; + private ToolStripMenuItem отчётыToolStripMenuItem1; + private ToolStripMenuItem sushisReportToolStripMenuItem; + private ToolStripMenuItem componentsReportПоСушиToolStripMenuItem; + private ToolStripMenuItem orderReportToolStripMenuItem; } } \ No newline at end of file diff --git a/SushiBar/SushiBar/Forms/FormMain.cs b/SushiBar/SushiBar/Forms/FormMain.cs index c7e1a22..8b0f023 100644 --- a/SushiBar/SushiBar/Forms/FormMain.cs +++ b/SushiBar/SushiBar/Forms/FormMain.cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.Logging; +using SushiBarBusinessLogic.BusinessLogics; using SushiBarContracts.BindingModels; using SushiBarContracts.BusinessLogicsContracts; @@ -8,11 +9,13 @@ namespace SushiBar.Forms { 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) { @@ -133,5 +136,36 @@ namespace SushiBar.Forms { LoadData(); } + + private void sushisReportToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SaveSushisToWordFile(new ReportBindingModel + { + FileName = dialog.FileName + }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + + private void componentsReportПоСушиToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportSushiComponents)); + if (service is FormReportSushiComponents form) + { + form.ShowDialog(); + } + } + + private void orderReportToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + if (service is FormReportOrders form) + { + form.ShowDialog(); + } + } } } diff --git a/SushiBar/SushiBar/Forms/FormReportOrders.Designer.cs b/SushiBar/SushiBar/Forms/FormReportOrders.Designer.cs new file mode 100644 index 0000000..0f8e56b --- /dev/null +++ b/SushiBar/SushiBar/Forms/FormReportOrders.Designer.cs @@ -0,0 +1,142 @@ +namespace SushiBar.Forms +{ + 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() + { + panel = new Panel(); + label2 = new Label(); + label1 = new Label(); + dateTimePickerTo = new DateTimePicker(); + dateTimePickerFrom = new DateTimePicker(); + buttonToPdf = new Button(); + buttonMake = new Button(); + panelBody = new Panel(); + panel.SuspendLayout(); + SuspendLayout(); + // + // panel + // + panel.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right; + panel.Controls.Add(label2); + panel.Controls.Add(label1); + panel.Controls.Add(dateTimePickerTo); + panel.Controls.Add(dateTimePickerFrom); + panel.Controls.Add(buttonToPdf); + panel.Controls.Add(buttonMake); + panel.Location = new Point(0, 0); + panel.Name = "panel"; + panel.Size = new Size(1242, 51); + panel.TabIndex = 0; + // + // label2 + // + label2.AutoSize = true; + label2.Location = new Point(317, 19); + label2.Name = "label2"; + label2.Size = new Size(27, 20); + label2.TabIndex = 5; + label2.Text = "по"; + // + // label1 + // + label1.AutoSize = true; + label1.Location = new Point(39, 19); + label1.Name = "label1"; + label1.Size = new Size(18, 20); + label1.TabIndex = 4; + label1.Text = "С"; + // + // dateTimePickerTo + // + dateTimePickerTo.Location = new Point(366, 14); + dateTimePickerTo.Name = "dateTimePickerTo"; + dateTimePickerTo.Size = new Size(210, 27); + dateTimePickerTo.TabIndex = 3; + // + // dateTimePickerFrom + // + dateTimePickerFrom.Location = new Point(73, 14); + dateTimePickerFrom.Name = "dateTimePickerFrom"; + dateTimePickerFrom.Size = new Size(214, 27); + dateTimePickerFrom.TabIndex = 2; + // + // buttonToPdf + // + buttonToPdf.Location = new Point(1076, 10); + buttonToPdf.Name = "buttonToPdf"; + buttonToPdf.Size = new Size(154, 29); + buttonToPdf.TabIndex = 1; + buttonToPdf.Text = "В PdF"; + buttonToPdf.UseVisualStyleBackColor = true; + buttonToPdf.Click += buttonToPdf_Click; + // + // buttonMake + // + buttonMake.Location = new Point(916, 10); + buttonMake.Name = "buttonMake"; + buttonMake.Size = new Size(154, 29); + buttonMake.TabIndex = 0; + buttonMake.Text = "Сформировать"; + buttonMake.UseVisualStyleBackColor = true; + buttonMake.Click += buttonMake_Click; + // + // panelBody + // + panelBody.AllowDrop = true; + panelBody.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + panelBody.Location = new Point(12, 57); + panelBody.Name = "panelBody"; + panelBody.Size = new Size(1218, 506); + panelBody.TabIndex = 1; + // + // FormReportOrders + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1242, 575); + Controls.Add(panelBody); + Controls.Add(panel); + Name = "FormReportOrders"; + Text = "FormReportOrders"; + panel.ResumeLayout(false); + panel.PerformLayout(); + ResumeLayout(false); + } + + #endregion + + private Panel panel; + private Button buttonToPdf; + private Button buttonMake; + private DateTimePicker dateTimePickerTo; + private DateTimePicker dateTimePickerFrom; + private Label label1; + private Label label2; + private Panel panelBody; + } +} \ No newline at end of file diff --git a/SushiBar/SushiBar/Forms/FormReportOrders.cs b/SushiBar/SushiBar/Forms/FormReportOrders.cs new file mode 100644 index 0000000..3c145f2 --- /dev/null +++ b/SushiBar/SushiBar/Forms/FormReportOrders.cs @@ -0,0 +1,93 @@ +using Microsoft.Extensions.Logging; +using Microsoft.Reporting.WinForms; +using SushiBarContracts.BindingModels; +using SushiBarContracts.BusinessLogicsContracts; + +namespace SushiBar.Forms +{ + 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("Report/ReportOrders.rdlc", FileMode.Open)); + panelBody.Controls.Add(reportViewer); + } + 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 + { + System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); + _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); + } + } + } + } +} diff --git a/SushiBar/SushiBar/Forms/FormReportOrders.resx b/SushiBar/SushiBar/Forms/FormReportOrders.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/SushiBar/SushiBar/Forms/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/Forms/FormReportSushiComponents.Designer.cs b/SushiBar/SushiBar/Forms/FormReportSushiComponents.Designer.cs new file mode 100644 index 0000000..23a38f1 --- /dev/null +++ b/SushiBar/SushiBar/Forms/FormReportSushiComponents.Designer.cs @@ -0,0 +1,108 @@ +namespace SushiBar.Forms +{ + partial class FormReportSushiComponents + { + /// + /// 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() + { + buttonSaveToExcel = new Button(); + dataGridView = new DataGridView(); + Component = new DataGridViewTextBoxColumn(); + Sushi = new DataGridViewTextBoxColumn(); + Count = new DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // buttonSaveToExcel + // + buttonSaveToExcel.Location = new Point(11, 12); + buttonSaveToExcel.Name = "buttonSaveToExcel"; + buttonSaveToExcel.Size = new Size(234, 29); + buttonSaveToExcel.TabIndex = 0; + buttonSaveToExcel.Text = "Сохранить в Excel"; + buttonSaveToExcel.UseVisualStyleBackColor = true; + buttonSaveToExcel.Click += buttonSaveToExcel_Click; + // + // dataGridView + // + dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; + dataGridView.ClipboardCopyMode = DataGridViewClipboardCopyMode.EnableAlwaysIncludeHeaderText; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { Component, Sushi, Count }); + dataGridView.Location = new Point(11, 47); + dataGridView.MultiSelect = false; + dataGridView.Name = "dataGridView"; + dataGridView.RowHeadersWidthSizeMode = DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders; + dataGridView.RowTemplate.Height = 29; + dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; + dataGridView.Size = new Size(883, 391); + dataGridView.TabIndex = 1; + // + // Component + // + Component.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + Component.HeaderText = "Компонент"; + Component.MinimumWidth = 6; + Component.Name = "Component"; + // + // Sushi + // + Sushi.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + Sushi.HeaderText = "Суши"; + Sushi.MinimumWidth = 6; + Sushi.Name = "Sushi"; + // + // Count + // + Count.HeaderText = "Количество"; + Count.MinimumWidth = 6; + Count.Name = "Count"; + Count.Width = 125; + // + // FormReportSushiComponents + // + AllowDrop = true; + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(909, 457); + Controls.Add(dataGridView); + Controls.Add(buttonSaveToExcel); + Name = "FormReportSushiComponents"; + Text = "FormReportSushiComponents"; + Load += FormReportSushiComponents_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Button buttonSaveToExcel; + private DataGridView dataGridView; + private DataGridViewTextBoxColumn Component; + private DataGridViewTextBoxColumn Sushi; + private DataGridViewTextBoxColumn Count; + } +} \ No newline at end of file diff --git a/SushiBar/SushiBar/Forms/FormReportSushiComponents.cs b/SushiBar/SushiBar/Forms/FormReportSushiComponents.cs new file mode 100644 index 0000000..15bc80e --- /dev/null +++ b/SushiBar/SushiBar/Forms/FormReportSushiComponents.cs @@ -0,0 +1,79 @@ +using Microsoft.Extensions.Logging; +using SushiBarContracts.BindingModels; +using SushiBarContracts.BusinessLogicsContracts; +using System.Windows.Forms; + +namespace SushiBar.Forms +{ + public partial class FormReportSushiComponents : Form + { + private readonly ILogger _logger; + private readonly IReportLogic _logic; + public FormReportSushiComponents(ILogger + logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormReportSushiComponents_Load(object sender, EventArgs e) + { + try + { + var dict = _logic.GetSushiComponent(); + if (dict != null) + { + dataGridView.Rows.Clear(); + foreach (var elem in dict) + { + dataGridView.Rows.Add(new object[] { + elem.SushiName, "", "" + }); + 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 buttonSaveToExcel_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog + { + Filter = "xlsx|*.xlsx" + }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + _logic.SaveSushiComponentToExcelFile(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/SushiBar/SushiBar/Forms/FormReportSushiComponents.resx b/SushiBar/SushiBar/Forms/FormReportSushiComponents.resx new file mode 100644 index 0000000..2a73aa9 --- /dev/null +++ b/SushiBar/SushiBar/Forms/FormReportSushiComponents.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/SushiBar/SushiBar/Forms/FormSushi.Designer.cs b/SushiBar/SushiBar/Forms/FormSushi.Designer.cs index 2a52066..732a2df 100644 --- a/SushiBar/SushiBar/Forms/FormSushi.Designer.cs +++ b/SushiBar/SushiBar/Forms/FormSushi.Designer.cs @@ -118,7 +118,7 @@ groupBox1.TabStop = false; groupBox1.Text = "Компоненты"; // - // ButtonRef + // buttonRef // ButtonRef.Anchor = AnchorStyles.Top | AnchorStyles.Right; ButtonRef.Location = new Point(614, 168); diff --git a/SushiBar/SushiBar/Forms/FormSushis.Designer.cs b/SushiBar/SushiBar/Forms/FormSushis.Designer.cs index 5b297a2..c9606ff 100644 --- a/SushiBar/SushiBar/Forms/FormSushis.Designer.cs +++ b/SushiBar/SushiBar/Forms/FormSushis.Designer.cs @@ -38,9 +38,9 @@ // // dataGridView // + dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.ColumnHeader; dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Dock = DockStyle.Left; dataGridView.Location = new Point(0, 0); dataGridView.Name = "dataGridView"; dataGridView.RowHeadersWidth = 70; diff --git a/SushiBar/SushiBar/Program.cs b/SushiBar/SushiBar/Program.cs index c16393c..2b7ab08 100644 --- a/SushiBar/SushiBar/Program.cs +++ b/SushiBar/SushiBar/Program.cs @@ -3,6 +3,8 @@ using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; using SushiBar.Forms; using SushiBarBusinessLogic.BusinessLogics; +using SushiBarBusinessLogic.OfficePackage; +using SushiBarBusinessLogic.OfficePackage.Implements; using SushiBarContracts.BusinessLogicsContracts; using SushiBarContracts.StoragesContracts; using SushiBarDatabaseImplement.Implements; @@ -41,6 +43,7 @@ namespace SushiBar services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -49,6 +52,12 @@ namespace SushiBar services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } diff --git a/SushiBar/SushiBar/Report/ReportOrders.rdlc b/SushiBar/SushiBar/Report/ReportOrders.rdlc new file mode 100644 index 0000000..55df95e --- /dev/null +++ b/SushiBar/SushiBar/Report/ReportOrders.rdlc @@ -0,0 +1,599 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 47cb53f0-7dde-4717-ba03-866a0bc4f4dd + + + + + + SushiBarContractsViewModels + /* Local Query */ + + + + Id + System.Int32 + + + DateCreate + System.DateTime + + + SushiName + System.String + + + OrderStatus + SushiBarDataModels.OrderStatus + + + Sum + System.Decimal + + + + SushiBarContracts.ViewModels + ReportOrderViewModel + SushiBarContracts.ViewModels.ReportOrderViewModel, 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.59525cm + + + 3.30963cm + + + 8.32842cm + + + 2.59525cm + + + 2.59525cm + + + + + 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 + 19.4238cm + 2 + + + + + + true + true + + + + + Итого: + + + + + + + 4.21167cm + 14.97625cm + 0.6cm + 2.5cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!Sum.Value, "DataSetOrders") + + + + + + + 4.21167cm + 17.47625cm + 0.6cm + 2.5cm + 4 + + + 2pt + 2pt + 2pt + 2pt + + + + 5.72875cm +