From a61f535adb95becd2b7b1843baf5c98a3d325e11 Mon Sep 17 00:00:00 2001 From: May Date: Sun, 19 May 2024 13:23:06 +0400 Subject: [PATCH] PIbd-22_Kamcharova_K.A._lab4 --- ...LogicsContracts.IComponentLogic.datasource | 10 + RenovationWork/FormMain.Designer.cs | 38 +- RenovationWork/FormMain.cs | 37 +- RenovationWork/FormRepairs.Designer.cs | 114 ++-- RenovationWork/FormRepairs.resx | 62 +- RenovationWork/FormReportOrders.Designer.cs | 130 ++++ RenovationWork/FormReportOrders.cs | 100 +++ RenovationWork/FormReportOrders.resx | 120 ++++ .../FormReportRepairComponents.Designer.cs | 99 +++ RenovationWork/FormReportRepairComponents.cs | 77 +++ .../FormReportRepairComponents.resx | 129 ++++ RenovationWork/Program.cs | 9 +- ...nessLogicsContracts.IOrderLogic.datasource | 10 + ...essLogicsContracts.IRepairLogic.datasource | 10 + ...essLogicsContracts.IReportLogic.datasource | 10 + ...agesContracts.IComponentStorage.datasource | 10 + ...StoragesContracts.IOrderStorage.datasource | 10 + ...toragesContracts.IRepairStorage.datasource | 10 + RenovationWork/RenovationWorkView.csproj | 5 +- RenovationWork/ReportOrders.rdlc | 599 ++++++++++++++++++ .../BusinessLogics/RepairLogic.cs | 6 +- .../BusinessLogics/ReportLogic.cs | 89 +++ .../OfficePackage/AbstractSaveToExcel.cs | 86 +++ .../OfficePackage/AbstractSaveToPdf.cs | 59 ++ .../OfficePackage/AbstractSaveToWord.cs | 46 ++ .../HelperEnums/ExcelStyleInfoType.cs | 15 + .../HelperEnums/PdfParagraphAlignmentType.cs | 15 + .../HelperEnums/WordJustificationType.cs | 15 + .../HelperModels/ExcelCellParameters.cs | 18 + .../OfficePackage/HelperModels/ExcelInfo.cs | 21 + .../HelperModels/ExcelMergeParameters.cs | 15 + .../OfficePackage/HelperModels/PdfInfo.cs | 19 + .../HelperModels/PdfParagraph.cs | 17 + .../HelperModels/PdfRowParameters.cs | 18 + .../OfficePackage/HelperModels/WordInfo.cs | 16 + .../HelperModels/WordParagraph.cs | 14 + .../HelperModels/WordTextProperties.cs | 18 + .../OfficePackage/Implements/SaveToExcel.cs | 334 ++++++++++ .../OfficePackage/Implements/SaveToPdf.cs | 101 +++ .../OfficePackage/Implements/SaveToWord.cs | 115 ++++ .../RenovationWorkBusinessLogic.csproj | 2 + .../BindingModels/ReportBindingModel.cs | 16 + .../BusinessLogicsContracts/IReportLogic.cs | 20 + .../SearchModels/OrderSearchModel.cs | 2 + .../ViewModels/ReportOrdersViewModel.cs | 18 + .../ReportRepairComponentViewModel.cs | 16 + .../Implements/OrderStorage.cs | 19 +- .../20240326091411_InitialCreate.Designer.cs | 171 +++++ .../20240326091411_InitialCreate.cs | 125 ++++ .../RenovationWorkDatabase.cs | 2 +- 50 files changed, 2941 insertions(+), 76 deletions(-) create mode 100644 RenovationWork/DataSources/RenovationWorkContracts.BusinessLogicsContracts.IComponentLogic.datasource create mode 100644 RenovationWork/FormReportOrders.Designer.cs create mode 100644 RenovationWork/FormReportOrders.cs create mode 100644 RenovationWork/FormReportOrders.resx create mode 100644 RenovationWork/FormReportRepairComponents.Designer.cs create mode 100644 RenovationWork/FormReportRepairComponents.cs create mode 100644 RenovationWork/FormReportRepairComponents.resx create mode 100644 RenovationWork/Properties/DataSources/RenovationWorkContracts.BusinessLogicsContracts.IOrderLogic.datasource create mode 100644 RenovationWork/Properties/DataSources/RenovationWorkContracts.BusinessLogicsContracts.IRepairLogic.datasource create mode 100644 RenovationWork/Properties/DataSources/RenovationWorkContracts.BusinessLogicsContracts.IReportLogic.datasource create mode 100644 RenovationWork/Properties/DataSources/RenovationWorkContracts.StoragesContracts.IComponentStorage.datasource create mode 100644 RenovationWork/Properties/DataSources/RenovationWorkContracts.StoragesContracts.IOrderStorage.datasource create mode 100644 RenovationWork/Properties/DataSources/RenovationWorkContracts.StoragesContracts.IRepairStorage.datasource create mode 100644 RenovationWork/ReportOrders.rdlc create mode 100644 RenovationWorkBusinessLogic/BusinessLogics/ReportLogic.cs create mode 100644 RenovationWorkBusinessLogic/OfficePackage/AbstractSaveToExcel.cs create mode 100644 RenovationWorkBusinessLogic/OfficePackage/AbstractSaveToPdf.cs create mode 100644 RenovationWorkBusinessLogic/OfficePackage/AbstractSaveToWord.cs create mode 100644 RenovationWorkBusinessLogic/OfficePackage/HelperEnums/ExcelStyleInfoType.cs create mode 100644 RenovationWorkBusinessLogic/OfficePackage/HelperEnums/PdfParagraphAlignmentType.cs create mode 100644 RenovationWorkBusinessLogic/OfficePackage/HelperEnums/WordJustificationType.cs create mode 100644 RenovationWorkBusinessLogic/OfficePackage/HelperModels/ExcelCellParameters.cs create mode 100644 RenovationWorkBusinessLogic/OfficePackage/HelperModels/ExcelInfo.cs create mode 100644 RenovationWorkBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs create mode 100644 RenovationWorkBusinessLogic/OfficePackage/HelperModels/PdfInfo.cs create mode 100644 RenovationWorkBusinessLogic/OfficePackage/HelperModels/PdfParagraph.cs create mode 100644 RenovationWorkBusinessLogic/OfficePackage/HelperModels/PdfRowParameters.cs create mode 100644 RenovationWorkBusinessLogic/OfficePackage/HelperModels/WordInfo.cs create mode 100644 RenovationWorkBusinessLogic/OfficePackage/HelperModels/WordParagraph.cs create mode 100644 RenovationWorkBusinessLogic/OfficePackage/HelperModels/WordTextProperties.cs create mode 100644 RenovationWorkBusinessLogic/OfficePackage/Implements/SaveToExcel.cs create mode 100644 RenovationWorkBusinessLogic/OfficePackage/Implements/SaveToPdf.cs create mode 100644 RenovationWorkBusinessLogic/OfficePackage/Implements/SaveToWord.cs create mode 100644 RenovationWorkContracts/BindingModels/ReportBindingModel.cs create mode 100644 RenovationWorkContracts/BusinessLogicsContracts/IReportLogic.cs create mode 100644 RenovationWorkContracts/ViewModels/ReportOrdersViewModel.cs create mode 100644 RenovationWorkContracts/ViewModels/ReportRepairComponentViewModel.cs create mode 100644 RenovationWorkDatabaseImplement/Migrations/20240326091411_InitialCreate.Designer.cs create mode 100644 RenovationWorkDatabaseImplement/Migrations/20240326091411_InitialCreate.cs diff --git a/RenovationWork/DataSources/RenovationWorkContracts.BusinessLogicsContracts.IComponentLogic.datasource b/RenovationWork/DataSources/RenovationWorkContracts.BusinessLogicsContracts.IComponentLogic.datasource new file mode 100644 index 0000000..c58d1ce --- /dev/null +++ b/RenovationWork/DataSources/RenovationWorkContracts.BusinessLogicsContracts.IComponentLogic.datasource @@ -0,0 +1,10 @@ + + + + RenovationWorkContracts.BusinessLogicsContracts.IComponentLogic, RenovationWorkContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/RenovationWork/FormMain.Designer.cs b/RenovationWork/FormMain.Designer.cs index 7e46eda..db5cddf 100644 --- a/RenovationWork/FormMain.Designer.cs +++ b/RenovationWork/FormMain.Designer.cs @@ -32,6 +32,10 @@ refbooksToolStripMenuItem = new ToolStripMenuItem(); componentsToolStripMenuItem = new ToolStripMenuItem(); JobTypeToolStripMenuItem = new ToolStripMenuItem(); + отчетыToolStripMenuItem = new ToolStripMenuItem(); + listComponentsToolStripMenuItem = new ToolStripMenuItem(); + componentRepairsПоИзделиямToolStripMenuItem = new ToolStripMenuItem(); + OrdersToolStripMenuItem = new ToolStripMenuItem(); dataGridView = new DataGridView(); buttonCreateOrder = new Button(); buttonTakeOrderInWork = new Button(); @@ -44,7 +48,7 @@ // // menuStrip // - menuStrip.Items.AddRange(new ToolStripItem[] { refbooksToolStripMenuItem }); + menuStrip.Items.AddRange(new ToolStripItem[] { refbooksToolStripMenuItem, отчетыToolStripMenuItem }); menuStrip.Location = new Point(0, 0); menuStrip.Name = "menuStrip"; menuStrip.Size = new Size(984, 24); @@ -72,6 +76,34 @@ JobTypeToolStripMenuItem.Text = "Вид работы"; JobTypeToolStripMenuItem.Click += JobTypeToolStripMenuItem_Click; // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { listComponentsToolStripMenuItem, componentRepairsПоИзделиямToolStripMenuItem, OrdersToolStripMenuItem }); + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(60, 20); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // listComponentsToolStripMenuItem + // + listComponentsToolStripMenuItem.Name = "listComponentsToolStripMenuItem"; + listComponentsToolStripMenuItem.Size = new Size(218, 22); + listComponentsToolStripMenuItem.Text = "Список изделий"; + listComponentsToolStripMenuItem.Click += listComponentsToolStripMenuItem_Click; + // + // componentRepairsПоИзделиямToolStripMenuItem + // + componentRepairsПоИзделиямToolStripMenuItem.Name = "componentRepairsПоИзделиямToolStripMenuItem"; + componentRepairsПоИзделиямToolStripMenuItem.Size = new Size(218, 22); + componentRepairsПоИзделиямToolStripMenuItem.Text = "Компоненты по изделиям"; + componentRepairsПоИзделиямToolStripMenuItem.Click += componentRepairsПоИзделиямToolStripMenuItem_Click; + // + // OrdersToolStripMenuItem + // + OrdersToolStripMenuItem.Name = "OrdersToolStripMenuItem"; + OrdersToolStripMenuItem.Size = new Size(218, 22); + OrdersToolStripMenuItem.Text = "Список заказов"; + OrdersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click; + // // dataGridView // dataGridView.BackgroundColor = SystemColors.ControlLightLight; @@ -167,5 +199,9 @@ private Button buttonOrderReady; private Button buttonIssuedOrder; private Button buttonRef; + private ToolStripMenuItem отчетыToolStripMenuItem; + private ToolStripMenuItem listComponentsToolStripMenuItem; + private ToolStripMenuItem componentRepairsПоИзделиямToolStripMenuItem; + private ToolStripMenuItem OrdersToolStripMenuItem; } } \ No newline at end of file diff --git a/RenovationWork/FormMain.cs b/RenovationWork/FormMain.cs index d143cbe..04e4b36 100644 --- a/RenovationWork/FormMain.cs +++ b/RenovationWork/FormMain.cs @@ -10,6 +10,7 @@ using System.Windows.Forms; using RenovationWorkContracts.BindingModels; using RenovationWorkContracts.BusinessLogicsContracts; using Microsoft.Extensions.Logging; +using RenovationWorkBusinessLogic.BusinessLogics; namespace RenovationWorkView { @@ -17,11 +18,13 @@ namespace RenovationWorkView { 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) @@ -154,6 +157,38 @@ namespace RenovationWorkView { LoadData(); } + + private void listComponentsToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SaveRepairsToWordFile(new ReportBindingModel + { + FileName = dialog.FileName + }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, + MessageBoxIcon.Information); + } + } + + private void componentRepairsПоИзделиямToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportRepairComponents)); + if (service is FormReportRepairComponents 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/RenovationWork/FormRepairs.Designer.cs b/RenovationWork/FormRepairs.Designer.cs index 34d9422..638fec6 100644 --- a/RenovationWork/FormRepairs.Designer.cs +++ b/RenovationWork/FormRepairs.Designer.cs @@ -28,83 +28,79 @@ /// private void InitializeComponent() { - this.dataGridView = new System.Windows.Forms.DataGridView(); - this.buttonAdd = new System.Windows.Forms.Button(); - this.buttonUpd = new System.Windows.Forms.Button(); - this.buttonDel = new System.Windows.Forms.Button(); - this.buttonRef = new System.Windows.Forms.Button(); - ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); - this.SuspendLayout(); + dataGridView = new DataGridView(); + buttonAdd = new Button(); + buttonUpd = new Button(); + buttonDel = new Button(); + buttonRef = new Button(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); // // dataGridView // - this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight; - this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.dataGridView.Location = new System.Drawing.Point(2, 3); - this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.dataGridView.Name = "dataGridView"; - this.dataGridView.RowHeadersWidth = 51; - this.dataGridView.RowTemplate.Height = 25; - this.dataGridView.Size = new System.Drawing.Size(632, 592); - this.dataGridView.TabIndex = 0; + dataGridView.BackgroundColor = SystemColors.ControlLightLight; + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Location = new Point(2, 2); + dataGridView.Name = "dataGridView"; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(553, 444); + dataGridView.TabIndex = 0; // // buttonAdd // - this.buttonAdd.Location = new System.Drawing.Point(641, 16); - this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.buttonAdd.Name = "buttonAdd"; - this.buttonAdd.Size = new System.Drawing.Size(112, 31); - this.buttonAdd.TabIndex = 1; - this.buttonAdd.Text = "Добавить"; - this.buttonAdd.UseVisualStyleBackColor = true; - this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click); + buttonAdd.Location = new Point(561, 12); + buttonAdd.Name = "buttonAdd"; + buttonAdd.Size = new Size(98, 23); + buttonAdd.TabIndex = 1; + buttonAdd.Text = "Добавить"; + buttonAdd.UseVisualStyleBackColor = true; + buttonAdd.Click += buttonAdd_Click; // // buttonUpd // - this.buttonUpd.Location = new System.Drawing.Point(641, 55); - this.buttonUpd.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.buttonUpd.Name = "buttonUpd"; - this.buttonUpd.Size = new System.Drawing.Size(112, 31); - this.buttonUpd.TabIndex = 2; - this.buttonUpd.Text = "Изменить"; - this.buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Location = new Point(561, 41); + buttonUpd.Name = "buttonUpd"; + buttonUpd.Size = new Size(98, 23); + buttonUpd.TabIndex = 2; + buttonUpd.Text = "Изменить"; + buttonUpd.UseVisualStyleBackColor = true; + buttonUpd.Click += buttonUpd_Click; // // buttonDel // - this.buttonDel.Location = new System.Drawing.Point(641, 93); - this.buttonDel.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.buttonDel.Name = "buttonDel"; - this.buttonDel.Size = new System.Drawing.Size(112, 31); - this.buttonDel.TabIndex = 3; - this.buttonDel.Text = "Удалить"; - this.buttonDel.UseVisualStyleBackColor = true; + buttonDel.Location = new Point(561, 70); + buttonDel.Name = "buttonDel"; + buttonDel.Size = new Size(98, 23); + buttonDel.TabIndex = 3; + buttonDel.Text = "Удалить"; + buttonDel.UseVisualStyleBackColor = true; + buttonDel.Click += buttonDel_Click; // // buttonRef // - this.buttonRef.Location = new System.Drawing.Point(641, 132); - this.buttonRef.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.buttonRef.Name = "buttonRef"; - this.buttonRef.Size = new System.Drawing.Size(112, 31); - this.buttonRef.TabIndex = 4; - this.buttonRef.Text = "Обновить"; - this.buttonRef.UseVisualStyleBackColor = true; + buttonRef.Location = new Point(561, 99); + buttonRef.Name = "buttonRef"; + buttonRef.Size = new Size(98, 23); + buttonRef.TabIndex = 4; + buttonRef.Text = "Обновить"; + buttonRef.UseVisualStyleBackColor = true; + buttonRef.Click += buttonRef_Click; // // FormRepairs // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(767, 597); - this.Controls.Add(this.buttonRef); - this.Controls.Add(this.buttonDel); - this.Controls.Add(this.buttonUpd); - this.Controls.Add(this.buttonAdd); - this.Controls.Add(this.dataGridView); - this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.Name = "FormRepairs"; - this.Text = "Список работ"; - ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); - this.ResumeLayout(false); - + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(671, 448); + Controls.Add(buttonRef); + Controls.Add(buttonDel); + Controls.Add(buttonUpd); + Controls.Add(buttonAdd); + Controls.Add(dataGridView); + Name = "FormRepairs"; + Text = "Список работ"; + Load += FormRepairs_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); } #endregion diff --git a/RenovationWork/FormRepairs.resx b/RenovationWork/FormRepairs.resx index f298a7b..af32865 100644 --- a/RenovationWork/FormRepairs.resx +++ b/RenovationWork/FormRepairs.resx @@ -1,4 +1,64 @@ - + + + diff --git a/RenovationWork/FormReportOrders.Designer.cs b/RenovationWork/FormReportOrders.Designer.cs new file mode 100644 index 0000000..d1cdeb3 --- /dev/null +++ b/RenovationWork/FormReportOrders.Designer.cs @@ -0,0 +1,130 @@ +namespace RenovationWorkView +{ + partial class FormReportOrders + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + panel = new Panel(); + buttonToPdf = new Button(); + buttonMake = new Button(); + dateTimePickerTo = new DateTimePicker(); + dateTimePickerFrom = new DateTimePicker(); + labelTo = new Label(); + labelFrom = new Label(); + panel.SuspendLayout(); + SuspendLayout(); + // + // panel + // + panel.Controls.Add(buttonToPdf); + panel.Controls.Add(buttonMake); + panel.Controls.Add(dateTimePickerTo); + panel.Controls.Add(dateTimePickerFrom); + panel.Controls.Add(labelTo); + panel.Controls.Add(labelFrom); + panel.Dock = DockStyle.Top; + panel.Location = new Point(0, 0); + panel.Name = "panel"; + panel.Size = new Size(826, 33); + panel.TabIndex = 0; + // + // buttonToPdf + // + buttonToPdf.Location = new Point(709, 5); + buttonToPdf.Name = "buttonToPdf"; + buttonToPdf.Size = new Size(103, 23); + buttonToPdf.TabIndex = 5; + buttonToPdf.Text = "В PDF"; + buttonToPdf.UseVisualStyleBackColor = true; + buttonToPdf.Click += buttonToPdf_Click; + // + // buttonMake + // + buttonMake.Location = new Point(510, 5); + buttonMake.Name = "buttonMake"; + buttonMake.Size = new Size(144, 23); + buttonMake.TabIndex = 4; + buttonMake.Text = "Сформировать"; + buttonMake.UseVisualStyleBackColor = true; + buttonMake.Click += buttonMake_Click; + // + // dateTimePickerTo + // + dateTimePickerTo.Location = new Point(282, 7); + dateTimePickerTo.Name = "dateTimePickerTo"; + dateTimePickerTo.Size = new Size(200, 23); + dateTimePickerTo.TabIndex = 3; + // + // dateTimePickerFrom + // + dateTimePickerFrom.Location = new Point(31, 7); + dateTimePickerFrom.Name = "dateTimePickerFrom"; + dateTimePickerFrom.Size = new Size(200, 23); + dateTimePickerFrom.TabIndex = 2; + // + // labelTo + // + labelTo.AutoSize = true; + labelTo.Location = new Point(246, 13); + labelTo.Name = "labelTo"; + labelTo.Size = new Size(21, 15); + labelTo.TabIndex = 1; + labelTo.Text = "по"; + // + // labelFrom + // + labelFrom.AutoSize = true; + labelFrom.Location = new Point(10, 13); + labelFrom.Name = "labelFrom"; + labelFrom.Size = new Size(15, 15); + labelFrom.TabIndex = 0; + labelFrom.Text = "С"; + // + // FormReportOrders + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(826, 277); + Controls.Add(panel); + Name = "FormReportOrders"; + Text = "Заказы"; + panel.ResumeLayout(false); + panel.PerformLayout(); + ResumeLayout(false); + } + + #endregion + + private Panel panel; + private DateTimePicker dateTimePickerFrom; + private Label labelTo; + private Label labelFrom; + private Button buttonToPdf; + private Button buttonMake; + private DateTimePicker dateTimePickerTo; + } +} \ No newline at end of file diff --git a/RenovationWork/FormReportOrders.cs b/RenovationWork/FormReportOrders.cs new file mode 100644 index 0000000..cbc6ff2 --- /dev/null +++ b/RenovationWork/FormReportOrders.cs @@ -0,0 +1,100 @@ +using RenovationWorkContracts.BindingModels; +using RenovationWorkContracts.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 RenovationWorkView +{ + 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/RenovationWork/FormReportOrders.resx b/RenovationWork/FormReportOrders.resx new file mode 100644 index 0000000..af32865 --- /dev/null +++ b/RenovationWork/FormReportOrders.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/RenovationWork/FormReportRepairComponents.Designer.cs b/RenovationWork/FormReportRepairComponents.Designer.cs new file mode 100644 index 0000000..946262f --- /dev/null +++ b/RenovationWork/FormReportRepairComponents.Designer.cs @@ -0,0 +1,99 @@ +namespace RenovationWorkView +{ + partial class FormReportRepairComponents + { + /// + /// 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() + { + buttonSaveToExcel = new Button(); + dataGridView = new DataGridView(); + ColumnComponent = new DataGridViewTextBoxColumn(); + ColumnRepair = new DataGridViewTextBoxColumn(); + ColumnCount = new DataGridViewTextBoxColumn(); + ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); + SuspendLayout(); + // + // buttonSaveToExcel + // + buttonSaveToExcel.Location = new Point(12, 12); + buttonSaveToExcel.Name = "buttonSaveToExcel"; + buttonSaveToExcel.Size = new Size(157, 23); + buttonSaveToExcel.TabIndex = 0; + buttonSaveToExcel.Text = "Сохранить в Excel"; + buttonSaveToExcel.UseVisualStyleBackColor = true; + buttonSaveToExcel.Click += buttonSaveToExcel_Click; + // + // dataGridView + // + dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnComponent, ColumnRepair, ColumnCount }); + dataGridView.Location = new Point(0, 41); + dataGridView.Name = "dataGridView"; + dataGridView.RowTemplate.Height = 25; + dataGridView.Size = new Size(600, 150); + dataGridView.TabIndex = 1; + // + // ColumnComponent + // + ColumnComponent.HeaderText = "Компонент"; + ColumnComponent.Name = "ColumnComponent"; + ColumnComponent.Width = 185; + // + // ColumnRepair + // + ColumnRepair.HeaderText = "Изделие"; + ColumnRepair.Name = "ColumnRepair"; + ColumnRepair.Width = 185; + // + // ColumnCount + // + ColumnCount.HeaderText = "Количество"; + ColumnCount.Name = "ColumnCount"; + ColumnCount.Width = 185; + // + // FormReportRepairComponents + // + AutoScaleDimensions = new SizeF(7F, 15F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(604, 229); + Controls.Add(dataGridView); + Controls.Add(buttonSaveToExcel); + Name = "FormReportRepairComponents"; + Text = "Компоненты по изделиям"; + Load += FormReportRepairComponents_Load; + ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); + ResumeLayout(false); + } + + #endregion + + private Button buttonSaveToExcel; + private DataGridView dataGridView; + private DataGridViewTextBoxColumn ColumnComponent; + private DataGridViewTextBoxColumn ColumnRepair; + private DataGridViewTextBoxColumn ColumnCount; + } +} \ No newline at end of file diff --git a/RenovationWork/FormReportRepairComponents.cs b/RenovationWork/FormReportRepairComponents.cs new file mode 100644 index 0000000..c92179e --- /dev/null +++ b/RenovationWork/FormReportRepairComponents.cs @@ -0,0 +1,77 @@ +using RenovationWorkContracts.BindingModels; +using RenovationWorkContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; +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 RenovationWorkView +{ + public partial class FormReportRepairComponents : Form + { + private readonly ILogger _logger; + private readonly IReportLogic _logic; + public FormReportRepairComponents(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormReportRepairComponents_Load(object sender, EventArgs e) + { + try + { + var dict = _logic.GetRepairComponent(); + if (dict != null) + { + dataGridView.Rows.Clear(); + foreach (var elem in dict) + { + dataGridView.Rows.Add(new object[] { elem.RepairName, "", "" }); + 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); + } + } + + private void buttonSaveToExcel_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + _logic.SaveRepairComponentToExcelFile(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/RenovationWork/FormReportRepairComponents.resx b/RenovationWork/FormReportRepairComponents.resx new file mode 100644 index 0000000..0df6b74 --- /dev/null +++ b/RenovationWork/FormReportRepairComponents.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + True + + + True + + + True + + \ No newline at end of file diff --git a/RenovationWork/Program.cs b/RenovationWork/Program.cs index 6bfba32..7c8d239 100644 --- a/RenovationWork/Program.cs +++ b/RenovationWork/Program.cs @@ -5,7 +5,8 @@ using RenovationWorkDatabaseImplement.Implements; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; - +using RenovationWorkBusinessLogic.OfficePackage.Implements; +using RenovationWorkBusinessLogic.OfficePackage; namespace RenovationWorkView { @@ -40,6 +41,10 @@ namespace RenovationWorkView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -47,6 +52,8 @@ namespace RenovationWorkView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/RenovationWork/Properties/DataSources/RenovationWorkContracts.BusinessLogicsContracts.IOrderLogic.datasource b/RenovationWork/Properties/DataSources/RenovationWorkContracts.BusinessLogicsContracts.IOrderLogic.datasource new file mode 100644 index 0000000..d16c001 --- /dev/null +++ b/RenovationWork/Properties/DataSources/RenovationWorkContracts.BusinessLogicsContracts.IOrderLogic.datasource @@ -0,0 +1,10 @@ + + + + RenovationWorkContracts.BusinessLogicsContracts.IOrderLogic, RenovationWorkContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/RenovationWork/Properties/DataSources/RenovationWorkContracts.BusinessLogicsContracts.IRepairLogic.datasource b/RenovationWork/Properties/DataSources/RenovationWorkContracts.BusinessLogicsContracts.IRepairLogic.datasource new file mode 100644 index 0000000..57d79de --- /dev/null +++ b/RenovationWork/Properties/DataSources/RenovationWorkContracts.BusinessLogicsContracts.IRepairLogic.datasource @@ -0,0 +1,10 @@ + + + + RenovationWorkContracts.BusinessLogicsContracts.IRepairlLogic, RenovationWorkContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/RenovationWork/Properties/DataSources/RenovationWorkContracts.BusinessLogicsContracts.IReportLogic.datasource b/RenovationWork/Properties/DataSources/RenovationWorkContracts.BusinessLogicsContracts.IReportLogic.datasource new file mode 100644 index 0000000..09ed5c4 --- /dev/null +++ b/RenovationWork/Properties/DataSources/RenovationWorkContracts.BusinessLogicsContracts.IReportLogic.datasource @@ -0,0 +1,10 @@ + + + + RenovationWorkContracts.BusinessLogicsContracts.IReportLogic, RenovationWorkContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/RenovationWork/Properties/DataSources/RenovationWorkContracts.StoragesContracts.IComponentStorage.datasource b/RenovationWork/Properties/DataSources/RenovationWorkContracts.StoragesContracts.IComponentStorage.datasource new file mode 100644 index 0000000..d10ea6f --- /dev/null +++ b/RenovationWork/Properties/DataSources/RenovationWorkContracts.StoragesContracts.IComponentStorage.datasource @@ -0,0 +1,10 @@ + + + + RenovationWorkContracts.StoragesContracts.IComponentStorage, RenovationWorkContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/RenovationWork/Properties/DataSources/RenovationWorkContracts.StoragesContracts.IOrderStorage.datasource b/RenovationWork/Properties/DataSources/RenovationWorkContracts.StoragesContracts.IOrderStorage.datasource new file mode 100644 index 0000000..007a219 --- /dev/null +++ b/RenovationWork/Properties/DataSources/RenovationWorkContracts.StoragesContracts.IOrderStorage.datasource @@ -0,0 +1,10 @@ + + + + RenovationWorkContracts.StoragesContracts.IOrderStorage, RenovationWorkContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/RenovationWork/Properties/DataSources/RenovationWorkContracts.StoragesContracts.IRepairStorage.datasource b/RenovationWork/Properties/DataSources/RenovationWorkContracts.StoragesContracts.IRepairStorage.datasource new file mode 100644 index 0000000..2616534 --- /dev/null +++ b/RenovationWork/Properties/DataSources/RenovationWorkContracts.StoragesContracts.IRepairStorage.datasource @@ -0,0 +1,10 @@ + + + + RenovationWorkContracts.StoragesContracts.IRepairStorage, RenovationWorkContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + \ No newline at end of file diff --git a/RenovationWork/RenovationWorkView.csproj b/RenovationWork/RenovationWorkView.csproj index 1f32740..5e3ee9b 100644 --- a/RenovationWork/RenovationWorkView.csproj +++ b/RenovationWork/RenovationWorkView.csproj @@ -2,7 +2,7 @@ WinExe - net6.0-windows + net7.0-windows enable true enable @@ -18,12 +18,15 @@ + + + diff --git a/RenovationWork/ReportOrders.rdlc b/RenovationWork/ReportOrders.rdlc new file mode 100644 index 0000000..58944c4 --- /dev/null +++ b/RenovationWork/ReportOrders.rdlc @@ -0,0 +1,599 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 47cb53f0-7dde-4717-ba03-866a0bc4f4dd + + + + + + RenovationWorkContractsViewModels + /* Local Query */ + + + + Id + System.Int32 + + + DateCreate + System.DateTime + + + RepairName + System.String + + + Sum + System.Decimal + + + Status + RenovationWorkDataModels.Status + + + + RenovationWorkContracts.ViewModels + ReportOrderViewModel + RenovationWorkContracts.ViewModels.ReportOrderViewModel, RenovationWorkContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + + + + + + + + + true + true + + + + + =Parameters!ReportParameterPeriod.Value + + + + + + + ReportParameterPeriod + 1cm + 1cm + 21cm + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + Список заказов + + + + + + + 1cm + 21cm + 1 + + + Middle + 2pt + 2pt + 2pt + 2pt + + + + + + + 2.5cm + + + 3.21438cm + + + 8.23317cm + + + 2.5cm + + + 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!RepairName.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 +