ПИбд-23 Салин Олег Алексеевич Лабораторная работа №1 (Усложненная) #5
@ -38,7 +38,7 @@
|
||||
//
|
||||
// NameTextBox
|
||||
//
|
||||
NameTextBox.Location = new Point(92, 13);
|
||||
NameTextBox.Location = new Point(91, 13);
|
||||
NameTextBox.Margin = new Padding(3, 4, 3, 4);
|
||||
NameTextBox.Name = "NameTextBox";
|
||||
NameTextBox.Size = new Size(277, 27);
|
||||
@ -46,7 +46,7 @@
|
||||
//
|
||||
// CostTextBox
|
||||
//
|
||||
CostTextBox.Location = new Point(92, 56);
|
||||
CostTextBox.Location = new Point(91, 56);
|
||||
CostTextBox.Margin = new Padding(3, 4, 3, 4);
|
||||
CostTextBox.Name = "CostTextBox";
|
||||
CostTextBox.Size = new Size(135, 27);
|
||||
@ -108,7 +108,7 @@
|
||||
Controls.Add(NameTextBox);
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "ComponentForm";
|
||||
Text = "Компонент";
|
||||
Text = "Форма компонент";
|
||||
Load += ComponentForm_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
|
33
IceCreamShop/IceCreamShop/ComponentsForm.Designer.cs
generated
33
IceCreamShop/IceCreamShop/ComponentsForm.Designer.cs
generated
@ -39,16 +39,19 @@
|
||||
// DataGridView
|
||||
//
|
||||
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
DataGridView.Location = new Point(12, 12);
|
||||
DataGridView.Location = new Point(14, 16);
|
||||
DataGridView.Margin = new Padding(3, 4, 3, 4);
|
||||
DataGridView.Name = "DataGridView";
|
||||
DataGridView.Size = new Size(369, 350);
|
||||
DataGridView.RowHeadersWidth = 51;
|
||||
DataGridView.Size = new Size(422, 467);
|
||||
DataGridView.TabIndex = 0;
|
||||
//
|
||||
// AddButton
|
||||
//
|
||||
AddButton.Location = new Point(387, 12);
|
||||
AddButton.Location = new Point(442, 16);
|
||||
AddButton.Margin = new Padding(3, 4, 3, 4);
|
||||
AddButton.Name = "AddButton";
|
||||
AddButton.Size = new Size(126, 23);
|
||||
AddButton.Size = new Size(144, 31);
|
||||
AddButton.TabIndex = 1;
|
||||
AddButton.Text = "Добавить";
|
||||
AddButton.UseVisualStyleBackColor = true;
|
||||
@ -56,9 +59,10 @@
|
||||
//
|
||||
// ChangeButton
|
||||
//
|
||||
ChangeButton.Location = new Point(387, 41);
|
||||
ChangeButton.Location = new Point(442, 55);
|
||||
ChangeButton.Margin = new Padding(3, 4, 3, 4);
|
||||
ChangeButton.Name = "ChangeButton";
|
||||
ChangeButton.Size = new Size(126, 23);
|
||||
ChangeButton.Size = new Size(144, 31);
|
||||
ChangeButton.TabIndex = 2;
|
||||
ChangeButton.Text = "Изменить";
|
||||
ChangeButton.UseVisualStyleBackColor = true;
|
||||
@ -66,9 +70,10 @@
|
||||
//
|
||||
// DeleteButton
|
||||
//
|
||||
DeleteButton.Location = new Point(387, 70);
|
||||
DeleteButton.Location = new Point(442, 93);
|
||||
DeleteButton.Margin = new Padding(3, 4, 3, 4);
|
||||
DeleteButton.Name = "DeleteButton";
|
||||
DeleteButton.Size = new Size(126, 23);
|
||||
DeleteButton.Size = new Size(144, 31);
|
||||
DeleteButton.TabIndex = 3;
|
||||
DeleteButton.Text = "Удалить";
|
||||
DeleteButton.UseVisualStyleBackColor = true;
|
||||
@ -76,9 +81,10 @@
|
||||
//
|
||||
// RefreshButton
|
||||
//
|
||||
RefreshButton.Location = new Point(387, 99);
|
||||
RefreshButton.Location = new Point(442, 132);
|
||||
RefreshButton.Margin = new Padding(3, 4, 3, 4);
|
||||
RefreshButton.Name = "RefreshButton";
|
||||
RefreshButton.Size = new Size(126, 23);
|
||||
RefreshButton.Size = new Size(144, 31);
|
||||
RefreshButton.TabIndex = 4;
|
||||
RefreshButton.Text = "Обновить";
|
||||
RefreshButton.UseVisualStyleBackColor = true;
|
||||
@ -86,16 +92,17 @@
|
||||
//
|
||||
// ComponentsForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(525, 374);
|
||||
ClientSize = new Size(600, 499);
|
||||
Controls.Add(RefreshButton);
|
||||
Controls.Add(DeleteButton);
|
||||
Controls.Add(ChangeButton);
|
||||
Controls.Add(AddButton);
|
||||
Controls.Add(DataGridView);
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "ComponentsForm";
|
||||
Text = "Компоненты";
|
||||
Text = "Форма компонентов";
|
||||
Load += ComponentsForm_Load;
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
|
@ -106,7 +106,7 @@
|
||||
Controls.Add(ComponentLabel);
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "IceCreamComponentForm";
|
||||
Text = "Компонент мороженного";
|
||||
Text = "Форма компонент мороженного";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
66
IceCreamShop/IceCreamShop/IceCreamForm.Designer.cs
generated
66
IceCreamShop/IceCreamShop/IceCreamForm.Designer.cs
generated
@ -50,34 +50,36 @@
|
||||
// NameLabel
|
||||
//
|
||||
NameLabel.AutoSize = true;
|
||||
NameLabel.Location = new Point(12, 9);
|
||||
NameLabel.Location = new Point(14, 12);
|
||||
NameLabel.Name = "NameLabel";
|
||||
NameLabel.Size = new Size(59, 15);
|
||||
NameLabel.Size = new Size(77, 20);
|
||||
NameLabel.TabIndex = 0;
|
||||
NameLabel.Text = "Название";
|
||||
//
|
||||
// PriceLabel
|
||||
//
|
||||
PriceLabel.AutoSize = true;
|
||||
PriceLabel.Location = new Point(12, 35);
|
||||
PriceLabel.Location = new Point(14, 47);
|
||||
PriceLabel.Name = "PriceLabel";
|
||||
PriceLabel.Size = new Size(35, 15);
|
||||
PriceLabel.Size = new Size(45, 20);
|
||||
PriceLabel.TabIndex = 1;
|
||||
PriceLabel.Text = "Цена";
|
||||
//
|
||||
// NameTextBox
|
||||
//
|
||||
NameTextBox.Location = new Point(77, 6);
|
||||
NameTextBox.Location = new Point(88, 8);
|
||||
NameTextBox.Margin = new Padding(3, 4, 3, 4);
|
||||
NameTextBox.Name = "NameTextBox";
|
||||
NameTextBox.Size = new Size(237, 23);
|
||||
NameTextBox.Size = new Size(270, 27);
|
||||
NameTextBox.TabIndex = 2;
|
||||
//
|
||||
// PriceTextBox
|
||||
//
|
||||
PriceTextBox.Location = new Point(77, 32);
|
||||
PriceTextBox.Location = new Point(88, 43);
|
||||
PriceTextBox.Margin = new Padding(3, 4, 3, 4);
|
||||
PriceTextBox.Name = "PriceTextBox";
|
||||
PriceTextBox.ReadOnly = true;
|
||||
PriceTextBox.Size = new Size(100, 23);
|
||||
PriceTextBox.Size = new Size(114, 27);
|
||||
PriceTextBox.TabIndex = 3;
|
||||
//
|
||||
// ComponentsGroupBox
|
||||
@ -87,18 +89,21 @@
|
||||
ComponentsGroupBox.Controls.Add(UpdateButton);
|
||||
ComponentsGroupBox.Controls.Add(AddButton);
|
||||
ComponentsGroupBox.Controls.Add(DataGridView);
|
||||
ComponentsGroupBox.Location = new Point(12, 64);
|
||||
ComponentsGroupBox.Location = new Point(14, 85);
|
||||
ComponentsGroupBox.Margin = new Padding(3, 4, 3, 4);
|
||||
ComponentsGroupBox.Name = "ComponentsGroupBox";
|
||||
ComponentsGroupBox.Size = new Size(582, 287);
|
||||
ComponentsGroupBox.Padding = new Padding(3, 4, 3, 4);
|
||||
ComponentsGroupBox.Size = new Size(665, 383);
|
||||
ComponentsGroupBox.TabIndex = 4;
|
||||
ComponentsGroupBox.TabStop = false;
|
||||
ComponentsGroupBox.Text = "Компоненты";
|
||||
//
|
||||
// RefreshButton
|
||||
//
|
||||
RefreshButton.Location = new Point(481, 109);
|
||||
RefreshButton.Location = new Point(550, 145);
|
||||
RefreshButton.Margin = new Padding(3, 4, 3, 4);
|
||||
RefreshButton.Name = "RefreshButton";
|
||||
RefreshButton.Size = new Size(75, 23);
|
||||
RefreshButton.Size = new Size(86, 31);
|
||||
RefreshButton.TabIndex = 4;
|
||||
RefreshButton.Text = "Обновить";
|
||||
RefreshButton.UseVisualStyleBackColor = true;
|
||||
@ -106,9 +111,10 @@
|
||||
//
|
||||
// DeleteButton
|
||||
//
|
||||
DeleteButton.Location = new Point(481, 80);
|
||||
DeleteButton.Location = new Point(550, 107);
|
||||
DeleteButton.Margin = new Padding(3, 4, 3, 4);
|
||||
DeleteButton.Name = "DeleteButton";
|
||||
DeleteButton.Size = new Size(75, 23);
|
||||
DeleteButton.Size = new Size(86, 31);
|
||||
DeleteButton.TabIndex = 3;
|
||||
DeleteButton.Text = "Удалить";
|
||||
DeleteButton.UseVisualStyleBackColor = true;
|
||||
@ -116,9 +122,10 @@
|
||||
//
|
||||
// UpdateButton
|
||||
//
|
||||
UpdateButton.Location = new Point(481, 51);
|
||||
UpdateButton.Location = new Point(550, 68);
|
||||
UpdateButton.Margin = new Padding(3, 4, 3, 4);
|
||||
UpdateButton.Name = "UpdateButton";
|
||||
UpdateButton.Size = new Size(75, 23);
|
||||
UpdateButton.Size = new Size(86, 31);
|
||||
UpdateButton.TabIndex = 2;
|
||||
UpdateButton.Text = "Изменить";
|
||||
UpdateButton.UseVisualStyleBackColor = true;
|
||||
@ -126,9 +133,10 @@
|
||||
//
|
||||
// AddButton
|
||||
//
|
||||
AddButton.Location = new Point(481, 22);
|
||||
AddButton.Location = new Point(550, 29);
|
||||
AddButton.Margin = new Padding(3, 4, 3, 4);
|
||||
AddButton.Name = "AddButton";
|
||||
AddButton.Size = new Size(75, 23);
|
||||
AddButton.Size = new Size(86, 31);
|
||||
AddButton.TabIndex = 1;
|
||||
AddButton.Text = "Добавить";
|
||||
AddButton.UseVisualStyleBackColor = true;
|
||||
@ -138,10 +146,11 @@
|
||||
//
|
||||
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
DataGridView.Columns.AddRange(new DataGridViewColumn[] { IdColumn, ComponentNameColumn, CountColumn });
|
||||
DataGridView.Location = new Point(6, 22);
|
||||
DataGridView.Location = new Point(7, 29);
|
||||
DataGridView.Margin = new Padding(3, 4, 3, 4);
|
||||
DataGridView.Name = "DataGridView";
|
||||
DataGridView.RowHeadersWidth = 51;
|
||||
DataGridView.Size = new Size(442, 259);
|
||||
DataGridView.Size = new Size(505, 345);
|
||||
DataGridView.TabIndex = 0;
|
||||
//
|
||||
// IdColumn
|
||||
@ -168,9 +177,10 @@
|
||||
//
|
||||
// SaveButton
|
||||
//
|
||||
SaveButton.Location = new Point(424, 363);
|
||||
SaveButton.Location = new Point(485, 484);
|
||||
SaveButton.Margin = new Padding(3, 4, 3, 4);
|
||||
SaveButton.Name = "SaveButton";
|
||||
SaveButton.Size = new Size(75, 23);
|
||||
SaveButton.Size = new Size(86, 31);
|
||||
SaveButton.TabIndex = 5;
|
||||
SaveButton.Text = "Сохранить";
|
||||
SaveButton.UseVisualStyleBackColor = true;
|
||||
@ -178,18 +188,19 @@
|
||||
//
|
||||
// CancelButton
|
||||
//
|
||||
CancelButton.Location = new Point(505, 363);
|
||||
CancelButton.Location = new Point(577, 484);
|
||||
CancelButton.Margin = new Padding(3, 4, 3, 4);
|
||||
CancelButton.Name = "CancelButton";
|
||||
CancelButton.Size = new Size(75, 23);
|
||||
CancelButton.Size = new Size(86, 31);
|
||||
CancelButton.TabIndex = 6;
|
||||
CancelButton.Text = "Отмена";
|
||||
CancelButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// IceCreamForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(606, 398);
|
||||
ClientSize = new Size(693, 531);
|
||||
Controls.Add(CancelButton);
|
||||
Controls.Add(SaveButton);
|
||||
Controls.Add(ComponentsGroupBox);
|
||||
@ -197,8 +208,9 @@
|
||||
Controls.Add(NameTextBox);
|
||||
Controls.Add(PriceLabel);
|
||||
Controls.Add(NameLabel);
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "IceCreamForm";
|
||||
Text = "Мороженное";
|
||||
Text = "Форма мороженного";
|
||||
Load += IceCreamForm_Load;
|
||||
ComponentsGroupBox.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).EndInit();
|
||||
|
@ -96,7 +96,7 @@
|
||||
Controls.Add(AddButton);
|
||||
Controls.Add(DataGridView);
|
||||
Name = "IceCreamsForm";
|
||||
Text = "IceCreamsForm";
|
||||
Text = "Форма мороженных";
|
||||
Load += IceCreamsForm_Load;
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
|
31
IceCreamShop/IceCreamShop/MainForm.Designer.cs
generated
31
IceCreamShop/IceCreamShop/MainForm.Designer.cs
generated
@ -32,6 +32,8 @@
|
||||
ToolStripMenu = new ToolStripMenuItem();
|
||||
КомпонентыStripMenuItem = new ToolStripMenuItem();
|
||||
МороженноеStripMenuItem = new ToolStripMenuItem();
|
||||
магазиныToolStripMenuItem = new ToolStripMenuItem();
|
||||
поставкиToolStripMenuItem = new ToolStripMenuItem();
|
||||
DataGridView = new DataGridView();
|
||||
CreateOrderButton = new Button();
|
||||
TakeInWorkButton = new Button();
|
||||
@ -48,13 +50,14 @@
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { ToolStripMenu });
|
||||
menuStrip1.Location = new Point(0, 0);
|
||||
menuStrip1.Name = "menuStrip1";
|
||||
menuStrip1.Size = new Size(1296, 28);
|
||||
menuStrip1.Padding = new Padding(6, 3, 0, 3);
|
||||
menuStrip1.Size = new Size(1296, 30);
|
||||
menuStrip1.TabIndex = 0;
|
||||
menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// ToolStripMenu
|
||||
//
|
||||
ToolStripMenu.DropDownItems.AddRange(new ToolStripItem[] { КомпонентыStripMenuItem, МороженноеStripMenuItem });
|
||||
ToolStripMenu.DropDownItems.AddRange(new ToolStripItem[] { КомпонентыStripMenuItem, МороженноеStripMenuItem, магазиныToolStripMenuItem, поставкиToolStripMenuItem });
|
||||
ToolStripMenu.Name = "ToolStripMenu";
|
||||
ToolStripMenu.Size = new Size(117, 24);
|
||||
ToolStripMenu.Text = "Справочники";
|
||||
@ -73,10 +76,24 @@
|
||||
МороженноеStripMenuItem.Text = "Мороженное";
|
||||
МороженноеStripMenuItem.Click += МороженноеStripMenuItem_Click;
|
||||
//
|
||||
// магазиныToolStripMenuItem
|
||||
//
|
||||
магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem";
|
||||
магазиныToolStripMenuItem.Size = new Size(186, 26);
|
||||
магазиныToolStripMenuItem.Text = "Магазины";
|
||||
магазиныToolStripMenuItem.Click += магазиныToolStripMenuItem_Click;
|
||||
//
|
||||
// поставкиToolStripMenuItem
|
||||
//
|
||||
поставкиToolStripMenuItem.Name = "поставкиToolStripMenuItem";
|
||||
поставкиToolStripMenuItem.Size = new Size(186, 26);
|
||||
поставкиToolStripMenuItem.Text = "Поставки";
|
||||
поставкиToolStripMenuItem.Click += поставкиToolStripMenuItem_Click;
|
||||
//
|
||||
// DataGridView
|
||||
//
|
||||
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
DataGridView.Location = new Point(12, 31);
|
||||
DataGridView.Location = new Point(11, 31);
|
||||
DataGridView.Name = "DataGridView";
|
||||
DataGridView.RowHeadersWidth = 51;
|
||||
DataGridView.Size = new Size(1007, 407);
|
||||
@ -94,7 +111,7 @@
|
||||
//
|
||||
// TakeInWorkButton
|
||||
//
|
||||
TakeInWorkButton.Location = new Point(1025, 66);
|
||||
TakeInWorkButton.Location = new Point(1025, 67);
|
||||
TakeInWorkButton.Name = "TakeInWorkButton";
|
||||
TakeInWorkButton.Size = new Size(259, 29);
|
||||
TakeInWorkButton.TabIndex = 3;
|
||||
@ -136,7 +153,7 @@
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1296, 450);
|
||||
ClientSize = new Size(1296, 451);
|
||||
Controls.Add(RefreshButton);
|
||||
Controls.Add(IssuedButton);
|
||||
Controls.Add(ReadyButton);
|
||||
@ -146,7 +163,7 @@
|
||||
Controls.Add(menuStrip1);
|
||||
MainMenuStrip = menuStrip1;
|
||||
Name = "MainForm";
|
||||
Text = "MainForm";
|
||||
Text = "Форма главная";
|
||||
Load += MainForm_Load;
|
||||
menuStrip1.ResumeLayout(false);
|
||||
menuStrip1.PerformLayout();
|
||||
@ -167,5 +184,7 @@
|
||||
private Button ReadyButton;
|
||||
private Button IssuedButton;
|
||||
private Button RefreshButton;
|
||||
private ToolStripMenuItem магазиныToolStripMenuItem;
|
||||
private ToolStripMenuItem поставкиToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -180,5 +180,23 @@ Program.ServiceProvider?.GetService(typeof(OrderForm));
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void магазиныToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(ShopsForm));
|
||||
if (service is ShopsForm form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void поставкиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(SupplyForm));
|
||||
if (service is SupplyForm form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
44
IceCreamShop/IceCreamShop/OrderForm.Designer.cs
generated
44
IceCreamShop/IceCreamShop/OrderForm.Designer.cs
generated
@ -41,34 +41,38 @@
|
||||
// IceCreamComboBox
|
||||
//
|
||||
IceCreamComboBox.FormattingEnabled = true;
|
||||
IceCreamComboBox.Location = new Point(103, 12);
|
||||
IceCreamComboBox.Location = new Point(118, 16);
|
||||
IceCreamComboBox.Margin = new Padding(3, 4, 3, 4);
|
||||
IceCreamComboBox.Name = "IceCreamComboBox";
|
||||
IceCreamComboBox.Size = new Size(232, 23);
|
||||
IceCreamComboBox.Size = new Size(265, 28);
|
||||
IceCreamComboBox.TabIndex = 0;
|
||||
IceCreamComboBox.SelectedIndexChanged += IceCreamComboBox_SelectedIndexChanged;
|
||||
//
|
||||
// CountTextBox
|
||||
//
|
||||
CountTextBox.Location = new Point(103, 41);
|
||||
CountTextBox.Location = new Point(118, 55);
|
||||
CountTextBox.Margin = new Padding(3, 4, 3, 4);
|
||||
CountTextBox.Name = "CountTextBox";
|
||||
CountTextBox.Size = new Size(232, 23);
|
||||
CountTextBox.Size = new Size(265, 27);
|
||||
CountTextBox.TabIndex = 1;
|
||||
CountTextBox.TextChanged += CountTextBox_TextChanged;
|
||||
//
|
||||
// SumTextBox
|
||||
//
|
||||
SumTextBox.Location = new Point(103, 70);
|
||||
SumTextBox.Location = new Point(118, 93);
|
||||
SumTextBox.Margin = new Padding(3, 4, 3, 4);
|
||||
SumTextBox.Name = "SumTextBox";
|
||||
SumTextBox.ReadOnly = true;
|
||||
SumTextBox.Size = new Size(232, 23);
|
||||
SumTextBox.Size = new Size(265, 27);
|
||||
SumTextBox.TabIndex = 2;
|
||||
SumTextBox.TextChanged += SumTextBox_TextChanged;
|
||||
//
|
||||
// SaveButton
|
||||
//
|
||||
SaveButton.Location = new Point(173, 99);
|
||||
SaveButton.Location = new Point(198, 132);
|
||||
SaveButton.Margin = new Padding(3, 4, 3, 4);
|
||||
SaveButton.Name = "SaveButton";
|
||||
SaveButton.Size = new Size(81, 23);
|
||||
SaveButton.Size = new Size(93, 31);
|
||||
SaveButton.TabIndex = 3;
|
||||
SaveButton.Text = "Сохранить";
|
||||
SaveButton.UseVisualStyleBackColor = true;
|
||||
@ -76,9 +80,10 @@
|
||||
//
|
||||
// CancelButton
|
||||
//
|
||||
CancelButton.Location = new Point(260, 99);
|
||||
CancelButton.Location = new Point(297, 132);
|
||||
CancelButton.Margin = new Padding(3, 4, 3, 4);
|
||||
CancelButton.Name = "CancelButton";
|
||||
CancelButton.Size = new Size(75, 23);
|
||||
CancelButton.Size = new Size(86, 31);
|
||||
CancelButton.TabIndex = 4;
|
||||
CancelButton.Text = "Отмена";
|
||||
CancelButton.UseVisualStyleBackColor = true;
|
||||
@ -87,35 +92,35 @@
|
||||
// IceCreamLabel
|
||||
//
|
||||
IceCreamLabel.AutoSize = true;
|
||||
IceCreamLabel.Location = new Point(12, 15);
|
||||
IceCreamLabel.Location = new Point(14, 20);
|
||||
IceCreamLabel.Name = "IceCreamLabel";
|
||||
IceCreamLabel.Size = new Size(81, 15);
|
||||
IceCreamLabel.Size = new Size(103, 20);
|
||||
IceCreamLabel.TabIndex = 5;
|
||||
IceCreamLabel.Text = "Мороженное";
|
||||
//
|
||||
// CountLabel
|
||||
//
|
||||
CountLabel.AutoSize = true;
|
||||
CountLabel.Location = new Point(12, 44);
|
||||
CountLabel.Location = new Point(14, 59);
|
||||
CountLabel.Name = "CountLabel";
|
||||
CountLabel.Size = new Size(72, 15);
|
||||
CountLabel.Size = new Size(90, 20);
|
||||
CountLabel.TabIndex = 6;
|
||||
CountLabel.Text = "Количество";
|
||||
//
|
||||
// SumLabel
|
||||
//
|
||||
SumLabel.AutoSize = true;
|
||||
SumLabel.Location = new Point(12, 73);
|
||||
SumLabel.Location = new Point(14, 97);
|
||||
SumLabel.Name = "SumLabel";
|
||||
SumLabel.Size = new Size(45, 15);
|
||||
SumLabel.Size = new Size(55, 20);
|
||||
SumLabel.TabIndex = 7;
|
||||
SumLabel.Text = "Сумма";
|
||||
//
|
||||
// OrderForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(348, 128);
|
||||
ClientSize = new Size(398, 171);
|
||||
Controls.Add(SumLabel);
|
||||
Controls.Add(CountLabel);
|
||||
Controls.Add(IceCreamLabel);
|
||||
@ -124,8 +129,9 @@
|
||||
Controls.Add(SumTextBox);
|
||||
Controls.Add(CountTextBox);
|
||||
Controls.Add(IceCreamComboBox);
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "OrderForm";
|
||||
Text = "OrderForm";
|
||||
Text = "Форма заказа";
|
||||
Load += OrderForm_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
|
@ -34,6 +34,8 @@ namespace IceCreamShop
|
||||
option.AddNLog("nlog.config");
|
||||
});
|
||||
services.AddTransient<IComponentStorage, ComponentStorage>();
|
||||
services.AddTransient<IShopStorage, ShopStorage>();
|
||||
services.AddTransient<IShopLogic, ShopLogic>();
|
||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||
services.AddTransient<IIceCreamStorage, IceCreamStorage>();
|
||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||
@ -46,6 +48,9 @@ namespace IceCreamShop
|
||||
services.AddTransient<IceCreamForm>();
|
||||
services.AddTransient<IceCreamComponentForm>();
|
||||
services.AddTransient<IceCreamsForm>();
|
||||
services.AddTransient<ShopForm>();
|
||||
services.AddTransient<ShopsForm>();
|
||||
services.AddTransient<SupplyForm>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
202
IceCreamShop/IceCreamShop/ShopForm.Designer.cs
generated
Normal file
202
IceCreamShop/IceCreamShop/ShopForm.Designer.cs
generated
Normal file
@ -0,0 +1,202 @@
|
||||
namespace IceCreamShop
|
||||
{
|
||||
partial class ShopForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
DateTimePicker = new DateTimePicker();
|
||||
NameTextBox = new TextBox();
|
||||
AddressTextBox = new TextBox();
|
||||
NameLabel = new Label();
|
||||
AdressLabel = new Label();
|
||||
DateLabel = new Label();
|
||||
SaveButton = new Button();
|
||||
CancelButton = new Button();
|
||||
DataGridView = new DataGridView();
|
||||
Column1 = new DataGridViewTextBoxColumn();
|
||||
Название = new DataGridViewTextBoxColumn();
|
||||
Цена = new DataGridViewTextBoxColumn();
|
||||
Количество = new DataGridViewTextBoxColumn();
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// DateTimePicker
|
||||
//
|
||||
DateTimePicker.Location = new Point(97, 93);
|
||||
DateTimePicker.Margin = new Padding(3, 4, 3, 4);
|
||||
DateTimePicker.Name = "DateTimePicker";
|
||||
DateTimePicker.Size = new Size(363, 27);
|
||||
DateTimePicker.TabIndex = 0;
|
||||
//
|
||||
// NameTextBox
|
||||
//
|
||||
NameTextBox.Location = new Point(97, 16);
|
||||
NameTextBox.Margin = new Padding(3, 4, 3, 4);
|
||||
NameTextBox.Name = "NameTextBox";
|
||||
NameTextBox.Size = new Size(363, 27);
|
||||
NameTextBox.TabIndex = 1;
|
||||
//
|
||||
// AddressTextBox
|
||||
//
|
||||
AddressTextBox.Location = new Point(97, 55);
|
||||
AddressTextBox.Margin = new Padding(3, 4, 3, 4);
|
||||
AddressTextBox.Name = "AddressTextBox";
|
||||
AddressTextBox.Size = new Size(363, 27);
|
||||
AddressTextBox.TabIndex = 2;
|
||||
//
|
||||
// NameLabel
|
||||
//
|
||||
NameLabel.AutoSize = true;
|
||||
NameLabel.Location = new Point(14, 20);
|
||||
NameLabel.Name = "NameLabel";
|
||||
NameLabel.Size = new Size(77, 20);
|
||||
NameLabel.TabIndex = 3;
|
||||
NameLabel.Text = "Название";
|
||||
//
|
||||
// AdressLabel
|
||||
//
|
||||
AdressLabel.AutoSize = true;
|
||||
AdressLabel.Location = new Point(14, 59);
|
||||
AdressLabel.Name = "AdressLabel";
|
||||
AdressLabel.Size = new Size(51, 20);
|
||||
AdressLabel.TabIndex = 4;
|
||||
AdressLabel.Text = "Адрес";
|
||||
//
|
||||
// DateLabel
|
||||
//
|
||||
DateLabel.AutoSize = true;
|
||||
DateLabel.Location = new Point(14, 101);
|
||||
DateLabel.Name = "DateLabel";
|
||||
DateLabel.Size = new Size(41, 20);
|
||||
DateLabel.TabIndex = 5;
|
||||
DateLabel.Text = "Дата";
|
||||
//
|
||||
// SaveButton
|
||||
//
|
||||
SaveButton.Location = new Point(282, 340);
|
||||
SaveButton.Margin = new Padding(3, 4, 3, 4);
|
||||
SaveButton.Name = "SaveButton";
|
||||
SaveButton.Size = new Size(86, 31);
|
||||
SaveButton.TabIndex = 6;
|
||||
SaveButton.Text = "Сохранить";
|
||||
SaveButton.UseVisualStyleBackColor = true;
|
||||
SaveButton.Click += SaveButton_Click;
|
||||
//
|
||||
// CancelButton
|
||||
//
|
||||
CancelButton.Location = new Point(375, 340);
|
||||
CancelButton.Margin = new Padding(3, 4, 3, 4);
|
||||
CancelButton.Name = "CancelButton";
|
||||
CancelButton.Size = new Size(86, 31);
|
||||
CancelButton.TabIndex = 7;
|
||||
CancelButton.Text = "Отмена";
|
||||
CancelButton.UseVisualStyleBackColor = true;
|
||||
CancelButton.Click += CancelButton_Click;
|
||||
//
|
||||
// DataGridView
|
||||
//
|
||||
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
DataGridView.Columns.AddRange(new DataGridViewColumn[] { Column1, Название, Цена, Количество });
|
||||
DataGridView.Location = new Point(14, 132);
|
||||
DataGridView.Margin = new Padding(3, 4, 3, 4);
|
||||
DataGridView.Name = "DataGridView";
|
||||
DataGridView.RowHeadersWidth = 51;
|
||||
DataGridView.Size = new Size(447, 200);
|
||||
DataGridView.TabIndex = 8;
|
||||
//
|
||||
// Column1
|
||||
//
|
||||
Column1.HeaderText = "Column1";
|
||||
Column1.MinimumWidth = 6;
|
||||
Column1.Name = "Column1";
|
||||
Column1.Visible = false;
|
||||
Column1.Width = 125;
|
||||
//
|
||||
// Название
|
||||
//
|
||||
Название.HeaderText = "Название";
|
||||
Название.MinimumWidth = 6;
|
||||
Название.Name = "Название";
|
||||
Название.ReadOnly = true;
|
||||
Название.Width = 150;
|
||||
//
|
||||
// Цена
|
||||
//
|
||||
Цена.HeaderText = "Цена";
|
||||
Цена.MinimumWidth = 6;
|
||||
Цена.Name = "Цена";
|
||||
Цена.ReadOnly = true;
|
||||
Цена.Width = 125;
|
||||
//
|
||||
// Количество
|
||||
//
|
||||
Количество.HeaderText = "Количество";
|
||||
Количество.MinimumWidth = 6;
|
||||
Количество.Name = "Количество";
|
||||
Количество.ReadOnly = true;
|
||||
Количество.Width = 125;
|
||||
//
|
||||
// ShopForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(470, 380);
|
||||
Controls.Add(DataGridView);
|
||||
Controls.Add(CancelButton);
|
||||
Controls.Add(SaveButton);
|
||||
Controls.Add(DateLabel);
|
||||
Controls.Add(AdressLabel);
|
||||
Controls.Add(NameLabel);
|
||||
Controls.Add(AddressTextBox);
|
||||
Controls.Add(NameTextBox);
|
||||
Controls.Add(DateTimePicker);
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "ShopForm";
|
||||
Text = "Форма магазина";
|
||||
Load += ShopForm_Load;
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DateTimePicker DateTimePicker;
|
||||
private TextBox NameTextBox;
|
||||
private TextBox AddressTextBox;
|
||||
private Label NameLabel;
|
||||
private Label AdressLabel;
|
||||
private Label DateLabel;
|
||||
private Button SaveButton;
|
||||
private Button CancelButton;
|
||||
private DataGridView DataGridView;
|
||||
private DataGridViewTextBoxColumn Column1;
|
||||
private DataGridViewTextBoxColumn Название;
|
||||
private DataGridViewTextBoxColumn Цена;
|
||||
private DataGridViewTextBoxColumn Количество;
|
||||
}
|
||||
}
|
124
IceCreamShop/IceCreamShop/ShopForm.cs
Normal file
124
IceCreamShop/IceCreamShop/ShopForm.cs
Normal file
@ -0,0 +1,124 @@
|
||||
using IceCreamShopContracts.BindingModels;
|
||||
using IceCreamShopContracts.BusinessLogicsContracts;
|
||||
using IceCreamShopContracts.SearchModels;
|
||||
using IceCreamShopDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace IceCreamShop
|
||||
{
|
||||
public partial class ShopForm : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IShopLogic _logic;
|
||||
public int? _id;
|
||||
private Dictionary<int, (IIceCreamModel, int)> _iceCreams;
|
||||
public ShopForm(ILogger<ShopForm> logger, IShopLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void ShopForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
_logger.LogInformation("Загрузка магазина");
|
||||
try
|
||||
{
|
||||
var shop = _logic.ReadElement(new ShopSearchModel { Id = _id });
|
||||
if (shop != null)
|
||||
{
|
||||
NameTextBox.Text = shop.ShopName;
|
||||
AddressTextBox.Text = shop.Address;
|
||||
DateTimePicker.Text = shop.DateOpen.ToString();
|
||||
_iceCreams = shop.ShopIceCreams;
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка товаров магазина");
|
||||
try
|
||||
{
|
||||
if (_iceCreams != null)
|
||||
{
|
||||
foreach (var iceCream in _iceCreams)
|
||||
{
|
||||
DataGridView.Rows.Add(new object[] { iceCream.Key, iceCream.Value.Item1.IceCreamName, iceCream.Value.Item1.Price, iceCream.Value.Item2 });
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки изделий магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void CancelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void SaveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(NameTextBox.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(AddressTextBox.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Сохранение магазина");
|
||||
try
|
||||
{
|
||||
var model = new ShopBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
ShopName = NameTextBox.Text,
|
||||
Address = AddressTextBox.Text,
|
||||
DateOpen = DateTimePicker.Value.Date,
|
||||
ShopIceCreams = _iceCreams
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
132
IceCreamShop/IceCreamShop/ShopForm.resx
Normal file
132
IceCreamShop/IceCreamShop/ShopForm.resx
Normal file
@ -0,0 +1,132 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="Column1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Название.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Цена.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Количество.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
124
IceCreamShop/IceCreamShop/ShopsForm.Designer.cs
generated
Normal file
124
IceCreamShop/IceCreamShop/ShopsForm.Designer.cs
generated
Normal file
@ -0,0 +1,124 @@
|
||||
namespace IceCreamShop
|
||||
{
|
||||
partial class ShopsForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
DataGridView = new DataGridView();
|
||||
AddButton = new Button();
|
||||
UpdateButton = new Button();
|
||||
RefreshButton = new Button();
|
||||
DeleteButton = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// DataGridView
|
||||
//
|
||||
DataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
DataGridView.Location = new Point(14, 16);
|
||||
DataGridView.Margin = new Padding(3, 4, 3, 4);
|
||||
DataGridView.Name = "DataGridView";
|
||||
DataGridView.RowHeadersWidth = 51;
|
||||
DataGridView.Size = new Size(449, 499);
|
||||
DataGridView.TabIndex = 0;
|
||||
//
|
||||
// AddButton
|
||||
//
|
||||
AddButton.Location = new Point(470, 16);
|
||||
AddButton.Margin = new Padding(3, 4, 3, 4);
|
||||
AddButton.Name = "AddButton";
|
||||
AddButton.Size = new Size(130, 31);
|
||||
AddButton.TabIndex = 1;
|
||||
AddButton.Text = "Добавить";
|
||||
AddButton.UseVisualStyleBackColor = true;
|
||||
AddButton.Click += AddButton_Click;
|
||||
//
|
||||
// UpdateButton
|
||||
//
|
||||
UpdateButton.Location = new Point(470, 55);
|
||||
UpdateButton.Margin = new Padding(3, 4, 3, 4);
|
||||
UpdateButton.Name = "UpdateButton";
|
||||
UpdateButton.Size = new Size(130, 31);
|
||||
UpdateButton.TabIndex = 2;
|
||||
UpdateButton.Text = "Изменить";
|
||||
UpdateButton.UseVisualStyleBackColor = true;
|
||||
UpdateButton.Click += UpdateButton_Click;
|
||||
//
|
||||
// RefreshButton
|
||||
//
|
||||
RefreshButton.Location = new Point(470, 93);
|
||||
RefreshButton.Margin = new Padding(3, 4, 3, 4);
|
||||
RefreshButton.Name = "RefreshButton";
|
||||
RefreshButton.Size = new Size(130, 31);
|
||||
RefreshButton.TabIndex = 3;
|
||||
RefreshButton.Text = "Обновить";
|
||||
RefreshButton.UseVisualStyleBackColor = true;
|
||||
RefreshButton.Click += RefreshButton_Click;
|
||||
//
|
||||
// DeleteButton
|
||||
//
|
||||
DeleteButton.Location = new Point(470, 132);
|
||||
DeleteButton.Margin = new Padding(3, 4, 3, 4);
|
||||
DeleteButton.Name = "DeleteButton";
|
||||
DeleteButton.Size = new Size(130, 31);
|
||||
DeleteButton.TabIndex = 4;
|
||||
DeleteButton.Text = "Удалить";
|
||||
DeleteButton.UseVisualStyleBackColor = true;
|
||||
DeleteButton.Click += DeleteButton_Click;
|
||||
//
|
||||
// ShopsForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(616, 537);
|
||||
Controls.Add(DeleteButton);
|
||||
Controls.Add(RefreshButton);
|
||||
Controls.Add(UpdateButton);
|
||||
Controls.Add(AddButton);
|
||||
Controls.Add(DataGridView);
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "ShopsForm";
|
||||
Text = "Форма магазинов";
|
||||
Load += ShopsForm_Load;
|
||||
((System.ComponentModel.ISupportInitialize)DataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView DataGridView;
|
||||
private Button AddButton;
|
||||
private Button UpdateButton;
|
||||
private Button RefreshButton;
|
||||
private Button DeleteButton;
|
||||
private DataGridViewTextBoxColumn Column1;
|
||||
private DataGridViewTextBoxColumn Column2;
|
||||
private DataGridViewTextBoxColumn Column3;
|
||||
private DataGridViewTextBoxColumn Column4;
|
||||
private DataGridViewTextBoxColumn Column5;
|
||||
}
|
||||
}
|
118
IceCreamShop/IceCreamShop/ShopsForm.cs
Normal file
118
IceCreamShop/IceCreamShop/ShopsForm.cs
Normal file
@ -0,0 +1,118 @@
|
||||
using IceCreamShopContracts.BindingModels;
|
||||
using IceCreamShopContracts.BusinessLogicsContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace IceCreamShop
|
||||
{
|
||||
public partial class ShopsForm : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IShopLogic _logic;
|
||||
public ShopsForm(ILogger<ShopsForm> logger, IShopLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
DataGridView.DataSource = list;
|
||||
DataGridView.Columns["Id"].Visible = false;
|
||||
DataGridView.Columns["ShopName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
DataGridView.Columns["Address"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
DataGridView.Columns["DateOpen"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
DataGridView.Columns["ShopIceCreams"].Visible = false;
|
||||
}
|
||||
_logger.LogInformation("Загрузка магазинов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки магазинов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ShopsForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void AddButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(ShopForm));
|
||||
if (service is ShopForm form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (DataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(ShopForm));
|
||||
if (service is ShopForm form)
|
||||
{
|
||||
var tmp = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
form._id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void DeleteButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (DataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Удаление магазина");
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new ShopBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
IceCreamShop/IceCreamShop/ShopsForm.resx
Normal file
120
IceCreamShop/IceCreamShop/ShopsForm.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
111
IceCreamShop/IceCreamShop/SupplyForm.Designer.cs
generated
Normal file
111
IceCreamShop/IceCreamShop/SupplyForm.Designer.cs
generated
Normal file
@ -0,0 +1,111 @@
|
||||
namespace IceCreamShop
|
||||
{
|
||||
partial class SupplyForm
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
ShopComboBox = new ComboBox();
|
||||
IceCreamComboBox = new ComboBox();
|
||||
CountTextBox = new TextBox();
|
||||
SaveButton = new Button();
|
||||
CancelButton = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// ShopComboBox
|
||||
//
|
||||
ShopComboBox.FormattingEnabled = true;
|
||||
ShopComboBox.Location = new Point(14, 16);
|
||||
ShopComboBox.Margin = new Padding(3, 4, 3, 4);
|
||||
ShopComboBox.Name = "ShopComboBox";
|
||||
ShopComboBox.Size = new Size(378, 28);
|
||||
ShopComboBox.TabIndex = 0;
|
||||
//
|
||||
// IceCreamComboBox
|
||||
//
|
||||
IceCreamComboBox.FormattingEnabled = true;
|
||||
IceCreamComboBox.Location = new Point(14, 55);
|
||||
IceCreamComboBox.Margin = new Padding(3, 4, 3, 4);
|
||||
IceCreamComboBox.Name = "IceCreamComboBox";
|
||||
IceCreamComboBox.Size = new Size(378, 28);
|
||||
IceCreamComboBox.TabIndex = 1;
|
||||
//
|
||||
// CountTextBox
|
||||
//
|
||||
CountTextBox.Location = new Point(14, 93);
|
||||
CountTextBox.Margin = new Padding(3, 4, 3, 4);
|
||||
CountTextBox.Name = "CountTextBox";
|
||||
CountTextBox.Size = new Size(378, 27);
|
||||
CountTextBox.TabIndex = 2;
|
||||
//
|
||||
// SaveButton
|
||||
//
|
||||
SaveButton.Location = new Point(214, 132);
|
||||
SaveButton.Margin = new Padding(3, 4, 3, 4);
|
||||
SaveButton.Name = "SaveButton";
|
||||
SaveButton.Size = new Size(86, 31);
|
||||
SaveButton.TabIndex = 3;
|
||||
SaveButton.Text = "Сохранить";
|
||||
SaveButton.UseVisualStyleBackColor = true;
|
||||
SaveButton.Click += SaveButton_Click;
|
||||
//
|
||||
// CancelButton
|
||||
//
|
||||
CancelButton.Location = new Point(306, 132);
|
||||
CancelButton.Margin = new Padding(3, 4, 3, 4);
|
||||
CancelButton.Name = "CancelButton";
|
||||
CancelButton.Size = new Size(86, 31);
|
||||
CancelButton.TabIndex = 4;
|
||||
CancelButton.Text = "Отмена";
|
||||
CancelButton.UseVisualStyleBackColor = true;
|
||||
CancelButton.Click += CancelButton_Click;
|
||||
//
|
||||
// SupplyForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(406, 181);
|
||||
Controls.Add(CancelButton);
|
||||
Controls.Add(SaveButton);
|
||||
Controls.Add(CountTextBox);
|
||||
Controls.Add(IceCreamComboBox);
|
||||
Controls.Add(ShopComboBox);
|
||||
Margin = new Padding(3, 4, 3, 4);
|
||||
Name = "SupplyForm";
|
||||
Text = "Форма поставок";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ComboBox ShopComboBox;
|
||||
private ComboBox IceCreamComboBox;
|
||||
private TextBox CountTextBox;
|
||||
private Button SaveButton;
|
||||
private Button CancelButton;
|
||||
}
|
||||
}
|
153
IceCreamShop/IceCreamShop/SupplyForm.cs
Normal file
153
IceCreamShop/IceCreamShop/SupplyForm.cs
Normal file
@ -0,0 +1,153 @@
|
||||
using IceCreamShopBusinessLogic.BusinessLogic;
|
||||
using IceCreamShopContracts.BusinessLogicsContracts;
|
||||
using IceCreamShopContracts.SearchModels;
|
||||
using IceCreamShopContracts.ViewModels;
|
||||
using IceCreamShopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace IceCreamShop
|
||||
{
|
||||
public partial class SupplyForm : Form
|
||||
{
|
||||
private readonly List<IceCreamViewModel>? _iceCreamList;
|
||||
private readonly List<ShopViewModel>? _shopsList;
|
||||
IShopLogic _shopLogic;
|
||||
IIceCreamLogic _iceCreamLogic;
|
||||
public int ShopId
|
||||
{
|
||||
get
|
||||
{
|
||||
return
|
||||
Convert.ToInt32(ShopComboBox.SelectedValue);
|
||||
}
|
||||
set
|
||||
{
|
||||
ShopComboBox.SelectedValue = value;
|
||||
}
|
||||
}
|
||||
public int IceCreamId
|
||||
{
|
||||
get
|
||||
{
|
||||
return
|
||||
Convert.ToInt32(IceCreamComboBox.SelectedValue);
|
||||
}
|
||||
set
|
||||
{
|
||||
IceCreamComboBox.SelectedValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
public IIceCreamModel? IceCreamModel
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_iceCreamList == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var elem in _iceCreamList)
|
||||
{
|
||||
if (elem.Id == IceCreamId)
|
||||
{
|
||||
return elem;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int Count
|
||||
{
|
||||
get { return Convert.ToInt32(CountTextBox.Text); }
|
||||
set
|
||||
{ CountTextBox.Text = value.ToString(); }
|
||||
}
|
||||
public SupplyForm(IIceCreamLogic iceCreamLogic, IShopLogic shopLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_shopLogic = shopLogic;
|
||||
_iceCreamLogic = iceCreamLogic;
|
||||
_iceCreamList = iceCreamLogic.ReadList(null);
|
||||
_shopsList = shopLogic.ReadList(null);
|
||||
if (_iceCreamList != null)
|
||||
{
|
||||
IceCreamComboBox.DisplayMember = "IceCreamName";
|
||||
IceCreamComboBox.ValueMember = "Id";
|
||||
IceCreamComboBox.DataSource = _iceCreamList;
|
||||
IceCreamComboBox.SelectedItem = null;
|
||||
}
|
||||
if (_shopsList != null)
|
||||
{
|
||||
ShopComboBox.DisplayMember = "ShopName";
|
||||
ShopComboBox.ValueMember = "Id";
|
||||
ShopComboBox.DataSource = _shopsList;
|
||||
ShopComboBox.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(CountTextBox.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните поле Количество", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (IceCreamComboBox.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите мороженное", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (ShopComboBox.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите магазин", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
int count = Convert.ToInt32(CountTextBox.Text);
|
||||
|
||||
bool res = _shopLogic.MakeSupply(
|
||||
new ShopSearchModel() { Id = Convert.ToInt32(ShopComboBox.SelectedValue) },
|
||||
_iceCreamLogic.ReadElement(new() { Id = Convert.ToInt32(IceCreamComboBox.SelectedValue) }),
|
||||
count
|
||||
);
|
||||
|
||||
if (!res)
|
||||
{
|
||||
throw new Exception("Ошибка при пополнении. Дополнительная информация в логах");
|
||||
}
|
||||
|
||||
MessageBox.Show("Пополнение прошло успешно");
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
MessageBox.Show("Ошибка пополнения");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void CancelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
IceCreamShop/IceCreamShop/SupplyForm.resx
Normal file
120
IceCreamShop/IceCreamShop/SupplyForm.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -0,0 +1,162 @@
|
||||
using IceCreamShopContracts.BindingModels;
|
||||
using IceCreamShopContracts.BusinessLogicsContracts;
|
||||
using IceCreamShopContracts.SearchModels;
|
||||
using IceCreamShopContracts.StoragesContracts;
|
||||
using IceCreamShopContracts.ViewModels;
|
||||
using IceCreamShopDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IceCreamShopBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class ShopLogic : IShopLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IShopStorage _shopStorage;
|
||||
|
||||
public ShopLogic(ILogger<ShopLogic> logger, IShopStorage shopStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_shopStorage = shopStorage;
|
||||
}
|
||||
|
||||
public List<ShopViewModel> ReadList(ShopSearchModel model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. ShopName:{Name}. Id:{ Id}", model?.Name, model?.Id);
|
||||
var list = model == null ? _shopStorage.GetFullList() :
|
||||
_shopStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
|
||||
}
|
||||
|
||||
public bool MakeSupply(ShopSearchModel model, IIceCreamModel iceCream, int count)
|
||||
{
|
||||
|
||||
if (model == null)
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
if (iceCream == null)
|
||||
throw new ArgumentNullException(nameof(iceCream));
|
||||
if (count <= 0)
|
||||
throw new ArgumentNullException("Количество должно быть положительным числом");
|
||||
|
||||
ShopViewModel curModel = _shopStorage.GetElement(model);
|
||||
if (curModel == null)
|
||||
throw new ArgumentNullException(nameof(curModel));
|
||||
if (curModel.ShopIceCreams.TryGetValue(iceCream.Id, out var pair))
|
||||
{
|
||||
curModel.ShopIceCreams[iceCream.Id] = (pair.Item1, pair.Item2 + count);
|
||||
}
|
||||
else
|
||||
{
|
||||
curModel.ShopIceCreams.Add(iceCream.Id, (iceCream, count));
|
||||
}
|
||||
Update(new()
|
||||
{
|
||||
Id = curModel.Id,
|
||||
ShopName = curModel.ShopName,
|
||||
DateOpen = curModel.DateOpen,
|
||||
Address = curModel.Address,
|
||||
ShopIceCreams = curModel.ShopIceCreams,
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
public ShopViewModel ReadElement(ShopSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. ShopName:{ShopName}.Id:{ Id}", model.Name, model.Id);
|
||||
var element = _shopStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
|
||||
public bool Create(ShopBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_shopStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(ShopBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_shopStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(ShopBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_shopStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(ShopBindingModel model, bool withParams =
|
||||
true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.ShopName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия магазина",
|
||||
nameof(model.ShopName));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Address))
|
||||
{
|
||||
throw new ArgumentNullException("Нет адресса магазина",
|
||||
nameof(model.ShopName));
|
||||
}
|
||||
if(model.DateOpen == null)
|
||||
{
|
||||
throw new ArgumentNullException("Нет даты открытия магазина",
|
||||
nameof(model.ShopName));
|
||||
}
|
||||
_logger.LogInformation("Shop. ShopName:{ShopName}.Address:{Address}. DateOpen:{DateOpen}. Id: { Id}", model.ShopName, model.Address, model.DateOpen, model.Id);
|
||||
var element = _shopStorage.GetElement(new ShopSearchModel
|
||||
{
|
||||
Name = model.ShopName
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
using IceCreamShopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IceCreamShopContracts.BindingModels
|
||||
{
|
||||
public class ShopBindingModel : IShopModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ShopName { get; set; }
|
||||
public string Address { get; set; }
|
||||
public DateTime DateOpen { get; set; }
|
||||
public Dictionary<int, (IIceCreamModel, int)> ShopIceCreams { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using IceCreamShopContracts.BindingModels;
|
||||
using IceCreamShopContracts.SearchModels;
|
||||
using IceCreamShopContracts.ViewModels;
|
||||
using IceCreamShopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IceCreamShopContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IShopLogic
|
||||
{
|
||||
List<ShopViewModel>? ReadList(ShopSearchModel? model);
|
||||
ShopViewModel? ReadElement(ShopSearchModel model);
|
||||
bool Create(ShopBindingModel model);
|
||||
bool Update(ShopBindingModel model);
|
||||
bool Delete(ShopBindingModel model);
|
||||
bool MakeSupply(ShopSearchModel model, IIceCreamModel iceCream, int count);
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using IceCreamShopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IceCreamShopContracts.SearchModels
|
||||
{
|
||||
public class ShopSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using IceCreamShopContracts.BindingModels;
|
||||
using IceCreamShopContracts.SearchModels;
|
||||
using IceCreamShopContracts.ViewModels;
|
||||
using IceCreamShopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IceCreamShopContracts.StoragesContracts
|
||||
{
|
||||
public interface IShopStorage
|
||||
{
|
||||
List<ShopViewModel> GetFullList();
|
||||
List<ShopViewModel> GetFilteredList(ShopSearchModel model);
|
||||
ShopViewModel? GetElement(ShopSearchModel model);
|
||||
ShopViewModel? Insert(ShopBindingModel model);
|
||||
ShopViewModel? Update(ShopBindingModel model);
|
||||
ShopViewModel? Delete(ShopBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using IceCreamShopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IceCreamShopContracts.ViewModels
|
||||
{
|
||||
public class ShopViewModel : IShopModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название магазина")]
|
||||
public string ShopName { get; set; }
|
||||
[DisplayName("Адрес магазина")]
|
||||
public string Address { get; set; }
|
||||
[DisplayName("Дата открытия")]
|
||||
public DateTime DateOpen { get; set; }
|
||||
public Dictionary<int, (IIceCreamModel, int)> ShopIceCreams { get; set; } = new();
|
||||
}
|
||||
}
|
16
IceCreamShop/IceCreamShopDataModels/IShopModel.cs
Normal file
16
IceCreamShop/IceCreamShopDataModels/IShopModel.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IceCreamShopDataModels.Models
|
||||
{
|
||||
public interface IShopModel : IId
|
||||
{
|
||||
string ShopName { get; }
|
||||
string Address { get; }
|
||||
DateTime DateOpen { get; }
|
||||
Dictionary<int, (IIceCreamModel, int)> ShopIceCreams { get; }
|
||||
}
|
||||
}
|
@ -13,11 +13,13 @@ namespace IceCreamShopListImplement
|
||||
public List<Component> Components { get; set; }
|
||||
public List<Order> Orders { get; set; }
|
||||
public List<IceCream> IceCreams { get; set; }
|
||||
public List<Shop> Shops { get; set; }
|
||||
private DataListSingleton()
|
||||
{
|
||||
Components = new List<Component>();
|
||||
Orders = new List<Order>();
|
||||
IceCreams = new List<IceCream>();
|
||||
Shops = new List<Shop>();
|
||||
}
|
||||
public static DataListSingleton GetInstance()
|
||||
{
|
||||
|
110
IceCreamShop/IceCreamShopListImplement/Implements/ShopStorage.cs
Normal file
110
IceCreamShop/IceCreamShopListImplement/Implements/ShopStorage.cs
Normal file
@ -0,0 +1,110 @@
|
||||
using IceCreamShopContracts.BindingModels;
|
||||
using IceCreamShopContracts.SearchModels;
|
||||
using IceCreamShopContracts.StoragesContracts;
|
||||
using IceCreamShopContracts.ViewModels;
|
||||
using IceCreamShopDataModels.Models;
|
||||
using IceCreamShopListImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace IceCreamShopListImplement.Implements
|
||||
{
|
||||
public class ShopStorage : IShopStorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
public ShopStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
public List<ShopViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<ShopViewModel>();
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
result.Add(shop.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<ShopViewModel> GetFilteredList(ShopSearchModel
|
||||
model)
|
||||
{
|
||||
var result = new List<ShopViewModel>();
|
||||
if (string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if (shop.ShopName.Contains(model.Name))
|
||||
{
|
||||
result.Add(shop.GetViewModel);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if ((!string.IsNullOrEmpty(model.Name) &&
|
||||
shop.ShopName == model.Name) ||
|
||||
(model.Id.HasValue && shop.Id == model.Id))
|
||||
{
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public ShopViewModel? Insert(ShopBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if (model.Id <= shop.Id)
|
||||
{
|
||||
model.Id = shop.Id + 1;
|
||||
}
|
||||
}
|
||||
var newShop = Shop.Create(model);
|
||||
if (newShop == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.Shops.Add(newShop);
|
||||
return newShop.GetViewModel;
|
||||
}
|
||||
public ShopViewModel? Update(ShopBindingModel model)
|
||||
{
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if (shop.Id == model.Id)
|
||||
{
|
||||
shop.Update(model);
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public ShopViewModel? Delete(ShopBindingModel model)
|
||||
{
|
||||
for (int i = 0; i < _source.Shops.Count; ++i)
|
||||
{
|
||||
if (_source.Shops[i].Id == model.Id)
|
||||
{
|
||||
var element = _source.Shops[i];
|
||||
_source.Shops.RemoveAt(i);
|
||||
return element.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -46,12 +46,7 @@ namespace IceCreamShopListImplement.Models
|
||||
{
|
||||
return;
|
||||
}
|
||||
Id = model.Id;
|
||||
IceCreamId = model.IceCreamId;
|
||||
Count = model.Count;
|
||||
Sum = model.Sum;
|
||||
Status = model.Status;
|
||||
DateCreate = model.DateCreate;
|
||||
DateImplement = model.DateImplement;
|
||||
}
|
||||
public OrderViewModel GetViewModel => new()
|
||||
|
56
IceCreamShop/IceCreamShopListImplement/Models/Shop.cs
Normal file
56
IceCreamShop/IceCreamShopListImplement/Models/Shop.cs
Normal file
@ -0,0 +1,56 @@
|
||||
using IceCreamShopContracts.BindingModels;
|
||||
using IceCreamShopContracts.ViewModels;
|
||||
using IceCreamShopDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace IceCreamShopListImplement.Models
|
||||
{
|
||||
public class Shop : IShopModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string ShopName { get; private set; }
|
||||
public string Address { get; private set; }
|
||||
public DateTime DateOpen { get; private set; }
|
||||
public Dictionary<int, (IIceCreamModel, int)> ShopIceCreams { get; private set; } = new();
|
||||
|
||||
public static Shop? Create (ShopBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
return null;
|
||||
return new Shop()
|
||||
{
|
||||
Id = model.Id,
|
||||
ShopName = model.ShopName,
|
||||
Address = model.Address,
|
||||
DateOpen = model.DateOpen,
|
||||
ShopIceCreams = new()
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(ShopBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ShopName = model.ShopName;
|
||||
Address = model.Address;
|
||||
DateOpen = model.DateOpen;
|
||||
ShopIceCreams = model.ShopIceCreams;
|
||||
}
|
||||
|
||||
public ShopViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ShopName = ShopName,
|
||||
Address = Address,
|
||||
DateOpen = DateOpen,
|
||||
ShopIceCreams = ShopIceCreams
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user