diff --git a/LawFirm/LawFirm/FormMain.Designer.cs b/LawFirm/LawFirm/FormMain.Designer.cs index 824ad60..ce67498 100644 --- a/LawFirm/LawFirm/FormMain.Designer.cs +++ b/LawFirm/LawFirm/FormMain.Designer.cs @@ -38,6 +38,10 @@ this.buttonSetToDone = new System.Windows.Forms.Button(); this.buttonSetToFinish = new System.Windows.Forms.Button(); this.buttonUpdate = new System.Windows.Forms.Button(); + 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.menuStrip.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.SuspendLayout(); @@ -46,7 +50,8 @@ // this.menuStrip.ImageScalingSize = new System.Drawing.Size(20, 20); 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(1139, 28); @@ -136,6 +141,35 @@ this.buttonUpdate.UseVisualStyleBackColor = true; this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_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(73, 24); + this.отчетыToolStripMenuItem.Text = "Отчеты"; + // + // списокБланковToolStripMenuItem + // + this.списокБланковToolStripMenuItem.Name = "списокБланковToolStripMenuItem"; + this.списокБланковToolStripMenuItem.Size = new System.Drawing.Size(252, 26); + this.списокБланковToolStripMenuItem.Text = "Список бланков"; + // + // бланкиПоДокументамToolStripMenuItem + // + this.бланкиПоДокументамToolStripMenuItem.Name = "бланкиПоДокументамToolStripMenuItem"; + this.бланкиПоДокументамToolStripMenuItem.Size = new System.Drawing.Size(252, 26); + this.бланкиПоДокументамToolStripMenuItem.Text = "Бланки по документам"; + this.бланкиПоДокументамToolStripMenuItem.Click += new System.EventHandler(this.бланкиПоДокументамToolStripMenuItem_Click); + // + // списокЗаказовToolStripMenuItem + // + this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; + this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(252, 26); + this.списокЗаказовToolStripMenuItem.Text = "Список заказов"; + // // FormMain // this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); @@ -172,5 +206,9 @@ private Button buttonSetToDone; private Button buttonSetToFinish; private Button buttonUpdate; + private ToolStripMenuItem отчетыToolStripMenuItem; + 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 7c21f6a..b1d6aa1 100644 --- a/LawFirm/LawFirm/FormMain.cs +++ b/LawFirm/LawFirm/FormMain.cs @@ -69,6 +69,15 @@ namespace LawFirmView } } + private void бланкиПоДокументамToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportDocumentBlanks)); + if (service is FormReportDocumentBlanks form) + { + form.ShowDialog(); + } + } + private void buttonCreateOrder_Click(object sender, EventArgs e) { var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); @@ -163,5 +172,7 @@ namespace LawFirmView { LoadData(); } + + } } diff --git a/LawFirm/LawFirm/FormReportDocumentBlanks.Designer.cs b/LawFirm/LawFirm/FormReportDocumentBlanks.Designer.cs new file mode 100644 index 0000000..ba07a69 --- /dev/null +++ b/LawFirm/LawFirm/FormReportDocumentBlanks.Designer.cs @@ -0,0 +1,110 @@ +namespace LawFirmView +{ + partial class FormReportDocumentBlanks + { + /// + /// 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.Blank = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Document = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.buttonSaveToExcel = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // dataGridView + // + this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { + this.Blank, + this.Document, + this.Count}); + this.dataGridView.Location = new System.Drawing.Point(12, 37); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowHeadersWidth = 51; + this.dataGridView.RowTemplate.Height = 29; + this.dataGridView.Size = new System.Drawing.Size(776, 401); + this.dataGridView.TabIndex = 0; + // + // Blank + // + this.Blank.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.Blank.HeaderText = "Бланк"; + this.Blank.MinimumWidth = 6; + this.Blank.Name = "Blank"; + // + // Document + // + this.Document.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill; + this.Document.HeaderText = "Документ"; + this.Document.MinimumWidth = 6; + this.Document.Name = "Document"; + // + // Count + // + this.Count.HeaderText = "Количество"; + this.Count.MinimumWidth = 6; + this.Count.Name = "Count"; + this.Count.Width = 125; + // + // buttonSaveToExcel + // + this.buttonSaveToExcel.Location = new System.Drawing.Point(12, 2); + this.buttonSaveToExcel.Name = "buttonSaveToExcel"; + this.buttonSaveToExcel.Size = new System.Drawing.Size(220, 29); + this.buttonSaveToExcel.TabIndex = 1; + this.buttonSaveToExcel.Text = "Сохранить в Excel"; + this.buttonSaveToExcel.UseVisualStyleBackColor = true; + this.buttonSaveToExcel.Click += new System.EventHandler(this.buttonSaveToExcel_Click); + // + // FormReportDocumentBlanks + // + this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.buttonSaveToExcel); + this.Controls.Add(this.dataGridView); + this.Name = "FormReportDocumentBlanks"; + this.Text = "Бланки по документам"; + this.Load += new System.EventHandler(this.FormReportDocumentBlanks_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private DataGridView dataGridView; + private DataGridViewTextBoxColumn Blank; + private DataGridViewTextBoxColumn Document; + private DataGridViewTextBoxColumn Count; + private Button buttonSaveToExcel; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirm/FormReportDocumentBlanks.cs b/LawFirm/LawFirm/FormReportDocumentBlanks.cs new file mode 100644 index 0000000..551d9d5 --- /dev/null +++ b/LawFirm/LawFirm/FormReportDocumentBlanks.cs @@ -0,0 +1,85 @@ +using LawFirmContracts.BindingModels; +using LawFirmContracts.BusinessLogicContracts; +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 LawFirmView +{ + public partial class FormReportDocumentBlanks : Form + { + private readonly ILogger _logger; + private readonly IReportLogic _logic; + + public FormReportDocumentBlanks(ILogger logger, IReportLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormReportDocumentBlanks_Load(object sender, EventArgs e) + { + try + { + var dict = _logic.GetProductComponent(); + if (dict != null) + { + dataGridView.Rows.Clear(); + foreach (var elem in dict) + { + dataGridView.Rows.Add(new object[] { elem.BlankName, "", "" }); + foreach (var listElem in elem.Documents) + { + 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.SaveProductComponentToExcelFile(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/LawFirm/LawFirm/FormReportDocumentBlanks.resx b/LawFirm/LawFirm/FormReportDocumentBlanks.resx new file mode 100644 index 0000000..0908e41 --- /dev/null +++ b/LawFirm/LawFirm/FormReportDocumentBlanks.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/LawFirm/LawFirm/Program.cs b/LawFirm/LawFirm/Program.cs index 8babc23..70ca19c 100644 --- a/LawFirm/LawFirm/Program.cs +++ b/LawFirm/LawFirm/Program.cs @@ -1,4 +1,6 @@ using LawFirmBusinessLogic.BusinessLogics; +using LawFirmBusinessLogic.OfficePackage; +using LawFirmBusinessLogic.OfficePackage.Implements; using LawFirmContracts.BusinessLogicContracts; using LawFirmContracts.StorageContracts; using LawFirmDatabaseImplement.Implements; @@ -45,6 +47,11 @@ namespace LawFirm services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -53,6 +60,7 @@ namespace LawFirm services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); } }