Мелкие правки

This commit is contained in:
gg12 darfren 2024-02-07 11:58:18 +04:00
parent 966aff265e
commit 2856e9043b
9 changed files with 55 additions and 70 deletions

View File

@ -109,7 +109,7 @@
Margin = new Padding(3, 4, 3, 4); Margin = new Padding(3, 4, 3, 4);
Name = "ComponentForm"; Name = "ComponentForm";
Text = "Компонент"; Text = "Компонент";
Load += FormComponent_Load; Load += ComponentForm_Load;
ResumeLayout(false); ResumeLayout(false);
PerformLayout(); PerformLayout();
} }

View File

@ -19,7 +19,7 @@ namespace IceCreamShop
_logic = logic; _logic = logic;
} }
private void FormComponent_Load(object sender, EventArgs e) private void ComponentForm_Load(object sender, EventArgs e)
{ {
if (_id.HasValue) if (_id.HasValue)
{ {

View File

@ -96,7 +96,7 @@
Controls.Add(DataGridView); Controls.Add(DataGridView);
Name = "ComponentsForm"; Name = "ComponentsForm";
Text = "Компоненты"; Text = "Компоненты";
Load += FormComponents_Load; Load += ComponentsForm_Load;
((System.ComponentModel.ISupportInitialize)DataGridView).EndInit(); ((System.ComponentModel.ISupportInitialize)DataGridView).EndInit();
ResumeLayout(false); ResumeLayout(false);
} }

View File

@ -24,7 +24,7 @@ namespace IceCreamShop
_logger = logger; _logger = logger;
_logic = logic; _logic = logic;
} }
private void FormComponents_Load(object sender, EventArgs e) private void ComponentsForm_Load(object sender, EventArgs e)
{ {
LoadData(); LoadData();
} }

View File

@ -66,7 +66,7 @@ namespace IceCreamShop
} }
private void ButtonSave_Click(object sender, EventArgs e) private void ButtonSave_Click(object sender, EventArgs e)
{ {
if (string.IsNullOrEmpty(ComboBox.Text)) if (string.IsNullOrEmpty(CountTextBox.Text))
{ {
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBox.Show("Заполните поле Количество", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBoxButtons.OK, MessageBoxIcon.Error);

View File

@ -50,35 +50,34 @@
// NameLabel // NameLabel
// //
NameLabel.AutoSize = true; NameLabel.AutoSize = true;
NameLabel.Location = new Point(14, 12); NameLabel.Location = new Point(12, 9);
NameLabel.Name = "NameLabel"; NameLabel.Name = "NameLabel";
NameLabel.Size = new Size(77, 20); NameLabel.Size = new Size(59, 15);
NameLabel.TabIndex = 0; NameLabel.TabIndex = 0;
NameLabel.Text = "Название"; NameLabel.Text = "Название";
// //
// PriceLabel // PriceLabel
// //
PriceLabel.AutoSize = true; PriceLabel.AutoSize = true;
PriceLabel.Location = new Point(14, 47); PriceLabel.Location = new Point(12, 35);
PriceLabel.Name = "PriceLabel"; PriceLabel.Name = "PriceLabel";
PriceLabel.Size = new Size(45, 20); PriceLabel.Size = new Size(35, 15);
PriceLabel.TabIndex = 1; PriceLabel.TabIndex = 1;
PriceLabel.Text = "Цена"; PriceLabel.Text = "Цена";
// //
// NameTextBox // NameTextBox
// //
NameTextBox.Location = new Point(88, 8); NameTextBox.Location = new Point(77, 6);
NameTextBox.Margin = new Padding(3, 4, 3, 4);
NameTextBox.Name = "NameTextBox"; NameTextBox.Name = "NameTextBox";
NameTextBox.Size = new Size(270, 27); NameTextBox.Size = new Size(237, 23);
NameTextBox.TabIndex = 2; NameTextBox.TabIndex = 2;
// //
// PriceTextBox // PriceTextBox
// //
PriceTextBox.Location = new Point(88, 43); PriceTextBox.Location = new Point(77, 32);
PriceTextBox.Margin = new Padding(3, 4, 3, 4);
PriceTextBox.Name = "PriceTextBox"; PriceTextBox.Name = "PriceTextBox";
PriceTextBox.Size = new Size(114, 27); PriceTextBox.ReadOnly = true;
PriceTextBox.Size = new Size(100, 23);
PriceTextBox.TabIndex = 3; PriceTextBox.TabIndex = 3;
// //
// ComponentsGroupBox // ComponentsGroupBox
@ -88,21 +87,18 @@
ComponentsGroupBox.Controls.Add(UpdateButton); ComponentsGroupBox.Controls.Add(UpdateButton);
ComponentsGroupBox.Controls.Add(AddButton); ComponentsGroupBox.Controls.Add(AddButton);
ComponentsGroupBox.Controls.Add(DataGridView); ComponentsGroupBox.Controls.Add(DataGridView);
ComponentsGroupBox.Location = new Point(14, 85); ComponentsGroupBox.Location = new Point(12, 64);
ComponentsGroupBox.Margin = new Padding(3, 4, 3, 4);
ComponentsGroupBox.Name = "ComponentsGroupBox"; ComponentsGroupBox.Name = "ComponentsGroupBox";
ComponentsGroupBox.Padding = new Padding(3, 4, 3, 4); ComponentsGroupBox.Size = new Size(582, 287);
ComponentsGroupBox.Size = new Size(665, 383);
ComponentsGroupBox.TabIndex = 4; ComponentsGroupBox.TabIndex = 4;
ComponentsGroupBox.TabStop = false; ComponentsGroupBox.TabStop = false;
ComponentsGroupBox.Text = "Компоненты"; ComponentsGroupBox.Text = "Компоненты";
// //
// RefreshButton // RefreshButton
// //
RefreshButton.Location = new Point(550, 145); RefreshButton.Location = new Point(481, 109);
RefreshButton.Margin = new Padding(3, 4, 3, 4);
RefreshButton.Name = "RefreshButton"; RefreshButton.Name = "RefreshButton";
RefreshButton.Size = new Size(86, 31); RefreshButton.Size = new Size(75, 23);
RefreshButton.TabIndex = 4; RefreshButton.TabIndex = 4;
RefreshButton.Text = "Обновить"; RefreshButton.Text = "Обновить";
RefreshButton.UseVisualStyleBackColor = true; RefreshButton.UseVisualStyleBackColor = true;
@ -110,10 +106,9 @@
// //
// DeleteButton // DeleteButton
// //
DeleteButton.Location = new Point(550, 107); DeleteButton.Location = new Point(481, 80);
DeleteButton.Margin = new Padding(3, 4, 3, 4);
DeleteButton.Name = "DeleteButton"; DeleteButton.Name = "DeleteButton";
DeleteButton.Size = new Size(86, 31); DeleteButton.Size = new Size(75, 23);
DeleteButton.TabIndex = 3; DeleteButton.TabIndex = 3;
DeleteButton.Text = "Удалить"; DeleteButton.Text = "Удалить";
DeleteButton.UseVisualStyleBackColor = true; DeleteButton.UseVisualStyleBackColor = true;
@ -121,10 +116,9 @@
// //
// UpdateButton // UpdateButton
// //
UpdateButton.Location = new Point(550, 68); UpdateButton.Location = new Point(481, 51);
UpdateButton.Margin = new Padding(3, 4, 3, 4);
UpdateButton.Name = "UpdateButton"; UpdateButton.Name = "UpdateButton";
UpdateButton.Size = new Size(86, 31); UpdateButton.Size = new Size(75, 23);
UpdateButton.TabIndex = 2; UpdateButton.TabIndex = 2;
UpdateButton.Text = "Изменить"; UpdateButton.Text = "Изменить";
UpdateButton.UseVisualStyleBackColor = true; UpdateButton.UseVisualStyleBackColor = true;
@ -132,10 +126,9 @@
// //
// AddButton // AddButton
// //
AddButton.Location = new Point(550, 29); AddButton.Location = new Point(481, 22);
AddButton.Margin = new Padding(3, 4, 3, 4);
AddButton.Name = "AddButton"; AddButton.Name = "AddButton";
AddButton.Size = new Size(86, 31); AddButton.Size = new Size(75, 23);
AddButton.TabIndex = 1; AddButton.TabIndex = 1;
AddButton.Text = "Добавить"; AddButton.Text = "Добавить";
AddButton.UseVisualStyleBackColor = true; AddButton.UseVisualStyleBackColor = true;
@ -145,11 +138,10 @@
// //
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
DataGridView.Columns.AddRange(new DataGridViewColumn[] { IdColumn, ComponentNameColumn, CountColumn }); DataGridView.Columns.AddRange(new DataGridViewColumn[] { IdColumn, ComponentNameColumn, CountColumn });
DataGridView.Location = new Point(7, 29); DataGridView.Location = new Point(6, 22);
DataGridView.Margin = new Padding(3, 4, 3, 4);
DataGridView.Name = "DataGridView"; DataGridView.Name = "DataGridView";
DataGridView.RowHeadersWidth = 51; DataGridView.RowHeadersWidth = 51;
DataGridView.Size = new Size(505, 345); DataGridView.Size = new Size(442, 259);
DataGridView.TabIndex = 0; DataGridView.TabIndex = 0;
// //
// IdColumn // IdColumn
@ -176,10 +168,9 @@
// //
// SaveButton // SaveButton
// //
SaveButton.Location = new Point(485, 484); SaveButton.Location = new Point(424, 363);
SaveButton.Margin = new Padding(3, 4, 3, 4);
SaveButton.Name = "SaveButton"; SaveButton.Name = "SaveButton";
SaveButton.Size = new Size(86, 31); SaveButton.Size = new Size(75, 23);
SaveButton.TabIndex = 5; SaveButton.TabIndex = 5;
SaveButton.Text = "Сохранить"; SaveButton.Text = "Сохранить";
SaveButton.UseVisualStyleBackColor = true; SaveButton.UseVisualStyleBackColor = true;
@ -187,19 +178,18 @@
// //
// CancelButton // CancelButton
// //
CancelButton.Location = new Point(577, 484); CancelButton.Location = new Point(505, 363);
CancelButton.Margin = new Padding(3, 4, 3, 4);
CancelButton.Name = "CancelButton"; CancelButton.Name = "CancelButton";
CancelButton.Size = new Size(86, 31); CancelButton.Size = new Size(75, 23);
CancelButton.TabIndex = 6; CancelButton.TabIndex = 6;
CancelButton.Text = "Отмена"; CancelButton.Text = "Отмена";
CancelButton.UseVisualStyleBackColor = true; CancelButton.UseVisualStyleBackColor = true;
// //
// IceCreamForm // IceCreamForm
// //
AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(693, 531); ClientSize = new Size(606, 398);
Controls.Add(CancelButton); Controls.Add(CancelButton);
Controls.Add(SaveButton); Controls.Add(SaveButton);
Controls.Add(ComponentsGroupBox); Controls.Add(ComponentsGroupBox);
@ -207,9 +197,9 @@
Controls.Add(NameTextBox); Controls.Add(NameTextBox);
Controls.Add(PriceLabel); Controls.Add(PriceLabel);
Controls.Add(NameLabel); Controls.Add(NameLabel);
Margin = new Padding(3, 4, 3, 4);
Name = "IceCreamForm"; Name = "IceCreamForm";
Text = "Мороженное"; Text = "Мороженное";
Load += IceCreamForm_Load;
ComponentsGroupBox.ResumeLayout(false); ComponentsGroupBox.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)DataGridView).EndInit(); ((System.ComponentModel.ISupportInitialize)DataGridView).EndInit();
ResumeLayout(false); ResumeLayout(false);

View File

@ -31,7 +31,7 @@ namespace IceCreamShop
_iceCreamComponents = new Dictionary<int, (IComponentModel, int)>(); _iceCreamComponents = new Dictionary<int, (IComponentModel, int)>();
} }
private void FormProduct_Load(object sender, EventArgs e) private void IceCreamForm_Load(object sender, EventArgs e)
{ {
if (_id.HasValue) if (_id.HasValue)
{ {

View File

@ -41,37 +41,34 @@
// IceCreamComboBox // IceCreamComboBox
// //
IceCreamComboBox.FormattingEnabled = true; IceCreamComboBox.FormattingEnabled = true;
IceCreamComboBox.Location = new Point(118, 16); IceCreamComboBox.Location = new Point(103, 12);
IceCreamComboBox.Margin = new Padding(3, 4, 3, 4);
IceCreamComboBox.Name = "IceCreamComboBox"; IceCreamComboBox.Name = "IceCreamComboBox";
IceCreamComboBox.Size = new Size(265, 28); IceCreamComboBox.Size = new Size(232, 23);
IceCreamComboBox.TabIndex = 0; IceCreamComboBox.TabIndex = 0;
IceCreamComboBox.SelectedIndexChanged += IceCreamComboBox_SelectedIndexChanged; IceCreamComboBox.SelectedIndexChanged += IceCreamComboBox_SelectedIndexChanged;
// //
// CountTextBox // CountTextBox
// //
CountTextBox.Location = new Point(118, 55); CountTextBox.Location = new Point(103, 41);
CountTextBox.Margin = new Padding(3, 4, 3, 4);
CountTextBox.Name = "CountTextBox"; CountTextBox.Name = "CountTextBox";
CountTextBox.Size = new Size(265, 27); CountTextBox.Size = new Size(232, 23);
CountTextBox.TabIndex = 1; CountTextBox.TabIndex = 1;
CountTextBox.TextChanged += CountTextBox_TextChanged; CountTextBox.TextChanged += CountTextBox_TextChanged;
// //
// SumTextBox // SumTextBox
// //
SumTextBox.Location = new Point(118, 93); SumTextBox.Location = new Point(103, 70);
SumTextBox.Margin = new Padding(3, 4, 3, 4);
SumTextBox.Name = "SumTextBox"; SumTextBox.Name = "SumTextBox";
SumTextBox.Size = new Size(265, 27); SumTextBox.ReadOnly = true;
SumTextBox.Size = new Size(232, 23);
SumTextBox.TabIndex = 2; SumTextBox.TabIndex = 2;
SumTextBox.TextChanged += SumTextBox_TextChanged; SumTextBox.TextChanged += SumTextBox_TextChanged;
// //
// SaveButton // SaveButton
// //
SaveButton.Location = new Point(198, 132); SaveButton.Location = new Point(173, 99);
SaveButton.Margin = new Padding(3, 4, 3, 4);
SaveButton.Name = "SaveButton"; SaveButton.Name = "SaveButton";
SaveButton.Size = new Size(93, 31); SaveButton.Size = new Size(81, 23);
SaveButton.TabIndex = 3; SaveButton.TabIndex = 3;
SaveButton.Text = "Сохранить"; SaveButton.Text = "Сохранить";
SaveButton.UseVisualStyleBackColor = true; SaveButton.UseVisualStyleBackColor = true;
@ -79,10 +76,9 @@
// //
// CancelButton // CancelButton
// //
CancelButton.Location = new Point(297, 132); CancelButton.Location = new Point(260, 99);
CancelButton.Margin = new Padding(3, 4, 3, 4);
CancelButton.Name = "CancelButton"; CancelButton.Name = "CancelButton";
CancelButton.Size = new Size(86, 31); CancelButton.Size = new Size(75, 23);
CancelButton.TabIndex = 4; CancelButton.TabIndex = 4;
CancelButton.Text = "Отмена"; CancelButton.Text = "Отмена";
CancelButton.UseVisualStyleBackColor = true; CancelButton.UseVisualStyleBackColor = true;
@ -91,35 +87,35 @@
// IceCreamLabel // IceCreamLabel
// //
IceCreamLabel.AutoSize = true; IceCreamLabel.AutoSize = true;
IceCreamLabel.Location = new Point(14, 20); IceCreamLabel.Location = new Point(12, 15);
IceCreamLabel.Name = "IceCreamLabel"; IceCreamLabel.Name = "IceCreamLabel";
IceCreamLabel.Size = new Size(103, 20); IceCreamLabel.Size = new Size(81, 15);
IceCreamLabel.TabIndex = 5; IceCreamLabel.TabIndex = 5;
IceCreamLabel.Text = "Мороженное"; IceCreamLabel.Text = "Мороженное";
// //
// CountLabel // CountLabel
// //
CountLabel.AutoSize = true; CountLabel.AutoSize = true;
CountLabel.Location = new Point(14, 59); CountLabel.Location = new Point(12, 44);
CountLabel.Name = "CountLabel"; CountLabel.Name = "CountLabel";
CountLabel.Size = new Size(90, 20); CountLabel.Size = new Size(72, 15);
CountLabel.TabIndex = 6; CountLabel.TabIndex = 6;
CountLabel.Text = "Количество"; CountLabel.Text = "Количество";
// //
// SumLabel // SumLabel
// //
SumLabel.AutoSize = true; SumLabel.AutoSize = true;
SumLabel.Location = new Point(14, 97); SumLabel.Location = new Point(12, 73);
SumLabel.Name = "SumLabel"; SumLabel.Name = "SumLabel";
SumLabel.Size = new Size(55, 20); SumLabel.Size = new Size(45, 15);
SumLabel.TabIndex = 7; SumLabel.TabIndex = 7;
SumLabel.Text = "Сумма"; SumLabel.Text = "Сумма";
// //
// OrderForm // OrderForm
// //
AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(398, 171); ClientSize = new Size(348, 128);
Controls.Add(SumLabel); Controls.Add(SumLabel);
Controls.Add(CountLabel); Controls.Add(CountLabel);
Controls.Add(IceCreamLabel); Controls.Add(IceCreamLabel);
@ -128,7 +124,6 @@
Controls.Add(SumTextBox); Controls.Add(SumTextBox);
Controls.Add(CountTextBox); Controls.Add(CountTextBox);
Controls.Add(IceCreamComboBox); Controls.Add(IceCreamComboBox);
Margin = new Padding(3, 4, 3, 4);
Name = "OrderForm"; Name = "OrderForm";
Text = "OrderForm"; Text = "OrderForm";
Load += OrderForm_Load; Load += OrderForm_Load;

View File

@ -60,13 +60,13 @@ logicI, IOrderLogic logicO)
try try
{ {
int id = Convert.ToInt32(IceCreamComboBox.SelectedValue); int id = Convert.ToInt32(IceCreamComboBox.SelectedValue);
var product = _logicI.ReadElement(new IceCreamSearchModel var iceCream = _logicI.ReadElement(new IceCreamSearchModel
{ {
Id Id
= id = id
}); });
int count = Convert.ToInt32(CountTextBox.Text); int count = Convert.ToInt32(CountTextBox.Text);
SumTextBox.Text = Math.Round(count * (product?.Price ?? 0), SumTextBox.Text = Math.Round(count * (iceCream?.Price ?? 0),
2).ToString(); 2).ToString();
_logger.LogInformation("Расчет суммы заказа"); _logger.LogInformation("Расчет суммы заказа");
} }