Шаг 6. Исправление неправильного оформления
This commit is contained in:
parent
c3b6653f5c
commit
1b1b8ee7bf
@ -28,24 +28,24 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.PackageNameLabel = new System.Windows.Forms.Label();
|
||||
this.ReinforcedNameLabel = new System.Windows.Forms.Label();
|
||||
this.CountLabel = new System.Windows.Forms.Label();
|
||||
this.SumLabel = new System.Windows.Forms.Label();
|
||||
this.PackageComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.ReinforcedComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.CountTextBox = new System.Windows.Forms.TextBox();
|
||||
this.SumTextBox = new System.Windows.Forms.TextBox();
|
||||
this.ButtonCancel = new System.Windows.Forms.Button();
|
||||
this.SaveButton = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// PackageNameLabel
|
||||
// ReinforcedNameLabel
|
||||
//
|
||||
this.PackageNameLabel.AutoSize = true;
|
||||
this.PackageNameLabel.Location = new System.Drawing.Point(12, 9);
|
||||
this.PackageNameLabel.Name = "PackageNameLabel";
|
||||
this.PackageNameLabel.Size = new System.Drawing.Size(59, 15);
|
||||
this.PackageNameLabel.TabIndex = 0;
|
||||
this.PackageNameLabel.Text = "Изделие: ";
|
||||
this.ReinforcedNameLabel.AutoSize = true;
|
||||
this.ReinforcedNameLabel.Location = new System.Drawing.Point(12, 9);
|
||||
this.ReinforcedNameLabel.Name = "ReinforcedNameLabel";
|
||||
this.ReinforcedNameLabel.Size = new System.Drawing.Size(59, 15);
|
||||
this.ReinforcedNameLabel.TabIndex = 0;
|
||||
this.ReinforcedNameLabel.Text = "Изделие: ";
|
||||
//
|
||||
// CountLabel
|
||||
//
|
||||
@ -65,14 +65,14 @@
|
||||
this.SumLabel.TabIndex = 2;
|
||||
this.SumLabel.Text = "Сумма: ";
|
||||
//
|
||||
// PackageComboBox
|
||||
// ReinforcedComboBox
|
||||
//
|
||||
this.PackageComboBox.FormattingEnabled = true;
|
||||
this.PackageComboBox.Location = new System.Drawing.Point(93, 6);
|
||||
this.PackageComboBox.Name = "PackageComboBox";
|
||||
this.PackageComboBox.Size = new System.Drawing.Size(201, 23);
|
||||
this.PackageComboBox.TabIndex = 3;
|
||||
this.PackageComboBox.SelectedIndexChanged += new System.EventHandler(this.PackageComboBox_SelectedIndexChanged);
|
||||
this.ReinforcedComboBox.FormattingEnabled = true;
|
||||
this.ReinforcedComboBox.Location = new System.Drawing.Point(93, 6);
|
||||
this.ReinforcedComboBox.Name = "ReinforcedComboBox";
|
||||
this.ReinforcedComboBox.Size = new System.Drawing.Size(201, 23);
|
||||
this.ReinforcedComboBox.TabIndex = 3;
|
||||
this.ReinforcedComboBox.SelectedIndexChanged += new System.EventHandler(this.ReinforcedComboBox_SelectedIndexChanged);
|
||||
//
|
||||
// CountTextBox
|
||||
//
|
||||
@ -118,10 +118,10 @@
|
||||
this.Controls.Add(this.ButtonCancel);
|
||||
this.Controls.Add(this.SumTextBox);
|
||||
this.Controls.Add(this.CountTextBox);
|
||||
this.Controls.Add(this.PackageComboBox);
|
||||
this.Controls.Add(this.ReinforcedComboBox);
|
||||
this.Controls.Add(this.SumLabel);
|
||||
this.Controls.Add(this.CountLabel);
|
||||
this.Controls.Add(this.PackageNameLabel);
|
||||
this.Controls.Add(this.ReinforcedNameLabel);
|
||||
this.Name = "FormCreateOrder";
|
||||
this.Text = "Заказ";
|
||||
this.ResumeLayout(false);
|
||||
@ -131,10 +131,10 @@
|
||||
|
||||
#endregion
|
||||
|
||||
private Label PackageNameLabel;
|
||||
private Label ReinforcedNameLabel;
|
||||
private Label CountLabel;
|
||||
private Label SumLabel;
|
||||
private ComboBox PackageComboBox;
|
||||
private ComboBox ReinforcedComboBox;
|
||||
private TextBox CountTextBox;
|
||||
private TextBox SumTextBox;
|
||||
private Button ButtonCancel;
|
||||
|
@ -39,10 +39,10 @@ namespace PrecastConcretePlantView
|
||||
var list = _logicP.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
PackageComboBox.DisplayMember = "ReinforcedName";
|
||||
PackageComboBox.ValueMember = "Id";
|
||||
PackageComboBox.DataSource = list;
|
||||
PackageComboBox.SelectedItem = null;
|
||||
ReinforcedComboBox.DisplayMember = "ReinforcedName";
|
||||
ReinforcedComboBox.ValueMember = "Id";
|
||||
ReinforcedComboBox.DataSource = list;
|
||||
ReinforcedComboBox.SelectedItem = null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -60,11 +60,11 @@ namespace PrecastConcretePlantView
|
||||
|
||||
private void CalcSum()
|
||||
{
|
||||
if (PackageComboBox.SelectedValue != null && !string.IsNullOrEmpty(CountTextBox.Text))
|
||||
if (ReinforcedComboBox.SelectedValue != null && !string.IsNullOrEmpty(CountTextBox.Text))
|
||||
{
|
||||
try
|
||||
{
|
||||
int id = Convert.ToInt32(PackageComboBox.SelectedValue);
|
||||
int id = Convert.ToInt32(ReinforcedComboBox.SelectedValue);
|
||||
|
||||
var reinforced = _logicP.ReadElement(new ReinforcedSearchModel
|
||||
{
|
||||
@ -88,11 +88,6 @@ namespace PrecastConcretePlantView
|
||||
CalcSum();
|
||||
}
|
||||
|
||||
private void PackageComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
CalcSum();
|
||||
}
|
||||
|
||||
private void SaveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(CountTextBox.Text))
|
||||
@ -101,7 +96,7 @@ namespace PrecastConcretePlantView
|
||||
return;
|
||||
}
|
||||
|
||||
if (PackageComboBox.SelectedValue == null)
|
||||
if (ReinforcedComboBox.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
@ -113,7 +108,7 @@ namespace PrecastConcretePlantView
|
||||
{
|
||||
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
||||
{
|
||||
ReinforcedId = Convert.ToInt32(PackageComboBox.SelectedValue),
|
||||
ReinforcedId = Convert.ToInt32(ReinforcedComboBox.SelectedValue),
|
||||
Count = Convert.ToInt32(CountTextBox.Text),
|
||||
Sum = Convert.ToDouble(SumTextBox.Text)
|
||||
});
|
||||
@ -139,5 +134,10 @@ namespace PrecastConcretePlantView
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void ReinforcedComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
CalcSum();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,9 +31,9 @@
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle();
|
||||
this.PackageNameLabel = new System.Windows.Forms.Label();
|
||||
this.ReinforcedNameLabel = new System.Windows.Forms.Label();
|
||||
this.PriceLabel = new System.Windows.Forms.Label();
|
||||
this.PackageNameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.ReinforcedNameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.PriceTextBox = new System.Windows.Forms.TextBox();
|
||||
this.ComponentsGroupBox = new System.Windows.Forms.GroupBox();
|
||||
this.UpdateButton = new System.Windows.Forms.Button();
|
||||
@ -50,14 +50,14 @@
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// PackageNameLabel
|
||||
// ReinforcedNameLabel
|
||||
//
|
||||
this.PackageNameLabel.AutoSize = true;
|
||||
this.PackageNameLabel.Location = new System.Drawing.Point(12, 9);
|
||||
this.PackageNameLabel.Name = "PackageNameLabel";
|
||||
this.PackageNameLabel.Size = new System.Drawing.Size(65, 15);
|
||||
this.PackageNameLabel.TabIndex = 0;
|
||||
this.PackageNameLabel.Text = "Название: ";
|
||||
this.ReinforcedNameLabel.AutoSize = true;
|
||||
this.ReinforcedNameLabel.Location = new System.Drawing.Point(12, 9);
|
||||
this.ReinforcedNameLabel.Name = "ReinforcedNameLabel";
|
||||
this.ReinforcedNameLabel.Size = new System.Drawing.Size(65, 15);
|
||||
this.ReinforcedNameLabel.TabIndex = 0;
|
||||
this.ReinforcedNameLabel.Text = "Название: ";
|
||||
//
|
||||
// PriceLabel
|
||||
//
|
||||
@ -68,12 +68,12 @@
|
||||
this.PriceLabel.TabIndex = 1;
|
||||
this.PriceLabel.Text = "Стоимость: ";
|
||||
//
|
||||
// PackageNameTextBox
|
||||
// ReinforcedNameTextBox
|
||||
//
|
||||
this.PackageNameTextBox.Location = new System.Drawing.Point(83, 6);
|
||||
this.PackageNameTextBox.Name = "PackageNameTextBox";
|
||||
this.PackageNameTextBox.Size = new System.Drawing.Size(283, 23);
|
||||
this.PackageNameTextBox.TabIndex = 2;
|
||||
this.ReinforcedNameTextBox.Location = new System.Drawing.Point(83, 6);
|
||||
this.ReinforcedNameTextBox.Name = "ReinforcedNameTextBox";
|
||||
this.ReinforcedNameTextBox.Size = new System.Drawing.Size(283, 23);
|
||||
this.ReinforcedNameTextBox.TabIndex = 2;
|
||||
//
|
||||
// PriceTextBox
|
||||
//
|
||||
@ -210,7 +210,7 @@
|
||||
this.SaveButton.UseVisualStyleBackColor = true;
|
||||
this.SaveButton.Click += new System.EventHandler(this.SaveButton_Click);
|
||||
//
|
||||
// FormPackage
|
||||
// FormReinforced
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
@ -219,10 +219,10 @@
|
||||
this.Controls.Add(this.ButtonCancel);
|
||||
this.Controls.Add(this.ComponentsGroupBox);
|
||||
this.Controls.Add(this.PriceTextBox);
|
||||
this.Controls.Add(this.PackageNameTextBox);
|
||||
this.Controls.Add(this.ReinforcedNameTextBox);
|
||||
this.Controls.Add(this.PriceLabel);
|
||||
this.Controls.Add(this.PackageNameLabel);
|
||||
this.Name = "FormPackage";
|
||||
this.Controls.Add(this.ReinforcedNameLabel);
|
||||
this.Name = "FormReinforced";
|
||||
this.Text = "Изделие";
|
||||
this.ComponentsGroupBox.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
|
||||
@ -233,9 +233,9 @@
|
||||
|
||||
#endregion
|
||||
|
||||
private Label PackageNameLabel;
|
||||
private Label ReinforcedNameLabel;
|
||||
private Label PriceLabel;
|
||||
private TextBox PackageNameTextBox;
|
||||
private TextBox ReinforcedNameTextBox;
|
||||
private TextBox PriceTextBox;
|
||||
private GroupBox ComponentsGroupBox;
|
||||
private Button UpdateButton;
|
||||
|
@ -24,7 +24,7 @@ namespace PrecastConcretePlantView
|
||||
|
||||
private int? _id;
|
||||
|
||||
private Dictionary<int, (IComponentModel, int)> _packageComponents;
|
||||
private Dictionary<int, (IComponentModel, int)> _reinforcedComponents;
|
||||
|
||||
public int Id { set { _id = value; } }
|
||||
public FormReinforced(ILogger<FormReinforced> logger, IReinforcedLogic logic)
|
||||
@ -32,9 +32,9 @@ namespace PrecastConcretePlantView
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
_packageComponents = new Dictionary<int, (IComponentModel, int)>();
|
||||
_reinforcedComponents = new Dictionary<int, (IComponentModel, int)>();
|
||||
}
|
||||
private void FormPackage_Load(object sender, EventArgs e)
|
||||
private void FormReinforced_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
@ -49,9 +49,9 @@ namespace PrecastConcretePlantView
|
||||
|
||||
if (view != null)
|
||||
{
|
||||
PackageNameTextBox.Text = view.ReinforcedName;
|
||||
ReinforcedNameTextBox.Text = view.ReinforcedName;
|
||||
PriceTextBox.Text = view.Price.ToString();
|
||||
_packageComponents = view.ReinforcedComponents ?? new Dictionary<int, (IComponentModel, int)>();
|
||||
_reinforcedComponents = view.ReinforcedComponents ?? new Dictionary<int, (IComponentModel, int)>();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
@ -68,10 +68,10 @@ namespace PrecastConcretePlantView
|
||||
|
||||
try
|
||||
{
|
||||
if (_packageComponents != null)
|
||||
if (_reinforcedComponents != null)
|
||||
{
|
||||
DataGridView.Rows.Clear();
|
||||
foreach (var pc in _packageComponents)
|
||||
foreach (var pc in _reinforcedComponents)
|
||||
{
|
||||
DataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.ComponentName, pc.Value.Item2 });
|
||||
}
|
||||
@ -99,14 +99,14 @@ namespace PrecastConcretePlantView
|
||||
|
||||
_logger.LogInformation("Добавление нового компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
|
||||
|
||||
if (_packageComponents.ContainsKey(form.Id))
|
||||
if (_reinforcedComponents.ContainsKey(form.Id))
|
||||
{
|
||||
_packageComponents[form.Id] = (form.ComponentModel, form.Count);
|
||||
_reinforcedComponents[form.Id] = (form.ComponentModel, form.Count);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
_packageComponents.Add(form.Id, (form.ComponentModel, form.Count));
|
||||
_reinforcedComponents.Add(form.Id, (form.ComponentModel, form.Count));
|
||||
}
|
||||
|
||||
LoadData();
|
||||
@ -124,7 +124,7 @@ namespace PrecastConcretePlantView
|
||||
{
|
||||
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells[0].Value);
|
||||
form.Id = id;
|
||||
form.Count = _packageComponents[id].Item2;
|
||||
form.Count = _reinforcedComponents[id].Item2;
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
@ -134,7 +134,7 @@ namespace PrecastConcretePlantView
|
||||
}
|
||||
|
||||
_logger.LogInformation("Изменение компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count);
|
||||
_packageComponents[form.Id] = (form.ComponentModel, form.Count);
|
||||
_reinforcedComponents[form.Id] = (form.ComponentModel, form.Count);
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
@ -150,7 +150,7 @@ namespace PrecastConcretePlantView
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Удаление компонента: { ComponentName} - { Count}", DataGridView.SelectedRows[0].Cells[1].Value);
|
||||
_packageComponents?.Remove(Convert.ToInt32(DataGridView.SelectedRows[0].Cells[0].Value));
|
||||
_reinforcedComponents?.Remove(Convert.ToInt32(DataGridView.SelectedRows[0].Cells[0].Value));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@ -169,7 +169,7 @@ namespace PrecastConcretePlantView
|
||||
|
||||
private void SaveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(PackageNameTextBox.Text))
|
||||
if (string.IsNullOrEmpty(ReinforcedNameTextBox.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
@ -181,7 +181,7 @@ namespace PrecastConcretePlantView
|
||||
return;
|
||||
}
|
||||
|
||||
if (_packageComponents == null || _packageComponents.Count == 0)
|
||||
if (_reinforcedComponents == null || _reinforcedComponents.Count == 0)
|
||||
{
|
||||
MessageBox.Show("Заполните компоненты", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
@ -194,9 +194,9 @@ namespace PrecastConcretePlantView
|
||||
var model = new ReinforcedBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
ReinforcedName = PackageNameTextBox.Text,
|
||||
ReinforcedName = ReinforcedNameTextBox.Text,
|
||||
Price = Convert.ToDouble(PriceTextBox.Text),
|
||||
ReinforcedComponents = _packageComponents
|
||||
ReinforcedComponents = _reinforcedComponents
|
||||
};
|
||||
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
@ -227,7 +227,7 @@ namespace PrecastConcretePlantView
|
||||
{
|
||||
double price = 0;
|
||||
|
||||
foreach (var elem in _packageComponents)
|
||||
foreach (var elem in _reinforcedComponents)
|
||||
{
|
||||
price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user