готово
This commit is contained in:
parent
3cf8dee733
commit
b630b2bbf0
@ -160,7 +160,7 @@ namespace TravelCompany.Forms
|
||||
using var dialog = new SaveFileDialog { Filter = "docx|*.docx" };
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_reportLogic.SaveComponentsToWordFile(new ReportBindingModel
|
||||
_reportLogic.SaveTravelsToWordFile(new ReportBindingModel
|
||||
{
|
||||
FileName = dialog.FileName
|
||||
});
|
||||
|
142
TravelCompany/TravelCompany/FormReportOrders.Designer.cs
generated
142
TravelCompany/TravelCompany/FormReportOrders.Designer.cs
generated
@ -28,102 +28,110 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
panel = new Panel();
|
||||
buttonCreateToPdf = new Button();
|
||||
buttonCreateReport = new Button();
|
||||
label2 = new Label();
|
||||
label1 = new Label();
|
||||
dateTimePickerFrom = new DateTimePicker();
|
||||
dateTimePickerTo = new DateTimePicker();
|
||||
panel.SuspendLayout();
|
||||
SuspendLayout();
|
||||
this.panel = new System.Windows.Forms.Panel();
|
||||
this.buttonCreateToPdf = new System.Windows.Forms.Button();
|
||||
this.buttonCreateReport = new System.Windows.Forms.Button();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.dateTimePickerEnd = new System.Windows.Forms.DateTimePicker();
|
||||
this.dateTimePickerStart = new System.Windows.Forms.DateTimePicker();
|
||||
this.panel.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// panel
|
||||
//
|
||||
panel.Controls.Add(buttonCreateToPdf);
|
||||
panel.Controls.Add(buttonCreateReport);
|
||||
panel.Controls.Add(label2);
|
||||
panel.Controls.Add(label1);
|
||||
panel.Controls.Add(dateTimePickerFrom);
|
||||
panel.Controls.Add(dateTimePickerTo);
|
||||
panel.Location = new Point(12, 12);
|
||||
panel.Name = "panel";
|
||||
panel.Size = new Size(776, 43);
|
||||
panel.TabIndex = 0;
|
||||
this.panel.Controls.Add(this.buttonCreateToPdf);
|
||||
this.panel.Controls.Add(this.buttonCreateReport);
|
||||
this.panel.Controls.Add(this.label2);
|
||||
this.panel.Controls.Add(this.label1);
|
||||
this.panel.Controls.Add(this.dateTimePickerEnd);
|
||||
this.panel.Controls.Add(this.dateTimePickerStart);
|
||||
this.panel.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.panel.Location = new System.Drawing.Point(0, 0);
|
||||
this.panel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.panel.Name = "panel";
|
||||
this.panel.Size = new System.Drawing.Size(861, 56);
|
||||
this.panel.TabIndex = 0;
|
||||
//
|
||||
// buttonCreateToPdf
|
||||
//
|
||||
buttonCreateToPdf.Location = new Point(623, 17);
|
||||
buttonCreateToPdf.Name = "buttonCreateToPdf";
|
||||
buttonCreateToPdf.Size = new Size(150, 23);
|
||||
buttonCreateToPdf.TabIndex = 5;
|
||||
buttonCreateToPdf.Text = "В Pdf";
|
||||
buttonCreateToPdf.UseVisualStyleBackColor = true;
|
||||
buttonCreateToPdf.Click += buttonCreateToPdf_Click;
|
||||
this.buttonCreateToPdf.Location = new System.Drawing.Point(684, 29);
|
||||
this.buttonCreateToPdf.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonCreateToPdf.Name = "buttonCreateToPdf";
|
||||
this.buttonCreateToPdf.Size = new System.Drawing.Size(166, 23);
|
||||
this.buttonCreateToPdf.TabIndex = 5;
|
||||
this.buttonCreateToPdf.Text = "PDF";
|
||||
this.buttonCreateToPdf.UseVisualStyleBackColor = true;
|
||||
this.buttonCreateToPdf.Click += new System.EventHandler(this.buttonCreateToPdf_Click);
|
||||
//
|
||||
// buttonCreateReport
|
||||
//
|
||||
buttonCreateReport.Location = new Point(470, 17);
|
||||
buttonCreateReport.Name = "buttonCreateReport";
|
||||
buttonCreateReport.Size = new Size(147, 23);
|
||||
buttonCreateReport.TabIndex = 4;
|
||||
buttonCreateReport.Text = "Сформировать";
|
||||
buttonCreateReport.UseVisualStyleBackColor = true;
|
||||
buttonCreateReport.Click += buttonCreateReport_Click;
|
||||
this.buttonCreateReport.Location = new System.Drawing.Point(485, 29);
|
||||
this.buttonCreateReport.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonCreateReport.Name = "buttonCreateReport";
|
||||
this.buttonCreateReport.Size = new System.Drawing.Size(166, 23);
|
||||
this.buttonCreateReport.TabIndex = 4;
|
||||
this.buttonCreateReport.Text = "Сформировать";
|
||||
this.buttonCreateReport.UseVisualStyleBackColor = true;
|
||||
this.buttonCreateReport.Click += new System.EventHandler(this.buttonCreateReport_Click);
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(235, 23);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(23, 15);
|
||||
label2.TabIndex = 3;
|
||||
label2.Text = "По";
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(323, 7);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(44, 15);
|
||||
this.label2.TabIndex = 3;
|
||||
this.label2.Text = "Конец:";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(8, 23);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(15, 15);
|
||||
label1.TabIndex = 2;
|
||||
label1.Text = "С";
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(76, 4);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(52, 15);
|
||||
this.label1.TabIndex = 2;
|
||||
this.label1.Text = "Начало:";
|
||||
//
|
||||
// dateTimePickerFrom
|
||||
// dateTimePickerEnd
|
||||
//
|
||||
dateTimePickerFrom.Location = new Point(29, 17);
|
||||
dateTimePickerFrom.Name = "dateTimePickerFrom";
|
||||
dateTimePickerFrom.Size = new Size(200, 23);
|
||||
dateTimePickerFrom.TabIndex = 0;
|
||||
this.dateTimePickerEnd.Location = new System.Drawing.Point(269, 29);
|
||||
this.dateTimePickerEnd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.dateTimePickerEnd.Name = "dateTimePickerEnd";
|
||||
this.dateTimePickerEnd.Size = new System.Drawing.Size(164, 23);
|
||||
this.dateTimePickerEnd.TabIndex = 1;
|
||||
//
|
||||
// dateTimePickerTo
|
||||
// dateTimePickerStart
|
||||
//
|
||||
dateTimePickerTo.Location = new Point(264, 17);
|
||||
dateTimePickerTo.Name = "dateTimePickerTo";
|
||||
dateTimePickerTo.Size = new Size(200, 23);
|
||||
dateTimePickerTo.TabIndex = 1;
|
||||
this.dateTimePickerStart.Location = new System.Drawing.Point(31, 29);
|
||||
this.dateTimePickerStart.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.dateTimePickerStart.Name = "dateTimePickerStart";
|
||||
this.dateTimePickerStart.Size = new System.Drawing.Size(164, 23);
|
||||
this.dateTimePickerStart.TabIndex = 0;
|
||||
//
|
||||
// FormReportOrders
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(panel);
|
||||
Name = "FormReportOrders";
|
||||
Text = "Заказы";
|
||||
panel.ResumeLayout(false);
|
||||
panel.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(861, 338);
|
||||
this.Controls.Add(this.panel);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.Name = "FormReportOrders";
|
||||
this.Text = "Заказы";
|
||||
this.panel.ResumeLayout(false);
|
||||
this.panel.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel panel;
|
||||
private DateTimePicker dateTimePickerEnd;
|
||||
private DateTimePicker dateTimePickerStart;
|
||||
private Button buttonCreateToPdf;
|
||||
private Button buttonCreateReport;
|
||||
private Label label2;
|
||||
private Label label1;
|
||||
private DateTimePicker dateTimePickerFrom;
|
||||
private DateTimePicker dateTimePickerTo;
|
||||
}
|
||||
}
|
||||
}
|
@ -11,8 +11,6 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using TravelCompanyContracts.BindingModels;
|
||||
using TravelCompanyContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace TravelCompany.Forms
|
||||
{
|
||||
@ -31,10 +29,7 @@ namespace TravelCompany.Forms
|
||||
{
|
||||
Dock = DockStyle.Fill
|
||||
};
|
||||
using (var fileStream = new FileStream("C:\\Users\\goldfest\\Desktop\\RPP\\TravelCompany\\TravelCompany\\ReportOrders.rdlc", FileMode.Open))
|
||||
{
|
||||
reportViewer.LocalReport.LoadReportDefinition(fileStream);
|
||||
}
|
||||
reportViewer.LocalReport.LoadReportDefinition(new FileStream("C:\\Users\\goldfest\\Desktop\\TravelCompany\\PrecastConcretePlant\\PrecastConcretePlantView\\ReportOrders.rdlc", FileMode.Open));
|
||||
Controls.Clear();
|
||||
Controls.Add(reportViewer);
|
||||
Controls.Add(panel);
|
||||
@ -42,7 +37,7 @@ namespace TravelCompany.Forms
|
||||
|
||||
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);
|
||||
return;
|
||||
@ -51,16 +46,16 @@ namespace TravelCompany.Forms
|
||||
{
|
||||
var dataSource = _logic.GetOrders(new ReportBindingModel
|
||||
{
|
||||
DateFrom = dateTimePickerFrom.Value,
|
||||
DateTo = dateTimePickerTo.Value
|
||||
DateFrom = dateTimePickerStart.Value,
|
||||
DateTo = dateTimePickerEnd.Value
|
||||
});
|
||||
var source = new ReportDataSource("DataSetOrders", dataSource);
|
||||
reportViewer.LocalReport.DataSources.Clear();
|
||||
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.RefreshReport();
|
||||
_logger.LogInformation("Загрузка списка заказов на период {From}-{ To}", dateTimePickerFrom.Value.ToShortDateString(), dateTimePickerTo.Value.ToShortDateString());
|
||||
_logger.LogInformation("Загрузка списка заказов на период {From}-{ To}", dateTimePickerStart.Value.ToShortDateString(), dateTimePickerEnd.Value.ToShortDateString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -73,7 +68,7 @@ namespace TravelCompany.Forms
|
||||
|
||||
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);
|
||||
return;
|
||||
@ -89,10 +84,10 @@ namespace TravelCompany.Forms
|
||||
_logic.SaveOrdersToPdfFile(new ReportBindingModel
|
||||
{
|
||||
FileName = dialog.FileName,
|
||||
DateFrom = dateTimePickerFrom.Value,
|
||||
DateTo = dateTimePickerTo.Value
|
||||
DateFrom = dateTimePickerStart.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);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -1,64 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<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.
|
||||
-->
|
||||
<root>
|
||||
<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:element name="root" msdata:IsDataSet="true">
|
||||
|
@ -72,7 +72,7 @@
|
||||
SaveButton.TabIndex = 1;
|
||||
SaveButton.Text = "Сохранить в Excel";
|
||||
SaveButton.UseVisualStyleBackColor = true;
|
||||
SaveButton.Click += SaveButton_Click;
|
||||
SaveButton.Click += ButtonSaveToExcel_Click;
|
||||
//
|
||||
// ReportTravelComponentForm
|
||||
//
|
||||
@ -83,7 +83,7 @@
|
||||
Controls.Add(dataGridView);
|
||||
Name = "ReportTravelComponentForm";
|
||||
Text = "Компоненты по мороженным";
|
||||
Load += ReportTravelComponentForm_Load;
|
||||
Load += FormReportTravelComponents_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
using TravelCompanyContracts.BindingModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using TravelCompanyContracts.BindingModels;
|
||||
using TravelCompanyContracts.BusinessLogicsContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
@ -18,78 +18,61 @@ namespace TravelCompany.Forms
|
||||
private readonly ILogger _logger;
|
||||
private readonly IReportLogic _logic;
|
||||
|
||||
public FormReportTravelComponents(ILogger<FormReportTravelComponents>
|
||||
logger, IReportLogic logic)
|
||||
public FormReportTravelComponents(ILogger<FormReportTravelComponents> logger, IReportLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
|
||||
}
|
||||
|
||||
private void ReportTravelComponentForm_Load(object sender, EventArgs e)
|
||||
private void FormReportTravelComponents_Load(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var dict = _logic.GetTravelComponent();
|
||||
var dict = _logic.GetTravelComponents();
|
||||
if (dict != null)
|
||||
{
|
||||
dataGridView.Rows.Clear();
|
||||
foreach (var elem in dict)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { elem.ComponentName,
|
||||
"", "" });
|
||||
foreach (var listElem in elem.Travels)
|
||||
dataGridView.Rows.Add(new object[] { elem.TravelName, "", "" });
|
||||
foreach (var listElem in elem.Components)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { "",
|
||||
listElem.Item1, listElem.Item2 });
|
||||
dataGridView.Rows.Add(new object[] { "", listElem.Item1, listElem.Item2 });
|
||||
}
|
||||
dataGridView.Rows.Add(new object[] { "Итого", "",
|
||||
elem.TotalCount });
|
||||
dataGridView.Rows.Add(new object[] { "Итого", "", elem.TotalCount });
|
||||
dataGridView.Rows.Add(Array.Empty<object>());
|
||||
}
|
||||
}
|
||||
_logger.LogInformation("Загрузка списка мороженных по компонентам");
|
||||
_logger.LogInformation("Загрузка списка изделий по компонентам");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки списка мороженных по компонентам");
|
||||
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
_logger.LogError(ex, "Ошибка загрузки списка изделий по компонентам");
|
||||
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
|
||||
{
|
||||
Filter = "xlsx|*.xlsx"
|
||||
};
|
||||
using var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" };
|
||||
if (dialog.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logic.SaveTravelComponentToExcelFile(new
|
||||
ReportBindingModel
|
||||
_logic.SaveTravelComponentToExcelFile(new ReportBindingModel
|
||||
{
|
||||
FileName = dialog.FileName
|
||||
});
|
||||
_logger.LogInformation("Сохранение списка мороженных по компонентам");
|
||||
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
_logger.LogInformation("Сохранение списка изделий по компонентам");
|
||||
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения списка мороженных по компонентам");
|
||||
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
_logger.LogError(ex, "Ошибка сохранения списка изделий по компонентам");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -212,7 +212,7 @@
|
||||
<Paragraph>
|
||||
<TextRuns>
|
||||
<TextRun>
|
||||
<Value>Путёвки</Value>
|
||||
<Value>Железные изделия</Value>
|
||||
<Style>
|
||||
<FontWeight>Bold</FontWeight>
|
||||
</Style>
|
||||
@ -428,7 +428,7 @@
|
||||
</TablixCell>
|
||||
<TablixCell>
|
||||
<CellContents>
|
||||
<Textbox Name="OrderStatus">
|
||||
<Textbox Name="Status">
|
||||
<CanGrow>true</CanGrow>
|
||||
<KeepTogether>true</KeepTogether>
|
||||
<Paragraphs>
|
||||
@ -442,7 +442,7 @@
|
||||
<Style />
|
||||
</Paragraph>
|
||||
</Paragraphs>
|
||||
<rd:DefaultName>OrderStatus</rd:DefaultName>
|
||||
<rd:DefaultName>Status</rd:DefaultName>
|
||||
<Style>
|
||||
<Border>
|
||||
<Color>LightGrey</Color>
|
||||
|
@ -10,69 +10,58 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
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
|
||||
{
|
||||
public class ReportLogic : IReportLogic
|
||||
{
|
||||
private readonly IComponentStorage _componentStorage;
|
||||
private readonly ITravelStorage _productStorage;
|
||||
private readonly ITravelStorage _TravelStorage;
|
||||
private readonly IOrderStorage _orderStorage;
|
||||
private readonly AbstractSaveToExcel _saveToExcel;
|
||||
private readonly AbstractSaveToWord _saveToWord;
|
||||
private readonly AbstractSaveToPdf _saveToPdf;
|
||||
public ReportLogic(ITravelStorage productStorage, IComponentStorage
|
||||
componentStorage, IOrderStorage orderStorage,
|
||||
AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord,
|
||||
AbstractSaveToPdf saveToPdf)
|
||||
public ReportLogic(ITravelStorage TravelStorage, IComponentStorage componentStorage, IOrderStorage orderStorage, AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
|
||||
{
|
||||
_productStorage = productStorage;
|
||||
_TravelStorage = TravelStorage;
|
||||
_componentStorage = componentStorage;
|
||||
_orderStorage = orderStorage;
|
||||
_saveToExcel = saveToExcel;
|
||||
_saveToWord = saveToWord;
|
||||
_saveToPdf = saveToPdf;
|
||||
}
|
||||
public List<ReportTravelComponentViewModel> GetTravelComponent()
|
||||
|
||||
public List<ReportTravelComponentViewModel> GetTravelComponents()
|
||||
{
|
||||
var components = _componentStorage.GetFullList();
|
||||
var products = _productStorage.GetFullList();
|
||||
var Travels = _TravelStorage.GetFullList();
|
||||
var list = new List<ReportTravelComponentViewModel>();
|
||||
foreach (var component in components)
|
||||
foreach (var Travel in Travels)
|
||||
{
|
||||
var record = new ReportTravelComponentViewModel
|
||||
{
|
||||
ComponentName = component.ComponentName,
|
||||
Travels = new List<Tuple<string, int>>(),
|
||||
TravelName = Travel.TravelName,
|
||||
Components = new List<(string Component, int Count)>(),
|
||||
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,
|
||||
int>(travel.TravelName, travel.TravelComponents[component.Id].Item2));
|
||||
record.TotalCount +=
|
||||
travel.TravelComponents[component.Id].Item2;
|
||||
record.Components.Add(new(component.ComponentName, Travel.TravelComponents[component.Id].Item2));
|
||||
record.TotalCount += Travel.TravelComponents[component.Id].Item2;
|
||||
}
|
||||
}
|
||||
list.Add(record);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<ReportOrdersViewModel> GetOrders(ReportBindingModel model)
|
||||
{
|
||||
return _orderStorage.GetFilteredList(new OrderSearchModel
|
||||
{
|
||||
DateFrom
|
||||
= model.DateFrom,
|
||||
DateFrom = model.DateFrom,
|
||||
DateTo = model.DateTo
|
||||
})
|
||||
.Select(x => new ReportOrdersViewModel
|
||||
@ -80,17 +69,19 @@ namespace TravelCompanyBusinessLogic.BusinessLogic
|
||||
Id = x.Id,
|
||||
DateCreate = x.DateCreate,
|
||||
TravelName = x.TravelName,
|
||||
Sum = x.Sum
|
||||
Sum = x.Sum,
|
||||
Status = x.Status.ToString(),
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
public void SaveComponentsToWordFile(ReportBindingModel model)
|
||||
|
||||
public void SaveTravelsToWordFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToWord.CreateDoc(new WordInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список компонент",
|
||||
Components = _componentStorage.GetFullList()
|
||||
Title = "Список ЖИ",
|
||||
Travels = _TravelStorage.GetFullList()
|
||||
});
|
||||
}
|
||||
public void SaveTravelComponentToExcelFile(ReportBindingModel model)
|
||||
@ -98,10 +89,11 @@ namespace TravelCompanyBusinessLogic.BusinessLogic
|
||||
_saveToExcel.CreateReport(new ExcelInfo
|
||||
{
|
||||
FileName = model.FileName,
|
||||
Title = "Список компонент",
|
||||
TravelComponents = GetTravelComponent()
|
||||
Title = "Список ЖИ",
|
||||
TravelComponents = GetTravelComponents()
|
||||
});
|
||||
}
|
||||
|
||||
public void SaveOrdersToPdfFile(ReportBindingModel model)
|
||||
{
|
||||
_saveToPdf.CreateDoc(new PdfInfo
|
||||
@ -113,5 +105,6 @@ namespace TravelCompanyBusinessLogic.BusinessLogic
|
||||
Orders = GetOrders(model)
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -32,11 +32,11 @@ namespace TravelCompanyBusinessLogic.OfficePackage
|
||||
{
|
||||
ColumnName = "A",
|
||||
RowIndex = rowIndex,
|
||||
Text = pc.ComponentName,
|
||||
Text = pc.TravelName,
|
||||
StyleInfo = ExcelStyleInfoType.Text
|
||||
});
|
||||
rowIndex++;
|
||||
foreach (var Travel in pc.Travels)
|
||||
foreach (var Travel in pc.Components)
|
||||
{
|
||||
InsertCellInWorksheet(new ExcelCellParameters
|
||||
{
|
||||
|
@ -16,21 +16,19 @@ namespace TravelCompanyBusinessLogic.OfficePackage
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = info.Title,
|
||||
Style =
|
||||
"NormalTitle",
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
CreateParagraph(new PdfParagraph
|
||||
{
|
||||
Text = $"с { info.DateFrom.ToShortDateString() } по { info.DateTo.ToShortDateString() }", Style
|
||||
= "Normal",
|
||||
Text = $"с{info.DateFrom.ToShortDateString()} по {info.DateTo.ToShortDateString()}",
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm" });
|
||||
CreateTable(new List<string> { "2cm", "3cm", "6cm", "3cm", "4cm" });
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { "Номер", "Дата заказа", "Изделие",
|
||||
"Сумма" },
|
||||
Texts = new List<string> { "Номер", "Дата заказа", "Изделие", "Сумма", "Статус" },
|
||||
Style = "NormalTitle",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Center
|
||||
});
|
||||
@ -38,8 +36,7 @@ namespace TravelCompanyBusinessLogic.OfficePackage
|
||||
{
|
||||
CreateRow(new PdfRowParameters
|
||||
{
|
||||
Texts = new List<string> { order.Id.ToString(),
|
||||
order.DateCreate.ToShortDateString(), order.TravelName, order.Sum.ToString() },
|
||||
Texts = new List<string> { order.Id.ToString(), order.DateCreate.ToShortDateString(), order.TravelName, order.Sum.ToString(), order.Status },
|
||||
Style = "Normal",
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Left
|
||||
});
|
||||
@ -48,16 +45,15 @@ order.DateCreate.ToShortDateString(), order.TravelName, order.Sum.ToString() },
|
||||
{
|
||||
Text = $"Итого: {info.Orders.Sum(x => x.Sum)}\t",
|
||||
Style = "Normal",
|
||||
ParagraphAlignment =
|
||||
PdfParagraphAlignmentType.Rigth
|
||||
ParagraphAlignment = PdfParagraphAlignmentType.Right
|
||||
});
|
||||
SavePdf(info);
|
||||
}
|
||||
|
||||
protected abstract void CreatePdf(PdfInfo info);
|
||||
protected abstract void CreateParagraph(PdfParagraph paragraph);
|
||||
protected abstract void CreateTable(List<string> columns);
|
||||
protected abstract void CreateRow(PdfRowParameters rowParameters);
|
||||
protected abstract void SavePdf(PdfInfo info);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -23,12 +23,12 @@ WordTextProperties { Bold = true, Size = "24", }) },
|
||||
JustificationType = WordJustificationType.Center
|
||||
}
|
||||
});
|
||||
foreach (var component in info.Components)
|
||||
foreach (var component in info.Travels)
|
||||
{
|
||||
CreateParagraph(new WordParagraph
|
||||
{
|
||||
Texts = new List<(string, WordTextProperties)> {
|
||||
(component.ComponentName, new WordTextProperties { Size = "24", }) },
|
||||
(component.TravelName, new WordTextProperties { Size = "24", }) },
|
||||
TextProperties = new WordTextProperties
|
||||
{
|
||||
Size = "24",
|
||||
|
@ -10,6 +10,6 @@ namespace TravelCompanyBusinessLogic.OfficePackage.HelperEnums
|
||||
{
|
||||
Center,
|
||||
Left,
|
||||
Rigth
|
||||
Right
|
||||
}
|
||||
}
|
||||
|
@ -11,6 +11,6 @@ namespace TravelCompanyBusinessLogic.OfficePackage.HelperModels
|
||||
{
|
||||
public string FileName { 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();
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ namespace TravelCompanyBusinessLogic.OfficePackage.Implements
|
||||
{
|
||||
PdfParagraphAlignmentType.Center => ParagraphAlignment.Center,
|
||||
PdfParagraphAlignmentType.Left => ParagraphAlignment.Left,
|
||||
PdfParagraphAlignmentType.Rigth => ParagraphAlignment.Right,
|
||||
PdfParagraphAlignmentType.Right => ParagraphAlignment.Right,
|
||||
_ => ParagraphAlignment.Justify,
|
||||
};
|
||||
}
|
||||
|
@ -10,9 +10,9 @@ namespace TravelCompanyContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IReportLogic
|
||||
{
|
||||
List<ReportTravelComponentViewModel> GetTravelComponent();
|
||||
List<ReportTravelComponentViewModel> GetTravelComponents();
|
||||
List<ReportOrdersViewModel> GetOrders(ReportBindingModel model);
|
||||
void SaveComponentsToWordFile(ReportBindingModel model);
|
||||
void SaveTravelsToWordFile(ReportBindingModel model);
|
||||
void SaveTravelComponentToExcelFile(ReportBindingModel model);
|
||||
void SaveOrdersToPdfFile(ReportBindingModel model);
|
||||
}
|
||||
|
@ -11,9 +11,8 @@ namespace TravelCompanyContracts.ViewModels
|
||||
public int Id { get; set; }
|
||||
public DateTime DateCreate { get; set; }
|
||||
public string TravelName { get; set; } = string.Empty;
|
||||
public string OrderStatus { get; set; } = string.Empty;
|
||||
|
||||
public double Sum { get; set; }
|
||||
public string Status { get; set; } = string.Empty;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -8,9 +8,10 @@ namespace TravelCompanyContracts.ViewModels
|
||||
{
|
||||
public class ReportTravelComponentViewModel
|
||||
{
|
||||
public string ComponentName { get; set; } = string.Empty;
|
||||
public string TravelName { get; set; } = string.Empty;
|
||||
public int TotalCount { get; set; }
|
||||
public List<Tuple<string, int>> Travels { get; set; } = new();
|
||||
public List<(string Component, int Count)> Components { get; set; } = new();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user