обновил формы
This commit is contained in:
parent
2fb30acd26
commit
a2d340d325
245
SushiBar/SushiBarView/FormCreateOrder.Designer.cs
generated
245
SushiBar/SushiBarView/FormCreateOrder.Designer.cs
generated
@ -20,119 +20,140 @@
|
|||||||
base.Dispose(disposing);
|
base.Dispose(disposing);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required method for Designer support - do not modify
|
/// Required method for Designer support - do not modify
|
||||||
/// the contents of this method with the code editor.
|
/// the contents of this method with the code editor.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
labelSushi = new Label();
|
labelSushi = new Label();
|
||||||
labelCount = new Label();
|
labelCount = new Label();
|
||||||
labelSum = new Label();
|
labelSum = new Label();
|
||||||
textBoxCount = new TextBox();
|
textBoxCount = new TextBox();
|
||||||
comboBoxSushi = new ComboBox();
|
comboBoxSushi = new ComboBox();
|
||||||
textBoxSum = new TextBox();
|
textBoxSum = new TextBox();
|
||||||
ButtonSave = new Button();
|
ButtonSave = new Button();
|
||||||
ButtonCancel = new Button();
|
ButtonCancel = new Button();
|
||||||
SuspendLayout();
|
comboBoxUser = new ComboBox();
|
||||||
//
|
labelUser = new Label();
|
||||||
// labelSushi
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
labelSushi.AutoSize = true;
|
// labelSushi
|
||||||
labelSushi.Location = new Point(42, 27);
|
//
|
||||||
labelSushi.Name = "labelSushi";
|
labelSushi.AutoSize = true;
|
||||||
labelSushi.Size = new Size(42, 15);
|
labelSushi.Location = new Point(33, 66);
|
||||||
labelSushi.TabIndex = 0;
|
labelSushi.Name = "labelSushi";
|
||||||
labelSushi.Text = "Суши:";
|
labelSushi.Size = new Size(42, 15);
|
||||||
//
|
labelSushi.TabIndex = 0;
|
||||||
// labelCount
|
labelSushi.Text = "Суши:";
|
||||||
//
|
//
|
||||||
labelCount.AutoSize = true;
|
// labelCount
|
||||||
labelCount.Location = new Point(42, 56);
|
//
|
||||||
labelCount.Name = "labelCount";
|
labelCount.AutoSize = true;
|
||||||
labelCount.Size = new Size(75, 15);
|
labelCount.Location = new Point(33, 95);
|
||||||
labelCount.TabIndex = 1;
|
labelCount.Name = "labelCount";
|
||||||
labelCount.Text = "Количество:";
|
labelCount.Size = new Size(75, 15);
|
||||||
//
|
labelCount.TabIndex = 1;
|
||||||
// labelSum
|
labelCount.Text = "Количество:";
|
||||||
//
|
//
|
||||||
labelSum.AutoSize = true;
|
// labelSum
|
||||||
labelSum.Location = new Point(42, 84);
|
//
|
||||||
labelSum.Name = "labelSum";
|
labelSum.AutoSize = true;
|
||||||
labelSum.Size = new Size(48, 15);
|
labelSum.Location = new Point(33, 124);
|
||||||
labelSum.TabIndex = 2;
|
labelSum.Name = "labelSum";
|
||||||
labelSum.Text = "Сумма:";
|
labelSum.Size = new Size(48, 15);
|
||||||
//
|
labelSum.TabIndex = 2;
|
||||||
// textBoxCount
|
labelSum.Text = "Сумма:";
|
||||||
//
|
//
|
||||||
textBoxCount.Location = new Point(123, 53);
|
// textBoxCount
|
||||||
textBoxCount.Name = "textBoxCount";
|
//
|
||||||
textBoxCount.Size = new Size(276, 23);
|
textBoxCount.Location = new Point(123, 95);
|
||||||
textBoxCount.TabIndex = 3;
|
textBoxCount.Name = "textBoxCount";
|
||||||
this.textBoxCount.TextChanged += new System.EventHandler(this.textBoxCost_TextChanged);
|
textBoxCount.Size = new Size(276, 23);
|
||||||
//
|
textBoxCount.TabIndex = 3;
|
||||||
// comboBoxSushi
|
textBoxCount.TextChanged += textBoxCost_TextChanged;
|
||||||
//
|
//
|
||||||
comboBoxSushi.FormattingEnabled = true;
|
// comboBoxSushi
|
||||||
comboBoxSushi.Location = new Point(123, 24);
|
//
|
||||||
comboBoxSushi.Name = "comboBoxSushi";
|
comboBoxSushi.FormattingEnabled = true;
|
||||||
comboBoxSushi.Size = new Size(276, 23);
|
comboBoxSushi.Location = new Point(123, 66);
|
||||||
comboBoxSushi.TabIndex = 4;
|
comboBoxSushi.Name = "comboBoxSushi";
|
||||||
comboBoxSushi.SelectedIndexChanged += comboBoxSushi_SelectedIndexChanged;
|
comboBoxSushi.Size = new Size(276, 23);
|
||||||
//
|
comboBoxSushi.TabIndex = 4;
|
||||||
// textBoxSum
|
comboBoxSushi.SelectedIndexChanged += comboBoxSushi_SelectedIndexChanged;
|
||||||
//
|
//
|
||||||
textBoxSum.Location = new Point(123, 84);
|
// textBoxSum
|
||||||
textBoxSum.Name = "textBoxSum";
|
//
|
||||||
textBoxSum.ReadOnly = true;
|
textBoxSum.Location = new Point(123, 124);
|
||||||
textBoxSum.Size = new Size(276, 23);
|
textBoxSum.Name = "textBoxSum";
|
||||||
textBoxSum.TabIndex = 5;
|
textBoxSum.ReadOnly = true;
|
||||||
//
|
textBoxSum.Size = new Size(276, 23);
|
||||||
// ButtonSave
|
textBoxSum.TabIndex = 5;
|
||||||
//
|
//
|
||||||
ButtonSave.Location = new Point(192, 124);
|
// ButtonSave
|
||||||
ButtonSave.Name = "ButtonSave";
|
//
|
||||||
ButtonSave.Size = new Size(98, 41);
|
ButtonSave.Location = new Point(197, 168);
|
||||||
ButtonSave.TabIndex = 6;
|
ButtonSave.Name = "ButtonSave";
|
||||||
ButtonSave.Text = "Сохранить";
|
ButtonSave.Size = new Size(98, 41);
|
||||||
ButtonSave.UseVisualStyleBackColor = true;
|
ButtonSave.TabIndex = 6;
|
||||||
ButtonSave.Click += ButtonSave_Click;
|
ButtonSave.Text = "Сохранить";
|
||||||
//
|
ButtonSave.UseVisualStyleBackColor = true;
|
||||||
// ButtonCancel
|
ButtonSave.Click += ButtonSave_Click;
|
||||||
//
|
//
|
||||||
ButtonCancel.Location = new Point(296, 124);
|
// ButtonCancel
|
||||||
ButtonCancel.Name = "ButtonCancel";
|
//
|
||||||
ButtonCancel.Size = new Size(98, 41);
|
ButtonCancel.Location = new Point(301, 168);
|
||||||
ButtonCancel.TabIndex = 7;
|
ButtonCancel.Name = "ButtonCancel";
|
||||||
ButtonCancel.Text = "Отмена";
|
ButtonCancel.Size = new Size(98, 41);
|
||||||
ButtonCancel.UseVisualStyleBackColor = true;
|
ButtonCancel.TabIndex = 7;
|
||||||
ButtonCancel.Click += ButtonCancel_Click;
|
ButtonCancel.Text = "Отмена";
|
||||||
//
|
ButtonCancel.UseVisualStyleBackColor = true;
|
||||||
// FormCreateOrder
|
ButtonCancel.Click += ButtonCancel_Click;
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
// comboBoxUser
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
//
|
||||||
ClientSize = new Size(411, 177);
|
comboBoxUser.FormattingEnabled = true;
|
||||||
Controls.Add(ButtonCancel);
|
comboBoxUser.Location = new Point(123, 37);
|
||||||
Controls.Add(ButtonSave);
|
comboBoxUser.Name = "comboBoxUser";
|
||||||
Controls.Add(textBoxSum);
|
comboBoxUser.Size = new Size(276, 23);
|
||||||
Controls.Add(comboBoxSushi);
|
comboBoxUser.TabIndex = 8;
|
||||||
Controls.Add(textBoxCount);
|
//
|
||||||
Controls.Add(labelSum);
|
// labelUser
|
||||||
Controls.Add(labelCount);
|
//
|
||||||
Controls.Add(labelSushi);
|
labelUser.AutoSize = true;
|
||||||
Name = "FormCreateOrder";
|
labelUser.Location = new Point(33, 40);
|
||||||
Text = "Заказ";
|
labelUser.Name = "labelUser";
|
||||||
Load += FormCreateOrder_Load;
|
labelUser.Size = new Size(87, 15);
|
||||||
ResumeLayout(false);
|
labelUser.TabIndex = 9;
|
||||||
PerformLayout();
|
labelUser.Text = "Пользователь:";
|
||||||
}
|
//
|
||||||
|
// FormCreateOrder
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(411, 217);
|
||||||
|
Controls.Add(labelUser);
|
||||||
|
Controls.Add(comboBoxUser);
|
||||||
|
Controls.Add(ButtonCancel);
|
||||||
|
Controls.Add(ButtonSave);
|
||||||
|
Controls.Add(textBoxSum);
|
||||||
|
Controls.Add(comboBoxSushi);
|
||||||
|
Controls.Add(textBoxCount);
|
||||||
|
Controls.Add(labelSum);
|
||||||
|
Controls.Add(labelCount);
|
||||||
|
Controls.Add(labelSushi);
|
||||||
|
Name = "FormCreateOrder";
|
||||||
|
Text = "Заказ";
|
||||||
|
Load += FormCreateOrder_Load;
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private Label labelSushi;
|
private Label labelSushi;
|
||||||
private Label labelCount;
|
private Label labelCount;
|
||||||
private Label labelSum;
|
private Label labelSum;
|
||||||
private TextBox textBoxCount;
|
private TextBox textBoxCount;
|
||||||
@ -140,5 +161,7 @@
|
|||||||
private TextBox textBoxSum;
|
private TextBox textBoxSum;
|
||||||
private Button ButtonSave;
|
private Button ButtonSave;
|
||||||
private Button ButtonCancel;
|
private Button ButtonCancel;
|
||||||
}
|
private ComboBox comboBoxUser;
|
||||||
|
private Label labelUser;
|
||||||
|
}
|
||||||
}
|
}
|
@ -16,113 +16,126 @@ using System.Windows.Forms;
|
|||||||
|
|
||||||
namespace SushiBarView
|
namespace SushiBarView
|
||||||
{
|
{
|
||||||
public partial class FormCreateOrder : Form
|
public partial class FormCreateOrder : Form
|
||||||
{
|
{
|
||||||
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;
|
private readonly IClientLogic _logicC;
|
||||||
|
private List<SushiViewModel>? _list;
|
||||||
|
private List<ClientViewModel>? _listClients;
|
||||||
|
|
||||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, ISushiLogic logicP, IOrderLogic logicO)
|
public FormCreateOrder(ILogger<FormCreateOrder> logger, ISushiLogic logicP, IOrderLogic logicO, IClientLogic logicC)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logicP = logicP;
|
_logicP = logicP;
|
||||||
_logicO = logicO;
|
_logicO = logicO;
|
||||||
}
|
_logicC = logicC;
|
||||||
private void FormCreateOrder_Load(object sender, EventArgs e)
|
}
|
||||||
{
|
private void FormCreateOrder_Load(object sender, EventArgs e)
|
||||||
_logger.LogInformation("Загрузка суши для заказа");
|
{
|
||||||
_list = _logicP.ReadList(null);
|
_logger.LogInformation("Загрузка суши для заказа");
|
||||||
if (_list != null)
|
_list = _logicP.ReadList(null);
|
||||||
{
|
if (_list != null)
|
||||||
comboBoxSushi.DisplayMember = "SushiName";
|
{
|
||||||
comboBoxSushi.ValueMember = "Id";
|
comboBoxSushi.DisplayMember = "SushiName";
|
||||||
comboBoxSushi.DataSource = _list;
|
comboBoxSushi.ValueMember = "Id";
|
||||||
comboBoxSushi.SelectedItem = null;
|
comboBoxSushi.DataSource = _list;
|
||||||
_logger.LogInformation("Загрузка суши для заказа");
|
comboBoxSushi.SelectedItem = null;
|
||||||
}
|
_logger.LogInformation("Загрузка суши для заказа");
|
||||||
}
|
}
|
||||||
private void ButtonSave_Click(object sender, EventArgs e)
|
_listClients = _logicC.ReadList(null);
|
||||||
{
|
if (_listClients != null)
|
||||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
{
|
||||||
{
|
comboBoxUser.DisplayMember = "ClientFIO";
|
||||||
MessageBox.Show("Заполните поле Количество", "Ошибка",
|
comboBoxUser.ValueMember = "Id";
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
comboBoxUser.DataSource = _listClients;
|
||||||
return;
|
comboBoxUser.SelectedItem = null;
|
||||||
}
|
_logger.LogInformation("Загрузка клиентов для заказа");
|
||||||
if (comboBoxSushi.SelectedValue == null)
|
}
|
||||||
{
|
|
||||||
MessageBox.Show("Выберите суши", "Ошибка",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_logger.LogInformation("Создание заказа");
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
|
||||||
{
|
|
||||||
SushiId = Convert.ToInt32(comboBoxSushi.SelectedValue),
|
|
||||||
Count = Convert.ToInt32(textBoxCount.Text),
|
|
||||||
Sum = Convert.ToDouble(textBoxSum.Text)
|
|
||||||
});
|
|
||||||
if (!operationResult)
|
|
||||||
{
|
|
||||||
throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах.");
|
|
||||||
}
|
|
||||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
||||||
DialogResult = DialogResult.OK;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
_logger.LogError(ex, "Ошибка создания заказа");
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
|
||||||
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)
|
}
|
||||||
{
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
CalcSum();
|
{
|
||||||
}
|
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните поле Количество", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (comboBoxSushi.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите суши", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Создание заказа");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
||||||
|
{
|
||||||
|
SushiId = Convert.ToInt32(comboBoxSushi.SelectedValue),
|
||||||
|
Count = Convert.ToInt32(textBoxCount.Text),
|
||||||
|
Sum = Convert.ToDouble(textBoxSum.Text)
|
||||||
|
});
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Ошибка создания заказа");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||||
|
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 textBoxCost_TextChanged(object sender, EventArgs e)
|
private void comboBoxSushi_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
CalcSum();
|
CalcSum();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
private void textBoxCost_TextChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
DialogResult = DialogResult.Cancel;
|
CalcSum();
|
||||||
Close();
|
}
|
||||||
}
|
|
||||||
}
|
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
2
SushiBar/SushiBarView/FormMain.Designer.cs
generated
2
SushiBar/SushiBarView/FormMain.Designer.cs
generated
@ -169,7 +169,7 @@
|
|||||||
clientToolStripMenuItem.Name = "clientToolStripMenuItem";
|
clientToolStripMenuItem.Name = "clientToolStripMenuItem";
|
||||||
clientToolStripMenuItem.Size = new Size(180, 22);
|
clientToolStripMenuItem.Size = new Size(180, 22);
|
||||||
clientToolStripMenuItem.Text = "Клиент";
|
clientToolStripMenuItem.Text = "Клиент";
|
||||||
clientToolStripMenuItem.Click += клиентToolStripMenuItem_Click;
|
clientToolStripMenuItem.Click += clientToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
|
@ -51,7 +51,8 @@ namespace SushiBarView
|
|||||||
services.AddTransient<FormSushi>();
|
services.AddTransient<FormSushi>();
|
||||||
services.AddTransient<FormReportOrders>();
|
services.AddTransient<FormReportOrders>();
|
||||||
services.AddTransient<FormReportSushiComponents>();
|
services.AddTransient<FormReportSushiComponents>();
|
||||||
services.AddTransient<IReportLogic, ReportLogic>();
|
services.AddTransient<FormClients>();
|
||||||
|
services.AddTransient<IReportLogic, ReportLogic>();
|
||||||
|
|
||||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||||
|
Loading…
Reference in New Issue
Block a user