diff --git a/SoftwareInstallation/SofrwareInstallationContracts/BindingModels/ReportBindingModel.cs b/SoftwareInstallation/SofrwareInstallationContracts/BindingModels/ReportBindingModel.cs new file mode 100644 index 0000000..36ce0ab --- /dev/null +++ b/SoftwareInstallation/SofrwareInstallationContracts/BindingModels/ReportBindingModel.cs @@ -0,0 +1,10 @@ +namespace SofrwareInstallationContracts.BindingModels +{ + public class ReportBindingModel + { + public string FileName { get; set; } = string.Empty; + public DateTime? DateFrom { get; set; } + public DateTime? DateTo { get; set; } + + } +} diff --git a/SoftwareInstallation/SofrwareInstallationContracts/BusinessLogicsContracts/IReportLogic.cs b/SoftwareInstallation/SofrwareInstallationContracts/BusinessLogicsContracts/IReportLogic.cs new file mode 100644 index 0000000..758a9ff --- /dev/null +++ b/SoftwareInstallation/SofrwareInstallationContracts/BusinessLogicsContracts/IReportLogic.cs @@ -0,0 +1,15 @@ +using SofrwareInstallationContracts.BindingModels; +using SofrwareInstallationContracts.ViewModels; + +namespace SofrwareInstallationContracts.BusinessLogicsContracts +{ + public interface IReportLogic + { + List GetPackageComponent(); + List GetOrders(ReportBindingModel model); + void SavePackagesToWordFile(ReportBindingModel model); + void SavePackageComponentToExcelFile(ReportBindingModel model); + void SaveOrdersToPdfFile(ReportBindingModel model); + + } +} diff --git a/SoftwareInstallation/SofrwareInstallationContracts/SearchModels/OrderSearchModel.cs b/SoftwareInstallation/SofrwareInstallationContracts/SearchModels/OrderSearchModel.cs index a42a1bc..2558a88 100644 --- a/SoftwareInstallation/SofrwareInstallationContracts/SearchModels/OrderSearchModel.cs +++ b/SoftwareInstallation/SofrwareInstallationContracts/SearchModels/OrderSearchModel.cs @@ -3,5 +3,7 @@ public class OrderSearchModel { public int? Id { get; set; } + public DateTime? DateFrom { get; set; } + public DateTime? DateTo { get; set; } } } diff --git a/SoftwareInstallation/SofrwareInstallationContracts/SofrwareInstallationContracts.csproj b/SoftwareInstallation/SofrwareInstallationContracts/SofrwareInstallationContracts.csproj index 525e763..0c8e243 100644 --- a/SoftwareInstallation/SofrwareInstallationContracts/SofrwareInstallationContracts.csproj +++ b/SoftwareInstallation/SofrwareInstallationContracts/SofrwareInstallationContracts.csproj @@ -30,6 +30,7 @@ + diff --git a/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/ReportOrdersViewModel.cs b/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/ReportOrdersViewModel.cs new file mode 100644 index 0000000..4ba8d08 --- /dev/null +++ b/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/ReportOrdersViewModel.cs @@ -0,0 +1,14 @@ +using SoftwareInstallationDataModels.Enums; + +namespace SofrwareInstallationContracts.ViewModels +{ + public class ReportOrdersViewModel + { + public int Id { get; set; } + public DateTime DateCreate { get; set; } + public string PackageName { get; set; } = string.Empty; + public double Sum { get; set; } + public String Status { get; set; } = string.Empty; + + } +} diff --git a/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/ReportPackageComponentViewModel.cs b/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/ReportPackageComponentViewModel.cs new file mode 100644 index 0000000..9c989b3 --- /dev/null +++ b/SoftwareInstallation/SofrwareInstallationContracts/ViewModels/ReportPackageComponentViewModel.cs @@ -0,0 +1,9 @@ +namespace SofrwareInstallationContracts.ViewModels +{ + public class ReportPackageComponentViewModel + { + public string PackageName { get; set; } = string.Empty; + public int TotalCount { get; set; } + public List> Components { get; set; } = new(); + } +} diff --git a/SoftwareInstallation/SoftwareInstallation/FormMain.Designer.cs b/SoftwareInstallation/SoftwareInstallation/FormMain.Designer.cs index 49adff0..a1c809b 100644 --- a/SoftwareInstallation/SoftwareInstallation/FormMain.Designer.cs +++ b/SoftwareInstallation/SoftwareInstallation/FormMain.Designer.cs @@ -32,6 +32,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(); this.DataGridView = new System.Windows.Forms.DataGridView(); this.CreateOrderButton = new System.Windows.Forms.Button(); this.TakeOrderInWorkButton = new System.Windows.Forms.Button(); @@ -45,7 +49,8 @@ // MenuStrip // this.MenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.СправочникиToolStripMenuItem}); + this.СправочникиToolStripMenuItem, + this.отчетыToolStripMenuItem}); this.MenuStrip.Location = new System.Drawing.Point(0, 0); this.MenuStrip.Name = "MenuStrip"; this.MenuStrip.Size = new System.Drawing.Size(865, 24); @@ -75,6 +80,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(220, 22); + this.списокИзделийToolStripMenuItem.Text = "Список Изделий"; + this.списокИзделийToolStripMenuItem.Click += new System.EventHandler(this.списокИзделийToolStripMenuItem_Click); + // + // компонентыПоИзделиямToolStripMenuItem + // + this.компонентыПоИзделиямToolStripMenuItem.Name = "компонентыПоИзделиямToolStripMenuItem"; + this.компонентыПоИзделиямToolStripMenuItem.Size = new System.Drawing.Size(220, 22); + this.компонентыПоИзделиямToolStripMenuItem.Text = "Компоненты по Изделиям"; + this.компонентыПоИзделиямToolStripMenuItem.Click += new System.EventHandler(this.компонентыПоИзделиямToolStripMenuItem_Click); + // + // списокЗаказовToolStripMenuItem + // + this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; + this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(220, 22); + this.списокЗаказовToolStripMenuItem.Text = "Список Заказов"; + this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.списокЗаказовToolStripMenuItem_Click); + // // DataGridView // this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; @@ -169,5 +205,9 @@ private Button OrderReadyButton; private Button IssuedOrderButton; private Button UpdateListButton; + private ToolStripMenuItem отчетыToolStripMenuItem; + private ToolStripMenuItem списокИзделийToolStripMenuItem; + private ToolStripMenuItem компонентыПоИзделиямToolStripMenuItem; + private ToolStripMenuItem списокЗаказовToolStripMenuItem; } } \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallation/FormMain.cs b/SoftwareInstallation/SoftwareInstallation/FormMain.cs index ab8d0e4..7123fb5 100644 --- a/SoftwareInstallation/SoftwareInstallation/FormMain.cs +++ b/SoftwareInstallation/SoftwareInstallation/FormMain.cs @@ -1,6 +1,7 @@ using Microsoft.Extensions.Logging; using SofrwareInstallationContracts.BindingModels; using SofrwareInstallationContracts.BusinessLogicsContracts; +using SoftwareInstallationBusinessLogic.BusinessLogic; using SoftwareInstallationDataModels.Enums; namespace SoftwareInstallationView @@ -10,12 +11,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) { InitializeComponent(); _logger = logger; _orderLogic = orderLogic; + _reportLogic = reportLogic; LoadData(); } @@ -188,5 +191,38 @@ namespace SoftwareInstallationView { LoadData(); } + + private void списокИзделийToolStripMenuItem_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); + } + + } + + private void компонентыПоИзделиямToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportPackageComponents)); + if (service is FormReportPackageComponents form) + { + form.ShowDialog(); + } + + } + + private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + if (service is FormReportOrders form) + { + form.ShowDialog(); + } + } } } diff --git a/SoftwareInstallation/SoftwareInstallation/FormReportOrders.Designer.cs b/SoftwareInstallation/SoftwareInstallation/FormReportOrders.Designer.cs new file mode 100644 index 0000000..df3bd29 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallation/FormReportOrders.Designer.cs @@ -0,0 +1,131 @@ +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.dateTimePickerFrom = new System.Windows.Forms.DateTimePicker(); + this.dateTimePickerTo = new System.Windows.Forms.DateTimePicker(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.MakeButton = new System.Windows.Forms.Button(); + this.ToPdfButton = new System.Windows.Forms.Button(); + this.panel = new System.Windows.Forms.Panel(); + this.panel.SuspendLayout(); + this.SuspendLayout(); + // + // dateTimePickerFrom + // + this.dateTimePickerFrom.Location = new System.Drawing.Point(43, 12); + this.dateTimePickerFrom.Name = "dateTimePickerFrom"; + this.dateTimePickerFrom.Size = new System.Drawing.Size(200, 23); + this.dateTimePickerFrom.TabIndex = 0; + // + // dateTimePickerTo + // + this.dateTimePickerTo.Location = new System.Drawing.Point(276, 12); + this.dateTimePickerTo.Name = "dateTimePickerTo"; + this.dateTimePickerTo.Size = new System.Drawing.Size(200, 23); + this.dateTimePickerTo.TabIndex = 1; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(22, 18); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(15, 15); + this.label1.TabIndex = 2; + this.label1.Text = "С"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(249, 18); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(21, 15); + this.label2.TabIndex = 3; + this.label2.Text = "по"; + // + // MakeButton + // + this.MakeButton.Location = new System.Drawing.Point(517, 12); + this.MakeButton.Name = "MakeButton"; + this.MakeButton.Size = new System.Drawing.Size(105, 23); + this.MakeButton.TabIndex = 4; + this.MakeButton.Text = "Сформировать"; + this.MakeButton.UseVisualStyleBackColor = true; + this.MakeButton.Click += new System.EventHandler(this.MakeButton_Click); + // + // ToPdfButton + // + this.ToPdfButton.Location = new System.Drawing.Point(684, 12); + this.ToPdfButton.Name = "ToPdfButton"; + this.ToPdfButton.Size = new System.Drawing.Size(75, 23); + this.ToPdfButton.TabIndex = 5; + this.ToPdfButton.Text = "В Pdf"; + this.ToPdfButton.UseVisualStyleBackColor = true; + this.ToPdfButton.Click += new System.EventHandler(this.ToPdfButton_Click); + // + // panel + // + this.panel.Controls.Add(this.label2); + this.panel.Controls.Add(this.ToPdfButton); + this.panel.Controls.Add(this.label1); + this.panel.Controls.Add(this.MakeButton); + this.panel.Controls.Add(this.dateTimePickerFrom); + this.panel.Controls.Add(this.dateTimePickerTo); + this.panel.Dock = System.Windows.Forms.DockStyle.Top; + this.panel.Location = new System.Drawing.Point(0, 0); + this.panel.Name = "panel"; + this.panel.Size = new System.Drawing.Size(800, 52); + this.panel.TabIndex = 6; + // + // 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 = "Заказы"; + this.panel.ResumeLayout(false); + this.panel.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private DateTimePicker dateTimePickerFrom; + private DateTimePicker dateTimePickerTo; + private Label label1; + private Label label2; + private Button MakeButton; + private Button ToPdfButton; + private Panel panel; + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallation/FormReportOrders.cs b/SoftwareInstallation/SoftwareInstallation/FormReportOrders.cs new file mode 100644 index 0000000..3619eb8 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallation/FormReportOrders.cs @@ -0,0 +1,89 @@ +using Microsoft.Extensions.Logging; +using SofrwareInstallationContracts.BindingModels; +using SofrwareInstallationContracts.BusinessLogicsContracts; +using Microsoft.Reporting.WinForms; + +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 MakeButton_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 ToPdfButton_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/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/FormReportPackageComponents.Designer.cs b/SoftwareInstallation/SoftwareInstallation/FormReportPackageComponents.Designer.cs new file mode 100644 index 0000000..ae778f4 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallation/FormReportPackageComponents.Designer.cs @@ -0,0 +1,102 @@ +namespace SoftwareInstallationView +{ + partial class FormReportPackageComponents + { + /// + /// 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.dataGridView = new System.Windows.Forms.DataGridView(); + this.SaveToExcelButton = new System.Windows.Forms.Button(); + this.ComponentColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.PackageColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.CountColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // dataGridView + // + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.ComponentColumn, + this.PackageColumn, + this.CountColumn}); + this.dataGridView.Location = new System.Drawing.Point(12, 38); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(607, 400); + this.dataGridView.TabIndex = 0; + // + // SaveToExcelButton + // + this.SaveToExcelButton.Location = new System.Drawing.Point(12, 9); + this.SaveToExcelButton.Name = "SaveToExcelButton"; + this.SaveToExcelButton.Size = new System.Drawing.Size(119, 23); + this.SaveToExcelButton.TabIndex = 1; + this.SaveToExcelButton.Text = "Сохранить в Excel"; + this.SaveToExcelButton.UseVisualStyleBackColor = true; + this.SaveToExcelButton.Click += new System.EventHandler(this.SaveToExcelButton_Click); + // + // ComponentColumn + // + this.ComponentColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.ComponentColumn.HeaderText = "Компонент"; + this.ComponentColumn.Name = "ComponentColumn"; + // + // PackageColumn + // + this.PackageColumn.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.PackageColumn.HeaderText = "Изделие"; + this.PackageColumn.Name = "PackageColumn"; + // + // CountColumn + // + this.CountColumn.HeaderText = "Количество"; + this.CountColumn.Name = "CountColumn"; + // + // FormReportPackageComponents + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(631, 450); + this.Controls.Add(this.SaveToExcelButton); + this.Controls.Add(this.dataGridView); + this.Name = "FormReportPackageComponents"; + this.Text = "Компоненты по Изделиям"; + this.Load += new System.EventHandler(this.FormReportPackageComponents_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private DataGridView dataGridView; + private DataGridViewTextBoxColumn ComponentColumn; + private DataGridViewTextBoxColumn PackageColumn; + private DataGridViewTextBoxColumn CountColumn; + private Button SaveToExcelButton; + } +} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallation/FormReportPackageComponents.cs b/SoftwareInstallation/SoftwareInstallation/FormReportPackageComponents.cs new file mode 100644 index 0000000..5943851 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallation/FormReportPackageComponents.cs @@ -0,0 +1,71 @@ +using Microsoft.Extensions.Logging; +using SofrwareInstallationContracts.BindingModels; +using SofrwareInstallationContracts.BusinessLogicsContracts; + +namespace SoftwareInstallationView +{ + public partial class FormReportPackageComponents : Form + { + private readonly ILogger _logger; + private readonly IReportLogic _logic; + public FormReportPackageComponents(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void SaveToExcelButton_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog + { + Filter = "xlsx|*.xlsx" + }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + _logic.SavePackageComponentToExcelFile(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); + } + } + } + + private void FormReportPackageComponents_Load(object sender, EventArgs e) + { + try + { + var dict = _logic.GetPackageComponent(); + if (dict != null) + { + dataGridView.Rows.Clear(); + foreach (var elem in dict) + { + dataGridView.Rows.Add(new object[] { elem.PackageName,"", "" }); + 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); + } + } + } +} diff --git a/SoftwareInstallation/SoftwareInstallation/FormReportPackageComponents.resx b/SoftwareInstallation/SoftwareInstallation/FormReportPackageComponents.resx new file mode 100644 index 0000000..1f80bb3 --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallation/FormReportPackageComponents.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/SoftwareInstallation/SoftwareInstallation/Program.cs b/SoftwareInstallation/SoftwareInstallation/Program.cs index 5645377..30829b1 100644 --- a/SoftwareInstallation/SoftwareInstallation/Program.cs +++ b/SoftwareInstallation/SoftwareInstallation/Program.cs @@ -5,7 +5,8 @@ using SofrwareInstallationContracts.StoragesContracts; using SoftwareInstallationDataBaseImplement.Implements; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; - +using SoftwareInstallationBusinessLogic.OfficePackage; +using SoftwareInstallationBusinessLogic.OfficePackage.Implements; namespace SoftwareInstallationView { @@ -37,6 +38,10 @@ namespace SoftwareInstallationView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -44,6 +49,8 @@ namespace SoftwareInstallationView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } diff --git a/SoftwareInstallation/SoftwareInstallation/Properties/Resources.Designer.cs b/SoftwareInstallation/SoftwareInstallation/Properties/Resources.Designer.cs deleted file mode 100644 index 46ddebe..0000000 --- a/SoftwareInstallation/SoftwareInstallation/Properties/Resources.Designer.cs +++ /dev/null @@ -1,63 +0,0 @@ -//------------------------------------------------------------------------------ -// -// Этот код создан программой. -// Исполняемая версия:4.0.30319.42000 -// -// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае -// повторной генерации кода. -// -//------------------------------------------------------------------------------ - -namespace SoftwareInstallationView.Properties { - using System; - - - /// - /// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д. - /// - // Этот класс создан автоматически классом StronglyTypedResourceBuilder - // с помощью такого средства, как ResGen или Visual Studio. - // Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen - // с параметром /str или перестройте свой проект VS. - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] - [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { - - private static global::System.Resources.ResourceManager resourceMan; - - private static global::System.Globalization.CultureInfo resourceCulture; - - [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] - internal Resources() { - } - - /// - /// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { - get { - if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("SoftwareInstallationView.Properties.Resources", typeof(Resources).Assembly); - resourceMan = temp; - } - return resourceMan; - } - } - - /// - /// Перезаписывает свойство CurrentUICulture текущего потока для всех - /// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией. - /// - [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { - get { - return resourceCulture; - } - set { - resourceCulture = value; - } - } - } -} diff --git a/SoftwareInstallation/SoftwareInstallation/Properties/Resources.resx b/SoftwareInstallation/SoftwareInstallation/Properties/Resources.resx deleted file mode 100644 index 1af7de1..0000000 --- a/SoftwareInstallation/SoftwareInstallation/Properties/Resources.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 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/Properties/launchSettings.json b/SoftwareInstallation/SoftwareInstallation/Properties/launchSettings.json deleted file mode 100644 index 8a978ef..0000000 --- a/SoftwareInstallation/SoftwareInstallation/Properties/launchSettings.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "profiles": { - "SoftwareInstallationView": { - "commandName": "Project" - } - } -} \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallation/ReportOrders.rdlc b/SoftwareInstallation/SoftwareInstallation/ReportOrders.rdlc new file mode 100644 index 0000000..ef338bf --- /dev/null +++ b/SoftwareInstallation/SoftwareInstallation/ReportOrders.rdlc @@ -0,0 +1,609 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + bf577a27-98a7-43b2-8beb-1a37d37ce5cd + + + + + + SofrwareInstallationContractsViewModels + /* Local Query */ + + + + Id + System.Int32 + + + DateCreate + System.DateTime + + + PackageName + System.String + + + Sum + System.Decimal + + + Status + System.String + + + + SofrwareInstallationContracts.ViewModels + ReportOrderViewModel + SofrwareInstallationContracts.ViewModels.ReportOrderViewModel, SofrwareInstallationContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + + + + + + + true + true + + + + + Заказы + + + + + + + Textbox1 + 0.94396cm + 19.01cm + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Parameters!ReportParameterPeriod.Value + + + + + + + ReportParameterPeriod + 0.97924cm + 0.83812cm + 19.01cm + 1 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + 5.20245cm + + + 5.20245cm + + + 3.90599cm + + + 2.19911cm + + + 2.5cm + + + + + 0.79844cm + + + + + true + true + + + + + Номер + + + + + + + Textbox2 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Дата создания + + + + + + + Textbox4 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Изделие + + + + + + + Textbox6 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Сумма + + + + + + + Textbox8 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Статус + + + + + + + Textbox3 + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.79844cm + + + + + 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 + 1.88792cm + 1.59688cm + 19.01cm + 2 + + + + + + true + true + + + + + Итого: + + + + + + + Textbox10 + 4.01849cm + 10.4049cm + 0.6cm + 2.5cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!Sum.Value, "DataSetOrders") + + + 2pt + 2pt + 2pt + 2pt + + + + 2in +