From 57852c70118ccf02dfb9c88c5e7866da04516924 Mon Sep 17 00:00:00 2001 From: GokaPek Date: Fri, 21 Jun 2024 19:29:54 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A7=D1=82=D0=BE-=D1=82=D0=BE=20=D1=81=D0=B4?= =?UTF-8?q?=D0=B5=D0=BB=D0=B0=D0=BD=D0=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Implements/ShopStorage.cs | 1 + .../Models/Shop.cs | 197 +++++++++--------- .../Implements/ShopStorage.cs | 6 +- .../Models/Shop.cs | 1 + LawFirm/LawFirmView/FormMain.cs | 11 +- LawFirm/LawFirmView/FormMain.designer.cs | 14 ++ .../LawFirmView/FormSellDocuments.Designer.cs | 120 +++++++++++ LawFirm/LawFirmView/FormSellDocuments.cs | 94 +++++++++ LawFirm/LawFirmView/FormSellDocuments.resx | 120 +++++++++++ LawFirm/LawFirmView/FormShop.Designer.cs | 37 +++- LawFirm/LawFirmView/FormShop.cs | 7 + LawFirm/LawFirmView/Program.cs | 1 + 12 files changed, 501 insertions(+), 108 deletions(-) create mode 100644 LawFirm/LawFirmView/FormSellDocuments.Designer.cs create mode 100644 LawFirm/LawFirmView/FormSellDocuments.cs create mode 100644 LawFirm/LawFirmView/FormSellDocuments.resx diff --git a/LawFirm/AbstractLawFirmFileImpliment/Implements/ShopStorage.cs b/LawFirm/AbstractLawFirmFileImpliment/Implements/ShopStorage.cs index 1038019..bb6969c 100644 --- a/LawFirm/AbstractLawFirmFileImpliment/Implements/ShopStorage.cs +++ b/LawFirm/AbstractLawFirmFileImpliment/Implements/ShopStorage.cs @@ -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; diff --git a/LawFirm/AbstractLawFirmFileImpliment/Models/Shop.cs b/LawFirm/AbstractLawFirmFileImpliment/Models/Shop.cs index 8ffb924..6b2a370 100644 --- a/LawFirm/AbstractLawFirmFileImpliment/Models/Shop.cs +++ b/LawFirm/AbstractLawFirmFileImpliment/Models/Shop.cs @@ -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 Documents { get; private set; } = new(); - private Dictionary? _shopDocuments = null; - public Dictionary 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 Documents { get; private set; } = new(); + private Dictionary? _shopDocuments = null; + public Dictionary 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())); + } +} \ No newline at end of file diff --git a/LawFirm/AbstractLawFirmListImplement/Implements/ShopStorage.cs b/LawFirm/AbstractLawFirmListImplement/Implements/ShopStorage.cs index aa88ff1..8a94b2d 100644 --- a/LawFirm/AbstractLawFirmListImplement/Implements/ShopStorage.cs +++ b/LawFirm/AbstractLawFirmListImplement/Implements/ShopStorage.cs @@ -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) diff --git a/LawFirm/AbstractLawFirmListImplement/Models/Shop.cs b/LawFirm/AbstractLawFirmListImplement/Models/Shop.cs index 144fea1..92430c3 100644 --- a/LawFirm/AbstractLawFirmListImplement/Models/Shop.cs +++ b/LawFirm/AbstractLawFirmListImplement/Models/Shop.cs @@ -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 ShopDocuments { diff --git a/LawFirm/LawFirmView/FormMain.cs b/LawFirm/LawFirmView/FormMain.cs index 0391af9..49a0a6d 100644 --- a/LawFirm/LawFirmView/FormMain.cs +++ b/LawFirm/LawFirmView/FormMain.cs @@ -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(); + } + } } } diff --git a/LawFirm/LawFirmView/FormMain.designer.cs b/LawFirm/LawFirmView/FormMain.designer.cs index b8e47a7..eb318fb 100644 --- a/LawFirm/LawFirmView/FormMain.designer.cs +++ b/LawFirm/LawFirmView/FormMain.designer.cs @@ -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; } } \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormSellDocuments.Designer.cs b/LawFirm/LawFirmView/FormSellDocuments.Designer.cs new file mode 100644 index 0000000..07cbb98 --- /dev/null +++ b/LawFirm/LawFirmView/FormSellDocuments.Designer.cs @@ -0,0 +1,120 @@ +namespace LawFirmView +{ + partial class FormSellDocuments + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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; + } +} \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormSellDocuments.cs b/LawFirm/LawFirmView/FormSellDocuments.cs new file mode 100644 index 0000000..8ca3cae --- /dev/null +++ b/LawFirm/LawFirmView/FormSellDocuments.cs @@ -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 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(); + } + } +} \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormSellDocuments.resx b/LawFirm/LawFirmView/FormSellDocuments.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/LawFirm/LawFirmView/FormSellDocuments.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormShop.Designer.cs b/LawFirm/LawFirmView/FormShop.Designer.cs index ac8233e..60240b8 100644 --- a/LawFirm/LawFirmView/FormShop.Designer.cs +++ b/LawFirm/LawFirmView/FormShop.Designer.cs @@ -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; } } \ No newline at end of file diff --git a/LawFirm/LawFirmView/FormShop.cs b/LawFirm/LawFirmView/FormShop.cs index cf7d42b..ae11116 100644 --- a/LawFirm/LawFirmView/FormShop.cs +++ b/LawFirm/LawFirmView/FormShop.cs @@ -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(); 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 }; diff --git a/LawFirm/LawFirmView/Program.cs b/LawFirm/LawFirmView/Program.cs index 603ee59..05c61ea 100644 --- a/LawFirm/LawFirmView/Program.cs +++ b/LawFirm/LawFirmView/Program.cs @@ -53,6 +53,7 @@ namespace LawFirmView services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); } }