готово

This commit is contained in:
goldfest 2024-03-22 19:04:16 +04:00
parent 3cf8dee733
commit b630b2bbf0
17 changed files with 157 additions and 242 deletions

View File

@ -160,7 +160,7 @@ namespace TravelCompany.Forms
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" }; using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
if (dialog.ShowDialog() == DialogResult.OK) if (dialog.ShowDialog() == DialogResult.OK)
{ {
_reportLogic.SaveComponentsToWordFile(new ReportBindingModel _reportLogic.SaveTravelsToWordFile(new ReportBindingModel
{ {
FileName = dialog.FileName FileName = dialog.FileName
}); });

View File

@ -28,102 +28,110 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
panel = new Panel(); this.panel = new System.Windows.Forms.Panel();
buttonCreateToPdf = new Button(); this.buttonCreateToPdf = new System.Windows.Forms.Button();
buttonCreateReport = new Button(); this.buttonCreateReport = new System.Windows.Forms.Button();
label2 = new Label(); this.label2 = new System.Windows.Forms.Label();
label1 = new Label(); this.label1 = new System.Windows.Forms.Label();
dateTimePickerFrom = new DateTimePicker(); this.dateTimePickerEnd = new System.Windows.Forms.DateTimePicker();
dateTimePickerTo = new DateTimePicker(); this.dateTimePickerStart = new System.Windows.Forms.DateTimePicker();
panel.SuspendLayout(); this.panel.SuspendLayout();
SuspendLayout(); this.SuspendLayout();
// //
// panel // panel
// //
panel.Controls.Add(buttonCreateToPdf); this.panel.Controls.Add(this.buttonCreateToPdf);
panel.Controls.Add(buttonCreateReport); this.panel.Controls.Add(this.buttonCreateReport);
panel.Controls.Add(label2); this.panel.Controls.Add(this.label2);
panel.Controls.Add(label1); this.panel.Controls.Add(this.label1);
panel.Controls.Add(dateTimePickerFrom); this.panel.Controls.Add(this.dateTimePickerEnd);
panel.Controls.Add(dateTimePickerTo); this.panel.Controls.Add(this.dateTimePickerStart);
panel.Location = new Point(12, 12); this.panel.Dock = System.Windows.Forms.DockStyle.Top;
panel.Name = "panel"; this.panel.Location = new System.Drawing.Point(0, 0);
panel.Size = new Size(776, 43); this.panel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
panel.TabIndex = 0; this.panel.Name = "panel";
this.panel.Size = new System.Drawing.Size(861, 56);
this.panel.TabIndex = 0;
// //
// buttonCreateToPdf // buttonCreateToPdf
// //
buttonCreateToPdf.Location = new Point(623, 17); this.buttonCreateToPdf.Location = new System.Drawing.Point(684, 29);
buttonCreateToPdf.Name = "buttonCreateToPdf"; this.buttonCreateToPdf.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
buttonCreateToPdf.Size = new Size(150, 23); this.buttonCreateToPdf.Name = "buttonCreateToPdf";
buttonCreateToPdf.TabIndex = 5; this.buttonCreateToPdf.Size = new System.Drawing.Size(166, 23);
buttonCreateToPdf.Text = "В Pdf"; this.buttonCreateToPdf.TabIndex = 5;
buttonCreateToPdf.UseVisualStyleBackColor = true; this.buttonCreateToPdf.Text = "PDF";
buttonCreateToPdf.Click += buttonCreateToPdf_Click; this.buttonCreateToPdf.UseVisualStyleBackColor = true;
this.buttonCreateToPdf.Click += new System.EventHandler(this.buttonCreateToPdf_Click);
// //
// buttonCreateReport // buttonCreateReport
// //
buttonCreateReport.Location = new Point(470, 17); this.buttonCreateReport.Location = new System.Drawing.Point(485, 29);
buttonCreateReport.Name = "buttonCreateReport"; this.buttonCreateReport.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
buttonCreateReport.Size = new Size(147, 23); this.buttonCreateReport.Name = "buttonCreateReport";
buttonCreateReport.TabIndex = 4; this.buttonCreateReport.Size = new System.Drawing.Size(166, 23);
buttonCreateReport.Text = "Сформировать"; this.buttonCreateReport.TabIndex = 4;
buttonCreateReport.UseVisualStyleBackColor = true; this.buttonCreateReport.Text = "Сформировать";
buttonCreateReport.Click += buttonCreateReport_Click; this.buttonCreateReport.UseVisualStyleBackColor = true;
this.buttonCreateReport.Click += new System.EventHandler(this.buttonCreateReport_Click);
// //
// label2 // label2
// //
label2.AutoSize = true; this.label2.AutoSize = true;
label2.Location = new Point(235, 23); this.label2.Location = new System.Drawing.Point(323, 7);
label2.Name = "label2"; this.label2.Name = "label2";
label2.Size = new Size(23, 15); this.label2.Size = new System.Drawing.Size(44, 15);
label2.TabIndex = 3; this.label2.TabIndex = 3;
label2.Text = "По"; this.label2.Text = "Конец:";
// //
// label1 // label1
// //
label1.AutoSize = true; this.label1.AutoSize = true;
label1.Location = new Point(8, 23); this.label1.Location = new System.Drawing.Point(76, 4);
label1.Name = "label1"; this.label1.Name = "label1";
label1.Size = new Size(15, 15); this.label1.Size = new System.Drawing.Size(52, 15);
label1.TabIndex = 2; this.label1.TabIndex = 2;
label1.Text = "С"; this.label1.Text = "Начало:";
// //
// dateTimePickerFrom // dateTimePickerEnd
// //
dateTimePickerFrom.Location = new Point(29, 17); this.dateTimePickerEnd.Location = new System.Drawing.Point(269, 29);
dateTimePickerFrom.Name = "dateTimePickerFrom"; this.dateTimePickerEnd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
dateTimePickerFrom.Size = new Size(200, 23); this.dateTimePickerEnd.Name = "dateTimePickerEnd";
dateTimePickerFrom.TabIndex = 0; this.dateTimePickerEnd.Size = new System.Drawing.Size(164, 23);
this.dateTimePickerEnd.TabIndex = 1;
// //
// dateTimePickerTo // dateTimePickerStart
// //
dateTimePickerTo.Location = new Point(264, 17); this.dateTimePickerStart.Location = new System.Drawing.Point(31, 29);
dateTimePickerTo.Name = "dateTimePickerTo"; this.dateTimePickerStart.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
dateTimePickerTo.Size = new Size(200, 23); this.dateTimePickerStart.Name = "dateTimePickerStart";
dateTimePickerTo.TabIndex = 1; this.dateTimePickerStart.Size = new System.Drawing.Size(164, 23);
this.dateTimePickerStart.TabIndex = 0;
// //
// FormReportOrders // FormReportOrders
// //
AutoScaleDimensions = new SizeF(7F, 15F); this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
ClientSize = new Size(800, 450); this.ClientSize = new System.Drawing.Size(861, 338);
Controls.Add(panel); this.Controls.Add(this.panel);
Name = "FormReportOrders"; this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
Text = "Заказы"; this.Name = "FormReportOrders";
panel.ResumeLayout(false); this.Text = "Заказы";
panel.PerformLayout(); this.panel.ResumeLayout(false);
ResumeLayout(false); this.panel.PerformLayout();
this.ResumeLayout(false);
} }
#endregion #endregion
private Panel panel; private Panel panel;
private DateTimePicker dateTimePickerEnd;
private DateTimePicker dateTimePickerStart;
private Button buttonCreateToPdf; private Button buttonCreateToPdf;
private Button buttonCreateReport; private Button buttonCreateReport;
private Label label2; private Label label2;
private Label label1; private Label label1;
private DateTimePicker dateTimePickerFrom;
private DateTimePicker dateTimePickerTo;
} }
} }

View File

@ -11,8 +11,6 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using TravelCompanyContracts.BindingModels;
using TravelCompanyContracts.BusinessLogicsContracts;
namespace TravelCompany.Forms namespace TravelCompany.Forms
{ {
@ -31,10 +29,7 @@ namespace TravelCompany.Forms
{ {
Dock = DockStyle.Fill Dock = DockStyle.Fill
}; };
using (var fileStream = new FileStream("C:\\Users\\goldfest\\Desktop\\RPP\\TravelCompany\\TravelCompany\\ReportOrders.rdlc", FileMode.Open)) reportViewer.LocalReport.LoadReportDefinition(new FileStream("C:\\Users\\goldfest\\Desktop\\TravelCompany\\PrecastConcretePlant\\PrecastConcretePlantView\\ReportOrders.rdlc", FileMode.Open));
{
reportViewer.LocalReport.LoadReportDefinition(fileStream);
}
Controls.Clear(); Controls.Clear();
Controls.Add(reportViewer); Controls.Add(reportViewer);
Controls.Add(panel); Controls.Add(panel);
@ -42,7 +37,7 @@ namespace TravelCompany.Forms
private void buttonCreateReport_Click(object sender, EventArgs e) private void buttonCreateReport_Click(object sender, EventArgs e)
{ {
if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date) if (dateTimePickerStart.Value.Date >= dateTimePickerEnd.Value.Date)
{ {
MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
@ -51,16 +46,16 @@ namespace TravelCompany.Forms
{ {
var dataSource = _logic.GetOrders(new ReportBindingModel var dataSource = _logic.GetOrders(new ReportBindingModel
{ {
DateFrom = dateTimePickerFrom.Value, DateFrom = dateTimePickerStart.Value,
DateTo = dateTimePickerTo.Value DateTo = dateTimePickerEnd.Value
}); });
var source = new ReportDataSource("DataSetOrders", dataSource); var source = new ReportDataSource("DataSetOrders", dataSource);
reportViewer.LocalReport.DataSources.Clear(); reportViewer.LocalReport.DataSources.Clear();
reportViewer.LocalReport.DataSources.Add(source); 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{dateTimePickerStart.Value.ToShortDateString()} по {dateTimePickerEnd.Value.ToShortDateString()}") };
reportViewer.LocalReport.SetParameters(parameters); reportViewer.LocalReport.SetParameters(parameters);
reportViewer.RefreshReport(); reportViewer.RefreshReport();
_logger.LogInformation("Загрузка списка заказов на период {From}-{ To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString()); _logger.LogInformation("Загрузка списка заказов на период {From}-{ To}", dateTimePickerStart.Value.ToShortDateString(), dateTimePickerEnd.Value.ToShortDateString());
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -73,7 +68,7 @@ namespace TravelCompany.Forms
private void buttonCreateToPdf_Click(object sender, EventArgs e) private void buttonCreateToPdf_Click(object sender, EventArgs e)
{ {
if (dateTimePickerFrom.Value.Date >= dateTimePickerTo.Value.Date) if (dateTimePickerStart.Value.Date >= dateTimePickerEnd.Value.Date)
{ {
MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Дата начала должна быть меньше даты окончания", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
@ -89,10 +84,10 @@ namespace TravelCompany.Forms
_logic.SaveOrdersToPdfFile(new ReportBindingModel _logic.SaveOrdersToPdfFile(new ReportBindingModel
{ {
FileName = dialog.FileName, FileName = dialog.FileName,
DateFrom = dateTimePickerFrom.Value, DateFrom = dateTimePickerStart.Value,
DateTo = dateTimePickerTo.Value DateTo = dateTimePickerEnd.Value
}); });
_logger.LogInformation("Сохранение списка заказов на период { From} -{ To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString()); _logger.LogInformation("Сохранение списка заказов на период { From} -{ To}", dateTimePickerStart.Value.ToShortDateString(), dateTimePickerEnd.Value.ToShortDateString());
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
} }
catch (Exception ex) catch (Exception ex)

View File

@ -1,64 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <root>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">

View File

@ -72,7 +72,7 @@
SaveButton.TabIndex = 1; SaveButton.TabIndex = 1;
SaveButton.Text = "Сохранить в Excel"; SaveButton.Text = "Сохранить в Excel";
SaveButton.UseVisualStyleBackColor = true; SaveButton.UseVisualStyleBackColor = true;
SaveButton.Click += SaveButton_Click; SaveButton.Click += ButtonSaveToExcel_Click;
// //
// ReportTravelComponentForm // ReportTravelComponentForm
// //
@ -83,7 +83,7 @@
Controls.Add(dataGridView); Controls.Add(dataGridView);
Name = "ReportTravelComponentForm"; Name = "ReportTravelComponentForm";
Text = "Компоненты по мороженным"; Text = "Компоненты по мороженным";
Load += ReportTravelComponentForm_Load; Load += FormReportTravelComponents_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false); ResumeLayout(false);
} }

View File

@ -1,6 +1,6 @@
using TravelCompanyContracts.BindingModels; using Microsoft.Extensions.Logging;
using TravelCompanyContracts.BindingModels;
using TravelCompanyContracts.BusinessLogicsContracts; using TravelCompanyContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
@ -18,78 +18,61 @@ namespace TravelCompany.Forms
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IReportLogic _logic; private readonly IReportLogic _logic;
public FormReportTravelComponents(ILogger<FormReportTravelComponents> public FormReportTravelComponents(ILogger<FormReportTravelComponents> logger, IReportLogic logic)
logger, IReportLogic logic)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_logic = logic; _logic = logic;
} }
private void ReportTravelComponentForm_Load(object sender, EventArgs e) private void FormReportTravelComponents_Load(object sender, EventArgs e)
{ {
try try
{ {
var dict = _logic.GetTravelComponent(); var dict = _logic.GetTravelComponents();
if (dict != null) if (dict != null)
{ {
dataGridView.Rows.Clear(); dataGridView.Rows.Clear();
foreach (var elem in dict) foreach (var elem in dict)
{ {
dataGridView.Rows.Add(new object[] { elem.ComponentName, dataGridView.Rows.Add(new object[] { elem.TravelName, "", "" });
"", "" }); foreach (var listElem in elem.Components)
foreach (var listElem in elem.Travels)
{ {
dataGridView.Rows.Add(new object[] { "", dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
listElem.Item1, listElem.Item2 });
} }
dataGridView.Rows.Add(new object[] { "Итого", "", dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount });
elem.TotalCount });
dataGridView.Rows.Add(Array.Empty<object>()); dataGridView.Rows.Add(Array.Empty<object>());
} }
} }
_logger.LogInformation("Загрузка списка мороженных по компонентам"); _logger.LogInformation("Загрузка списка изделий по компонентам");
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка загрузки списка мороженных по компонентам"); _logger.LogError(ex, "Ошибка загрузки списка изделий по компонентам");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
} }
} }
private void SaveButton_Click(object sender, EventArgs e) private void ButtonSaveToExcel_Click(object sender, EventArgs e)
{ {
using var dialog = new SaveFileDialog using var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" };
{
Filter = "xlsx|*.xlsx"
};
if (dialog.ShowDialog() == DialogResult.OK) if (dialog.ShowDialog() == DialogResult.OK)
{ {
try try
{ {
_logic.SaveTravelComponentToExcelFile(new _logic.SaveTravelComponentToExcelFile(new ReportBindingModel
ReportBindingModel
{ {
FileName = dialog.FileName FileName = dialog.FileName
}); });
_logger.LogInformation("Сохранение списка мороженных по компонентам"); _logger.LogInformation("Сохранение списка изделий по компонентам");
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
MessageBoxIcon.Information);
} }
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка сохранения списка мороженных по компонентам"); _logger.LogError(ex, "Ошибка сохранения списка изделий по компонентам");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
} }
} }
} }
} }
} }

View File

@ -212,7 +212,7 @@
<Paragraph> <Paragraph>
<TextRuns> <TextRuns>
<TextRun> <TextRun>
<Value>Путёвки</Value> <Value>Железные изделия</Value>
<Style> <Style>
<FontWeight>Bold</FontWeight> <FontWeight>Bold</FontWeight>
</Style> </Style>
@ -428,7 +428,7 @@
</TablixCell> </TablixCell>
<TablixCell> <TablixCell>
<CellContents> <CellContents>
<Textbox Name="OrderStatus"> <Textbox Name="Status">
<CanGrow>true</CanGrow> <CanGrow>true</CanGrow>
<KeepTogether>true</KeepTogether> <KeepTogether>true</KeepTogether>
<Paragraphs> <Paragraphs>
@ -442,7 +442,7 @@
<Style /> <Style />
</Paragraph> </Paragraph>
</Paragraphs> </Paragraphs>
<rd:DefaultName>OrderStatus</rd:DefaultName> <rd:DefaultName>Status</rd:DefaultName>
<Style> <Style>
<Border> <Border>
<Color>LightGrey</Color> <Color>LightGrey</Color>

View File

@ -10,69 +10,58 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using TravelCompanyBusinessLogic.OfficePackage.HelperModels;
using TravelCompanyBusinessLogic.OfficePackage;
using TravelCompanyContracts.BindingModels;
using TravelCompanyContracts.BusinessLogicsContracts;
using TravelCompanyContracts.SearchModels;
using TravelCompanyContracts.StoragesContracts;
using TravelCompanyContracts.ViewModels;
namespace TravelCompanyBusinessLogic.BusinessLogic namespace TravelCompanyBusinessLogic.BusinessLogic
{ {
public class ReportLogic : IReportLogic public class ReportLogic : IReportLogic
{ {
private readonly IComponentStorage _componentStorage; private readonly IComponentStorage _componentStorage;
private readonly ITravelStorage _productStorage; private readonly ITravelStorage _TravelStorage;
private readonly IOrderStorage _orderStorage; private readonly IOrderStorage _orderStorage;
private readonly AbstractSaveToExcel _saveToExcel; private readonly AbstractSaveToExcel _saveToExcel;
private readonly AbstractSaveToWord _saveToWord; private readonly AbstractSaveToWord _saveToWord;
private readonly AbstractSaveToPdf _saveToPdf; private readonly AbstractSaveToPdf _saveToPdf;
public ReportLogic(ITravelStorage productStorage, IComponentStorage public ReportLogic(ITravelStorage TravelStorage, IComponentStorage componentStorage, IOrderStorage orderStorage, AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
componentStorage, IOrderStorage orderStorage,
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord,
AbstractSaveToPdf saveToPdf)
{ {
_productStorage = productStorage; _TravelStorage = TravelStorage;
_componentStorage = componentStorage; _componentStorage = componentStorage;
_orderStorage = orderStorage; _orderStorage = orderStorage;
_saveToExcel = saveToExcel; _saveToExcel = saveToExcel;
_saveToWord = saveToWord; _saveToWord = saveToWord;
_saveToPdf = saveToPdf; _saveToPdf = saveToPdf;
} }
public List<ReportTravelComponentViewModel> GetTravelComponent()
public List<ReportTravelComponentViewModel> GetTravelComponents()
{ {
var components = _componentStorage.GetFullList(); var components = _componentStorage.GetFullList();
var products = _productStorage.GetFullList(); var Travels = _TravelStorage.GetFullList();
var list = new List<ReportTravelComponentViewModel>(); var list = new List<ReportTravelComponentViewModel>();
foreach (var component in components) foreach (var Travel in Travels)
{ {
var record = new ReportTravelComponentViewModel var record = new ReportTravelComponentViewModel
{ {
ComponentName = component.ComponentName, TravelName = Travel.TravelName,
Travels = new List<Tuple<string, int>>(), Components = new List<(string Component, int Count)>(),
TotalCount = 0 TotalCount = 0
}; };
foreach (var travel in products) foreach (var component in components)
{ {
if (travel.TravelComponents.ContainsKey(component.Id)) if (Travel.TravelComponents.ContainsKey(component.Id))
{ {
record.Travels.Add(new Tuple<string, record.Components.Add(new(component.ComponentName, Travel.TravelComponents[component.Id].Item2));
int>(travel.TravelName, travel.TravelComponents[component.Id].Item2)); record.TotalCount += Travel.TravelComponents[component.Id].Item2;
record.TotalCount +=
travel.TravelComponents[component.Id].Item2;
} }
} }
list.Add(record); list.Add(record);
} }
return list; return list;
} }
public List<ReportOrdersViewModel> GetOrders(ReportBindingModel model) public List<ReportOrdersViewModel> GetOrders(ReportBindingModel model)
{ {
return _orderStorage.GetFilteredList(new OrderSearchModel return _orderStorage.GetFilteredList(new OrderSearchModel
{ {
DateFrom DateFrom = model.DateFrom,
= model.DateFrom,
DateTo = model.DateTo DateTo = model.DateTo
}) })
.Select(x => new ReportOrdersViewModel .Select(x => new ReportOrdersViewModel
@ -80,17 +69,19 @@ namespace TravelCompanyBusinessLogic.BusinessLogic
Id = x.Id, Id = x.Id,
DateCreate = x.DateCreate, DateCreate = x.DateCreate,
TravelName = x.TravelName, TravelName = x.TravelName,
Sum = x.Sum Sum = x.Sum,
Status = x.Status.ToString(),
}) })
.ToList(); .ToList();
} }
public void SaveComponentsToWordFile(ReportBindingModel model)
public void SaveTravelsToWordFile(ReportBindingModel model)
{ {
_saveToWord.CreateDoc(new WordInfo _saveToWord.CreateDoc(new WordInfo
{ {
FileName = model.FileName, FileName = model.FileName,
Title = "Список компонент", Title = "Список ЖИ",
Components = _componentStorage.GetFullList() Travels = _TravelStorage.GetFullList()
}); });
} }
public void SaveTravelComponentToExcelFile(ReportBindingModel model) public void SaveTravelComponentToExcelFile(ReportBindingModel model)
@ -98,10 +89,11 @@ namespace TravelCompanyBusinessLogic.BusinessLogic
_saveToExcel.CreateReport(new ExcelInfo _saveToExcel.CreateReport(new ExcelInfo
{ {
FileName = model.FileName, FileName = model.FileName,
Title = "Список компонент", Title = "Список ЖИ",
TravelComponents = GetTravelComponent() TravelComponents = GetTravelComponents()
}); });
} }
public void SaveOrdersToPdfFile(ReportBindingModel model) public void SaveOrdersToPdfFile(ReportBindingModel model)
{ {
_saveToPdf.CreateDoc(new PdfInfo _saveToPdf.CreateDoc(new PdfInfo
@ -113,5 +105,6 @@ namespace TravelCompanyBusinessLogic.BusinessLogic
Orders = GetOrders(model) Orders = GetOrders(model)
}); });
} }
} }
} }

View File

@ -32,11 +32,11 @@ namespace TravelCompanyBusinessLogic.OfficePackage
{ {
ColumnName = "A", ColumnName = "A",
RowIndex = rowIndex, RowIndex = rowIndex,
Text = pc.ComponentName, Text = pc.TravelName,
StyleInfo = ExcelStyleInfoType.Text StyleInfo = ExcelStyleInfoType.Text
}); });
rowIndex++; rowIndex++;
foreach (var Travel in pc.Travels) foreach (var Travel in pc.Components)
{ {
InsertCellInWorksheet(new ExcelCellParameters InsertCellInWorksheet(new ExcelCellParameters
{ {

View File

@ -16,21 +16,19 @@ namespace TravelCompanyBusinessLogic.OfficePackage
CreateParagraph(new PdfParagraph CreateParagraph(new PdfParagraph
{ {
Text = info.Title, Text = info.Title,
Style = Style = "NormalTitle",
"NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center ParagraphAlignment = PdfParagraphAlignmentType.Center
}); });
CreateParagraph(new PdfParagraph CreateParagraph(new PdfParagraph
{ {
Text = $"с { info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style Text = $"с{info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}",
= "Normal", Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Center ParagraphAlignment = PdfParagraphAlignmentType.Center
}); });
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm" }); CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "4cm" });
CreateRow(new PdfRowParameters CreateRow(new PdfRowParameters
{ {
Texts = new List<string> { "Номер", "Дата заказа", "Изделие", Texts = new List<string> { "Номер", "Дата заказа", "Изделие", "Сумма", "Статус" },
"Сумма" },
Style = "NormalTitle", Style = "NormalTitle",
ParagraphAlignment = PdfParagraphAlignmentType.Center ParagraphAlignment = PdfParagraphAlignmentType.Center
}); });
@ -38,8 +36,7 @@ namespace TravelCompanyBusinessLogic.OfficePackage
{ {
CreateRow(new PdfRowParameters CreateRow(new PdfRowParameters
{ {
Texts = new List<string> { order.Id.ToString(), Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.TravelName, order.Sum.ToString(), order.Status },
order.DateCreate.ToShortDateString(), order.TravelName, order.Sum.ToString() },
Style = "Normal", Style = "Normal",
ParagraphAlignment = PdfParagraphAlignmentType.Left ParagraphAlignment = PdfParagraphAlignmentType.Left
}); });
@ -48,16 +45,15 @@ order.DateCreate.ToShortDateString(), order.TravelName, order.Sum.ToString() },
{ {
Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t", Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t",
Style = "Normal", Style = "Normal",
ParagraphAlignment = ParagraphAlignment = PdfParagraphAlignmentType.Right
PdfParagraphAlignmentType.Rigth
}); });
SavePdf(info); SavePdf(info);
} }
protected abstract void CreatePdf(PdfInfo info); protected abstract void CreatePdf(PdfInfo info);
protected abstract void CreateParagraph(PdfParagraph paragraph); protected abstract void CreateParagraph(PdfParagraph paragraph);
protected abstract void CreateTable(List<string> columns); protected abstract void CreateTable(List<string> columns);
protected abstract void CreateRow(PdfRowParameters rowParameters); protected abstract void CreateRow(PdfRowParameters rowParameters);
protected abstract void SavePdf(PdfInfo info); protected abstract void SavePdf(PdfInfo info);
} }
} }

View File

@ -23,12 +23,12 @@ WordTextProperties { Bold = true, Size = "24", }) },
JustificationType = WordJustificationType.Center JustificationType = WordJustificationType.Center
} }
}); });
foreach (var component in info.Components) foreach (var component in info.Travels)
{ {
CreateParagraph(new WordParagraph CreateParagraph(new WordParagraph
{ {
Texts = new List<(string, WordTextProperties)> { Texts = new List<(string, WordTextProperties)> {
(component.ComponentName, new WordTextProperties { Size = "24", }) }, (component.TravelName, new WordTextProperties { Size = "24", }) },
TextProperties = new WordTextProperties TextProperties = new WordTextProperties
{ {
Size = "24", Size = "24",

View File

@ -10,6 +10,6 @@ namespace TravelCompanyBusinessLogic.OfficePackage.HelperEnums
{ {
Center, Center,
Left, Left,
Rigth Right
} }
} }

View File

@ -11,6 +11,6 @@ namespace TravelCompanyBusinessLogic.OfficePackage.HelperModels
{ {
public string FileName { get; set; } = string.Empty; public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty; public string Title { get; set; } = string.Empty;
public List<ComponentViewModel> Components { get; set; } = new(); public List<TravelViewModel> Travels { get; set; } = new();
} }
} }

View File

@ -23,7 +23,7 @@ namespace TravelCompanyBusinessLogic.OfficePackage.Implements
{ {
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center, PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left, PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
PdfParagraphAlignmentType.Rigth => ParagraphAlignment.Right, PdfParagraphAlignmentType.Right => ParagraphAlignment.Right,
_ => ParagraphAlignment.Justify, _ => ParagraphAlignment.Justify,
}; };
} }

View File

@ -10,9 +10,9 @@ namespace TravelCompanyContracts.BusinessLogicsContracts
{ {
public interface IReportLogic public interface IReportLogic
{ {
List<ReportTravelComponentViewModel> GetTravelComponent(); List<ReportTravelComponentViewModel> GetTravelComponents();
List<ReportOrdersViewModel> GetOrders(ReportBindingModel model); List<ReportOrdersViewModel> GetOrders(ReportBindingModel model);
void SaveComponentsToWordFile(ReportBindingModel model); void SaveTravelsToWordFile(ReportBindingModel model);
void SaveTravelComponentToExcelFile(ReportBindingModel model); void SaveTravelComponentToExcelFile(ReportBindingModel model);
void SaveOrdersToPdfFile(ReportBindingModel model); void SaveOrdersToPdfFile(ReportBindingModel model);
} }

View File

@ -11,9 +11,8 @@ namespace TravelCompanyContracts.ViewModels
public int Id { get; set; } public int Id { get; set; }
public DateTime DateCreate { get; set; } public DateTime DateCreate { get; set; }
public string TravelName { get; set; } = string.Empty; public string TravelName { get; set; } = string.Empty;
public string OrderStatus { get; set; } = string.Empty;
public double Sum { get; set; } public double Sum { get; set; }
public string Status { get; set; } = string.Empty;
} }
} }

View File

@ -8,9 +8,10 @@ namespace TravelCompanyContracts.ViewModels
{ {
public class ReportTravelComponentViewModel public class ReportTravelComponentViewModel
{ {
public string ComponentName { get; set; } = string.Empty; public string TravelName { get; set; } = string.Empty;
public int TotalCount { get; set; } public int TotalCount { get; set; }
public List<Tuple<string, int>> Travels { get; set; } = new(); public List<(string Component, int Count)> Components { get; set; } = new();
} }
} }