форма

This commit is contained in:
Мк Игорь 2023-04-24 04:12:10 +04:00
parent 349663d499
commit 376ad6e63f
2 changed files with 40 additions and 1 deletions

View File

@ -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;
}
}

View File

@ -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)