diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/BlacksmithWorkshopView.csproj b/BlacksmithWorkshop/BlacksmithWorkshop/BlacksmithWorkshopView.csproj index fe9d4c2..59d8696 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/BlacksmithWorkshopView.csproj +++ b/BlacksmithWorkshop/BlacksmithWorkshop/BlacksmithWorkshopView.csproj @@ -10,6 +10,7 @@ + @@ -20,6 +21,9 @@ Always + + Always + @@ -40,4 +44,10 @@ + + + Form + + + \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs index 60a9bae..8745b33 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.Designer.cs @@ -38,6 +38,7 @@ this.reportManufactureComponentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.reportOrdersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.reportStoresToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.reportManufacturesInStoreToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.dataGridView = new System.Windows.Forms.DataGridView(); this.buttonCreateOrder = new System.Windows.Forms.Button(); this.buttonTakeOrderInWork = new System.Windows.Forms.Button(); @@ -46,7 +47,7 @@ this.buttonRef = new System.Windows.Forms.Button(); this.buttonFillStore = new System.Windows.Forms.Button(); this.buttonSellManufacture = new System.Windows.Forms.Button(); - this.reportManufacturesInStoreToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.reportGroupOrdersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.SuspendLayout(); @@ -100,7 +101,8 @@ this.reportManufactureComponentsToolStripMenuItem, this.reportOrdersToolStripMenuItem, this.reportStoresToolStripMenuItem, - this.reportManufacturesInStoreToolStripMenuItem}); + this.reportManufacturesInStoreToolStripMenuItem, + this.reportGroupOrdersToolStripMenuItem}); this.reportToolStripMenuItem.Name = "reportToolStripMenuItem"; this.reportToolStripMenuItem.Size = new System.Drawing.Size(51, 20); this.reportToolStripMenuItem.Text = "Отчет"; @@ -133,6 +135,13 @@ this.reportStoresToolStripMenuItem.Text = "Список магазинов"; this.reportStoresToolStripMenuItem.Click += new System.EventHandler(this.ReportStoresToolStripMenuItem_Click); // + // reportManufacturesInStoreToolStripMenuItem + // + this.reportManufacturesInStoreToolStripMenuItem.Name = "reportManufacturesInStoreToolStripMenuItem"; + this.reportManufacturesInStoreToolStripMenuItem.Size = new System.Drawing.Size(218, 22); + this.reportManufacturesInStoreToolStripMenuItem.Text = "Изделия в магазинах"; + this.reportManufacturesInStoreToolStripMenuItem.Click += new System.EventHandler(this.ReportManufacturesInStoreToolStripMenuItem_Click); + // // dataGridView // this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight; @@ -219,12 +228,12 @@ this.buttonSellManufacture.UseVisualStyleBackColor = true; this.buttonSellManufacture.Click += new System.EventHandler(this.ButtonSellManufacture_Click); // - // reportManufacturesInStoreToolStripMenuItem + // reportGroupOrdersToolStripMenuItem // - this.reportManufacturesInStoreToolStripMenuItem.Name = "reportManufacturesInStoreToolStripMenuItem"; - this.reportManufacturesInStoreToolStripMenuItem.Size = new System.Drawing.Size(218, 22); - this.reportManufacturesInStoreToolStripMenuItem.Text = "Изделия в магазинах"; - this.reportManufacturesInStoreToolStripMenuItem.Click += new System.EventHandler(this.ReportManufacturesInStoreToolStripMenuItem_Click); + this.reportGroupOrdersToolStripMenuItem.Name = "reportGroupOrdersToolStripMenuItem"; + this.reportGroupOrdersToolStripMenuItem.Size = new System.Drawing.Size(218, 22); + this.reportGroupOrdersToolStripMenuItem.Text = "Заказы по датам"; + this.reportGroupOrdersToolStripMenuItem.Click += new System.EventHandler(this.ReportGroupOrdersToolStripMenuItem_Click); // // FormMain // @@ -273,5 +282,6 @@ private ToolStripMenuItem reportOrdersToolStripMenuItem; private ToolStripMenuItem reportStoresToolStripMenuItem; private ToolStripMenuItem reportManufacturesInStoreToolStripMenuItem; + private ToolStripMenuItem reportGroupOrdersToolStripMenuItem; } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs index a568a2a..6c14fe6 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormMain.cs @@ -220,5 +220,15 @@ namespace BlacksmithWorkshopView LoadData(); } } + + private void ReportGroupOrdersToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportGroupOrders)); + if (service is FormReportGroupOrders form) + { + form.ShowDialog(); + LoadData(); + } + } } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormReportGroupOrders.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormReportGroupOrders.cs new file mode 100644 index 0000000..a4abc4f --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormReportGroupOrders.cs @@ -0,0 +1,71 @@ +using BlacksmithWorkshopContracts.BindingModels; +using BlacksmithWorkshopContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; +using Microsoft.Reporting.WinForms; + +namespace BlacksmithWorkshopView +{ + public partial class FormReportGroupOrders : Form + { + private readonly ReportViewer reportViewer; + + private readonly ILogger _logger; + + private readonly IReportLogic _logic; + + public FormReportGroupOrders(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + reportViewer = new ReportViewer + { + Dock = DockStyle.Fill + }; + reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportGroupOrders.rdlc", FileMode.Open)); + Controls.Clear(); + Controls.Add(reportViewer); + Controls.Add(panel); + } + + private void ButtonMake_Click(object sender, EventArgs e) + { + try + { + var dataSource = _logic.GetGroupOrders(); + var source = new ReportDataSource("DataSetOrders", dataSource); + reportViewer.LocalReport.DataSources.Clear(); + reportViewer.LocalReport.DataSources.Add(source); + + reportViewer.RefreshReport(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка заказов на период"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonToPdf_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + _logic.SaveGroupOrdersToPdfFile(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/BlacksmithWorkshop/BlacksmithWorkshop/FormReportGroupOrders.designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormReportGroupOrders.designer.cs new file mode 100644 index 0000000..a1bb41b --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormReportGroupOrders.designer.cs @@ -0,0 +1,92 @@ +namespace BlacksmithWorkshopView +{ + partial class FormReportGroupOrders + { + /// + /// 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.panel.SuspendLayout(); + this.SuspendLayout(); + // + // panel + // + this.panel.Controls.Add(this.buttonToPdf); + this.panel.Controls.Add(this.buttonMake); + 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(13, 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); + // + // FormReportGroupOrders + // + 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 = "FormReportGroupOrders"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Заказы"; + this.panel.ResumeLayout(false); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel panel; + private System.Windows.Forms.Button buttonToPdf; + private System.Windows.Forms.Button buttonMake; + } +} \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormReportGroupOrders.resx b/BlacksmithWorkshop/BlacksmithWorkshop/FormReportGroupOrders.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormReportGroupOrders.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/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs b/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs index 0b4e84e..29d1343 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/Program.cs @@ -60,6 +60,7 @@ namespace BlacksmithWorkshopView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/ReportGroupOrders.rdlc b/BlacksmithWorkshop/BlacksmithWorkshop/ReportGroupOrders.rdlc new file mode 100644 index 0000000..ea2f7f7 --- /dev/null +++ b/BlacksmithWorkshop/BlacksmithWorkshop/ReportGroupOrders.rdlc @@ -0,0 +1,459 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 10791c83-cee8-4a38-bbd0-245fc17cefb3 + + + + + + BlacksmithWorkshopContractsViewModels + /* Local Query */ + + + + Date + System.DateTime + + + Count + System.Int32 + + + Sum + System.Double + + + + BlacksmithWorkshopContracts.ViewModels + ReportOrdersViewModel + BlacksmithWorkshopContracts.ViewModels.ReportOrdersViewModel, BlacksmithWorkshopContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + + + + + + + true + true + + + + + =Parameters!ReportParameterPeriod.Value + + + + + + + ReportParameterPeriod + 1cm + 1cm + 12.40104cm + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Заказы + + + + + + + 1cm + 12.40104cm + 1 + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + 3.21438cm + + + 3.53188cm + + + 4.35209cm + + + + + 0.6cm + + + + + true + true + + + + + Дата создания + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Количество заказов + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Сумма + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.6cm + + + + + true + true + + + + + =Fields!Date.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Count.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Sum.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSetOrders + 2.48391cm + 0.55245cm + 1.2cm + 11.09835cm + 2 + + + + + + true + true + + + + + Итого: + + + + + + + 4cm + 6.6508cm + 0.6cm + 2.5cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!Sum.Value, "DataSetOrders") + + + + + + + 4cm + 9.1508cm + 0.6cm + 2.5cm + 4 + + + 2pt + 2pt + 2pt + 2pt + + + + 5.72875cm +