diff --git a/LawFirm/LawFirm/FormMain.Designer.cs b/LawFirm/LawFirm/FormMain.Designer.cs index f9a969a..bfda821 100644 --- a/LawFirm/LawFirm/FormMain.Designer.cs +++ b/LawFirm/LawFirm/FormMain.Designer.cs @@ -38,6 +38,7 @@ 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.buttonCreateOrder = new System.Windows.Forms.Button(); this.buttonSetToWork = new System.Windows.Forms.Button(); @@ -46,7 +47,7 @@ this.buttonUpdate = new System.Windows.Forms.Button(); this.buttonSupplyShop = new System.Windows.Forms.Button(); this.buttonSellDocuments = new System.Windows.Forms.Button(); - this.документыВМагазинахToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.списокЗаказовПоДатеToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.menuStrip.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.SuspendLayout(); @@ -101,7 +102,8 @@ this.бланкиПоДокументамToolStripMenuItem, this.списокЗаказовToolStripMenuItem, this.списокМагазиновToolStripMenuItem, - this.документыВМагазинахToolStripMenuItem}); + this.документыВМагазинахToolStripMenuItem, + this.списокЗаказовПоДатеToolStripMenuItem}); this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(73, 24); this.отчетыToolStripMenuItem.Text = "Отчеты"; @@ -134,6 +136,13 @@ this.списокМагазиновToolStripMenuItem.Text = "Список магазинов"; this.списокМагазиновToolStripMenuItem.Click += new System.EventHandler(this.списокМагазиновToolStripMenuItem_Click); // + // документыВМагазинахToolStripMenuItem + // + this.документыВМагазинахToolStripMenuItem.Name = "документыВМагазинахToolStripMenuItem"; + this.документыВМагазинахToolStripMenuItem.Size = new System.Drawing.Size(259, 26); + this.документыВМагазинахToolStripMenuItem.Text = "Документы в магазинах"; + this.документыВМагазинахToolStripMenuItem.Click += new System.EventHandler(this.документыВМагазинахToolStripMenuItem_Click); + // // dataGridView // this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; @@ -214,12 +223,12 @@ this.buttonSellDocuments.UseVisualStyleBackColor = true; this.buttonSellDocuments.Click += new System.EventHandler(this.buttonSellDocuments_Click); // - // документыВМагазинахToolStripMenuItem + // списокЗаказовПоДатеToolStripMenuItem // - this.документыВМагазинахToolStripMenuItem.Name = "документыВМагазинахToolStripMenuItem"; - this.документыВМагазинахToolStripMenuItem.Size = new System.Drawing.Size(259, 26); - this.документыВМагазинахToolStripMenuItem.Text = "Документы в магазинах"; - this.документыВМагазинахToolStripMenuItem.Click += new System.EventHandler(this.документыВМагазинахToolStripMenuItem_Click); + this.списокЗаказовПоДатеToolStripMenuItem.Name = "списокЗаказовПоДатеToolStripMenuItem"; + this.списокЗаказовПоДатеToolStripMenuItem.Size = new System.Drawing.Size(259, 26); + this.списокЗаказовПоДатеToolStripMenuItem.Text = "Список заказов по дате"; + this.списокЗаказовПоДатеToolStripMenuItem.Click += new System.EventHandler(this.списокЗаказовПоДатеToolStripMenuItem_Click); // // FormMain // @@ -268,5 +277,6 @@ private Button buttonSellDocuments; private ToolStripMenuItem списокМагазиновToolStripMenuItem; private ToolStripMenuItem документыВМагазинахToolStripMenuItem; + private ToolStripMenuItem списокЗаказовПоДатеToolStripMenuItem; } } \ No newline at end of file diff --git a/LawFirm/LawFirm/FormMain.cs b/LawFirm/LawFirm/FormMain.cs index 8b2f7bd..90f0221 100644 --- a/LawFirm/LawFirm/FormMain.cs +++ b/LawFirm/LawFirm/FormMain.cs @@ -126,6 +126,15 @@ namespace LawFirmView } } + private void списокЗаказовПоДатеToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportDateOrders)); + if (service is FormReportDateOrders form) + { + form.ShowDialog(); + } + } + private void магазиныToolStripMenuItem_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormShops)); diff --git a/LawFirm/LawFirm/FormReportDateOrders.Designer.cs b/LawFirm/LawFirm/FormReportDateOrders.Designer.cs new file mode 100644 index 0000000..a8f19ff --- /dev/null +++ b/LawFirm/LawFirm/FormReportDateOrders.Designer.cs @@ -0,0 +1,131 @@ +namespace LawFirmView +{ + partial class FormReportDateOrders + { + /// + /// 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.buttonCreateToPdf = new System.Windows.Forms.Button(); + this.buttonCreateReport = new System.Windows.Forms.Button(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.dateTimePickerEnd = new System.Windows.Forms.DateTimePicker(); + this.dateTimePickerStart = new System.Windows.Forms.DateTimePicker(); + this.panel.SuspendLayout(); + this.SuspendLayout(); + // + // panel + // + this.panel.Controls.Add(this.buttonCreateToPdf); + this.panel.Controls.Add(this.buttonCreateReport); + this.panel.Controls.Add(this.label2); + this.panel.Controls.Add(this.label1); + this.panel.Controls.Add(this.dateTimePickerEnd); + this.panel.Controls.Add(this.dateTimePickerStart); + 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(978, 69); + this.panel.TabIndex = 1; + // + // buttonCreateToPdf + // + this.buttonCreateToPdf.Location = new System.Drawing.Point(769, 39); + this.buttonCreateToPdf.Name = "buttonCreateToPdf"; + this.buttonCreateToPdf.Size = new System.Drawing.Size(190, 27); + this.buttonCreateToPdf.TabIndex = 5; + this.buttonCreateToPdf.Text = "PDF"; + this.buttonCreateToPdf.UseVisualStyleBackColor = true; + this.buttonCreateToPdf.Click += new System.EventHandler(this.buttonCreateToPdf_Click); + // + // buttonCreateReport + // + this.buttonCreateReport.Location = new System.Drawing.Point(554, 39); + this.buttonCreateReport.Name = "buttonCreateReport"; + this.buttonCreateReport.Size = new System.Drawing.Size(190, 27); + this.buttonCreateReport.TabIndex = 4; + this.buttonCreateReport.Text = "Сформировать"; + this.buttonCreateReport.UseVisualStyleBackColor = true; + this.buttonCreateReport.Click += new System.EventHandler(this.buttonCreateReport_Click); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(369, 9); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(56, 20); + this.label2.TabIndex = 3; + this.label2.Text = "Конец:"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(87, 6); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(64, 20); + this.label1.TabIndex = 2; + this.label1.Text = "Начало:"; + // + // dateTimePickerEnd + // + this.dateTimePickerEnd.Location = new System.Drawing.Point(307, 39); + this.dateTimePickerEnd.Name = "dateTimePickerEnd"; + this.dateTimePickerEnd.Size = new System.Drawing.Size(187, 27); + this.dateTimePickerEnd.TabIndex = 1; + // + // dateTimePickerStart + // + this.dateTimePickerStart.Location = new System.Drawing.Point(35, 39); + this.dateTimePickerStart.Name = "dateTimePickerStart"; + this.dateTimePickerStart.Size = new System.Drawing.Size(187, 27); + this.dateTimePickerStart.TabIndex = 0; + // + // FormReportDateOrders + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(978, 450); + this.Controls.Add(this.panel); + this.Name = "FormReportDateOrders"; + this.Text = "Заказы по датам"; + this.panel.ResumeLayout(false); + this.panel.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private Panel panel; + private Button buttonCreateToPdf; + private Button buttonCreateReport; + private Label label2; + private Label label1; + private DateTimePicker dateTimePickerEnd; + private DateTimePicker dateTimePickerStart; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirm/FormReportDateOrders.cs b/LawFirm/LawFirm/FormReportDateOrders.cs new file mode 100644 index 0000000..c0c0f25 --- /dev/null +++ b/LawFirm/LawFirm/FormReportDateOrders.cs @@ -0,0 +1,97 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.BusinessLogicContracts; +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 LawFirmView +{ + public partial class FormReportDateOrders : Form + { + private readonly ReportViewer reportViewer; + + private readonly ILogger _logger; + + private readonly IReportLogic _logic; + public FormReportDateOrders(ILogger logger, IReportLogic reportLogic) + { + InitializeComponent(); + _logger = logger; + _logic = reportLogic; + reportViewer = new ReportViewer + { + Dock = DockStyle.Fill + }; + reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportOrdersByDate.rdlc", FileMode.Open)); + Controls.Clear(); + Controls.Add(reportViewer); + Controls.Add(panel); + } + + private void buttonCreateReport_Click(object sender, EventArgs e) + { + if (dateTimePickerStart.Value.Date >= dateTimePickerEnd.Value.Date) + { + MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + try + { + var dataSource = _logic.GetDateOrders(new ReportBindingModel + { + DateFrom = dateTimePickerStart.Value, + DateTo = dateTimePickerEnd.Value + }); + var source = new ReportDataSource("DataSetOrders", dataSource); + reportViewer.LocalReport.DataSources.Clear(); + reportViewer.LocalReport.DataSources.Add(source); + var parameters = new[] { new ReportParameter("ReportParameterPeriod", $"c {dateTimePickerStart.Value.ToShortDateString()} по {dateTimePickerEnd.Value.ToShortDateString()}") }; + reportViewer.LocalReport.SetParameters(parameters); + reportViewer.RefreshReport(); + _logger.LogInformation("Загрузка списка заказов на период {From}-{To}", dateTimePickerStart.Value.ToShortDateString(), dateTimePickerEnd.Value.ToShortDateString()); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка заказов на период"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void buttonCreateToPdf_Click(object sender, EventArgs e) + { + if (dateTimePickerStart.Value.Date >= dateTimePickerEnd.Value.Date) + { + MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + _logic.SaveDateOrdersToPdfFile(new ReportBindingModel + { + FileName = dialog.FileName, + DateFrom = dateTimePickerStart.Value, + DateTo = dateTimePickerEnd.Value + }); + _logger.LogInformation("Сохранение списка заказов на период {From}-{To}", dateTimePickerStart.Value.ToShortDateString(), dateTimePickerEnd.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/LawFirm/LawFirm/FormReportDateOrders.resx b/LawFirm/LawFirm/FormReportDateOrders.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/LawFirm/LawFirm/FormReportDateOrders.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/LawFirm/LawFirm/Program.cs b/LawFirm/LawFirm/Program.cs index 58b4590..5c0f65a 100644 --- a/LawFirm/LawFirm/Program.cs +++ b/LawFirm/LawFirm/Program.cs @@ -68,6 +68,8 @@ namespace LawFirm services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + } } diff --git a/LawFirm/LawFirm/ReportOrdersByDate.rdlc b/LawFirm/LawFirm/ReportOrdersByDate.rdlc new file mode 100644 index 0000000..7ce32cb --- /dev/null +++ b/LawFirm/LawFirm/ReportOrdersByDate.rdlc @@ -0,0 +1,460 @@ + + + 0 + + + + System.Data.DataSet + /* Local Connection */ + + 10791c83-cee8-4a38-bbd0-245fc17cefb3 + + + + + + LawFirmContractsViewModels + /* Local Query */ + + + + DateCreate + System.DateTime + + + CountOrders + System.Decimal + + + TotalSumOrders + System.Double + + + + LawFirmContracts.ViewModels + ReportDateOrdersViewModel + LawFirmContracts.ViewModels.ReportDateOrdersViewModel, LawFirmContracts, 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 + + + + + + + 3cm + + + 3cm + + + 7cm + + + + + 0.6cm + + + + + true + true + + + + + Дата создания + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Количество заказов + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + Сумма + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + 0.6cm + + + + + true + true + + + + + =Fields!DateCreate.Value + + + + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!CountOrders.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!SumOrders.Value + + + 2pt + 2pt + 2pt + 2pt + + + true + + + + + + + + + + + + + + + + + After + + + + + + + DataSetOrders + 2.48391cm + 0.55245cm + 1.2cm + 13cm + 2 + + + + + + true + true + + + + + Всего: + + + + + + + 4cm + 8.55245cm + 0.6cm + 2.5cm + 3 + + + 2pt + 2pt + 2pt + 2pt + + + + true + true + + + + + =Sum(Fields!SumOrders.Value, "DataSetOrders") + + + + + + + 4cm + 11.05245cm + 0.6cm + 2.5cm + 4 + + + 2pt + 2pt + 2pt + 2pt + + + + 5.72875cm +