diff --git a/SushiBar/Reports/FormReportOrders.Designer.cs b/SushiBar/Reports/FormReportOrders.Designer.cs new file mode 100644 index 0000000..3e17dca --- /dev/null +++ b/SushiBar/Reports/FormReportOrders.Designer.cs @@ -0,0 +1,128 @@ +namespace SushiBarView.Reports +{ + 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(); + dateTimePickerDateTo = new DateTimePicker(); + dateTimePickerDateFrom = new DateTimePicker(); + buttonMake = new Button(); + buttonToPdf = new Button(); + labelTo = new Label(); + labelFrom = new Label(); + panel.SuspendLayout(); + SuspendLayout(); + // + // panel + // + panel.Controls.Add(labelFrom); + panel.Controls.Add(buttonToPdf); + panel.Controls.Add(dateTimePickerDateFrom); + panel.Controls.Add(labelTo); + panel.Controls.Add(dateTimePickerDateTo); + panel.Controls.Add(buttonMake); + panel.Dock = DockStyle.Top; + panel.Location = new Point(0, 0); + panel.Name = "panel"; + panel.Size = new Size(1321, 71); + panel.TabIndex = 3; + // + // dateTimePickerDateTo + // + dateTimePickerDateTo.Location = new Point(365, 27); + dateTimePickerDateTo.Name = "dateTimePickerDateTo"; + dateTimePickerDateTo.Size = new Size(250, 27); + dateTimePickerDateTo.TabIndex = 1; + // + // dateTimePickerDateFrom + // + dateTimePickerDateFrom.Location = new Point(51, 27); + dateTimePickerDateFrom.Name = "dateTimePickerDateFrom"; + dateTimePickerDateFrom.Size = new Size(250, 27); + dateTimePickerDateFrom.TabIndex = 0; + // + // buttonMake + // + buttonMake.Location = new Point(677, 27); + buttonMake.Name = "buttonMake"; + buttonMake.Size = new Size(132, 29); + buttonMake.TabIndex = 3; + buttonMake.Text = "Сформировать"; + buttonMake.UseVisualStyleBackColor = true; + // + // buttonToPdf + // + buttonToPdf.Location = new Point(1200, 27); + buttonToPdf.Name = "buttonToPdf"; + buttonToPdf.Size = new Size(94, 29); + buttonToPdf.TabIndex = 4; + buttonToPdf.Text = "В PDF"; + buttonToPdf.UseVisualStyleBackColor = true; + // + // labelTo + // + labelTo.AutoSize = true; + labelTo.Location = new Point(317, 31); + labelTo.Name = "labelTo"; + labelTo.Size = new Size(29, 20); + labelTo.TabIndex = 4; + labelTo.Text = "По"; + // + // labelFrom + // + labelFrom.AutoSize = true; + labelFrom.Location = new Point(16, 31); + labelFrom.Name = "labelFrom"; + labelFrom.Size = new Size(18, 20); + labelFrom.TabIndex = 3; + labelFrom.Text = "С"; + // + // FormReportOrders + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(1321, 450); + Controls.Add(panel); + Name = "FormReportOrders"; + Text = "FormReportOrders"; + panel.ResumeLayout(false); + panel.PerformLayout(); + ResumeLayout(false); + } + + #endregion + private GroupBox groupBox1; + private Panel panel; + private DateTimePicker dateTimePickerDateTo; + private DateTimePicker dateTimePickerDateFrom; + private Button buttonMake; + private Button buttonToPdf; + private Label labelTo; + private Label labelFrom; + } +} \ No newline at end of file diff --git a/SushiBar/Reports/FormReportOrders.cs b/SushiBar/Reports/FormReportOrders.cs new file mode 100644 index 0000000..b6822e8 --- /dev/null +++ b/SushiBar/Reports/FormReportOrders.cs @@ -0,0 +1,101 @@ +using Microsoft.Extensions.Logging; +using Microsoft.Reporting.WinForms; +using SushiBarContracts.BindingModel; +using SushiBarContracts.BusinessLogicsContracts; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace SushiBarView.Reports +{ + 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 (dateTimePickerDateFrom.Value.Date >= dateTimePickerDateTo.Value.Date) + { + MessageBox.Show("Дата начала должна быть меньше даты окончания", + "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + try + { + var dataSource = _logic.GetOrders(new ReportBindingModel + { + DateFrom = dateTimePickerDateFrom.Value, + DateTo = dateTimePickerDateTo.Value + }); + var source = new ReportDataSource("DataSetOrders", dataSource); + reportViewer.LocalReport.DataSources.Clear(); + reportViewer.LocalReport.DataSources.Add(source); + var parameters = new[] { new ReportParameter("ReportParameterPeriod", + $"c{dateTimePickerDateFrom.Value.ToShortDateString()} по {dateTimePickerDateTo.Value.ToShortDateString()}") + }; + reportViewer.LocalReport.SetParameters(parameters); + reportViewer.RefreshReport(); + _logger.LogInformation("Загрузка списка заказов на период {From} - {To} ", + dateTimePickerDateFrom.Value.ToShortDateString(), dateTimePickerDateTo.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 (dateTimePickerDateFrom.Value.Date >= dateTimePickerDateTo.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 = dateTimePickerDateFrom.Value, + DateTo = dateTimePickerDateTo.Value + }); + _logger.LogInformation("Сохранение списка заказов на период { From} - { To} ", + dateTimePickerDateFrom.Value.ToShortDateString(), dateTimePickerDateTo.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/Reports/FormReportOrders.resx b/SushiBar/Reports/FormReportOrders.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/SushiBar/Reports/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/Reports/FormReportSushiComponent.Designer.cs b/SushiBar/Reports/FormReportSushiComponent.Designer.cs new file mode 100644 index 0000000..f851f4e --- /dev/null +++ b/SushiBar/Reports/FormReportSushiComponent.Designer.cs @@ -0,0 +1,102 @@ +namespace SushiBarView +{ + partial class FormReportSushiComponent + { + /// + /// 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() + { + dataGridView1 = new DataGridView(); + Component = new DataGridViewTextBoxColumn(); + Sushi = new DataGridViewTextBoxColumn(); + Count = new DataGridViewTextBoxColumn(); + buttonSaveToExcel = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit(); + SuspendLayout(); + // + // dataGridView1 + // + dataGridView1.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; + dataGridView1.BackgroundColor = Color.LightGoldenrodYellow; + dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView1.Columns.AddRange(new DataGridViewColumn[] { Component, Sushi, Count }); + dataGridView1.Dock = DockStyle.Bottom; + dataGridView1.Location = new Point(0, 57); + dataGridView1.Name = "dataGridView1"; + dataGridView1.RowHeadersVisible = false; + dataGridView1.RowHeadersWidth = 51; + dataGridView1.Size = new Size(800, 448); + dataGridView1.TabIndex = 0; + // + // Component + // + Component.HeaderText = "Компонент"; + Component.MinimumWidth = 6; + Component.Name = "Component"; + // + // Sushi + // + Sushi.HeaderText = "Суши"; + Sushi.MinimumWidth = 6; + Sushi.Name = "Sushi"; + // + // Count + // + Count.HeaderText = "Количество"; + Count.MinimumWidth = 6; + Count.Name = "Count"; + // + // buttonSaveToExcel + // + buttonSaveToExcel.BackColor = Color.Goldenrod; + buttonSaveToExcel.Location = new Point(319, 9); + buttonSaveToExcel.Name = "buttonSaveToExcel"; + buttonSaveToExcel.Size = new Size(170, 36); + buttonSaveToExcel.TabIndex = 1; + buttonSaveToExcel.Text = "Сохранить в Excel"; + buttonSaveToExcel.UseVisualStyleBackColor = false; + // + // FormReportSushiComponent + // + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(800, 505); + Controls.Add(buttonSaveToExcel); + Controls.Add(dataGridView1); + Name = "FormReportSushiComponent"; + Text = "Компоненты по изделиям"; + ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); + ResumeLayout(false); + } + + #endregion + + private DataGridView dataGridView1; + private Button buttonSaveToExcel; + private DataGridViewTextBoxColumn Component; + private DataGridViewTextBoxColumn Sushi; + private DataGridViewTextBoxColumn Count; + } +} \ No newline at end of file diff --git a/SushiBar/Reports/FormReportSushiComponent.cs b/SushiBar/Reports/FormReportSushiComponent.cs new file mode 100644 index 0000000..2019ab2 --- /dev/null +++ b/SushiBar/Reports/FormReportSushiComponent.cs @@ -0,0 +1,73 @@ +using Microsoft.Extensions.Logging; +using SushiBarContracts.BindingModel; +using SushiBarContracts.BusinessLogicsContracts; + +namespace SushiBarView +{ + public partial class FormReportSushiComponent : Form + { + private readonly ILogger _logger; + private readonly IReportLogic _logic; + public FormReportSushiComponent(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + private void FormReportProductComponents_Load(object sender, EventArgs e) + { + try + { + var dict = _logic.GetSushiComponent(); + if (dict != null) + { + dataGridView1.Rows.Clear(); + foreach (var elem in dict) + { + dataGridView1.Rows.Add(new object[] { elem.ComponentName, "", "" }); + foreach (var listElem in elem.Sushis) + { + dataGridView1.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 }); + } + dataGridView1.Rows.Add(new object[] { "Итого", "", elem.TotalCount }); + dataGridView1.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/Reports/FormReportSushiComponent.resx b/SushiBar/Reports/FormReportSushiComponent.resx new file mode 100644 index 0000000..2a73aa9 --- /dev/null +++ b/SushiBar/Reports/FormReportSushiComponent.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/Reports/ReportOrders.rdlc b/SushiBar/Reports/ReportOrders.rdlc new file mode 100644 index 0000000..872aad4 --- /dev/null +++ b/SushiBar/Reports/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 +