From 376ad6e63ff2f96d77ab292cd75db4d57801a6fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=BA=20=D0=98=D0=B3=D0=BE=D1=80=D1=8C?= Date: Mon, 24 Apr 2023 04:12:10 +0400 Subject: [PATCH] =?UTF-8?q?=D1=84=D0=BE=D1=80=D0=BC=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BlacksmithWorkshop/FormStore.Designer.cs | 22 +++++++++++++++++++ .../BlacksmithWorkshop/FormStore.cs | 19 +++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormStore.Designer.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormStore.Designer.cs index 79e5adf..8df428b 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormStore.Designer.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormStore.Designer.cs @@ -40,6 +40,8 @@ this.ColumnManufactureName = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ColumnPrice = new System.Windows.Forms.DataGridViewTextBoxColumn(); this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn(); + this.textBoxMaxManufactures = new System.Windows.Forms.TextBox(); + this.labelMaxManufactures = new System.Windows.Forms.Label(); ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); this.SuspendLayout(); // @@ -143,6 +145,22 @@ this.ColumnCount.HeaderText = "Количество"; this.ColumnCount.Name = "ColumnCount"; // + // textBoxMaxManufactures + // + this.textBoxMaxManufactures.Location = new System.Drawing.Point(493, 15); + this.textBoxMaxManufactures.Name = "textBoxMaxManufactures"; + this.textBoxMaxManufactures.Size = new System.Drawing.Size(132, 23); + this.textBoxMaxManufactures.TabIndex = 4; + // + // labelMaxManufactures + // + this.labelMaxManufactures.AutoSize = true; + this.labelMaxManufactures.Location = new System.Drawing.Point(400, 18); + this.labelMaxManufactures.Name = "labelMaxManufactures"; + this.labelMaxManufactures.Size = new System.Drawing.Size(87, 15); + this.labelMaxManufactures.TabIndex = 6; + this.labelMaxManufactures.Text = "Макс. изделий"; + // // FormStore // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); @@ -154,8 +172,10 @@ this.Controls.Add(this.buttonSave); this.Controls.Add(this.labelOpeningDate); this.Controls.Add(this.labelAddress); + this.Controls.Add(this.labelMaxManufactures); this.Controls.Add(this.labelName); this.Controls.Add(this.textBoxAddress); + this.Controls.Add(this.textBoxMaxManufactures); this.Controls.Add(this.textBoxName); this.Name = "FormStore"; this.Text = "Магазин"; @@ -180,5 +200,7 @@ private DataGridViewTextBoxColumn ColumnManufactureName; private DataGridViewTextBoxColumn ColumnPrice; private DataGridViewTextBoxColumn ColumnCount; + private TextBox textBoxMaxManufactures; + private Label labelMaxManufactures; } } \ No newline at end of file diff --git a/BlacksmithWorkshop/BlacksmithWorkshop/FormStore.cs b/BlacksmithWorkshop/BlacksmithWorkshop/FormStore.cs index 1242c50..43837ff 100644 --- a/BlacksmithWorkshop/BlacksmithWorkshop/FormStore.cs +++ b/BlacksmithWorkshop/BlacksmithWorkshop/FormStore.cs @@ -38,6 +38,7 @@ namespace BlacksmithWorkshopView textBoxName.Text = view.StoreName; textBoxAddress.Text = view.Address; dateTimePicker.Value = view.OpeningDate; + textBoxMaxManufactures.Text = view.MaxManufactures.ToString(); } LoadData(); } @@ -89,6 +90,21 @@ namespace BlacksmithWorkshopView MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } + if (string.IsNullOrEmpty(textBoxMaxManufactures.Text)) + { + MessageBox.Show("Заполните максимальное количество изделий", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + int maxManufactures; + try//штоб программа не упала + { + maxManufactures = Convert.ToInt32(textBoxMaxManufactures.Text); + } + catch + { + MessageBox.Show("Неверное значение в поле Макс. изделий", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } _logger.LogInformation("Сохранение магазина"); try { @@ -97,7 +113,8 @@ namespace BlacksmithWorkshopView Id = _id ?? 0, StoreName = textBoxName.Text, Address = textBoxAddress.Text, - OpeningDate = dateTimePicker.Value + OpeningDate = dateTimePicker.Value, + MaxManufactures = maxManufactures }; var operationResult = _id.HasValue ? _logicS.Update(model) : _logicS.Create(model); if (!operationResult)