diff --git a/SoftwareInstallation/SoftWareInstallationFileImplement/OrderStorage.cs b/SoftwareInstallation/SoftWareInstallationFileImplement/OrderStorage.cs index ffcd255..e1383fa 100644 --- a/SoftwareInstallation/SoftWareInstallationFileImplement/OrderStorage.cs +++ b/SoftwareInstallation/SoftWareInstallationFileImplement/OrderStorage.cs @@ -34,6 +34,13 @@ namespace SoftwareInstallationFileImplement.Implements } public List GetFilteredList(OrderSearchModel model) { + if (!model.Id.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue) // если не ищем по айдишнику, значит ищем по диапазону дат + { + return _source.Orders + .Where(x => model.DateFrom <= x.DateCreate.Date && x.DateCreate <= model.DateTo) + .Select(x => x.GetViewModel) + .ToList(); + } var result = GetElement(model); return result != null ? new() { result } : new(); } diff --git a/SoftwareInstallation/SoftwareInstallationBusinessLogic/BusinessLogic/ReportLogic.cs b/SoftwareInstallation/SoftwareInstallationBusinessLogic/BusinessLogic/ReportLogic.cs index d32adf3..1cfdab3 100644 --- a/SoftwareInstallation/SoftwareInstallationBusinessLogic/BusinessLogic/ReportLogic.cs +++ b/SoftwareInstallation/SoftwareInstallationBusinessLogic/BusinessLogic/ReportLogic.cs @@ -31,25 +31,16 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogics /// public List GetPackageComponent() { - var components = _componentStorage.GetFullList(); var packages = _packageStorage.GetFullList(); var list = new List(); - foreach (var component in components) + foreach (var package in packages) { var record = new ReportPackageComponentViewModel { - ComponentName = component.ComponentName, - Packages = new List>(), - TotalCount = 0 + PackageName = package.PackageName, + Components = package.PackageComponents.Values.Select(x => Tuple.Create(x.Item1.ComponentName, x.Item2)).ToList(), + TotalCount = package.PackageComponents.Values.Select(x => x.Item2).Sum(), }; - foreach (var package in packages) - { - if (package.PackageComponents.ContainsKey(component.Id)) - { - record.Packages.Add(new Tuple(package.PackageName, package.PackageComponents[component.Id].Item2)); - record.TotalCount += package.PackageComponents[component.Id].Item2; - } - } list.Add(record); } return list; @@ -65,12 +56,14 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogics { DateFrom = model.DateFrom, DateTo = model.DateTo + }) .Select(x => new ReportOrdersViewModel { Id = x.Id, DateCreate = x.DateCreate, PackageName = x.PackageName, + OrderStatus = x.Status.ToString(), Sum = x.Sum }) .ToList(); @@ -85,7 +78,7 @@ namespace SoftwareInstallationBusinessLogic.BusinessLogics { FileName = model.FileName, Title = "Список компонент", - Components = _componentStorage.GetFullList() + Packages = _packageStorage.GetFullList() }); } /// diff --git a/SoftwareInstallation/SoftwareInstallationBusinessLogic/OfficePackage/AbstractSaveToExcel.cs b/SoftwareInstallation/SoftwareInstallationBusinessLogic/OfficePackage/AbstractSaveToExcel.cs index 4bdeee8..90be74a 100644 --- a/SoftwareInstallation/SoftwareInstallationBusinessLogic/OfficePackage/AbstractSaveToExcel.cs +++ b/SoftwareInstallation/SoftwareInstallationBusinessLogic/OfficePackage/AbstractSaveToExcel.cs @@ -31,11 +31,11 @@ namespace SoftwareInstallationBusinessLogic.OfficePackage { ColumnName = "A", RowIndex = rowIndex, - Text = pc.ComponentName, + Text = pc.PackageName, StyleInfo = ExcelStyleInfoType.Text }); rowIndex++; - foreach (var package in pc.Packages) + foreach (var package in pc.Components) { InsertCellInWorksheet(new ExcelCellParameters { diff --git a/SoftwareInstallation/SoftwareInstallationBusinessLogic/OfficePackage/AbstractSaveToPdf.cs b/SoftwareInstallation/SoftwareInstallationBusinessLogic/OfficePackage/AbstractSaveToPdf.cs index e76bc9b..3cc948f 100644 --- a/SoftwareInstallation/SoftwareInstallationBusinessLogic/OfficePackage/AbstractSaveToPdf.cs +++ b/SoftwareInstallation/SoftwareInstallationBusinessLogic/OfficePackage/AbstractSaveToPdf.cs @@ -21,10 +21,10 @@ namespace SoftwareInstallationBusinessLogic.OfficePackage Text = $"с{ info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Center }); - CreateTable(new List { "2cm", "3cm", "6cm", "3cm" }); + CreateTable(new List { "2cm", "3cm", "6cm", "4cm", "3cm" }); CreateRow(new PdfRowParameters { - Texts = new List { "Номер", "Дата заказа", "Изделие","Сумма" }, + Texts = new List { "Номер", "Дата заказа", "Изделие", "Статус заказа", "Сумма" }, Style = "NormalTitle", ParagraphAlignment = PdfParagraphAlignmentType.Center }); @@ -32,7 +32,7 @@ namespace SoftwareInstallationBusinessLogic.OfficePackage { CreateRow(new PdfRowParameters { - Texts = new List { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.PackageName, order.Sum.ToString() }, + Texts = new List { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.PackageName, Convert.ToString(order.OrderStatus), order.Sum.ToString() }, Style = "Normal", ParagraphAlignment = PdfParagraphAlignmentType.Left }); diff --git a/SoftwareInstallation/SoftwareInstallationBusinessLogic/OfficePackage/AbstractSaveToWord.cs b/SoftwareInstallation/SoftwareInstallationBusinessLogic/OfficePackage/AbstractSaveToWord.cs index 4a49c3f..69b901d 100644 --- a/SoftwareInstallation/SoftwareInstallationBusinessLogic/OfficePackage/AbstractSaveToWord.cs +++ b/SoftwareInstallation/SoftwareInstallationBusinessLogic/OfficePackage/AbstractSaveToWord.cs @@ -1,6 +1,5 @@ using SoftwareInstallationBusinessLogic.OfficePackage.HelperEnums; using SoftwareInstallationBusinessLogic.OfficePackage.HelperModels; -using System.Collections.Generic; namespace SoftwareInstallationBusinessLogic.OfficePackage { @@ -11,20 +10,22 @@ namespace SoftwareInstallationBusinessLogic.OfficePackage CreateWord(info); CreateParagraph(new WordParagraph { - Texts = new List<(string, WordTextProperties)> { (info.Title, new -WordTextProperties { Bold = true, Size = "24", }) }, + Texts = new List<(string, WordTextProperties)> { (info.Title, new WordTextProperties { Bold = true, Size = "24", }) }, TextProperties = new WordTextProperties { Size = "24", JustificationType = WordJustificationType.Center } }); - foreach (var component in info.Components) + foreach (var package in info.Packages) { CreateParagraph(new WordParagraph { - Texts = new List<(string, WordTextProperties)> { -(component.ComponentName, new WordTextProperties { Size = "24", }) }, + Texts = new List<(string, WordTextProperties)> + { + (package.PackageName, new WordTextProperties { Size = "24", Bold = true}), + (" - цена: " + package.Price.ToString(), new WordTextProperties { Size = "24" }) + }, TextProperties = new WordTextProperties { Size = "24", diff --git a/SoftwareInstallation/SoftwareInstallationBusinessLogic/OfficePackage/HelperModels/WordInfo.cs b/SoftwareInstallation/SoftwareInstallationBusinessLogic/OfficePackage/HelperModels/WordInfo.cs index 9be31cc..3bc53d6 100644 --- a/SoftwareInstallation/SoftwareInstallationBusinessLogic/OfficePackage/HelperModels/WordInfo.cs +++ b/SoftwareInstallation/SoftwareInstallationBusinessLogic/OfficePackage/HelperModels/WordInfo.cs @@ -6,6 +6,6 @@ namespace SoftwareInstallationBusinessLogic.OfficePackage.HelperModels { public string FileName { get; set; } = string.Empty; public string Title { get; set; } = string.Empty; - public List Components { get; set; } = new(); + public List Packages { get; set; } = new(); } } \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationContracts/ViewModels/ReportPackageComponentViewModel.cs b/SoftwareInstallation/SoftwareInstallationContracts/ViewModels/ReportPackageComponentViewModel.cs index 238a3a8..8e658b1 100644 --- a/SoftwareInstallation/SoftwareInstallationContracts/ViewModels/ReportPackageComponentViewModel.cs +++ b/SoftwareInstallation/SoftwareInstallationContracts/ViewModels/ReportPackageComponentViewModel.cs @@ -2,8 +2,8 @@ { public class ReportPackageComponentViewModel { - public string ComponentName { get; set; } = string.Empty; + public string PackageName { get; set; } = string.Empty; public int TotalCount { get; set; } - public List> Packages { get; set; } = new(); + public List> Components { get; set; } = new(); } } \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationDatabaseImplement/OrderStorage.cs b/SoftwareInstallation/SoftwareInstallationDatabaseImplement/OrderStorage.cs index 591305a..8fdfe84 100644 --- a/SoftwareInstallation/SoftwareInstallationDatabaseImplement/OrderStorage.cs +++ b/SoftwareInstallation/SoftwareInstallationDatabaseImplement/OrderStorage.cs @@ -36,6 +36,15 @@ namespace SoftwareInstallationDatabaseImplement.Implements public List GetFilteredList(OrderSearchModel model) { + if (!model.Id.HasValue && model.DateFrom.HasValue && model.DateTo.HasValue) // если не ищем по айдишнику, значит ищем по диапазону дат + { + using var context = new SoftwareInstallationDatabase(); + return context.Orders + .Include(x => x.Package) + .Where(x => model.DateFrom <= x.DateCreate.Date && x.DateCreate <= model.DateTo) + .Select(x => x.GetViewModel) + .ToList(); + } var result = GetElement(model); return result != null ? new() { result } : new(); } diff --git a/SoftwareInstallation/SoftwareInstallationListImplement/OrderStorage.cs b/SoftwareInstallation/SoftwareInstallationListImplement/OrderStorage.cs index 85f1ea4..58041aa 100644 --- a/SoftwareInstallation/SoftwareInstallationListImplement/OrderStorage.cs +++ b/SoftwareInstallation/SoftwareInstallationListImplement/OrderStorage.cs @@ -54,6 +54,10 @@ namespace SoftwareInstallationListImplement.Implements { return new() { order.GetViewModel }; } + if(model.DateFrom != null && model.DateTo != null && model.DateFrom <= order.DateCreate.Date && order.DateCreate <= model.DateTo) + { + result.Add(order.GetViewModel); + } } return result; } diff --git a/SoftwareInstallation/SoftwareInstallationView/FormMain.cs b/SoftwareInstallation/SoftwareInstallationView/FormMain.cs index 1c44234..c115f8a 100644 --- a/SoftwareInstallation/SoftwareInstallationView/FormMain.cs +++ b/SoftwareInstallation/SoftwareInstallationView/FormMain.cs @@ -10,11 +10,12 @@ namespace SoftwareInstallationView private readonly ILogger _logger; private readonly IOrderLogic _orderLogic; private readonly IReportLogic _reportLogic; - public FormMain(ILogger logger, IOrderLogic orderLogic) + public FormMain(ILogger logger, IOrderLogic orderLogic, IReportLogic reportLogic) { InitializeComponent(); _logger = logger; _orderLogic = orderLogic; + _reportLogic = reportLogic; } private void FormMain_Load(object sender, EventArgs e) { diff --git a/SoftwareInstallation/SoftwareInstallationView/FormReportOrders.cs b/SoftwareInstallation/SoftwareInstallationView/FormReportOrders.cs index dabfd66..57e4fed 100644 --- a/SoftwareInstallation/SoftwareInstallationView/FormReportOrders.cs +++ b/SoftwareInstallation/SoftwareInstallationView/FormReportOrders.cs @@ -45,8 +45,7 @@ namespace SoftwareInstallationView 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()}") }; + var parameters = new[] { new ReportParameter("ReportParameterPeriod",$"c {dateTimePickerFrom.Value.ToShortDateString()} по {dateTimePickerTo.Value.ToShortDateString()}") }; reportViewer.LocalReport.SetParameters(parameters); reportViewer.RefreshReport(); diff --git a/SoftwareInstallation/SoftwareInstallationView/FormReportPackageComponents.cs b/SoftwareInstallation/SoftwareInstallationView/FormReportPackageComponents.cs index 291e93c..2bef1ad 100644 --- a/SoftwareInstallation/SoftwareInstallationView/FormReportPackageComponents.cs +++ b/SoftwareInstallation/SoftwareInstallationView/FormReportPackageComponents.cs @@ -23,8 +23,8 @@ namespace SoftwareInstallationView dataGridView.Rows.Clear(); foreach (var elem in dict) { - dataGridView.Rows.Add(new object[] { elem.ComponentName,"", "" }); - foreach (var listElem in elem.Packages) + dataGridView.Rows.Add(new object[] { elem.PackageName,"", "" }); + foreach (var listElem in elem.Components) { dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 }); } diff --git a/SoftwareInstallation/SoftwareInstallationView/Program.cs b/SoftwareInstallation/SoftwareInstallationView/Program.cs index 6b75d5d..6c779b9 100644 --- a/SoftwareInstallation/SoftwareInstallationView/Program.cs +++ b/SoftwareInstallation/SoftwareInstallationView/Program.cs @@ -5,6 +5,9 @@ using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; using NLog.Extensions.Logging; using SoftwareInstallationBusinessLogic.BusinessLogic; +using SoftwareInstallationBusinessLogic.BusinessLogics; +using SoftwareInstallationBusinessLogic.OfficePackage.Implements; +using SoftwareInstallationBusinessLogic.OfficePackage; namespace SoftwareInstallationView { @@ -40,6 +43,11 @@ namespace SoftwareInstallationView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -48,6 +56,9 @@ namespace SoftwareInstallationView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + } } } \ No newline at end of file diff --git a/SoftwareInstallation/SoftwareInstallationView/ReportOrders.rdlc b/SoftwareInstallation/SoftwareInstallationView/ReportOrders.rdlc index f79c8a5..996f31d 100644 --- a/SoftwareInstallation/SoftwareInstallationView/ReportOrders.rdlc +++ b/SoftwareInstallation/SoftwareInstallationView/ReportOrders.rdlc @@ -424,7 +424,6 @@ 2pt - true @@ -484,7 +483,7 @@ 2.48391cm 0.55245cm 1.2cm - 19.84713cm + 19.84714cm 2