помогите...
This commit is contained in:
parent
29752b766c
commit
ddc9b358cc
@ -11,16 +11,13 @@ public class Employee
|
||||
public int Id { get; private set; }
|
||||
public DateTime Date { get; private set; }
|
||||
public int NumberStorage { get; private set; }
|
||||
//public int StorageSize { get; private set; }
|
||||
|
||||
public static Employee CreateEntity(int id, DateTime date,int numberStorage)
|
||||
{
|
||||
return new Employee
|
||||
{
|
||||
Id = id,
|
||||
Date = date,
|
||||
NumberStorage = numberStorage,
|
||||
//StorageSize = storageSize
|
||||
NumberStorage = numberStorage
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -13,9 +13,9 @@ public class Receipt
|
||||
public ProductType ProductType { get; private set; }
|
||||
public DateTime DateOfReceipt { get; private set; }
|
||||
public int NumberOfPairsReceived { get; private set; }
|
||||
//public int StorageSize { get; private set; }
|
||||
public int ProductId { get; private set; }
|
||||
|
||||
public static Receipt CreateOperation(int id,ProductType productType, DateTime date,int numberOfPairsReceived)
|
||||
public static Receipt CreateOperation(int id,ProductType productType, DateTime date,int numberOfPairsReceived, int productId)
|
||||
{
|
||||
return new Receipt
|
||||
{
|
||||
@ -23,6 +23,7 @@ public class Receipt
|
||||
ProductType = productType,
|
||||
DateOfReceipt = date,
|
||||
NumberOfPairsReceived = numberOfPairsReceived,
|
||||
ProductId = productId
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1,9 +1,12 @@
|
||||
using ShoeStore.Entities.Enums;
|
||||
using DocumentFormat.OpenXml.Office2010.Excel;
|
||||
using ShoeStore.Entities.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Unity;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace ShoeStore.Entities;
|
||||
|
||||
@ -11,23 +14,30 @@ public class Sale
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public DateTime DateOfSale { get; private set; }
|
||||
|
||||
public int SalesNumber { get; private set; }
|
||||
public IEnumerable<ProductSale> Product
|
||||
{
|
||||
get;
|
||||
private set;
|
||||
} = [];
|
||||
|
||||
public static Sale CreateOperation(int id, int salesNumber, DateTime date, IEnumerable<ProductSale> product)
|
||||
public static Sale CreateOperation(int id, DateTime date, IEnumerable<ProductSale> product)
|
||||
{
|
||||
return new Sale
|
||||
{
|
||||
Id = id,
|
||||
DateOfSale = date,
|
||||
SalesNumber = salesNumber,
|
||||
Product = product
|
||||
};
|
||||
}
|
||||
|
||||
public static Sale CreateOperation(TempProductSale tempProductSale, IEnumerable<ProductSale> products)
|
||||
{
|
||||
return new Sale
|
||||
{
|
||||
Id = tempProductSale.Id,
|
||||
DateOfSale = tempProductSale.DateOfSale,
|
||||
Product = products
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
15
ShoeStore/Entities/TempProductSale.cs
Normal file
15
ShoeStore/Entities/TempProductSale.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ShoeStore.Entities;
|
||||
|
||||
public class TempProductSale
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public DateTime DateOfSale { get; private set; }
|
||||
public int ProductId { get; private set; }
|
||||
public int SalesNumber { get; private set; }
|
||||
}
|
113
ShoeStore/Forms/FormDistributionReport.Designer.cs
generated
Normal file
113
ShoeStore/Forms/FormDistributionReport.Designer.cs
generated
Normal file
@ -0,0 +1,113 @@
|
||||
namespace ShoeStore.Forms
|
||||
{
|
||||
partial class FormDistributionReport
|
||||
{
|
||||
/// <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();
|
||||
label1 = new Label();
|
||||
dateTimePicker = new DateTimePicker();
|
||||
buttonCreate = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonSelectFileName
|
||||
//
|
||||
buttonSelectFileName.BackColor = Color.FromArgb(192, 255, 192);
|
||||
buttonSelectFileName.Location = new Point(10, 17);
|
||||
buttonSelectFileName.Margin = new Padding(3, 2, 3, 2);
|
||||
buttonSelectFileName.Name = "buttonSelectFileName";
|
||||
buttonSelectFileName.Size = new Size(113, 22);
|
||||
buttonSelectFileName.TabIndex = 0;
|
||||
buttonSelectFileName.Text = "Выбрать";
|
||||
buttonSelectFileName.UseVisualStyleBackColor = false;
|
||||
buttonSelectFileName.Click += ButtonSelectFileName_Click;
|
||||
//
|
||||
// labelFileName
|
||||
//
|
||||
labelFileName.AutoSize = true;
|
||||
labelFileName.Location = new Point(157, 20);
|
||||
labelFileName.Name = "labelFileName";
|
||||
labelFileName.Size = new Size(36, 15);
|
||||
labelFileName.TabIndex = 1;
|
||||
labelFileName.Text = "Файл";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(10, 61);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(35, 15);
|
||||
label1.TabIndex = 2;
|
||||
label1.Text = "Дата:";
|
||||
//
|
||||
// dateTimePicker
|
||||
//
|
||||
dateTimePicker.Location = new Point(157, 57);
|
||||
dateTimePicker.Margin = new Padding(3, 2, 3, 2);
|
||||
dateTimePicker.Name = "dateTimePicker";
|
||||
dateTimePicker.Size = new Size(161, 23);
|
||||
dateTimePicker.TabIndex = 3;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.BackColor = Color.FromArgb(192, 255, 192);
|
||||
buttonCreate.Location = new Point(10, 110);
|
||||
buttonCreate.Margin = new Padding(3, 2, 3, 2);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(306, 22);
|
||||
buttonCreate.TabIndex = 4;
|
||||
buttonCreate.Text = "Сформировать";
|
||||
buttonCreate.UseVisualStyleBackColor = false;
|
||||
buttonCreate.Click += ButtonCreate_Click;
|
||||
//
|
||||
// FormDistribtionReport
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(346, 170);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(dateTimePicker);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(labelFileName);
|
||||
Controls.Add(buttonSelectFileName);
|
||||
Margin = new Padding(3, 2, 3, 2);
|
||||
Name = "FormDistribtionReport";
|
||||
Text = "FormInvoiceDistributionReport";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonSelectFileName;
|
||||
private Label labelFileName;
|
||||
private Label label1;
|
||||
private DateTimePicker dateTimePicker;
|
||||
private Button buttonCreate;
|
||||
}
|
||||
}
|
66
ShoeStore/Forms/FormDistributionReport.cs
Normal file
66
ShoeStore/Forms/FormDistributionReport.cs
Normal file
@ -0,0 +1,66 @@
|
||||
using ShoeStore.Reports;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Unity;
|
||||
|
||||
namespace ShoeStore.Forms
|
||||
{
|
||||
public partial class FormDistributionReport : Form
|
||||
{
|
||||
private string _fileName = string.Empty;
|
||||
|
||||
private readonly IUnityContainer _container;
|
||||
public FormDistributionReport(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, dateTimePicker.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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
120
ShoeStore/Forms/FormDistributionReport.resx
Normal file
120
ShoeStore/Forms/FormDistributionReport.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
148
ShoeStore/Forms/FormProductReport.Designer.cs
generated
Normal file
148
ShoeStore/Forms/FormProductReport.Designer.cs
generated
Normal file
@ -0,0 +1,148 @@
|
||||
namespace ShoeStore.Forms
|
||||
{
|
||||
partial class FormProductReport
|
||||
{
|
||||
/// <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();
|
||||
label3 = new Label();
|
||||
label4 = new Label();
|
||||
textBoxFilePath = new TextBox();
|
||||
dateTimePickerStartDate = new DateTimePicker();
|
||||
dateTimePickerEndDate = new DateTimePicker();
|
||||
buttonSelectFilePath = new Button();
|
||||
buttonMakeReport = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(19, 15);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(90, 15);
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "Путь до файла:";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(19, 54);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(77, 15);
|
||||
label3.TabIndex = 2;
|
||||
label3.Text = "Дата начала:";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.AutoSize = true;
|
||||
label4.Location = new Point(19, 93);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(71, 15);
|
||||
label4.TabIndex = 3;
|
||||
label4.Text = "Дата конца:";
|
||||
//
|
||||
// textBoxFilePath
|
||||
//
|
||||
textBoxFilePath.Location = new Point(164, 15);
|
||||
textBoxFilePath.Margin = new Padding(3, 2, 3, 2);
|
||||
textBoxFilePath.Name = "textBoxFilePath";
|
||||
textBoxFilePath.ReadOnly = true;
|
||||
textBoxFilePath.Size = new Size(129, 23);
|
||||
textBoxFilePath.TabIndex = 4;
|
||||
//
|
||||
// dateTimePickerStartDate
|
||||
//
|
||||
dateTimePickerStartDate.Location = new Point(164, 54);
|
||||
dateTimePickerStartDate.Margin = new Padding(3, 2, 3, 2);
|
||||
dateTimePickerStartDate.Name = "dateTimePickerStartDate";
|
||||
dateTimePickerStartDate.Size = new Size(159, 23);
|
||||
dateTimePickerStartDate.TabIndex = 5;
|
||||
//
|
||||
// dateTimePickerEndDate
|
||||
//
|
||||
dateTimePickerEndDate.Location = new Point(164, 89);
|
||||
dateTimePickerEndDate.Margin = new Padding(3, 2, 3, 2);
|
||||
dateTimePickerEndDate.Name = "dateTimePickerEndDate";
|
||||
dateTimePickerEndDate.Size = new Size(159, 23);
|
||||
dateTimePickerEndDate.TabIndex = 6;
|
||||
//
|
||||
// buttonSelectFilePath
|
||||
//
|
||||
buttonSelectFilePath.BackColor = Color.FromArgb(192, 192, 255);
|
||||
buttonSelectFilePath.Location = new Point(298, 15);
|
||||
buttonSelectFilePath.Margin = new Padding(3, 2, 3, 2);
|
||||
buttonSelectFilePath.Name = "buttonSelectFilePath";
|
||||
buttonSelectFilePath.Size = new Size(24, 22);
|
||||
buttonSelectFilePath.TabIndex = 7;
|
||||
buttonSelectFilePath.Text = "..";
|
||||
buttonSelectFilePath.UseVisualStyleBackColor = false;
|
||||
buttonSelectFilePath.Click += ButtonSelectFilePath_Click;
|
||||
//
|
||||
// buttonMakeReport
|
||||
//
|
||||
buttonMakeReport.BackColor = Color.FromArgb(192, 192, 255);
|
||||
buttonMakeReport.Location = new Point(19, 135);
|
||||
buttonMakeReport.Margin = new Padding(3, 2, 3, 2);
|
||||
buttonMakeReport.Name = "buttonMakeReport";
|
||||
buttonMakeReport.Size = new Size(304, 22);
|
||||
buttonMakeReport.TabIndex = 9;
|
||||
buttonMakeReport.Text = "Сформировать";
|
||||
buttonMakeReport.UseVisualStyleBackColor = false;
|
||||
buttonMakeReport.Click += ButtonMakeReport_Click;
|
||||
//
|
||||
// FormProductReport
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(358, 175);
|
||||
Controls.Add(buttonMakeReport);
|
||||
Controls.Add(buttonSelectFilePath);
|
||||
Controls.Add(dateTimePickerEndDate);
|
||||
Controls.Add(dateTimePickerStartDate);
|
||||
Controls.Add(textBoxFilePath);
|
||||
Controls.Add(label4);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(label1);
|
||||
Margin = new Padding(3, 2, 3, 2);
|
||||
Name = "FormProductReport";
|
||||
Text = "FormProductReport";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private Label label3;
|
||||
private Label label4;
|
||||
private TextBox textBoxFilePath;
|
||||
private DateTimePicker dateTimePickerStartDate;
|
||||
private DateTimePicker dateTimePickerEndDate;
|
||||
private Button buttonSelectFilePath;
|
||||
private Button buttonMakeReport;
|
||||
}
|
||||
}
|
66
ShoeStore/Forms/FormProductReport.cs
Normal file
66
ShoeStore/Forms/FormProductReport.cs
Normal file
@ -0,0 +1,66 @@
|
||||
using ShoeStore.Reports;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Unity;
|
||||
|
||||
namespace ShoeStore.Forms
|
||||
{
|
||||
public partial class FormProductReport : Form
|
||||
{
|
||||
IUnityContainer _container;
|
||||
|
||||
public FormProductReport(IUnityContainer container)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
}
|
||||
|
||||
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 (dateTimePickerEndDate.Value <= dateTimePickerStartDate.Value)
|
||||
{
|
||||
throw new Exception("Дата начала должна быть раньше даты окончания");
|
||||
}
|
||||
if (_container.Resolve<TableReport>().CreateTable(textBoxFilePath.Text, dateTimePickerStartDate.Value, dateTimePickerEndDate.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
ShoeStore/Forms/FormProductReport.resx
Normal file
120
ShoeStore/Forms/FormProductReport.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -102,7 +102,7 @@ namespace ShoeStore.Forms
|
||||
{
|
||||
try
|
||||
{
|
||||
//_container.Resolve<FormStorages>().ShowDialog();
|
||||
//_container.Resolve<FormProducts>().ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
29
ShoeStore/Forms/FormReceipt.Designer.cs
generated
29
ShoeStore/Forms/FormReceipt.Designer.cs
generated
@ -36,6 +36,8 @@
|
||||
comboBoxProdctType = new ComboBox();
|
||||
label1 = new Label();
|
||||
dateTimePickerDate = new DateTimePicker();
|
||||
label2 = new Label();
|
||||
comboBoxProduct = new ComboBox();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownNumOfPairs).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
@ -57,7 +59,7 @@
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(258, 255);
|
||||
buttonCancel.Location = new Point(246, 307);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(102, 23);
|
||||
buttonCancel.TabIndex = 18;
|
||||
@ -67,7 +69,7 @@
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(58, 255);
|
||||
buttonSave.Location = new Point(46, 307);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(100, 23);
|
||||
buttonSave.TabIndex = 17;
|
||||
@ -108,11 +110,30 @@
|
||||
dateTimePickerDate.Size = new Size(132, 23);
|
||||
dateTimePickerDate.TabIndex = 21;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(27, 223);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(56, 15);
|
||||
label2.TabIndex = 23;
|
||||
label2.Text = "Продукт:";
|
||||
//
|
||||
// comboBoxProduct
|
||||
//
|
||||
comboBoxProduct.FormattingEnabled = true;
|
||||
comboBoxProduct.Location = new Point(246, 220);
|
||||
comboBoxProduct.Name = "comboBoxProduct";
|
||||
comboBoxProduct.Size = new Size(121, 23);
|
||||
comboBoxProduct.TabIndex = 24;
|
||||
//
|
||||
// FormReceipt
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(398, 330);
|
||||
ClientSize = new Size(398, 369);
|
||||
Controls.Add(comboBoxProduct);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(dateTimePickerDate);
|
||||
Controls.Add(comboBoxProdctType);
|
||||
@ -137,5 +158,7 @@
|
||||
private ComboBox comboBoxProdctType;
|
||||
private Label label1;
|
||||
private DateTimePicker dateTimePickerDate;
|
||||
private Label label2;
|
||||
private ComboBox comboBoxProduct;
|
||||
}
|
||||
}
|
@ -20,7 +20,7 @@ namespace ShoeStore.Froms
|
||||
//private int? _receiptId;
|
||||
|
||||
|
||||
public FormReceipt(IReceiptRepository receiptRepository)
|
||||
public FormReceipt(IReceiptRepository receiptRepository, IProductRepository productRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_receiptRepository = receiptRepository ?? throw new ArgumentNullException(nameof(receiptRepository));
|
||||
@ -30,6 +30,10 @@ namespace ShoeStore.Froms
|
||||
comboBoxProdctType.Items.Add(elem);
|
||||
}
|
||||
|
||||
comboBoxProduct.DataSource = productRepository.ReadProducts();
|
||||
comboBoxProduct.DisplayMember = "NameOfShoes";
|
||||
comboBoxProduct.ValueMember = "Id";
|
||||
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
@ -45,7 +49,7 @@ namespace ShoeStore.Froms
|
||||
{
|
||||
throw new Exception("Не выбран тип продукта");
|
||||
}
|
||||
if (numericUpDownNumOfPairs.Value < 0)
|
||||
if (numericUpDownNumOfPairs.Value < 0 || comboBoxProduct.SelectedIndex < 0)
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
@ -53,7 +57,8 @@ namespace ShoeStore.Froms
|
||||
0,
|
||||
productType,
|
||||
dateTimePickerDate.Value,
|
||||
Convert.ToInt32(numericUpDownNumOfPairs.Value)));
|
||||
Convert.ToInt32(numericUpDownNumOfPairs.Value),
|
||||
(int)comboBoxProduct.SelectedValue!));
|
||||
Close();
|
||||
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ public partial class FormSale : Form
|
||||
}
|
||||
|
||||
|
||||
_saleRepository.CreateSale(Sale.CreateOperation(0, Convert.ToInt32(numericUpDownStorageSize.Value), dateTimePickerDate.Value, CreateListProductSaleFromDataGrid()));
|
||||
_saleRepository.CreateSale(Sale.CreateOperation(0, dateTimePickerDate.Value, CreateListProductSaleFromDataGrid()));
|
||||
|
||||
MessageBox.Show("Данные успешно добавлены!", "Информация", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
Close();
|
||||
|
46
ShoeStore/Reports/ChartReport.cs
Normal file
46
ShoeStore/Reports/ChartReport.cs
Normal file
@ -0,0 +1,46 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ShoeStore.Repositories;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ShoeStore.Reports;
|
||||
|
||||
public class ChartReport
|
||||
{
|
||||
private readonly IReceiptRepository _receiptRepository;
|
||||
private readonly ILogger<ChartReport> _logger;
|
||||
public ChartReport(IReceiptRepository receiptRepository, ILogger<ChartReport> logger)
|
||||
{
|
||||
_receiptRepository = receiptRepository ?? throw new ArgumentNullException(nameof(receiptRepository));
|
||||
_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 _receiptRepository
|
||||
.ReadReceipts()
|
||||
.Where(x => x.DateOfReceipt.Date == dateTime.Date)
|
||||
.GroupBy(x => x.ProductId, (key, group) => new { ID = key, Count = group.Sum(y => y.NumberOfPairsReceived) })
|
||||
.Select(x => (x.ID.ToString(), (double)x.Count))
|
||||
.ToList();
|
||||
}
|
||||
}
|
87
ShoeStore/Reports/PdfBuilder.cs
Normal file
87
ShoeStore/Reports/PdfBuilder.cs
Normal file
@ -0,0 +1,87 @@
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.DocumentObjectModel.Shapes.Charts;
|
||||
using MigraDoc.Rendering;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ShoeStore.Reports;
|
||||
|
||||
public 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.AddStyle("NormalBold", "Normal");
|
||||
headerStyle.Font.Bold = true;
|
||||
headerStyle.Font.Size = 14;
|
||||
}
|
||||
}
|
@ -24,14 +24,13 @@ internal class TableReport
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
|
||||
public bool CreateTable(string filePath, int productID, DateTime startDate, DateTime endDate)
|
||||
public bool CreateTable(string filePath, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
try
|
||||
|
||||
try {
|
||||
new ExcelBuilder(filePath)
|
||||
.AddHeader("Сводка по движению товара", 0, 4)
|
||||
.AddParagraph("за период", 0)
|
||||
.AddTable([10, 10, 15, 15], GetData(productID, startDate, endDate))
|
||||
.AddTable([10, 10, 15, 15], GetData(startDate, endDate))
|
||||
.Build();
|
||||
return true;
|
||||
}
|
||||
@ -42,23 +41,23 @@ internal class TableReport
|
||||
}
|
||||
}
|
||||
|
||||
private List<string[]> GetData(int productID, DateTime startDate, DateTime endDate)
|
||||
private List<string[]> GetData(DateTime startDate, DateTime endDate)
|
||||
{
|
||||
var data = _saleRepository
|
||||
.ReadSales()
|
||||
.Where(x => x.DateOfSale >= startDate && x.DateOfSale <= endDate && x..Any(y => y.ProductID == productID))
|
||||
.Select(x => new { x.Products.First(y => y.ProductID == productID).ProductID, Date = x.DateOfReceipt, CountIn = (int?)null, CountOut = (int?)x.Products.FirstOrDefault(y => y.ProductID == productID)?.Count })
|
||||
.Where(x => x.DateOfSale >= startDate && x.DateOfSale <= endDate && x.Product.Any(y => y.SaleId == x.Id))
|
||||
.Select(x => new { x.Product.First(y => y.SaleId == x.Id).ProductId, Date = x.DateOfSale, CountIn = (int?)null, CountOut = (int?)x.Product.FirstOrDefault(y => y.SaleId == x.Id)?.SalesNumber })
|
||||
.Union(
|
||||
_saleRepository
|
||||
.ReadSales()
|
||||
.Where(x => x.DateOfSale >= startDate && x.DateOfSale <= endDate && x.ProductID == productID && x.MovementType == Movement.Reseipt)
|
||||
.Select(x => new { x.ProductID, x.Date, CountIn = (int?)x.Count, CountOut = (int?)null }))
|
||||
_receiptRepository
|
||||
.ReadReceipts()
|
||||
.Where(x => x.DateOfReceipt >= startDate && x.DateOfReceipt <= endDate)
|
||||
.Select(x => new { x.ProductId, Date = x.DateOfReceipt, CountIn = (int?)x.NumberOfPairsReceived, CountOut = (int?)null }))
|
||||
.OrderBy(x => x.Date);
|
||||
return
|
||||
new List<string[]>() { item }
|
||||
.Union(
|
||||
data
|
||||
.Select(x => new string[] { x.ProductID.ToString(), x.Date.ToString(), x.CountIn?.ToString() ?? string.Empty, x.CountOut?.ToString() ?? string.Empty }))
|
||||
.Select(x => new string[] { x.ProductId.ToString(), x.Date.ToString(), x.CountIn?.ToString() ?? string.Empty, x.CountOut?.ToString() ?? string.Empty }))
|
||||
.Union([["Всего", "", data.Sum(x => x.CountIn ?? 0).ToString(), data.Sum(x => x.CountOut ?? 0).ToString()]])
|
||||
.ToList();
|
||||
|
||||
|
@ -8,6 +8,6 @@ namespace ShoeStore.Repositories.Implementations;
|
||||
|
||||
internal class ConnectionString : IConnectionString
|
||||
{
|
||||
string IConnectionString.ConnectionString => "Server=127.0.0.1;Port=5432;Database=shoestore_oop;Uid=postgres;Pwd=01010101;";
|
||||
string IConnectionString.ConnectionString => "Server=127.0.0.1;Port=5432;Database=shoestore_otp;Uid=postgres;Pwd=01010101;";
|
||||
|
||||
}
|
@ -28,8 +28,8 @@ public class EmployeeRepository : IEmployeeRepository
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"INSERT INTO Employees (NumberStorage, StorageSize, Date)
|
||||
VALUES (@NumberStorage, @StorageSize, @Date)";
|
||||
var queryInsert = @"INSERT INTO Employee (NumberStorage, Date)
|
||||
VALUES (@NumberStorage, @Date)";
|
||||
connection.Execute(queryInsert, employee);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -46,7 +46,7 @@ public class EmployeeRepository : IEmployeeRepository
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryDelete = @"DELETE FROM Employees WHERE ID=@id";
|
||||
var queryDelete = @"DELETE FROM Employee WHERE ID=@id";
|
||||
connection.Execute(queryDelete, new { id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -63,7 +63,7 @@ public class EmployeeRepository : IEmployeeRepository
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"SELECT * FROM Employees WHERE ID=@id";
|
||||
var querySelect = @"SELECT * FROM Employee WHERE ID=@id";
|
||||
var employee = connection.QueryFirst<Employee>(querySelect, new
|
||||
{
|
||||
id
|
||||
@ -85,7 +85,7 @@ public IEnumerable<Employee> ReadEmployees()
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM Employees";
|
||||
var querySelect = "SELECT * FROM Employee";
|
||||
var employee = connection.Query<Employee>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
JsonConvert.SerializeObject(employee));
|
||||
@ -106,7 +106,7 @@ public IEnumerable<Employee> ReadEmployees()
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryUpdate = @"UPDATE Employees SET
|
||||
var queryUpdate = @"UPDATE Employee SET
|
||||
NumberStorage=@NumberStorage,
|
||||
StorageSize=@StorageSize,
|
||||
Date=@Date
|
||||
|
@ -37,23 +37,10 @@ public class ProductRepository : IProductRepository
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
connection.Open();
|
||||
using var transaction = connection.BeginTransaction();
|
||||
var queryInsert = @"INSERT INTO Product (Nameofshoes, manufacturingcompany, price)
|
||||
VALUES (@Nameofshoes, @manufacturingcompany, @price);
|
||||
SELECT MAX(Id) FROM Product";
|
||||
var ProductID = connection.QueryFirst<int>(queryInsert, product, transaction);
|
||||
var querySubInsert = @"INSERT INTO Product_Sales (ID, Amount, SalesNumber)
|
||||
VALUES (@ID, @Amount, @SalesNumber)";
|
||||
foreach (var elem in product.Sales)
|
||||
{
|
||||
connection.Execute(querySubInsert, new
|
||||
{
|
||||
ProductID,
|
||||
elem.SaleId,
|
||||
elem.SalesNumber
|
||||
}, transaction);
|
||||
}
|
||||
transaction.Commit();
|
||||
connection.Execute(queryInsert, product);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -33,8 +33,8 @@ public class ReceiptRepository : IReceiptRepository
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"INSERT INTO Receipts (ProductType, NumberOfPairsReceived, DateOfReceipt)
|
||||
VALUES (@ProductType, @NumberOfPairsReceived, @DateOfReceipt)";
|
||||
var queryInsert = @"INSERT INTO Receipt (ProductType, NumberOfPairsReceived, DateOfReceipt, ProductId)
|
||||
VALUES (@ProductType, @NumberOfPairsReceived, @DateOfReceipt, @ProductId)";
|
||||
connection.Execute(queryInsert, receipt);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -50,7 +50,7 @@ public class ReceiptRepository : IReceiptRepository
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM Receipts";
|
||||
var querySelect = "SELECT * FROM Receipt";
|
||||
var receipt = connection.Query<Receipt>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
JsonConvert.SerializeObject(receipt));
|
||||
|
@ -8,6 +8,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Unity;
|
||||
|
||||
namespace ShoeStore.Repositories.Implementations;
|
||||
|
||||
@ -35,19 +36,19 @@ public class SaleRepository : ISaleRepository
|
||||
connection.Open();
|
||||
using var transaction = connection.BeginTransaction();
|
||||
var queryInsert = @"
|
||||
INSERT INTO Sales (SalesNumber, DateOfSale)
|
||||
VALUES (@SalesNumber, @DateOfSale);
|
||||
SELECT MAX(Id) FROM Sales";
|
||||
INSERT INTO Sale (DateOfSale)
|
||||
VALUES (@DateOfSale);
|
||||
SELECT MAX(Id) FROM Sale";
|
||||
var visitingId = connection.QueryFirst<int>(queryInsert, sale, transaction);
|
||||
var querySubInsert = @"
|
||||
INSERT INTO Product_Sales (Amount, SalesNumber)
|
||||
VALUES (@Amount,@SalesNumber)";
|
||||
INSERT INTO ProductSale (ProductId, SaleId, SalesNumber)
|
||||
VALUES (@ProductId, @visitingId, @SalesNumber)";
|
||||
foreach (var elem in sale.Product)
|
||||
{
|
||||
connection.Execute(querySubInsert, new
|
||||
{
|
||||
elem.ProductId,
|
||||
elem.SaleId,
|
||||
visitingId,
|
||||
elem.SalesNumber
|
||||
}, transaction);
|
||||
}
|
||||
@ -67,7 +68,7 @@ public class SaleRepository : ISaleRepository
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryDelete = @"DELETE FROM Sales
|
||||
var queryDelete = @"DELETE FROM Sale
|
||||
WHERE ID=@id";
|
||||
connection.Execute(queryDelete, new { id });
|
||||
}
|
||||
@ -85,12 +86,15 @@ public class SaleRepository : ISaleRepository
|
||||
{
|
||||
using var connection = new
|
||||
NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"SELECT * FROM Sales";
|
||||
var sale =
|
||||
connection.Query<Sale>(querySelect);
|
||||
var querySelect = @"SELECT s.*, ps.ProductId, ps.SalesNumber
|
||||
FROM Sale s
|
||||
INNER JOIN ProductSale ps ON ps.SaleId = s.Id";
|
||||
var sale = connection.Query<TempProductSale>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
JsonConvert.SerializeObject(sale));
|
||||
return sale;
|
||||
return sale.GroupBy(x => x.Id, y => y,
|
||||
(key, value) => Sale.CreateOperation(value.First(),
|
||||
value.Select(z => ProductSale.CreateOperation( z.ProductId, z.Id, z.SalesNumber)))).ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -30,7 +30,7 @@ public class StorageRepository : IStorageRepository
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"INSERT INTO Storages (Size, NumberStorage, QuantityInStock)
|
||||
var queryInsert = @"INSERT INTO Storage (Size, NumberStorage, QuantityInStock)
|
||||
VALUES (@Size, @NumberStorage, @QuantityInStock)";
|
||||
connection.Execute(queryInsert, storage);
|
||||
}
|
||||
@ -48,7 +48,7 @@ public class StorageRepository : IStorageRepository
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryDelete = @"DELETE FROM Storages WHERE ID=@id";
|
||||
var queryDelete = @"DELETE FROM Storage WHERE ID=@id";
|
||||
connection.Execute(queryDelete, new { id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -65,7 +65,7 @@ public class StorageRepository : IStorageRepository
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"SELECT * FROM Storages WHERE ID=@id";
|
||||
var querySelect = @"SELECT * FROM Storage WHERE ID=@id";
|
||||
var storage = connection.QueryFirst<Storage>(querySelect, new
|
||||
{
|
||||
id
|
||||
@ -87,7 +87,7 @@ public class StorageRepository : IStorageRepository
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM Storages";
|
||||
var querySelect = "SELECT * FROM Storage";
|
||||
var storage = connection.Query<Storage>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
JsonConvert.SerializeObject(storage));
|
||||
@ -108,7 +108,7 @@ public class StorageRepository : IStorageRepository
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryUpdate = @"UPDATE Storages SET
|
||||
var queryUpdate = @"UPDATE Storage SET
|
||||
Size=@Size,
|
||||
NumberStorage=@NumberStorage,
|
||||
QuantityInStock=@QuantityInStock
|
||||
|
21
ShoeStore/ShoeStore.Designer.cs
generated
21
ShoeStore/ShoeStore.Designer.cs
generated
@ -38,6 +38,8 @@
|
||||
SalesToolStripMenuItem = new ToolStripMenuItem();
|
||||
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
||||
DirectoryReportToolStripMenuItem = new ToolStripMenuItem();
|
||||
ProductReportToolStripMenuItem = new ToolStripMenuItem();
|
||||
ProductDistributionToolStripMenuItem = new ToolStripMenuItem();
|
||||
menuStrip1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
@ -101,7 +103,7 @@
|
||||
//
|
||||
// отчетыToolStripMenuItem
|
||||
//
|
||||
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { DirectoryReportToolStripMenuItem });
|
||||
отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { DirectoryReportToolStripMenuItem, ProductReportToolStripMenuItem, ProductDistributionToolStripMenuItem });
|
||||
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
||||
отчетыToolStripMenuItem.Size = new Size(60, 20);
|
||||
отчетыToolStripMenuItem.Text = "Отчеты";
|
||||
@ -114,12 +116,25 @@
|
||||
DirectoryReportToolStripMenuItem.Text = "Документ со справониками";
|
||||
DirectoryReportToolStripMenuItem.Click += DirectoryReportToolStripMenuItem_Click;
|
||||
//
|
||||
// ProductReportToolStripMenuItem
|
||||
//
|
||||
ProductReportToolStripMenuItem.Name = "ProductReportToolStripMenuItem";
|
||||
ProductReportToolStripMenuItem.Size = new Size(273, 22);
|
||||
ProductReportToolStripMenuItem.Text = "Движение товаров";
|
||||
ProductReportToolStripMenuItem.Click += ProductReportToolStripMenuItem_Click;
|
||||
//
|
||||
// ProductDistributionToolStripMenuItem
|
||||
//
|
||||
ProductDistributionToolStripMenuItem.Name = "ProductDistributionToolStripMenuItem";
|
||||
ProductDistributionToolStripMenuItem.Size = new Size(273, 22);
|
||||
ProductDistributionToolStripMenuItem.Text = "Поступившие товары";
|
||||
ProductDistributionToolStripMenuItem.Click += ProductDistributionToolStripMenuItem_Click;
|
||||
//
|
||||
// ShoeStore
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
BackColor = SystemColors.ControlLightLight;
|
||||
BackgroundImage = Properties.Resources.обувной;
|
||||
BackgroundImageLayout = ImageLayout.Zoom;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(menuStrip1);
|
||||
@ -144,5 +159,7 @@
|
||||
private ToolStripMenuItem SalesToolStripMenuItem;
|
||||
private ToolStripMenuItem отчетыToolStripMenuItem;
|
||||
private ToolStripMenuItem DirectoryReportToolStripMenuItem;
|
||||
private ToolStripMenuItem ProductReportToolStripMenuItem;
|
||||
private ToolStripMenuItem ProductDistributionToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -95,5 +95,29 @@ namespace ShoeStore
|
||||
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ProductReportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormProductReport>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ProductDistributionToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormDistributionReport>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Npgsql" Version="9.0.1" />
|
||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||
<PackageReference Include="Serilog" Version="4.1.0" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user