Remake
This commit is contained in:
parent
363f6fe4e4
commit
9c61f92636
107
Pizzeria/Pizzeria/FormShop.Designer.cs
generated
107
Pizzeria/Pizzeria/FormShop.Designer.cs
generated
@ -34,48 +34,52 @@
|
||||
this.labelAdress = new System.Windows.Forms.Label();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.buttonSave = new System.Windows.Forms.Button();
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.id = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.PizzaName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.dateTimeOpen = new System.Windows.Forms.DateTimePicker();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// labelName
|
||||
//
|
||||
this.labelName.AutoSize = true;
|
||||
this.labelName.Location = new System.Drawing.Point(10, 11);
|
||||
this.labelName.Location = new System.Drawing.Point(11, 15);
|
||||
this.labelName.Name = "labelName";
|
||||
this.labelName.Size = new System.Drawing.Size(65, 15);
|
||||
this.labelName.Size = new System.Drawing.Size(84, 20);
|
||||
this.labelName.TabIndex = 0;
|
||||
this.labelName.Text = "Название: ";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
this.textBoxName.Location = new System.Drawing.Point(89, 9);
|
||||
this.textBoxName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.textBoxName.Location = new System.Drawing.Point(102, 12);
|
||||
this.textBoxName.Name = "textBoxName";
|
||||
this.textBoxName.Size = new System.Drawing.Size(242, 23);
|
||||
this.textBoxName.Size = new System.Drawing.Size(276, 27);
|
||||
this.textBoxName.TabIndex = 1;
|
||||
//
|
||||
// textBoxAdress
|
||||
//
|
||||
this.textBoxAdress.Location = new System.Drawing.Point(89, 44);
|
||||
this.textBoxAdress.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.textBoxAdress.Location = new System.Drawing.Point(102, 59);
|
||||
this.textBoxAdress.Name = "textBoxAdress";
|
||||
this.textBoxAdress.Size = new System.Drawing.Size(374, 23);
|
||||
this.textBoxAdress.Size = new System.Drawing.Size(427, 27);
|
||||
this.textBoxAdress.TabIndex = 3;
|
||||
//
|
||||
// labelAdress
|
||||
//
|
||||
this.labelAdress.AutoSize = true;
|
||||
this.labelAdress.Location = new System.Drawing.Point(10, 46);
|
||||
this.labelAdress.Location = new System.Drawing.Point(11, 61);
|
||||
this.labelAdress.Name = "labelAdress";
|
||||
this.labelAdress.Size = new System.Drawing.Size(46, 15);
|
||||
this.labelAdress.Size = new System.Drawing.Size(58, 20);
|
||||
this.labelAdress.TabIndex = 2;
|
||||
this.labelAdress.Text = "Адрес: ";
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(393, 92);
|
||||
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonCancel.Location = new System.Drawing.Point(451, 457);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(114, 33);
|
||||
this.buttonCancel.Size = new System.Drawing.Size(130, 44);
|
||||
this.buttonCancel.TabIndex = 5;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
@ -83,30 +87,89 @@
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Location = new System.Drawing.Point(264, 92);
|
||||
this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonSave.Location = new System.Drawing.Point(315, 457);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(114, 33);
|
||||
this.buttonSave.Size = new System.Drawing.Size(130, 44);
|
||||
this.buttonSave.TabIndex = 6;
|
||||
this.buttonSave.Text = "Сохранить";
|
||||
this.buttonSave.UseVisualStyleBackColor = true;
|
||||
this.buttonSave.Click += new System.EventHandler(this.buttonSave_Click);
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.AllowUserToAddRows = false;
|
||||
this.dataGridView.AllowUserToDeleteRows = false;
|
||||
this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.id,
|
||||
this.PizzaName,
|
||||
this.Count});
|
||||
this.dataGridView.Location = new System.Drawing.Point(12, 144);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.ReadOnly = true;
|
||||
this.dataGridView.RowHeadersBorderStyle = System.Windows.Forms.DataGridViewHeaderBorderStyle.None;
|
||||
this.dataGridView.RowHeadersWidthSizeMode = System.Windows.Forms.DataGridViewRowHeadersWidthSizeMode.AutoSizeToDisplayedHeaders;
|
||||
this.dataGridView.RowTemplate.Height = 29;
|
||||
this.dataGridView.Size = new System.Drawing.Size(569, 307);
|
||||
this.dataGridView.TabIndex = 7;
|
||||
//
|
||||
// id
|
||||
//
|
||||
this.id.HeaderText = "id";
|
||||
this.id.MinimumWidth = 6;
|
||||
this.id.Name = "id";
|
||||
this.id.ReadOnly = true;
|
||||
this.id.Visible = false;
|
||||
//
|
||||
// PizzaName
|
||||
//
|
||||
this.PizzaName.HeaderText = "Пицца";
|
||||
this.PizzaName.MinimumWidth = 6;
|
||||
this.PizzaName.Name = "PizzaName";
|
||||
this.PizzaName.ReadOnly = true;
|
||||
//
|
||||
// Count
|
||||
//
|
||||
this.Count.HeaderText = "Количество";
|
||||
this.Count.MinimumWidth = 6;
|
||||
this.Count.Name = "Count";
|
||||
this.Count.ReadOnly = true;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(12, 103);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(110, 20);
|
||||
this.label1.TabIndex = 8;
|
||||
this.label1.Text = "Дата открытия";
|
||||
//
|
||||
// dateTimeOpen
|
||||
//
|
||||
this.dateTimeOpen.Location = new System.Drawing.Point(128, 103);
|
||||
this.dateTimeOpen.Name = "dateTimeOpen";
|
||||
this.dateTimeOpen.Size = new System.Drawing.Size(401, 27);
|
||||
this.dateTimeOpen.TabIndex = 9;
|
||||
//
|
||||
// FormShop
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(519, 144);
|
||||
this.ClientSize = new System.Drawing.Size(593, 513);
|
||||
this.Controls.Add(this.dateTimeOpen);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.textBoxAdress);
|
||||
this.Controls.Add(this.labelAdress);
|
||||
this.Controls.Add(this.textBoxName);
|
||||
this.Controls.Add(this.labelName);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.Name = "FormShop";
|
||||
this.Text = "Магазин";
|
||||
this.Load += new System.EventHandler(this.FormShop_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@ -120,5 +183,11 @@
|
||||
private Label labelAdress;
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
private DataGridView dataGridView;
|
||||
private DataGridViewTextBoxColumn id;
|
||||
private DataGridViewTextBoxColumn PizzaName;
|
||||
private DataGridViewTextBoxColumn Count;
|
||||
private Label label1;
|
||||
private DateTimePicker dateTimeOpen;
|
||||
}
|
||||
}
|
@ -45,8 +45,9 @@ namespace PizzeriaView
|
||||
{
|
||||
textBoxName.Text = view.ShopName;
|
||||
textBoxAdress.Text = view.Adress;
|
||||
_openingDate = view.OpeningDate;
|
||||
_ShopPizzas = view.ShopPizzas ?? new Dictionary<int, (IPizzaModel, int)>();
|
||||
dateTimeOpen.Value = view.OpeningDate;
|
||||
_ShopPizzas = view.ShopPizzas ?? new Dictionary<int, (IPizzaModel, int)>();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -57,6 +58,27 @@ namespace PizzeriaView
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка изделий в магазине");
|
||||
try
|
||||
{
|
||||
if (_ShopPizzas != null)
|
||||
{
|
||||
dataGridView.Rows.Clear();
|
||||
foreach (var sr in _ShopPizzas)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { sr.Key, sr.Value.Item1.PizzaName, sr.Value.Item2 });
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки изделий магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||
@ -70,7 +92,6 @@ namespace PizzeriaView
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Сохранение магазина");
|
||||
_openingDate = _openingDate.HasValue? _openingDate : DateTime.Now;
|
||||
try
|
||||
{
|
||||
var model = new ShopBindingModel
|
||||
@ -78,7 +99,7 @@ namespace PizzeriaView
|
||||
Id = _id ?? 0,
|
||||
ShopName = textBoxName.Text,
|
||||
Adress = textBoxAdress.Text,
|
||||
OpeningDate = _openingDate.Value
|
||||
OpeningDate = dateTimeOpen.Value
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
|
@ -57,4 +57,13 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="PizzaName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Count.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
Loading…
Reference in New Issue
Block a user