diff --git a/SoftwareInstallation/SoftwareInstallation/FormMain.Designer.cs b/SoftwareInstallation/SoftwareInstallation/FormMain.Designer.cs index a850436..44742c2 100644 --- a/SoftwareInstallation/SoftwareInstallation/FormMain.Designer.cs +++ b/SoftwareInstallation/SoftwareInstallation/FormMain.Designer.cs @@ -1,4 +1,6 @@ -namespace SoftwareInstallationView +using SoftwareInstallation; + +namespace SoftwareInstallationView { partial class FormMain { @@ -121,6 +123,37 @@ this.guideToolStripMenuItem.Size = new System.Drawing.Size(94, 20); this.guideToolStripMenuItem.Text = "Справочники"; // + // reportsToolStripMenuItem + // + //this.reportsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + //this.packagesToolStripMenuItem, + //this.packageSoftwaresToolStripMenuItem, + //this.ordersToolStripMenuItem}); + //this.reportsToolStripMenuItem.Name = "reportsToolStripMenuItem"; + //this.reportsToolStripMenuItem.Size = new System.Drawing.Size(73, 24); + //this.reportsToolStripMenuItem.Text = "Отчеты"; + // + // packagesToolStripMenuItem + // + //this.packagesToolStripMenuItem.Name = "packagesToolStripMenuItem"; + //this.packagesToolStripMenuItem.Size = new System.Drawing.Size(252, 26); + //this.packagesToolStripMenuItem.Text = "Список пакетов"; + //this.packagesToolStripMenuItem.Click += new System.EventHandler(this.packagesToolStripMenuItem_Click); + // + // packageSoftwaresToolStripMenuItem + // + //this.packageSoftwaresToolStripMenuItem.Name = "packageSoftwaresToolStripMenuItem"; + //this.packageSoftwaresToolStripMenuItem.Size = new System.Drawing.Size(252, 26); + //this.packageSoftwaresToolStripMenuItem.Text = "ПО по пакетам"; + //this.packageSoftwaresToolStripMenuItem.Click += new System.EventHandler(this.packageSoftwaresToolStripMenuItem_Click); + // + // ordersToolStripMenuItem + // + //this.ordersToolStripMenuItem.Name = "ordersToolStripMenuItem"; + //this.ordersToolStripMenuItem.Size = new System.Drawing.Size(252, 26); + //this.ordersToolStripMenuItem.Text = "Список заказов"; + //this.ordersToolStripMenuItem.Click += new System.EventHandler(this.ordersToolStripMenuItem_Click); + // // packageToolStripMenuItem2 // this.packageToolStripMenuItem2.Name = "packageToolStripMenuItem2"; @@ -170,5 +203,9 @@ private ToolStripMenuItem guideToolStripMenuItem; private ToolStripMenuItem packageToolStripMenuItem2; private ToolStripMenuItem storageToolStripMenuItem3; + private ToolStripMenuItem reportsToolStripMenuItem; + private ToolStripMenuItem packagesToolStripMenuItem; + private ToolStripMenuItem packageSoftwaresToolStripMenuItem; + private ToolStripMenuItem ordersToolStripMenuItem; } } \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallation/FormMain.cs b/SoftwareInstallation/SoftwareInstallation/FormMain.cs index 0113608..328e042 100644 --- a/SoftwareInstallation/SoftwareInstallation/FormMain.cs +++ b/SoftwareInstallation/SoftwareInstallation/FormMain.cs @@ -18,12 +18,14 @@ namespace SoftwareInstallationView { private readonly ILogger _logger; private readonly IOrderLogic _orderLogic; + private readonly IReportLogic _reportLogic; - public FormMain(ILogger logger, IOrderLogic orderLogic) + public FormMain(ILogger logger, IOrderLogic orderLogic , IReportLogic reportLogic) { InitializeSoftware(); _logger = logger; _orderLogic = orderLogic; + _reportLogic = reportLogic; } private void FormMain_Load(object sender, EventArgs e) { @@ -151,10 +153,40 @@ namespace SoftwareInstallationView form.ShowDialog(); } } + private void buttonRef_Click(object sender, EventArgs e) { LoadData(); } + private void ordersToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + if (service is FormReportOrders form) + { + form.ShowDialog(); + } + } + private void packageSoftwaresToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportPackageSoftwares)); + if (service is FormReportOrders form) + { + form.ShowDialog(); + } + } + + private void packagesToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SavePackagesToWordFile(new ReportBindingModel + { + FileName = dialog.FileName + }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } } } diff --git a/SoftwareInstallation/SoftwareInstallation/FormReportOrders.Designer.cs b/SoftwareInstallation/SoftwareInstallation/FormReportOrders.Designer.cs new file mode 100644 index 0000000..b22211d --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallation/FormReportOrders.Designer.cs @@ -0,0 +1,130 @@ +namespace SoftwareInstallationView +{ + 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.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.buttonCreateToPdf = new System.Windows.Forms.Button(); + this.buttonCreateReport = new System.Windows.Forms.Button(); + this.dateTimePicker2 = new System.Windows.Forms.DateTimePicker(); + this.dateTimePicker1 = new System.Windows.Forms.DateTimePicker(); + this.panel.SuspendLayout(); + this.SuspendLayout(); + // + // panel + // + this.panel.Controls.Add(this.label2); + this.panel.Controls.Add(this.label1); + this.panel.Controls.Add(this.buttonCreateToPdf); + this.panel.Controls.Add(this.buttonCreateReport); + this.panel.Controls.Add(this.dateTimePicker2); + this.panel.Controls.Add(this.dateTimePicker1); + this.panel.Location = new System.Drawing.Point(0, 0); + this.panel.Name = "panel"; + this.panel.Size = new System.Drawing.Size(801, 46); + this.panel.TabIndex = 0; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(217, 18); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(23, 15); + this.label2.TabIndex = 5; + this.label2.Text = "По"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(12, 16); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(15, 15); + this.label1.TabIndex = 4; + this.label1.Text = "С"; + // + // buttonCreateToPdf + // + this.buttonCreateToPdf.Location = new System.Drawing.Point(667, 12); + this.buttonCreateToPdf.Name = "buttonCreateToPdf"; + this.buttonCreateToPdf.Size = new System.Drawing.Size(110, 23); + this.buttonCreateToPdf.TabIndex = 3; + this.buttonCreateToPdf.Text = "В Pdf"; + this.buttonCreateToPdf.UseVisualStyleBackColor = true; + this.buttonCreateToPdf.Click += new System.EventHandler(this.buttonCreateToPdf_Click); + // + // buttonCreateReport + // + this.buttonCreateReport.Location = new System.Drawing.Point(441, 12); + this.buttonCreateReport.Name = "buttonCreateReport"; + this.buttonCreateReport.Size = new System.Drawing.Size(100, 23); + this.buttonCreateReport.TabIndex = 2; + this.buttonCreateReport.Text = "Сформировать"; + this.buttonCreateReport.UseVisualStyleBackColor = true; + this.buttonCreateReport.Click += new System.EventHandler(this.buttonCreateReport_Click); + // + // dateTimePicker2 + // + this.dateTimePicker2.Location = new System.Drawing.Point(256, 12); + this.dateTimePicker2.Name = "dateTimePicker2"; + this.dateTimePicker2.Size = new System.Drawing.Size(147, 23); + this.dateTimePicker2.TabIndex = 1; + // + // dateTimePicker1 + // + this.dateTimePicker1.Location = new System.Drawing.Point(53, 12); + this.dateTimePicker1.Name = "dateTimePicker1"; + this.dateTimePicker1.Size = new System.Drawing.Size(147, 23); + this.dateTimePicker1.TabIndex = 0; + // + // FormReportOrders + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.panel); + this.Name = "FormReportOrders"; + this.Text = "FormReportOrders"; + this.panel.ResumeLayout(false); + this.panel.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private Panel panel; + private Label label2; + private Label label1; + private Button buttonCreateToPdf; + private Button buttonCreateReport; + private DateTimePicker dateTimePicker2; + private DateTimePicker dateTimePicker1; + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallation/FormReportOrders.cs b/SoftwareInstallation/SoftwareInstallation/FormReportOrders.cs new file mode 100644 index 0000000..3ba1199 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallation/FormReportOrders.cs @@ -0,0 +1,101 @@ +using AbstractSoftwareInstallationContracts.BindingModels; +using AbstractSoftwareInstallationContracts.BusinessLogicsContracts; +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 SoftwareInstallationView +{ + 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 buttonCreateReport_Click(object sender, EventArgs e) + { + if (dateTimePicker1.Value.Date >= dateTimePicker2.Value.Date) + { + MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + try + { + var dataSource = _logic.GetOrders(new ReportBindingModel + { + DateFrom = dateTimePicker1.Value, + DateTo = dateTimePicker2.Value + }); + var source = new ReportDataSource("DataSetOrders", dataSource); + reportViewer.LocalReport.DataSources.Clear(); + reportViewer.LocalReport.DataSources.Add(source); + var parameters = new[] { new ReportParameter("ReportParameterPeriod", $"c{ dateTimePicker1.Value.ToShortDateString()} по {dateTimePicker2.Value.ToShortDateString()}") }; + reportViewer.LocalReport.SetParameters(parameters); + reportViewer.RefreshReport(); + _logger.LogInformation("Загрузка списка заказов на период {From}-{ To}", dateTimePicker1.Value.ToShortDateString(), dateTimePicker2.Value.ToShortDateString()); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка заказов на период"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + + } + + private void buttonCreateToPdf_Click(object sender, EventArgs e) + { + if (dateTimePicker1.Value.Date >= dateTimePicker2.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 = dateTimePicker1.Value, + DateTo = dateTimePicker2.Value + }); + _logger.LogInformation("Сохранение списка заказов на период { From} -{ To}", dateTimePicker1.Value.ToShortDateString(), dateTimePicker2.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/SoftwareInstallation/SoftwareInstallation/FormReportOrders.resx b/SoftwareInstallation/SoftwareInstallation/FormReportOrders.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallation/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/SoftwareInstallation/SoftwareInstallation/FormReportPackageSoftwares.Designer.cs b/SoftwareInstallation/SoftwareInstallation/FormReportPackageSoftwares.Designer.cs index f8a738b..e6ec60f 100644 --- a/SoftwareInstallation/SoftwareInstallation/FormReportPackageSoftwares.Designer.cs +++ b/SoftwareInstallation/SoftwareInstallation/FormReportPackageSoftwares.Designer.cs @@ -32,6 +32,7 @@ this.ColumnSoftware = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ColumnPackage = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.buttonSaveToExcel = new System.Windows.Forms.Button(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.SuspendLayout(); // @@ -45,10 +46,10 @@ this.ColumnCount}); this.dataGridView.Dock = System.Windows.Forms.DockStyle.Bottom; this.dataGridView.GridColor = System.Drawing.SystemColors.ButtonHighlight; - this.dataGridView.Location = new System.Drawing.Point(0, 54); + this.dataGridView.Location = new System.Drawing.Point(0, 47); this.dataGridView.Name = "dataGridView"; this.dataGridView.RowTemplate.Height = 25; - this.dataGridView.Size = new System.Drawing.Size(800, 396); + this.dataGridView.Size = new System.Drawing.Size(750, 396); this.dataGridView.TabIndex = 0; // // ColumnSoftware @@ -69,11 +70,22 @@ this.ColumnCount.HeaderText = "Количество"; this.ColumnCount.Name = "ColumnCount"; // + // buttonSaveToExcel + // + this.buttonSaveToExcel.Location = new System.Drawing.Point(25, 12); + this.buttonSaveToExcel.Name = "buttonSaveToExcel"; + this.buttonSaveToExcel.Size = new System.Drawing.Size(140, 23); + this.buttonSaveToExcel.TabIndex = 1; + this.buttonSaveToExcel.Text = "Сохранить в Excel"; + this.buttonSaveToExcel.UseVisualStyleBackColor = true; + this.buttonSaveToExcel.Click += new System.EventHandler(this.buttonSaveToExcel_Click); + // // FormReportPackageSoftwares // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); + this.ClientSize = new System.Drawing.Size(750, 443); + this.Controls.Add(this.buttonSaveToExcel); this.Controls.Add(this.dataGridView); this.Name = "FormReportPackageSoftwares"; this.Text = "FormReportPackageSoftwares"; @@ -88,5 +100,6 @@ private DataGridViewTextBoxColumn ColumnSoftware; private DataGridViewTextBoxColumn ColumnPackage; private DataGridViewTextBoxColumn ColumnCount; + private Button buttonSaveToExcel; } } \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallation/FormReportPackageSoftwares.resx b/SoftwareInstallation/SoftwareInstallation/FormReportPackageSoftwares.resx index d4e2846..ab9d5fe 100644 --- a/SoftwareInstallation/SoftwareInstallation/FormReportPackageSoftwares.resx +++ b/SoftwareInstallation/SoftwareInstallation/FormReportPackageSoftwares.resx @@ -66,13 +66,4 @@ True - - True - - - True - - - True - \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallation/ReportOrders.rdlc b/SoftwareInstallation/SoftwareInstallation/ReportOrders.rdlc index 05fae95..0dccc81 100644 --- a/SoftwareInstallation/SoftwareInstallation/ReportOrders.rdlc +++ b/SoftwareInstallation/SoftwareInstallation/ReportOrders.rdlc @@ -1,21 +1,599 @@ - - - 2in - + + + + + + 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!PackageName.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Sum.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Status.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 +