Лаба 1. Готова.
This commit is contained in:
parent
59b1467ac7
commit
6898b826c6
@ -11,7 +11,7 @@ namespace SushiBarContracts.ViewModels
|
|||||||
public class SushiViewModel : ISushiModel
|
public class SushiViewModel : ISushiModel
|
||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
[DisplayName("Название изделия")]
|
[DisplayName("Название суши")]
|
||||||
public string SushiName { get; set; } = string.Empty;
|
public string SushiName { get; set; } = string.Empty;
|
||||||
[DisplayName("Цена")]
|
[DisplayName("Цена")]
|
||||||
public double Price { get; set; }
|
public double Price { get; set; }
|
||||||
|
1
SushiBar/SushiBarView/FormComponents.Designer.cs
generated
1
SushiBar/SushiBarView/FormComponents.Designer.cs
generated
@ -39,6 +39,7 @@
|
|||||||
// dataGridView
|
// dataGridView
|
||||||
//
|
//
|
||||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
|
dataGridView.BackgroundColor = SystemColors.Window;
|
||||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView.Location = new Point(2, 2);
|
dataGridView.Location = new Point(2, 2);
|
||||||
dataGridView.Name = "dataGridView";
|
dataGridView.Name = "dataGridView";
|
||||||
|
@ -79,6 +79,7 @@
|
|||||||
comboBoxSushi.Name = "comboBoxSushi";
|
comboBoxSushi.Name = "comboBoxSushi";
|
||||||
comboBoxSushi.Size = new Size(276, 23);
|
comboBoxSushi.Size = new Size(276, 23);
|
||||||
comboBoxSushi.TabIndex = 4;
|
comboBoxSushi.TabIndex = 4;
|
||||||
|
comboBoxSushi.SelectedIndexChanged += comboBoxSushi_SelectedIndexChanged;
|
||||||
//
|
//
|
||||||
// textBoxSum
|
// textBoxSum
|
||||||
//
|
//
|
||||||
@ -123,6 +124,7 @@
|
|||||||
Controls.Add(labelSushi);
|
Controls.Add(labelSushi);
|
||||||
Name = "FormCreateOrder";
|
Name = "FormCreateOrder";
|
||||||
Text = "Заказ";
|
Text = "Заказ";
|
||||||
|
Load += FormCreateOrder_Load;
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,9 @@
|
|||||||
using SushiBarContracts.BindingModels;
|
using SushiBarContracts.BindingModels;
|
||||||
using SushiBarContracts.BusinessLogicsContracts;
|
using SushiBarContracts.BusinessLogicsContracts;
|
||||||
using SushiBarContracts.SearchModels;
|
using SushiBarContracts.SearchModels;
|
||||||
|
using SushiBarContracts.ViewModels;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
@ -12,13 +14,19 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
|
||||||
namespace SushiBarView
|
namespace SushiBarView
|
||||||
{
|
{
|
||||||
public partial class FormCreateOrder : Form
|
public partial class FormCreateOrder : Form
|
||||||
{
|
{
|
||||||
|
public FormCreateOrder()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly ISushiLogic _logicP;
|
private readonly ISushiLogic _logicP;
|
||||||
private readonly IOrderLogic _logicO;
|
private readonly IOrderLogic _logicO;
|
||||||
|
private List<SushiViewModel>? _list;
|
||||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, ISushiLogic
|
public FormCreateOrder(ILogger<FormCreateOrder> logger, ISushiLogic
|
||||||
logicP, IOrderLogic logicO)
|
logicP, IOrderLogic logicO)
|
||||||
{
|
{
|
||||||
@ -29,8 +37,16 @@ namespace SushiBarView
|
|||||||
}
|
}
|
||||||
private void FormCreateOrder_Load(object sender, EventArgs e)
|
private void FormCreateOrder_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Загрузка изделий для заказа");
|
_logger.LogInformation("Загрузка суши для заказа");
|
||||||
// прописать логику
|
_list = _logicP.ReadList(null);
|
||||||
|
if (_list != null)
|
||||||
|
{
|
||||||
|
comboBoxSushi.DisplayMember = "SushiName";
|
||||||
|
comboBoxSushi.ValueMember = "Id";
|
||||||
|
comboBoxSushi.DataSource = _list;
|
||||||
|
comboBoxSushi.SelectedItem = null;
|
||||||
|
_logger.LogInformation("Загрузка суши для заказа");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private void CalcSum()
|
private void CalcSum()
|
||||||
{
|
{
|
||||||
@ -40,14 +56,9 @@ namespace SushiBarView
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
int id = Convert.ToInt32(comboBoxSushi.SelectedValue);
|
int id = Convert.ToInt32(comboBoxSushi.SelectedValue);
|
||||||
var product = _logicP.ReadElement(new SushiSearchModel
|
var sushi = _logicP.ReadElement(new SushiSearchModel { Id = id });
|
||||||
{
|
|
||||||
Id
|
|
||||||
= id
|
|
||||||
});
|
|
||||||
int count = Convert.ToInt32(textBoxCount.Text);
|
int count = Convert.ToInt32(textBoxCount.Text);
|
||||||
textBoxSum.Text = Math.Round(count * (product?.Price ?? 0),
|
textBoxSum.Text = Math.Round(count * (sushi?.Price ?? 0), 2).ToString();
|
||||||
2).ToString();
|
|
||||||
_logger.LogInformation("Расчет суммы заказа");
|
_logger.LogInformation("Расчет суммы заказа");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -62,8 +73,7 @@ namespace SushiBarView
|
|||||||
{
|
{
|
||||||
CalcSum();
|
CalcSum();
|
||||||
}
|
}
|
||||||
private void ComboBoxSushi_SelectedIndexChanged(object sender,
|
private void comboBoxSushi_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
EventArgs e)
|
|
||||||
{
|
{
|
||||||
CalcSum();
|
CalcSum();
|
||||||
}
|
}
|
||||||
@ -77,7 +87,7 @@ namespace SushiBarView
|
|||||||
}
|
}
|
||||||
if (comboBoxSushi.SelectedValue == null)
|
if (comboBoxSushi.SelectedValue == null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Выберите изделие", "Ошибка",
|
MessageBox.Show("Выберите суши", "Ошибка",
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
8
SushiBar/SushiBarView/FormMain.Designer.cs
generated
8
SushiBar/SushiBarView/FormMain.Designer.cs
generated
@ -44,6 +44,7 @@
|
|||||||
//
|
//
|
||||||
// dataGridView
|
// dataGridView
|
||||||
//
|
//
|
||||||
|
dataGridView.BackgroundColor = SystemColors.Window;
|
||||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView.Location = new Point(1, 29);
|
dataGridView.Location = new Point(1, 29);
|
||||||
dataGridView.Name = "dataGridView";
|
dataGridView.Name = "dataGridView";
|
||||||
@ -89,6 +90,7 @@
|
|||||||
ButtonIssuedOrder.TabIndex = 4;
|
ButtonIssuedOrder.TabIndex = 4;
|
||||||
ButtonIssuedOrder.Text = "Заказ выдан";
|
ButtonIssuedOrder.Text = "Заказ выдан";
|
||||||
ButtonIssuedOrder.UseVisualStyleBackColor = true;
|
ButtonIssuedOrder.UseVisualStyleBackColor = true;
|
||||||
|
ButtonIssuedOrder.Click += ButtonIssuedOrder_Click;
|
||||||
//
|
//
|
||||||
// ButtonRef
|
// ButtonRef
|
||||||
//
|
//
|
||||||
@ -119,14 +121,14 @@
|
|||||||
// componentsToolStripMenuItem
|
// componentsToolStripMenuItem
|
||||||
//
|
//
|
||||||
componentsToolStripMenuItem.Name = "componentsToolStripMenuItem";
|
componentsToolStripMenuItem.Name = "componentsToolStripMenuItem";
|
||||||
componentsToolStripMenuItem.Size = new Size(180, 22);
|
componentsToolStripMenuItem.Size = new Size(145, 22);
|
||||||
componentsToolStripMenuItem.Text = "Компоненты";
|
componentsToolStripMenuItem.Text = "Компоненты";
|
||||||
componentsToolStripMenuItem.Click += componentsToolStripMenuItem_Click;
|
componentsToolStripMenuItem.Click += componentsToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// sushiToolStripMenuItem
|
// sushiToolStripMenuItem
|
||||||
//
|
//
|
||||||
sushiToolStripMenuItem.Name = "sushiToolStripMenuItem";
|
sushiToolStripMenuItem.Name = "sushiToolStripMenuItem";
|
||||||
sushiToolStripMenuItem.Size = new Size(180, 22);
|
sushiToolStripMenuItem.Size = new Size(145, 22);
|
||||||
sushiToolStripMenuItem.Text = "Суши";
|
sushiToolStripMenuItem.Text = "Суши";
|
||||||
sushiToolStripMenuItem.Click += sushiToolStripMenuItem_Click;
|
sushiToolStripMenuItem.Click += sushiToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
@ -144,7 +146,7 @@
|
|||||||
Controls.Add(menuStrip);
|
Controls.Add(menuStrip);
|
||||||
MainMenuStrip = menuStrip;
|
MainMenuStrip = menuStrip;
|
||||||
Name = "FormMain";
|
Name = "FormMain";
|
||||||
Text = "FormMain";
|
Text = "Суши-бар";
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
menuStrip.ResumeLayout(false);
|
menuStrip.ResumeLayout(false);
|
||||||
menuStrip.PerformLayout();
|
menuStrip.PerformLayout();
|
||||||
|
26
SushiBar/SushiBarView/FormSushi.Designer.cs
generated
26
SushiBar/SushiBarView/FormSushi.Designer.cs
generated
@ -40,9 +40,6 @@
|
|||||||
dataGridView = new DataGridView();
|
dataGridView = new DataGridView();
|
||||||
ButtonSave = new Button();
|
ButtonSave = new Button();
|
||||||
ButtonCancel = new Button();
|
ButtonCancel = new Button();
|
||||||
idColumn = new DataGridViewTextBoxColumn();
|
|
||||||
componentColumn = new DataGridViewTextBoxColumn();
|
|
||||||
countColumn = new DataGridViewTextBoxColumn();
|
|
||||||
groupBoxComponents.SuspendLayout();
|
groupBoxComponents.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
@ -138,8 +135,8 @@
|
|||||||
//
|
//
|
||||||
dataGridView.Anchor = AnchorStyles.Top;
|
dataGridView.Anchor = AnchorStyles.Top;
|
||||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
|
dataGridView.BackgroundColor = SystemColors.Window;
|
||||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView.Columns.AddRange(new DataGridViewColumn[] { idColumn, componentColumn, countColumn });
|
|
||||||
dataGridView.Location = new Point(6, 22);
|
dataGridView.Location = new Point(6, 22);
|
||||||
dataGridView.Name = "dataGridView";
|
dataGridView.Name = "dataGridView";
|
||||||
dataGridView.RowTemplate.Height = 25;
|
dataGridView.RowTemplate.Height = 25;
|
||||||
@ -166,22 +163,6 @@
|
|||||||
ButtonCancel.UseVisualStyleBackColor = true;
|
ButtonCancel.UseVisualStyleBackColor = true;
|
||||||
ButtonCancel.Click += ButtonCancel_Click;
|
ButtonCancel.Click += ButtonCancel_Click;
|
||||||
//
|
//
|
||||||
// idColumn
|
|
||||||
//
|
|
||||||
idColumn.HeaderText = "id";
|
|
||||||
idColumn.Name = "idColumn";
|
|
||||||
idColumn.Visible = false;
|
|
||||||
//
|
|
||||||
// componentColumn
|
|
||||||
//
|
|
||||||
componentColumn.HeaderText = "Компонент";
|
|
||||||
componentColumn.Name = "componentColumn";
|
|
||||||
//
|
|
||||||
// countColumn
|
|
||||||
//
|
|
||||||
countColumn.HeaderText = "Количество";
|
|
||||||
countColumn.Name = "countColumn";
|
|
||||||
//
|
|
||||||
// FormSushi
|
// FormSushi
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
@ -195,7 +176,7 @@
|
|||||||
Controls.Add(labelCost);
|
Controls.Add(labelCost);
|
||||||
Controls.Add(labelName);
|
Controls.Add(labelName);
|
||||||
Name = "FormSushi";
|
Name = "FormSushi";
|
||||||
Text = "FormSushi";
|
Text = "Суши";
|
||||||
groupBoxComponents.ResumeLayout(false);
|
groupBoxComponents.ResumeLayout(false);
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
@ -216,8 +197,5 @@
|
|||||||
private Button ButtonAdd;
|
private Button ButtonAdd;
|
||||||
private Button ButtonSave;
|
private Button ButtonSave;
|
||||||
private Button ButtonCancel;
|
private Button ButtonCancel;
|
||||||
private DataGridViewTextBoxColumn idColumn;
|
|
||||||
private DataGridViewTextBoxColumn componentColumn;
|
|
||||||
private DataGridViewTextBoxColumn countColumn;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -20,39 +20,60 @@ namespace SushiBarView
|
|||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly ISushiLogic _logic;
|
private readonly ISushiLogic _logic;
|
||||||
private int? _id;
|
private int? _id;
|
||||||
private Dictionary<int, (IComponentModel, int)> _productComponents;
|
private Dictionary<int, (IComponentModel, int)> _sushiComponents;
|
||||||
public int Id { set { _id = value; } }
|
public int Id { set { _id = value; } }
|
||||||
|
public FormSushi()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
public FormSushi(ILogger<FormSushi> logger, ISushiLogic logic)
|
public FormSushi(ILogger<FormSushi> logger, ISushiLogic logic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logic = logic;
|
_logic = logic;
|
||||||
_productComponents = new Dictionary<int, (IComponentModel, int)>();
|
_sushiComponents = new Dictionary<int, (IComponentModel, int)>();
|
||||||
}
|
}
|
||||||
private void FormSushi_Load(object sender, EventArgs e)
|
private void FormSushi_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
var list = _logic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView.AllowUserToAddRows = false;
|
||||||
|
DataGridViewTextBoxColumn Id = new DataGridViewTextBoxColumn();
|
||||||
|
DataGridViewTextBoxColumn Component = new DataGridViewTextBoxColumn();
|
||||||
|
DataGridViewTextBoxColumn Number = new DataGridViewTextBoxColumn();
|
||||||
|
Component.HeaderText = "Количество";
|
||||||
|
Number.HeaderText = "Компонент";
|
||||||
|
Number.Name = "Number";
|
||||||
|
Id.Name = "Id";
|
||||||
|
dataGridView.Columns.Add(Id);
|
||||||
|
dataGridView.Columns.Add(Number);
|
||||||
|
dataGridView.Columns.Add(Component);
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
|
||||||
|
dataGridView.Columns["Number"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
}
|
||||||
if (_id.HasValue)
|
if (_id.HasValue)
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Загрузка изделия");
|
_logger.LogInformation("Загрузка суши");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var view = _logic.ReadElement(new SushiSearchModel
|
var view = _logic.ReadElement(new SushiSearchModel
|
||||||
{
|
{
|
||||||
Id =
|
Id = _id.Value
|
||||||
_id.Value
|
|
||||||
});
|
});
|
||||||
if (view != null)
|
if (view != null)
|
||||||
{
|
{
|
||||||
textBoxName.Text = view.SushiName;
|
textBoxName.Text = view.SushiName;
|
||||||
textBoxPrice.Text = view.Price.ToString();
|
textBoxPrice.Text = view.Price.ToString();
|
||||||
_productComponents = view.SushiComponents ?? new
|
_sushiComponents = view.SushiComponents ?? new
|
||||||
Dictionary<int, (IComponentModel, int)>();
|
Dictionary<int, (IComponentModel, int)>();
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка загрузки изделия");
|
_logger.LogError(ex, "Ошибка загрузки суши");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||||
MessageBoxIcon.Error);
|
MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
@ -60,13 +81,13 @@ namespace SushiBarView
|
|||||||
}
|
}
|
||||||
private void LoadData()
|
private void LoadData()
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Загрузка компонент изделия");
|
_logger.LogInformation("Загрузка компонент суши");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (_productComponents != null)
|
if (_sushiComponents != null)
|
||||||
{
|
{
|
||||||
dataGridView.Rows.Clear();
|
dataGridView.Rows.Clear();
|
||||||
foreach (var pc in _productComponents)
|
foreach (var pc in _sushiComponents)
|
||||||
{
|
{
|
||||||
dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 });
|
dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 });
|
||||||
}
|
}
|
||||||
@ -75,7 +96,7 @@ namespace SushiBarView
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка загрузки компонент изделия");
|
_logger.LogError(ex, "Ошибка загрузки компонент суши");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||||
MessageBoxIcon.Error);
|
MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
@ -93,14 +114,14 @@ namespace SushiBarView
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Добавление нового компонента: { ComponentName}- { Count}", form.ComponentModel.ComponentName, form.Count);
|
_logger.LogInformation("Добавление нового компонента: { ComponentName}- { Count}", form.ComponentModel.ComponentName, form.Count);
|
||||||
if (_productComponents.ContainsKey(form.Id))
|
if (_sushiComponents.ContainsKey(form.Id))
|
||||||
{
|
{
|
||||||
_productComponents[form.Id] = (form.ComponentModel,
|
_sushiComponents[form.Id] = (form.ComponentModel,
|
||||||
form.Count);
|
form.Count);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_productComponents.Add(form.Id, (form.ComponentModel,
|
_sushiComponents.Add(form.Id, (form.ComponentModel,
|
||||||
form.Count));
|
form.Count));
|
||||||
}
|
}
|
||||||
LoadData();
|
LoadData();
|
||||||
@ -118,7 +139,7 @@ namespace SushiBarView
|
|||||||
int id =
|
int id =
|
||||||
Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||||
form.Id = id;
|
form.Id = id;
|
||||||
form.Count = _productComponents[id].Item2;
|
form.Count = _sushiComponents[id].Item2;
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
if (form.ComponentModel == null)
|
if (form.ComponentModel == null)
|
||||||
@ -126,7 +147,7 @@ namespace SushiBarView
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Изменение компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
|
_logger.LogInformation("Изменение компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
|
||||||
_productComponents[form.Id] = (form.ComponentModel, form.Count);
|
_sushiComponents[form.Id] = (form.ComponentModel, form.Count);
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -141,7 +162,7 @@ namespace SushiBarView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_logger.LogInformation("Удаление компонента: { ComponentName} - { Count}", dataGridView.SelectedRows[0].Cells[1].Value); _productComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
|
_logger.LogInformation("Удаление компонента: { ComponentName} - { Count}", dataGridView.SelectedRows[0].Cells[1].Value); _sushiComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -170,13 +191,13 @@ namespace SushiBarView
|
|||||||
MessageBoxIcon.Error);
|
MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (_productComponents == null || _productComponents.Count == 0)
|
if (_sushiComponents == null || _sushiComponents.Count == 0)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Заполните компоненты", "Ошибка",
|
MessageBox.Show("Заполните компоненты", "Ошибка",
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Сохранение изделия");
|
_logger.LogInformation("Сохранение суши");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var model = new SushiBindingModel
|
var model = new SushiBindingModel
|
||||||
@ -184,7 +205,7 @@ namespace SushiBarView
|
|||||||
Id = _id ?? 0,
|
Id = _id ?? 0,
|
||||||
SushiName = textBoxName.Text,
|
SushiName = textBoxName.Text,
|
||||||
Price = Convert.ToDouble(textBoxPrice.Text),
|
Price = Convert.ToDouble(textBoxPrice.Text),
|
||||||
SushiComponents = _productComponents
|
SushiComponents = _sushiComponents
|
||||||
};
|
};
|
||||||
var operationResult = _id.HasValue ? _logic.Update(model) :
|
var operationResult = _id.HasValue ? _logic.Update(model) :
|
||||||
_logic.Create(model);
|
_logic.Create(model);
|
||||||
@ -199,7 +220,7 @@ namespace SushiBarView
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.LogError(ex, "Ошибка сохранения изделия");
|
_logger.LogError(ex, "Ошибка сохранения суши");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -211,7 +232,7 @@ namespace SushiBarView
|
|||||||
private double CalcPrice()
|
private double CalcPrice()
|
||||||
{
|
{
|
||||||
double price = 0;
|
double price = 0;
|
||||||
foreach (var elem in _productComponents)
|
foreach (var elem in _sushiComponents)
|
||||||
{
|
{
|
||||||
price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
|
price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
|
||||||
}
|
}
|
||||||
|
@ -117,13 +117,4 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<metadata name="idColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="componentColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="countColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
</root>
|
@ -101,7 +101,7 @@
|
|||||||
Controls.Add(labelCount);
|
Controls.Add(labelCount);
|
||||||
Controls.Add(labelComponent);
|
Controls.Add(labelComponent);
|
||||||
Name = "FormSushiComponent";
|
Name = "FormSushiComponent";
|
||||||
Text = "Компонент изделия";
|
Text = "Компонент суши";
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
3
SushiBar/SushiBarView/FormSushis.Designer.cs
generated
3
SushiBar/SushiBarView/FormSushis.Designer.cs
generated
@ -38,6 +38,7 @@
|
|||||||
//
|
//
|
||||||
// dataGridView
|
// dataGridView
|
||||||
//
|
//
|
||||||
|
dataGridView.BackgroundColor = SystemColors.Window;
|
||||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView.Location = new Point(12, 12);
|
dataGridView.Location = new Point(12, 12);
|
||||||
dataGridView.Name = "dataGridView";
|
dataGridView.Name = "dataGridView";
|
||||||
@ -96,7 +97,7 @@
|
|||||||
Controls.Add(ButtonAdd);
|
Controls.Add(ButtonAdd);
|
||||||
Controls.Add(dataGridView);
|
Controls.Add(dataGridView);
|
||||||
Name = "FormSushis";
|
Name = "FormSushis";
|
||||||
Text = "FormSushis";
|
Text = "Суши";
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<configuration>
|
<configuration>
|
||||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
autoReload="true" internalLogLevel="Info">
|
autoReload="true" internalLogLevel="Info">
|
||||||
|
|
||||||
<targets>
|
<targets>
|
||||||
<target xsi:type="File" name="tofile" fileName="log-${shortdate}.log" />
|
<target xsi:type="File" name="tofile" fileName="log-${shortdate}.log" />
|
||||||
</targets>
|
</targets>
|
||||||
|
|
||||||
<rules>
|
<rules>
|
||||||
<logger name="*" minlevel="Debug" writeTo="tofile" />
|
<logger name="*" minlevel="Debug" writeTo="tofile" />
|
||||||
</rules>
|
</rules>
|
||||||
</nlog>
|
</nlog>
|
||||||
</configuration>
|
</configuration>
|
Loading…
Reference in New Issue
Block a user