В процессе
This commit is contained in:
parent
dc2a6f8486
commit
cc2cd308d9
@ -11,16 +11,16 @@ public class Employee
|
|||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
public DateTime Date { get; private set; }
|
public DateTime Date { get; private set; }
|
||||||
public int NumberStorage { get; private set; }
|
public int NumberStorage { get; private set; }
|
||||||
public int StorageSize { get; private set; }
|
//public int StorageSize { get; private set; }
|
||||||
|
|
||||||
public static Employee CreateEntity(int id, DateTime date,int numberStorage, int storageSize)
|
public static Employee CreateEntity(int id, DateTime date,int numberStorage)
|
||||||
{
|
{
|
||||||
return new Employee
|
return new Employee
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
Date = date,
|
Date = date,
|
||||||
NumberStorage = numberStorage,
|
NumberStorage = numberStorage,
|
||||||
StorageSize = storageSize
|
//StorageSize = storageSize
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
99
ShoeStore/Forms/FormDirectoryReport.Designer.cs
generated
Normal file
99
ShoeStore/Forms/FormDirectoryReport.Designer.cs
generated
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
namespace ShoeStore.Forms
|
||||||
|
{
|
||||||
|
partial class FormDirectoryReport
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
checkBoxProduct = new CheckBox();
|
||||||
|
buttonBuild = new Button();
|
||||||
|
checkBoxStorage = new CheckBox();
|
||||||
|
checkBoxEmployee = new CheckBox();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// checkBoxProduct
|
||||||
|
//
|
||||||
|
checkBoxProduct.AutoSize = true;
|
||||||
|
checkBoxProduct.Location = new Point(49, 45);
|
||||||
|
checkBoxProduct.Name = "checkBoxProduct";
|
||||||
|
checkBoxProduct.Size = new Size(72, 19);
|
||||||
|
checkBoxProduct.TabIndex = 0;
|
||||||
|
checkBoxProduct.Text = "Продукт";
|
||||||
|
checkBoxProduct.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// buttonBuild
|
||||||
|
//
|
||||||
|
buttonBuild.Location = new Point(216, 83);
|
||||||
|
buttonBuild.Name = "buttonBuild";
|
||||||
|
buttonBuild.Size = new Size(165, 48);
|
||||||
|
buttonBuild.TabIndex = 1;
|
||||||
|
buttonBuild.Text = "Сформировать";
|
||||||
|
buttonBuild.UseVisualStyleBackColor = true;
|
||||||
|
buttonBuild.Click += buttonBuild_Click;
|
||||||
|
//
|
||||||
|
// checkBoxStorage
|
||||||
|
//
|
||||||
|
checkBoxStorage.AutoSize = true;
|
||||||
|
checkBoxStorage.Location = new Point(49, 99);
|
||||||
|
checkBoxStorage.Name = "checkBoxStorage";
|
||||||
|
checkBoxStorage.Size = new Size(59, 19);
|
||||||
|
checkBoxStorage.TabIndex = 2;
|
||||||
|
checkBoxStorage.Text = "Склад";
|
||||||
|
checkBoxStorage.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// checkBoxEmployee
|
||||||
|
//
|
||||||
|
checkBoxEmployee.AutoSize = true;
|
||||||
|
checkBoxEmployee.Location = new Point(49, 153);
|
||||||
|
checkBoxEmployee.Name = "checkBoxEmployee";
|
||||||
|
checkBoxEmployee.Size = new Size(85, 19);
|
||||||
|
checkBoxEmployee.TabIndex = 3;
|
||||||
|
checkBoxEmployee.Text = "Сотрудник";
|
||||||
|
checkBoxEmployee.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// FormDirectoryReport
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(431, 229);
|
||||||
|
Controls.Add(checkBoxEmployee);
|
||||||
|
Controls.Add(checkBoxStorage);
|
||||||
|
Controls.Add(buttonBuild);
|
||||||
|
Controls.Add(checkBoxProduct);
|
||||||
|
Name = "FormDirectoryReport";
|
||||||
|
Text = "FormDirectoryReport";
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private CheckBox checkBoxProduct;
|
||||||
|
private Button buttonBuild;
|
||||||
|
private CheckBox checkBoxStorage;
|
||||||
|
private CheckBox checkBoxEmployee;
|
||||||
|
}
|
||||||
|
}
|
64
ShoeStore/Forms/FormDirectoryReport.cs
Normal file
64
ShoeStore/Forms/FormDirectoryReport.cs
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
using ShoeStore.Reports;
|
||||||
|
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;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
|
namespace ShoeStore.Forms
|
||||||
|
{
|
||||||
|
public partial class FormDirectoryReport : Form
|
||||||
|
{
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
public FormDirectoryReport(IUnityContainer container)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonBuild_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!checkBoxProduct.Checked &&
|
||||||
|
!checkBoxStorage.Checked && !checkBoxEmployee.Checked)
|
||||||
|
{
|
||||||
|
throw new Exception("Не выбран ни один справочник для выгрузки");
|
||||||
|
}
|
||||||
|
var sfd = new SaveFileDialog()
|
||||||
|
{
|
||||||
|
Filter = "Docx Files | *.docx"
|
||||||
|
};
|
||||||
|
if (sfd.ShowDialog() != DialogResult.OK)
|
||||||
|
{
|
||||||
|
throw new Exception("Не выбран файла для отчета");
|
||||||
|
}
|
||||||
|
if
|
||||||
|
(_container.Resolve<DocReport>().CreateDoc(sfd.FileName, checkBoxProduct.Checked,
|
||||||
|
checkBoxStorage.Checked,
|
||||||
|
checkBoxEmployee.Checked))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Документ сформирован",
|
||||||
|
"Формирование документа",
|
||||||
|
MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах",
|
||||||
|
"Формирование документа",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при создании отчета", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
ShoeStore/Forms/FormDirectoryReport.resx
Normal file
120
ShoeStore/Forms/FormDirectoryReport.resx
Normal 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>
|
30
ShoeStore/Forms/FormEmployee.Designer.cs
generated
30
ShoeStore/Forms/FormEmployee.Designer.cs
generated
@ -31,13 +31,10 @@
|
|||||||
dateTimePickerDate = new DateTimePicker();
|
dateTimePickerDate = new DateTimePicker();
|
||||||
label1 = new Label();
|
label1 = new Label();
|
||||||
label2 = new Label();
|
label2 = new Label();
|
||||||
label3 = new Label();
|
|
||||||
numericUpDownNumStorage = new NumericUpDown();
|
numericUpDownNumStorage = new NumericUpDown();
|
||||||
numericUpDownStorageSize = new NumericUpDown();
|
|
||||||
buttonSave = new Button();
|
buttonSave = new Button();
|
||||||
buttonCancel = new Button();
|
buttonCancel = new Button();
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownNumStorage).BeginInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDownNumStorage).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownStorageSize).BeginInit();
|
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// dateTimePickerDate
|
// dateTimePickerDate
|
||||||
@ -65,15 +62,6 @@
|
|||||||
label2.TabIndex = 2;
|
label2.TabIndex = 2;
|
||||||
label2.Text = "Номер склада:";
|
label2.Text = "Номер склада:";
|
||||||
//
|
//
|
||||||
// label3
|
|
||||||
//
|
|
||||||
label3.AutoSize = true;
|
|
||||||
label3.Location = new Point(40, 178);
|
|
||||||
label3.Name = "label3";
|
|
||||||
label3.Size = new Size(106, 15);
|
|
||||||
label3.TabIndex = 3;
|
|
||||||
label3.Text = "Размер на складе:";
|
|
||||||
//
|
|
||||||
// numericUpDownNumStorage
|
// numericUpDownNumStorage
|
||||||
//
|
//
|
||||||
numericUpDownNumStorage.Location = new Point(179, 107);
|
numericUpDownNumStorage.Location = new Point(179, 107);
|
||||||
@ -81,16 +69,9 @@
|
|||||||
numericUpDownNumStorage.Size = new Size(132, 23);
|
numericUpDownNumStorage.Size = new Size(132, 23);
|
||||||
numericUpDownNumStorage.TabIndex = 4;
|
numericUpDownNumStorage.TabIndex = 4;
|
||||||
//
|
//
|
||||||
// numericUpDownStorageSize
|
|
||||||
//
|
|
||||||
numericUpDownStorageSize.Location = new Point(179, 176);
|
|
||||||
numericUpDownStorageSize.Name = "numericUpDownStorageSize";
|
|
||||||
numericUpDownStorageSize.Size = new Size(132, 23);
|
|
||||||
numericUpDownStorageSize.TabIndex = 5;
|
|
||||||
//
|
|
||||||
// buttonSave
|
// buttonSave
|
||||||
//
|
//
|
||||||
buttonSave.Location = new Point(40, 251);
|
buttonSave.Location = new Point(40, 198);
|
||||||
buttonSave.Name = "buttonSave";
|
buttonSave.Name = "buttonSave";
|
||||||
buttonSave.Size = new Size(106, 23);
|
buttonSave.Size = new Size(106, 23);
|
||||||
buttonSave.TabIndex = 6;
|
buttonSave.TabIndex = 6;
|
||||||
@ -100,7 +81,7 @@
|
|||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
buttonCancel.Location = new Point(205, 251);
|
buttonCancel.Location = new Point(205, 198);
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(106, 23);
|
buttonCancel.Size = new Size(106, 23);
|
||||||
buttonCancel.TabIndex = 7;
|
buttonCancel.TabIndex = 7;
|
||||||
@ -112,19 +93,16 @@
|
|||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(352, 316);
|
ClientSize = new Size(352, 276);
|
||||||
Controls.Add(buttonCancel);
|
Controls.Add(buttonCancel);
|
||||||
Controls.Add(buttonSave);
|
Controls.Add(buttonSave);
|
||||||
Controls.Add(numericUpDownStorageSize);
|
|
||||||
Controls.Add(numericUpDownNumStorage);
|
Controls.Add(numericUpDownNumStorage);
|
||||||
Controls.Add(label3);
|
|
||||||
Controls.Add(label2);
|
Controls.Add(label2);
|
||||||
Controls.Add(label1);
|
Controls.Add(label1);
|
||||||
Controls.Add(dateTimePickerDate);
|
Controls.Add(dateTimePickerDate);
|
||||||
Name = "FormEmployee";
|
Name = "FormEmployee";
|
||||||
Text = "Сотрудник";
|
Text = "Сотрудник";
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownNumStorage).EndInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDownNumStorage).EndInit();
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownStorageSize).EndInit();
|
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
@ -134,9 +112,7 @@
|
|||||||
private DateTimePicker dateTimePickerDate;
|
private DateTimePicker dateTimePickerDate;
|
||||||
private Label label1;
|
private Label label1;
|
||||||
private Label label2;
|
private Label label2;
|
||||||
private Label label3;
|
|
||||||
private NumericUpDown numericUpDownNumStorage;
|
private NumericUpDown numericUpDownNumStorage;
|
||||||
private NumericUpDown numericUpDownStorageSize;
|
|
||||||
private Button buttonSave;
|
private Button buttonSave;
|
||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ public partial class FormEmployee : Form
|
|||||||
throw new InvalidDataException(nameof(employee));
|
throw new InvalidDataException(nameof(employee));
|
||||||
}
|
}
|
||||||
numericUpDownNumStorage.Value = employee.NumberStorage;
|
numericUpDownNumStorage.Value = employee.NumberStorage;
|
||||||
numericUpDownStorageSize.Value = (decimal)employee.StorageSize;
|
//numericUpDownStorageSize.Value = (decimal)employee.StorageSize;
|
||||||
dateTimePickerDate.Value = employee.Date;
|
dateTimePickerDate.Value = employee.Date;
|
||||||
_employeeId = value;
|
_employeeId = value;
|
||||||
}
|
}
|
||||||
@ -54,7 +54,7 @@ public partial class FormEmployee : Form
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (numericUpDownNumStorage.Value <= 0 || numericUpDownStorageSize.Value <= 0)
|
if (numericUpDownNumStorage.Value <= 0 )
|
||||||
{
|
{
|
||||||
throw new Exception("Имеются незаполненные поля");
|
throw new Exception("Имеются незаполненные поля");
|
||||||
return;
|
return;
|
||||||
@ -79,6 +79,5 @@ public partial class FormEmployee : Form
|
|||||||
|
|
||||||
private void ButtonCancel_Click_1(object sender, EventArgs e) => Close();
|
private void ButtonCancel_Click_1(object sender, EventArgs e) => Close();
|
||||||
|
|
||||||
private Employee CreateEmployee(int id) => Employee.CreateEntity(id, dateTimePickerDate.Value,Convert.ToInt32(numericUpDownNumStorage.Value),
|
private Employee CreateEmployee(int id) => Employee.CreateEntity(id, dateTimePickerDate.Value,Convert.ToInt32(numericUpDownNumStorage.Value));
|
||||||
Convert.ToInt32(numericUpDownStorageSize.Value));
|
|
||||||
}
|
}
|
||||||
|
87
ShoeStore/Reports/DocReport.cs
Normal file
87
ShoeStore/Reports/DocReport.cs
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using ShoeStore.Repositories;
|
||||||
|
using ShoeStore.Repositories.Implementations;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ShoeStore.Reports;
|
||||||
|
|
||||||
|
internal class DocReport
|
||||||
|
{
|
||||||
|
private readonly IProductRepository _productRepository;
|
||||||
|
private readonly IStorageRepository _storageRepository;
|
||||||
|
private readonly IEmployeeRepository _employeeRepository;
|
||||||
|
private readonly ILogger<DocReport> _logger;
|
||||||
|
|
||||||
|
public DocReport(IProductRepository productRepository, IStorageRepository storageRepository, IEmployeeRepository employeeRepository, ILogger<DocReport> logger)
|
||||||
|
{
|
||||||
|
_productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository));
|
||||||
|
_storageRepository = storageRepository ?? throw new ArgumentNullException(nameof(storageRepository));
|
||||||
|
_employeeRepository = employeeRepository ?? throw new ArgumentNullException(nameof(employeeRepository));
|
||||||
|
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool CreateDoc(string filePath, bool includeProduct, bool includeStorage, bool includeEmployee)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var builder = new WordBuilder(filePath)
|
||||||
|
.AddHeader("Документ со справочниками");
|
||||||
|
if (includeProduct)
|
||||||
|
{
|
||||||
|
builder.AddParagraph("Продукты")
|
||||||
|
.AddTable([2400, 2400, 2400], GetProducts());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (includeStorage)
|
||||||
|
{
|
||||||
|
builder.AddParagraph("Склады")
|
||||||
|
.AddTable([2400, 2400, 2400], GetStorages());
|
||||||
|
}
|
||||||
|
if (includeEmployee)
|
||||||
|
{
|
||||||
|
builder.AddParagraph("Сотрудники")
|
||||||
|
.AddTable([2400, 2400], GetEmployees());
|
||||||
|
}
|
||||||
|
builder.Build();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<string[]> GetProducts()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
["Название обуви", "Компания-производитель", "Цена"],
|
||||||
|
.. _productRepository
|
||||||
|
.ReadProducts()
|
||||||
|
.Select(x => new string[] { x.NameOfShoes, x.ManufacturingCompany.ToString(), x.Price.ToString()}),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
private List<string[]> GetStorages()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
["Размер", "Наличие на складе", "Номер склада"],
|
||||||
|
.. _storageRepository
|
||||||
|
.ReadStorages()
|
||||||
|
.Select(x => new string[] { x.Size.ToString(), x.QuantityInStock.ToString(), x.NumberStorage.ToString()}),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
private List<string[]> GetEmployees()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
["Дата", "Номер склада"],
|
||||||
|
.. _employeeRepository
|
||||||
|
.ReadEmployees()
|
||||||
|
.Select(x => new string[] { x.Date.ToString(), x.NumberStorage.ToString()}),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
92
ShoeStore/Reports/WordBuilder.cs
Normal file
92
ShoeStore/Reports/WordBuilder.cs
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
using DocumentFormat.OpenXml.Packaging;
|
||||||
|
using DocumentFormat.OpenXml.Wordprocessing;
|
||||||
|
using DocumentFormat.OpenXml;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ShoeStore.Reports;
|
||||||
|
|
||||||
|
internal class WordBuilder
|
||||||
|
{
|
||||||
|
private readonly string _filePath;
|
||||||
|
private readonly Document _document;
|
||||||
|
private readonly Body _body;
|
||||||
|
public WordBuilder(string filePath)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(filePath))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(filePath));
|
||||||
|
}
|
||||||
|
if (File.Exists(filePath))
|
||||||
|
{
|
||||||
|
File.Delete(filePath);
|
||||||
|
}
|
||||||
|
_filePath = filePath;
|
||||||
|
_document = new Document();
|
||||||
|
_body = _document.AppendChild(new Body());
|
||||||
|
}
|
||||||
|
|
||||||
|
public WordBuilder AddHeader(string header)
|
||||||
|
{
|
||||||
|
var paragraph = _body.AppendChild(new Paragraph());
|
||||||
|
var run = paragraph.AppendChild(new Run());
|
||||||
|
run.PrependChild(new RunProperties());
|
||||||
|
run.RunProperties.AddChild(new Bold());
|
||||||
|
run.AppendChild(new Text(header));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public WordBuilder AddParagraph(string text)
|
||||||
|
{
|
||||||
|
var paragraph = _body.AppendChild(new Paragraph());
|
||||||
|
var run = paragraph.AppendChild(new Run());
|
||||||
|
run.AppendChild(new Text(text));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public WordBuilder AddTable(int[] widths, List<string[]> data)
|
||||||
|
{
|
||||||
|
if (widths == null || widths.Length == 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(widths));
|
||||||
|
}
|
||||||
|
if (data == null || data.Count == 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(data));
|
||||||
|
}
|
||||||
|
if (data.Any(x => x.Length != widths.Length))
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("widths.Length != data.Length");
|
||||||
|
}
|
||||||
|
var table = new Table();
|
||||||
|
table.AppendChild(new TableProperties(
|
||||||
|
new TableBorders(
|
||||||
|
new TopBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
||||||
|
new BottomBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
||||||
|
new LeftBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
||||||
|
new RightBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
||||||
|
new InsideHorizontalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 },
|
||||||
|
new InsideVerticalBorder() { Val = new EnumValue<BorderValues>(BorderValues.Single), Size = 12 })));
|
||||||
|
|
||||||
|
// Заголовок
|
||||||
|
var tr = new TableRow();
|
||||||
|
for (var j = 0; j < widths.Length; ++j)
|
||||||
|
{
|
||||||
|
tr.Append(new TableCell(new TableCellProperties(new TableCellWidth() { Width = widths[j].ToString() }),
|
||||||
|
new Paragraph(new Run(new RunProperties(new Bold()), new Text(data.First()[j])))));
|
||||||
|
}
|
||||||
|
table.Append(tr);
|
||||||
|
// Данные
|
||||||
|
table.Append(data.Skip(1).Select(x => new TableRow(x.Select(y => new TableCell(new Paragraph(new Run(new Text(y))))))));
|
||||||
|
_body.Append(table);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public void Build()
|
||||||
|
{
|
||||||
|
using var wordDocument = WordprocessingDocument.Create(_filePath, WordprocessingDocumentType.Document);
|
||||||
|
var mainPart = wordDocument.AddMainDocumentPart();
|
||||||
|
mainPart.Document = _document;
|
||||||
|
}
|
||||||
|
}
|
12
ShoeStore/ShoeStore.Designer.cs
generated
12
ShoeStore/ShoeStore.Designer.cs
generated
@ -37,6 +37,7 @@
|
|||||||
ReceiptsToolStripMenuItem = new ToolStripMenuItem();
|
ReceiptsToolStripMenuItem = new ToolStripMenuItem();
|
||||||
SalesToolStripMenuItem = new ToolStripMenuItem();
|
SalesToolStripMenuItem = new ToolStripMenuItem();
|
||||||
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
DirectoryReportToolStripMenuItem = new ToolStripMenuItem();
|
||||||
menuStrip1.SuspendLayout();
|
menuStrip1.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -100,10 +101,19 @@
|
|||||||
//
|
//
|
||||||
// отчетыToolStripMenuItem
|
// отчетыToolStripMenuItem
|
||||||
//
|
//
|
||||||
|
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { DirectoryReportToolStripMenuItem });
|
||||||
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
||||||
отчетыToolStripMenuItem.Size = new Size(60, 20);
|
отчетыToolStripMenuItem.Size = new Size(60, 20);
|
||||||
отчетыToolStripMenuItem.Text = "Отчеты";
|
отчетыToolStripMenuItem.Text = "Отчеты";
|
||||||
//
|
//
|
||||||
|
// DirectoryReportToolStripMenuItem
|
||||||
|
//
|
||||||
|
DirectoryReportToolStripMenuItem.Name = "DirectoryReportToolStripMenuItem";
|
||||||
|
DirectoryReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.W;
|
||||||
|
DirectoryReportToolStripMenuItem.Size = new Size(273, 22);
|
||||||
|
DirectoryReportToolStripMenuItem.Text = "Документ со справониками";
|
||||||
|
DirectoryReportToolStripMenuItem.Click += DirectoryReportToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// ShoeStore
|
// ShoeStore
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
@ -116,7 +126,6 @@
|
|||||||
MainMenuStrip = menuStrip1;
|
MainMenuStrip = menuStrip1;
|
||||||
Name = "ShoeStore";
|
Name = "ShoeStore";
|
||||||
Text = "ShoeStore";
|
Text = "ShoeStore";
|
||||||
//Load += ShoeStore_Load;
|
|
||||||
menuStrip1.ResumeLayout(false);
|
menuStrip1.ResumeLayout(false);
|
||||||
menuStrip1.PerformLayout();
|
menuStrip1.PerformLayout();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
@ -134,5 +143,6 @@
|
|||||||
private ToolStripMenuItem ReceiptsToolStripMenuItem;
|
private ToolStripMenuItem ReceiptsToolStripMenuItem;
|
||||||
private ToolStripMenuItem SalesToolStripMenuItem;
|
private ToolStripMenuItem SalesToolStripMenuItem;
|
||||||
private ToolStripMenuItem отчетыToolStripMenuItem;
|
private ToolStripMenuItem отчетыToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem DirectoryReportToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -84,7 +84,16 @@ namespace ShoeStore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DirectoryReportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormDirectoryReport>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Dapper" Version="2.1.35" />
|
<PackageReference Include="Dapper" Version="2.1.35" />
|
||||||
|
<PackageReference Include="DocumentFormat.OpenXml" Version="3.2.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user