diff --git a/ComputersShop/ComputersShopBusinessLogic/BusinessLogics/ReportLogic.cs b/ComputersShop/ComputersShopBusinessLogic/BusinessLogics/ReportLogic.cs index 17532d4..3522afa 100644 --- a/ComputersShop/ComputersShopBusinessLogic/BusinessLogics/ReportLogic.cs +++ b/ComputersShop/ComputersShopBusinessLogic/BusinessLogics/ReportLogic.cs @@ -102,8 +102,8 @@ namespace ComputersShopBusinessLogic.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/ComputersShop/ComputersShopDataBaseImplement/Implements/OrderStorage.cs b/ComputersShop/ComputersShopDataBaseImplement/Implements/OrderStorage.cs index 627e1ad..d9e6c2f 100644 --- a/ComputersShop/ComputersShopDataBaseImplement/Implements/OrderStorage.cs +++ b/ComputersShop/ComputersShopDataBaseImplement/Implements/OrderStorage.cs @@ -45,14 +45,14 @@ namespace ComputersShopDataBaseImplement.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 ComputersShopDataBase(); - 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/ComputersShop/ComputersShopFileImplement/Implements/OrderStorage.cs b/ComputersShop/ComputersShopFileImplement/Implements/OrderStorage.cs index b9ad9eb..1c6bc95 100644 --- a/ComputersShop/ComputersShopFileImplement/Implements/OrderStorage.cs +++ b/ComputersShop/ComputersShopFileImplement/Implements/OrderStorage.cs @@ -31,11 +31,11 @@ namespace ComputersShopFileImplement.Implements public List GetFilteredList(OrderSearchModel model) { - if (!model.Id.HasValue) + if (!model.Id.HasValue && !model.DateFrom.HasValue && !model.DateTo.HasValue) { return new(); } - return source.Orders.Where(x => x.Id == model.Id).Select(x => GetViewModel(x)).ToList(); + return source.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/ComputersShop/ComputersShopListImplement/Implements/OrderStorage.cs b/ComputersShop/ComputersShopListImplement/Implements/OrderStorage.cs index 04a23aa..694d107 100644 --- a/ComputersShop/ComputersShopListImplement/Implements/OrderStorage.cs +++ b/ComputersShop/ComputersShopListImplement/Implements/OrderStorage.cs @@ -37,7 +37,7 @@ namespace OrdersShopListImplement.Implements } 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/ComputersShop/ComputersShopView/ComputersShopView.csproj b/ComputersShop/ComputersShopView/ComputersShopView.csproj index 4fb8431..f192a2d 100644 --- a/ComputersShop/ComputersShopView/ComputersShopView.csproj +++ b/ComputersShop/ComputersShopView/ComputersShopView.csproj @@ -18,6 +18,7 @@ + diff --git a/ComputersShop/ComputersShopView/FormReportOrders.cs b/ComputersShop/ComputersShopView/FormReportOrders.cs index cf64245..ea3911d 100644 --- a/ComputersShop/ComputersShopView/FormReportOrders.cs +++ b/ComputersShop/ComputersShopView/FormReportOrders.cs @@ -8,7 +8,6 @@ using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; -using System.Text; using System.Threading.Tasks; using System.Windows.Forms; @@ -31,7 +30,7 @@ namespace ComputersShopView { Dock = DockStyle.Fill }; - reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportOrders.rdlc", FileMode.Open)); + reportViewer.LocalReport.LoadReportDefinition(new FileStream(@"D:\Учёба\РПП\PIbd-22_Bondarenko_M.S._ComputersShop\ComputersShop\ComputersShopView\ReportOrders.rdlc", FileMode.Open)); Controls.Clear(); Controls.Add(reportViewer); Controls.Add(panel); @@ -48,8 +47,8 @@ namespace ComputersShopView { 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(); @@ -70,6 +69,7 @@ namespace ComputersShopView 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); @@ -83,8 +83,8 @@ namespace ComputersShopView _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);