Усложнённая лабораторная №1: Исправление

This commit is contained in:
Сергей Полевой 2023-03-26 00:21:15 +04:00
parent 808e702f0b
commit 992bc106c7
2 changed files with 27 additions and 3 deletions

View File

@ -38,6 +38,8 @@
this.ColumnCount = new System.Windows.Forms.DataGridViewTextBoxColumn();
this.buttonCancel = new System.Windows.Forms.Button();
this.buttonSave = new System.Windows.Forms.Button();
this.openDateTimePicker = new System.Windows.Forms.DateTimePicker();
this.openDateLabel = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
@ -82,12 +84,12 @@
this.ColumnId,
this.ColumnBouquetName,
this.ColumnCount});
this.dataGridView.Location = new System.Drawing.Point(12, 61);
this.dataGridView.Location = new System.Drawing.Point(12, 99);
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowHeadersWidth = 51;
this.dataGridView.RowTemplate.Height = 29;
this.dataGridView.Size = new System.Drawing.Size(351, 251);
this.dataGridView.Size = new System.Drawing.Size(351, 224);
this.dataGridView.TabIndex = 10;
//
// ColumnId
@ -134,11 +136,29 @@
this.buttonSave.UseVisualStyleBackColor = true;
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
//
// openDateTimePicker
//
this.openDateTimePicker.Location = new System.Drawing.Point(108, 62);
this.openDateTimePicker.Name = "openDateTimePicker";
this.openDateTimePicker.Size = new System.Drawing.Size(255, 23);
this.openDateTimePicker.TabIndex = 13;
//
// openDateLabel
//
this.openDateLabel.AutoSize = true;
this.openDateLabel.Location = new System.Drawing.Point(12, 68);
this.openDateLabel.Name = "openDateLabel";
this.openDateLabel.Size = new System.Drawing.Size(90, 15);
this.openDateLabel.TabIndex = 14;
this.openDateLabel.Text = "Дата открытия:";
//
// FormShop
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(389, 367);
this.Controls.Add(this.openDateLabel);
this.Controls.Add(this.openDateTimePicker);
this.Controls.Add(this.buttonCancel);
this.Controls.Add(this.buttonSave);
this.Controls.Add(this.dataGridView);
@ -168,5 +188,7 @@
private DataGridViewTextBoxColumn ColumnId;
private DataGridViewTextBoxColumn ColumnBouquetName;
private DataGridViewTextBoxColumn ColumnCount;
private DateTimePicker openDateTimePicker;
private Label openDateLabel;
}
}

View File

@ -37,6 +37,7 @@ namespace FlowerShop
{
textBoxName.Text = view.Name;
textBoxAddress.Text = view.Address;
openDateTimePicker.Value = view.OpeningDate;
_shopBouquets = view.ShopBouquets ?? new Dictionary<int, (IBouquetModel, int)>();
LoadData();
}
@ -94,7 +95,8 @@ namespace FlowerShop
Id = _id ?? 0,
Name = textBoxName.Text,
Address = textBoxAddress.Text,
OpeningDate = DateTime.Now
OpeningDate = openDateTimePicker.Value,
ShopBouquets = _shopBouquets
};
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);