Изменена форма создания магазина с учетом вместимости

This commit is contained in:
Данила Мочалов 2023-02-27 10:31:58 +04:00
parent de6f3af8df
commit f20984c4ba
3 changed files with 58 additions and 32 deletions

View File

@ -35,11 +35,13 @@
this.labelOpeningDate = new System.Windows.Forms.Label();
this.dateTimePicker = new System.Windows.Forms.DateTimePicker();
this.dataGridView = new System.Windows.Forms.DataGridView();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonSave = new System.Windows.Forms.Button();
this.ColumnId = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnDocumentName = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonSave = new System.Windows.Forms.Button();
this.labelMaxCount = new System.Windows.Forms.Label();
this.textBoxMaxCountDocs = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
@ -98,33 +100,13 @@
this.ColumnId,
this.ColumnDocumentName,
this.ColumnCount});
this.dataGridView.Location = new System.Drawing.Point(14, 138);
this.dataGridView.Location = new System.Drawing.Point(14, 173);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowHeadersWidth = 51;
this.dataGridView.RowTemplate.Height = 29;
this.dataGridView.Size = new System.Drawing.Size(401, 300);
this.dataGridView.Size = new System.Drawing.Size(401, 265);
this.dataGridView.TabIndex = 10;
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(228, 448);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(155, 29);
this.buttonCancel.TabIndex = 12;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(48, 448);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(155, 29);
this.buttonSave.TabIndex = 11;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
//
// ColumnId
//
this.ColumnId.HeaderText = "ID";
@ -147,11 +129,49 @@
this.ColumnCount.Name = "ColumnCount";
this.ColumnCount.Width = 125;
//
// buttonCancel
//
this.buttonCancel.Location = new System.Drawing.Point(228, 448);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(155, 29);
this.buttonCancel.TabIndex = 12;
this.buttonCancel.Text = "Отмена";
this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
//
// buttonSave
//
this.buttonSave.Location = new System.Drawing.Point(48, 448);
this.buttonSave.Name = "buttonSave";
this.buttonSave.Size = new System.Drawing.Size(155, 29);
this.buttonSave.TabIndex = 11;
this.buttonSave.Text = "Сохранить";
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
//
// labelMaxCount
//
this.labelMaxCount.AutoSize = true;
this.labelMaxCount.Location = new System.Drawing.Point(18, 128);
this.labelMaxCount.Name = "labelMaxCount";
this.labelMaxCount.Size = new System.Drawing.Size(216, 20);
this.labelMaxCount.TabIndex = 13;
this.labelMaxCount.Text = "Макс. количество документов";
//
// textBoxMaxCountDocs
//
this.textBoxMaxCountDocs.Location = new System.Drawing.Point(240, 128);
this.textBoxMaxCountDocs.Name = "textBoxMaxCountDocs";
this.textBoxMaxCountDocs.Size = new System.Drawing.Size(175, 27);
this.textBoxMaxCountDocs.TabIndex = 14;
//
// FormShop
//
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(445, 489);
this.Controls.Add(this.textBoxMaxCountDocs);
this.Controls.Add(this.labelMaxCount);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.dataGridView);
@ -184,5 +204,7 @@
private DataGridViewTextBoxColumn ColumnId;
private DataGridViewTextBoxColumn ColumnDocumentName;
private DataGridViewTextBoxColumn ColumnCount;
private Label labelMaxCount;
private TextBox textBoxMaxCountDocs;
}
}

View File

@ -102,6 +102,11 @@ namespace LawFirmView
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxMaxCountDocs.Text))
{
MessageBox.Show("Заполните макс. количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Сохранение магазина");
try
{
@ -110,7 +115,8 @@ namespace LawFirmView
Id = _id ?? 0,
Name = textBoxName.Text,
Adress = textBoxAddress.Text,
OpeningDate = dateTimePicker.Value.Date
OpeningDate = dateTimePicker.Value.Date,
MaxCountDocuments = Convert.ToInt32(textBoxMaxCountDocs.Text)
};
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
if (!operationResult)

View File

@ -97,12 +97,9 @@ namespace LawFirmFileImplement.Implements
{
if (doc.Value.Item1.Id == document.Id)
{
if (count > 0)
{
count = count - doc.Value.Item2;
}
count -= doc.Value.Item2;
}
if (count < 1)
if (count <= 0)
{
break;
}
@ -134,7 +131,7 @@ namespace LawFirmFileImplement.Implements
}
}
if (count < 1)
if (count <= 0)
{
shop.Update(new ShopBindingModel
{
@ -145,9 +142,10 @@ namespace LawFirmFileImplement.Implements
MaxCountDocuments = shop.MaxCountDocuments,
ShopDocuments= documents
});
break;
return true;
}
}
shop.Update(new ShopBindingModel
{
Id = shop.Id,