Последний фикс.
This commit is contained in:
parent
46bf657b83
commit
f910c279a7
@ -71,6 +71,7 @@
|
||||
textBoxCount.Name = "textBoxCount";
|
||||
textBoxCount.Size = new Size(276, 23);
|
||||
textBoxCount.TabIndex = 3;
|
||||
this.textBoxCount.TextChanged += new System.EventHandler(this.textBoxCost_TextChanged);
|
||||
//
|
||||
// comboBoxSushi
|
||||
//
|
||||
|
@ -14,7 +14,6 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
|
||||
namespace SushiBarView
|
||||
{
|
||||
public partial class FormCreateOrder : Form
|
||||
@ -23,8 +22,11 @@ namespace SushiBarView
|
||||
private readonly ISushiLogic _logicP;
|
||||
private readonly IOrderLogic _logicO;
|
||||
private List<SushiViewModel>? _list;
|
||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, ISushiLogic
|
||||
logicP, IOrderLogic logicO)
|
||||
public FormCreateOrder()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, ISushiLogic logicP, IOrderLogic logicO)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
@ -33,7 +35,7 @@ namespace SushiBarView
|
||||
}
|
||||
private void FormCreateOrder_Load(object sender, EventArgs e)
|
||||
{
|
||||
_logger.LogInformation("Загрузка суши для заказа");
|
||||
_logger.LogInformation("Загрузка изделий для заказа");
|
||||
_list = _logicP.ReadList(null);
|
||||
if (_list != null)
|
||||
{
|
||||
@ -44,35 +46,6 @@ namespace SushiBarView
|
||||
_logger.LogInformation("Загрузка суши для заказа");
|
||||
}
|
||||
}
|
||||
private void CalcSum()
|
||||
{
|
||||
if (comboBoxSushi.SelectedValue != null &&
|
||||
!string.IsNullOrEmpty(textBoxCount.Text))
|
||||
{
|
||||
try
|
||||
{
|
||||
int id = Convert.ToInt32(comboBoxSushi.SelectedValue);
|
||||
var sushi = _logicP.ReadElement(new SushiSearchModel { Id = id });
|
||||
int count = Convert.ToInt32(textBoxCount.Text);
|
||||
textBoxSum.Text = Math.Round(count * (sushi?.Price ?? 0), 2).ToString();
|
||||
_logger.LogInformation("Расчет суммы заказа");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка расчета суммы заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void comboBoxSushi_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
CalcSum();
|
||||
}
|
||||
private void TextBoxCount_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
CalcSum();
|
||||
}
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||
@ -83,7 +56,7 @@ namespace SushiBarView
|
||||
}
|
||||
if (comboBoxSushi.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите суши", "Ошибка",
|
||||
MessageBox.Show("Выберите изделие", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
@ -112,10 +85,47 @@ namespace SushiBarView
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void CalcSum()
|
||||
{
|
||||
if (comboBoxSushi.SelectedValue != null &&
|
||||
!string.IsNullOrEmpty(textBoxCount.Text))
|
||||
{
|
||||
try
|
||||
{
|
||||
int id = Convert.ToInt32(comboBoxSushi.SelectedValue);
|
||||
var sushi = _logicP.ReadElement(new SushiSearchModel
|
||||
{
|
||||
Id
|
||||
= id
|
||||
});
|
||||
int count = Convert.ToInt32(textBoxCount.Text);
|
||||
textBoxSum.Text = Math.Round(count * (sushi?.Price ?? 0),
|
||||
2).ToString();
|
||||
_logger.LogInformation("Расчет суммы заказа");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка расчета суммы заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBoxSushi_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
CalcSum();
|
||||
}
|
||||
|
||||
private void textBoxCost_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
CalcSum();
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
16
SushiBar/SushiBarView/FormMain.Designer.cs
generated
16
SushiBar/SushiBarView/FormMain.Designer.cs
generated
@ -49,12 +49,12 @@
|
||||
dataGridView.Location = new Point(1, 29);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowTemplate.Height = 25;
|
||||
dataGridView.Size = new Size(608, 307);
|
||||
dataGridView.Size = new Size(1080, 307);
|
||||
dataGridView.TabIndex = 0;
|
||||
//
|
||||
// ButtonCreateOrder
|
||||
//
|
||||
ButtonCreateOrder.Location = new Point(641, 38);
|
||||
ButtonCreateOrder.Location = new Point(1087, 41);
|
||||
ButtonCreateOrder.Name = "ButtonCreateOrder";
|
||||
ButtonCreateOrder.Size = new Size(147, 33);
|
||||
ButtonCreateOrder.TabIndex = 1;
|
||||
@ -64,7 +64,7 @@
|
||||
//
|
||||
// ButtonTakeOrderInWork
|
||||
//
|
||||
ButtonTakeOrderInWork.Location = new Point(641, 86);
|
||||
ButtonTakeOrderInWork.Location = new Point(1087, 80);
|
||||
ButtonTakeOrderInWork.Name = "ButtonTakeOrderInWork";
|
||||
ButtonTakeOrderInWork.Size = new Size(147, 33);
|
||||
ButtonTakeOrderInWork.TabIndex = 2;
|
||||
@ -74,7 +74,7 @@
|
||||
//
|
||||
// ButtonOrderReady
|
||||
//
|
||||
ButtonOrderReady.Location = new Point(641, 135);
|
||||
ButtonOrderReady.Location = new Point(1087, 119);
|
||||
ButtonOrderReady.Name = "ButtonOrderReady";
|
||||
ButtonOrderReady.Size = new Size(147, 33);
|
||||
ButtonOrderReady.TabIndex = 3;
|
||||
@ -84,7 +84,7 @@
|
||||
//
|
||||
// ButtonIssuedOrder
|
||||
//
|
||||
ButtonIssuedOrder.Location = new Point(641, 184);
|
||||
ButtonIssuedOrder.Location = new Point(1087, 158);
|
||||
ButtonIssuedOrder.Name = "ButtonIssuedOrder";
|
||||
ButtonIssuedOrder.Size = new Size(147, 33);
|
||||
ButtonIssuedOrder.TabIndex = 4;
|
||||
@ -94,7 +94,7 @@
|
||||
//
|
||||
// ButtonRef
|
||||
//
|
||||
ButtonRef.Location = new Point(641, 232);
|
||||
ButtonRef.Location = new Point(1087, 197);
|
||||
ButtonRef.Name = "ButtonRef";
|
||||
ButtonRef.Size = new Size(147, 33);
|
||||
ButtonRef.TabIndex = 5;
|
||||
@ -107,7 +107,7 @@
|
||||
menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem });
|
||||
menuStrip.Location = new Point(0, 0);
|
||||
menuStrip.Name = "menuStrip";
|
||||
menuStrip.Size = new Size(800, 24);
|
||||
menuStrip.Size = new Size(1265, 24);
|
||||
menuStrip.TabIndex = 6;
|
||||
menuStrip.Text = "menuStrip1";
|
||||
//
|
||||
@ -136,7 +136,7 @@
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 337);
|
||||
ClientSize = new Size(1265, 337);
|
||||
Controls.Add(ButtonRef);
|
||||
Controls.Add(ButtonIssuedOrder);
|
||||
Controls.Add(ButtonOrderReady);
|
||||
|
@ -39,6 +39,8 @@ namespace SushiBarView
|
||||
dataGridView.Columns["SushiId"].Visible = false;
|
||||
dataGridView.Columns["SushiName"].AutoSizeMode =
|
||||
DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
|
||||
}
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user