ПИбд-22 Петрушин Егор | Усложнённая Лабораторная №2 Юридическая фирма #10

Closed
Egor_Petrushin wants to merge 8 commits from Lab2_hard into Lab1_hard
12 changed files with 501 additions and 108 deletions
Showing only changes of commit 57852c7011 - Show all commits

View File

@ -3,6 +3,7 @@ using AbstractLawFirmContracts.SearchModels;
using AbstractLawFirmContracts.StoragesContracts;
using AbstractLawFirmContracts.ViewModels;
using AbstractLawFirmDataModels.Models;
using AbstractLawFirmFileImplement.Models;
using AbstractLawFirmFileImpliment;
using System;
using System.Collections.Generic;

View File

@ -11,105 +11,104 @@ using System.Xml.Linq;
namespace AbstractLawFirmFileImplement.Models
{
public class Shop : IShopModel
{
public int Id { get; private set; }
public string ShopName { get; private set; } = string.Empty;
public string Address { get; private set; } = string.Empty;
public int MaxCountDocuments { get; private set; }
public DateTime OpeningDate { get; private set; }
public Dictionary<int, int> Documents { get; private set; } = new();
private Dictionary<int, (IDocumentModel, int)>? _shopDocuments = null;
public Dictionary<int, (IDocumentModel, int)> ShopDocuments
{
get
{
if (_shopDocuments == null)
{
var source = DataFileSingleton.GetInstance();
_shopDocuments = Documents.ToDictionary(
x => x.Key,
y => ((source.Documents.FirstOrDefault(z => z.Id == y.Key) as IDocumentModel)!, y.Value)
);
}
return _shopDocuments;
}
}
public static Shop? Create(ShopBindingModel? model)
{
if (model == null)
{
return null;
}
return new Shop()
{
Id = model.Id,
ShopName = model.ShopName,
Address = model.Address,
MaxCountDocuments = model.MaxCountDocuments,
OpeningDate = model.OpeningDate,
Documents = model.ShopDocuments.ToDictionary(x => x.Key, x => x.Value.Item2)
};
}
public static Shop? Create(XElement element)
{
if (element == null)
{
return null;
}
return new Shop()
{
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
ShopName = element.Element("ShopName")!.Value,
Address = element.Element("Address")!.Value,
MaxCountDocuments = Convert.ToInt32(element.Element("MaxCountDocuments")!.Value),
OpeningDate = Convert.ToDateTime(element.Element("OpeningDate")!.Value),
Documents = element.Element("ShopDocuments")!.Elements("ShopDocument").ToDictionary(
x => Convert.ToInt32(x.Element("Key")?.Value),
x => Convert.ToInt32(x.Element("Value")?.Value)
)
};
}
public class Shop : IShopModel
{
public int Id { get; private set; }
public string ShopName { get; private set; } = string.Empty;
public string Address { get; private set; } = string.Empty;
public int MaxCountDocuments { get; private set; }
public DateTime OpeningDate { get; private set; }
public Dictionary<int, int> Documents { get; private set; } = new();
private Dictionary<int, (IDocumentModel, int)>? _shopDocuments = null;
public Dictionary<int, (IDocumentModel, int)> ShopDocuments
{
get
{
if (_shopDocuments == null)
{
var source = DataFileSingleton.GetInstance();
_shopDocuments = Documents.ToDictionary(
x => x.Key,
y => ((source.Documents.FirstOrDefault(z => z.Id == y.Key) as IDocumentModel)!, y.Value)
);
}
return _shopDocuments;
}
}
public static Shop? Create(ShopBindingModel? model)
{
if (model == null)
{
return null;
}
return new Shop()
{
Id = model.Id,
ShopName = model.ShopName,
Address = model.Address,
MaxCountDocuments = model.MaxCountDocuments,
OpeningDate = model.OpeningDate,
Documents = model.ShopDocuments.ToDictionary(x => x.Key, x => x.Value.Item2)
};
}
public static Shop? Create(XElement element)
{
if (element == null)
{
return null;
}
return new Shop()
{
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
ShopName = element.Element("ShopName")!.Value,
Address = element.Element("Address")!.Value,
MaxCountDocuments = Convert.ToInt32(element.Element("MaxCountDocuments")!.Value),
OpeningDate = Convert.ToDateTime(element.Element("OpeningDate")!.Value),
Documents = element.Element("ShopDocuments")!.Elements("ShopDocument").ToDictionary(
x => Convert.ToInt32(x.Element("Key")?.Value),
x => Convert.ToInt32(x.Element("Value")?.Value)
)
};
}
public void Update(ShopBindingModel? model)
{
if (model == null)
{
return;
}
ShopName = model.ShopName;
Address = model.Address;
MaxCountDocuments = model.MaxCountDocuments;
OpeningDate = model.OpeningDate;
if (model.ShopDocuments.Count > 0)
{
Documents = model.ShopDocuments.ToDictionary(x => x.Key, x => x.Value.Item2);
_shopDocuments = null;
}
}
public ShopViewModel GetViewModel => new()
{
Id = Id,
ShopName = ShopName,
Address = Address,
MaxCountDocuments = MaxCountDocuments,
OpeningDate = OpeningDate,
ShopDocuments = ShopDocuments,
};
public void Update(ShopBindingModel? model)
{
if (model == null)
{
return;
}
ShopName = model.ShopName;
Address = model.Address;
MaxCountDocuments = model.MaxCountDocuments;
OpeningDate = model.OpeningDate;
if (model.ShopDocuments.Count > 0)
{
Documents = model.ShopDocuments.ToDictionary(x => x.Key, x => x.Value.Item2);
_shopDocuments = null;
}
}
public ShopViewModel GetViewModel => new()
{
Id = Id,
ShopName = ShopName,
Address = Address,
MaxCountDocuments = MaxCountDocuments,
OpeningDate = OpeningDate,
ShopDocuments = ShopDocuments,
};
public XElement GetXElement => new(
"Shop",
new XAttribute("Id", Id),
new XElement("ShopName", ShopName),
new XElement("Address", Address),
new XElement("MaxCountDocuments", MaxCountDocuments),
new XElement("OpeningDate", OpeningDate.ToString()),
new XElement("ShopDocuments", Documents.Select(x =>
new XElement("ShopDocument",
new XElement("Key", x.Key),
new XElement("Value", x.Value)))
.ToArray()));
}
}
}
public XElement GetXElement => new(
"Shop",
new XAttribute("Id", Id),
new XElement("ShopName", ShopName),
new XElement("Address", Address),
new XElement("MaxCountDocuments", MaxCountDocuments),
new XElement("OpeningDate", OpeningDate.ToString()),
new XElement("ShopDocuments", Documents.Select(x =>
new XElement("ShopDocument",
new XElement("Key", x.Key),
new XElement("Value", x.Value)))
.ToArray()));
}
}

View File

@ -3,6 +3,7 @@ using AbstractLawFirmContracts.SearchModels;
using AbstractLawFirmContracts.StoragesContracts;
using AbstractLawFirmContracts.ViewModels;
using AbstractLawFirmListImplement.Models;
using AbstractLawFirmDataModels.Models;
using System;
using System.Collections.Generic;
using System.Linq;
@ -19,7 +20,10 @@ namespace AbstractLawFirmListImplement.Implements
{
_source = DataListSingleton.GetInstance();
}
public bool SellDocument(IDocumentModel document, int count)
{
throw new NotImplementedException();
}
public ShopViewModel? GetElement(ShopSearchModel model)
{
if (string.IsNullOrEmpty(model.ShopName) && !model.Id.HasValue)

View File

@ -14,6 +14,7 @@ namespace AbstractLawFirmListImplement.Models
public int Id { get; private set; }
public string ShopName { get; private set; } = string.Empty;
public string Address { get; private set; } = string.Empty;
public int MaxCountDocuments { get; private set; }
public DateTime OpeningDate { get; private set; }
public Dictionary<int, (IDocumentModel, int)> ShopDocuments
{

View File

@ -126,7 +126,7 @@ namespace LawFirmView
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка отметки о готовности заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
@ -193,5 +193,14 @@ namespace LawFirmView
form.ShowDialog();
}
}
private void buttonSellDocs_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormSellDocuments));
if (service is FormSellDocuments form)
{
form.ShowDialog();
}
}
}
}

View File

@ -40,6 +40,7 @@
buttonIssuedOrder = new Button();
buttonRef = new Button();
buttonSupplyShop = new Button();
buttonSellDocs = new Button();
menuStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
@ -160,11 +161,23 @@
buttonSupplyShop.UseVisualStyleBackColor = true;
buttonSupplyShop.Click += buttonSupplyShop_Click;
//
// buttonSellDocs
//
buttonSellDocs.Location = new Point(850, 289);
buttonSellDocs.Margin = new Padding(3, 4, 3, 4);
buttonSellDocs.Name = "buttonSellDocs";
buttonSellDocs.Size = new Size(178, 31);
buttonSellDocs.TabIndex = 8;
buttonSellDocs.Text = "Продать документы";
buttonSellDocs.UseVisualStyleBackColor = true;
buttonSellDocs.Click += buttonSellDocs_Click;
//
// FormMain
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1040, 636);
Controls.Add(buttonSellDocs);
Controls.Add(buttonSupplyShop);
Controls.Add(buttonRef);
Controls.Add(buttonIssuedOrder);
@ -199,5 +212,6 @@
private Button buttonRef;
private ToolStripMenuItem магазиныToolStripMenuItem;
private Button buttonSupplyShop;
private Button buttonSellDocs;
}
}

View File

@ -0,0 +1,120 @@
namespace LawFirmView
{
partial class FormSellDocuments
{
/// <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.comboBoxDoc = new System.Windows.Forms.ComboBox();
this.label1 = new System.Windows.Forms.Label();
this.textBoxCount = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.buttonSell = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// comboBoxDoc
//
this.comboBoxDoc.FormattingEnabled = true;
this.comboBoxDoc.Location = new System.Drawing.Point(149, 12);
this.comboBoxDoc.Name = "comboBoxDoc";
this.comboBoxDoc.Size = new System.Drawing.Size(218, 23);
this.comboBoxDoc.TabIndex = 0;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(24, 15);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(110, 15);
this.label1.TabIndex = 1;
this.label1.Text = "Пакет документов:";
//
// textBoxCount
//
this.textBoxCount.Location = new System.Drawing.Point(149, 41);
this.textBoxCount.Name = "textBoxCount";
this.textBoxCount.Size = new System.Drawing.Size(218, 23);
this.textBoxCount.TabIndex = 2;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(59, 49);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(75, 15);
this.label2.TabIndex = 4;
this.label2.Text = "Количество:";
//
// buttonSell
//
this.buttonSell.Location = new System.Drawing.Point(149, 92);
this.buttonSell.Name = "buttonSell";
this.buttonSell.Size = new System.Drawing.Size(75, 23);
this.buttonSell.TabIndex = 5;
this.buttonSell.Text = "Продать";
this.buttonSell.UseVisualStyleBackColor = true;
this.buttonSell.Click += new System.EventHandler(this.buttonSell_Click);
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(259, 92);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
this.buttonCancel.TabIndex = 6;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// FormSellDocuments
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(394, 137);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSell);
this.Controls.Add(this.label2);
this.Controls.Add(this.textBoxCount);
this.Controls.Add(this.label1);
this.Controls.Add(this.comboBoxDoc);
this.Name = "FormSellDocuments";
this.Text = "FormSellDocuments";
this.Load += new System.EventHandler(this.FormSellDocuments_Load);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private ComboBox comboBoxDoc;
private Label label1;
private TextBox textBoxCount;
private Label label2;
private Button buttonSell;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,94 @@
using AbstractLawFirmContracts.BindingModels;
using AbstractLawFirmContracts.BusinessLogicsContracts;
using Microsoft.Extensions.Logging;
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 LawFirmView
{
public partial class FormSellDocuments : Form
{
private readonly ILogger _logger;
private readonly IDocumentLogic _logicDocument;
private readonly IShopLogic _logicShop;
public FormSellDocuments(ILogger<FormSellDocuments> logger, IDocumentLogic logicDocument, IShopLogic logicShop)
{
InitializeComponent();
_logger = logger;
_logicDocument = logicDocument;
_logicShop = logicShop;
}
private void FormSellDocuments_Load(object sender, EventArgs e)
{
_logger.LogInformation("Загрузка документов для продажи");
try
{
var list = _logicDocument.ReadList(null);
if (list != null)
{
comboBoxDoc.DisplayMember = "DocumentName";
comboBoxDoc.ValueMember = "Id";
comboBoxDoc.DataSource = list;
comboBoxDoc.SelectedItem = null;
}
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки списка документов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonSell_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxCount.Text))
{
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxDoc.SelectedValue == null)
{
MessageBox.Show("Выберите пакет документов", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Создание продажи");
try
{
var operationResult = _logicShop.SellDocument(
new DocumentBindingModel
{
Id = Convert.ToInt32(comboBoxDoc.SelectedValue)
},
Convert.ToInt32(textBoxCount.Text)
);
if (!operationResult)
{
throw new Exception("Ошибка при создании продажи. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка создания продажи");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
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

@ -40,12 +40,14 @@
Column2 = new DataGridViewTextBoxColumn();
Column1 = new DataGridViewTextBoxColumn();
dataGridView = new DataGridView();
label4 = new Label();
textBoxMaxCountDoc = new TextBox();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// textBoxName
//
textBoxName.Location = new Point(149, 20);
textBoxName.Location = new Point(204, 6);
textBoxName.Margin = new Padding(3, 4, 3, 4);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(228, 27);
@ -53,7 +55,7 @@
//
// textBoxAddress
//
textBoxAddress.Location = new Point(149, 56);
textBoxAddress.Location = new Point(204, 41);
textBoxAddress.Margin = new Padding(3, 4, 3, 4);
textBoxAddress.Name = "textBoxAddress";
textBoxAddress.Size = new Size(228, 27);
@ -61,7 +63,7 @@
//
// dateTimePicker
//
dateTimePicker.Location = new Point(149, 94);
dateTimePicker.Location = new Point(204, 76);
dateTimePicker.Margin = new Padding(3, 4, 3, 4);
dateTimePicker.Name = "dateTimePicker";
dateTimePicker.Size = new Size(228, 27);
@ -92,7 +94,7 @@
// label1
//
label1.AutoSize = true;
label1.Location = new Point(48, 20);
label1.Location = new Point(30, 13);
label1.Name = "label1";
label1.Size = new Size(80, 20);
label1.TabIndex = 6;
@ -101,7 +103,7 @@
// label2
//
label2.AutoSize = true;
label2.Location = new Point(59, 59);
label2.Location = new Point(30, 48);
label2.Name = "label2";
label2.Size = new Size(54, 20);
label2.TabIndex = 7;
@ -110,7 +112,7 @@
// label3
//
label3.AutoSize = true;
label3.Location = new Point(30, 101);
label3.Location = new Point(30, 79);
label3.Name = "label3";
label3.Size = new Size(113, 20);
label3.TabIndex = 8;
@ -140,7 +142,7 @@
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Columns.AddRange(new DataGridViewColumn[] { Column1, Column2, Column3 });
dataGridView.Location = new Point(14, 132);
dataGridView.Location = new Point(12, 145);
dataGridView.Margin = new Padding(3, 4, 3, 4);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersWidth = 51;
@ -148,11 +150,30 @@
dataGridView.Size = new Size(613, 327);
dataGridView.TabIndex = 3;
//
// label4
//
label4.AutoSize = true;
label4.Location = new Point(30, 108);
label4.Name = "label4";
label4.Size = new Size(168, 20);
label4.TabIndex = 9;
label4.Text = "Максимальное кол-во:";
//
// textBoxMaxCountDoc
//
textBoxMaxCountDoc.Location = new Point(204, 101);
textBoxMaxCountDoc.Margin = new Padding(3, 4, 3, 4);
textBoxMaxCountDoc.Name = "textBoxMaxCountDoc";
textBoxMaxCountDoc.Size = new Size(228, 27);
textBoxMaxCountDoc.TabIndex = 10;
//
// FormShop
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(640, 557);
Controls.Add(textBoxMaxCountDoc);
Controls.Add(label4);
Controls.Add(label3);
Controls.Add(label2);
Controls.Add(label1);
@ -185,5 +206,7 @@
private DataGridViewTextBoxColumn Column2;
private DataGridViewTextBoxColumn Column1;
private DataGridView dataGridView;
private Label label4;
private TextBox textBoxMaxCountDoc;
}
}

View File

@ -45,6 +45,7 @@ namespace LawFirmView
{
textBoxName.Text = view.ShopName;
textBoxAddress.Text = view.Address;
textBoxMaxCountDoc.Text = view.MaxCountDocuments.ToString();
dateTimePicker.Value = view.OpeningDate;
_shopDocuments = view.ShopDocuments ?? new Dictionary<int, (IDocumentModel, int)>();
LoadData();
@ -98,6 +99,11 @@ namespace LawFirmView
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxMaxCountDoc.Text))
{
MessageBox.Show("Заполните макс. количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Сохранение магазина");
try
{
@ -106,6 +112,7 @@ namespace LawFirmView
Id = _id ?? 0,
ShopName = textBoxName.Text,
Address = textBoxAddress.Text,
MaxCountDocuments = Convert.ToInt32(textBoxMaxCountDoc.Text),
OpeningDate = dateTimePicker.Value.Date,
ShopDocuments = _shopDocuments
};

View File

@ -53,6 +53,7 @@ namespace LawFirmView
services.AddTransient<FormShop>();
services.AddTransient<FormShops>();
services.AddTransient<FormShopSupply>();
services.AddTransient<FormSellDocuments>();
}
}