Отчёт excel

This commit is contained in:
ujijrujijr 2024-06-14 16:56:48 +04:00
parent 2e66e6e59f
commit 576a486a40
16 changed files with 752 additions and 27 deletions

View File

@ -47,6 +47,8 @@
textileComponentsToolStripMenuItem = new ToolStripMenuItem();
ordersToolStripMenuItem = new ToolStripMenuItem();
магазиныВDocToolStripMenuItem = new ToolStripMenuItem();
загруженностьМагазиновToolStripMenuItem = new ToolStripMenuItem();
заказыПоДатамToolStripMenuItem = new ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
menuStrip1.SuspendLayout();
SuspendLayout();
@ -183,7 +185,7 @@
//
// отчётыToolStripMenuItem
//
отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { textilesToolStripMenuItem, textileComponentsToolStripMenuItem, ordersToolStripMenuItem, магазиныВDocToolStripMenuItem });
отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { textilesToolStripMenuItem, textileComponentsToolStripMenuItem, ordersToolStripMenuItem, магазиныВDocToolStripMenuItem, загруженностьМагазиновToolStripMenuItem, заказыПоДатамToolStripMenuItem });
отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
отчётыToolStripMenuItem.Size = new Size(73, 24);
отчётыToolStripMenuItem.Text = "Отчёты";
@ -191,31 +193,45 @@
// textilesToolStripMenuItem
//
textilesToolStripMenuItem.Name = "textilesToolStripMenuItem";
textilesToolStripMenuItem.Size = new Size(274, 26);
textilesToolStripMenuItem.Size = new Size(276, 26);
textilesToolStripMenuItem.Text = "Текстили";
textilesToolStripMenuItem.Click += TextilesToolStripMenuItem_Click;
//
// textileComponentsToolStripMenuItem
//
textileComponentsToolStripMenuItem.Name = "textileComponentsToolStripMenuItem";
textileComponentsToolStripMenuItem.Size = new Size(274, 26);
textileComponentsToolStripMenuItem.Size = new Size(276, 26);
textileComponentsToolStripMenuItem.Text = "Текстили с компонентами";
textileComponentsToolStripMenuItem.Click += ComponentTextilesToolStripMenuItem_Click;
//
// ordersToolStripMenuItem
//
ordersToolStripMenuItem.Name = "ordersToolStripMenuItem";
ordersToolStripMenuItem.Size = new Size(274, 26);
ordersToolStripMenuItem.Size = new Size(276, 26);
ordersToolStripMenuItem.Text = "Заказы";
ordersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click;
//
// магазиныВDocToolStripMenuItem
//
магазиныВDocToolStripMenuItem.Name = агазиныВDocToolStripMenuItem";
магазиныВDocToolStripMenuItem.Size = new Size(274, 26);
магазиныВDocToolStripMenuItem.Size = new Size(276, 26);
магазиныВDocToolStripMenuItem.Text = "Магазины в doc";
магазиныВDocToolStripMenuItem.Click += магазиныВDocToolStripMenuItem_Click;
//
// загруженностьМагазиновToolStripMenuItem
//
загруженностьМагазиновToolStripMenuItem.Name = агруженностьМагазиновToolStripMenuItem";
загруженностьМагазиновToolStripMenuItem.Size = new Size(276, 26);
загруженностьМагазиновToolStripMenuItem.Text = "Загруженность магазинов";
загруженностьМагазиновToolStripMenuItem.Click += загруженностьМагазиновToolStripMenuItem_Click;
//
// заказыПоДатамToolStripMenuItem
//
заказыПоДатамToolStripMenuItem.Name = аказыПоДатамToolStripMenuItem";
заказыПоДатамToolStripMenuItem.Size = new Size(276, 26);
заказыПоДатамToolStripMenuItem.Text = "Заказы по датам";
заказыПоДатамToolStripMenuItem.Click += заказыПоДатамToolStripMenuItem_Click;
//
// FormMain
//
AutoScaleDimensions = new SizeF(8F, 20F);
@ -260,5 +276,7 @@
private ToolStripMenuItem textileComponentsToolStripMenuItem;
private ToolStripMenuItem ordersToolStripMenuItem;
private ToolStripMenuItem магазиныВDocToolStripMenuItem;
private ToolStripMenuItem загруженностьМагазиновToolStripMenuItem;
private ToolStripMenuItem заказыПоДатамToolStripMenuItem;
}
}

View File

@ -221,5 +221,23 @@ namespace GarmentFactoryView
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void загруженностьМагазиновToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormReportShops));
if (service is FormReportShops form)
{
form.ShowDialog();
}
}
private void заказыПоДатамToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormReportGroupedOrders));
if (service is FormReportGroupedOrders form)
{
form.ShowDialog();
}
}
}
}

View File

@ -0,0 +1,86 @@
namespace GarmentFactoryView
{
partial class FormReportGroupedOrders
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.panel = new System.Windows.Forms.Panel();
this.buttonToPDF = new System.Windows.Forms.Button();
this.buttonMake = new System.Windows.Forms.Button();
this.panel.SuspendLayout();
this.SuspendLayout();
//
// panel
//
this.panel.Controls.Add(this.buttonToPDF);
this.panel.Controls.Add(this.buttonMake);
this.panel.Dock = System.Windows.Forms.DockStyle.Top;
this.panel.Location = new System.Drawing.Point(0, 0);
this.panel.Name = "panel";
this.panel.Size = new System.Drawing.Size(970, 52);
this.panel.TabIndex = 1;
//
// buttonToPDF
//
this.buttonToPDF.Location = new System.Drawing.Point(486, 12);
this.buttonToPDF.Name = "buttonToPDF";
this.buttonToPDF.Size = new System.Drawing.Size(411, 29);
this.buttonToPDF.TabIndex = 5;
this.buttonToPDF.Text = "В PDF";
this.buttonToPDF.UseVisualStyleBackColor = true;
this.buttonToPDF.Click += new System.EventHandler(this.buttonToPDF_Click);
//
// buttonMake
//
this.buttonMake.Location = new System.Drawing.Point(49, 12);
this.buttonMake.Name = "buttonMake";
this.buttonMake.Size = new System.Drawing.Size(377, 29);
this.buttonMake.TabIndex = 4;
this.buttonMake.Text = "Сформировать";
this.buttonMake.UseVisualStyleBackColor = true;
this.buttonMake.Click += new System.EventHandler(this.ButtonMake_Click);
//
// FormReportGroupedOrders
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(970, 450);
this.Controls.Add(this.panel);
this.Name = "FormReportGroupedOrders";
this.Text = "Отчёт по группированным заказам ";
this.panel.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private Panel panel;
private Button buttonToPDF;
private Button buttonMake;
}
}

View File

@ -0,0 +1,80 @@
using GarmentFactoryContracts.BindingModels;
using GarmentFactoryContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
using Microsoft.Reporting.WinForms;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace GarmentFactoryView
{
public partial class FormReportGroupedOrders : Form
{
private readonly ReportViewer reportViewer;
private readonly ILogger _logger;
private readonly IReportLogic _logic;
public FormReportGroupedOrders(ILogger<FormReportGroupedOrders> logger, IReportLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
reportViewer = new ReportViewer
{
Dock = DockStyle.Fill
};
reportViewer.LocalReport.LoadReportDefinition(new FileStream("ReportGroupedOrders.rdlc", FileMode.Open));
Controls.Clear();
Controls.Add(reportViewer);
Controls.Add(panel);
}
private void ButtonMake_Click(object sender, EventArgs e)
{
try
{
var dataSource = _logic.GetGroupedOrders();
var source = new ReportDataSource("DataSetGroupedOrders", dataSource);
reportViewer.LocalReport.DataSources.Clear();
reportViewer.LocalReport.DataSources.Add(source);
reportViewer.RefreshReport();
_logger.LogInformation("Загрузка списка группированных заказов");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки списка группированных заказов на период");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonToPDF_Click(object sender, EventArgs e)
{
using var dialog = new SaveFileDialog { Filter = "pdf|*.pdf" };
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
_logic.SaveGroupedOrdersToPdfFile(new ReportBindingModel
{
FileName = dialog.FileName,
});
_logger.LogInformation("Сохранение списка группированных заказов");
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения списка группированных заказов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}

View File

@ -0,0 +1,120 @@
<?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.
-->
<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">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

112
GarmentFactory/FormReportShops.Designer.cs generated Normal file
View File

@ -0,0 +1,112 @@
namespace GarmentFactoryView
{
partial class FormReportShops
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
buttonSaveToExcel = new Button();
dataGridView = new DataGridView();
ColumnShop = new DataGridViewTextBoxColumn();
ColumnTextile = new DataGridViewTextBoxColumn();
ColumnCount = new DataGridViewTextBoxColumn();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// buttonSaveToExcel
//
buttonSaveToExcel.Location = new Point(12, 9);
buttonSaveToExcel.Name = "buttonSaveToExcel";
buttonSaveToExcel.Size = new Size(169, 29);
buttonSaveToExcel.TabIndex = 3;
buttonSaveToExcel.Text = "Сохранить в Excel";
buttonSaveToExcel.UseVisualStyleBackColor = true;
buttonSaveToExcel.Click += ButtonSaveToExcel_Click;
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToOrderColumns = true;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnShop, ColumnTextile, ColumnCount });
dataGridView.Dock = DockStyle.Bottom;
dataGridView.Location = new Point(0, 47);
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersWidth = 51;
dataGridView.RowTemplate.Height = 29;
dataGridView.Size = new Size(598, 403);
dataGridView.TabIndex = 2;
//
// ColumnShop
//
ColumnShop.FillWeight = 130F;
ColumnShop.HeaderText = "Магазин";
ColumnShop.MinimumWidth = 6;
ColumnShop.Name = "ColumnShop";
ColumnShop.ReadOnly = true;
//
// ColumnTextile
//
ColumnTextile.FillWeight = 140F;
ColumnTextile.HeaderText = "Текстиль";
ColumnTextile.MinimumWidth = 6;
ColumnTextile.Name = "ColumnTextile";
ColumnTextile.ReadOnly = true;
//
// ColumnCount
//
ColumnCount.FillWeight = 90F;
ColumnCount.HeaderText = "Количество";
ColumnCount.MinimumWidth = 6;
ColumnCount.Name = "ColumnCount";
ColumnCount.ReadOnly = true;
//
// FormReportShops
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(598, 450);
Controls.Add(buttonSaveToExcel);
Controls.Add(dataGridView);
Name = "FormReportShops";
Text = "Загруженность магазинов";
Load += FormReportShops_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Button buttonSaveToExcel;
private DataGridView dataGridView;
private DataGridViewTextBoxColumn ColumnShop;
private DataGridViewTextBoxColumn ColumnTextile;
private DataGridViewTextBoxColumn ColumnCount;
}
}

View File

@ -0,0 +1,78 @@
using GarmentFactoryContracts.BindingModels;
using GarmentFactoryContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace GarmentFactoryView
{
public partial class FormReportShops : Form
{
private readonly ILogger _logger;
private readonly IReportLogic _logic;
public FormReportShops(ILogger<FormReportShops> logger, IReportLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void FormReportShops_Load(object sender, EventArgs e)
{
try
{
var shops = _logic.GetShops();
if (shops != null)
{
dataGridView.Rows.Clear();
foreach (var shop in shops)
{
dataGridView.Rows.Add(new object[] { shop.ShopName, "", "" });
foreach (var textile in shop.Textiles)
{
dataGridView.Rows.Add(new object[] { "", textile.Item1, textile.Item2 });
}
dataGridView.Rows.Add(new object[] { "Итого", "", shop.TotalCount });
dataGridView.Rows.Add(Array.Empty<object>());
}
}
_logger.LogInformation("Загрузка списка текстилей по магазинам");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки списка текстилей по магазинам");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonSaveToExcel_Click(object sender, EventArgs e)
{
using var dialog = new SaveFileDialog { Filter = "xlsx|*.xlsx" };
if (dialog.ShowDialog() == DialogResult.OK)
{
try
{
_logic.SaveShopsToExcelFile(new ReportBindingModel
{
FileName = dialog.FileName
});
_logger.LogInformation("Сохранение списка текстилей по магазинам");
MessageBox.Show("Выполнено", "Успех", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка сохранения списка текстилей по магазинам");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}

View File

@ -0,0 +1,120 @@
<?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.
-->
<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">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -67,6 +67,8 @@ namespace GarmentFactory
services.AddTransient<FormReportTextileComponents>();
services.AddTransient<FormReportOrders>();
services.AddTransient<FormReportShops>();
services.AddTransient<FormReportGroupedOrders>();
}
}
}

View File

@ -140,15 +140,15 @@ namespace GarmentFactoryBusinessLogic.BusinessLogics
});
}
//public void SaveShopsToExcelFile(ReportBindingModel model)
//{
// _saveToExcel.CreateShopTextilesReport(new ExcelShop
// {
// FileName = model.FileName,
// Title = "Наполненость магазинов",
// ShopTextiles = GetShops()
// });
//}
public void SaveShopsToExcelFile(ReportBindingModel model)
{
_saveToExcel.CreateShopTextilesReport(new ExcelShopInfo
{
FileName = model.FileName,
Title = "Загруженность магазинов",
ShopTextiles = GetShops()
});
}
//public void SaveGroupedOrdersToPdfFile(ReportBindingModel model)
//{

View File

@ -80,9 +80,82 @@ namespace GarmentFactoryBusinessLogic.OfficePackage
SaveExcel(info);
}
protected abstract void CreateExcel(ExcelInfo info);
public void CreateShopTextilesReport(ExcelShopInfo info)
{
CreateExcel(info);
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = 1,
Text = info.Title,
StyleInfo = ExcelStyleInfoType.Title
});
MergeCells(new ExcelMergeParameters
{
CellFromName = "A1",
CellToName = "C1"
});
uint rowIndex = 2;
foreach (var shop_textile in info.ShopTextiles)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
Text = shop_textile.ShopName,
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
foreach (var (textile, count) in shop_textile.Textiles)
{
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "B",
RowIndex = rowIndex,
Text = textile,
StyleInfo = ExcelStyleInfoType.TextWithBorder
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
Text = count.ToString(),
StyleInfo = ExcelStyleInfoType.TextWithBorder
});
rowIndex++;
}
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "A",
RowIndex = rowIndex,
Text = "Итого",
StyleInfo = ExcelStyleInfoType.Text
});
InsertCellInWorksheet(new ExcelCellParameters
{
ColumnName = "C",
RowIndex = rowIndex,
Text = shop_textile.TotalCount.ToString(),
StyleInfo = ExcelStyleInfoType.Text
});
rowIndex++;
}
SaveExcel(info);
}
protected abstract void CreateExcel(IDocumentInfo info);
protected abstract void InsertCellInWorksheet(ExcelCellParameters excelParams);
protected abstract void MergeCells(ExcelMergeParameters excelParams);
protected abstract void SaveExcel(ExcelInfo info);
protected abstract void SaveExcel(IDocumentInfo info);
}
}

View File

@ -7,7 +7,7 @@ using System.Threading.Tasks;
namespace GarmentFactoryBusinessLogic.OfficePackage.HelperModels
{
public class ExcelInfo
public class ExcelInfo : IDocumentInfo
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;

View File

@ -0,0 +1,16 @@
using GarmentFactoryContracts.ViewModels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace GarmentFactoryBusinessLogic.OfficePackage.HelperModels
{
public class ExcelShopInfo : IDocumentInfo
{
public string FileName { get; set; } = string.Empty;
public string Title { get; set; } = string.Empty;
public List<ReportShopsViewModel> ShopTextiles { get; set; } = new();
}
}

View File

@ -159,7 +159,7 @@ namespace GarmentFactoryBusinessLogic.OfficePackage.Implements
};
}
protected override void CreateExcel(ExcelInfo info)
protected override void CreateExcel(IDocumentInfo info)
{
_spreadsheetDocument = SpreadsheetDocument.Create(info.FileName, SpreadsheetDocumentType.Workbook);
// Создание книги (в ней хранятся листы)
@ -288,7 +288,7 @@ namespace GarmentFactoryBusinessLogic.OfficePackage.Implements
mergeCells.Append(mergeCell);
}
protected override void SaveExcel(ExcelInfo info)
protected override void SaveExcel(IDocumentInfo info)
{
if (_spreadsheetDocument == null)
{

View File

@ -136,13 +136,13 @@ namespace GarmentFactoryBusinessLogic.OfficePackage.Implements
_wordDocument.Close();
}
private Table? _lastTable;
private Table? _table;
protected override void CreateTable(List<string> columns)
{
if (_docBody == null)
return;
_lastTable = new Table();
_table = new Table();
var tableProp = new TableProperties();
tableProp.AppendChild(new TableLayout { Type = TableLayoutValues.Fixed });
@ -155,21 +155,21 @@ namespace GarmentFactoryBusinessLogic.OfficePackage.Implements
new InsideVerticalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 4 }
));
tableProp.AppendChild(new TableWidth { Type = TableWidthUnitValues.Auto });
_lastTable.AppendChild(tableProp);
_table.AppendChild(tableProp);
TableGrid tableGrid = new TableGrid();
foreach (var column in columns)
{
tableGrid.AppendChild(new GridColumn() { Width = column });
}
_lastTable.AppendChild(tableGrid);
_table.AppendChild(tableGrid);
_docBody.AppendChild(_lastTable);
_docBody.AppendChild(_table);
}
protected override void CreateRow(WordRowParameters rowParameters)
{
if (_docBody == null || _lastTable == null)
if (_docBody == null || _table == null)
return;
TableRow docRow = new TableRow();
@ -205,7 +205,7 @@ namespace GarmentFactoryBusinessLogic.OfficePackage.Implements
docCell.AppendChild(docParagraph);
docRow.AppendChild(docCell);
}
_lastTable.AppendChild(docRow);
_table.AppendChild(docRow);
}
}
}

View File

@ -14,6 +14,8 @@ namespace GarmentFactoryContracts.BusinessLogicsContracts
List<ReportOrdersViewModel> GetOrders(ReportBindingModel model);
List<ReportShopsViewModel> GetShops();
void SaveTextilesToWordFile(ReportBindingModel model);
void SaveTextileComponentToExcelFile(ReportBindingModel model);
@ -21,7 +23,7 @@ namespace GarmentFactoryContracts.BusinessLogicsContracts
void SaveOrdersToPdfFile(ReportBindingModel model);
void SaveShopsToWordFile(ReportBindingModel model);
//void SaveShopsToExcelFile(ReportBindingModel model);
void SaveShopsToExcelFile(ReportBindingModel model);
//void SaveGroupedOrdersToPdfFile(ReportBindingModel model);
}