diff --git a/ClothShop/ClothShopBusinessLogic/BusinessLogics/ReportLogic.cs b/ClothShop/ClothShopBusinessLogic/BusinessLogics/ReportLogic.cs index 3571096..1cc0559 100644 --- a/ClothShop/ClothShopBusinessLogic/BusinessLogics/ReportLogic.cs +++ b/ClothShop/ClothShopBusinessLogic/BusinessLogics/ReportLogic.cs @@ -68,21 +68,16 @@ namespace ClothShopBusinessLogic.BusinessLogics /// public List GetOrders(ReportBindingModel model) { - return _orderStorage.GetFilteredList(new OrderSearchModel - { - DateFrom - = model.DateFrom, - DateTo = model.DateTo - }) - .Select(x => new ReportOrdersViewModel - { - Id = x.Id, - DateCreate = x.DateCreate, - TextileName = x.TextileName, - Sum = x.Sum, - Status = x.Status, - }) - .ToList(); + return _orderStorage.GetFilteredList(new OrderSearchModel { DateFrom = model.DateFrom, DateTo = model.DateTo }) + .Select(x => new ReportOrdersViewModel + { + Id = x.Id, + DateCreate = x.DateCreate, + TextileName = x.TextileName, + Status = x.Status.ToString(), + Sum = x.Sum + }) + .ToList(); } /// /// Сохранение компонент в файл-Word diff --git a/ClothShop/ClothShopContracts/ViewModels/ReportOrdersViewModel.cs b/ClothShop/ClothShopContracts/ViewModels/ReportOrdersViewModel.cs index 5af6fcd..000e867 100644 --- a/ClothShop/ClothShopContracts/ViewModels/ReportOrdersViewModel.cs +++ b/ClothShop/ClothShopContracts/ViewModels/ReportOrdersViewModel.cs @@ -10,21 +10,11 @@ namespace ClothShopContracts.ViewModels { public class ReportOrdersViewModel { - [DisplayName("Номер")] public int Id { get; set; } - public int TextileId { get; set; } - [DisplayName("Изделие")] + public DateTime DateCreate { get; set; } public string TextileName { get; set; } = string.Empty; - [DisplayName("Количество")] - public int Count { get; set; } - [DisplayName("Сумма")] + public string Status { get; set; } = string.Empty; public double Sum { get; set; } - [DisplayName("Статус")] - public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; - [DisplayName("Дата создания")] - public DateTime DateCreate { get; set; } = DateTime.Now; - [DisplayName("Дата выполнения")] - public DateTime? DateImplement { get; set; } } } diff --git a/ClothShop/ClothShopDatabaseImplement/Implements/OrderStorage.cs b/ClothShop/ClothShopDatabaseImplement/Implements/OrderStorage.cs index 5d1f7ac..134f1df 100644 --- a/ClothShop/ClothShopDatabaseImplement/Implements/OrderStorage.cs +++ b/ClothShop/ClothShopDatabaseImplement/Implements/OrderStorage.cs @@ -23,15 +23,24 @@ namespace ClothShopDatabaseImplement.Implements } public List GetFilteredList(OrderSearchModel model) { - if (!model.Id.HasValue) + if (!model.Id.HasValue && !model.DateFrom.HasValue) { return new(); } using var context = new ClothShopDatabase(); - return context.Orders.Include(x => x.Textiles) - .Where(x => x.Id == model.Id) - .Select(x => x.GetViewModel) - .ToList(); + if (model.DateFrom.HasValue) + { + return context.Orders + .Include(x => x.Textiles) + .Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo) + .Select(x => x.GetViewModel) + .ToList(); + } + return context.Orders + .Include(x => x.Textiles) + .Where(x => x.Id == model.Id) + .Select(x => x.GetViewModel) + .ToList(); } public OrderViewModel? GetElement(OrderSearchModel model) { diff --git a/ClothShop/ClothShopView/FormReportOrders.cs b/ClothShop/ClothShopView/FormReportOrders.cs index c4aa2c5..8558293 100644 --- a/ClothShop/ClothShopView/FormReportOrders.cs +++ b/ClothShop/ClothShopView/FormReportOrders.cs @@ -95,14 +95,10 @@ namespace ClothShopView { 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 @@ -113,17 +109,13 @@ namespace ClothShopView DateFrom = dateTimePickerFrom.Value, DateTo = dateTimePickerTo.Value }); - _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/ClothShop/ClothShopView/Report2.rdlc b/ClothShop/ClothShopView/Report2.rdlc deleted file mode 100644 index f965163..0000000 --- a/ClothShop/ClothShopView/Report2.rdlc +++ /dev/null @@ -1,599 +0,0 @@ - - - 0 - - - - System.Data.DataSet - /* Local Connection */ - - 47cb53f0-7dde-4717-ba03-866a0bc4f4dd - - - - - - ClothShopContractsViewModels - /* Local Query */ - - - - Id - System.Int32 - - - DateCreate - System.DateTime - - - TextileName - System.String - - - Sum - System.Decimal - - - OrderStatus - ClothShopDataModels.OrderStatus - - - - ClothShopContractsViewModels - ReportOrderViewModel - ClothShopContracts.ViewModels.ReportOrderViewModel, ClothShopContracts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null - - - - - - - - - true - true - - - - - =Parameters!ReportParameterPeriod.Value - - - - - - - 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!TextileName.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.53528cm - 0.6cm - 2.5cm - 4 - - - 2pt - 2pt - 2pt - 2pt - - - - 5.72875cm -