diff --git a/LawFirm/LawFirmBusinessLogic/BusinessLogics/ReportLogic.cs b/LawFirm/LawFirmBusinessLogic/BusinessLogics/ReportLogic.cs index 0b141dd..def32b9 100644 --- a/LawFirm/LawFirmBusinessLogic/BusinessLogics/ReportLogic.cs +++ b/LawFirm/LawFirmBusinessLogic/BusinessLogics/ReportLogic.cs @@ -49,8 +49,7 @@ namespace LawFirmBusinessLogic.BusinessLogics { if (document.DocumentBlanks.ContainsKey(blank.Id)) { - record.Blanks.Add(new Tuple(blank.BlankName, document.DocumentBlanks[blank.Id].Item2)); + record.Blanks.Add(new Tuple(blank.BlankName, document.DocumentBlanks[blank.Id].Item2)); record.TotalCount += document.DocumentBlanks[blank.Id].Item2; } @@ -90,12 +89,12 @@ namespace LawFirmBusinessLogic.BusinessLogics _saveToWord.CreateDoc(new WordInfo { FileName = model.FileName, - Title = "Список компонент", + Title = "Список бланков", Blanks = _blankStorage.GetFullList() }); } /// - /// Сохранение компонент с указаеним продуктов в файл-Excel + /// Сохранение продукта с указаеним компонент в файл-Excel /// /// public void SaveDocumentBlankToExcelFile(ReportBindingModel model) @@ -103,7 +102,7 @@ namespace LawFirmBusinessLogic.BusinessLogics _saveToExcel.CreateReport(new ExcelInfo { FileName = model.FileName, - Title = "Список компонент", + Title = "Документы и их бланки", DocumentBlanks = GetDocumentBlank() }); } @@ -117,8 +116,8 @@ namespace LawFirmBusinessLogic.BusinessLogics { FileName = model.FileName, Title = "Список заказов", - DateFrom = model.DateFrom!.Value, - DateTo = model.DateTo!.Value, + DateFrom = DateTime.SpecifyKind(model.DateFrom!.Value, DateTimeKind.Utc), + DateTo = DateTime.SpecifyKind(model.DateTo!.Value, DateTimeKind.Utc), Orders = GetOrders(model) }); } diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index fd3f7bb..0b5443c 100644 --- a/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -31,27 +31,25 @@ namespace LawFirmBusinessLogic.OfficePackage { ColumnName = "A", RowIndex = rowIndex, - Text = pc.BlankName, + Text = pc.DocumentName, StyleInfo = ExcelStyleInfoType.Text }); rowIndex++; - foreach (var document in pc.Documents) + foreach (var (Blanks, Count) in pc.Blanks) { InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "B", RowIndex = rowIndex, - Text = document.Item1, - StyleInfo = - ExcelStyleInfoType.TextWithBroder + Text = Blanks, + StyleInfo = ExcelStyleInfoType.TextWithBroder }); InsertCellInWorksheet(new ExcelCellParameters { ColumnName = "C", RowIndex = rowIndex, - Text = document.Item2.ToString(), - StyleInfo = - ExcelStyleInfoType.TextWithBroder + Text = Count.ToString(), + StyleInfo = ExcelStyleInfoType.TextWithBroder }); rowIndex++; } diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToWord.cs index 5fec1e8..49afb71 100644 --- a/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -22,7 +22,10 @@ namespace LawFirmBusinessLogic.OfficePackage { CreateParagraph(new WordParagraph { - Texts = new List<(string, WordTextProperties)> {(blank.BlankName, new WordTextProperties { Size = "24", }) }, + Texts = new List<(string, WordTextProperties)> { + (blank.BlankName + " - ", new WordTextProperties { Size = "24", Bold=true}), + (blank.Price.ToString(), new WordTextProperties { Size = "24", }) + }, TextProperties = new WordTextProperties { Size = "24", diff --git a/LawFirm/LawFirmBusinessLogic/OfficePackage/Implements/SaveToWord.cs b/LawFirm/LawFirmBusinessLogic/OfficePackage/Implements/SaveToWord.cs index 5fb2b62..c309228 100644 --- a/LawFirm/LawFirmBusinessLogic/OfficePackage/Implements/SaveToWord.cs +++ b/LawFirm/LawFirmBusinessLogic/OfficePackage/Implements/SaveToWord.cs @@ -54,8 +54,7 @@ namespace LawFirmBusinessLogic.OfficePackage.Implements var properties = new ParagraphProperties(); properties.AppendChild(new Justification() { - Val = - GetJustificationValues(paragraphProperties.JustificationType) + Val = GetJustificationValues(paragraphProperties.JustificationType) }); properties.AppendChild(new SpacingBetweenLines { @@ -67,8 +66,7 @@ namespace LawFirmBusinessLogic.OfficePackage.Implements { paragraphMarkRunProperties.AppendChild(new FontSize { - Val = - paragraphProperties.Size + Val = paragraphProperties.Size }); } properties.AppendChild(paragraphMarkRunProperties); diff --git a/LawFirm/LawFirmContracts/ViewModels/OrderViewModel.cs b/LawFirm/LawFirmContracts/ViewModels/OrderViewModel.cs index 59f4972..06c7dd3 100644 --- a/LawFirm/LawFirmContracts/ViewModels/OrderViewModel.cs +++ b/LawFirm/LawFirmContracts/ViewModels/OrderViewModel.cs @@ -18,7 +18,7 @@ namespace LawFirmContracts.ViewModels [DisplayName("Статус")] public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; [DisplayName("Дата создания")] - public DateTime DateCreate { get; set; } = DateTime.Now; + public DateTime DateCreate { get; set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc); [DisplayName("Дата выполнения")] public DateTime? DateImplement { get; set; } } diff --git a/LawFirm/LawFirmContracts/ViewModels/ReportDocumentBlankViewModel.cs b/LawFirm/LawFirmContracts/ViewModels/ReportDocumentBlankViewModel.cs index 7862899..c435fff 100644 --- a/LawFirm/LawFirmContracts/ViewModels/ReportDocumentBlankViewModel.cs +++ b/LawFirm/LawFirmContracts/ViewModels/ReportDocumentBlankViewModel.cs @@ -4,6 +4,6 @@ { public string DocumentName { get; set; } = string.Empty; public int TotalCount { get; set; } - public List<(string Blank, int Count)> Blanks { get; set; } = new(); + public List> Blanks { get; set; } = new(); } } diff --git a/LawFirm/LawFirmDatabaseImplement/Implements/OrderStorage.cs b/LawFirm/LawFirmDatabaseImplement/Implements/OrderStorage.cs index a7fb3e1..b68d054 100644 --- a/LawFirm/LawFirmDatabaseImplement/Implements/OrderStorage.cs +++ b/LawFirm/LawFirmDatabaseImplement/Implements/OrderStorage.cs @@ -40,14 +40,14 @@ namespace LawFirmDatabaseImplement.Implements public List GetFilteredList(OrderSearchModel model) { - if (!model.Id.HasValue) + if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue) { return new(); } using var context = new LawFirmDatabase(); - return context.Orders.Where(x => x.Id == model.Id).Select(x => GetViewModel(x)).ToList(); + return context.Orders.Where(x => x.Id == model.Id || model.DateFrom <= x.DateCreate && x.DateCreate <= model.DateTo).Select(x => GetViewModel(x)).ToList(); } public List GetFullList() diff --git a/LawFirm/LawFirmDatabaseImplement/Models/Order.cs b/LawFirm/LawFirmDatabaseImplement/Models/Order.cs index 1f72f68..8ed70ff 100644 --- a/LawFirm/LawFirmDatabaseImplement/Models/Order.cs +++ b/LawFirm/LawFirmDatabaseImplement/Models/Order.cs @@ -60,8 +60,7 @@ namespace LawFirmDatabaseImplement.Models Sum = Sum, Status = Status, DateCreate = DateCreate, - DateImplement = DateImplement, - DocumentName = Document.DocumentName + DateImplement = DateImplement }; } } diff --git a/LawFirm/LawFirmFileImplement/Implements/OrderStorage.cs b/LawFirm/LawFirmFileImplement/Implements/OrderStorage.cs index 783ef1a..aa6c9dd 100644 --- a/LawFirm/LawFirmFileImplement/Implements/OrderStorage.cs +++ b/LawFirm/LawFirmFileImplement/Implements/OrderStorage.cs @@ -23,7 +23,7 @@ namespace LawFirmFileImplement.Implements { return new(); } - return source.Orders.Where(x => x.Id.Equals(model.Id)).Select(x => GetViewModel(x)).ToList(); + return source.Orders.Where(x => x.Id.Equals(model.Id) || model.DateFrom <= model.DateFrom && model.DateFrom <= model.DateTo).Select(x => GetViewModel(x)).ToList(); } public OrderViewModel? GetElement(OrderSearchModel model) { diff --git a/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs b/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs index 73c22d4..39a3c7a 100644 --- a/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs +++ b/LawFirm/LawFirmListImplement/Implements/OrderStorage.cs @@ -25,13 +25,13 @@ namespace LawFirmListImplement.Implements public List GetFilteredList(OrderSearchModel model) { var result = new List(); - if (!model.Id.HasValue) + if (!model.Id.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue) { return result; } foreach (var order in _source.Orders) { - if (order.Id == model.Id) + if (order.Id == model.Id || model.DateFrom <= order.DateCreate && order.DateCreate <= model.DateTo) { result.Add(GetViewModel(order)); } diff --git a/LawFirm/LawFirmView/FormMain.Designer.cs b/LawFirm/LawFirmView/FormMain.Designer.cs index b64acd9..3ea6402 100644 --- a/LawFirm/LawFirmView/FormMain.Designer.cs +++ b/LawFirm/LawFirmView/FormMain.Designer.cs @@ -32,16 +32,16 @@ this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.бланкиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.документыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.отчетыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.списокКомпонентовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.компонентыПоИзделиямToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.списокЗаказовToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.dataGridView = new System.Windows.Forms.DataGridView(); this.buttonCreateOrder = new System.Windows.Forms.Button(); this.buttonTakeOrderInWork = new System.Windows.Forms.Button(); this.buttonOrderReady = new System.Windows.Forms.Button(); this.buttonIssuedOrder = 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.menuStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.SuspendLayout(); @@ -69,17 +69,48 @@ // бланкиToolStripMenuItem // this.бланкиToolStripMenuItem.Name = "бланкиToolStripMenuItem"; - this.бланкиToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.бланкиToolStripMenuItem.Size = new System.Drawing.Size(137, 22); this.бланкиToolStripMenuItem.Text = "Бланки"; this.бланкиToolStripMenuItem.Click += new System.EventHandler(this.BlanksToolStripMenuItem_Click); // // документыToolStripMenuItem // this.документыToolStripMenuItem.Name = "документыToolStripMenuItem"; - this.документыToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.документыToolStripMenuItem.Size = new System.Drawing.Size(137, 22); this.документыToolStripMenuItem.Text = "Документы"; this.документыToolStripMenuItem.Click += new System.EventHandler(this.DocumentsToolStripMenuItem_Click); // + // отчетыToolStripMenuItem + // + this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.списокКомпонентовToolStripMenuItem, + this.компонентыПоИзделиямToolStripMenuItem, + this.списокЗаказовToolStripMenuItem}); + this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; + this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(60, 20); + this.отчетыToolStripMenuItem.Text = "Отчеты"; + // + // списокКомпонентовToolStripMenuItem + // + this.списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem"; + this.списокКомпонентовToolStripMenuItem.Size = new System.Drawing.Size(218, 22); + this.списокКомпонентовToolStripMenuItem.Text = "Список компонентов"; + this.списокКомпонентовToolStripMenuItem.Click += new System.EventHandler(this.BlanksReportToolStripMenuItem_Click); + // + // компонентыПоИзделиямToolStripMenuItem + // + this.компонентыПоИзделиямToolStripMenuItem.Name = "компонентыПоИзделиямToolStripMenuItem"; + this.компонентыПоИзделиямToolStripMenuItem.Size = new System.Drawing.Size(218, 22); + this.компонентыПоИзделиямToolStripMenuItem.Text = "Компоненты по изделиям"; + this.компонентыПоИзделиямToolStripMenuItem.Click += new System.EventHandler(this.DocumentBlanksReportToolStripMenuItem_Click); + // + // списокЗаказовToolStripMenuItem + // + this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; + this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(218, 22); + this.списокЗаказовToolStripMenuItem.Text = "Список заказов"; + this.списокЗаказовToolStripMenuItem.Click += new System.EventHandler(this.OrdersReportToolStripMenuItem_Click); + // // dataGridView // this.dataGridView.AllowUserToAddRows = false; @@ -143,34 +174,6 @@ this.buttonUpdate.UseVisualStyleBackColor = true; this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click); // - // отчетыToolStripMenuItem - // - this.отчетыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { - this.списокКомпонентовToolStripMenuItem, - this.компонентыПоИзделиямToolStripMenuItem, - this.списокЗаказовToolStripMenuItem}); - this.отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; - this.отчетыToolStripMenuItem.Size = new System.Drawing.Size(60, 20); - this.отчетыToolStripMenuItem.Text = "Отчеты"; - // - // списокКомпонентовToolStripMenuItem - // - this.списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem"; - this.списокКомпонентовToolStripMenuItem.Size = new System.Drawing.Size(218, 22); - this.списокКомпонентовToolStripMenuItem.Text = "Список компонентов"; - // - // компонентыПоИзделиямToolStripMenuItem - // - this.компонентыПоИзделиямToolStripMenuItem.Name = "компонентыПоИзделиямToolStripMenuItem"; - this.компонентыПоИзделиямToolStripMenuItem.Size = new System.Drawing.Size(218, 22); - this.компонентыПоИзделиямToolStripMenuItem.Text = "Компоненты по изделиям"; - // - // списокЗаказовToolStripMenuItem - // - this.списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; - this.списокЗаказовToolStripMenuItem.Size = new System.Drawing.Size(218, 22); - this.списокЗаказовToolStripMenuItem.Text = "Список заказов"; - // // FormMain // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -186,6 +189,7 @@ this.MainMenuStrip = this.menuStrip1; this.Name = "FormMain"; this.Text = "Юридическая фирма"; + this.Load += new System.EventHandler(this.FormMain_Load); this.menuStrip1.ResumeLayout(false); this.menuStrip1.PerformLayout(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); diff --git a/LawFirm/LawFirmView/FormMain.cs b/LawFirm/LawFirmView/FormMain.cs index 62fa289..28d703b 100644 --- a/LawFirm/LawFirmView/FormMain.cs +++ b/LawFirm/LawFirmView/FormMain.cs @@ -1,4 +1,5 @@ -using LawFirmContracts.BindingModels; +using LawFirmBusinessLogic.BusinessLogics; +using LawFirmContracts.BindingModels; using LawFirmContracts.BusinessLogicsContracts; using LawFirmDataModels.Enums; using Microsoft.Extensions.Logging; @@ -10,11 +11,14 @@ namespace LawFirmView { 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) { @@ -162,5 +166,39 @@ namespace LawFirmView form.ShowDialog(); } } + + private void BlanksReportToolStripMenuItem_Click(object sender, EventArgs +e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SaveBlanksToWordFile(new ReportBindingModel + { + FileName = dialog.FileName + }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, + MessageBoxIcon.Information); + } + } + private void DocumentBlanksReportToolStripMenuItem_Click(object sender, + EventArgs e) + { + var service = + Program.ServiceProvider?.GetService(typeof(FormReportDocumentBlanks)); + if (service is FormReportDocumentBlanks form) + { + form.ShowDialog(); + } + } + private void OrdersReportToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = + Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + if (service is FormReportOrders form) + { + form.ShowDialog(); + } + } } } diff --git a/LawFirm/LawFirmView/FormReportDocumentBlanks.Designer.cs b/LawFirm/LawFirmView/FormReportDocumentBlanks.Designer.cs index 4c068e8..8bbaa31 100644 --- a/LawFirm/LawFirmView/FormReportDocumentBlanks.Designer.cs +++ b/LawFirm/LawFirmView/FormReportDocumentBlanks.Designer.cs @@ -44,6 +44,7 @@ this.buttonSaveToExcel.TabIndex = 0; this.buttonSaveToExcel.Text = "Сохранить в Excel"; this.buttonSaveToExcel.UseVisualStyleBackColor = true; + this.buttonSaveToExcel.Click += new System.EventHandler(this.ButtonSaveToExcel_Click); // // dataGridView // @@ -62,12 +63,12 @@ // // ColumnBlank // - this.ColumnBlank.HeaderText = "Бланк"; + this.ColumnBlank.HeaderText = "Документ"; this.ColumnBlank.Name = "ColumnBlank"; // // ColumnDocument // - this.ColumnDocument.HeaderText = "Документ"; + this.ColumnDocument.HeaderText = "Бланк"; this.ColumnDocument.Name = "ColumnDocument"; // // ColumnCount diff --git a/LawFirm/LawFirmView/FormReportDocumentBlanks.cs b/LawFirm/LawFirmView/FormReportDocumentBlanks.cs index ce48ab3..cf09d42 100644 --- a/LawFirm/LawFirmView/FormReportDocumentBlanks.cs +++ b/LawFirm/LawFirmView/FormReportDocumentBlanks.cs @@ -28,8 +28,8 @@ namespace LawFirmView 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[] { elem.DocumentName, "", "" }); + foreach (var listElem in elem.Blanks) { dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 }); @@ -50,5 +50,34 @@ elem.TotalCount }); } } + + private void ButtonSaveToExcel_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog + { + Filter = "xlsx|*.xlsx" + }; + + if (dialog.ShowDialog() == DialogResult.OK) + { + try + { + _logic.SaveDocumentBlankToExcelFile(new ReportBindingModel + { + FileName = dialog.FileName + }); + + _logger.LogInformation("Saving list of computers by components"); + + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + catch (Exception ex) + { + _logger.LogError(ex, "Error saving list of computers by components"); + + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } } } diff --git a/LawFirm/LawFirmView/FormReportDocumentBlanks.resx b/LawFirm/LawFirmView/FormReportDocumentBlanks.resx index 5328be4..26da436 100644 --- a/LawFirm/LawFirmView/FormReportDocumentBlanks.resx +++ b/LawFirm/LawFirmView/FormReportDocumentBlanks.resx @@ -66,13 +66,4 @@ True - - True - - - True - - - True - \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormReportOrders.Designer.cs b/LawFirm/LawFirmView/FormReportOrders.Designer.cs index a7120bf..dd1733a 100644 --- a/LawFirm/LawFirmView/FormReportOrders.Designer.cs +++ b/LawFirm/LawFirmView/FormReportOrders.Designer.cs @@ -1,4 +1,4 @@ -namespace TravelCompanyView +namespace LawFirmView { partial class FormReportOrders { @@ -28,103 +28,104 @@ /// private void InitializeComponent() { - labelFrom = new Label(); - dateTimePickerFrom = new DateTimePicker(); - labelTo = new Label(); - dateTimePickerTo = new DateTimePicker(); - buttonMake = new Button(); - buttonToPDF = new Button(); - panel = new Panel(); - panel.SuspendLayout(); - SuspendLayout(); - // - // labelFrom - // - labelFrom.AutoSize = true; - labelFrom.Location = new Point(11, 16); - labelFrom.Name = "labelFrom"; - labelFrom.Size = new Size(23, 25); - labelFrom.TabIndex = 0; - labelFrom.Text = "С"; - // - // dateTimePickerFrom - // - dateTimePickerFrom.Location = new Point(40, 11); - dateTimePickerFrom.Name = "dateTimePickerFrom"; - dateTimePickerFrom.Size = new Size(224, 31); - dateTimePickerFrom.TabIndex = 1; - // - // labelTo - // - labelTo.AutoSize = true; - labelTo.Location = new Point(270, 16); - labelTo.Name = "labelTo"; - labelTo.Size = new Size(33, 25); - labelTo.TabIndex = 2; - labelTo.Text = "по"; - // - // dateTimePickerTo - // - dateTimePickerTo.Location = new Point(309, 11); - dateTimePickerTo.Name = "dateTimePickerTo"; - dateTimePickerTo.Size = new Size(224, 31); - dateTimePickerTo.TabIndex = 3; + this.buttonMake = new System.Windows.Forms.Button(); + this.buttonToPdf = new System.Windows.Forms.Button(); + this.dateTimePickerFrom = new System.Windows.Forms.DateTimePicker(); + this.dateTimePickerTo = new System.Windows.Forms.DateTimePicker(); + this.label1 = new System.Windows.Forms.Label(); + this.label2 = new System.Windows.Forms.Label(); + this.panel = new System.Windows.Forms.Panel(); + this.panel.SuspendLayout(); + this.SuspendLayout(); // // buttonMake // - buttonMake.Location = new Point(613, 11); - buttonMake.Name = "buttonMake"; - buttonMake.Size = new Size(170, 34); - buttonMake.TabIndex = 4; - buttonMake.Text = "Сформировать"; - buttonMake.UseVisualStyleBackColor = true; - buttonMake.Click += ButtonMake_Click; + this.buttonMake.Location = new System.Drawing.Point(354, 3); + this.buttonMake.Name = "buttonMake"; + this.buttonMake.Size = new System.Drawing.Size(127, 23); + this.buttonMake.TabIndex = 0; + this.buttonMake.Text = "Сформировать"; + this.buttonMake.UseVisualStyleBackColor = true; + this.buttonMake.Click += new System.EventHandler(this.ButtonMake_Click); // - // buttonToPDF + // buttonToPdf // - buttonToPDF.Location = new Point(1061, 11); - buttonToPDF.Name = "buttonToPDF"; - buttonToPDF.Size = new Size(170, 34); - buttonToPDF.TabIndex = 5; - buttonToPDF.Text = "В PDF"; - buttonToPDF.UseVisualStyleBackColor = true; - buttonToPDF.Click += ButtonToPdf_Click; + this.buttonToPdf.Location = new System.Drawing.Point(487, 5); + this.buttonToPdf.Name = "buttonToPdf"; + this.buttonToPdf.Size = new System.Drawing.Size(75, 22); + this.buttonToPdf.TabIndex = 1; + this.buttonToPdf.Text = "В PDF"; + this.buttonToPdf.UseVisualStyleBackColor = true; + this.buttonToPdf.Click += new System.EventHandler(this.ButtonToPdf_Click); + // + // dateTimePickerFrom + // + this.dateTimePickerFrom.Location = new System.Drawing.Point(28, 3); + this.dateTimePickerFrom.Name = "dateTimePickerFrom"; + this.dateTimePickerFrom.Size = new System.Drawing.Size(144, 23); + this.dateTimePickerFrom.TabIndex = 2; + // + // dateTimePickerTo + // + this.dateTimePickerTo.Location = new System.Drawing.Point(204, 3); + this.dateTimePickerTo.Name = "dateTimePickerTo"; + this.dateTimePickerTo.Size = new System.Drawing.Size(144, 23); + this.dateTimePickerTo.TabIndex = 3; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(3, 9); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(15, 15); + this.label1.TabIndex = 4; + this.label1.Text = "С"; + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(178, 9); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(21, 15); + this.label2.TabIndex = 5; + this.label2.Text = "по"; // // panel // - panel.Controls.Add(buttonToPDF); - panel.Controls.Add(dateTimePickerTo); - panel.Controls.Add(buttonMake); - panel.Controls.Add(labelTo); - panel.Controls.Add(dateTimePickerFrom); - panel.Controls.Add(labelFrom); - panel.Dock = DockStyle.Top; - panel.Location = new Point(0, 0); - panel.Name = "panel"; - panel.Size = new Size(1244, 56); - panel.TabIndex = 6; + this.panel.Controls.Add(this.dateTimePickerFrom); + this.panel.Controls.Add(this.buttonToPdf); + this.panel.Controls.Add(this.label1); + this.panel.Controls.Add(this.buttonMake); + this.panel.Controls.Add(this.label2); + this.panel.Controls.Add(this.dateTimePickerTo); + this.panel.Location = new System.Drawing.Point(0, 0); + this.panel.Name = "panel"; + this.panel.Size = new System.Drawing.Size(893, 32); + this.panel.TabIndex = 6; // // FormReportOrders // - AutoScaleDimensions = new SizeF(10F, 25F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1244, 450); - Controls.Add(panel); - Name = "FormReportOrders"; - Text = "Заказы"; - panel.ResumeLayout(false); - panel.PerformLayout(); - ResumeLayout(false); + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(892, 325); + this.Controls.Add(this.panel); + this.Name = "FormReportOrders"; + this.Text = "FormReportOrders"; + this.Load += new System.EventHandler(this.FormReportOrders_Load); + this.panel.ResumeLayout(false); + this.panel.PerformLayout(); + this.ResumeLayout(false); + } #endregion - private Label labelFrom; - private DateTimePicker dateTimePickerFrom; - private Label labelTo; - private DateTimePicker dateTimePickerTo; private Button buttonMake; - private Button buttonToPDF; + private Button buttonToPdf; + private DateTimePicker dateTimePickerFrom; + private DateTimePicker dateTimePickerTo; + private Label label1; + private Label label2; private Panel panel; } } \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormReportOrders.cs b/LawFirm/LawFirmView/FormReportOrders.cs index c659068..8bca39f 100644 --- a/LawFirm/LawFirmView/FormReportOrders.cs +++ b/LawFirm/LawFirmView/FormReportOrders.cs @@ -1,18 +1,16 @@ -using Microsoft.Extensions.Logging; -using Microsoft.Reporting.WinForms; -using LawFirmContracts.BindingModels; +using LawFirmContracts.BindingModels; using LawFirmContracts.BusinessLogicsContracts; +using Microsoft.Extensions.Logging; +using Microsoft.Reporting.WinForms; +using System.Windows.Forms; -namespace TravelCompanyView +namespace LawFirmView { public partial class FormReportOrders : Form { private readonly ReportViewer reportViewer; - private readonly ILogger _logger; - private readonly IReportLogic _logic; - public FormReportOrders(ILogger logger, IReportLogic logic) { InitializeComponent(); @@ -20,53 +18,67 @@ namespace TravelCompanyView _logic = logic; reportViewer = new ReportViewer { - Dock = DockStyle.Fill + Dock = DockStyle.Bottom }; - reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportOrders.rdlc", FileMode.Open)); + try + { + reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportOrders.rdlc", FileMode.Open)); + }catch(Exception ex){} + Controls.Clear(); Controls.Add(reportViewer); Controls.Add(panel); } + private void FormReportOrders_Load(object sender, EventArgs e) + { + + } private void ButtonMake_Click(object sender, EventArgs e) { if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date) { - MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Дата начала должна быть меньше даты окончания", + "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { var dataSource = _logic.GetOrders(new ReportBindingModel { - DateFrom = dateTimePickerFrom.Value, - DateTo = dateTimePickerTo.Value + DateFrom = DateTime.SpecifyKind(dateTimePickerFrom.Value, DateTimeKind.Utc), + DateTo = DateTime.SpecifyKind(dateTimePickerTo.Value, DateTimeKind.Utc) }); 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); - + 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()); + _logger.LogInformation("Загрузка списка заказов на период {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(), + dateTimePickerTo.Value.ToShortDateString()); } catch (Exception ex) { _logger.LogError(ex, "Ошибка загрузки списка заказов на период"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); } } - private void ButtonToPdf_Click(object sender, EventArgs e) { + System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance); if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date) { - MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show("Дата начала должна быть меньше даты окончания", + "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } - using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" }; + using var dialog = new SaveFileDialog + { + Filter = "pdf|*.pdf" + }; if (dialog.ShowDialog() == DialogResult.OK) { try @@ -74,16 +86,20 @@ namespace TravelCompanyView _logic.SaveOrdersToPdfFile(new ReportBindingModel { FileName = dialog.FileName, - DateFrom = dateTimePickerFrom.Value, - DateTo = dateTimePickerTo.Value + DateFrom = DateTime.SpecifyKind(dateTimePickerFrom.Value, DateTimeKind.Utc), + DateTo = DateTime.SpecifyKind(dateTimePickerTo.Value, DateTimeKind.Utc) }); - _logger.LogInformation("Сохранение списка заказов на период {From}-{To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString()); - MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + _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); + + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); } } } diff --git a/LawFirm/LawFirmView/Program.cs b/LawFirm/LawFirmView/Program.cs index c535b91..b24e404 100644 --- a/LawFirm/LawFirmView/Program.cs +++ b/LawFirm/LawFirmView/Program.cs @@ -1,4 +1,6 @@ using LawFirmBusinessLogic.BusinessLogics; +using LawFirmBusinessLogic.OfficePackage.Implements; +using LawFirmBusinessLogic.OfficePackage; using LawFirmContracts.BusinessLogicsContracts; using LawFirmContracts.StoragesContracts; using LawFirmDatabaseImplement.Implements; @@ -40,6 +42,11 @@ namespace LawFirmView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/LawFirm/LawFirmView/ReportOrders.rdlc b/LawFirm/LawFirmView/ReportOrders.rdlc index f85c747..3d5e2af 100644 --- a/LawFirm/LawFirmView/ReportOrders.rdlc +++ b/LawFirm/LawFirmView/ReportOrders.rdlc @@ -1,76 +1,599 @@ - + - 0 - - - - - - true - true - - - - - - + + + + + + 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!DocumentName.Value + + + 2pt + 2pt + 2pt + 2pt + + + + + + + + true + true + + + + + =Fields!OrderStatus.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 + 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 - - 2pt - 2pt - 2pt - 2pt - - - - 2in -