Завершение проверки корректности кода.
This commit is contained in:
parent
5d37351d22
commit
e5a9b72a76
@ -18,16 +18,16 @@ namespace BlacksmithWorkshop
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IManufactureLogic _logicA;
|
||||
private readonly IManufactureLogic _logicM;
|
||||
|
||||
private readonly IOrderLogic _logicO;
|
||||
|
||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, IManufactureLogic logicA, IOrderLogic logicO)
|
||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, IManufactureLogic logicM, IOrderLogic logicO)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = logger;
|
||||
_logicA = logicA;
|
||||
_logicM = logicM;
|
||||
_logicO = logicO;
|
||||
}
|
||||
|
||||
@ -46,12 +46,13 @@ namespace BlacksmithWorkshop
|
||||
{
|
||||
int id = Convert.ToInt32(comboBoxManufacture.SelectedValue);
|
||||
|
||||
var manufacture = _logicA.ReadElement(new ManufactureSearchModel
|
||||
var manufacture = _logicM.ReadElement(new ManufactureSearchModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
|
||||
int count = Convert.ToInt32(textBoxCount.Text);
|
||||
|
||||
textBoxSum.Text = Math.Round(count * (manufacture?.Price ?? 0), 2).ToString();
|
||||
|
||||
_logger.LogInformation("Расчет суммы заказа");
|
||||
@ -64,12 +65,12 @@ namespace BlacksmithWorkshop
|
||||
}
|
||||
}
|
||||
|
||||
private void ComboBoxManufacture_SelectedIndexChanged(object sender, EventArgs e)
|
||||
private void TextBoxCount_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
CalcSum();
|
||||
}
|
||||
|
||||
private void TextBoxCount_TextChanged(object sender, EventArgs e)
|
||||
private void ComboBoxManufacture_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
CalcSum();
|
||||
}
|
||||
@ -78,16 +79,14 @@ namespace BlacksmithWorkshop
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните поле Количество", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (comboBoxManufacture.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите изделие", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -108,8 +107,7 @@ namespace BlacksmithWorkshop
|
||||
throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
|
||||
Close();
|
||||
|
@ -31,7 +31,7 @@
|
||||
this.labelName = new System.Windows.Forms.Label();
|
||||
this.labelCost = new System.Windows.Forms.Label();
|
||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||
this.textBoxCost = new System.Windows.Forms.TextBox();
|
||||
this.textBoxPrice = new System.Windows.Forms.TextBox();
|
||||
this.groupBoxWorkPiece = new System.Windows.Forms.GroupBox();
|
||||
this.buttonRef = new System.Windows.Forms.Button();
|
||||
this.buttonDel = new System.Windows.Forms.Button();
|
||||
@ -71,12 +71,12 @@
|
||||
this.textBoxName.Size = new System.Drawing.Size(332, 27);
|
||||
this.textBoxName.TabIndex = 2;
|
||||
//
|
||||
// textBoxCost
|
||||
// textBoxPrice
|
||||
//
|
||||
this.textBoxCost.Location = new System.Drawing.Point(133, 81);
|
||||
this.textBoxCost.Name = "textBoxCost";
|
||||
this.textBoxCost.Size = new System.Drawing.Size(196, 27);
|
||||
this.textBoxCost.TabIndex = 3;
|
||||
this.textBoxPrice.Location = new System.Drawing.Point(133, 81);
|
||||
this.textBoxPrice.Name = "textBoxPrice";
|
||||
this.textBoxPrice.Size = new System.Drawing.Size(196, 27);
|
||||
this.textBoxPrice.TabIndex = 3;
|
||||
//
|
||||
// groupBoxWorkPiece
|
||||
//
|
||||
@ -187,7 +187,7 @@
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.groupBoxWorkPiece);
|
||||
this.Controls.Add(this.textBoxCost);
|
||||
this.Controls.Add(this.textBoxPrice);
|
||||
this.Controls.Add(this.textBoxName);
|
||||
this.Controls.Add(this.labelCost);
|
||||
this.Controls.Add(this.labelName);
|
||||
@ -206,7 +206,7 @@
|
||||
private Label labelName;
|
||||
private Label labelCost;
|
||||
private TextBox textBoxName;
|
||||
private TextBox textBoxCost;
|
||||
private TextBox textBoxPrice;
|
||||
private GroupBox groupBoxWorkPiece;
|
||||
private Button buttonRef;
|
||||
private Button buttonDel;
|
||||
|
@ -49,7 +49,7 @@ namespace BlacksmithWorkshop
|
||||
if(view != null)
|
||||
{
|
||||
textBoxName.Text = view.ManufactureName;
|
||||
textBoxCost.Text = view.Price.ToString();
|
||||
textBoxPrice.Text = view.Price.ToString();
|
||||
_manufactureWorkPieces = view.ManufactureWorkPieces ?? new Dictionary<int, (IWorkPieceModel, int)>();
|
||||
LoadData();
|
||||
}
|
||||
@ -77,7 +77,7 @@ namespace BlacksmithWorkshop
|
||||
dataGridView.Rows.Add(new object[] { awp.Key, awp.Value.Item1.WorkPieceName, awp.Value.Item2 });
|
||||
}
|
||||
|
||||
textBoxCost.Text = CalcPrice().ToString();
|
||||
textBoxPrice.Text = CalcPrice().ToString();
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
@ -90,13 +90,16 @@ namespace BlacksmithWorkshop
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormManufactureWorkPiece));
|
||||
|
||||
if (service is FormManufactureWorkPiece form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
if (form.WorkPieceModel == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Добавление новой заготовки:{WorkPieceName} - {Count}", form.WorkPieceModel.WorkPieceName, form.Count);
|
||||
|
||||
if (_manufactureWorkPieces.ContainsKey(form.Id))
|
||||
@ -110,6 +113,7 @@ namespace BlacksmithWorkshop
|
||||
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||
@ -131,7 +135,7 @@ namespace BlacksmithWorkshop
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Изменение компонента:{ComponentName} - {Count}", form.WorkPieceModel.WorkPieceName, form.Count);
|
||||
_logger.LogInformation("Изменение компонента:{WorkPieceName} - {Count}", form.WorkPieceModel.WorkPieceName, form.Count);
|
||||
_manufactureWorkPieces[form.Id] = (form.WorkPieceModel, form.Count);
|
||||
|
||||
LoadData();
|
||||
@ -144,8 +148,7 @@ namespace BlacksmithWorkshop
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос",
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -154,8 +157,7 @@ namespace BlacksmithWorkshop
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
LoadData();
|
||||
@ -177,7 +179,7 @@ namespace BlacksmithWorkshop
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(textBoxCost.Text))
|
||||
if (string.IsNullOrEmpty(textBoxPrice.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
||||
@ -199,12 +201,11 @@ namespace BlacksmithWorkshop
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
ManufactureName = textBoxName.Text,
|
||||
Price = Convert.ToDouble(textBoxCost.Text),
|
||||
Price = Convert.ToDouble(textBoxPrice.Text),
|
||||
ManufactureWorkPieces = _manufactureWorkPieces
|
||||
};
|
||||
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) :
|
||||
_logic.Create(model);
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
|
||||
if (!operationResult)
|
||||
{
|
||||
@ -229,6 +230,7 @@ namespace BlacksmithWorkshop
|
||||
Close();
|
||||
}
|
||||
|
||||
//в конце умножить на 1.1, так как прибавляем к итоговой стоимости некоторый процент (в данном случае 10%)
|
||||
private double CalcPrice()
|
||||
{
|
||||
double price = 0;
|
||||
|
@ -63,4 +63,10 @@
|
||||
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnWorkPiece.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
@ -68,6 +68,7 @@ namespace BlacksmithWorkshop
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (comboBoxWorkPiece.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите заготовку", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
|
@ -46,11 +46,11 @@ namespace BlacksmithWorkshop
|
||||
dataGridView.Columns["ColumnName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка компонентов");
|
||||
_logger.LogInformation("Загрузка изделий");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки компонентов");
|
||||
_logger.LogError(ex, "Ошибка загрузки изделий");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
@ -93,7 +93,7 @@ namespace BlacksmithWorkshop
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
|
||||
_logger.LogInformation("Удаление компонента");
|
||||
_logger.LogInformation("Удаление изделия");
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -31,7 +31,7 @@
|
||||
this.labelName = new System.Windows.Forms.Label();
|
||||
this.labelPrice = new System.Windows.Forms.Label();
|
||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||
this.textBoxPrice = new System.Windows.Forms.TextBox();
|
||||
this.textBoxCost = new System.Windows.Forms.TextBox();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.buttonSave = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
@ -61,12 +61,12 @@
|
||||
this.textBoxName.Size = new System.Drawing.Size(293, 27);
|
||||
this.textBoxName.TabIndex = 2;
|
||||
//
|
||||
// textBoxPrice
|
||||
// textBoxCost
|
||||
//
|
||||
this.textBoxPrice.Location = new System.Drawing.Point(127, 62);
|
||||
this.textBoxPrice.Name = "textBoxPrice";
|
||||
this.textBoxPrice.Size = new System.Drawing.Size(179, 27);
|
||||
this.textBoxPrice.TabIndex = 3;
|
||||
this.textBoxCost.Location = new System.Drawing.Point(127, 62);
|
||||
this.textBoxCost.Name = "textBoxCost";
|
||||
this.textBoxCost.Size = new System.Drawing.Size(179, 27);
|
||||
this.textBoxCost.TabIndex = 3;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
@ -95,7 +95,7 @@
|
||||
this.ClientSize = new System.Drawing.Size(464, 153);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.textBoxPrice);
|
||||
this.Controls.Add(this.textBoxCost);
|
||||
this.Controls.Add(this.textBoxName);
|
||||
this.Controls.Add(this.labelPrice);
|
||||
this.Controls.Add(this.labelName);
|
||||
@ -112,7 +112,7 @@
|
||||
private Label labelName;
|
||||
private Label labelPrice;
|
||||
private TextBox textBoxName;
|
||||
private TextBox textBoxPrice;
|
||||
private TextBox textBoxCost;
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ using Microsoft.Extensions.Logging;
|
||||
namespace BlacksmithWorkshop
|
||||
{
|
||||
//ôîðìà "Çàãîòîâêà"
|
||||
public partial class FormWorkPiece : System.Windows.Forms.Form
|
||||
public partial class FormWorkPiece : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
@ -20,6 +20,7 @@ namespace BlacksmithWorkshop
|
||||
public FormWorkPiece(ILogger<FormWorkPiece> logger, IWorkPieceLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
@ -39,7 +40,7 @@ namespace BlacksmithWorkshop
|
||||
if(view != null)
|
||||
{
|
||||
textBoxName.Text = view.WorkPieceName;
|
||||
textBoxPrice.Text = view.Cost.ToString();
|
||||
textBoxCost.Text = view.Cost.ToString();
|
||||
}
|
||||
}
|
||||
catch(Exception ex)
|
||||
@ -70,7 +71,7 @@ namespace BlacksmithWorkshop
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
WorkPieceName = textBoxName.Text,
|
||||
Cost = Convert.ToDouble(textBoxPrice.Text)
|
||||
Cost = Convert.ToDouble(textBoxCost.Text)
|
||||
};
|
||||
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
|
@ -17,9 +17,9 @@ namespace BlacksmithWorkshop
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
|
||||
private readonly IManufactureLogic _logic;
|
||||
private readonly IWorkPieceLogic _logic;
|
||||
|
||||
public FormWorkPieces(ILogger<FormWorkPieces> logger, IManufactureLogic logic)
|
||||
public FormWorkPieces(ILogger<FormWorkPieces> logger, IWorkPieceLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
@ -42,14 +42,14 @@ namespace BlacksmithWorkshop
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ManufactureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["WorkPieceName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка компонентов");
|
||||
_logger.LogInformation("Загрузка заготовок");
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки компонентов");
|
||||
_logger.LogError(ex, "Ошибка загрузки заготовок");
|
||||
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
@ -57,9 +57,9 @@ namespace BlacksmithWorkshop
|
||||
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormWorkPieces));
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormWorkPiece));
|
||||
|
||||
if (service is FormWorkPieces form)
|
||||
if (service is FormWorkPiece form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
@ -99,7 +99,7 @@ namespace BlacksmithWorkshop
|
||||
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new ManufactureBindingModel
|
||||
if (!_logic.Delete(new WorkPieceBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
@ -112,8 +112,7 @@ namespace BlacksmithWorkshop
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления компонента");
|
||||
MessageBox.Show(ex.Message, "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user