diff --git a/AircraftPlant/AircraftPlantBusinessLogic/BusinessLogics/ReportLogic.cs b/AircraftPlant/AircraftPlantBusinessLogic/BusinessLogics/ReportLogic.cs index 12294d1..52ea7b6 100644 --- a/AircraftPlant/AircraftPlantBusinessLogic/BusinessLogics/ReportLogic.cs +++ b/AircraftPlant/AircraftPlantBusinessLogic/BusinessLogics/ReportLogic.cs @@ -68,7 +68,7 @@ namespace AircraftPlantBusinessLogic.BusinessLogics DateCreate = x.DateCreate, PlaneName = x.PlaneName, OrderStatus = x.Status.ToString(), - Sum = x.Sum + Sum = x.Sum, }) .ToList(); } @@ -76,7 +76,7 @@ namespace AircraftPlantBusinessLogic.BusinessLogics /// Сохранение компонент в файл-Word /// /// - public void SaveComponentsToWordFile(ReportBindingModel model) + public void SavePlanesToWordFile(ReportBindingModel model) { _saveToWord.CreateDoc(new WordInfo { diff --git a/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/AbstractSaveToPdf.cs b/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/AbstractSaveToPdf.cs index 2022235..5d3f6fd 100644 --- a/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/AbstractSaveToPdf.cs +++ b/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/AbstractSaveToPdf.cs @@ -25,7 +25,7 @@ namespace AircraftPlantBusinessLogic.OfficePackage CreateRow(new PdfRowParameters { - Texts = new List { "Номер", "Дата заказа", "Мороженое", "Статус", "Сумма" }, + Texts = new List { "Номер", "Дата заказа", "Самолёт", "Сумма", "Статус" }, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); @@ -35,7 +35,7 @@ namespace AircraftPlantBusinessLogic.OfficePackage CreateRow(new PdfRowParameters { Texts = new List { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.PlaneName, - order.OrderStatus, order.Sum.ToString() }, + order.Sum.ToString(), order.OrderStatus}, Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Left }); diff --git a/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/AbstractSaveToWord.cs index baaa7c2..79ed90c 100644 --- a/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -22,11 +22,13 @@ namespace AircraftPlantBusinessLogic.OfficePackage JustificationType = WordJustificationType.Center } }); - foreach (var plane in info.Planes) + foreach (var component in info.Planes) { CreateParagraph(new WordParagraph { - Texts = new List<(string, WordTextProperties)> { (plane.PlaneName, new WordTextProperties { Size = "24", }) }, + Texts = new List<(string, WordTextProperties)> { (component.PlaneName, new WordTextProperties { Size = "24", Bold = true }), + (" стоит " + component.Price.ToString() + " рублей", new WordTextProperties { Size = "24"}) + }, TextProperties = new WordTextProperties { Size = "24", diff --git a/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/Implements/SaveToWord .cs b/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/Implements/SaveToWord .cs index 5c93cb0..e02093f 100644 --- a/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/Implements/SaveToWord .cs +++ b/AircraftPlant/AircraftPlantBusinessLogic/OfficePackage/Implements/SaveToWord .cs @@ -6,10 +6,8 @@ using DocumentFormat.OpenXml.Wordprocessing; using System; using System.Collections.Generic; using System.Linq; -using System.Reflection.Metadata; using System.Text; using System.Threading.Tasks; -using static System.Net.Mime.MediaTypeNames; namespace AircraftPlantBusinessLogic.OfficePackage.Implements { @@ -113,7 +111,7 @@ namespace AircraftPlantBusinessLogic.OfficePackage.Implements } _docBody.AppendChild(CreateSectionProperties()); _wordDocument.MainDocumentPart!.Document.Save(); - _wordDocument.Close(); + _wordDocument.Dispose(); } } } \ No newline at end of file diff --git a/AircraftPlant/AircraftPlantContracts»/BusinessLogicsContracts/IReportLogic.cs b/AircraftPlant/AircraftPlantContracts»/BusinessLogicsContracts/IReportLogic.cs index 64d7685..a2c0a3a 100644 --- a/AircraftPlant/AircraftPlantContracts»/BusinessLogicsContracts/IReportLogic.cs +++ b/AircraftPlant/AircraftPlantContracts»/BusinessLogicsContracts/IReportLogic.cs @@ -25,7 +25,7 @@ namespace AircraftPlantContracts.BusinessLogicsContracts /// Сохранение компонент в файл-Word /// /// - void SaveComponentsToWordFile(ReportBindingModel model); + void SavePlanesToWordFile(ReportBindingModel model); /// /// Сохранение компонент с указаеним продуктов в файл-Excel /// diff --git a/AircraftPlant/AircraftPlantContracts»/ViewModels/ReportOrdersViewModel.cs b/AircraftPlant/AircraftPlantContracts»/ViewModels/ReportOrdersViewModel.cs index 4cdd4f8..05db6d7 100644 --- a/AircraftPlant/AircraftPlantContracts»/ViewModels/ReportOrdersViewModel.cs +++ b/AircraftPlant/AircraftPlantContracts»/ViewModels/ReportOrdersViewModel.cs @@ -11,7 +11,7 @@ namespace AircraftPlantContracts.ViewModels public int Id { get; set; } public DateTime DateCreate { get; set; } public string PlaneName { get; set; } = string.Empty; - public string OrderStatus { get; set; } = string.Empty; public double Sum { get; set; } + public string OrderStatus { get; set; } = string.Empty; } } diff --git a/AircraftPlant/AircraftPlantDatabaseImplement/Implements/OrderStorage.cs b/AircraftPlant/AircraftPlantDatabaseImplement/Implements/OrderStorage.cs index cad61b5..9cfb628 100644 --- a/AircraftPlant/AircraftPlantDatabaseImplement/Implements/OrderStorage.cs +++ b/AircraftPlant/AircraftPlantDatabaseImplement/Implements/OrderStorage.cs @@ -20,11 +20,19 @@ namespace AircraftPlantDatabaseImplement.Implements public List GetFilteredList(OrderSearchModel model) { - if (!model.Id.HasValue) + if (!model.Id.HasValue && !model.DateFrom.HasValue) { return new(); } using var context = new AircraftPlantDatabase(); + if (model.DateFrom.HasValue) + { + return context.Orders + .Include(x => x.Plane) + .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo) + .Select(x => x.GetViewModel) + .ToList(); + } return context.Orders .Include(x => x.Plane) .Where(x => x.Id == model.Id) diff --git a/AircraftPlant/AircraftPlantView/FormMain.Designer.cs b/AircraftPlant/AircraftPlantView/FormMain.Designer.cs index dcbef40..6c0ef74 100644 --- a/AircraftPlant/AircraftPlantView/FormMain.Designer.cs +++ b/AircraftPlant/AircraftPlantView/FormMain.Designer.cs @@ -163,20 +163,23 @@ // списокКомпонентовToolStripMenuItem // списокКомпонентовToolStripMenuItem.Name = "списокКомпонентовToolStripMenuItem"; - списокКомпонентовToolStripMenuItem.Size = new Size(276, 26); - списокКомпонентовToolStripMenuItem.Text = "Список компонентов"; + списокКомпонентовToolStripMenuItem.Size = new Size(284, 26); + списокКомпонентовToolStripMenuItem.Text = "Список самолётов"; + списокКомпонентовToolStripMenuItem.Click += СписокСамолётовToolStripMenuItem_Click; // // компонентыПоИзделиямToolStripMenuItem // компонентыПоИзделиямToolStripMenuItem.Name = "компонентыПоИзделиямToolStripMenuItem"; - компонентыПоИзделиямToolStripMenuItem.Size = new Size(276, 26); - компонентыПоИзделиямToolStripMenuItem.Text = "Компоненты по изделиям"; + компонентыПоИзделиямToolStripMenuItem.Size = new Size(284, 26); + компонентыПоИзделиямToolStripMenuItem.Text = "Компоненты по самолётам"; + компонентыПоИзделиямToolStripMenuItem.Click += КомпонентыПоСамолётамToolStripMenuItem_Click; // // списокЗаказовToolStripMenuItem // списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; - списокЗаказовToolStripMenuItem.Size = new Size(276, 26); + списокЗаказовToolStripMenuItem.Size = new Size(284, 26); списокЗаказовToolStripMenuItem.Text = "Список заказов"; + списокЗаказовToolStripMenuItem.Click += СписокЗаказовToolStripMenuItem_Click; // // FormMain // diff --git a/AircraftPlant/AircraftPlantView/FormMain.cs b/AircraftPlant/AircraftPlantView/FormMain.cs index 3670437..1f0d511 100644 --- a/AircraftPlant/AircraftPlantView/FormMain.cs +++ b/AircraftPlant/AircraftPlantView/FormMain.cs @@ -32,11 +32,14 @@ namespace AircraftPlantView /// /// /// - public FormMain(ILogger logger, IOrderLogic logic) + private readonly IReportLogic _reportLogic; + + public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic) { InitializeComponent(); _logger = logger; - _orderLogic = logic; + _orderLogic = orderLogic; + _reportLogic = reportLogic; } /// /// Загрузка списка заказов @@ -202,5 +205,33 @@ namespace AircraftPlantView MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } } + private void СписокСамолётовToolStripMenuItem_Click(object sender, EventArgs e) + { + using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; + if (dialog.ShowDialog() == DialogResult.OK) + { + _reportLogic.SavePlanesToWordFile(new ReportBindingModel { FileName = dialog.FileName }); + MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); + } + } + + private void КомпонентыПоСамолётамToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportPlaneComponents)); + if (service is FormReportPlaneComponents form) + { + form.ShowDialog(); + } + } + + private void СписокЗаказовToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); + if (service is FormReportOrders form) + { + form.ShowDialog(); + } + } + } } diff --git a/AircraftPlant/AircraftPlantView/FormReportOrders .rdlc b/AircraftPlant/AircraftPlantView/FormReportOrders .rdlc deleted file mode 100644 index 529692c..0000000 --- a/AircraftPlant/AircraftPlantView/FormReportOrders .rdlc +++ /dev/null @@ -1,50 +0,0 @@ - - - - - - true - true - - - - - - - - 2pt - 2pt - 2pt - 2pt - - - - 4.16379in - + + + + + + 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!PlaneName.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 +