diff --git a/FurnitureAssembly/FurnitureAssembly.sln b/FurnitureAssembly/FurnitureAssembly.sln index 2b753c4..ff7d6ae 100644 --- a/FurnitureAssembly/FurnitureAssembly.sln +++ b/FurnitureAssembly/FurnitureAssembly.sln @@ -15,7 +15,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyListImplem EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemFileImplement", "FurnitureAssemFileImplement\FurnitureAssemFileImplement.csproj", "{A6822E0E-DBF3-4DEA-A337-C6C64429C0DE}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FurnitureAssemblyDatabaseImplement", "FurnitureAssemblyDatabaseImplement\FurnitureAssemblyDatabaseImplement.csproj", "{F4FAEBEF-1E02-44DE-A13B-27A8C3838D98}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "FurnitureAssemblyDatabaseImplement", "FurnitureAssemblyDatabaseImplement\FurnitureAssemblyDatabaseImplement.csproj", "{F4FAEBEF-1E02-44DE-A13B-27A8C3838D98}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs index 0199789..fe10999 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs +++ b/FurnitureAssembly/FurnitureAssembly/FormMain.Designer.cs @@ -38,6 +38,10 @@ 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.списокКомонентовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.компонентыПоИзделиямToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.menuStrip1.SuspendLayout(); this.SuspendLayout(); @@ -104,7 +108,8 @@ // menuStrip1 // this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.справочникиToolStripMenuItem}); + this.справочникиToolStripMenuItem, + this.отчетыToolStripMenuItem}); this.menuStrip1.Location = new System.Drawing.Point(0, 0); this.menuStrip1.Name = "menuStrip1"; this.menuStrip1.Size = new System.Drawing.Size(1065, 24); @@ -134,6 +139,37 @@ this.изделияToolStripMenuItem.Text = "Изделия"; this.изделияToolStripMenuItem.Click += new System.EventHandler(this.ИзделияToolStripMenuItem_Click); // + // отчеты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(218, 22); + this.списокКомонентовToolStripMenuItem.Text = "Список комонентов"; + this.списокКомонентовToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click); + // + // компонентыПоИзделиямToolStripMenuItem + // + this.компонентыПоИзделиямToolStripMenuItem.Name = "компонентыПоИзделиямToolStripMenuItem"; + this.компонентыПоИзделиямToolStripMenuItem.Size = new System.Drawing.Size(218, 22); + this.компонентыПоИзделиямToolStripMenuItem.Text = "Компоненты по изделиям"; + this.компонентыПоИзделиямToolStripMenuItem.Click += new System.EventHandler(this.ComponentProductsToolStripMenuItem_Click); + // + // списокЗаказовToolStripMenuItem + // + this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; + this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(218, 22); + this.списокЗаказовToolStripMenuItem.Text = "Список заказов"; + this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.OrdersToolStripMenuItem_Click); + // // FormMain // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -170,5 +206,9 @@ private ToolStripMenuItem справочникиToolStripMenuItem; private ToolStripMenuItem компонентыToolStripMenuItem; private ToolStripMenuItem изделияToolStripMenuItem; + private ToolStripMenuItem отчетыToolStripMenuItem; + private ToolStripMenuItem списокКомонентовToolStripMenuItem; + private ToolStripMenuItem компонентыПоИзделиямToolStripMenuItem; + private ToolStripMenuItem списокЗаказовToolStripMenuItem; } } \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/FormMain.cs b/FurnitureAssembly/FurnitureAssembly/FormMain.cs index 62e043a..e4d50f1 100644 --- a/FurnitureAssembly/FurnitureAssembly/FormMain.cs +++ b/FurnitureAssembly/FurnitureAssembly/FormMain.cs @@ -1,4 +1,5 @@ -using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyBusinessLogic; +using FurnitureAssemblyContracts.BindingModels; using FurnitureAssemblyContracts.BusinessLogicsContarcts; using FurnitureAssemblyDataModels.Enums; using Microsoft.Extensions.Logging; @@ -18,11 +19,13 @@ namespace FurnitureAssembly { 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) { @@ -153,6 +156,40 @@ namespace FurnitureAssembly private void ButtonRef_Click(object sender, EventArgs e) { LoadData(); - } + } + + private void ComponentsToolStripMenuItem_Click(object sender, EventArgs + e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SaveComponentsToWordFile(new ReportBindingModel + { + FileName = dialog.FileName + }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, + MessageBoxIcon.Information); + } + } + private void ComponentProductsToolStripMenuItem_Click(object sender, + EventArgs e) + { + var service = + Program.ServiceProvider?.GetService(typeof(FormReportFurnitureComponents)); + if (service is FormReportFurnitureComponents 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(); + } + } } } diff --git a/FurnitureAssembly/FurnitureAssembly/FormReportFurnitureComponents.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormReportFurnitureComponents.Designer.cs new file mode 100644 index 0000000..a77a5e5 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormReportFurnitureComponents.Designer.cs @@ -0,0 +1,104 @@ +namespace FurnitureAssembly +{ + partial class FormReportFurnitureComponents + { + /// + /// 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.ButtonSaveToExcel = new System.Windows.Forms.Button(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.Component = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Furniture = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // ButtonSaveToExcel + // + this.ButtonSaveToExcel.Location = new System.Drawing.Point(12, 31); + this.ButtonSaveToExcel.Name = "ButtonSaveToExcel"; + this.ButtonSaveToExcel.Size = new System.Drawing.Size(166, 27); + this.ButtonSaveToExcel.TabIndex = 0; + this.ButtonSaveToExcel.Text = "Сохранить в Excel"; + this.ButtonSaveToExcel.UseVisualStyleBackColor = true; + this.ButtonSaveToExcel.Click += new System.EventHandler(this.ButtonSaveToExcel_Click); + // + // dataGridView + // + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.Component, + this.Furniture, + this.Count}); + this.dataGridView.Location = new System.Drawing.Point(12, 80); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(600, 358); + this.dataGridView.TabIndex = 1; + // + // Component + // + this.Component.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.Component.HeaderText = "Компонент"; + this.Component.Name = "Component"; + // + // Furniture + // + this.Furniture.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.Furniture.HeaderText = "Изделие"; + this.Furniture.Name = "Furniture"; + // + // Count + // + this.Count.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.ColumnHeader; + this.Count.HeaderText = "Количество"; + this.Count.Name = "Count"; + this.Count.Width = 97; + // + // FormReportFurnitureComponents + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(627, 450); + this.Controls.Add(this.dataGridView); + this.Controls.Add(this.ButtonSaveToExcel); + this.Name = "FormReportFurnitureComponents"; + this.Text = "Компоненты по изделиям"; + this.Load += new System.EventHandler(this.FormReportProductComponents_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private Button ButtonSaveToExcel; + private DataGridView dataGridView; + private DataGridViewTextBoxColumn Component; + private DataGridViewTextBoxColumn Furniture; + private DataGridViewTextBoxColumn Count; + } +} \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/FormReportFurnitureComponents.cs b/FurnitureAssembly/FurnitureAssembly/FormReportFurnitureComponents.cs new file mode 100644 index 0000000..8083445 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormReportFurnitureComponents.cs @@ -0,0 +1,81 @@ +using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyContracts.BusinessLogicsContarcts; +using Microsoft.Extensions.Logging; +using System.Windows.Forms; + +namespace FurnitureAssembly +{ + public partial class FormReportFurnitureComponents : Form + { + + private readonly ILogger _logger; + private readonly IReportLogic _logic; + + public FormReportFurnitureComponents(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + + private void FormReportProductComponents_Load(object sender, EventArgs e) + { + try + { + var dict = _logic.GetFurnitureComponent(); + if (dict != null) + { + dataGridView.Rows.Clear(); + foreach (var elem in dict) + { + dataGridView.Rows.Add(new object[] { elem.ComponentName, "", "" }); + foreach (var listElem in elem.Furnitures) + { + 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.SaveFurnitureComponentToExcelFile(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/FurnitureAssembly/FurnitureAssembly/FormReportFurnitureComponents.resx b/FurnitureAssembly/FurnitureAssembly/FormReportFurnitureComponents.resx new file mode 100644 index 0000000..95b78ed --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormReportFurnitureComponents.resx @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 + + + True + + + True + + + True + + \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/FormReportOrders.Designer.cs b/FurnitureAssembly/FurnitureAssembly/FormReportOrders.Designer.cs new file mode 100644 index 0000000..0219e3f --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormReportOrders.Designer.cs @@ -0,0 +1,153 @@ +namespace FurnitureAssembly +{ + 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.button1 = new System.Windows.Forms.Button(); + this.panel.SuspendLayout(); + this.SuspendLayout(); + // + // panel + // + this.panel.Controls.Add(this.button1); + 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(987, 40); + this.panel.TabIndex = 1; + // + // 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(1665, 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; + // + // 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 = "С"; + // + // button1 + // + this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); + this.button1.Location = new System.Drawing.Point(777, 8); + this.button1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(139, 27); + this.button1.TabIndex = 6; + this.button1.Text = "В Pdf"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.ButtonToPdf_Click); + // + // FormReportOrders + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(987, 596); + this.Controls.Add(this.panel); + this.Name = "FormReportOrders"; + this.Text = "Заказы"; + this.panel.ResumeLayout(false); + this.panel.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private Panel panel; + private Button button1; + private Button buttonToPdf; + private Button buttonMake; + private DateTimePicker dateTimePickerTo; + private Label labelTo; + private DateTimePicker dateTimePickerFrom; + private Label labelFrom; + } +} \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/FormReportOrders.cs b/FurnitureAssembly/FurnitureAssembly/FormReportOrders.cs new file mode 100644 index 0000000..543b357 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormReportOrders.cs @@ -0,0 +1,100 @@ +using FurnitureAssemblyContracts.BindingModels; +using FurnitureAssemblyContracts.BusinessLogicsContarcts; +using Microsoft.Extensions.Logging; +using Microsoft.Reporting.WinForms; +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 FurnitureAssembly +{ + 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); + } + } + } + } +} diff --git a/FurnitureAssembly/FurnitureAssembly/FormReportOrders.resx b/FurnitureAssembly/FurnitureAssembly/FormReportOrders.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/FormReportOrders.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/FurnitureAssembly/FurnitureAssembly/FurnitureAssembly.csproj b/FurnitureAssembly/FurnitureAssembly/FurnitureAssembly.csproj index 6b9be89..7eb04fa 100644 --- a/FurnitureAssembly/FurnitureAssembly/FurnitureAssembly.csproj +++ b/FurnitureAssembly/FurnitureAssembly/FurnitureAssembly.csproj @@ -10,12 +10,16 @@ + Always + + Always + @@ -27,13 +31,19 @@ + + + + + + \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/Program.cs b/FurnitureAssembly/FurnitureAssembly/Program.cs index 3058944..9c472b4 100644 --- a/FurnitureAssembly/FurnitureAssembly/Program.cs +++ b/FurnitureAssembly/FurnitureAssembly/Program.cs @@ -1,4 +1,6 @@ using FurnitureAssemblyBusinessLogic; +using FurnitureAssemblyBusinessLogic.OfficePackage.Implements; +using FurnitureAssemblyBusinessLogic.OfficePackage; using FurnitureAssemblyContracts.BusinessLogicsContarcts; using FurnitureAssemblyContracts.StoragesContracts; using FurnitureAssemblyDatabaseImplement.Implements; @@ -38,9 +40,16 @@ namespace FurnitureAssembly 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(); @@ -48,6 +57,8 @@ namespace FurnitureAssembly services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/FurnitureAssembly/FurnitureAssembly/ReportOrders.rdlc b/FurnitureAssembly/FurnitureAssembly/ReportOrders.rdlc new file mode 100644 index 0000000..29dd1f4 --- /dev/null +++ b/FurnitureAssembly/FurnitureAssembly/ReportOrders.rdlc @@ -0,0 +1,600 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 10791c83-cee8-4a38-bbd0-245fc17cefb3 + + + + + + FurnitureAssemblyContractsViewModels + /* Local Query */ + + + + Id + System.Int32 + + + DateCreate + System.DateTime + + + FurnitureName + System.String + + + Sum + System.Decimal + + + OrderStatus + FurnitureAssemblyDataModels.OrderStatus + + + + FurnitureAssemblyContracts.ViewModels + ReportOrdersViewModel + FurnitureAssemblyContracts.ViewModels.ReportOrdersViewModel, ConfectioneryContracts, 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 + + + 3.02917cm + + + 2.87042cm + + + + + 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!FurnitureName.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!OrderStatus.Value + + + 2pt + 2pt + 2pt + 2pt + + + true + + + + + + true + true + + + + + =Fields!Sum.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSetOrders + 2.48391cm + 0.55245cm + 1.2cm + 19.84713cm + 2 + + + + + + true + true + + + + + Итого: + + + + + + + 4cm + 15.39958cm + 0.6cm + 2.5cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!Sum.Value, "DataSetOrders") + + + + + + + 4cm + 17.89958cm + 0.6cm + 2.5cm + 4 + + + 2pt + 2pt + 2pt + 2pt + + + + 5.72875cm +