почти готово БЕЗ УЧЕТА ТРЕБОВАНИЙ есть баг с загрузкой отчета

This commit is contained in:
ekallin 2024-03-24 20:42:18 +04:00
parent c3c88ad6e1
commit 1aa25cc87c
11 changed files with 50 additions and 44 deletions

View File

@ -172,7 +172,6 @@ namespace SushiBarView
{ {
form.ShowDialog(); form.ShowDialog();
} }
} }
} }
} }

View File

@ -29,12 +29,12 @@
private void InitializeComponent() private void InitializeComponent()
{ {
panel = new Panel(); panel = new Panel();
dateTimePickerDateTo = new DateTimePicker();
dateTimePickerDateFrom = new DateTimePicker();
buttonMake = new Button();
buttonToPdf = new Button();
labelTo = new Label();
labelFrom = new Label(); labelFrom = new Label();
buttonToPdf = new Button();
dateTimePickerDateFrom = new DateTimePicker();
labelTo = new Label();
dateTimePickerDateTo = new DateTimePicker();
buttonMake = new Button();
panel.SuspendLayout(); panel.SuspendLayout();
SuspendLayout(); SuspendLayout();
// //
@ -52,28 +52,14 @@
panel.Size = new Size(1321, 71); panel.Size = new Size(1321, 71);
panel.TabIndex = 3; panel.TabIndex = 3;
// //
// dateTimePickerDateTo // labelFrom
// //
dateTimePickerDateTo.Location = new Point(365, 27); labelFrom.AutoSize = true;
dateTimePickerDateTo.Name = "dateTimePickerDateTo"; labelFrom.Location = new Point(16, 31);
dateTimePickerDateTo.Size = new Size(250, 27); labelFrom.Name = "labelFrom";
dateTimePickerDateTo.TabIndex = 1; labelFrom.Size = new Size(18, 20);
// labelFrom.TabIndex = 3;
// dateTimePickerDateFrom labelFrom.Text = "С";
//
dateTimePickerDateFrom.Location = new Point(51, 27);
dateTimePickerDateFrom.Name = "dateTimePickerDateFrom";
dateTimePickerDateFrom.Size = new Size(250, 27);
dateTimePickerDateFrom.TabIndex = 0;
//
// buttonMake
//
buttonMake.Location = new Point(677, 27);
buttonMake.Name = "buttonMake";
buttonMake.Size = new Size(132, 29);
buttonMake.TabIndex = 3;
buttonMake.Text = "Сформировать";
buttonMake.UseVisualStyleBackColor = true;
// //
// buttonToPdf // buttonToPdf
// //
@ -83,6 +69,14 @@
buttonToPdf.TabIndex = 4; buttonToPdf.TabIndex = 4;
buttonToPdf.Text = "В PDF"; buttonToPdf.Text = "В PDF";
buttonToPdf.UseVisualStyleBackColor = true; buttonToPdf.UseVisualStyleBackColor = true;
buttonToPdf.Click += ButtonToPdf_Click;
//
// dateTimePickerDateFrom
//
dateTimePickerDateFrom.Location = new Point(51, 27);
dateTimePickerDateFrom.Name = "dateTimePickerDateFrom";
dateTimePickerDateFrom.Size = new Size(250, 27);
dateTimePickerDateFrom.TabIndex = 0;
// //
// labelTo // labelTo
// //
@ -93,14 +87,22 @@
labelTo.TabIndex = 4; labelTo.TabIndex = 4;
labelTo.Text = "По"; labelTo.Text = "По";
// //
// labelFrom // dateTimePickerDateTo
// //
labelFrom.AutoSize = true; dateTimePickerDateTo.Location = new Point(365, 27);
labelFrom.Location = new Point(16, 31); dateTimePickerDateTo.Name = "dateTimePickerDateTo";
labelFrom.Name = "labelFrom"; dateTimePickerDateTo.Size = new Size(250, 27);
labelFrom.Size = new Size(18, 20); dateTimePickerDateTo.TabIndex = 1;
labelFrom.TabIndex = 3; //
labelFrom.Text = "С"; // buttonMake
//
buttonMake.Location = new Point(677, 27);
buttonMake.Name = "buttonMake";
buttonMake.Size = new Size(132, 29);
buttonMake.TabIndex = 3;
buttonMake.Text = "Сформировать";
buttonMake.UseVisualStyleBackColor = true;
buttonMake.Click += ButtonMake_Click;
// //
// FormReportOrders // FormReportOrders
// //

View File

@ -28,7 +28,9 @@ namespace SushiBarView.Reports
{ {
Dock = DockStyle.Fill Dock = DockStyle.Fill
}; };
reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportOrders.rdlc", FileMode.Open)); var path = Directory.GetParent(Directory.GetCurrentDirectory())?.Parent?.Parent?.ToString() + "\\ReportOrders.rdlc";
reportViewer.LocalReport.LoadReportDefinition(new FileStream(path, FileMode.Open));
//reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportOrders.rdlc", FileMode.Open));
Controls.Clear(); Controls.Clear();
Controls.Add(reportViewer); Controls.Add(reportViewer);
Controls.Add(panel); Controls.Add(panel);
@ -52,11 +54,11 @@ namespace SushiBarView.Reports
reportViewer.LocalReport.DataSources.Clear(); reportViewer.LocalReport.DataSources.Clear();
reportViewer.LocalReport.DataSources.Add(source); reportViewer.LocalReport.DataSources.Add(source);
var parameters = new[] { new ReportParameter("ReportParameterPeriod", var parameters = new[] { new ReportParameter("ReportParameterPeriod",
$"c{dateTimePickerDateFrom.Value.ToShortDateString()} по {dateTimePickerDateTo.Value.ToShortDateString()}") $"c {dateTimePickerDateFrom.Value.ToShortDateString()} по {dateTimePickerDateTo.Value.ToShortDateString()}")
}; };
reportViewer.LocalReport.SetParameters(parameters); reportViewer.LocalReport.SetParameters(parameters);
reportViewer.RefreshReport(); reportViewer.RefreshReport();
_logger.LogInformation("Загрузка списка заказов на период {From} - {To} ", _logger.LogInformation("Загрузка списка заказов на период {From}-{To}",
dateTimePickerDateFrom.Value.ToShortDateString(), dateTimePickerDateTo.Value.ToShortDateString()); dateTimePickerDateFrom.Value.ToShortDateString(), dateTimePickerDateTo.Value.ToShortDateString());
} }
catch (Exception ex) catch (Exception ex)
@ -86,7 +88,7 @@ namespace SushiBarView.Reports
DateFrom = dateTimePickerDateFrom.Value, DateFrom = dateTimePickerDateFrom.Value,
DateTo = dateTimePickerDateTo.Value DateTo = dateTimePickerDateTo.Value
}); });
_logger.LogInformation("Сохранение списка заказов на период { From} - { To} ", _logger.LogInformation("Сохранение списка заказов на период {From}-{To} ",
dateTimePickerDateFrom.Value.ToShortDateString(), dateTimePickerDateTo.Value.ToShortDateString()); dateTimePickerDateFrom.Value.ToShortDateString(), dateTimePickerDateTo.Value.ToShortDateString());
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
} }

View File

@ -77,6 +77,7 @@
buttonSaveToExcel.TabIndex = 1; buttonSaveToExcel.TabIndex = 1;
buttonSaveToExcel.Text = "Сохранить в Excel"; buttonSaveToExcel.Text = "Сохранить в Excel";
buttonSaveToExcel.UseVisualStyleBackColor = false; buttonSaveToExcel.UseVisualStyleBackColor = false;
buttonSaveToExcel.Click += ButtonSaveToExcel_Click;
// //
// FormReportSushiComponent // FormReportSushiComponent
// //
@ -87,6 +88,7 @@
Controls.Add(dataGridView1); Controls.Add(dataGridView1);
Name = "FormReportSushiComponent"; Name = "FormReportSushiComponent";
Text = "Компоненты по изделиям"; Text = "Компоненты по изделиям";
Load += FormReportProductComponents_Load;
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit(); ((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
ResumeLayout(false); ResumeLayout(false);
} }

View File

@ -3,6 +3,8 @@ using Microsoft.Extensions.Logging;
using NLog.Extensions.Logging; using NLog.Extensions.Logging;
using SushiBarBusinessLogic; using SushiBarBusinessLogic;
using SushiBarBusinessLogic.BusinessLogic; using SushiBarBusinessLogic.BusinessLogic;
using SushiBarBusinessLogic.OfficePackage;
using SushiBarBusinessLogic.OfficePackage.Implements;
using SushiBarContracts.BusinessLogicsContracts; using SushiBarContracts.BusinessLogicsContracts;
using SushiBarContracts.StoragesContracts; using SushiBarContracts.StoragesContracts;
using SushiBarDatabaseImplement.Implements; using SushiBarDatabaseImplement.Implements;
@ -48,6 +50,10 @@ namespace SushiBar
services.AddTransient<ISushiLogic, SushiLogic>(); services.AddTransient<ISushiLogic, SushiLogic>();
services.AddTransient<IReportLogic, ReportLogic>(); services.AddTransient<IReportLogic, ReportLogic>();
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
services.AddTransient<AbstractSaveToWord, SaveToWord>();
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
services.AddTransient<FormMain>(); services.AddTransient<FormMain>();
services.AddTransient<FormComponent>(); services.AddTransient<FormComponent>();
services.AddTransient<FormComponents>(); services.AddTransient<FormComponents>();

View File

@ -5,11 +5,6 @@ using SushiBarContracts.BusinessLogicsContracts;
using SushiBarContracts.SearchModel; using SushiBarContracts.SearchModel;
using SushiBarContracts.StoragesContracts; using SushiBarContracts.StoragesContracts;
using SushiBarContracts.ViewModels; using SushiBarContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SushiBarBusinessLogic namespace SushiBarBusinessLogic
{ {

View File

@ -25,7 +25,7 @@ namespace SushiBarDatabaseImplement.Implements
if (model.Id.HasValue) if (model.Id.HasValue)
return context.Orders.Where(x => x.Id == model.Id).Select(x => AccessViewModel(x.GetViewModel)).ToList(); return context.Orders.Where(x => x.Id == model.Id).Select(x => AccessViewModel(x.GetViewModel)).ToList();
else else
return context.Orders.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo).Select(x => AccessViewModel(x.GetViewModel)).ToList(); return context.Orders.Where(x => x.DateCreate >= model.DateFrom).Where(x => x.DateCreate <= model.DateTo).Select(x => AccessViewModel(x.GetViewModel)).ToList();
} }
public OrderViewModel? GetElement(OrderSearchModel model) public OrderViewModel? GetElement(OrderSearchModel model)
{ {