diff --git a/SushiBar/FormMain.Designer.cs b/SushiBar/FormMain.Designer.cs index 52e8ee4..31b3a22 100644 --- a/SushiBar/FormMain.Designer.cs +++ b/SushiBar/FormMain.Designer.cs @@ -36,6 +36,7 @@ списокКомпонентовToolStripMenuItem = new ToolStripMenuItem(); компонентыПоИзделиямToolStripMenuItem = new ToolStripMenuItem(); списокЗаказовToolStripMenuItem = new ToolStripMenuItem(); + клиентыToolStripMenuItem = new ToolStripMenuItem(); dataGridView = new DataGridView(); buttonCreateOrder = new Button(); buttonTakeOrderInWork = new Button(); @@ -49,7 +50,7 @@ // menuStrip1 // menuStrip1.ImageScalingSize = new Size(20, 20); - menuStrip1.Items.AddRange(new ToolStripItem[] { ToolStripMenuItemRef, отчетыToolStripMenuItem }); + menuStrip1.Items.AddRange(new ToolStripItem[] { ToolStripMenuItemRef, отчетыToolStripMenuItem, клиентыToolStripMenuItem }); menuStrip1.Location = new Point(0, 0); menuStrip1.Name = "menuStrip1"; menuStrip1.Size = new Size(1140, 28); @@ -105,6 +106,13 @@ списокЗаказовToolStripMenuItem.Text = "Список заказов"; списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click; // + // клиентыToolStripMenuItem + // + клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem"; + клиентыToolStripMenuItem.Size = new Size(83, 24); + клиентыToolStripMenuItem.Text = "Клиенты"; + клиентыToolStripMenuItem.Click += клиентыToolStripMenuItem_Click; + // // dataGridView // dataGridView.BackgroundColor = Color.White; @@ -206,5 +214,6 @@ private ToolStripMenuItem списокКомпонентовToolStripMenuItem; private ToolStripMenuItem компонентыПоИзделиямToolStripMenuItem; private ToolStripMenuItem списокЗаказовToolStripMenuItem; + private ToolStripMenuItem клиентыToolStripMenuItem; } } \ No newline at end of file diff --git a/SushiBar/FormMain.cs b/SushiBar/FormMain.cs index 254d871..583d706 100644 --- a/SushiBar/FormMain.cs +++ b/SushiBar/FormMain.cs @@ -2,6 +2,7 @@ using SushiBar; using SushiBarContracts.BindingModel; using SushiBarContracts.BusinessLogicsContracts; +using SushiBarView.Clients; using SushiBarView.Reports; namespace SushiBarView @@ -33,6 +34,8 @@ namespace SushiBarView dataGridView.DataSource = list; dataGridView.Columns["SushiId"].Visible = false; dataGridView.Columns["SushiName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + dataGridView.Columns["ClientId"].Visible = false; + dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка заказов"); } @@ -173,5 +176,14 @@ namespace SushiBarView form.ShowDialog(); } } + + private void клиентыToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormClients)); + if(service is FormClients form) + { + form.ShowDialog(); + } + } } } diff --git a/SushiBar/Orders/FormCreateOrder.Designer.cs b/SushiBar/Orders/FormCreateOrder.Designer.cs index 6cd491f..b796f5e 100644 --- a/SushiBar/Orders/FormCreateOrder.Designer.cs +++ b/SushiBar/Orders/FormCreateOrder.Designer.cs @@ -36,6 +36,8 @@ comboBoxSushi = new ComboBox(); buttonSave = new Button(); buttonCancel = new Button(); + comboBoxClients = new ComboBox(); + labelClient = new Label(); SuspendLayout(); // // labelSushi @@ -51,7 +53,7 @@ // labelCount // labelCount.AutoSize = true; - labelCount.Location = new Point(30, 102); + labelCount.Location = new Point(30, 159); labelCount.Margin = new Padding(4, 0, 4, 0); labelCount.Name = "labelCount"; labelCount.Size = new Size(112, 24); @@ -61,7 +63,7 @@ // labelSum // labelSum.AutoSize = true; - labelSum.Location = new Point(30, 174); + labelSum.Location = new Point(30, 231); labelSum.Margin = new Padding(4, 0, 4, 0); labelSum.Name = "labelSum"; labelSum.Size = new Size(68, 24); @@ -70,7 +72,7 @@ // // textBoxCount // - textBoxCount.Location = new Point(227, 94); + textBoxCount.Location = new Point(227, 151); textBoxCount.Name = "textBoxCount"; textBoxCount.Size = new Size(326, 32); textBoxCount.TabIndex = 3; @@ -79,7 +81,7 @@ // textBoxSum // textBoxSum.Enabled = false; - textBoxSum.Location = new Point(227, 166); + textBoxSum.Location = new Point(227, 223); textBoxSum.Name = "textBoxSum"; textBoxSum.Size = new Size(326, 32); textBoxSum.TabIndex = 4; @@ -96,7 +98,7 @@ // // buttonSave // - buttonSave.Location = new Point(227, 231); + buttonSave.Location = new Point(227, 304); buttonSave.Name = "buttonSave"; buttonSave.Size = new Size(140, 49); buttonSave.TabIndex = 6; @@ -106,7 +108,7 @@ // // buttonCancel // - buttonCancel.Location = new Point(413, 231); + buttonCancel.Location = new Point(413, 304); buttonCancel.Name = "buttonCancel"; buttonCancel.Size = new Size(140, 49); buttonCancel.TabIndex = 7; @@ -114,12 +116,33 @@ buttonCancel.UseVisualStyleBackColor = true; buttonCancel.Click += buttonCancel_Click; // + // comboBoxClients + // + comboBoxClients.DropDownStyle = ComboBoxStyle.DropDownList; + comboBoxClients.FormattingEnabled = true; + comboBoxClients.Location = new Point(227, 93); + comboBoxClients.Name = "comboBoxClients"; + comboBoxClients.Size = new Size(326, 32); + comboBoxClients.TabIndex = 9; + // + // labelClient + // + labelClient.AutoSize = true; + labelClient.Location = new Point(30, 101); + labelClient.Margin = new Padding(4, 0, 4, 0); + labelClient.Name = "labelClient"; + labelClient.Size = new Size(72, 24); + labelClient.TabIndex = 8; + labelClient.Text = "Клиент"; + // // FormCreateOrder // AutoScaleDimensions = new SizeF(11F, 24F); AutoScaleMode = AutoScaleMode.Font; BackColor = Color.FromArgb(192, 192, 255); - ClientSize = new Size(595, 302); + ClientSize = new Size(595, 387); + Controls.Add(comboBoxClients); + Controls.Add(labelClient); Controls.Add(buttonCancel); Controls.Add(buttonSave); Controls.Add(comboBoxSushi); @@ -147,5 +170,7 @@ private ComboBox comboBoxSushi; private Button buttonSave; private Button buttonCancel; + private ComboBox comboBoxClients; + private Label labelClient; } } \ No newline at end of file diff --git a/SushiBar/Orders/FormCreateOrder.cs b/SushiBar/Orders/FormCreateOrder.cs index 7e6b04f..52ab892 100644 --- a/SushiBar/Orders/FormCreateOrder.cs +++ b/SushiBar/Orders/FormCreateOrder.cs @@ -10,18 +10,18 @@ namespace SushiBarView private readonly ILogger _logger; private readonly ISushiLogic _logicSushi; private readonly IOrderLogic _logicO; - public FormCreateOrder(ILogger logger, ISushiLogic logicSushi, IOrderLogic logicO) + private readonly IClientLogic _logicC; + public FormCreateOrder(ILogger logger, ISushiLogic logicSushi, IOrderLogic logicO, IClientLogic logicC) { InitializeComponent(); _logger = logger; _logicSushi = logicSushi; _logicO = logicO; + _logicC = logicC; } private void FormCreateOrder_Load(object sender, EventArgs e) { - _logger.LogInformation("Загрузка изделий для заказа"); - try { var list = _logicSushi.ReadList(null); @@ -31,7 +31,7 @@ namespace SushiBarView comboBoxSushi.ValueMember = "Id"; comboBoxSushi.DataSource = list; comboBoxSushi.SelectedItem = null; - _logger.LogInformation("Загрузка изделий для заказа"); + _logger.LogInformation("Загрузка суши для заказа"); } } catch (Exception ex) @@ -39,7 +39,24 @@ namespace SushiBarView _logger.LogError(ex, "Ошибка загрузки списка изделий"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); } - // прописать логику + + try + { + var list = _logicC.ReadList(null); + if (list != null) + { + comboBoxClients.DisplayMember = "ClientFIO"; + comboBoxClients.ValueMember = "Id"; + comboBoxClients.DataSource = list; + comboBoxClients.SelectedItem = null; + _logger.LogInformation("Загрузка клиентов для заказа"); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки списка клиентов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } } private void comboBoxSushi_SelectedIndexChanged(object sender, EventArgs e) @@ -64,12 +81,18 @@ namespace SushiBarView MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } + if (comboBoxClients.SelectedValue == null) + { + MessageBox.Show("Выберите клиента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } _logger.LogInformation("Создание заказа"); try { var operationResult = _logicO.CreateOrder(new OrderBindingModel { SushiId = Convert.ToInt32(comboBoxSushi.SelectedValue), + ClientId = Convert.ToInt32(comboBoxClients.SelectedValue), Count = Convert.ToInt32(textBoxCount.Text), Sum = Convert.ToDouble(textBoxSum.Text) }); @@ -115,4 +138,4 @@ namespace SushiBarView } } } -} +} \ No newline at end of file diff --git a/SushiBar/Program.cs b/SushiBar/Program.cs index cd9022b..7452b31 100644 --- a/SushiBar/Program.cs +++ b/SushiBar/Program.cs @@ -9,6 +9,7 @@ using SushiBarContracts.BusinessLogicsContracts; using SushiBarContracts.StoragesContracts; using SushiBarDatabaseImplement.Implements; using SushiBarView; +using SushiBarView.Clients; using SushiBarView.Reports; using System.Text; @@ -48,10 +49,12 @@ namespace SushiBar services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); @@ -65,6 +68,7 @@ namespace SushiBar services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/SushiBar/SushiBar.sln b/SushiBar/SushiBar.sln index 7188e03..b33aa37 100644 --- a/SushiBar/SushiBar.sln +++ b/SushiBar/SushiBar.sln @@ -13,9 +13,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SushiBarBusinessLogic", ".. EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SushiBarListImplements", "..\SushiBarListImplements\SushiBarListImplements.csproj", "{BAA05DBA-C77F-4CF6-9998-4C150FA5797C}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SushiBarFileImplement", "..\SushiBarFileImplement\SushiBarFileImplement.csproj", "{15B17431-20EB-4A87-9088-C19E5C2DD209}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SushiBarFileImplement", "..\SushiBarFileImplement\SushiBarFileImplement.csproj", "{15B17431-20EB-4A87-9088-C19E5C2DD209}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SushiBarDatabaseImplement", "..\SushiBarDatabaseImplement\SushiBarDatabaseImplement.csproj", "{920F7D63-E1A0-4629-8322-AAD4A5F5ECAF}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SushiBarDatabaseImplement", "..\SushiBarDatabaseImplement\SushiBarDatabaseImplement.csproj", "{920F7D63-E1A0-4629-8322-AAD4A5F5ECAF}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SushiBarRestApi", "..\SushiBarRestApi\SushiBarRestApi.csproj", "{F7905836-1FF4-48B5-9565-7C03BA76AB96}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -51,6 +53,10 @@ Global {920F7D63-E1A0-4629-8322-AAD4A5F5ECAF}.Debug|Any CPU.Build.0 = Debug|Any CPU {920F7D63-E1A0-4629-8322-AAD4A5F5ECAF}.Release|Any CPU.ActiveCfg = Release|Any CPU {920F7D63-E1A0-4629-8322-AAD4A5F5ECAF}.Release|Any CPU.Build.0 = Release|Any CPU + {F7905836-1FF4-48B5-9565-7C03BA76AB96}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F7905836-1FF4-48B5-9565-7C03BA76AB96}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F7905836-1FF4-48B5-9565-7C03BA76AB96}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F7905836-1FF4-48B5-9565-7C03BA76AB96}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE