ща буит мясо

This commit is contained in:
Леонид Малафеев 2024-11-06 02:29:24 +04:00
parent 2269741c4e
commit c877e5ef03
12 changed files with 688 additions and 10 deletions

View File

@ -9,6 +9,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ComponentsLibraryNet60" Version="1.0.0" />
<PackageReference Include="ControlsLibraryNet60" Version="1.0.0" />
<PackageReference Include="CreateVisualComponent" Version="1.0.0" />
<PackageReference Include="CustomComponentsTest" Version="1.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.35" />

View File

@ -28,6 +28,7 @@ namespace Controls
InitializeComponent();
}
[Obsolete]
public void CreateDocument(string docPath, string title, string[] rows)
{
if (string.IsNullOrEmpty(docPath))

View File

@ -29,6 +29,7 @@ namespace Controls
InitializeComponent();
}
[Obsolete]
public void CreateTable<T>(string docPath, string title, List<MergeCells>? mergeCells, List<ColumnInfo> colInfo, List<T> data) where T : class, new()
{
if (string.IsNullOrEmpty(docPath))

View File

@ -11,8 +11,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace DatabaseImplement.Migrations
{
[DbContext(typeof(Database))]
[Migration("20241104155629_abobus")]
partial class abobus
[Migration("20241105214035_abobau")]
partial class abobau
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{

View File

@ -5,7 +5,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace DatabaseImplement.Migrations
{
public partial class abobus : Migration
public partial class abobau : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{

220
Cop_25/Forms/DeliveryForm.Designer.cs generated Normal file
View File

@ -0,0 +1,220 @@
namespace Forms
{
partial class DeliveryForm
{
/// <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()
{
tableLayoutPanel1 = new TableLayoutPanel();
comboBoxType = new ComboBox();
label2 = new Label();
label3 = new Label();
label4 = new Label();
label1 = new Label();
inputComponentDate = new CreateVisualComponent.InputComponent();
textBoxFCs = new TextBox();
textBoxWishes = new TextBox();
tableLayoutPanel2 = new TableLayoutPanel();
buttonSave = new Button();
buttonCancel = new Button();
tableLayoutPanel1.SuspendLayout();
tableLayoutPanel2.SuspendLayout();
SuspendLayout();
//
// tableLayoutPanel1
//
tableLayoutPanel1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
tableLayoutPanel1.ColumnCount = 4;
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableLayoutPanel1.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 25F));
tableLayoutPanel1.Controls.Add(comboBoxType, 2, 1);
tableLayoutPanel1.Controls.Add(label2, 1, 0);
tableLayoutPanel1.Controls.Add(label3, 2, 0);
tableLayoutPanel1.Controls.Add(label4, 3, 0);
tableLayoutPanel1.Controls.Add(label1, 0, 0);
tableLayoutPanel1.Controls.Add(inputComponentDate, 3, 1);
tableLayoutPanel1.Controls.Add(textBoxFCs, 0, 1);
tableLayoutPanel1.Controls.Add(textBoxWishes, 1, 1);
tableLayoutPanel1.Location = new Point(12, 34);
tableLayoutPanel1.Name = "tableLayoutPanel1";
tableLayoutPanel1.RowCount = 2;
tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 30.2325573F));
tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.Percent, 69.76744F));
tableLayoutPanel1.Size = new Size(912, 92);
tableLayoutPanel1.TabIndex = 1;
//
// comboBoxType
//
comboBoxType.Anchor = AnchorStyles.Left | AnchorStyles.Right;
comboBoxType.Cursor = Cursors.IBeam;
comboBoxType.FormattingEnabled = true;
comboBoxType.Location = new Point(459, 45);
comboBoxType.Name = "comboBoxType";
comboBoxType.Size = new Size(222, 28);
comboBoxType.TabIndex = 2;
comboBoxType.SelectedIndexChanged += OnInputChange;
//
// label2
//
label2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
label2.AutoSize = true;
label2.Location = new Point(231, 0);
label2.Name = "label2";
label2.Size = new Size(222, 20);
label2.TabIndex = 1;
label2.Text = "Пожелания по доставке";
label2.TextAlign = ContentAlignment.MiddleCenter;
//
// label3
//
label3.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
label3.AutoSize = true;
label3.Location = new Point(459, 0);
label3.Name = "label3";
label3.Size = new Size(222, 20);
label3.TabIndex = 2;
label3.Text = "Тип доставки";
label3.TextAlign = ContentAlignment.MiddleCenter;
//
// label4
//
label4.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
label4.AutoSize = true;
label4.Location = new Point(687, 0);
label4.Name = "label4";
label4.Size = new Size(222, 20);
label4.TabIndex = 3;
label4.Text = "Дата доставки";
label4.TextAlign = ContentAlignment.MiddleCenter;
//
// label1
//
label1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
label1.AutoSize = true;
label1.Location = new Point(3, 0);
label1.Name = "label1";
label1.Size = new Size(222, 20);
label1.TabIndex = 0;
label1.Text = "ФИО";
label1.TextAlign = ContentAlignment.MiddleCenter;
//
// inputComponentDate
//
inputComponentDate.Anchor = AnchorStyles.Left | AnchorStyles.Right;
inputComponentDate.Location = new Point(687, 30);
inputComponentDate.Name = "inputComponentDate";
inputComponentDate.Size = new Size(222, 59);
inputComponentDate.TabIndex = 4;
//
// textBoxFCs
//
textBoxFCs.Anchor = AnchorStyles.Left | AnchorStyles.Right;
textBoxFCs.Location = new Point(3, 46);
textBoxFCs.Name = "textBoxFCs";
textBoxFCs.Size = new Size(222, 27);
textBoxFCs.TabIndex = 6;
textBoxFCs.TextChanged += OnInputChange;
//
// textBoxWishes
//
textBoxWishes.Anchor = AnchorStyles.Left | AnchorStyles.Right;
textBoxWishes.Location = new Point(231, 46);
textBoxWishes.Name = "textBoxWishes";
textBoxWishes.Size = new Size(222, 27);
textBoxWishes.TabIndex = 5;
textBoxWishes.TextChanged += OnInputChange;
//
// tableLayoutPanel2
//
tableLayoutPanel2.ColumnCount = 2;
tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
tableLayoutPanel2.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
tableLayoutPanel2.Controls.Add(buttonSave, 0, 0);
tableLayoutPanel2.Controls.Add(buttonCancel, 1, 0);
tableLayoutPanel2.Location = new Point(12, 132);
tableLayoutPanel2.Name = "tableLayoutPanel2";
tableLayoutPanel2.RowCount = 1;
tableLayoutPanel2.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
tableLayoutPanel2.Size = new Size(250, 36);
tableLayoutPanel2.TabIndex = 2;
//
// buttonSave
//
buttonSave.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
buttonSave.Location = new Point(3, 3);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(119, 30);
buttonSave.TabIndex = 0;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonAdd_Click;
//
// buttonCancel
//
buttonCancel.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
buttonCancel.Location = new Point(128, 3);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(119, 30);
buttonCancel.TabIndex = 1;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// DeliveryForm
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(936, 209);
Controls.Add(tableLayoutPanel2);
Controls.Add(tableLayoutPanel1);
Name = "DeliveryForm";
Text = "DeliveryForm";
FormClosing += ProviderForm_FormClosing;
tableLayoutPanel1.ResumeLayout(false);
tableLayoutPanel1.PerformLayout();
tableLayoutPanel2.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private ListBox listBox1;
private TableLayoutPanel tableLayoutPanel1;
private Label label2;
private Label label3;
private Label label4;
private Label label1;
private CreateVisualComponent.InputComponent inputComponentDate;
private ComboBox comboBoxType;
private TextBox textBoxWishes;
private TextBox textBoxFCs;
private TableLayoutPanel tableLayoutPanel2;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,129 @@
using Contracts.BindlingModels;
using Contracts.BusinessLogicContracts;
using Contracts.SearchModels;
using ControlsLibraryNet60.Input;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Forms
{
public partial class DeliveryForm : Form
{
private int? _id;
private readonly IDeliveryLogic _dLogic;
private readonly IDeliveryTypeLogic _dtLogic;
private bool isEdited;
public DeliveryForm(IDeliveryLogic dLogic, IDeliveryTypeLogic dtLogic, int? id = null)
{
InitializeComponent();
_id = id;
_dLogic = dLogic;
_dtLogic = dtLogic;
isEdited = false;
LoadData();
}
private void LoadData()
{
var list = _dtLogic.ReadList(null);
if (list != null)
{
foreach (var item in list)
{
comboBoxType.Items.Add(item.Name);
}
}
if (_id.HasValue)
{
var view = _dLogic.ReadElement(new DeliverySearchModel
{
Id = _id.Value,
});
textBoxWishes.Text = view.Wishes;
textBoxFCs.Text = view.FCs;
if (view.DeliveryDate != "Даты доставки нет")
{
inputComponentDate.Value = Convert.ToDateTime(view.DeliveryDate);
}
else
{
inputComponentDate.Value = null;
}
comboBoxType.SelectedItem = view.DeliveryType;
isEdited = false;
}
}
private void OnInputChange(object sender, EventArgs e)
{
isEdited = true;
}
private void buttonAdd_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxFCs.Text))
{
MessageBox.Show("Заполните поле ФИО курьера", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxWishes.Text))
{
MessageBox.Show("Заполните Пожелания ", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if ((comboBoxType.SelectedItem == null))
{
MessageBox.Show("Выберите Тип доставки", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
isEdited = false;
try
{
var model = new DeliveryBindingModel
{
Id = _id ?? 0,
FCs = textBoxFCs.Text,
Wishes = textBoxWishes.Text,
DeliveryDate = inputComponentDate.Value.ToString().Length >= 10 ? inputComponentDate.Value.ToString().Substring(0, 10) : "Даты доставки нет",
DeliveryType = comboBoxType.SelectedItem.ToString(),
};
var OperationResult = _id.HasValue ? _dLogic.Update(model) : _dLogic.Create(model);
if (!OperationResult)
{
throw new Exception("Ошибка при создании курьера.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ProviderForm_FormClosing(object sender, FormClosingEventArgs e)
{
if (!isEdited) return;
var confirmResult = MessageBox.Show("Вы не сохранили изменения.\nВы действительно хотите выйти?", "Подтвердите действие",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question
);
if (confirmResult == DialogResult.No) e.Cancel = true;
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -28,19 +28,27 @@
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
menuStrip1 = new MenuStrip();
созданиеДоставкиToolStripMenuItem = new ToolStripMenuItem();
создатьДоставкуToolStripMenuItem = new ToolStripMenuItem();
редактироватьДоставкуToolStripMenuItem = new ToolStripMenuItem();
удалитьДоставкуToolStripMenuItem = new ToolStripMenuItem();
созданиеТипаДоставкиToolStripMenuItem = new ToolStripMenuItem();
pDFДокументToolStripMenuItem = new ToolStripMenuItem();
excelОтчётToolStripMenuItem = new ToolStripMenuItem();
wordДиаграммаToolStripMenuItem = new ToolStripMenuItem();
редактироватьtoolStripMenuItem = new ToolStripMenuItem();
controlDataTreeTable = new ControlsLibraryNet60.Data.ControlDataTreeTable();
largeTextComponent = new Controls.LargeTextComponent(components);
componentDocumentWithChartPieWord = new ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartPieWord(components);
menuStrip1.SuspendLayout();
SuspendLayout();
//
// menuStrip1
//
menuStrip1.ImageScalingSize = new Size(20, 20);
menuStrip1.Items.AddRange(new ToolStripItem[] { созданиеДоставкиToolStripMenuItem, созданиеТипаДоставкиToolStripMenuItem, pDFДокументToolStripMenuItem, excelОтчётToolStripMenuItem, wordДиаграммаToolStripMenuItem });
menuStrip1.Items.AddRange(new ToolStripItem[] { созданиеДоставкиToolStripMenuItem, созданиеТипаДоставкиToolStripMenuItem, pDFДокументToolStripMenuItem, excelОтчётToolStripMenuItem, wordДиаграммаToolStripMenuItem, редактироватьtoolStripMenuItem });
menuStrip1.Location = new Point(0, 0);
menuStrip1.Name = "menuStrip1";
menuStrip1.Size = new Size(800, 28);
@ -49,9 +57,31 @@
//
// созданиеДоставкиToolStripMenuItem
//
созданиеДоставкиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { создатьДоставкуToolStripMenuItem, редактироватьДоставкуToolStripMenuItem, удалитьДоставкуToolStripMenuItem });
созданиеДоставкиToolStripMenuItem.Name = "созданиеДоставкиToolStripMenuItem";
созданиеДоставкиToolStripMenuItem.Size = new Size(156, 24);
созданиеДоставкиToolStripMenuItem.Text = "Создание доставки";
созданиеДоставкиToolStripMenuItem.Size = new Size(131, 24);
созданиеДоставкиToolStripMenuItem.Text = "Меню доставок";
//
// создатьДоставкуToolStripMenuItem
//
создатьДоставкуToolStripMenuItem.Name = "создатьДоставкуToolStripMenuItem";
создатьДоставкуToolStripMenuItem.Size = new Size(258, 26);
создатьДоставкуToolStripMenuItem.Text = "Создать доставку";
создатьДоставкуToolStripMenuItem.Click += созданиеДоставкиToolStripMenuItem_Click;
//
// редактироватьДоставкуToolStripMenuItem
//
редактироватьДоставкуToolStripMenuItem.Name = "редактироватьДоставкуToolStripMenuItem";
редактироватьДоставкуToolStripMenuItem.Size = new Size(258, 26);
редактироватьДоставкуToolStripMenuItem.Text = "Редактировать доставку";
редактироватьДоставкуToolStripMenuItem.Click += editProviderToolStripMenuItem_Click;
//
// удалитьДоставкуToolStripMenuItem
//
удалитьДоставкуToolStripMenuItem.Name = "удалитьДоставкуToolStripMenuItem";
удалитьДоставкуToolStripMenuItem.Size = new Size(258, 26);
удалитьДоставкуToolStripMenuItem.Text = "Удалить доставку";
удалитьДоставкуToolStripMenuItem.Click += deleteProviderToolStripMenuItem_Click;
//
// созданиеТипаДоставкиToolStripMenuItem
//
@ -65,6 +95,7 @@
pDFДокументToolStripMenuItem.Name = "pDFДокументToolStripMenuItem";
pDFДокументToolStripMenuItem.Size = new Size(118, 24);
pDFДокументToolStripMenuItem.Text = "PDF документ";
pDFДокументToolStripMenuItem.Click += pDFДокументToolStripMenuItem_Click;
//
// excelОтчётToolStripMenuItem
//
@ -77,16 +108,33 @@
wordДиаграммаToolStripMenuItem.Name = "wordДиаграммаToolStripMenuItem";
wordДиаграммаToolStripMenuItem.Size = new Size(141, 24);
wordДиаграммаToolStripMenuItem.Text = "Word диаграмма";
wordДиаграммаToolStripMenuItem.Click += wordДиаграммаToolStripMenuItem_Click;
//
// редактироватьtoolStripMenuItem
//
редактироватьtoolStripMenuItem.Name = "редактироватьtoolStripMenuItem";
редактироватьtoolStripMenuItem.Size = new Size(189, 24);
редактироватьtoolStripMenuItem.Text = "Редактировать доставку";
//
// controlDataTreeTable
//
controlDataTreeTable.Location = new Point(0, 33);
controlDataTreeTable.Margin = new Padding(4, 5, 4, 5);
controlDataTreeTable.Name = "controlDataTreeTable";
controlDataTreeTable.Size = new Size(787, 320);
controlDataTreeTable.TabIndex = 2;
//
// FormMain
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
ClientSize = new Size(800, 367);
Controls.Add(controlDataTreeTable);
Controls.Add(menuStrip1);
MainMenuStrip = menuStrip1;
Name = "FormMain";
Text = "FormMain";
Load += FormMain_Load;
menuStrip1.ResumeLayout(false);
menuStrip1.PerformLayout();
ResumeLayout(false);
@ -101,5 +149,12 @@
private ToolStripMenuItem pDFДокументToolStripMenuItem;
private ToolStripMenuItem excelОтчётToolStripMenuItem;
private ToolStripMenuItem wordДиаграммаToolStripMenuItem;
private ToolStripMenuItem создатьДоставкуToolStripMenuItem;
private ToolStripMenuItem редактироватьДоставкуToolStripMenuItem;
private ToolStripMenuItem удалитьДоставкуToolStripMenuItem;
private ToolStripMenuItem редактироватьtoolStripMenuItem;
private ControlsLibraryNet60.Data.ControlDataTreeTable controlDataTreeTable;
private Controls.LargeTextComponent largeTextComponent;
private ComponentsLibraryNet60.DocumentWithChart.ComponentDocumentWithChartPieWord componentDocumentWithChartPieWord;
}
}

View File

@ -1,4 +1,13 @@
using System;
using ComponentsLibraryNet60.DocumentWithChart;
using ComponentsLibraryNet60.Models;
using Contracts.BindlingModels;
using Contracts.BusinessLogicContracts;
using Contracts.ViewModels;
using Controls;
using ControlsLibraryNet60.Data;
using ControlsLibraryNet60.Models;
using CustomComponents;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@ -12,9 +21,38 @@ namespace Forms
{
public partial class FormMain : Form
{
public FormMain()
private readonly IDeliveryLogic _dlogic;
private readonly IDeliveryTypeLogic _dtlogic;
public FormMain(IDeliveryLogic dLogic, IDeliveryTypeLogic dtLogic)
{
InitializeComponent();
_dlogic = dLogic;
_dtlogic = dtLogic;
TreeConfig();
LoadData();
}
private void TreeConfig()
{
DataTreeNodeConfig treeConfig = new();
treeConfig.NodeNames = new();
treeConfig.NodeNames.Enqueue("Id");
treeConfig.NodeNames.Enqueue("FCs");
treeConfig.NodeNames.Enqueue("Wishes");
treeConfig.NodeNames.Enqueue("DeliveryType");
treeConfig.NodeNames.Enqueue("DeliveryDate");
controlDataTreeTable.LoadConfig(treeConfig);
}
private void LoadData()
{
var list = _dlogic.ReadList(null);
if (list != null)
{
controlDataTreeTable.Clear();
controlDataTreeTable.AddTable(list);
}
}
private void созданиеТипаДоставкиToolStripMenuItem_Click(object sender, EventArgs e)
@ -25,5 +63,111 @@ namespace Forms
form.ShowDialog();
}
}
private void созданиеДоставкиToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(DeliveryForm));
if (service is DeliveryForm form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void editProviderToolStripMenuItem_Click(object sender, EventArgs e)
{
int id = Convert.ToInt32(controlDataTreeTable.GetSelectedObject<DeliveryViewModel>()?.Id);
DeliveryForm form = new DeliveryForm(_dlogic, _dtlogic, id);
form.ShowDialog();
LoadData();
}
private void deleteProviderToolStripMenuItem_Click(object sender, EventArgs e)
{
var confirmResult = MessageBox.Show("Вы действительно хотите удалить запись?", "Подтвердите действие",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question
);
if (confirmResult == DialogResult.Yes)
{
_dlogic.Delete(new DeliveryBindingModel
{
Id = Convert.ToInt32(controlDataTreeTable.GetSelectedObject<DeliveryViewModel>()?.Id),
});
LoadData();
}
}
private void FormMain_Load(object sender, EventArgs e)
{
LoadData();
}
private void pDFДокументToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.ShowDialog();
string path = saveFileDialog.FileName + ".pdf";
var list = _dlogic.ReadList(null);
if (list != null)
{
int i = 0;
foreach (var item in list)
{
if (item.DeliveryDate == "Даты доставки нет") i++;
}
string[] strings = new string[i];
int j = 0;
foreach (var item in list)
{
if (item.DeliveryDate == "Даты доставки нет") { strings[j] = ($"{item.FCs} : {item.Wishes}"); j++; }
}
largeTextComponent.CreateDocument(path, $"Отчет по доставкам без даты:", strings);
MessageBox.Show("Отчет готов");
}
}
private void wordДиаграммаToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog saveFileDialog = new SaveFileDialog();
saveFileDialog.ShowDialog();
string path = saveFileDialog.FileName + ".docx";
var list = _dlogic.ReadList(null);
var data = new List<(int Date, double Value)> { };
string header = "График доставок известной даты\n";
var chart = new Dictionary<string, List<(int Date, double Value)>> { };
int index = 1;
foreach (var type in _dtlogic.ReadList(null)!)
{
int sum = 0;
foreach (var item in list)
{
if (item.DeliveryType == type.Name)
{
sum++;
}
}
header += $"{index} - {type.Name}\n";
if (sum != 0) data.Add((index, sum));
index++;
}
chart.Add("ИП", data);
var conf = new ComponentDocumentWithChartConfig
{
FilePath = path,
Header = header,
ChartTitle = "Диаграмма по типам доставок",
LegendLocation = ComponentsLibraryNet60.Models.Location.Bottom,
Data = chart,
};
componentDocumentWithChartPieWord.CreateDoc(conf);
MessageBox.Show("Отчет готов");
}
}
}

View File

@ -120,4 +120,10 @@
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<metadata name="largeTextComponent.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>153, 17</value>
</metadata>
<metadata name="componentDocumentWithChartPieWord.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>348, 17</value>
</metadata>
</root>

View File

@ -35,7 +35,7 @@ namespace Forms
services.AddTransient<IDeliveryStorage, DeliveryStorage>();
services.AddTransient<FormMain>();
services.AddTransient<DeliveryTypeForm>();
//services.AddTransient<DeliveryForm>(); ;
services.AddTransient<DeliveryForm>(); ;
}
}
}