лаба 3
This commit is contained in:
parent
b5a3d4e2a3
commit
6b7a684869
@ -20,4 +20,17 @@ public class Order
|
||||
DateTime = DateTime.Now
|
||||
};
|
||||
}
|
||||
|
||||
public static Order CreateOpeartion(TempOrderProducts tempOrderPoducts,
|
||||
IEnumerable<OrderProducts> orderProducts)
|
||||
{
|
||||
return new Order
|
||||
{
|
||||
Id = tempOrderPoducts.Id,
|
||||
Name = tempOrderPoducts.Name,
|
||||
Phone = tempOrderPoducts.Phone,
|
||||
OrderProducts = orderProducts,
|
||||
DateTime = tempOrderPoducts.DateTime
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -7,15 +7,16 @@ public class Purchase
|
||||
public DateTime DateTime { get; private set; }
|
||||
public int SellerId { get; private set; }
|
||||
public int ComponentId { get; private set; }
|
||||
|
||||
public static Purchase CreateOpeartion(int id, int sellerId, int componentId)
|
||||
public decimal Count { get; private set; }
|
||||
public static Purchase CreateOpeartion(int id, int sellerId, int componentId, decimal count)
|
||||
{
|
||||
return new Purchase
|
||||
{
|
||||
Id = id,
|
||||
DateTime = DateTime.Now,
|
||||
SellerId = sellerId,
|
||||
ComponentId = componentId
|
||||
ComponentId = componentId,
|
||||
Count = count
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
|
||||
namespace ProjectConfectFactory.Entities;
|
||||
|
||||
public class TempOrderProducts
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string Name { get; private set; } = string.Empty;
|
||||
public string Phone { get; private set; } = string.Empty;
|
||||
public DateTime DateTime { get; private set; }
|
||||
public int ProductId { get; private set; }
|
||||
public int Count { get; private set; }
|
||||
public decimal Price { get; private set; }
|
||||
}
|
@ -37,6 +37,9 @@
|
||||
OrderToolStripMenuItem = new ToolStripMenuItem();
|
||||
PurchaseToolStripMenuItem = new ToolStripMenuItem();
|
||||
ReportToolStripMenuItem = new ToolStripMenuItem();
|
||||
DirectoryReportToolStripMenuItem = new ToolStripMenuItem();
|
||||
toolStripMenuItemComponentReport = new ToolStripMenuItem();
|
||||
OrderDistribReportToolStripMenuItem = new ToolStripMenuItem();
|
||||
menuStripTool.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
@ -102,10 +105,35 @@
|
||||
//
|
||||
// ReportToolStripMenuItem
|
||||
//
|
||||
ReportToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { DirectoryReportToolStripMenuItem, toolStripMenuItemComponentReport, OrderDistribReportToolStripMenuItem });
|
||||
ReportToolStripMenuItem.Name = "ReportToolStripMenuItem";
|
||||
ReportToolStripMenuItem.Size = new Size(73, 24);
|
||||
ReportToolStripMenuItem.Text = "Отчёты";
|
||||
//
|
||||
// DirectoryReportToolStripMenuItem
|
||||
//
|
||||
DirectoryReportToolStripMenuItem.Name = "DirectoryReportToolStripMenuItem";
|
||||
DirectoryReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.W;
|
||||
DirectoryReportToolStripMenuItem.Size = new Size(350, 26);
|
||||
DirectoryReportToolStripMenuItem.Text = "Документ со справочниками";
|
||||
DirectoryReportToolStripMenuItem.Click += DirectoryReportToolStripMenuItem_Click;
|
||||
//
|
||||
// toolStripMenuItemComponentReport
|
||||
//
|
||||
toolStripMenuItemComponentReport.Name = "toolStripMenuItemComponentReport";
|
||||
toolStripMenuItemComponentReport.ShortcutKeys = Keys.Control | Keys.E;
|
||||
toolStripMenuItemComponentReport.Size = new Size(350, 26);
|
||||
toolStripMenuItemComponentReport.Text = "Распределение компонентов";
|
||||
toolStripMenuItemComponentReport.Click += toolStripMenuItemComponentReport_Click;
|
||||
//
|
||||
// OrderDistribReportToolStripMenuItem
|
||||
//
|
||||
OrderDistribReportToolStripMenuItem.Name = "OrderDistribReportToolStripMenuItem";
|
||||
OrderDistribReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.P;
|
||||
OrderDistribReportToolStripMenuItem.Size = new Size(350, 26);
|
||||
OrderDistribReportToolStripMenuItem.Text = "Востребованность продуктов";
|
||||
OrderDistribReportToolStripMenuItem.Click += OrderDistribReportToolStripMenuItem_Click;
|
||||
//
|
||||
// FormConFactory
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
@ -135,5 +163,8 @@
|
||||
private ToolStripMenuItem OrderToolStripMenuItem;
|
||||
private ToolStripMenuItem PurchaseToolStripMenuItem;
|
||||
private ToolStripMenuItem ReportToolStripMenuItem;
|
||||
private ToolStripMenuItem DirectoryReportToolStripMenuItem;
|
||||
private ToolStripMenuItem toolStripMenuItemComponentReport;
|
||||
private ToolStripMenuItem OrderDistribReportToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -82,4 +82,43 @@ public partial class FormConFactory : Form
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DirectoryReportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormDirectoryReport>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при загрузке",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void OrderDistribReportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<OrderDistributionReport>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при загрузке",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void toolStripMenuItemComponentReport_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormComponentReport>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при загрузке",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,9 @@
|
||||
//
|
||||
// buttonBack
|
||||
//
|
||||
buttonBack.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonBack.Location = new Point(291, 245);
|
||||
buttonBack.MinimumSize = new Size(94, 29);
|
||||
buttonBack.Name = "buttonBack";
|
||||
buttonBack.Size = new Size(94, 29);
|
||||
buttonBack.TabIndex = 17;
|
||||
@ -52,6 +54,7 @@
|
||||
//
|
||||
// ButtonSave
|
||||
//
|
||||
ButtonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
ButtonSave.Location = new Point(67, 245);
|
||||
ButtonSave.Name = "ButtonSave";
|
||||
ButtonSave.Size = new Size(94, 29);
|
||||
@ -66,9 +69,9 @@
|
||||
label4.BackColor = Color.Bisque;
|
||||
label4.Location = new Point(22, 191);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(112, 20);
|
||||
label4.Size = new Size(132, 20);
|
||||
label4.TabIndex = 15;
|
||||
label4.Text = "Кол-во сейчас:";
|
||||
label4.Text = "Кол-во на складе:";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
@ -103,6 +106,7 @@
|
||||
//
|
||||
// textBoxComponentUnit
|
||||
//
|
||||
textBoxComponentUnit.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
textBoxComponentUnit.Location = new Point(206, 124);
|
||||
textBoxComponentUnit.Name = "textBoxComponentUnit";
|
||||
textBoxComponentUnit.Size = new Size(218, 27);
|
||||
@ -110,6 +114,7 @@
|
||||
//
|
||||
// textBoxComponentName
|
||||
//
|
||||
textBoxComponentName.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
textBoxComponentName.Location = new Point(206, 60);
|
||||
textBoxComponentName.Name = "textBoxComponentName";
|
||||
textBoxComponentName.Size = new Size(218, 27);
|
||||
@ -117,6 +122,7 @@
|
||||
//
|
||||
// numericUpDownComponentCount
|
||||
//
|
||||
numericUpDownComponentCount.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
numericUpDownComponentCount.Location = new Point(206, 184);
|
||||
numericUpDownComponentCount.Maximum = new decimal(new int[] { 10000, 0, 0, 0 });
|
||||
numericUpDownComponentCount.Name = "numericUpDownComponentCount";
|
||||
|
186
ProjectConfectFactory/ProjectConfectFactory/Forms/FormComponentReport.Designer.cs
generated
Normal file
186
ProjectConfectFactory/ProjectConfectFactory/Forms/FormComponentReport.Designer.cs
generated
Normal file
@ -0,0 +1,186 @@
|
||||
namespace ProjectConfectFactory.Forms;
|
||||
partial class FormComponentReport
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
label1 = new Label();
|
||||
textBoxFilePath = new TextBox();
|
||||
ButtonSelectFilePath = new Button();
|
||||
label2 = new Label();
|
||||
label3 = new Label();
|
||||
label4 = new Label();
|
||||
ButtonMakeReport = new Button();
|
||||
dateTimePickerStart = new DateTimePicker();
|
||||
dateTimePickerEnd = new DateTimePicker();
|
||||
comboBoxComponent = new ComboBox();
|
||||
label5 = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.BackColor = Color.Bisque;
|
||||
label1.Location = new Point(18, 65);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(112, 20);
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "Путь до файла:";
|
||||
//
|
||||
// textBoxFilePath
|
||||
//
|
||||
textBoxFilePath.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
textBoxFilePath.Location = new Point(158, 62);
|
||||
textBoxFilePath.Name = "textBoxFilePath";
|
||||
textBoxFilePath.Size = new Size(212, 27);
|
||||
textBoxFilePath.TabIndex = 1;
|
||||
//
|
||||
// ButtonSelectFilePath
|
||||
//
|
||||
ButtonSelectFilePath.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
ButtonSelectFilePath.Location = new Point(376, 65);
|
||||
ButtonSelectFilePath.Name = "ButtonSelectFilePath";
|
||||
ButtonSelectFilePath.Size = new Size(32, 27);
|
||||
ButtonSelectFilePath.TabIndex = 2;
|
||||
ButtonSelectFilePath.Text = "...";
|
||||
ButtonSelectFilePath.UseVisualStyleBackColor = true;
|
||||
ButtonSelectFilePath.Click += ButtonSelectFilePath_Click;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.BackColor = Color.Bisque;
|
||||
label2.Location = new Point(18, 119);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(91, 20);
|
||||
label2.TabIndex = 3;
|
||||
label2.Text = "Компонент:";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.BackColor = Color.Bisque;
|
||||
label3.Location = new Point(18, 171);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(97, 20);
|
||||
label3.TabIndex = 5;
|
||||
label3.Text = "Дата начала:";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.BackColor = Color.Bisque;
|
||||
label4.Location = new Point(18, 233);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(90, 20);
|
||||
label4.TabIndex = 7;
|
||||
label4.Text = "Дата конца:";
|
||||
//
|
||||
// ButtonMakeReport
|
||||
//
|
||||
ButtonMakeReport.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
ButtonMakeReport.Location = new Point(106, 268);
|
||||
ButtonMakeReport.Name = "ButtonMakeReport";
|
||||
ButtonMakeReport.Size = new Size(199, 40);
|
||||
ButtonMakeReport.TabIndex = 9;
|
||||
ButtonMakeReport.Text = "Сформировать";
|
||||
ButtonMakeReport.UseVisualStyleBackColor = true;
|
||||
ButtonMakeReport.Click += ButtonMakeReport_Click;
|
||||
//
|
||||
// dateTimePickerStart
|
||||
//
|
||||
dateTimePickerStart.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
dateTimePickerStart.Location = new Point(158, 164);
|
||||
dateTimePickerStart.Name = "dateTimePickerStart";
|
||||
dateTimePickerStart.Size = new Size(250, 27);
|
||||
dateTimePickerStart.TabIndex = 10;
|
||||
//
|
||||
// dateTimePickerEnd
|
||||
//
|
||||
dateTimePickerEnd.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
dateTimePickerEnd.Location = new Point(158, 226);
|
||||
dateTimePickerEnd.Name = "dateTimePickerEnd";
|
||||
dateTimePickerEnd.Size = new Size(250, 27);
|
||||
dateTimePickerEnd.TabIndex = 11;
|
||||
//
|
||||
// comboBoxComponent
|
||||
//
|
||||
comboBoxComponent.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
comboBoxComponent.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxComponent.FormattingEnabled = true;
|
||||
comboBoxComponent.Location = new Point(158, 111);
|
||||
comboBoxComponent.Name = "comboBoxComponent";
|
||||
comboBoxComponent.Size = new Size(250, 28);
|
||||
comboBoxComponent.TabIndex = 12;
|
||||
//
|
||||
// label5
|
||||
//
|
||||
label5.AutoSize = true;
|
||||
label5.BackColor = Color.Bisque;
|
||||
label5.Location = new Point(133, 17);
|
||||
label5.Name = "label5";
|
||||
label5.Size = new Size(172, 20);
|
||||
label5.TabIndex = 13;
|
||||
label5.Text = "Характеристики отчёта:";
|
||||
//
|
||||
// FormComponentReport
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
BackColor = Color.AntiqueWhite;
|
||||
ClientSize = new Size(431, 331);
|
||||
Controls.Add(label5);
|
||||
Controls.Add(comboBoxComponent);
|
||||
Controls.Add(dateTimePickerEnd);
|
||||
Controls.Add(dateTimePickerStart);
|
||||
Controls.Add(ButtonMakeReport);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(ButtonSelectFilePath);
|
||||
Controls.Add(textBoxFilePath);
|
||||
Controls.Add(label1);
|
||||
MinimumSize = new Size(449, 378);
|
||||
Name = "FormComponentReport";
|
||||
Text = "Отчёт по компонентам";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private TextBox textBoxFilePath;
|
||||
private Button ButtonSelectFilePath;
|
||||
private Label label2;
|
||||
private Label label3;
|
||||
private Label label4;
|
||||
private Button ButtonMakeReport;
|
||||
private DateTimePicker dateTimePickerStart;
|
||||
private DateTimePicker dateTimePickerEnd;
|
||||
private ComboBox comboBoxComponent;
|
||||
private Label label5;
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
using ProjectConfectFactory.Reports;
|
||||
using ProjectConfectFactory.Repositories;
|
||||
using Unity;
|
||||
|
||||
namespace ProjectConfectFactory.Forms;
|
||||
|
||||
public partial class FormComponentReport : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
public FormComponentReport(IUnityContainer container, IComponentRepository componentRepository, IProductRepository productRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
|
||||
comboBoxComponent.DataSource = componentRepository.ReadComponents();
|
||||
comboBoxComponent.DisplayMember = "Name";
|
||||
comboBoxComponent.ValueMember = "Id";
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void ButtonSelectFilePath_Click(object sender, EventArgs e)
|
||||
{
|
||||
var sfd = new SaveFileDialog()
|
||||
{
|
||||
Filter = "Excel Files | *.xlsx"
|
||||
};
|
||||
|
||||
if (sfd.ShowDialog() != DialogResult.OK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
textBoxFilePath.Text = sfd.FileName;
|
||||
}
|
||||
|
||||
private void ButtonMakeReport_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textBoxFilePath.Text))
|
||||
{
|
||||
throw new Exception("Отсутствует имя файла для отчета");
|
||||
}
|
||||
|
||||
if (comboBoxComponent.SelectedIndex < 0)
|
||||
{
|
||||
throw new Exception("Не выбраны данные");
|
||||
}
|
||||
|
||||
if (dateTimePickerEnd.Value <= dateTimePickerStart.Value)
|
||||
{
|
||||
throw new Exception("Дата начала должна быть раньше даты окончания");
|
||||
}
|
||||
|
||||
|
||||
if
|
||||
(_container.Resolve<TableReport>().CreateTable(textBoxFilePath.Text,
|
||||
(int)comboBoxComponent.SelectedValue!, dateTimePickerStart.Value, dateTimePickerEnd.Value))
|
||||
{
|
||||
MessageBox.Show("Документ сформирован", "Формирование документа",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах", "Формирование документа",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при создании очета",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
@ -1,130 +1,130 @@
|
||||
namespace ProjectConfectFactory.Forms
|
||||
namespace ProjectConfectFactory.Forms;
|
||||
|
||||
partial class FormComponents
|
||||
{
|
||||
partial class FormComponents
|
||||
/// <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)
|
||||
{
|
||||
/// <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))
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
components.Dispose();
|
||||
}
|
||||
|
||||
#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()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormComponents));
|
||||
panel1 = new Panel();
|
||||
buttonUpd = new Button();
|
||||
buttonDel = new Button();
|
||||
buttonAdd = new Button();
|
||||
dataGridViewComponents = new DataGridView();
|
||||
panel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewComponents).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.BackColor = Color.Linen;
|
||||
panel1.Controls.Add(buttonUpd);
|
||||
panel1.Controls.Add(buttonDel);
|
||||
panel1.Controls.Add(buttonAdd);
|
||||
panel1.Dock = DockStyle.Right;
|
||||
panel1.Location = new Point(657, 0);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(143, 450);
|
||||
panel1.TabIndex = 1;
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
buttonUpd.BackgroundImage = (Image)resources.GetObject("buttonUpd.BackgroundImage");
|
||||
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonUpd.Location = new Point(27, 339);
|
||||
buttonUpd.Name = "buttonUpd";
|
||||
buttonUpd.Size = new Size(95, 90);
|
||||
buttonUpd.TabIndex = 4;
|
||||
buttonUpd.UseVisualStyleBackColor = true;
|
||||
buttonUpd.Click += buttonUpd_Click;
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
buttonDel.BackgroundImage = (Image)resources.GetObject("buttonDel.BackgroundImage");
|
||||
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonDel.Location = new Point(27, 134);
|
||||
buttonDel.Name = "buttonDel";
|
||||
buttonDel.Size = new Size(95, 90);
|
||||
buttonDel.TabIndex = 3;
|
||||
buttonDel.UseVisualStyleBackColor = true;
|
||||
buttonDel.Click += buttonDel_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.BackgroundImage = Properties.Resources.add;
|
||||
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonAdd.Location = new Point(27, 24);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(95, 90);
|
||||
buttonAdd.TabIndex = 0;
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// dataGridViewComponents
|
||||
//
|
||||
dataGridViewComponents.AllowUserToAddRows = false;
|
||||
dataGridViewComponents.AllowUserToDeleteRows = false;
|
||||
dataGridViewComponents.AllowUserToResizeColumns = false;
|
||||
dataGridViewComponents.AllowUserToResizeRows = false;
|
||||
dataGridViewComponents.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridViewComponents.BackgroundColor = Color.Bisque;
|
||||
dataGridViewComponents.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewComponents.Dock = DockStyle.Fill;
|
||||
dataGridViewComponents.GridColor = Color.Bisque;
|
||||
dataGridViewComponents.Location = new Point(0, 0);
|
||||
dataGridViewComponents.MultiSelect = false;
|
||||
dataGridViewComponents.Name = "dataGridViewComponents";
|
||||
dataGridViewComponents.ReadOnly = true;
|
||||
dataGridViewComponents.RowHeadersVisible = false;
|
||||
dataGridViewComponents.RowHeadersWidth = 51;
|
||||
dataGridViewComponents.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridViewComponents.Size = new Size(657, 450);
|
||||
dataGridViewComponents.TabIndex = 2;
|
||||
//
|
||||
// FormComponents
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(dataGridViewComponents);
|
||||
Controls.Add(panel1);
|
||||
Name = "FormComponents";
|
||||
Text = "Компоненты";
|
||||
Load += FormComponents_Load;
|
||||
panel1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewComponents).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel panel1;
|
||||
private Button buttonUpd;
|
||||
private Button buttonDel;
|
||||
private Button buttonAdd;
|
||||
private DataGridView dataGridViewComponents;
|
||||
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()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormComponents));
|
||||
panel1 = new Panel();
|
||||
buttonUpd = new Button();
|
||||
buttonDel = new Button();
|
||||
buttonAdd = new Button();
|
||||
dataGridViewComponents = new DataGridView();
|
||||
panel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewComponents).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.BackColor = Color.Linen;
|
||||
panel1.Controls.Add(buttonUpd);
|
||||
panel1.Controls.Add(buttonDel);
|
||||
panel1.Controls.Add(buttonAdd);
|
||||
panel1.Dock = DockStyle.Right;
|
||||
panel1.Location = new Point(657, 0);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(143, 450);
|
||||
panel1.TabIndex = 1;
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
buttonUpd.BackgroundImage = (Image)resources.GetObject("buttonUpd.BackgroundImage");
|
||||
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonUpd.Location = new Point(27, 339);
|
||||
buttonUpd.Name = "buttonUpd";
|
||||
buttonUpd.Size = new Size(95, 90);
|
||||
buttonUpd.TabIndex = 4;
|
||||
buttonUpd.UseVisualStyleBackColor = true;
|
||||
buttonUpd.Click += buttonUpd_Click;
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
buttonDel.BackgroundImage = (Image)resources.GetObject("buttonDel.BackgroundImage");
|
||||
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonDel.Location = new Point(27, 134);
|
||||
buttonDel.Name = "buttonDel";
|
||||
buttonDel.Size = new Size(95, 90);
|
||||
buttonDel.TabIndex = 3;
|
||||
buttonDel.UseVisualStyleBackColor = true;
|
||||
buttonDel.Click += buttonDel_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.BackgroundImage = Properties.Resources.add;
|
||||
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonAdd.Location = new Point(27, 24);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(95, 90);
|
||||
buttonAdd.TabIndex = 0;
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// dataGridViewComponents
|
||||
//
|
||||
dataGridViewComponents.AllowUserToAddRows = false;
|
||||
dataGridViewComponents.AllowUserToDeleteRows = false;
|
||||
dataGridViewComponents.AllowUserToResizeColumns = false;
|
||||
dataGridViewComponents.AllowUserToResizeRows = false;
|
||||
dataGridViewComponents.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridViewComponents.BackgroundColor = Color.Bisque;
|
||||
dataGridViewComponents.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewComponents.Dock = DockStyle.Fill;
|
||||
dataGridViewComponents.GridColor = Color.Bisque;
|
||||
dataGridViewComponents.Location = new Point(0, 0);
|
||||
dataGridViewComponents.MultiSelect = false;
|
||||
dataGridViewComponents.Name = "dataGridViewComponents";
|
||||
dataGridViewComponents.ReadOnly = true;
|
||||
dataGridViewComponents.RowHeadersVisible = false;
|
||||
dataGridViewComponents.RowHeadersWidth = 51;
|
||||
dataGridViewComponents.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridViewComponents.Size = new Size(657, 450);
|
||||
dataGridViewComponents.TabIndex = 2;
|
||||
//
|
||||
// FormComponents
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(dataGridViewComponents);
|
||||
Controls.Add(panel1);
|
||||
MinimumSize = new Size(818, 497);
|
||||
Name = "FormComponents";
|
||||
Text = "Компоненты";
|
||||
Load += FormComponents_Load;
|
||||
panel1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewComponents).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel panel1;
|
||||
private Button buttonUpd;
|
||||
private Button buttonDel;
|
||||
private Button buttonAdd;
|
||||
private DataGridView dataGridViewComponents;
|
||||
}
|
103
ProjectConfectFactory/ProjectConfectFactory/Forms/FormDirectoryReport.Designer.cs
generated
Normal file
103
ProjectConfectFactory/ProjectConfectFactory/Forms/FormDirectoryReport.Designer.cs
generated
Normal file
@ -0,0 +1,103 @@
|
||||
namespace ProjectConfectFactory.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();
|
||||
checkBoxComponent = new CheckBox();
|
||||
checkBoxSeller = new CheckBox();
|
||||
buttonBuild = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// checkBoxProduct
|
||||
//
|
||||
checkBoxProduct.AutoSize = true;
|
||||
checkBoxProduct.Location = new Point(25, 24);
|
||||
checkBoxProduct.Name = "checkBoxProduct";
|
||||
checkBoxProduct.Size = new Size(99, 24);
|
||||
checkBoxProduct.TabIndex = 0;
|
||||
checkBoxProduct.Text = "Продукты";
|
||||
checkBoxProduct.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxComponent
|
||||
//
|
||||
checkBoxComponent.AutoSize = true;
|
||||
checkBoxComponent.Location = new Point(25, 54);
|
||||
checkBoxComponent.Name = "checkBoxComponent";
|
||||
checkBoxComponent.Size = new Size(121, 24);
|
||||
checkBoxComponent.TabIndex = 1;
|
||||
checkBoxComponent.Text = "Компоненты";
|
||||
checkBoxComponent.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxSeller
|
||||
//
|
||||
checkBoxSeller.AutoSize = true;
|
||||
checkBoxSeller.Location = new Point(25, 84);
|
||||
checkBoxSeller.Name = "checkBoxSeller";
|
||||
checkBoxSeller.Size = new Size(117, 24);
|
||||
checkBoxSeller.TabIndex = 2;
|
||||
checkBoxSeller.Text = "Поставщики";
|
||||
checkBoxSeller.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonBuild
|
||||
//
|
||||
buttonBuild.Location = new Point(196, 49);
|
||||
buttonBuild.Name = "buttonBuild";
|
||||
buttonBuild.Size = new Size(132, 29);
|
||||
buttonBuild.TabIndex = 4;
|
||||
buttonBuild.Text = "Сформировать";
|
||||
buttonBuild.UseVisualStyleBackColor = true;
|
||||
buttonBuild.Click += ButtonBuild_Click;
|
||||
//
|
||||
// FormDirectoryReport
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
BackColor = Color.AntiqueWhite;
|
||||
ClientSize = new Size(361, 130);
|
||||
Controls.Add(buttonBuild);
|
||||
Controls.Add(checkBoxSeller);
|
||||
Controls.Add(checkBoxComponent);
|
||||
Controls.Add(checkBoxProduct);
|
||||
Name = "FormDirectoryReport";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Выгрузка справочников";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
private CheckBox checkBoxProduct;
|
||||
private CheckBox checkBoxComponent;
|
||||
private CheckBox checkBoxSeller;
|
||||
private Button buttonBuild;
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
using ProjectConfectFactory.Reports;
|
||||
using Unity;
|
||||
|
||||
namespace ProjectConfectFactory.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 && !checkBoxComponent.Checked && !checkBoxSeller.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,
|
||||
checkBoxSeller.Checked, checkBoxComponent.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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -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>
|
@ -79,6 +79,7 @@
|
||||
//
|
||||
// textBoxOrderPhone
|
||||
//
|
||||
textBoxOrderPhone.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
textBoxOrderPhone.Location = new Point(284, 105);
|
||||
textBoxOrderPhone.Name = "textBoxOrderPhone";
|
||||
textBoxOrderPhone.Size = new Size(250, 27);
|
||||
@ -86,6 +87,7 @@
|
||||
//
|
||||
// textBoxOrderName
|
||||
//
|
||||
textBoxOrderName.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
textBoxOrderName.Location = new Point(284, 55);
|
||||
textBoxOrderName.Name = "textBoxOrderName";
|
||||
textBoxOrderName.Size = new Size(250, 27);
|
||||
@ -93,6 +95,7 @@
|
||||
//
|
||||
// dateTimePickerOrder
|
||||
//
|
||||
dateTimePickerOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
dateTimePickerOrder.Enabled = false;
|
||||
dateTimePickerOrder.Location = new Point(284, 156);
|
||||
dateTimePickerOrder.Name = "dateTimePickerOrder";
|
||||
@ -111,6 +114,7 @@
|
||||
//
|
||||
// groupBoxListProducts
|
||||
//
|
||||
groupBoxListProducts.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
groupBoxListProducts.Controls.Add(dataGridViewProducts);
|
||||
groupBoxListProducts.Location = new Point(27, 209);
|
||||
groupBoxListProducts.Name = "groupBoxListProducts";
|
||||
@ -155,6 +159,7 @@
|
||||
//
|
||||
// buttonBack
|
||||
//
|
||||
buttonBack.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonBack.Location = new Point(406, 521);
|
||||
buttonBack.Name = "buttonBack";
|
||||
buttonBack.Size = new Size(100, 30);
|
||||
@ -165,6 +170,7 @@
|
||||
//
|
||||
// ButtonSave
|
||||
//
|
||||
ButtonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
ButtonSave.Location = new Point(92, 521);
|
||||
ButtonSave.Name = "ButtonSave";
|
||||
ButtonSave.Size = new Size(100, 30);
|
||||
@ -189,6 +195,7 @@
|
||||
Controls.Add(label1);
|
||||
Controls.Add(textBoxOrderPhone);
|
||||
Controls.Add(textBoxOrderName);
|
||||
MinimumSize = new Size(649, 610);
|
||||
Name = "FormOrder";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Заказ";
|
||||
|
@ -55,7 +55,9 @@ public partial class FormOrder : Form
|
||||
list.Add(OrderProducts.CreateElement(0, Convert.ToInt32(row.Cells["ColumnProduct"].Value), Convert.ToInt32(row.Cells["ColumnCount"].Value), Convert.ToDecimal(row.Cells["ColumnPrice"].Value)));
|
||||
}
|
||||
|
||||
return list;
|
||||
return list.GroupBy(x => x.ProductId, x => new { x.Count, x.Price })
|
||||
.Select(g => OrderProducts.CreateElement(0, g.Key, g.Sum(x => x.Count), g.Sum(x => x.Price))).ToList();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -126,4 +126,13 @@
|
||||
<metadata name="ColumnPrice.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnProduct.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnPrice.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
@ -98,6 +98,7 @@
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(dataGridViewOrders);
|
||||
Controls.Add(panel1);
|
||||
MinimumSize = new Size(818, 497);
|
||||
Name = "FormOrders";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Заказы";
|
||||
|
@ -76,6 +76,7 @@
|
||||
//
|
||||
// numericUpDownProductPrice
|
||||
//
|
||||
numericUpDownProductPrice.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
numericUpDownProductPrice.Location = new Point(484, 66);
|
||||
numericUpDownProductPrice.Maximum = new decimal(new int[] { 10000, 0, 0, 0 });
|
||||
numericUpDownProductPrice.Name = "numericUpDownProductPrice";
|
||||
@ -94,6 +95,7 @@
|
||||
//
|
||||
// buttonBack
|
||||
//
|
||||
buttonBack.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonBack.Location = new Point(435, 498);
|
||||
buttonBack.Name = "buttonBack";
|
||||
buttonBack.Size = new Size(100, 30);
|
||||
@ -104,6 +106,7 @@
|
||||
//
|
||||
// ButtonSave
|
||||
//
|
||||
ButtonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
ButtonSave.Location = new Point(129, 498);
|
||||
ButtonSave.Name = "ButtonSave";
|
||||
ButtonSave.Size = new Size(100, 30);
|
||||
@ -114,6 +117,7 @@
|
||||
//
|
||||
// groupBoxRecipe
|
||||
//
|
||||
groupBoxRecipe.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
groupBoxRecipe.Controls.Add(dataGridViewRecipe);
|
||||
groupBoxRecipe.Location = new Point(43, 242);
|
||||
groupBoxRecipe.Name = "groupBoxRecipe";
|
||||
@ -161,6 +165,7 @@
|
||||
//
|
||||
// checkedListBoxProductType
|
||||
//
|
||||
checkedListBoxProductType.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
checkedListBoxProductType.FormattingEnabled = true;
|
||||
checkedListBoxProductType.Location = new Point(43, 151);
|
||||
checkedListBoxProductType.MultiColumn = true;
|
||||
@ -184,6 +189,7 @@
|
||||
Controls.Add(label1);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(textBoxProductName);
|
||||
MinimumSize = new Size(709, 600);
|
||||
Name = "FormProduct";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Продукт";
|
||||
|
@ -111,6 +111,7 @@
|
||||
ClientSize = new Size(923, 450);
|
||||
Controls.Add(dataGridViewProducts);
|
||||
Controls.Add(panel1);
|
||||
MinimumSize = new Size(941, 497);
|
||||
Name = "FormProducts";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Продукты";
|
||||
|
@ -37,6 +37,9 @@
|
||||
label3 = new Label();
|
||||
buttonBack = new Button();
|
||||
ButtonSave = new Button();
|
||||
numericUpDownComponentCount = new NumericUpDown();
|
||||
label5 = new Label();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownComponentCount).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label4
|
||||
@ -51,6 +54,7 @@
|
||||
//
|
||||
// dateTimePickerPruchase
|
||||
//
|
||||
dateTimePickerPruchase.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
dateTimePickerPruchase.Enabled = false;
|
||||
dateTimePickerPruchase.Location = new Point(171, 136);
|
||||
dateTimePickerPruchase.Name = "dateTimePickerPruchase";
|
||||
@ -80,6 +84,8 @@
|
||||
//
|
||||
// comboBoxComponent
|
||||
//
|
||||
comboBoxComponent.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
comboBoxComponent.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxComponent.FormattingEnabled = true;
|
||||
comboBoxComponent.Location = new Point(171, 187);
|
||||
comboBoxComponent.Name = "comboBoxComponent";
|
||||
@ -88,6 +94,8 @@
|
||||
//
|
||||
// comboBoxSellerName
|
||||
//
|
||||
comboBoxSellerName.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
comboBoxSellerName.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxSellerName.FormattingEnabled = true;
|
||||
comboBoxSellerName.Location = new Point(171, 80);
|
||||
comboBoxSellerName.Name = "comboBoxSellerName";
|
||||
@ -106,7 +114,8 @@
|
||||
//
|
||||
// buttonBack
|
||||
//
|
||||
buttonBack.Location = new Point(272, 252);
|
||||
buttonBack.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonBack.Location = new Point(272, 299);
|
||||
buttonBack.Name = "buttonBack";
|
||||
buttonBack.Size = new Size(100, 30);
|
||||
buttonBack.TabIndex = 27;
|
||||
@ -116,7 +125,8 @@
|
||||
//
|
||||
// ButtonSave
|
||||
//
|
||||
ButtonSave.Location = new Point(68, 252);
|
||||
ButtonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
ButtonSave.Location = new Point(68, 299);
|
||||
ButtonSave.Name = "ButtonSave";
|
||||
ButtonSave.Size = new Size(100, 30);
|
||||
ButtonSave.TabIndex = 26;
|
||||
@ -124,12 +134,33 @@
|
||||
ButtonSave.UseVisualStyleBackColor = true;
|
||||
ButtonSave.Click += ButtonSave_Click;
|
||||
//
|
||||
// numericUpDownComponentCount
|
||||
//
|
||||
numericUpDownComponentCount.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
numericUpDownComponentCount.Location = new Point(171, 245);
|
||||
numericUpDownComponentCount.Maximum = new decimal(new int[] { 10000, 0, 0, 0 });
|
||||
numericUpDownComponentCount.Name = "numericUpDownComponentCount";
|
||||
numericUpDownComponentCount.Size = new Size(250, 27);
|
||||
numericUpDownComponentCount.TabIndex = 28;
|
||||
//
|
||||
// label5
|
||||
//
|
||||
label5.AutoSize = true;
|
||||
label5.BackColor = Color.Bisque;
|
||||
label5.Location = new Point(37, 252);
|
||||
label5.Name = "label5";
|
||||
label5.Size = new Size(61, 20);
|
||||
label5.TabIndex = 29;
|
||||
label5.Text = "Кол-во:";
|
||||
//
|
||||
// FormPurchase
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
BackColor = Color.AntiqueWhite;
|
||||
ClientSize = new Size(449, 308);
|
||||
ClientSize = new Size(449, 355);
|
||||
Controls.Add(label5);
|
||||
Controls.Add(numericUpDownComponentCount);
|
||||
Controls.Add(buttonBack);
|
||||
Controls.Add(ButtonSave);
|
||||
Controls.Add(label3);
|
||||
@ -142,6 +173,7 @@
|
||||
Name = "FormPurchase";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Поставка";
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownComponentCount).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
@ -157,5 +189,7 @@
|
||||
private Label label3;
|
||||
private Button buttonBack;
|
||||
private Button ButtonSave;
|
||||
private NumericUpDown numericUpDownComponentCount;
|
||||
private Label label5;
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
using ProjectConfectFactory.Entities;
|
||||
using ProjectConfectFactory.Repositories;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace ProjectConfectFactory.Forms;
|
||||
|
||||
@ -21,6 +22,7 @@ public partial class FormPurchase : Form
|
||||
comboBoxComponent.DataSource = componentRepository.ReadComponents();
|
||||
comboBoxComponent.DisplayMember = "Name";
|
||||
comboBoxComponent.ValueMember = "Id";
|
||||
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
@ -32,7 +34,7 @@ public partial class FormPurchase : Form
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
|
||||
_purchaseRepository.CreatePurchase(Purchase.CreateOpeartion(0, (int)comboBoxSellerName.SelectedValue!, (int)comboBoxComponent.SelectedValue!));
|
||||
_purchaseRepository.CreatePurchase(Purchase.CreateOpeartion(0, (int)comboBoxSellerName.SelectedValue!, (int)comboBoxComponent.SelectedValue!, (decimal) numericUpDownComponentCount.Value));
|
||||
|
||||
Close();
|
||||
}
|
||||
|
@ -84,6 +84,7 @@
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(dataGridViewPurchases);
|
||||
Controls.Add(panel1);
|
||||
MinimumSize = new Size(818, 497);
|
||||
Name = "FormPurchases";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Поставки";
|
||||
|
@ -41,6 +41,7 @@
|
||||
//
|
||||
// textBoxSellerName
|
||||
//
|
||||
textBoxSellerName.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
textBoxSellerName.Location = new Point(230, 66);
|
||||
textBoxSellerName.Name = "textBoxSellerName";
|
||||
textBoxSellerName.Size = new Size(218, 27);
|
||||
@ -48,6 +49,7 @@
|
||||
//
|
||||
// textBoxSellerPhone
|
||||
//
|
||||
textBoxSellerPhone.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
textBoxSellerPhone.Location = new Point(230, 130);
|
||||
textBoxSellerPhone.Name = "textBoxSellerPhone";
|
||||
textBoxSellerPhone.Size = new Size(218, 27);
|
||||
@ -55,6 +57,7 @@
|
||||
//
|
||||
// comboBoxSellerDelivTime
|
||||
//
|
||||
comboBoxSellerDelivTime.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
comboBoxSellerDelivTime.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxSellerDelivTime.FormattingEnabled = true;
|
||||
comboBoxSellerDelivTime.Location = new Point(230, 189);
|
||||
@ -105,6 +108,7 @@
|
||||
//
|
||||
// ButtonSellerSave
|
||||
//
|
||||
ButtonSellerSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
ButtonSellerSave.Location = new Point(71, 251);
|
||||
ButtonSellerSave.Name = "ButtonSellerSave";
|
||||
ButtonSellerSave.Size = new Size(94, 29);
|
||||
@ -115,6 +119,7 @@
|
||||
//
|
||||
// ButtonSellerBack
|
||||
//
|
||||
ButtonSellerBack.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
ButtonSellerBack.Location = new Point(315, 251);
|
||||
ButtonSellerBack.Name = "ButtonSellerBack";
|
||||
ButtonSellerBack.Size = new Size(94, 29);
|
||||
@ -138,6 +143,7 @@
|
||||
Controls.Add(comboBoxSellerDelivTime);
|
||||
Controls.Add(textBoxSellerPhone);
|
||||
Controls.Add(textBoxSellerName);
|
||||
MinimumSize = new Size(500, 350);
|
||||
Name = "FormSeller";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Поставщик";
|
||||
|
@ -89,10 +89,10 @@
|
||||
dataGridViewSellers.AllowUserToDeleteRows = false;
|
||||
dataGridViewSellers.AllowUserToResizeColumns = false;
|
||||
dataGridViewSellers.AllowUserToResizeRows = false;
|
||||
dataGridViewSellers.Anchor = AnchorStyles.Left | AnchorStyles.Right;
|
||||
dataGridViewSellers.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridViewSellers.BackgroundColor = Color.Bisque;
|
||||
dataGridViewSellers.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewSellers.Dock = DockStyle.Fill;
|
||||
dataGridViewSellers.GridColor = Color.Bisque;
|
||||
dataGridViewSellers.Location = new Point(0, 0);
|
||||
dataGridViewSellers.MultiSelect = false;
|
||||
@ -111,6 +111,7 @@
|
||||
ClientSize = new Size(932, 453);
|
||||
Controls.Add(dataGridViewSellers);
|
||||
Controls.Add(panel1);
|
||||
MinimumSize = new Size(950, 500);
|
||||
Name = "FormSellers";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Поставщики";
|
||||
|
@ -121,7 +121,7 @@
|
||||
<data name="buttonUpd.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||
vwAADr8BOAVTJAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAED/SURBVHhe7d0H
|
||||
vQAADr0BR/uQrQAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAED/SURBVHhe7d0H
|
||||
mBRF/sbxH3EBQdIRFAUFxZxFwRMzoqfomQMmBBWz3p05Y8CsiJjPiIoIiqinglkMcIBgOPXU81RUUEwY
|
||||
Ti/V/6m9Hf+zVb1Lh+rprp7v+zyf5/FZ2dnqmZqud3p6ekQIyWeWFZEhInKxiEwRkb+IyGIR+YeI/FtE
|
||||
vhKRD0TkKRG5XkQOFZGVzRshtekmIvuKyFUi8riIvFN3//0sIv+s+2/9M/3/9L/R/1b/DrGj55iea3rO
|
||||
@ -405,7 +405,7 @@
|
||||
<data name="buttonDel.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAYAAAD0eNT6AAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
|
||||
vgAADr4B6kKxwAAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAA65SURBVHhe7d1t
|
||||
vAAADrwBlbxySQAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAA65SURBVHhe7d1t
|
||||
jKVnXcfxLRZfCYjGhxRQ2E7n+l9z5pxuu6S0EGFeNgRfaaKJSRMD0aAkoCigiVL1nSGakhaRGMMLnyAG
|
||||
oQ+JkQS33W23BWJ8SCmiQrttt43dpcVdt7Lt7prbTEL8ezfu0/zvMzOfT/J9f537evHbOTvnzJ49AAAA
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
|
121
ProjectConfectFactory/ProjectConfectFactory/Forms/OrderDistributionReport.Designer.cs
generated
Normal file
121
ProjectConfectFactory/ProjectConfectFactory/Forms/OrderDistributionReport.Designer.cs
generated
Normal file
@ -0,0 +1,121 @@
|
||||
namespace ProjectConfectFactory.Forms;
|
||||
|
||||
partial class OrderDistributionReport
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
ButtonSelectFileName = new Button();
|
||||
labelFileName = new Label();
|
||||
ButtonCreate = new Button();
|
||||
label2 = new Label();
|
||||
npgsqlDataAdapter1 = new Npgsql.NpgsqlDataAdapter();
|
||||
dateTimePickerODR = new DateTimePicker();
|
||||
SuspendLayout();
|
||||
//
|
||||
// ButtonSelectFileName
|
||||
//
|
||||
ButtonSelectFileName.Location = new Point(12, 21);
|
||||
ButtonSelectFileName.Name = "ButtonSelectFileName";
|
||||
ButtonSelectFileName.Size = new Size(94, 29);
|
||||
ButtonSelectFileName.TabIndex = 0;
|
||||
ButtonSelectFileName.Text = "Выбрать";
|
||||
ButtonSelectFileName.UseVisualStyleBackColor = true;
|
||||
ButtonSelectFileName.Click += ButtonSelectFileName_Click;
|
||||
//
|
||||
// labelFileName
|
||||
//
|
||||
labelFileName.AutoSize = true;
|
||||
labelFileName.BackColor = Color.Bisque;
|
||||
labelFileName.Location = new Point(190, 21);
|
||||
labelFileName.Name = "labelFileName";
|
||||
labelFileName.Size = new Size(45, 20);
|
||||
labelFileName.TabIndex = 1;
|
||||
labelFileName.Text = "Файл";
|
||||
//
|
||||
// ButtonCreate
|
||||
//
|
||||
ButtonCreate.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
ButtonCreate.Location = new Point(94, 149);
|
||||
ButtonCreate.Name = "ButtonCreate";
|
||||
ButtonCreate.Size = new Size(209, 29);
|
||||
ButtonCreate.TabIndex = 4;
|
||||
ButtonCreate.Text = "Сформировать";
|
||||
ButtonCreate.UseVisualStyleBackColor = true;
|
||||
ButtonCreate.Click += ButtonCreate_Click;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.BackColor = Color.Bisque;
|
||||
label2.Location = new Point(23, 88);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(44, 20);
|
||||
label2.TabIndex = 2;
|
||||
label2.Text = "Дата:";
|
||||
//
|
||||
// npgsqlDataAdapter1
|
||||
//
|
||||
npgsqlDataAdapter1.DeleteCommand = null;
|
||||
npgsqlDataAdapter1.InsertCommand = null;
|
||||
npgsqlDataAdapter1.SelectCommand = null;
|
||||
npgsqlDataAdapter1.UpdateCommand = null;
|
||||
//
|
||||
// dateTimePickerODR
|
||||
//
|
||||
dateTimePickerODR.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
dateTimePickerODR.Location = new Point(119, 83);
|
||||
dateTimePickerODR.Name = "dateTimePickerODR";
|
||||
dateTimePickerODR.Size = new Size(250, 27);
|
||||
dateTimePickerODR.TabIndex = 5;
|
||||
//
|
||||
// OrderDistributionReport
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
BackColor = Color.AntiqueWhite;
|
||||
ClientSize = new Size(402, 203);
|
||||
Controls.Add(dateTimePickerODR);
|
||||
Controls.Add(ButtonCreate);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(labelFileName);
|
||||
Controls.Add(ButtonSelectFileName);
|
||||
MinimumSize = new Size(420, 250);
|
||||
Name = "OrderDistributionReport";
|
||||
Text = "Востребованность продуктов";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button ButtonSelectFileName;
|
||||
private Label labelFileName;
|
||||
private Button ButtonCreate;
|
||||
private Label label2;
|
||||
private Npgsql.NpgsqlDataAdapter npgsqlDataAdapter1;
|
||||
private DateTimePicker dateTimePickerODR;
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
|
||||
using ProjectConfectFactory.Reports;
|
||||
using System.Windows.Forms;
|
||||
using Unity;
|
||||
|
||||
namespace ProjectConfectFactory.Forms;
|
||||
|
||||
public partial class OrderDistributionReport : Form
|
||||
{
|
||||
private string _fileName = string.Empty;
|
||||
|
||||
private readonly IUnityContainer _container;
|
||||
public OrderDistributionReport(IUnityContainer container)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
}
|
||||
private void ButtonSelectFileName_Click(object sender, EventArgs e)
|
||||
{
|
||||
var sfd = new SaveFileDialog()
|
||||
{
|
||||
Filter = "Pdf Files | *.pdf"
|
||||
};
|
||||
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_fileName = sfd.FileName;
|
||||
labelFileName.Text = Path.GetFileName(_fileName);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_fileName))
|
||||
{
|
||||
throw new Exception("Отсутствует имя файла для отчета");
|
||||
}
|
||||
if
|
||||
(_container.Resolve<ChartReport>().CreateChart(_fileName, dateTimePickerODR.Value))
|
||||
{
|
||||
MessageBox.Show("Документ сформирован",
|
||||
"Формирование документа",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах",
|
||||
|
||||
"Формирование документа",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при создании очета",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,123 @@
|
||||
<?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>
|
||||
<metadata name="npgsqlDataAdapter1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
@ -10,11 +10,13 @@
|
||||
|
||||
<ItemGroup>
|
||||
<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.Json" Version="9.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Npgsql" Version="9.0.2" />
|
||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||
<PackageReference Include="Serilog" Version="4.2.0" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="9.0.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="9.0.0" />
|
||||
|
@ -0,0 +1,50 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ProjectConfectFactory.Repositories;
|
||||
|
||||
namespace ProjectConfectFactory.Reports;
|
||||
|
||||
internal class ChartReport
|
||||
{
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
|
||||
private readonly ILogger<ChartReport> _logger;
|
||||
|
||||
public ChartReport(IOrderRepository orderRepository, ILogger<ChartReport> logger)
|
||||
{
|
||||
_orderRepository = orderRepository ??
|
||||
throw new ArgumentNullException(nameof(orderRepository));
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
|
||||
public bool CreateChart(string filePath, DateTime dateTime)
|
||||
{
|
||||
try
|
||||
{
|
||||
new PdfBuilder(filePath)
|
||||
.AddHeader("Заказы")
|
||||
.AddPieChart("Купленные продукты", GetData(dateTime))
|
||||
.Build();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
private List<(string Caption, double Value)> GetData(DateTime dateTime)
|
||||
{
|
||||
return _orderRepository
|
||||
.ReadOrder()
|
||||
.Where(x => x.DateTime.Date == dateTime.Date)
|
||||
.SelectMany(x => x.OrderProducts)
|
||||
.GroupBy(x => x.ProductId, (key, group) => new
|
||||
{
|
||||
ProductId = key,
|
||||
TotalCount = group.Sum(x => x.Count)
|
||||
})
|
||||
.Select(x => ($"{x.ProductId}", (double)x.TotalCount))
|
||||
.ToList();
|
||||
}
|
||||
}
|
@ -0,0 +1,99 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ProjectConfectFactory.Entities;
|
||||
using ProjectConfectFactory.Repositories;
|
||||
using System.Data;
|
||||
|
||||
namespace ProjectConfectFactory.Reports;
|
||||
|
||||
internal class DocReport
|
||||
{
|
||||
private readonly IComponentRepository _componentRepository;
|
||||
private readonly IProductRepository _productRepository;
|
||||
private readonly ISellerRepository _sellerRepository;
|
||||
|
||||
private readonly ILogger<DocReport> _logger;
|
||||
|
||||
public DocReport(IProductRepository productRepository, IComponentRepository componentRepository,
|
||||
ISellerRepository sellerRepository, ILogger<DocReport> logger)
|
||||
{
|
||||
|
||||
_productRepository = productRepository ?? throw new ArgumentNullException(nameof(productRepository));
|
||||
_componentRepository = componentRepository ?? throw new ArgumentNullException(nameof(componentRepository));
|
||||
_sellerRepository = sellerRepository ?? throw new ArgumentNullException(nameof(sellerRepository));
|
||||
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
|
||||
public bool CreateDoc(string filePath, bool includeProduct, bool
|
||||
includeComponent, bool includeSeller)
|
||||
{
|
||||
try
|
||||
{
|
||||
var builder = new WordBuilder(filePath)
|
||||
.AddHeader("Документ со справочниками");
|
||||
|
||||
|
||||
if (includeProduct)
|
||||
{
|
||||
builder.AddParagraph("Продукты")
|
||||
.AddTable([2400, 2400, 2400, 1200], GetProduct());
|
||||
}
|
||||
|
||||
if (includeComponent)
|
||||
{
|
||||
builder.AddParagraph("Компоненты")
|
||||
.AddTable([2400, 1200, 2400], GetComponent());
|
||||
}
|
||||
|
||||
if (includeSeller)
|
||||
{
|
||||
builder.AddParagraph("Поставщики")
|
||||
.AddTable([2400, 2400, 1200], GetSeller());
|
||||
}
|
||||
|
||||
builder.Build();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private List<string[]> GetProduct()
|
||||
{
|
||||
var product = _productRepository.ReadProducts();
|
||||
|
||||
var header = new[] { "Наименование", "Тип продукта", "Рецепт", "Цена" };
|
||||
var dataRows = product.Select(product => new[]
|
||||
{
|
||||
product.Name,
|
||||
product.ProductType.ToString(),
|
||||
string.Join(", ", product.Recipe.Select(r => $"{r.ComponentId} ({r.CountComponent})")),
|
||||
product.Price.ToString() }).ToList();
|
||||
|
||||
return new List<string[]> { header }.Concat(dataRows).ToList();
|
||||
}
|
||||
|
||||
private List<string[]> GetComponent()
|
||||
{
|
||||
return [
|
||||
["Наименование", "Единица измерения", "Количество на складе"],
|
||||
.. _componentRepository
|
||||
.ReadComponents()
|
||||
.Select(x => new string[] { x.Name, x.Unit, x.Count.ToString()}),
|
||||
];
|
||||
}
|
||||
private List<string[]> GetSeller()
|
||||
{
|
||||
return [
|
||||
["Наименование", "Телефон", "Тип доставки"],
|
||||
.. _sellerRepository
|
||||
.ReadSellers()
|
||||
.Select(x => new string[] { x.Name, x.Phone, x.DeliveryTime.ToString() }),
|
||||
];
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,342 @@
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using DocumentFormat.OpenXml;
|
||||
|
||||
namespace ProjectConfectFactory.Reports;
|
||||
|
||||
internal class ExcelBuilder
|
||||
{
|
||||
private readonly string _filePath;
|
||||
private readonly SheetData _sheetData;
|
||||
private readonly MergeCells _mergeCells;
|
||||
private readonly Columns _columns;
|
||||
private uint _rowIndex = 0;
|
||||
public ExcelBuilder(string filePath)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(filePath))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(filePath));
|
||||
}
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
File.Delete(filePath);
|
||||
}
|
||||
|
||||
_filePath = filePath;
|
||||
_sheetData = new SheetData();
|
||||
_mergeCells = new MergeCells();
|
||||
_columns = new Columns();
|
||||
_rowIndex = 1;
|
||||
}
|
||||
|
||||
public ExcelBuilder AddHeader(string header, int startIndex, int count)
|
||||
{
|
||||
CreateCell(startIndex, _rowIndex, header, StyleIndex.BoldTextWithoutBorder);
|
||||
for (int i = startIndex + 1; i < startIndex + count; ++i)
|
||||
{
|
||||
CreateCell(i, _rowIndex, "",StyleIndex.SimpleTextWithoutBorder);
|
||||
}
|
||||
|
||||
_mergeCells.Append(new MergeCell()
|
||||
{
|
||||
Reference =
|
||||
new
|
||||
StringValue($"{GetExcelColumnName(startIndex)}{_rowIndex}:{GetExcelColumnName(startIndex + count - 1)}{_rowIndex}")
|
||||
});
|
||||
|
||||
_rowIndex++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExcelBuilder AddParagraph(string text, int columnIndex)
|
||||
{
|
||||
CreateCell(columnIndex, _rowIndex++, text, StyleIndex.SimpleTextWithoutBorder);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public ExcelBuilder AddTable(int[] columnsWidths, List<string[]> data)
|
||||
{
|
||||
if (columnsWidths == null || columnsWidths.Length == 0)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(columnsWidths));
|
||||
}
|
||||
|
||||
if (data == null || data.Count == 0)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(data));
|
||||
}
|
||||
|
||||
if (data.Any(x => x.Length != columnsWidths.Length))
|
||||
{
|
||||
throw new InvalidOperationException("widths.Length != data.Length");
|
||||
}
|
||||
|
||||
uint counter = 1;
|
||||
int coef = 2;
|
||||
_columns.Append(columnsWidths.Select(x => new Column
|
||||
{
|
||||
Min = counter,
|
||||
Max = counter++,
|
||||
Width = x * coef,
|
||||
CustomWidth = true
|
||||
}));
|
||||
|
||||
// Добавление заголовка
|
||||
for (var j = 0; j < data.First().Length; ++j)
|
||||
{
|
||||
CreateCell(j, _rowIndex, data.First()[j], StyleIndex.BoldTextWithBorder);
|
||||
}
|
||||
_rowIndex++;
|
||||
|
||||
// Добавление основных данных
|
||||
for (var i = 1; i < data.Count - 1; ++i)
|
||||
{
|
||||
for (var j = 0; j < data[i].Length; ++j)
|
||||
{
|
||||
CreateCell(j, _rowIndex, data[i][j], StyleIndex.SimpleTextWithBorder);
|
||||
}
|
||||
_rowIndex++;
|
||||
}
|
||||
|
||||
// Добавление итоговой строки
|
||||
for (var j = 0; j < data.Last().Length; ++j)
|
||||
{
|
||||
CreateCell(j, _rowIndex, data.Last()[j], StyleIndex.BoldTextWithBorder);
|
||||
}
|
||||
_rowIndex++;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Build()
|
||||
{
|
||||
using var spreadsheetDocument = SpreadsheetDocument.Create(_filePath,
|
||||
SpreadsheetDocumentType.Workbook);
|
||||
var workbookpart = spreadsheetDocument.AddWorkbookPart();
|
||||
GenerateStyle(workbookpart);
|
||||
workbookpart.Workbook = new Workbook();
|
||||
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
||||
worksheetPart.Worksheet = new Worksheet();
|
||||
if (_columns.HasChildren)
|
||||
{
|
||||
worksheetPart.Worksheet.Append(_columns);
|
||||
}
|
||||
|
||||
worksheetPart.Worksheet.Append(_sheetData);
|
||||
var sheets =
|
||||
spreadsheetDocument.WorkbookPart!.Workbook.AppendChild(new Sheets());
|
||||
var sheet = new Sheet()
|
||||
{
|
||||
Id =
|
||||
spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
|
||||
SheetId = 1,
|
||||
Name = "Лист 1"
|
||||
};
|
||||
|
||||
sheets.Append(sheet);
|
||||
if (_mergeCells.HasChildren)
|
||||
{
|
||||
worksheetPart.Worksheet.InsertAfter(_mergeCells,
|
||||
worksheetPart.Worksheet.Elements<SheetData>().First());
|
||||
}
|
||||
}
|
||||
|
||||
private static void GenerateStyle(WorkbookPart workbookPart)
|
||||
{
|
||||
var workbookStylesPart =
|
||||
workbookPart.AddNewPart<WorkbookStylesPart>();
|
||||
workbookStylesPart.Stylesheet = new Stylesheet();
|
||||
|
||||
var fonts = new Fonts()
|
||||
{
|
||||
Count = 2,
|
||||
KnownFonts =
|
||||
BooleanValue.FromBoolean(true)
|
||||
};
|
||||
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
|
||||
{
|
||||
FontSize = new FontSize() { Val = 11 },
|
||||
FontName = new FontName() { Val = "Calibri" },
|
||||
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
|
||||
FontScheme = new FontScheme()
|
||||
{
|
||||
Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor)
|
||||
}
|
||||
});
|
||||
// TODO добавить шрифт с жирным
|
||||
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
|
||||
{
|
||||
FontSize = new FontSize() { Val = 11 },
|
||||
FontName = new FontName() { Val = "Calibri" },
|
||||
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
|
||||
FontScheme = new FontScheme()
|
||||
{
|
||||
Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor)
|
||||
},
|
||||
Bold = new Bold() { Val = true }
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(fonts);
|
||||
|
||||
// Default Fill
|
||||
var fills = new Fills() { Count = 1 };
|
||||
fills.Append(new Fill
|
||||
{
|
||||
PatternFill = new PatternFill()
|
||||
{
|
||||
PatternType = new
|
||||
EnumValue<PatternValues>(PatternValues.None)
|
||||
}
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(fills);
|
||||
|
||||
// Default Border
|
||||
var borders = new Borders() { Count = 2 };
|
||||
borders.Append(new Border
|
||||
{
|
||||
LeftBorder = new LeftBorder(),
|
||||
RightBorder = new RightBorder(),
|
||||
TopBorder = new TopBorder(),
|
||||
BottomBorder = new BottomBorder(),
|
||||
DiagonalBorder = new DiagonalBorder()
|
||||
});
|
||||
// TODO добавить настройку с границами
|
||||
borders.Append(new Border
|
||||
{
|
||||
LeftBorder = new LeftBorder() { Style = BorderStyleValues.Thin },
|
||||
RightBorder = new RightBorder() { Style = BorderStyleValues.Thin },
|
||||
TopBorder = new TopBorder() { Style = BorderStyleValues.Thin },
|
||||
BottomBorder = new BottomBorder() { Style = BorderStyleValues.Thin },
|
||||
DiagonalBorder = new DiagonalBorder()
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(borders);
|
||||
|
||||
// Default cell format and a date cell format
|
||||
var cellFormats = new CellFormats() { Count = 4 };
|
||||
cellFormats.Append(new CellFormat
|
||||
{
|
||||
NumberFormatId = 0,
|
||||
FormatId = 0,
|
||||
FontId = 0,
|
||||
BorderId = 0,
|
||||
FillId = 0,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Horizontal = HorizontalAlignmentValues.Left,
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true
|
||||
}
|
||||
});
|
||||
// TODO дополнить форматы
|
||||
cellFormats.Append(new CellFormat
|
||||
{
|
||||
NumberFormatId = 0,
|
||||
FormatId = 0,
|
||||
FontId = 0,
|
||||
BorderId = 1,
|
||||
FillId = 0,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Horizontal = HorizontalAlignmentValues.Right,
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true
|
||||
}
|
||||
});
|
||||
cellFormats.Append(new CellFormat
|
||||
{
|
||||
NumberFormatId = 0,
|
||||
FormatId = 0,
|
||||
FontId = 1,
|
||||
BorderId = 0,
|
||||
FillId = 0,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Horizontal = HorizontalAlignmentValues.Center,
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true
|
||||
}
|
||||
});
|
||||
cellFormats.Append(new CellFormat
|
||||
{
|
||||
NumberFormatId = 0,
|
||||
FormatId = 0,
|
||||
FontId = 1,
|
||||
BorderId = 1,
|
||||
FillId = 0,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Horizontal = HorizontalAlignmentValues.Center,
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true
|
||||
}
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(cellFormats);
|
||||
}
|
||||
|
||||
private enum StyleIndex
|
||||
{
|
||||
// TODO дополнить стили
|
||||
SimpleTextWithoutBorder = 0,
|
||||
SimpleTextWithBorder = 1,
|
||||
BoldTextWithoutBorder = 2,
|
||||
BoldTextWithBorder = 3,
|
||||
}
|
||||
private void CreateCell(int columnIndex, uint rowIndex, string text,
|
||||
StyleIndex styleIndex)
|
||||
{
|
||||
var columnName = GetExcelColumnName(columnIndex);
|
||||
var cellReference = columnName + rowIndex;
|
||||
var row = _sheetData.Elements<Row>().FirstOrDefault(r => r.RowIndex!
|
||||
== rowIndex);
|
||||
if (row == null)
|
||||
{
|
||||
row = new Row() { RowIndex = rowIndex };
|
||||
_sheetData.Append(row);
|
||||
}
|
||||
|
||||
var newCell = row.Elements<Cell>()
|
||||
.FirstOrDefault(c => c.CellReference != null &&
|
||||
c.CellReference.Value == columnName + rowIndex);
|
||||
if (newCell == null)
|
||||
{
|
||||
Cell? refCell = null;
|
||||
foreach (Cell cell in row.Elements<Cell>())
|
||||
{
|
||||
if (cell.CellReference?.Value != null &&
|
||||
cell.CellReference.Value.Length == cellReference.Length)
|
||||
{
|
||||
if (string.Compare(cell.CellReference.Value,
|
||||
cellReference, true) > 0)
|
||||
{
|
||||
refCell = cell;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
newCell = new Cell() { CellReference = cellReference };
|
||||
row.InsertBefore(newCell, refCell);
|
||||
}
|
||||
|
||||
newCell.CellValue = new CellValue(text);
|
||||
newCell.DataType = CellValues.String;
|
||||
newCell.StyleIndex = (uint)styleIndex;
|
||||
}
|
||||
|
||||
private static string GetExcelColumnName(int columnNumber)
|
||||
{
|
||||
columnNumber += 1;
|
||||
int dividend = columnNumber;
|
||||
string columnName = string.Empty;
|
||||
int modulo;
|
||||
|
||||
while (dividend > 0)
|
||||
{
|
||||
modulo = (dividend - 1) % 26;
|
||||
columnName = Convert.ToChar(65 + modulo).ToString() +
|
||||
columnName;
|
||||
dividend = (dividend - modulo) / 26;
|
||||
}
|
||||
|
||||
return columnName;
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.DocumentObjectModel.Shapes.Charts;
|
||||
using MigraDoc.Rendering;
|
||||
using System.Text;
|
||||
|
||||
namespace ProjectConfectFactory.Reports;
|
||||
|
||||
internal class PdfBuilder
|
||||
{
|
||||
private readonly string _filePath;
|
||||
private readonly Document _document;
|
||||
|
||||
public PdfBuilder(string filePath)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(filePath))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(filePath));
|
||||
}
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
File.Delete(filePath);
|
||||
}
|
||||
_filePath = filePath;
|
||||
_document = new Document();
|
||||
DefineStyles();
|
||||
}
|
||||
|
||||
public PdfBuilder AddHeader(string header)
|
||||
{
|
||||
_document.AddSection().AddParagraph(header, "NormalBold");
|
||||
return this;
|
||||
}
|
||||
|
||||
public PdfBuilder AddPieChart(string title, List<(string Caption, double Value)> data)
|
||||
{
|
||||
if (data == null || data.Count == 0)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
var chart = new Chart(ChartType.Pie2D);
|
||||
var series = chart.SeriesCollection.AddSeries();
|
||||
series.Add(data.Select(x => x.Value).ToArray());
|
||||
var xseries = chart.XValues.AddXSeries();
|
||||
xseries.Add(data.Select(x => x.Caption).ToArray());
|
||||
chart.DataLabel.Type = DataLabelType.Percent;
|
||||
chart.DataLabel.Position = DataLabelPosition.OutsideEnd;
|
||||
chart.Width = Unit.FromCentimeter(16);
|
||||
chart.Height = Unit.FromCentimeter(12);
|
||||
chart.TopArea.AddParagraph(title);
|
||||
chart.XAxis.MajorTickMark = TickMarkType.Outside;
|
||||
chart.YAxis.MajorTickMark = TickMarkType.Outside;
|
||||
chart.YAxis.HasMajorGridlines = true;
|
||||
chart.PlotArea.LineFormat.Width = 1;
|
||||
chart.PlotArea.LineFormat.Visible = true;
|
||||
chart.TopArea.AddLegend();
|
||||
_document.LastSection.Add(chart);
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Build()
|
||||
{
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
var renderer = new PdfDocumentRenderer(true)
|
||||
{
|
||||
Document = _document
|
||||
};
|
||||
renderer.RenderDocument();
|
||||
renderer.PdfDocument.Save(_filePath);
|
||||
}
|
||||
private void DefineStyles()
|
||||
{
|
||||
var headerStyle = _document.Styles.AddStyle("NormalBold", "Normal");
|
||||
headerStyle.Font.Bold = true;
|
||||
headerStyle.Font.Size = 14;
|
||||
}
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ProjectConfectFactory.Repositories;
|
||||
|
||||
namespace ProjectConfectFactory.Reports;
|
||||
|
||||
internal class TableReport
|
||||
{
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
private readonly IPurchaseRepository _purchaseRepository;
|
||||
|
||||
private readonly ILogger<TableReport> _logger;
|
||||
|
||||
public TableReport(IOrderRepository orderRepository,IPurchaseRepository purchaseRepository,
|
||||
ILogger<TableReport> logger)
|
||||
{
|
||||
_orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
|
||||
_purchaseRepository = purchaseRepository ?? throw new ArgumentNullException(nameof(purchaseRepository));
|
||||
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
|
||||
internal static readonly string[] item = ["Поставщик", "Дата", "Количество купленного компонента", "Продукт", "Количество купленного продукта"];
|
||||
|
||||
public bool CreateTable(string filePath, int ComponentId, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
try
|
||||
{
|
||||
new ExcelBuilder(filePath)
|
||||
.AddHeader("Сводка по компонентам и проудктам", 0, 5)
|
||||
.AddParagraph("за период", 0)
|
||||
.AddTable([10, 10, 15, 10, 15], GetData(ComponentId, startDate, endDate))
|
||||
.Build();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
private List<string[]> GetData(int componentId, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
{
|
||||
var data =
|
||||
_purchaseRepository
|
||||
.ReadPurchases()
|
||||
.Where(x => x.DateTime >= startDate && x.DateTime <= endDate && x.ComponentId == componentId)
|
||||
.Select(x => new
|
||||
{
|
||||
SellerId = (int?)x.SellerId,
|
||||
Date = (DateTime?)x.DateTime,
|
||||
CountIn = (int?)x.Count,
|
||||
ProductId = (int?)null,
|
||||
CountOut = (int?)null
|
||||
}).Union(
|
||||
_orderRepository
|
||||
.ReadOrder()
|
||||
.Where(x => x.DateTime >= startDate && x.DateTime <= endDate)
|
||||
.Select(x => new {
|
||||
SellerId = (int?)null,
|
||||
Date = (DateTime?)x.DateTime,
|
||||
CountIn = (int?)null,
|
||||
ProductId = (int?)x.OrderProducts.FirstOrDefault()?.ProductId,
|
||||
CountOut = (int?)x.OrderProducts.FirstOrDefault()?.Count
|
||||
}))
|
||||
.OrderBy(x => x.Date);
|
||||
|
||||
return new List<string[]>() { item }
|
||||
.Union(
|
||||
data.Select(x => new string[] {
|
||||
x.SellerId.ToString(),
|
||||
x.Date.ToString(),
|
||||
x.CountIn.ToString(),
|
||||
x.ProductId.ToString(),
|
||||
x.CountOut.ToString()
|
||||
}))
|
||||
.Union(
|
||||
[["Всего", "", data.Sum(x => x.CountIn).ToString(), "" ,data.Sum(x=> x.CountOut).ToString()]])
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,137 @@
|
||||
using DocumentFormat.OpenXml.Drawing.Charts;
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
|
||||
namespace ProjectConfectFactory.Reports;
|
||||
|
||||
public 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());
|
||||
var runProperties = run.AppendChild(new RunProperties());
|
||||
runProperties.AppendChild(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;
|
||||
}
|
||||
|
||||
}
|
@ -10,7 +10,7 @@ namespace ProjectConfectFactory.Repositories;
|
||||
|
||||
public interface IPurchaseRepository
|
||||
{
|
||||
IEnumerable<Purchase> ReadPurchases(DateTime? dateForm = null, DateTime? dateTo = null, int? SellerId = null, int? ComponentId = null);
|
||||
IEnumerable<Purchase> ReadPurchases(DateTime? dateForm = null, DateTime? dateTo = null, int? SellerId = null, int? ComponentId = null, int? Count = null);
|
||||
|
||||
void CreatePurchase(Purchase purchase);
|
||||
}
|
||||
|
@ -81,11 +81,17 @@ WHERE Id=@id";
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"SELECT * FROM Orders";
|
||||
var orders = connection.Query<Order>(querySelect);
|
||||
var querySelect = @"
|
||||
SELECT o.*, orr.ProductId, orr.Count, orr.Price FROM orders o
|
||||
INNER JOIN orderProduct orr ON orr.OrderId = o.Id";
|
||||
var orders =
|
||||
connection.Query<TempOrderProducts>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
JsonConvert.SerializeObject(orders));
|
||||
return orders;
|
||||
JsonConvert.SerializeObject(orders));
|
||||
return orders.GroupBy(x => x.Id, y => y,
|
||||
(key, value) =>
|
||||
Order.CreateOpeartion(value.First(),
|
||||
value.Select(z => OrderProducts.CreateElement(0, z.ProductId, z.Count,z.Price)))).ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -4,11 +4,6 @@ using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using ProjectConfectFactory.Entities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectConfectFactory.Repositories.Implementations;
|
||||
|
||||
@ -32,8 +27,8 @@ public class PurchaseRepository : IPurchaseRepository
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"
|
||||
INSERT INTO Purchases (DateTime, SellerId, ComponentId)
|
||||
VALUES (@DateTime, @SellerId, @ComponentId)";
|
||||
INSERT INTO Purchases (DateTime, SellerId, ComponentId, Count)
|
||||
VALUES (@DateTime, @SellerId, @ComponentId, @Count)";
|
||||
connection.Execute(queryInsert, purchase);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -43,7 +38,7 @@ VALUES (@DateTime, @SellerId, @ComponentId)";
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Purchase> ReadPurchases(DateTime? dateForm = null, DateTime? dateTo = null, int? SellerId = null, int? ComponentId = null)
|
||||
public IEnumerable<Purchase> ReadPurchases(DateTime? dateForm = null, DateTime? dateTo = null, int? SellerId = null, int? ComponentId = null, int? Count = null)
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
|
Loading…
x
Reference in New Issue
Block a user