From d455459ca1333777c5350c8d978062f73a8711a9 Mon Sep 17 00:00:00 2001 From: "ityurner02@mail.ru" Date: Mon, 20 Mar 2023 16:12:37 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BD=D0=B5=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82?= =?UTF-8?q?=D0=B0=D0=B5=D1=82=20=D0=BE=D1=82=D1=87=D0=B5=D1=82=20=D0=BF?= =?UTF-8?q?=D0=BE=20=D0=B7=D0=B0=D0=BA=D0=B0=D0=B7=D0=B0=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlumbingRepair/FormMain.Designer.cs | 242 ++++--- PlumbingRepair/PlumbingRepair/FormMain.cs | 36 +- .../FormReportOrders.Designer.cs | 141 +++++ .../PlumbingRepair/FormReportOrders.cs | 91 +++ .../PlumbingRepair/FormReportOrders.resx | 120 ++++ .../PlumbingRepair/PlumbingRepair.csproj | 2 + PlumbingRepair/PlumbingRepair/Program.cs | 1 + .../PlumbingRepair/ReportOrders.rdlc | 599 ++++++++++++++++++ 8 files changed, 1126 insertions(+), 106 deletions(-) create mode 100644 PlumbingRepair/PlumbingRepair/FormReportOrders.Designer.cs create mode 100644 PlumbingRepair/PlumbingRepair/FormReportOrders.cs create mode 100644 PlumbingRepair/PlumbingRepair/FormReportOrders.resx create mode 100644 PlumbingRepair/PlumbingRepair/ReportOrders.rdlc diff --git a/PlumbingRepair/PlumbingRepair/FormMain.Designer.cs b/PlumbingRepair/PlumbingRepair/FormMain.Designer.cs index 3812a8c..8881750 100644 --- a/PlumbingRepair/PlumbingRepair/FormMain.Designer.cs +++ b/PlumbingRepair/PlumbingRepair/FormMain.Designer.cs @@ -28,144 +28,172 @@ /// private void InitializeComponent() { - this.MenuStrip = new System.Windows.Forms.MenuStrip(); - 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(); - this.OrderReadyButton = new System.Windows.Forms.Button(); - this.IssuedOrderButton = new System.Windows.Forms.Button(); - this.UpdateListButton = new System.Windows.Forms.Button(); - this.MenuStrip.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit(); - this.SuspendLayout(); + MenuStrip = new MenuStrip(); + СправочникиToolStripMenuItem = new ToolStripMenuItem(); + ИзделияToolStripMenuItem = new ToolStripMenuItem(); + КомпонентыToolStripMenuItem = new ToolStripMenuItem(); + отчетыToolStripMenuItem = new ToolStripMenuItem(); + WorksToolStripMenuItem = new ToolStripMenuItem(); + WorkComponentToolStripMenuItem = new ToolStripMenuItem(); + OrdersToolStripMenuItem = new ToolStripMenuItem(); + DataGridView = new DataGridView(); + CreateOrderButton = new Button(); + TakeOrderInWorkButton = new Button(); + OrderReadyButton = new Button(); + IssuedOrderButton = new Button(); + UpdateListButton = new Button(); + MenuStrip.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit(); + SuspendLayout(); // // MenuStrip // - this.MenuStrip.ImageScalingSize = new System.Drawing.Size(20, 20); - this.MenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.СправочникиToolStripMenuItem}); - this.MenuStrip.Location = new System.Drawing.Point(0, 0); - this.MenuStrip.Name = "MenuStrip"; - this.MenuStrip.Padding = new System.Windows.Forms.Padding(7, 3, 0, 3); - this.MenuStrip.Size = new System.Drawing.Size(989, 30); - this.MenuStrip.TabIndex = 0; - this.MenuStrip.Text = "menuStrip1"; + MenuStrip.ImageScalingSize = new Size(20, 20); + MenuStrip.Items.AddRange(new ToolStripItem[] { СправочникиToolStripMenuItem, отчетыToolStripMenuItem }); + MenuStrip.Location = new Point(0, 0); + MenuStrip.Name = "MenuStrip"; + MenuStrip.Padding = new Padding(7, 3, 0, 3); + MenuStrip.Size = new Size(989, 30); + MenuStrip.TabIndex = 0; + MenuStrip.Text = "menuStrip1"; // // СправочникиToolStripMenuItem // - this.СправочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.ИзделияToolStripMenuItem, - this.КомпонентыToolStripMenuItem}); - this.СправочникиToolStripMenuItem.Name = "СправочникиToolStripMenuItem"; - this.СправочникиToolStripMenuItem.Size = new System.Drawing.Size(117, 24); - this.СправочникиToolStripMenuItem.Text = "Cправочники"; + СправочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ИзделияToolStripMenuItem, КомпонентыToolStripMenuItem }); + СправочникиToolStripMenuItem.Name = "СправочникиToolStripMenuItem"; + СправочникиToolStripMenuItem.Size = new Size(117, 24); + СправочникиToolStripMenuItem.Text = "Cправочники"; // // ИзделияToolStripMenuItem // - this.ИзделияToolStripMenuItem.Name = "ИзделияToolStripMenuItem"; - this.ИзделияToolStripMenuItem.Size = new System.Drawing.Size(182, 26); - this.ИзделияToolStripMenuItem.Text = "Изделия"; - this.ИзделияToolStripMenuItem.Click += new System.EventHandler(this.ИзделияToolStripMenuItem_Click); + ИзделияToolStripMenuItem.Name = "ИзделияToolStripMenuItem"; + ИзделияToolStripMenuItem.Size = new Size(182, 26); + ИзделияToolStripMenuItem.Text = "Изделия"; + ИзделияToolStripMenuItem.Click += ИзделияToolStripMenuItem_Click; // // КомпонентыToolStripMenuItem // - this.КомпонентыToolStripMenuItem.Name = "КомпонентыToolStripMenuItem"; - this.КомпонентыToolStripMenuItem.Size = new System.Drawing.Size(182, 26); - this.КомпонентыToolStripMenuItem.Text = "Компоненты"; - this.КомпонентыToolStripMenuItem.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click); + КомпонентыToolStripMenuItem.Name = "КомпонентыToolStripMenuItem"; + КомпонентыToolStripMenuItem.Size = new Size(182, 26); + КомпонентыToolStripMenuItem.Text = "Компоненты"; + КомпонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click; + // + // отчетыToolStripMenuItem + // + отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { WorksToolStripMenuItem, WorkComponentToolStripMenuItem, OrdersToolStripMenuItem }); + отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + отчетыToolStripMenuItem.Size = new Size(73, 24); + отчетыToolStripMenuItem.Text = "Отчеты"; + // + // WorksToolStripMenuItem + // + WorksToolStripMenuItem.Name = "WorksToolStripMenuItem"; + WorksToolStripMenuItem.Size = new Size(273, 26); + WorksToolStripMenuItem.Text = "Список изделий"; + WorksToolStripMenuItem.Click += WorksToolStripMenuItem_Click; + // + // WorkComponentToolStripMenuItem + // + WorkComponentToolStripMenuItem.Name = "WorkComponentToolStripMenuItem"; + WorkComponentToolStripMenuItem.Size = new Size(273, 26); + WorkComponentToolStripMenuItem.Text = "Изделия по компонентам"; + WorkComponentToolStripMenuItem.Click += WorkComponentToolStripMenuItem_Click; + // + // OrdersToolStripMenuItem + // + OrdersToolStripMenuItem.Name = "OrdersToolStripMenuItem"; + OrdersToolStripMenuItem.Size = new Size(273, 26); + OrdersToolStripMenuItem.Text = "Список заказов"; + OrdersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click; // // DataGridView // - this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; - this.DataGridView.Location = new System.Drawing.Point(0, 36); - 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(825, 561); - this.DataGridView.TabIndex = 1; + DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; + DataGridView.Location = new Point(0, 36); + DataGridView.Margin = new Padding(3, 4, 3, 4); + DataGridView.Name = "DataGridView"; + DataGridView.RowHeadersWidth = 51; + DataGridView.RowTemplate.Height = 25; + DataGridView.Size = new Size(825, 561); + DataGridView.TabIndex = 1; // // CreateOrderButton // - this.CreateOrderButton.Location = new System.Drawing.Point(832, 37); - this.CreateOrderButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.CreateOrderButton.Name = "CreateOrderButton"; - this.CreateOrderButton.Size = new System.Drawing.Size(143, 44); - this.CreateOrderButton.TabIndex = 2; - this.CreateOrderButton.Text = "Создать заказ"; - this.CreateOrderButton.UseVisualStyleBackColor = true; - this.CreateOrderButton.Click += new System.EventHandler(this.CreateOrderButton_Click); + CreateOrderButton.Location = new Point(832, 37); + CreateOrderButton.Margin = new Padding(3, 4, 3, 4); + CreateOrderButton.Name = "CreateOrderButton"; + CreateOrderButton.Size = new Size(143, 44); + CreateOrderButton.TabIndex = 2; + CreateOrderButton.Text = "Создать заказ"; + CreateOrderButton.UseVisualStyleBackColor = true; + CreateOrderButton.Click += CreateOrderButton_Click; // // TakeOrderInWorkButton // - this.TakeOrderInWorkButton.Location = new System.Drawing.Point(832, 111); - this.TakeOrderInWorkButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.TakeOrderInWorkButton.Name = "TakeOrderInWorkButton"; - this.TakeOrderInWorkButton.Size = new System.Drawing.Size(143, 52); - this.TakeOrderInWorkButton.TabIndex = 3; - this.TakeOrderInWorkButton.Text = "Отдать на выполнение"; - this.TakeOrderInWorkButton.UseVisualStyleBackColor = true; - this.TakeOrderInWorkButton.Click += new System.EventHandler(this.TakeOrderInWorkButton_Click); + TakeOrderInWorkButton.Location = new Point(832, 111); + TakeOrderInWorkButton.Margin = new Padding(3, 4, 3, 4); + TakeOrderInWorkButton.Name = "TakeOrderInWorkButton"; + TakeOrderInWorkButton.Size = new Size(143, 52); + TakeOrderInWorkButton.TabIndex = 3; + TakeOrderInWorkButton.Text = "Отдать на выполнение"; + TakeOrderInWorkButton.UseVisualStyleBackColor = true; + TakeOrderInWorkButton.Click += TakeOrderInWorkButton_Click; // // OrderReadyButton // - this.OrderReadyButton.Location = new System.Drawing.Point(832, 195); - this.OrderReadyButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.OrderReadyButton.Name = "OrderReadyButton"; - this.OrderReadyButton.Size = new System.Drawing.Size(143, 44); - this.OrderReadyButton.TabIndex = 4; - this.OrderReadyButton.Text = "Заказ готов"; - this.OrderReadyButton.UseVisualStyleBackColor = true; - this.OrderReadyButton.Click += new System.EventHandler(this.OrderReadyButton_Click); + OrderReadyButton.Location = new Point(832, 195); + OrderReadyButton.Margin = new Padding(3, 4, 3, 4); + OrderReadyButton.Name = "OrderReadyButton"; + OrderReadyButton.Size = new Size(143, 44); + OrderReadyButton.TabIndex = 4; + OrderReadyButton.Text = "Заказ готов"; + OrderReadyButton.UseVisualStyleBackColor = true; + OrderReadyButton.Click += OrderReadyButton_Click; // // IssuedOrderButton // - this.IssuedOrderButton.Location = new System.Drawing.Point(832, 272); - this.IssuedOrderButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.IssuedOrderButton.Name = "IssuedOrderButton"; - this.IssuedOrderButton.Size = new System.Drawing.Size(143, 44); - this.IssuedOrderButton.TabIndex = 5; - this.IssuedOrderButton.Text = "Заказ выдан"; - this.IssuedOrderButton.UseVisualStyleBackColor = true; - this.IssuedOrderButton.Click += new System.EventHandler(this.IssuedOrderButton_Click); + IssuedOrderButton.Location = new Point(832, 272); + IssuedOrderButton.Margin = new Padding(3, 4, 3, 4); + IssuedOrderButton.Name = "IssuedOrderButton"; + IssuedOrderButton.Size = new Size(143, 44); + IssuedOrderButton.TabIndex = 5; + IssuedOrderButton.Text = "Заказ выдан"; + IssuedOrderButton.UseVisualStyleBackColor = true; + IssuedOrderButton.Click += IssuedOrderButton_Click; // // UpdateListButton // - this.UpdateListButton.Location = new System.Drawing.Point(832, 349); - this.UpdateListButton.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.UpdateListButton.Name = "UpdateListButton"; - this.UpdateListButton.Size = new System.Drawing.Size(143, 44); - this.UpdateListButton.TabIndex = 6; - this.UpdateListButton.Text = "Обновить список"; - this.UpdateListButton.UseVisualStyleBackColor = true; - this.UpdateListButton.Click += new System.EventHandler(this.UpdateListButton_Click); + UpdateListButton.Location = new Point(832, 349); + UpdateListButton.Margin = new Padding(3, 4, 3, 4); + UpdateListButton.Name = "UpdateListButton"; + UpdateListButton.Size = new Size(143, 44); + UpdateListButton.TabIndex = 6; + UpdateListButton.Text = "Обновить список"; + UpdateListButton.UseVisualStyleBackColor = true; + UpdateListButton.Click += UpdateListButton_Click; // // FormMain // - this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(989, 600); - this.Controls.Add(this.UpdateListButton); - this.Controls.Add(this.IssuedOrderButton); - this.Controls.Add(this.OrderReadyButton); - this.Controls.Add(this.TakeOrderInWorkButton); - this.Controls.Add(this.CreateOrderButton); - this.Controls.Add(this.DataGridView); - this.Controls.Add(this.MenuStrip); - this.MainMenuStrip = this.MenuStrip; - this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); - this.Name = "FormMain"; - this.Text = "Ремонт сантехники"; - this.Load += new System.EventHandler(this.FormMain_Load); - this.MenuStrip.ResumeLayout(false); - this.MenuStrip.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit(); - this.ResumeLayout(false); - this.PerformLayout(); - + AutoScaleDimensions = new SizeF(8F, 20F); + AutoScaleMode = AutoScaleMode.Font; + ClientSize = new Size(989, 600); + Controls.Add(UpdateListButton); + Controls.Add(IssuedOrderButton); + Controls.Add(OrderReadyButton); + Controls.Add(TakeOrderInWorkButton); + Controls.Add(CreateOrderButton); + Controls.Add(DataGridView); + Controls.Add(MenuStrip); + MainMenuStrip = MenuStrip; + Margin = new Padding(3, 4, 3, 4); + Name = "FormMain"; + Text = "Ремонт сантехники"; + Load += FormMain_Load; + MenuStrip.ResumeLayout(false); + MenuStrip.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)DataGridView).EndInit(); + ResumeLayout(false); + PerformLayout(); } #endregion @@ -180,5 +208,9 @@ private Button OrderReadyButton; private Button IssuedOrderButton; private Button UpdateListButton; + private ToolStripMenuItem отчетыToolStripMenuItem; + private ToolStripMenuItem WorksToolStripMenuItem; + private ToolStripMenuItem WorkComponentToolStripMenuItem; + private ToolStripMenuItem OrdersToolStripMenuItem; } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepair/FormMain.cs b/PlumbingRepair/PlumbingRepair/FormMain.cs index c926035..dfbb423 100644 --- a/PlumbingRepair/PlumbingRepair/FormMain.cs +++ b/PlumbingRepair/PlumbingRepair/FormMain.cs @@ -1,4 +1,5 @@ using Microsoft.Extensions.Logging; +using PlumbingRepairBusinessLogic.BusinessLogic; using PlumbingRepairContracts.BindingModels; using PlumbingRepairContracts.BusinessLogicsContracts; using PlumbingRepairDataModels.Enums; @@ -10,11 +11,13 @@ namespace PlumbingRepair 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) @@ -186,5 +189,36 @@ namespace PlumbingRepair { LoadData(); } + + private void WorksToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SaveWorksToWordFile(new ReportBindingModel + { + FileName = dialog.FileName + }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + + private void WorkComponentToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportWorkComponents)); + if (service is FormReportWorkComponents 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/PlumbingRepair/PlumbingRepair/FormReportOrders.Designer.cs b/PlumbingRepair/PlumbingRepair/FormReportOrders.Designer.cs new file mode 100644 index 0000000..cc02116 --- /dev/null +++ b/PlumbingRepair/PlumbingRepair/FormReportOrders.Designer.cs @@ -0,0 +1,141 @@ +namespace PlumbingRepair +{ + partial class FormReportOrders + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.panel = new System.Windows.Forms.Panel(); + this.buttonToPdf = new System.Windows.Forms.Button(); + this.buttonMake = new System.Windows.Forms.Button(); + this.dateTimePickerTo = new System.Windows.Forms.DateTimePicker(); + this.labelTo = new System.Windows.Forms.Label(); + this.dateTimePickerFrom = new System.Windows.Forms.DateTimePicker(); + this.labelFrom = new System.Windows.Forms.Label(); + this.panel.SuspendLayout(); + this.SuspendLayout(); + // + // panel + // + this.panel.Controls.Add(this.buttonToPdf); + this.panel.Controls.Add(this.buttonMake); + this.panel.Controls.Add(this.dateTimePickerTo); + this.panel.Controls.Add(this.labelTo); + this.panel.Controls.Add(this.dateTimePickerFrom); + this.panel.Controls.Add(this.labelFrom); + this.panel.Dock = System.Windows.Forms.DockStyle.Top; + this.panel.Location = new System.Drawing.Point(0, 0); + this.panel.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.panel.Name = "panel"; + this.panel.Size = new System.Drawing.Size(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(476, 8); + this.buttonMake.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.buttonMake.Name = "buttonMake"; + this.buttonMake.Size = new System.Drawing.Size(139, 27); + this.buttonMake.TabIndex = 4; + this.buttonMake.Text = "Сформировать"; + this.buttonMake.UseVisualStyleBackColor = true; + this.buttonMake.Click += new System.EventHandler(this.ButtonMake_Click); + // + // dateTimePickerTo + // + this.dateTimePickerTo.Location = new System.Drawing.Point(237, 7); + this.dateTimePickerTo.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.dateTimePickerTo.Name = "dateTimePickerTo"; + this.dateTimePickerTo.Size = new System.Drawing.Size(163, 23); + this.dateTimePickerTo.TabIndex = 3; + // + // labelTo + // + this.labelTo.AutoSize = true; + this.labelTo.Location = new System.Drawing.Point(208, 10); + this.labelTo.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.labelTo.Name = "labelTo"; + this.labelTo.Size = new System.Drawing.Size(21, 15); + this.labelTo.TabIndex = 2; + this.labelTo.Text = "по"; + // + // dateTimePickerFrom + // + this.dateTimePickerFrom.Location = new System.Drawing.Point(37, 7); + this.dateTimePickerFrom.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3); + this.dateTimePickerFrom.Name = "dateTimePickerFrom"; + this.dateTimePickerFrom.Size = new System.Drawing.Size(163, 23); + this.dateTimePickerFrom.TabIndex = 1; + // + // labelFrom + // + this.labelFrom.AutoSize = true; + this.labelFrom.Location = new System.Drawing.Point(14, 10); + this.labelFrom.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0); + this.labelFrom.Name = "labelFrom"; + this.labelFrom.Size = new System.Drawing.Size(15, 15); + this.labelFrom.TabIndex = 0; + this.labelFrom.Text = "С"; + // + // FormReportOrders + // + 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 = "FormReportOrders"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Заказы"; + this.panel.ResumeLayout(false); + this.panel.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Panel panel; + private System.Windows.Forms.Button buttonToPdf; + private System.Windows.Forms.Button buttonMake; + private System.Windows.Forms.DateTimePicker dateTimePickerTo; + private System.Windows.Forms.Label labelTo; + private System.Windows.Forms.DateTimePicker dateTimePickerFrom; + private System.Windows.Forms.Label labelFrom; + } +} \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepair/FormReportOrders.cs b/PlumbingRepair/PlumbingRepair/FormReportOrders.cs new file mode 100644 index 0000000..ed05ab7 --- /dev/null +++ b/PlumbingRepair/PlumbingRepair/FormReportOrders.cs @@ -0,0 +1,91 @@ +using Microsoft.Extensions.Logging; +using Microsoft.Reporting.WinForms; +using PlumbingRepairContracts.BindingModels; +using PlumbingRepairContracts.BusinessLogicsContracts; + +namespace PlumbingRepair +{ + 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/PlumbingRepair/PlumbingRepair/FormReportOrders.resx b/PlumbingRepair/PlumbingRepair/FormReportOrders.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/PlumbingRepair/PlumbingRepair/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/PlumbingRepair/PlumbingRepair/PlumbingRepair.csproj b/PlumbingRepair/PlumbingRepair/PlumbingRepair.csproj index 0b36aea..b5a0dde 100644 --- a/PlumbingRepair/PlumbingRepair/PlumbingRepair.csproj +++ b/PlumbingRepair/PlumbingRepair/PlumbingRepair.csproj @@ -14,10 +14,12 @@ runtime; build; native; contentfiles; analyzers; buildtransitive + + diff --git a/PlumbingRepair/PlumbingRepair/Program.cs b/PlumbingRepair/PlumbingRepair/Program.cs index 05d00b1..343fd1a 100644 --- a/PlumbingRepair/PlumbingRepair/Program.cs +++ b/PlumbingRepair/PlumbingRepair/Program.cs @@ -53,6 +53,7 @@ namespace PlumbingRepair services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/PlumbingRepair/PlumbingRepair/ReportOrders.rdlc b/PlumbingRepair/PlumbingRepair/ReportOrders.rdlc new file mode 100644 index 0000000..e376033 --- /dev/null +++ b/PlumbingRepair/PlumbingRepair/ReportOrders.rdlc @@ -0,0 +1,599 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 10791c83-cee8-4a38-bbd0-245fc17cefb3 + + + + + + PlumbingRepairContractsViewModels + /* Local Query */ + + + + Id + System.Int32 + + + DateCreate + System.DateTime + + + WorkName + System.String + + + Status + System.String + + + Sum + System.Decimal + + + + AbstractShopContracts.ViewModels + ReportOrdersViewModel + PlumbingRepairContracts.ViewModels.ReportOrdersViewModel, PlumbingRepairContracts, 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!WorkName.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Status.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!Sum.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + + + + + + + + + + + + + + After + + + + + + + DataSetOrders + 2.48391cm + 0.55245cm + 1.2cm + 18.94755cm + 2 + + + + + + true + true + + + + + Итого: + + + + + + + 4cm + 14.5cm + 0.6cm + 2.5cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!Sum.Value, "DataSetOrders") + + + + + + + 4cm + 17cm + 0.6cm + 2.5cm + 4 + + + 2pt + 2pt + 2pt + 2pt + + + + 5.72875cm +