Bondarenko M.S. Lab Work 4 #7

Closed
maxnes3 wants to merge 5 commits from LabWork_04 into LabWork_03
6 changed files with 14 additions and 13 deletions
Showing only changes of commit 358a4a70ea - Show all commits

View File

@ -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)
});
}

View File

@ -45,14 +45,14 @@ namespace ComputersShopDataBaseImplement.Implements
public List<OrderViewModel> 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<OrderViewModel> GetFullList()

View File

@ -31,11 +31,11 @@ namespace ComputersShopFileImplement.Implements
public List<OrderViewModel> 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<OrderViewModel> GetFullList()

View File

@ -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));
}

View File

@ -18,6 +18,7 @@
<PackageReference Include="NLog" Version="5.1.1" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.1" />
<PackageReference Include="ReportViewerCore.WinForms" Version="15.1.17" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="7.0.0" />
</ItemGroup>
<ItemGroup>

View File

@ -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);