проверка
This commit is contained in:
parent
0d89c1f012
commit
a0db0595f1
@ -14,10 +14,10 @@ public class AccessoiresOrder
|
||||
|
||||
public int Count { get; private set; }
|
||||
|
||||
public DateTime Date { get; private set; }
|
||||
|
||||
|
||||
public static AccessoiresOrder CreateElement(int id, int orderId, int count, DateTime date)
|
||||
public static AccessoiresOrder CreateElement(int id, int orderId, int count)
|
||||
{
|
||||
return new AccessoiresOrder { Id = id, OrderId = orderId, Count = count, Date = DateTime.Now};
|
||||
return new AccessoiresOrder { Id = id, OrderId = orderId, Count = count};
|
||||
}
|
||||
}
|
||||
|
@ -17,14 +17,17 @@ public class Accessories
|
||||
|
||||
public float Price { get; private set; }
|
||||
|
||||
public static Accessories CreateEntity(int id, AccessoriesType accessoriesType, int count, float price)
|
||||
public DateTime Date { get; private set; }
|
||||
|
||||
public static Accessories CreateEntity(int id, AccessoriesType accessoriesType, int count, float price, DateTime date)
|
||||
{
|
||||
return new Accessories
|
||||
{
|
||||
Id = id,
|
||||
AccessoriesType = accessoriesType,
|
||||
Count = count,
|
||||
Price = price
|
||||
Price = price,
|
||||
Date = date
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,8 @@
|
||||
buttonCreate = new Button();
|
||||
buttonCancel = new Button();
|
||||
comboBoxType = new ComboBox();
|
||||
labelDate = new Label();
|
||||
dateTimePickerAccessories = new DateTimePicker();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownCount).BeginInit();
|
||||
SuspendLayout();
|
||||
@ -36,9 +38,9 @@
|
||||
//
|
||||
labelType.Anchor = AnchorStyles.Right;
|
||||
labelType.AutoSize = true;
|
||||
labelType.Location = new Point(54, 75);
|
||||
labelType.Location = new Point(47, 56);
|
||||
labelType.Name = "labelType";
|
||||
labelType.Size = new Size(158, 20);
|
||||
labelType.Size = new Size(128, 15);
|
||||
labelType.TabIndex = 0;
|
||||
labelType.Text = "Вид комплектующего";
|
||||
//
|
||||
@ -46,9 +48,9 @@
|
||||
//
|
||||
labelCount.Anchor = AnchorStyles.Right;
|
||||
labelCount.AutoSize = true;
|
||||
labelCount.Location = new Point(54, 152);
|
||||
labelCount.Location = new Point(47, 114);
|
||||
labelCount.Name = "labelCount";
|
||||
labelCount.Size = new Size(98, 20);
|
||||
labelCount.Size = new Size(79, 15);
|
||||
labelCount.TabIndex = 2;
|
||||
labelCount.Text = "Колличество";
|
||||
//
|
||||
@ -56,9 +58,9 @@
|
||||
//
|
||||
labelPrice.Anchor = AnchorStyles.Right;
|
||||
labelPrice.AutoSize = true;
|
||||
labelPrice.Location = new Point(54, 231);
|
||||
labelPrice.Location = new Point(47, 173);
|
||||
labelPrice.Name = "labelPrice";
|
||||
labelPrice.Size = new Size(45, 20);
|
||||
labelPrice.Size = new Size(35, 15);
|
||||
labelPrice.TabIndex = 4;
|
||||
labelPrice.Text = "Цена";
|
||||
//
|
||||
@ -66,29 +68,26 @@
|
||||
//
|
||||
numericUpDownPrice.Anchor = AnchorStyles.Right;
|
||||
numericUpDownPrice.DecimalPlaces = 2;
|
||||
numericUpDownPrice.Location = new Point(252, 235);
|
||||
numericUpDownPrice.Margin = new Padding(3, 4, 3, 4);
|
||||
numericUpDownPrice.Location = new Point(220, 176);
|
||||
numericUpDownPrice.Name = "numericUpDownPrice";
|
||||
numericUpDownPrice.Size = new Size(119, 27);
|
||||
numericUpDownPrice.Size = new Size(104, 23);
|
||||
numericUpDownPrice.TabIndex = 5;
|
||||
//
|
||||
// numericUpDownCount
|
||||
//
|
||||
numericUpDownCount.Anchor = AnchorStyles.Right;
|
||||
numericUpDownCount.Location = new Point(252, 156);
|
||||
numericUpDownCount.Margin = new Padding(3, 4, 3, 4);
|
||||
numericUpDownCount.Location = new Point(220, 117);
|
||||
numericUpDownCount.Name = "numericUpDownCount";
|
||||
numericUpDownCount.Size = new Size(119, 27);
|
||||
numericUpDownCount.Size = new Size(104, 23);
|
||||
numericUpDownCount.TabIndex = 6;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.AllowDrop = true;
|
||||
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
buttonCreate.Location = new Point(53, 417);
|
||||
buttonCreate.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonCreate.Location = new Point(46, 313);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(98, 33);
|
||||
buttonCreate.Size = new Size(86, 25);
|
||||
buttonCreate.TabIndex = 8;
|
||||
buttonCreate.Text = "Сохранить";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
@ -97,10 +96,9 @@
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||
buttonCancel.Location = new Point(310, 416);
|
||||
buttonCancel.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonCancel.Location = new Point(271, 312);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(101, 31);
|
||||
buttonCancel.Size = new Size(88, 23);
|
||||
buttonCancel.TabIndex = 10;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
@ -109,19 +107,38 @@
|
||||
// comboBoxType
|
||||
//
|
||||
comboBoxType.FormattingEnabled = true;
|
||||
comboBoxType.Location = new Point(250, 78);
|
||||
comboBoxType.Location = new Point(219, 58);
|
||||
comboBoxType.Margin = new Padding(3, 2, 3, 2);
|
||||
comboBoxType.Name = "comboBoxType";
|
||||
comboBoxType.Size = new Size(151, 28);
|
||||
comboBoxType.Size = new Size(133, 23);
|
||||
comboBoxType.TabIndex = 11;
|
||||
//
|
||||
// labelDate
|
||||
//
|
||||
labelDate.AutoSize = true;
|
||||
labelDate.Location = new Point(47, 234);
|
||||
labelDate.Name = "labelDate";
|
||||
labelDate.Size = new Size(68, 15);
|
||||
labelDate.TabIndex = 12;
|
||||
labelDate.Text = "Поступили";
|
||||
//
|
||||
// dateTimePickerAccessories
|
||||
//
|
||||
dateTimePickerAccessories.Location = new Point(220, 234);
|
||||
dateTimePickerAccessories.Name = "dateTimePickerAccessories";
|
||||
dateTimePickerAccessories.Size = new Size(132, 23);
|
||||
dateTimePickerAccessories.TabIndex = 13;
|
||||
//
|
||||
// FormAccessorie
|
||||
//
|
||||
AllowDrop = true;
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
||||
AutoValidate = AutoValidate.EnableAllowFocusChange;
|
||||
ClientSize = new Size(448, 478);
|
||||
ClientSize = new Size(392, 358);
|
||||
Controls.Add(dateTimePickerAccessories);
|
||||
Controls.Add(labelDate);
|
||||
Controls.Add(comboBoxType);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonCreate);
|
||||
@ -130,7 +147,6 @@
|
||||
Controls.Add(labelPrice);
|
||||
Controls.Add(labelCount);
|
||||
Controls.Add(labelType);
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "FormAccessorie";
|
||||
Text = "Комплектующое";
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
|
||||
@ -150,5 +166,7 @@
|
||||
private Button buttonUpdate;
|
||||
private Button buttonCancel;
|
||||
private ComboBox comboBoxType;
|
||||
private Label labelDate;
|
||||
private DateTimePicker dateTimePickerAccessories;
|
||||
}
|
||||
}
|
@ -31,7 +31,8 @@ namespace ProjectCompRepair.Forms
|
||||
{
|
||||
throw new InvalidOperationException(nameof(accessorie));
|
||||
}
|
||||
|
||||
|
||||
dateTimePickerAccessories.Value = accessorie.Date;
|
||||
numericUpDownCount.Value = accessorie.Count;
|
||||
numericUpDownPrice.Value = (int)accessorie.Price;
|
||||
_accessorieId = value;
|
||||
@ -79,7 +80,7 @@ namespace ProjectCompRepair.Forms
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
private Accessories CreateAccessories(int id) => Accessories.CreateEntity(id, (AccessoriesType)comboBoxType.SelectedItem! , (int)numericUpDownCount.Value, (float)numericUpDownPrice.Value);
|
||||
private Accessories CreateAccessories(int id) => Accessories.CreateEntity(id, (AccessoriesType)comboBoxType.SelectedItem! , (int)numericUpDownCount.Value, (float)numericUpDownPrice.Value, dateTimePickerAccessories.Value);
|
||||
|
||||
|
||||
}
|
||||
|
39
ProjectCompRepair/ProjectCompRepair/Forms/FormAccessoriesReport.Designer.cs
generated
Normal file
39
ProjectCompRepair/ProjectCompRepair/Forms/FormAccessoriesReport.Designer.cs
generated
Normal file
@ -0,0 +1,39 @@
|
||||
namespace ProjectCompRepair.Forms
|
||||
{
|
||||
partial class FormAccessoriesReport
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "FormAccessoriesReport";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
using ProjectCompRepair.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 ProjectCompRepair.Forms;
|
||||
|
||||
public partial class FormAccessoriesReport : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
public FormAccessoriesReport()
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
comboBoxFeed.DataSource = feedRepository.ReadFeeds();
|
||||
comboBoxFeed.DisplayMember = "Name";
|
||||
comboBoxFeed.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 (comboBoxFeed.SelectedIndex < 0)
|
||||
{
|
||||
throw new Exception("Не выбран корм");
|
||||
}
|
||||
|
||||
if (dateTimePickerDateEnd.Value <= dateTimePickerDateBegin.Value)
|
||||
{
|
||||
throw new Exception("Дата начала должна быть раньше даты окончания");
|
||||
}
|
||||
|
||||
if (_container.Resolve<TableReport>().CreateTable(textBoxFilePath.Text, (int)comboBoxFeed.SelectedValue!, dateTimePickerDateBegin.Value, dateTimePickerDateEnd.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>
|
@ -55,74 +55,79 @@
|
||||
// labelName
|
||||
//
|
||||
labelName.AutoSize = true;
|
||||
labelName.Location = new Point(19, 35);
|
||||
labelName.Location = new Point(17, 26);
|
||||
labelName.Name = "labelName";
|
||||
labelName.Size = new Size(77, 20);
|
||||
labelName.Size = new Size(59, 15);
|
||||
labelName.TabIndex = 0;
|
||||
labelName.Text = "Название";
|
||||
//
|
||||
// labelComent
|
||||
//
|
||||
labelComent.AutoSize = true;
|
||||
labelComent.Location = new Point(19, 109);
|
||||
labelComent.Location = new Point(17, 82);
|
||||
labelComent.Name = "labelComent";
|
||||
labelComent.Size = new Size(79, 20);
|
||||
labelComent.Size = new Size(62, 15);
|
||||
labelComent.TabIndex = 1;
|
||||
labelComent.Text = "Описание";
|
||||
//
|
||||
// textBoxComent
|
||||
//
|
||||
textBoxComent.Location = new Point(208, 81);
|
||||
textBoxComent.Location = new Point(182, 61);
|
||||
textBoxComent.Margin = new Padding(3, 2, 3, 2);
|
||||
textBoxComent.Multiline = true;
|
||||
textBoxComent.Name = "textBoxComent";
|
||||
textBoxComent.Size = new Size(125, 72);
|
||||
textBoxComent.Size = new Size(110, 55);
|
||||
textBoxComent.TabIndex = 2;
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(208, 28);
|
||||
textBoxName.Location = new Point(182, 21);
|
||||
textBoxName.Margin = new Padding(3, 2, 3, 2);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(125, 27);
|
||||
textBoxName.Size = new Size(110, 23);
|
||||
textBoxName.TabIndex = 3;
|
||||
//
|
||||
// labelDate
|
||||
//
|
||||
labelDate.AutoSize = true;
|
||||
labelDate.Location = new Point(19, 192);
|
||||
labelDate.Location = new Point(17, 144);
|
||||
labelDate.Name = "labelDate";
|
||||
labelDate.Size = new Size(183, 20);
|
||||
labelDate.Size = new Size(142, 15);
|
||||
labelDate.TabIndex = 4;
|
||||
labelDate.Text = "Дата регистрации заказа";
|
||||
//
|
||||
// dateTimePicker
|
||||
//
|
||||
dateTimePicker.Location = new Point(208, 192);
|
||||
dateTimePicker.Location = new Point(182, 144);
|
||||
dateTimePicker.Margin = new Padding(3, 2, 3, 2);
|
||||
dateTimePicker.Name = "dateTimePicker";
|
||||
dateTimePicker.Size = new Size(192, 27);
|
||||
dateTimePicker.Size = new Size(168, 23);
|
||||
dateTimePicker.TabIndex = 5;
|
||||
//
|
||||
// comboBoxMaster
|
||||
//
|
||||
comboBoxMaster.FormattingEnabled = true;
|
||||
comboBoxMaster.Location = new Point(208, 254);
|
||||
comboBoxMaster.Location = new Point(182, 190);
|
||||
comboBoxMaster.Margin = new Padding(3, 2, 3, 2);
|
||||
comboBoxMaster.Name = "comboBoxMaster";
|
||||
comboBoxMaster.Size = new Size(151, 28);
|
||||
comboBoxMaster.Size = new Size(133, 23);
|
||||
comboBoxMaster.TabIndex = 6;
|
||||
//
|
||||
// labelMaster
|
||||
//
|
||||
labelMaster.AutoSize = true;
|
||||
labelMaster.Location = new Point(21, 262);
|
||||
labelMaster.Location = new Point(18, 196);
|
||||
labelMaster.Name = "labelMaster";
|
||||
labelMaster.Size = new Size(60, 20);
|
||||
labelMaster.Size = new Size(48, 15);
|
||||
labelMaster.TabIndex = 7;
|
||||
labelMaster.Text = "Мастер";
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(35, 389);
|
||||
buttonSave.Location = new Point(31, 292);
|
||||
buttonSave.Margin = new Padding(3, 2, 3, 2);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(94, 29);
|
||||
buttonSave.Size = new Size(82, 22);
|
||||
buttonSave.TabIndex = 8;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
@ -130,9 +135,10 @@
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(1077, 389);
|
||||
buttonCancel.Location = new Point(942, 292);
|
||||
buttonCancel.Margin = new Padding(3, 2, 3, 2);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(94, 29);
|
||||
buttonCancel.Size = new Size(82, 22);
|
||||
buttonCancel.TabIndex = 9;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
@ -141,9 +147,11 @@
|
||||
// groupBox1
|
||||
//
|
||||
groupBox1.Controls.Add(dataGridViewAccessories);
|
||||
groupBox1.Location = new Point(449, 35);
|
||||
groupBox1.Location = new Point(393, 26);
|
||||
groupBox1.Margin = new Padding(3, 2, 3, 2);
|
||||
groupBox1.Name = "groupBox1";
|
||||
groupBox1.Size = new Size(309, 247);
|
||||
groupBox1.Padding = new Padding(3, 2, 3, 2);
|
||||
groupBox1.Size = new Size(270, 183);
|
||||
groupBox1.TabIndex = 10;
|
||||
groupBox1.TabStop = false;
|
||||
groupBox1.Text = "Комплектующие";
|
||||
@ -153,10 +161,11 @@
|
||||
dataGridViewAccessories.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewAccessories.Columns.AddRange(new DataGridViewColumn[] { ColumnAccessories, ColumnCount });
|
||||
dataGridViewAccessories.Dock = DockStyle.Fill;
|
||||
dataGridViewAccessories.Location = new Point(3, 23);
|
||||
dataGridViewAccessories.Location = new Point(3, 18);
|
||||
dataGridViewAccessories.Margin = new Padding(3, 2, 3, 2);
|
||||
dataGridViewAccessories.Name = "dataGridViewAccessories";
|
||||
dataGridViewAccessories.RowHeadersWidth = 51;
|
||||
dataGridViewAccessories.Size = new Size(303, 221);
|
||||
dataGridViewAccessories.Size = new Size(264, 163);
|
||||
dataGridViewAccessories.TabIndex = 0;
|
||||
//
|
||||
// ColumnAccessories
|
||||
@ -176,9 +185,11 @@
|
||||
// groupBoxServices
|
||||
//
|
||||
groupBoxServices.Controls.Add(dataGridViewServices);
|
||||
groupBoxServices.Location = new Point(789, 35);
|
||||
groupBoxServices.Location = new Point(690, 26);
|
||||
groupBoxServices.Margin = new Padding(3, 2, 3, 2);
|
||||
groupBoxServices.Name = "groupBoxServices";
|
||||
groupBoxServices.Size = new Size(310, 247);
|
||||
groupBoxServices.Padding = new Padding(3, 2, 3, 2);
|
||||
groupBoxServices.Size = new Size(271, 185);
|
||||
groupBoxServices.TabIndex = 11;
|
||||
groupBoxServices.TabStop = false;
|
||||
groupBoxServices.Text = "Услуги";
|
||||
@ -188,10 +199,11 @@
|
||||
dataGridViewServices.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewServices.Columns.AddRange(new DataGridViewColumn[] { ColumnService, ColumnCountServ });
|
||||
dataGridViewServices.Dock = DockStyle.Fill;
|
||||
dataGridViewServices.Location = new Point(3, 23);
|
||||
dataGridViewServices.Location = new Point(3, 18);
|
||||
dataGridViewServices.Margin = new Padding(3, 2, 3, 2);
|
||||
dataGridViewServices.Name = "dataGridViewServices";
|
||||
dataGridViewServices.RowHeadersWidth = 51;
|
||||
dataGridViewServices.Size = new Size(304, 221);
|
||||
dataGridViewServices.Size = new Size(265, 165);
|
||||
dataGridViewServices.TabIndex = 0;
|
||||
//
|
||||
// ColumnService
|
||||
@ -210,9 +222,9 @@
|
||||
//
|
||||
// FormOrder
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1183, 430);
|
||||
ClientSize = new Size(1035, 322);
|
||||
Controls.Add(groupBoxServices);
|
||||
Controls.Add(groupBox1);
|
||||
Controls.Add(buttonCancel);
|
||||
@ -225,6 +237,7 @@
|
||||
Controls.Add(textBoxComent);
|
||||
Controls.Add(labelComent);
|
||||
Controls.Add(labelName);
|
||||
Margin = new Padding(3, 2, 3, 2);
|
||||
Name = "FormOrder";
|
||||
Text = "Заказ";
|
||||
groupBox1.ResumeLayout(false);
|
||||
|
@ -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" />
|
||||
|
47
ProjectCompRepair/ProjectCompRepair/Reports/ChartReport.cs
Normal file
47
ProjectCompRepair/ProjectCompRepair/Reports/ChartReport.cs
Normal file
@ -0,0 +1,47 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectCompRepair.Reports;
|
||||
|
||||
internal class ChartReport
|
||||
{
|
||||
private readonly IFeedingAnimalRepository _feedingAnimalRepository;
|
||||
private readonly ILogger<ChartReport> _logger;
|
||||
|
||||
public ChartReport(IFeedingAnimalRepository feedingAnimalRepository, ILogger<ChartReport> logger)
|
||||
{
|
||||
_feedingAnimalRepository = feedingAnimalRepository ?? throw new ArgumentNullException(nameof(feedingAnimalRepository));
|
||||
_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 _feedingAnimalRepository
|
||||
.ReadFeedingAnimals()
|
||||
.Where(x => x.FeedingDate.Date == dateTime.Date)
|
||||
.GroupBy(x => x.AnimalId, (key, group) => new { Id = key, Count = group.Sum(x => x.Ration) })
|
||||
.Select(x => (x.Id.ToString(), (double)x.Count))
|
||||
.ToList();
|
||||
}
|
||||
}
|
87
ProjectCompRepair/ProjectCompRepair/Reports/PdfBuilder.cs
Normal file
87
ProjectCompRepair/ProjectCompRepair/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 ProjectCompRepair.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()
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
@ -12,15 +12,15 @@ namespace ProjectCompRepair.Reports;
|
||||
internal class TableReport
|
||||
{
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
private readonly IAccessoriesOrderRepository _accessoriesOrdersRepository;
|
||||
private readonly IAccessoriesRepository _accessoriesRepository;
|
||||
private readonly ILogger<TableReport> _logger;
|
||||
|
||||
internal static readonly string[] item = ["Сотрудник", "Дата", "Тип комплектующего", "кол-во"];
|
||||
internal static readonly string[] item = ["Дата", "Тип комплектующего", "кол-во"];
|
||||
|
||||
public TableReport(IOrderRepository orderRepository, IAccessoriesOrderRepository accessoriesOrdersRepository, ILogger<TableReport> logger)
|
||||
public TableReport(IOrderRepository orderRepository, IAccessoriesRepository accessoriesRepository, ILogger<TableReport> logger)
|
||||
{
|
||||
_orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
|
||||
_accessoriesOrdersRepository = accessoriesOrdersRepository ?? throw new ArgumentNullException(nameof(accessoriesOrdersRepository));
|
||||
_accessoriesRepository = accessoriesRepository ?? throw new ArgumentNullException(nameof(accessoriesRepository));
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
|
||||
@ -44,21 +44,20 @@ internal class TableReport
|
||||
|
||||
private List<string[]> GetData(int accessoriesId, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
var data = _feedReplenishmentRepository
|
||||
.ReadFeedReplenishment()
|
||||
.Where(x => x.DateReceipt >= startDate && x.DateReceipt <= endDate && x.FeedFeedReplenishments.Any(y => y.FeedId == feedId))
|
||||
.Select(x => new { x.EmployeeId, Date = x.DateReceipt, CountIn = x.FeedFeedReplenishments.FirstOrDefault(y => y.FeedId == feedId)?.Count, CountOut = (int?)null })
|
||||
var data = _orderRepository.ReadOrder()
|
||||
.Where(x => x.Date >= startDate && x.Date <= endDate && x.AccessoiresOrders.Any(y => y.Id == accessoriesId))
|
||||
.Select(x => new {Date = x.Date, CountIn = x.AccessoiresOrders.FirstOrDefault(y => y.Id == accessoriesId)?.Count, CountOut = (int?)null })
|
||||
.Union(
|
||||
_feedingAnimalRepository
|
||||
.ReadFeedingAnimals()
|
||||
.Where(x => x.FeedingDate >= startDate && x.FeedingDate <= endDate && x.FeedId == feedId)
|
||||
.Select(x => new { x.EmployeeId, Date = x.FeedingDate, CountIn = (int?)null, CountOut = (int?)x.Ration }))
|
||||
_accessoriesRepository
|
||||
.ReadAccessories()
|
||||
.Where(x => x.Date >= startDate && x.Date <= endDate && x.Id == accessoriesId)
|
||||
.Select(x => new {Date = x.Date, CountIn = (int?)null, CountOut = (int?)x.Count }))
|
||||
.OrderBy(x => x.Date);
|
||||
|
||||
return new List<string[]>() { item }
|
||||
.Union(
|
||||
data
|
||||
.Select(x => new string[] { x.EmployeeId.ToString(), x.Date.ToString(), x.CountIn?.ToString() ?? string.Empty, x.CountOut?.ToString() ?? string.Empty }))
|
||||
.Select(x => new string[] { 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();
|
||||
|
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ProjectCompRepair.Repositories.Implemantations;
|
||||
|
||||
public class AccessoriesOrderRepository
|
||||
{
|
||||
|
||||
}
|
@ -35,8 +35,8 @@ public class AccessoriesRepository : IAccessoriesRepository
|
||||
connection.Open();
|
||||
|
||||
var queryInsert = @"
|
||||
INSERT INTO Accessories (AccessoriesType, Count, Price)
|
||||
VALUES (@AccessoriesType, @Count, @Price)";
|
||||
INSERT INTO Accessories (AccessoriesType, Count, Price, Date)
|
||||
VALUES (@AccessoriesType, @Count, @Price, @Date)";
|
||||
connection.Execute(queryInsert, accessories);
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -58,7 +58,8 @@ VALUES (@AccessoriesType, @Count, @Price)";
|
||||
SET
|
||||
AccessoriesType = @AccessoriesType,
|
||||
Count = @Count,
|
||||
Price = @Price
|
||||
Price = @Price,
|
||||
Date = @Date
|
||||
WHERE ID = @Id;";
|
||||
connection.Execute(queryUpdate, accessories);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user