From 686653b5a2f94c10a096c4e35bb117b303993c5f Mon Sep 17 00:00:00 2001 From: ValAnn Date: Wed, 7 Feb 2024 13:11:30 +0400 Subject: [PATCH 1/4] test --- SushiBar/SushiBar/Form1.Designer.cs | 23 ++++++++++- SushiBar/SushiBar/Form1.cs | 4 ++ SushiBar/SushiBar/Form1.resx | 62 +---------------------------- 3 files changed, 27 insertions(+), 62 deletions(-) diff --git a/SushiBar/SushiBar/Form1.Designer.cs b/SushiBar/SushiBar/Form1.Designer.cs index b5f899b..943ecea 100644 --- a/SushiBar/SushiBar/Form1.Designer.cs +++ b/SushiBar/SushiBar/Form1.Designer.cs @@ -28,12 +28,33 @@ /// private void InitializeComponent() { - this.components = new System.ComponentModel.Container(); + this.button1 = new System.Windows.Forms.Button(); + this.SuspendLayout(); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(285, 116); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(300, 135); + this.button1.TabIndex = 0; + this.button1.Text = "button1"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // Form1 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(800, 450); + this.Controls.Add(this.button1); + this.Name = "Form1"; this.Text = "Form1"; + this.ResumeLayout(false); + } #endregion + + private Button button1; } } \ No newline at end of file diff --git a/SushiBar/SushiBar/Form1.cs b/SushiBar/SushiBar/Form1.cs index 0eaa471..984f574 100644 --- a/SushiBar/SushiBar/Form1.cs +++ b/SushiBar/SushiBar/Form1.cs @@ -6,5 +6,9 @@ namespace SushiBar { InitializeComponent(); } + + private void button1_Click(object sender, EventArgs e) + { + } } } \ No newline at end of file diff --git a/SushiBar/SushiBar/Form1.resx b/SushiBar/SushiBar/Form1.resx index 1af7de1..f298a7b 100644 --- a/SushiBar/SushiBar/Form1.resx +++ b/SushiBar/SushiBar/Form1.resx @@ -1,64 +1,4 @@ - - - + -- 2.25.1 From b4a01267c969ea5a28379cea1be7822c1d2db46a Mon Sep 17 00:00:00 2001 From: ValAnn Date: Mon, 12 Feb 2024 15:00:02 +0400 Subject: [PATCH 2/4] process --- SushiBar/SushiBar.sln | 84 ++++++++++++- SushiBar/SushiBarBusinessLogic/App.config | 6 + .../SushiBarBusinessLogic/ComponentLogic.cs | 112 +++++++++++++++++ .../SushiBarBusinessLogic.csproj | 48 +++++++ .../BindingModels/ComponentBindingModel.cs | 16 +++ .../BindingModels/OrderBindingModel.cs | 21 ++++ .../BindingModels/SushiBindingModel.cs | 22 ++++ .../IComponentLogic.cs | 20 +++ .../BusinessLogicsContracts/IOrderLogic.cs | 20 +++ .../BusinessLogicsContracts/ISushiLogic.cs | 21 ++++ .../SearchModels/ComponentSearchModel.cs | 14 +++ .../SearchModels/OrderSearchModel.cs | 13 ++ .../SearchModels/SushiSearchModel.cs | 14 +++ .../StoragesContracts/IComponentStorage.cs | 21 ++++ .../StoragesContracts/IOrderStorage.cs | 22 ++++ .../StoragesContracts/ISushiStorage.cs | 22 ++++ .../SushiBarContracts.csproj | 13 ++ .../ViewModels/ComponentViewModel.cs | 21 ++++ .../ViewModels/OrderViewModel.cs | 37 ++++++ .../ViewModels/SushiViewModel.cs | 25 ++++ SushiBar/SushiBarDataModels/Class1.cs | 7 ++ .../SushiBarDataModels/Enums/OrderStatus.cs | 17 +++ SushiBar/SushiBarDataModels/IId.cs | 7 ++ .../Models/IComponentModel.cs | 15 +++ .../SushiBarDataModels/Models/IOrderModel.cs | 19 +++ .../SushiBarDataModels/Models/ISushiModel.cs | 15 +++ .../SushiBarDataModels.csproj | 9 ++ SushiBar/SushiBarListImplement/App.config | 6 + SushiBar/SushiBarListImplement/Component.cs | 43 +++++++ .../SushiBarListImplement/ComponentStorage.cs | 111 +++++++++++++++++ .../DataListSingleton.cs | 31 +++++ SushiBar/SushiBarListImplement/Sushi.cs | 52 ++++++++ .../SushiBarListImplement.csproj | 55 ++++++++ .../SushiBarView/FormComponent.Designer.cs | 117 ++++++++++++++++++ SushiBar/SushiBarView/FormComponent.cs | 89 +++++++++++++ SushiBar/SushiBarView/FormComponent.resx | 60 +++++++++ SushiBar/SushiBarView/Program.cs | 17 +++ SushiBar/SushiBarView/SushiBarView.csproj | 21 ++++ 38 files changed, 1262 insertions(+), 1 deletion(-) create mode 100644 SushiBar/SushiBarBusinessLogic/App.config create mode 100644 SushiBar/SushiBarBusinessLogic/ComponentLogic.cs create mode 100644 SushiBar/SushiBarBusinessLogic/SushiBarBusinessLogic.csproj create mode 100644 SushiBar/SushiBarContracts/BindingModels/ComponentBindingModel.cs create mode 100644 SushiBar/SushiBarContracts/BindingModels/OrderBindingModel.cs create mode 100644 SushiBar/SushiBarContracts/BindingModels/SushiBindingModel.cs create mode 100644 SushiBar/SushiBarContracts/BusinessLogicsContracts/IComponentLogic.cs create mode 100644 SushiBar/SushiBarContracts/BusinessLogicsContracts/IOrderLogic.cs create mode 100644 SushiBar/SushiBarContracts/BusinessLogicsContracts/ISushiLogic.cs create mode 100644 SushiBar/SushiBarContracts/SearchModels/ComponentSearchModel.cs create mode 100644 SushiBar/SushiBarContracts/SearchModels/OrderSearchModel.cs create mode 100644 SushiBar/SushiBarContracts/SearchModels/SushiSearchModel.cs create mode 100644 SushiBar/SushiBarContracts/StoragesContracts/IComponentStorage.cs create mode 100644 SushiBar/SushiBarContracts/StoragesContracts/IOrderStorage.cs create mode 100644 SushiBar/SushiBarContracts/StoragesContracts/ISushiStorage.cs create mode 100644 SushiBar/SushiBarContracts/SushiBarContracts.csproj create mode 100644 SushiBar/SushiBarContracts/ViewModels/ComponentViewModel.cs create mode 100644 SushiBar/SushiBarContracts/ViewModels/OrderViewModel.cs create mode 100644 SushiBar/SushiBarContracts/ViewModels/SushiViewModel.cs create mode 100644 SushiBar/SushiBarDataModels/Class1.cs create mode 100644 SushiBar/SushiBarDataModels/Enums/OrderStatus.cs create mode 100644 SushiBar/SushiBarDataModels/IId.cs create mode 100644 SushiBar/SushiBarDataModels/Models/IComponentModel.cs create mode 100644 SushiBar/SushiBarDataModels/Models/IOrderModel.cs create mode 100644 SushiBar/SushiBarDataModels/Models/ISushiModel.cs create mode 100644 SushiBar/SushiBarDataModels/SushiBarDataModels.csproj create mode 100644 SushiBar/SushiBarListImplement/App.config create mode 100644 SushiBar/SushiBarListImplement/Component.cs create mode 100644 SushiBar/SushiBarListImplement/ComponentStorage.cs create mode 100644 SushiBar/SushiBarListImplement/DataListSingleton.cs create mode 100644 SushiBar/SushiBarListImplement/Sushi.cs create mode 100644 SushiBar/SushiBarListImplement/SushiBarListImplement.csproj create mode 100644 SushiBar/SushiBarView/FormComponent.Designer.cs create mode 100644 SushiBar/SushiBarView/FormComponent.cs create mode 100644 SushiBar/SushiBarView/FormComponent.resx create mode 100644 SushiBar/SushiBarView/Program.cs create mode 100644 SushiBar/SushiBarView/SushiBarView.csproj diff --git a/SushiBar/SushiBar.sln b/SushiBar/SushiBar.sln index e1006df..747c7e6 100644 --- a/SushiBar/SushiBar.sln +++ b/SushiBar/SushiBar.sln @@ -3,18 +3,100 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.3.32825.248 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SushiBar", "SushiBar\SushiBar.csproj", "{1DBEFDAC-8E94-49DB-9C92-576BF0A2B862}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SushiBar", "SushiBar\SushiBar.csproj", "{1DBEFDAC-8E94-49DB-9C92-576BF0A2B862}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SushiBarDataModels", "SushiBarDataModels\SushiBarDataModels.csproj", "{76043DE7-71BC-41E8-B4C0-ECFADDFBF55F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SushiBarContracts", "SushiBarContracts\SushiBarContracts.csproj", "{993E0787-3AD5-4743-8997-C828CD0CDC10}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SushiBarBusinessLogic", "SushiBarBusinessLogic\SushiBarBusinessLogic.csproj", "{E9064087-924C-4E00-A9EA-8E922CF49D11}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SushiBarListImplement", "SushiBarListImplement\SushiBarListImplement.csproj", "{1BBC3A4B-BF06-4EBF-AA20-863B369E234E}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SushiBarView", "SushiBarView\SushiBarView.csproj", "{55A792F4-5723-476F-A420-0F863B7C7F99}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {1DBEFDAC-8E94-49DB-9C92-576BF0A2B862}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {1DBEFDAC-8E94-49DB-9C92-576BF0A2B862}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1DBEFDAC-8E94-49DB-9C92-576BF0A2B862}.Debug|x64.ActiveCfg = Debug|Any CPU + {1DBEFDAC-8E94-49DB-9C92-576BF0A2B862}.Debug|x64.Build.0 = Debug|Any CPU + {1DBEFDAC-8E94-49DB-9C92-576BF0A2B862}.Debug|x86.ActiveCfg = Debug|Any CPU + {1DBEFDAC-8E94-49DB-9C92-576BF0A2B862}.Debug|x86.Build.0 = Debug|Any CPU {1DBEFDAC-8E94-49DB-9C92-576BF0A2B862}.Release|Any CPU.ActiveCfg = Release|Any CPU {1DBEFDAC-8E94-49DB-9C92-576BF0A2B862}.Release|Any CPU.Build.0 = Release|Any CPU + {1DBEFDAC-8E94-49DB-9C92-576BF0A2B862}.Release|x64.ActiveCfg = Release|Any CPU + {1DBEFDAC-8E94-49DB-9C92-576BF0A2B862}.Release|x64.Build.0 = Release|Any CPU + {1DBEFDAC-8E94-49DB-9C92-576BF0A2B862}.Release|x86.ActiveCfg = Release|Any CPU + {1DBEFDAC-8E94-49DB-9C92-576BF0A2B862}.Release|x86.Build.0 = Release|Any CPU + {76043DE7-71BC-41E8-B4C0-ECFADDFBF55F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {76043DE7-71BC-41E8-B4C0-ECFADDFBF55F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {76043DE7-71BC-41E8-B4C0-ECFADDFBF55F}.Debug|x64.ActiveCfg = Debug|Any CPU + {76043DE7-71BC-41E8-B4C0-ECFADDFBF55F}.Debug|x64.Build.0 = Debug|Any CPU + {76043DE7-71BC-41E8-B4C0-ECFADDFBF55F}.Debug|x86.ActiveCfg = Debug|Any CPU + {76043DE7-71BC-41E8-B4C0-ECFADDFBF55F}.Debug|x86.Build.0 = Debug|Any CPU + {76043DE7-71BC-41E8-B4C0-ECFADDFBF55F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {76043DE7-71BC-41E8-B4C0-ECFADDFBF55F}.Release|Any CPU.Build.0 = Release|Any CPU + {76043DE7-71BC-41E8-B4C0-ECFADDFBF55F}.Release|x64.ActiveCfg = Release|Any CPU + {76043DE7-71BC-41E8-B4C0-ECFADDFBF55F}.Release|x64.Build.0 = Release|Any CPU + {76043DE7-71BC-41E8-B4C0-ECFADDFBF55F}.Release|x86.ActiveCfg = Release|Any CPU + {76043DE7-71BC-41E8-B4C0-ECFADDFBF55F}.Release|x86.Build.0 = Release|Any CPU + {993E0787-3AD5-4743-8997-C828CD0CDC10}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {993E0787-3AD5-4743-8997-C828CD0CDC10}.Debug|Any CPU.Build.0 = Debug|Any CPU + {993E0787-3AD5-4743-8997-C828CD0CDC10}.Debug|x64.ActiveCfg = Debug|Any CPU + {993E0787-3AD5-4743-8997-C828CD0CDC10}.Debug|x64.Build.0 = Debug|Any CPU + {993E0787-3AD5-4743-8997-C828CD0CDC10}.Debug|x86.ActiveCfg = Debug|Any CPU + {993E0787-3AD5-4743-8997-C828CD0CDC10}.Debug|x86.Build.0 = Debug|Any CPU + {993E0787-3AD5-4743-8997-C828CD0CDC10}.Release|Any CPU.ActiveCfg = Release|Any CPU + {993E0787-3AD5-4743-8997-C828CD0CDC10}.Release|Any CPU.Build.0 = Release|Any CPU + {993E0787-3AD5-4743-8997-C828CD0CDC10}.Release|x64.ActiveCfg = Release|Any CPU + {993E0787-3AD5-4743-8997-C828CD0CDC10}.Release|x64.Build.0 = Release|Any CPU + {993E0787-3AD5-4743-8997-C828CD0CDC10}.Release|x86.ActiveCfg = Release|Any CPU + {993E0787-3AD5-4743-8997-C828CD0CDC10}.Release|x86.Build.0 = Release|Any CPU + {E9064087-924C-4E00-A9EA-8E922CF49D11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E9064087-924C-4E00-A9EA-8E922CF49D11}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E9064087-924C-4E00-A9EA-8E922CF49D11}.Debug|x64.ActiveCfg = Debug|Any CPU + {E9064087-924C-4E00-A9EA-8E922CF49D11}.Debug|x64.Build.0 = Debug|Any CPU + {E9064087-924C-4E00-A9EA-8E922CF49D11}.Debug|x86.ActiveCfg = Debug|Any CPU + {E9064087-924C-4E00-A9EA-8E922CF49D11}.Debug|x86.Build.0 = Debug|Any CPU + {E9064087-924C-4E00-A9EA-8E922CF49D11}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E9064087-924C-4E00-A9EA-8E922CF49D11}.Release|Any CPU.Build.0 = Release|Any CPU + {E9064087-924C-4E00-A9EA-8E922CF49D11}.Release|x64.ActiveCfg = Release|Any CPU + {E9064087-924C-4E00-A9EA-8E922CF49D11}.Release|x64.Build.0 = Release|Any CPU + {E9064087-924C-4E00-A9EA-8E922CF49D11}.Release|x86.ActiveCfg = Release|Any CPU + {E9064087-924C-4E00-A9EA-8E922CF49D11}.Release|x86.Build.0 = Release|Any CPU + {1BBC3A4B-BF06-4EBF-AA20-863B369E234E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1BBC3A4B-BF06-4EBF-AA20-863B369E234E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1BBC3A4B-BF06-4EBF-AA20-863B369E234E}.Debug|x64.ActiveCfg = Debug|Any CPU + {1BBC3A4B-BF06-4EBF-AA20-863B369E234E}.Debug|x64.Build.0 = Debug|Any CPU + {1BBC3A4B-BF06-4EBF-AA20-863B369E234E}.Debug|x86.ActiveCfg = Debug|Any CPU + {1BBC3A4B-BF06-4EBF-AA20-863B369E234E}.Debug|x86.Build.0 = Debug|Any CPU + {1BBC3A4B-BF06-4EBF-AA20-863B369E234E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1BBC3A4B-BF06-4EBF-AA20-863B369E234E}.Release|Any CPU.Build.0 = Release|Any CPU + {1BBC3A4B-BF06-4EBF-AA20-863B369E234E}.Release|x64.ActiveCfg = Release|Any CPU + {1BBC3A4B-BF06-4EBF-AA20-863B369E234E}.Release|x64.Build.0 = Release|Any CPU + {1BBC3A4B-BF06-4EBF-AA20-863B369E234E}.Release|x86.ActiveCfg = Release|Any CPU + {1BBC3A4B-BF06-4EBF-AA20-863B369E234E}.Release|x86.Build.0 = Release|Any CPU + {55A792F4-5723-476F-A420-0F863B7C7F99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {55A792F4-5723-476F-A420-0F863B7C7F99}.Debug|Any CPU.Build.0 = Debug|Any CPU + {55A792F4-5723-476F-A420-0F863B7C7F99}.Debug|x64.ActiveCfg = Debug|Any CPU + {55A792F4-5723-476F-A420-0F863B7C7F99}.Debug|x64.Build.0 = Debug|Any CPU + {55A792F4-5723-476F-A420-0F863B7C7F99}.Debug|x86.ActiveCfg = Debug|Any CPU + {55A792F4-5723-476F-A420-0F863B7C7F99}.Debug|x86.Build.0 = Debug|Any CPU + {55A792F4-5723-476F-A420-0F863B7C7F99}.Release|Any CPU.ActiveCfg = Release|Any CPU + {55A792F4-5723-476F-A420-0F863B7C7F99}.Release|Any CPU.Build.0 = Release|Any CPU + {55A792F4-5723-476F-A420-0F863B7C7F99}.Release|x64.ActiveCfg = Release|Any CPU + {55A792F4-5723-476F-A420-0F863B7C7F99}.Release|x64.Build.0 = Release|Any CPU + {55A792F4-5723-476F-A420-0F863B7C7F99}.Release|x86.ActiveCfg = Release|Any CPU + {55A792F4-5723-476F-A420-0F863B7C7F99}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SushiBar/SushiBarBusinessLogic/App.config b/SushiBar/SushiBarBusinessLogic/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/SushiBar/SushiBarBusinessLogic/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/SushiBar/SushiBarBusinessLogic/ComponentLogic.cs b/SushiBar/SushiBarBusinessLogic/ComponentLogic.cs new file mode 100644 index 0000000..98d9d85 --- /dev/null +++ b/SushiBar/SushiBarBusinessLogic/ComponentLogic.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarBusinessLogic.BusinessLogics +{ + public class ComponentLogic + private readonly ILogger _logger; + private readonly IComponentStorage _componentStorage; + public ComponentLogic(ILogger logger, IComponentStorage + componentStorage) + { + _logger = logger; + _componentStorage = componentStorage; + } + public List? ReadList(ComponentSearchModel? model) + { + _logger.LogInformation("ReadList. ComponentName:{ComponentName}. Id:{ Id}", model?.ComponentName, model?.Id); + var list = model == null ? _componentStorage.GetFullList() : _componentStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public ComponentViewModel? ReadElement(ComponentSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. ComponentName:{ComponentName}. Id:{ Id} ", model.ComponentName, model.Id); + var element = _componentStorage.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(ComponentBindingModel model) + { + CheckModel(model); + if (_componentStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + 18 + } + public bool Update(ComponentBindingModel model) + { + CheckModel(model); + if (_componentStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(ComponentBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_componentStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(ComponentBindingModel model, bool withParams = + true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.ComponentName)) + { + throw new ArgumentNullException("Нет названия компонента", + nameof(model.ComponentName)); + } + if (model.Cost <= 0) + { + throw new ArgumentNullException("Цена компонента должна быть + больше 0", nameof(model.Cost)); + } + _logger.LogInformation("Component. ComponentName:{ComponentName}. + Cost:{ Cost}. Id: { Id} + ", model.ComponentName, model.Cost, model.Id); + var element = _componentStorage.GetElement(new ComponentSearchModel + { + ComponentName = model.ComponentName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Компонент с таким названием + уже есть"); + } + } +} diff --git a/SushiBar/SushiBarBusinessLogic/SushiBarBusinessLogic.csproj b/SushiBar/SushiBarBusinessLogic/SushiBarBusinessLogic.csproj new file mode 100644 index 0000000..166199b --- /dev/null +++ b/SushiBar/SushiBarBusinessLogic/SushiBarBusinessLogic.csproj @@ -0,0 +1,48 @@ + + + + + Debug + AnyCPU + {E9064087-924C-4E00-A9EA-8E922CF49D11} + Exe + SushiBarBusinessLogic + SushiBarBusinessLogic + v4.7.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + {993e0787-3ad5-4743-8997-c828cd0cdc10} + SushiBarContracts + + + + + + + \ No newline at end of file diff --git a/SushiBar/SushiBarContracts/BindingModels/ComponentBindingModel.cs b/SushiBar/SushiBarContracts/BindingModels/ComponentBindingModel.cs new file mode 100644 index 0000000..206930c --- /dev/null +++ b/SushiBar/SushiBarContracts/BindingModels/ComponentBindingModel.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SushiBarDataModels.Models; + +namespace SushiBarContracts.BindingModels +{ + public class ComponentBindingModel : IComponentModel + { + public int Id { get; set; } + public string ComponentName { get; set; } = string.Empty; + public double Cost { get; set; } + } +} diff --git a/SushiBar/SushiBarContracts/BindingModels/OrderBindingModel.cs b/SushiBar/SushiBarContracts/BindingModels/OrderBindingModel.cs new file mode 100644 index 0000000..ee30e84 --- /dev/null +++ b/SushiBar/SushiBarContracts/BindingModels/OrderBindingModel.cs @@ -0,0 +1,21 @@ +using SushiBarDataModels.Enums; +using SushiBarDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarContracts.BindingModels +{ + public class OrderBindingModel : IOrderModel + { + public int Id { get; set; } + public int SushiId { get; set; } + public int Count { get; set; } + public double Sum { get; set; } + public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; + public DateTime DateCreate { get; set; } = DateTime.Now; + public DateTime? DateImplement { get; set; } + } +} diff --git a/SushiBar/SushiBarContracts/BindingModels/SushiBindingModel.cs b/SushiBar/SushiBarContracts/BindingModels/SushiBindingModel.cs new file mode 100644 index 0000000..ce67161 --- /dev/null +++ b/SushiBar/SushiBarContracts/BindingModels/SushiBindingModel.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SushiBarDataModels.Models; + +namespace SushiBarContracts.BindingModels +{ + public class SushiBindingModel : ISushiModel + { + public int Id { get; set; } + public string SushiName { get; set; } = string.Empty; + public double Price { get; set; } + public Dictionary SushiComponents + { + get; + set; + } = new(); + + } +} diff --git a/SushiBar/SushiBarContracts/BusinessLogicsContracts/IComponentLogic.cs b/SushiBar/SushiBarContracts/BusinessLogicsContracts/IComponentLogic.cs new file mode 100644 index 0000000..5c2b515 --- /dev/null +++ b/SushiBar/SushiBarContracts/BusinessLogicsContracts/IComponentLogic.cs @@ -0,0 +1,20 @@ +using SushiBarContracts.BindingModels; +using SushiBarContracts.SearchModels; +using SushiBarContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarContracts.BusinessLogicsContracts +{ + public interface IComponentLogic + { + List? ReadList(ComponentSearchModel? model); + ComponentViewModel? ReadElement(ComponentSearchModel model); + bool Create(ComponentBindingModel model); + bool Update(ComponentBindingModel model); + bool Delete(ComponentBindingModel model); + } +} diff --git a/SushiBar/SushiBarContracts/BusinessLogicsContracts/IOrderLogic.cs b/SushiBar/SushiBarContracts/BusinessLogicsContracts/IOrderLogic.cs new file mode 100644 index 0000000..b90fb79 --- /dev/null +++ b/SushiBar/SushiBarContracts/BusinessLogicsContracts/IOrderLogic.cs @@ -0,0 +1,20 @@ +using SushiBarContracts.BindingModels; +using SushiBarContracts.SearchModels; +using SushiBarContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarContracts.BusinessLogicsContracts +{ + public interface IOrderLogic + { + List? ReadList(OrderSearchModel? model); + bool CreateOrder(OrderBindingModel model); + bool TakeOrderInWork(OrderBindingModel model); + bool FinishOrder(OrderBindingModel model); + bool DeliveryOrder(OrderBindingModel model); + } +} diff --git a/SushiBar/SushiBarContracts/BusinessLogicsContracts/ISushiLogic.cs b/SushiBar/SushiBarContracts/BusinessLogicsContracts/ISushiLogic.cs new file mode 100644 index 0000000..32c732b --- /dev/null +++ b/SushiBar/SushiBarContracts/BusinessLogicsContracts/ISushiLogic.cs @@ -0,0 +1,21 @@ +using SushiBarContracts.BindingModels; +using SushiBarContracts.SearchModels; +using SushiBarContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarContracts.BusinessLogicsContracts +{ + public interface ISushiLogic + { + List? ReadList(SushiSearchModel? model); + SushiViewModel? ReadElement(SushiSearchModel model); + bool Create(SushiBindingModel model); + bool Update(SushiBindingModel model); + bool Delete(SushiBindingModel model); + } + +} diff --git a/SushiBar/SushiBarContracts/SearchModels/ComponentSearchModel.cs b/SushiBar/SushiBarContracts/SearchModels/ComponentSearchModel.cs new file mode 100644 index 0000000..a69687d --- /dev/null +++ b/SushiBar/SushiBarContracts/SearchModels/ComponentSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarContracts.SearchModels +{ + public class ComponentSearchModel + { + public int? Id { get; set; } + public string? ComponentName { get; set; } + } +} diff --git a/SushiBar/SushiBarContracts/SearchModels/OrderSearchModel.cs b/SushiBar/SushiBarContracts/SearchModels/OrderSearchModel.cs new file mode 100644 index 0000000..98630db --- /dev/null +++ b/SushiBar/SushiBarContracts/SearchModels/OrderSearchModel.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarContracts.SearchModels +{ + public class OrderSearchModel + { + public int? Id { get; set; } + } +} diff --git a/SushiBar/SushiBarContracts/SearchModels/SushiSearchModel.cs b/SushiBar/SushiBarContracts/SearchModels/SushiSearchModel.cs new file mode 100644 index 0000000..95d2732 --- /dev/null +++ b/SushiBar/SushiBarContracts/SearchModels/SushiSearchModel.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarContracts.SearchModels +{ + public class SushiSearchModel + { + public int? Id { get; set; } + public string? SushiName { get; set; } + } +} diff --git a/SushiBar/SushiBarContracts/StoragesContracts/IComponentStorage.cs b/SushiBar/SushiBarContracts/StoragesContracts/IComponentStorage.cs new file mode 100644 index 0000000..a58deb5 --- /dev/null +++ b/SushiBar/SushiBarContracts/StoragesContracts/IComponentStorage.cs @@ -0,0 +1,21 @@ +using SushiBarContracts.BindingModels; +using SushiBarContracts.SearchModels; +using SushiBarContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarContracts.StoragesContracts +{ + public interface IComponentStorage + { + List GetFullList(); + List GetFilteredList(ComponentSearchModel model); + ComponentViewModel? GetElement(ComponentSearchModel model); + ComponentViewModel? Insert(ComponentBindingModel model); + ComponentViewModel? Update(ComponentBindingModel model); + ComponentViewModel? Delete(ComponentBindingModel model); + } +} diff --git a/SushiBar/SushiBarContracts/StoragesContracts/IOrderStorage.cs b/SushiBar/SushiBarContracts/StoragesContracts/IOrderStorage.cs new file mode 100644 index 0000000..5d310e8 --- /dev/null +++ b/SushiBar/SushiBarContracts/StoragesContracts/IOrderStorage.cs @@ -0,0 +1,22 @@ +using SushiBarContracts.BindingModels; +using SushiBarContracts.SearchModels; +using SushiBarContracts.ViewModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarContracts.StoragesContracts +{ + public interface IOrderStorage + { + List GetFullList(); + List GetFilteredList(OrderSearchModel model); + OrderViewModel? GetElement(OrderSearchModel model); + OrderViewModel? Insert(OrderBindingModel model); + OrderViewModel? Update(OrderBindingModel model); + OrderViewModel? Delete(OrderBindingModel model); + } + +} diff --git a/SushiBar/SushiBarContracts/StoragesContracts/ISushiStorage.cs b/SushiBar/SushiBarContracts/StoragesContracts/ISushiStorage.cs new file mode 100644 index 0000000..3682ff7 --- /dev/null +++ b/SushiBar/SushiBarContracts/StoragesContracts/ISushiStorage.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SushiBarContracts.BindingModels; +using SushiBarContracts.SearchModels; +using SushiBarContracts.ViewModels; + +namespace SushiBarContracts.StoragesContracts +{ + public interface ISushiStorage + { + List GetFullList(); + List GetFilteredList(SushiSearchModel model); + SushiViewModel? GetElement(SushiSearchModel model); + SushiViewModel? Insert(SushiBindingModel model); + SushiViewModel? Update(SushiBindingModel model); + SushiViewModel? Delete(SushiBindingModel model); + } + +} diff --git a/SushiBar/SushiBarContracts/SushiBarContracts.csproj b/SushiBar/SushiBarContracts/SushiBarContracts.csproj new file mode 100644 index 0000000..a25f2c8 --- /dev/null +++ b/SushiBar/SushiBarContracts/SushiBarContracts.csproj @@ -0,0 +1,13 @@ + + + + net6.0 + enable + enable + + + + + + + diff --git a/SushiBar/SushiBarContracts/ViewModels/ComponentViewModel.cs b/SushiBar/SushiBarContracts/ViewModels/ComponentViewModel.cs new file mode 100644 index 0000000..5b924c1 --- /dev/null +++ b/SushiBar/SushiBarContracts/ViewModels/ComponentViewModel.cs @@ -0,0 +1,21 @@ +using SushiBarDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarContracts.ViewModels +{ + public class ComponentViewModel : IComponentModel + { + public int Id { get; set; } + + [DisplayName("Название компонента")] + public string ComponentName { get; set; } = string.Empty; + + [DisplayName("Цена")] + public double Cost { get; set; } + } +} diff --git a/SushiBar/SushiBarContracts/ViewModels/OrderViewModel.cs b/SushiBar/SushiBarContracts/ViewModels/OrderViewModel.cs new file mode 100644 index 0000000..36203b3 --- /dev/null +++ b/SushiBar/SushiBarContracts/ViewModels/OrderViewModel.cs @@ -0,0 +1,37 @@ +using SushiBarDataModels.Enums; +using SushiBarDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarContracts.ViewModels +{ + public class OrderViewModel : IOrderModel + { + [DisplayName("Номер")] + public int Id { get; set; } + + public int SushiId { get; set; } + + [DisplayName("Изделие")] + public string SushiName { get; set; } = string.Empty; + + [DisplayName("Количество")] + public int Count { get; set; } + + [DisplayName("Сумма")] + public double Sum { get; set; } + + [DisplayName("Статус")] + public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; + + [DisplayName("Дата создания")] + public DateTime DateCreate { get; set; } = DateTime.Now; + + [DisplayName("Дата выполнения")] + public DateTime? DateImplement { get; set; } + } +} diff --git a/SushiBar/SushiBarContracts/ViewModels/SushiViewModel.cs b/SushiBar/SushiBarContracts/ViewModels/SushiViewModel.cs new file mode 100644 index 0000000..8f9608c --- /dev/null +++ b/SushiBar/SushiBarContracts/ViewModels/SushiViewModel.cs @@ -0,0 +1,25 @@ +using SushiBarDataModels.Models; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarContracts.ViewModels +{ + public class SushiViewModel : ISushiModel + { + public int Id { get; set; } + [DisplayName("Название изделия")] + public string SushiName { get; set; } = string.Empty; + [DisplayName("Цена")] + public double Price { get; set; } + public Dictionary SushiComponents + { + get; + set; + } = new(); + + } +} diff --git a/SushiBar/SushiBarDataModels/Class1.cs b/SushiBar/SushiBarDataModels/Class1.cs new file mode 100644 index 0000000..08ec173 --- /dev/null +++ b/SushiBar/SushiBarDataModels/Class1.cs @@ -0,0 +1,7 @@ +namespace SushiBarDataModels +{ + public class Class1 + { + + } +} \ No newline at end of file diff --git a/SushiBar/SushiBarDataModels/Enums/OrderStatus.cs b/SushiBar/SushiBarDataModels/Enums/OrderStatus.cs new file mode 100644 index 0000000..c1b6d91 --- /dev/null +++ b/SushiBar/SushiBarDataModels/Enums/OrderStatus.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarDataModels.Enums +{ + public enum OrderStatus + { + Неизвестен = -1, + Принят = 0, + Выполняется = 1, + Готов = 2, + Выдан = 3 + } +} diff --git a/SushiBar/SushiBarDataModels/IId.cs b/SushiBar/SushiBarDataModels/IId.cs new file mode 100644 index 0000000..91a1366 --- /dev/null +++ b/SushiBar/SushiBarDataModels/IId.cs @@ -0,0 +1,7 @@ +namespace SushiBarDataModels +{ + public interface IId + { + int Id { get; } + } +} \ No newline at end of file diff --git a/SushiBar/SushiBarDataModels/Models/IComponentModel.cs b/SushiBar/SushiBarDataModels/Models/IComponentModel.cs new file mode 100644 index 0000000..b82c233 --- /dev/null +++ b/SushiBar/SushiBarDataModels/Models/IComponentModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarDataModels.Models +{ + public interface IComponentModel : IId + { + string ComponentName { get; } + double Cost { get; } + + } +} diff --git a/SushiBar/SushiBarDataModels/Models/IOrderModel.cs b/SushiBar/SushiBarDataModels/Models/IOrderModel.cs new file mode 100644 index 0000000..02ca513 --- /dev/null +++ b/SushiBar/SushiBarDataModels/Models/IOrderModel.cs @@ -0,0 +1,19 @@ +using SushiBarDataModels.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarDataModels.Models +{ + public interface IOrderModel : IId + { + int SushiId { get; } + int Count { get; } + double Sum { get; } + OrderStatus Status { get; } + DateTime DateCreate { get; } + DateTime? DateImplement { get; } + } +} diff --git a/SushiBar/SushiBarDataModels/Models/ISushiModel.cs b/SushiBar/SushiBarDataModels/Models/ISushiModel.cs new file mode 100644 index 0000000..a6c7e0c --- /dev/null +++ b/SushiBar/SushiBarDataModels/Models/ISushiModel.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarDataModels.Models +{ + public interface ISushiModel : IId + { + string SushiName { get; } + double Price { get; } + Dictionary SushiComponents { get; } + } +} diff --git a/SushiBar/SushiBarDataModels/SushiBarDataModels.csproj b/SushiBar/SushiBarDataModels/SushiBarDataModels.csproj new file mode 100644 index 0000000..132c02c --- /dev/null +++ b/SushiBar/SushiBarDataModels/SushiBarDataModels.csproj @@ -0,0 +1,9 @@ + + + + net6.0 + enable + enable + + + diff --git a/SushiBar/SushiBarListImplement/App.config b/SushiBar/SushiBarListImplement/App.config new file mode 100644 index 0000000..56efbc7 --- /dev/null +++ b/SushiBar/SushiBarListImplement/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/SushiBar/SushiBarListImplement/Component.cs b/SushiBar/SushiBarListImplement/Component.cs new file mode 100644 index 0000000..453d89c --- /dev/null +++ b/SushiBar/SushiBarListImplement/Component.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarListImplement.Models +{ + public class Component : IComponentModel + { + public int Id { get; private set; } + public string ComponentName { get; private set; } = string.Empty; + public double Cost { get; set; } + public static Component? Create(ComponentBindingModel? model) + { + if (model == null) + { + return null; + } + return new Component() + { + Id = model.Id, + ComponentName = model.ComponentName, + Cost = model.Cost + }; + } + public void Update(ComponentBindingModel? model) + { + if (model == null) + { + return; + } + ComponentName = model.ComponentName; + Cost = model.Cost; + } + public ComponentViewModel GetViewModel => new() + { + Id = Id, + ComponentName = ComponentName, + Cost = Cost + }; + } +} diff --git a/SushiBar/SushiBarListImplement/ComponentStorage.cs b/SushiBar/SushiBarListImplement/ComponentStorage.cs new file mode 100644 index 0000000..463d75c --- /dev/null +++ b/SushiBar/SushiBarListImplement/ComponentStorage.cs @@ -0,0 +1,111 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SushiBarContracts.BindingModels; +using SushiBarContracts.SearchModels; +using SushiBarContracts.StoragesContracts; +using SushiBarContracts.ViewModels; +using SushiBarListImplement.Models; + +namespace SushiBarListImplement.Implements +{ + internal class ComponentStorage : IComponentStorage + { + private readonly DataListSingleton _source; + public ComponentStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var component in _source.Components) + { + result.Add(component.GetViewModel); + } + return result; + } + public List GetFilteredList(ComponentSearchModel + model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.ComponentName)) + { + return result; + } + foreach (var component in _source.Components) + { + if (component.ComponentName.Contains(model.ComponentName)) + { + result.Add(component.GetViewModel); + } + } + return result; + } + public ComponentViewModel? GetElement(ComponentSearchModel model) + { + if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue) + { + return null; + } + 23 + foreach (var component in _source.Components) + { + if ((!string.IsNullOrEmpty(model.ComponentName) && + component.ComponentName == model.ComponentName) || + (model.Id.HasValue && component.Id == model.Id)) + { + return component.GetViewModel; + } + } + return null; + } + public ComponentViewModel? Insert(ComponentBindingModel model) + { + model.Id = 1; + foreach (var component in _source.Components) + { + if (model.Id <= component.Id) + { + model.Id = component.Id + 1; + } + } + var newComponent = Component.Create(model); + if (newComponent == null) + { + return null; + } + _source.Components.Add(newComponent); + return newComponent.GetViewModel; + } + public ComponentViewModel? Update(ComponentBindingModel model) + { + foreach (var component in _source.Components) + { + if (component.Id == model.Id) + { + component.Update(model); + return component.GetViewModel; + } + } + return null; + } + public ComponentViewModel? Delete(ComponentBindingModel model) + { + for (int i = 0; i < _source.Components.Count; ++i) + { + if (_source.Components[i].Id == model.Id) + { + var element = _source.Components[i]; + _source.Components.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + } + +} +} diff --git a/SushiBar/SushiBarListImplement/DataListSingleton.cs b/SushiBar/SushiBarListImplement/DataListSingleton.cs new file mode 100644 index 0000000..f0f9a1b --- /dev/null +++ b/SushiBar/SushiBarListImplement/DataListSingleton.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SushiBarListImplement.Models; + +namespace SushiBarListImplement +{ + public class DataListSingleton + { + private static DataListSingleton? _instance; + public List Components { get; set; } + public List Orders { get; set; } + public List Products { get; set; } + private DataListSingleton() + { + Components = new List(); + Orders = new List(); + Products = new List(); + } + public static DataListSingleton GetInstance() + { + if (_instance == null) + { + _instance = new DataListSingleton(); + } + return _instance; + } + } +} diff --git a/SushiBar/SushiBarListImplement/Sushi.cs b/SushiBar/SushiBarListImplement/Sushi.cs new file mode 100644 index 0000000..133090b --- /dev/null +++ b/SushiBar/SushiBarListImplement/Sushi.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarListImplement.Models +{ + internal class Sushi : IProductModel + { + public int Id { get; private set; } + public string ProductName { get; private set; } = string.Empty; + public double Price { get; private set; } + public Dictionary ProductComponents + { + get; + private set; + } = new Dictionary(); + public static Product? Create(ProductBindingModel? model) + { + if (model == null) + { + return null; + } + return new Product() + { + Id = model.Id, + ProductName = model.ProductName, + Price = model.Price, + ProductComponents = model.ProductComponents + }; + } + public void Update(ProductBindingModel? model) + { + if (model == null) + { + return; + } + ProductName = model.ProductName; + Price = model.Price; + ProductComponents = model.ProductComponents; + } + public ProductViewModel GetViewModel => new() + { + Id = Id, + ProductName = ProductName, + Price = Price, + ProductComponents = ProductComponents + }; + + } +} diff --git a/SushiBar/SushiBarListImplement/SushiBarListImplement.csproj b/SushiBar/SushiBarListImplement/SushiBarListImplement.csproj new file mode 100644 index 0000000..bbf9d38 --- /dev/null +++ b/SushiBar/SushiBarListImplement/SushiBarListImplement.csproj @@ -0,0 +1,55 @@ + + + + + Debug + AnyCPU + {1BBC3A4B-BF06-4EBF-AA20-863B369E234E} + Exe + SushiBarListImplement + SushiBarListImplement + v4.7.2 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + {993e0787-3ad5-4743-8997-c828cd0cdc10} + SushiBarContracts + + + {76043de7-71bc-41e8-b4c0-ecfaddfbf55f} + SushiBarDataModels + + + + + + + + + + \ No newline at end of file diff --git a/SushiBar/SushiBarView/FormComponent.Designer.cs b/SushiBar/SushiBarView/FormComponent.Designer.cs new file mode 100644 index 0000000..f8da578 --- /dev/null +++ b/SushiBar/SushiBarView/FormComponent.Designer.cs @@ -0,0 +1,117 @@ +namespace SushiBarView +{ + partial class FormComponent + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.ButtonSave = new System.Windows.Forms.Button(); + this.ButtonCancel = new System.Windows.Forms.Button(); + this.labelName = new System.Windows.Forms.Label(); + this.labelCost = new System.Windows.Forms.Label(); + this.textBoxName = new System.Windows.Forms.TextBox(); + this.textBoxCost = new System.Windows.Forms.TextBox(); + this.SuspendLayout(); + // + // ButtonSave + // + this.ButtonSave.Location = new System.Drawing.Point(174, 99); + this.ButtonSave.Name = "ButtonSave"; + this.ButtonSave.Size = new System.Drawing.Size(87, 26); + this.ButtonSave.TabIndex = 0; + this.ButtonSave.Text = "Сохранить"; + this.ButtonSave.UseVisualStyleBackColor = true; + this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // ButtonCancel + // + this.ButtonCancel.Location = new System.Drawing.Point(267, 99); + this.ButtonCancel.Name = "ButtonCancel"; + this.ButtonCancel.Size = new System.Drawing.Size(87, 26); + this.ButtonCancel.TabIndex = 1; + this.ButtonCancel.Text = "Отмена"; + this.ButtonCancel.UseVisualStyleBackColor = true; + // + // labelName + // + this.labelName.AutoSize = true; + this.labelName.Location = new System.Drawing.Point(12, 24); + this.labelName.Name = "labelName"; + this.labelName.Size = new System.Drawing.Size(59, 15); + this.labelName.TabIndex = 2; + this.labelName.Text = "Название"; + // + // labelCost + // + this.labelCost.AutoSize = true; + this.labelCost.Location = new System.Drawing.Point(12, 65); + this.labelCost.Name = "labelCost"; + this.labelCost.Size = new System.Drawing.Size(35, 15); + this.labelCost.TabIndex = 3; + this.labelCost.Text = "Цена"; + // + // textBoxName + // + this.textBoxName.Location = new System.Drawing.Point(83, 21); + this.textBoxName.Name = "textBoxName"; + this.textBoxName.Size = new System.Drawing.Size(133, 23); + this.textBoxName.TabIndex = 4; + // + // textBoxCost + // + this.textBoxCost.Location = new System.Drawing.Point(83, 57); + this.textBoxCost.Name = "textBoxCost"; + this.textBoxCost.Size = new System.Drawing.Size(133, 23); + this.textBoxCost.TabIndex = 5; + // + // FormComponent + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(357, 137); + this.Controls.Add(this.textBoxCost); + this.Controls.Add(this.textBoxName); + this.Controls.Add(this.labelCost); + this.Controls.Add(this.labelName); + this.Controls.Add(this.ButtonCancel); + this.Controls.Add(this.ButtonSave); + this.Name = "FormComponent"; + this.Text = "Компонент"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Button ButtonSave; + private Button ButtonCancel; + private Label labelName; + private Label labelCost; + private TextBox textBoxName; + private TextBox textBoxCost; + } +} \ No newline at end of file diff --git a/SushiBar/SushiBarView/FormComponent.cs b/SushiBar/SushiBarView/FormComponent.cs new file mode 100644 index 0000000..2b7fce4 --- /dev/null +++ b/SushiBar/SushiBarView/FormComponent.cs @@ -0,0 +1,89 @@ +using Microsoft.Extensions.Logging; +using SushiBarContracts.BindingModels; +using SushiBarContracts.BusinessLogicsContracts; +using SushiBarContracts.SearchModels; + + +namespace SushiBarView +{ + public partial class FormComponent : Form + { + private readonly ILogger _logger; + private readonly IComponentLogic _logic; + private int? _id; + public int Id { set { _id = value; } } + public FormComponent(ILogger logger, IComponentLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + MessageBox.Show(" ", "", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation(" "); + try + { + var model = new ComponentBindingModel + { + Id = _id ?? 0, + ComponentName = textBoxName.Text, + Cost = Convert.ToDouble(textBoxCost.Text) + }; + 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); + } + + } + + private void FormComponent_Load(object sender, EventArgs e) + { + if (_id.HasValue) + { + try + { + _logger.LogInformation(" "); + var view = _logic.ReadElement(new ComponentSearchModel + { + Id = + _id.Value + }); + if (view != null) + { + textBoxName.Text = view.ComponentName; + textBoxCost.Text = view.Cost.ToString(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, " "); + MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + + + } +} \ No newline at end of file diff --git a/SushiBar/SushiBarView/FormComponent.resx b/SushiBar/SushiBarView/FormComponent.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/SushiBar/SushiBarView/FormComponent.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SushiBar/SushiBarView/Program.cs b/SushiBar/SushiBarView/Program.cs new file mode 100644 index 0000000..34ba1ed --- /dev/null +++ b/SushiBar/SushiBarView/Program.cs @@ -0,0 +1,17 @@ +namespace SushiBarView +{ + internal static class Program + { + /// + /// The main entry point for the application. + /// + [STAThread] + static void Main() + { + // To customize application configuration such as set high DPI settings or default font, + // see https://aka.ms/applicationconfiguration. + ApplicationConfiguration.Initialize(); + Application.Run(new FormComponent()); + } + } +} \ No newline at end of file diff --git a/SushiBar/SushiBarView/SushiBarView.csproj b/SushiBar/SushiBarView/SushiBarView.csproj new file mode 100644 index 0000000..cf6300c --- /dev/null +++ b/SushiBar/SushiBarView/SushiBarView.csproj @@ -0,0 +1,21 @@ + + + + WinExe + net6.0-windows + enable + true + enable + + + + + + + + + + + + + \ No newline at end of file -- 2.25.1 From 7826ae0c6d80dc717f8dde77e7810aa2b43ed00f Mon Sep 17 00:00:00 2001 From: ValAnn Date: Wed, 14 Feb 2024 00:58:39 +0400 Subject: [PATCH 3/4] =?UTF-8?q?=D0=BF=D0=BE=D0=B9=D0=B4=D0=B5=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SushiBar/SushiBar.sln | 54 ++-- .../SushiBarBusinessLogic/ComponentLogic.cs | 1 - .../SushiBarBusinessLogic_/ComponentLogic.cs | 117 ++++++++ SushiBar/SushiBarBusinessLogic_/OrderLogic.cs | 125 +++++++++ .../SushiBarBusinessLogic.csproj | 17 ++ SushiBar/SushiBarBusinessLogic_/SushiLogic.cs | 117 ++++++++ .../SushiBarListImplement/ComponentStorage.cs | 1 - .../DataListSingleton.cs | 31 +++ .../Implements/ComponentStorage.cs | 110 ++++++++ .../Implements/OrderStorage.cs | 125 +++++++++ .../Implements/SushiStorage.cs | 113 ++++++++ .../Models/Component.cs | 48 ++++ .../SushiBarListImplement_/Models/Order.cs | 62 +++++ .../SushiBarListImplement_/Models/Sushi.cs | 55 ++++ .../SushiBarListImplement.csproj | 14 + .../SushiBarView/FormComponent.Designer.cs | 7 +- SushiBar/SushiBarView/FormComponent.cs | 3 +- .../SushiBarView/FormComponents.Designer.cs | 115 ++++++++ SushiBar/SushiBarView/FormComponents.cs | 123 +++++++++ SushiBar/SushiBarView/FormComponents.resx | 60 +++++ .../SushiBarView/FormCreateOrder.Designer.cs | 145 ++++++++++ SushiBar/SushiBarView/FormCreateOrder.cs | 136 ++++++++++ SushiBar/SushiBarView/FormCreateOrder.resx | 60 +++++ SushiBar/SushiBarView/FormMain.Designer.cs | 175 ++++++++++++ SushiBar/SushiBarView/FormMain.cs | 171 ++++++++++++ SushiBar/SushiBarView/FormMain.resx | 63 +++++ SushiBar/SushiBarView/FormSushi.Designer.cs | 198 ++++++++++++++ SushiBar/SushiBarView/FormSushi.cs | 251 ++++++++++++++++++ SushiBar/SushiBarView/FormSushi.resx | 60 +++++ .../FormSushiComponent.Designer.cs | 119 +++++++++ SushiBar/SushiBarView/FormSushiComponent.cs | 99 +++++++ SushiBar/SushiBarView/FormSushiComponent.resx | 60 +++++ SushiBar/SushiBarView/FormSushis.Designer.cs | 115 ++++++++ SushiBar/SushiBarView/FormSushis.cs | 121 +++++++++ SushiBar/SushiBarView/FormSushis.resx | 60 +++++ SushiBar/SushiBarView/Program.cs | 41 ++- SushiBar/SushiBarView/SushiBarView.csproj | 19 +- SushiBar/SushiBarView/nlog.config | 15 ++ 38 files changed, 3166 insertions(+), 40 deletions(-) create mode 100644 SushiBar/SushiBarBusinessLogic_/ComponentLogic.cs create mode 100644 SushiBar/SushiBarBusinessLogic_/OrderLogic.cs create mode 100644 SushiBar/SushiBarBusinessLogic_/SushiBarBusinessLogic.csproj create mode 100644 SushiBar/SushiBarBusinessLogic_/SushiLogic.cs create mode 100644 SushiBar/SushiBarListImplement_/DataListSingleton.cs create mode 100644 SushiBar/SushiBarListImplement_/Implements/ComponentStorage.cs create mode 100644 SushiBar/SushiBarListImplement_/Implements/OrderStorage.cs create mode 100644 SushiBar/SushiBarListImplement_/Implements/SushiStorage.cs create mode 100644 SushiBar/SushiBarListImplement_/Models/Component.cs create mode 100644 SushiBar/SushiBarListImplement_/Models/Order.cs create mode 100644 SushiBar/SushiBarListImplement_/Models/Sushi.cs create mode 100644 SushiBar/SushiBarListImplement_/SushiBarListImplement.csproj create mode 100644 SushiBar/SushiBarView/FormComponents.Designer.cs create mode 100644 SushiBar/SushiBarView/FormComponents.cs create mode 100644 SushiBar/SushiBarView/FormComponents.resx create mode 100644 SushiBar/SushiBarView/FormCreateOrder.Designer.cs create mode 100644 SushiBar/SushiBarView/FormCreateOrder.cs create mode 100644 SushiBar/SushiBarView/FormCreateOrder.resx create mode 100644 SushiBar/SushiBarView/FormMain.Designer.cs create mode 100644 SushiBar/SushiBarView/FormMain.cs create mode 100644 SushiBar/SushiBarView/FormMain.resx create mode 100644 SushiBar/SushiBarView/FormSushi.Designer.cs create mode 100644 SushiBar/SushiBarView/FormSushi.cs create mode 100644 SushiBar/SushiBarView/FormSushi.resx create mode 100644 SushiBar/SushiBarView/FormSushiComponent.Designer.cs create mode 100644 SushiBar/SushiBarView/FormSushiComponent.cs create mode 100644 SushiBar/SushiBarView/FormSushiComponent.resx create mode 100644 SushiBar/SushiBarView/FormSushis.Designer.cs create mode 100644 SushiBar/SushiBarView/FormSushis.cs create mode 100644 SushiBar/SushiBarView/FormSushis.resx create mode 100644 SushiBar/SushiBarView/nlog.config diff --git a/SushiBar/SushiBar.sln b/SushiBar/SushiBar.sln index 747c7e6..053c8c9 100644 --- a/SushiBar/SushiBar.sln +++ b/SushiBar/SushiBar.sln @@ -9,11 +9,11 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SushiBarDataModels", "Sushi EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SushiBarContracts", "SushiBarContracts\SushiBarContracts.csproj", "{993E0787-3AD5-4743-8997-C828CD0CDC10}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SushiBarBusinessLogic", "SushiBarBusinessLogic\SushiBarBusinessLogic.csproj", "{E9064087-924C-4E00-A9EA-8E922CF49D11}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SushiBarView", "SushiBarView\SushiBarView.csproj", "{55A792F4-5723-476F-A420-0F863B7C7F99}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SushiBarListImplement", "SushiBarListImplement\SushiBarListImplement.csproj", "{1BBC3A4B-BF06-4EBF-AA20-863B369E234E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SushiBarListImplement", "SushiBarListImplement_\SushiBarListImplement.csproj", "{AF2B4854-10FE-45CC-BA64-0C0B93BF41C4}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SushiBarView", "SushiBarView\SushiBarView.csproj", "{55A792F4-5723-476F-A420-0F863B7C7F99}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SushiBarBusinessLogic", "SushiBarBusinessLogic_\SushiBarBusinessLogic.csproj", "{D7936C41-351B-43FD-B90B-5477375EEC1E}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -61,30 +61,6 @@ Global {993E0787-3AD5-4743-8997-C828CD0CDC10}.Release|x64.Build.0 = Release|Any CPU {993E0787-3AD5-4743-8997-C828CD0CDC10}.Release|x86.ActiveCfg = Release|Any CPU {993E0787-3AD5-4743-8997-C828CD0CDC10}.Release|x86.Build.0 = Release|Any CPU - {E9064087-924C-4E00-A9EA-8E922CF49D11}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E9064087-924C-4E00-A9EA-8E922CF49D11}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E9064087-924C-4E00-A9EA-8E922CF49D11}.Debug|x64.ActiveCfg = Debug|Any CPU - {E9064087-924C-4E00-A9EA-8E922CF49D11}.Debug|x64.Build.0 = Debug|Any CPU - {E9064087-924C-4E00-A9EA-8E922CF49D11}.Debug|x86.ActiveCfg = Debug|Any CPU - {E9064087-924C-4E00-A9EA-8E922CF49D11}.Debug|x86.Build.0 = Debug|Any CPU - {E9064087-924C-4E00-A9EA-8E922CF49D11}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E9064087-924C-4E00-A9EA-8E922CF49D11}.Release|Any CPU.Build.0 = Release|Any CPU - {E9064087-924C-4E00-A9EA-8E922CF49D11}.Release|x64.ActiveCfg = Release|Any CPU - {E9064087-924C-4E00-A9EA-8E922CF49D11}.Release|x64.Build.0 = Release|Any CPU - {E9064087-924C-4E00-A9EA-8E922CF49D11}.Release|x86.ActiveCfg = Release|Any CPU - {E9064087-924C-4E00-A9EA-8E922CF49D11}.Release|x86.Build.0 = Release|Any CPU - {1BBC3A4B-BF06-4EBF-AA20-863B369E234E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {1BBC3A4B-BF06-4EBF-AA20-863B369E234E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {1BBC3A4B-BF06-4EBF-AA20-863B369E234E}.Debug|x64.ActiveCfg = Debug|Any CPU - {1BBC3A4B-BF06-4EBF-AA20-863B369E234E}.Debug|x64.Build.0 = Debug|Any CPU - {1BBC3A4B-BF06-4EBF-AA20-863B369E234E}.Debug|x86.ActiveCfg = Debug|Any CPU - {1BBC3A4B-BF06-4EBF-AA20-863B369E234E}.Debug|x86.Build.0 = Debug|Any CPU - {1BBC3A4B-BF06-4EBF-AA20-863B369E234E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {1BBC3A4B-BF06-4EBF-AA20-863B369E234E}.Release|Any CPU.Build.0 = Release|Any CPU - {1BBC3A4B-BF06-4EBF-AA20-863B369E234E}.Release|x64.ActiveCfg = Release|Any CPU - {1BBC3A4B-BF06-4EBF-AA20-863B369E234E}.Release|x64.Build.0 = Release|Any CPU - {1BBC3A4B-BF06-4EBF-AA20-863B369E234E}.Release|x86.ActiveCfg = Release|Any CPU - {1BBC3A4B-BF06-4EBF-AA20-863B369E234E}.Release|x86.Build.0 = Release|Any CPU {55A792F4-5723-476F-A420-0F863B7C7F99}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {55A792F4-5723-476F-A420-0F863B7C7F99}.Debug|Any CPU.Build.0 = Debug|Any CPU {55A792F4-5723-476F-A420-0F863B7C7F99}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -97,6 +73,30 @@ Global {55A792F4-5723-476F-A420-0F863B7C7F99}.Release|x64.Build.0 = Release|Any CPU {55A792F4-5723-476F-A420-0F863B7C7F99}.Release|x86.ActiveCfg = Release|Any CPU {55A792F4-5723-476F-A420-0F863B7C7F99}.Release|x86.Build.0 = Release|Any CPU + {AF2B4854-10FE-45CC-BA64-0C0B93BF41C4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AF2B4854-10FE-45CC-BA64-0C0B93BF41C4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AF2B4854-10FE-45CC-BA64-0C0B93BF41C4}.Debug|x64.ActiveCfg = Debug|Any CPU + {AF2B4854-10FE-45CC-BA64-0C0B93BF41C4}.Debug|x64.Build.0 = Debug|Any CPU + {AF2B4854-10FE-45CC-BA64-0C0B93BF41C4}.Debug|x86.ActiveCfg = Debug|Any CPU + {AF2B4854-10FE-45CC-BA64-0C0B93BF41C4}.Debug|x86.Build.0 = Debug|Any CPU + {AF2B4854-10FE-45CC-BA64-0C0B93BF41C4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AF2B4854-10FE-45CC-BA64-0C0B93BF41C4}.Release|Any CPU.Build.0 = Release|Any CPU + {AF2B4854-10FE-45CC-BA64-0C0B93BF41C4}.Release|x64.ActiveCfg = Release|Any CPU + {AF2B4854-10FE-45CC-BA64-0C0B93BF41C4}.Release|x64.Build.0 = Release|Any CPU + {AF2B4854-10FE-45CC-BA64-0C0B93BF41C4}.Release|x86.ActiveCfg = Release|Any CPU + {AF2B4854-10FE-45CC-BA64-0C0B93BF41C4}.Release|x86.Build.0 = Release|Any CPU + {D7936C41-351B-43FD-B90B-5477375EEC1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D7936C41-351B-43FD-B90B-5477375EEC1E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D7936C41-351B-43FD-B90B-5477375EEC1E}.Debug|x64.ActiveCfg = Debug|Any CPU + {D7936C41-351B-43FD-B90B-5477375EEC1E}.Debug|x64.Build.0 = Debug|Any CPU + {D7936C41-351B-43FD-B90B-5477375EEC1E}.Debug|x86.ActiveCfg = Debug|Any CPU + {D7936C41-351B-43FD-B90B-5477375EEC1E}.Debug|x86.Build.0 = Debug|Any CPU + {D7936C41-351B-43FD-B90B-5477375EEC1E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D7936C41-351B-43FD-B90B-5477375EEC1E}.Release|Any CPU.Build.0 = Release|Any CPU + {D7936C41-351B-43FD-B90B-5477375EEC1E}.Release|x64.ActiveCfg = Release|Any CPU + {D7936C41-351B-43FD-B90B-5477375EEC1E}.Release|x64.Build.0 = Release|Any CPU + {D7936C41-351B-43FD-B90B-5477375EEC1E}.Release|x86.ActiveCfg = Release|Any CPU + {D7936C41-351B-43FD-B90B-5477375EEC1E}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/SushiBar/SushiBarBusinessLogic/ComponentLogic.cs b/SushiBar/SushiBarBusinessLogic/ComponentLogic.cs index 98d9d85..f4885e5 100644 --- a/SushiBar/SushiBarBusinessLogic/ComponentLogic.cs +++ b/SushiBar/SushiBarBusinessLogic/ComponentLogic.cs @@ -52,7 +52,6 @@ namespace SushiBarBusinessLogic.BusinessLogics return false; } return true; - 18 } public bool Update(ComponentBindingModel model) { diff --git a/SushiBar/SushiBarBusinessLogic_/ComponentLogic.cs b/SushiBar/SushiBarBusinessLogic_/ComponentLogic.cs new file mode 100644 index 0000000..46d0d91 --- /dev/null +++ b/SushiBar/SushiBarBusinessLogic_/ComponentLogic.cs @@ -0,0 +1,117 @@ +using Microsoft.Extensions.Logging; +using SushiBarContracts.BindingModels; +using SushiBarContracts.BusinessLogicsContracts; +using SushiBarContracts.SearchModels; +using SushiBarContracts.StoragesContracts; +using SushiBarContracts.ViewModels; +using SushiBarDataModels.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarBusinessLogic.BusinessLogics +{ + public class ComponentLogic : IComponentLogic + { + + private readonly ILogger _logger; + private readonly IComponentStorage _componentStorage; + public ComponentLogic(ILogger logger, IComponentStorage + componentStorage) + { + _logger = logger; + _componentStorage = componentStorage; + } + public List? ReadList(ComponentSearchModel? model) + { + _logger.LogInformation("ReadList. ComponentName:{ComponentName}. Id:{ Id}", model?.ComponentName, model?.Id); + var list = model == null ? _componentStorage.GetFullList() : _componentStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public ComponentViewModel? ReadElement(ComponentSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. ComponentName:{ComponentName}. Id:{ Id} ", model.ComponentName, model.Id); + var element = _componentStorage.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(ComponentBindingModel model) + { + CheckModel(model); + if (_componentStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(ComponentBindingModel model) + { + CheckModel(model); + if (_componentStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(ComponentBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_componentStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(ComponentBindingModel model, bool withParams = + true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.ComponentName)) + { + throw new ArgumentNullException("Нет названия компонента", + nameof(model.ComponentName)); + } + if (model.Cost <= 0) + { + throw new ArgumentNullException("Цена компонента должна больше 0", nameof(model.Cost)); + } + _logger.LogInformation("Component. ComponentName:{ComponentName}. Cost:{ Cost}. Id: { Id} ", model.ComponentName, model.Cost, model.Id); + var element = _componentStorage.GetElement(new ComponentSearchModel + { + ComponentName = model.ComponentName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Компонент с таким названием уже есть"); + } + } + } +} \ No newline at end of file diff --git a/SushiBar/SushiBarBusinessLogic_/OrderLogic.cs b/SushiBar/SushiBarBusinessLogic_/OrderLogic.cs new file mode 100644 index 0000000..ac3e5f0 --- /dev/null +++ b/SushiBar/SushiBarBusinessLogic_/OrderLogic.cs @@ -0,0 +1,125 @@ +using Microsoft.Extensions.Logging; +using SushiBarContracts.BindingModels; +using SushiBarContracts.BusinessLogicsContracts; +using SushiBarContracts.SearchModels; +using SushiBarContracts.StoragesContracts; +using SushiBarContracts.ViewModels; +using SushiBarDataModels.Enums; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarBusinessLogic.BusinessLogics +{ + public class OrderLogic : IOrderLogic + { + private readonly ILogger _logger; + private readonly IOrderStorage _orderStorage; + public OrderLogic(ILogger logger, IOrderStorage orderStorage) + { + _logger = logger; + _orderStorage = orderStorage; + } + public List? ReadList(OrderSearchModel? model) + { + _logger.LogInformation("ReadList. OrderId:{Id}", model?.Id); + var list = model == null ? _orderStorage.GetFullList() : _orderStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public bool CreateOrder(OrderBindingModel model) + { + CheckModel(model); + if (model.Status != OrderStatus.Неизвестен) + return false; + model.Status = OrderStatus.Принят; + if (_orderStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + + public bool TakeOrderInWork(OrderBindingModel model) + { + return ChangeStatus(model, OrderStatus.Выполняется); + } + + public bool FinishOrder(OrderBindingModel model) + { + return ChangeStatus(model, OrderStatus.Готов); + } + + public bool DeliveryOrder(OrderBindingModel model) + { + return ChangeStatus(model, OrderStatus.Выдан); + } + + private void CheckModel(OrderBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (model.Count <= 0) + { + throw new ArgumentException("Колличество пиццы в заказе не может быть меньше 1", nameof(model.Count)); + } + if (model.Sum <= 0) + { + throw new ArgumentException("Стоимость заказа на может быть меньше 1", nameof(model.Sum)); + } + if (model.DateImplement.HasValue && model.DateImplement < model.DateCreate) + { + throw new ArithmeticException($"Дата выдачи заказа {model.DateImplement} не может быть раньше даты его создания {model.DateCreate}"); + } + _logger.LogInformation("Sushi. SushiId:{SushiId}.Count:{Count}.Sum:{Sum}Id:{Id}", + model.SushiId, model.Count, model.Sum, model.Id); + } + + private bool ChangeStatus(OrderBindingModel model, OrderStatus requiredStatus) + { + CheckModel(model, false); + var element = _orderStorage.GetElement(new OrderSearchModel() + { + Id = model.Id + }); + if (element == null) + { + throw new ArgumentNullException(nameof(element)); + } + model.DateCreate = element.DateCreate; + model.SushiId = element.SushiId; + model.DateImplement = element.DateImplement; + model.Status = element.Status; + model.Count = element.Count; + model.Sum = element.Sum; + if (requiredStatus - model.Status == 1) + { + model.Status = requiredStatus; + if (model.Status == OrderStatus.Выдан) + model.DateImplement = DateTime.Now; + if (_orderStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + _logger.LogWarning("Changing status operation faled: Current-{Status}:required-{requiredStatus}.", model.Status, requiredStatus); + throw new ArgumentException($"Невозможно присвоить статус {requiredStatus} заказу с текущим статусом {model.Status}"); + } + } +} diff --git a/SushiBar/SushiBarBusinessLogic_/SushiBarBusinessLogic.csproj b/SushiBar/SushiBarBusinessLogic_/SushiBarBusinessLogic.csproj new file mode 100644 index 0000000..8d13c8d --- /dev/null +++ b/SushiBar/SushiBarBusinessLogic_/SushiBarBusinessLogic.csproj @@ -0,0 +1,17 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + diff --git a/SushiBar/SushiBarBusinessLogic_/SushiLogic.cs b/SushiBar/SushiBarBusinessLogic_/SushiLogic.cs new file mode 100644 index 0000000..fefe4a4 --- /dev/null +++ b/SushiBar/SushiBarBusinessLogic_/SushiLogic.cs @@ -0,0 +1,117 @@ +using Microsoft.Extensions.Logging; +using SushiBarContracts.BusinessLogicsContracts; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SushiBarContracts.BindingModels; +using SushiBarContracts.BusinessLogicsContracts; +using SushiBarContracts.SearchModels; +using SushiBarContracts.StoragesContracts; +using SushiBarContracts.ViewModels; + +namespace SushiBarBusinessLogic.BusinessLogics +{ + public class SushiLogic :ISushiLogic + { + private readonly ILogger _logger; + private readonly ISushiStorage _SushiStorage; + public SushiLogic(ILogger logger, ISushiStorage SushiStorage) + { + _logger = logger; + _SushiStorage = SushiStorage; + } + public List? ReadList(SushiSearchModel? model) + { + _logger.LogInformation("ReadList. SushiName:{SushiName}.Id:{ Id}", model?.SushiName, model?.Id); + var list = model == null ? _SushiStorage.GetFullList() : _SushiStorage.GetFilteredList(model); + if (list == null) + { + _logger.LogWarning("ReadList return null list"); + return null; + } + _logger.LogInformation("ReadList. Count:{Count}", list.Count); + return list; + } + public SushiViewModel? ReadElement(SushiSearchModel model) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + _logger.LogInformation("ReadElement. SushiName:{SushiName}.Id:{ Id}", model.SushiName, model.Id); + var element = _SushiStorage.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(SushiBindingModel model) + { + CheckModel(model); + if (_SushiStorage.Insert(model) == null) + { + _logger.LogWarning("Insert operation failed"); + return false; + } + return true; + } + public bool Update(SushiBindingModel model) + { + CheckModel(model); + if (_SushiStorage.Update(model) == null) + { + _logger.LogWarning("Update operation failed"); + return false; + } + return true; + } + public bool Delete(SushiBindingModel model) + { + CheckModel(model, false); + _logger.LogInformation("Delete. Id:{Id}", model.Id); + if (_SushiStorage.Delete(model) == null) + { + _logger.LogWarning("Delete operation failed"); + return false; + } + return true; + } + private void CheckModel(SushiBindingModel model, bool withParams = true) + { + if (model == null) + { + throw new ArgumentNullException(nameof(model)); + } + if (!withParams) + { + return; + } + if (string.IsNullOrEmpty(model.SushiName)) + { + throw new ArgumentNullException("Нет названия пиццы", nameof(model.SushiName)); + } + if (model.Price <= 0) + { + throw new ArgumentNullException("Цена пиццы должна быть больше 0", nameof(model.Price)); + } + if (model.SushiComponents == null || model.SushiComponents.Count == 0) + { + throw new ArgumentNullException("Перечень ингредиентов не может быть пустым", nameof(model.SushiComponents)); + } + _logger.LogInformation("Sushi. SushiName:{SushiName}.Price:{Price}.Id: { Id}", model.SushiName, model.Price, model.Id); + var element = _SushiStorage.GetElement(new SushiSearchModel + { + SushiName = model.SushiName + }); + if (element != null && element.Id != model.Id) + { + throw new InvalidOperationException("Пицца с таким названием уже есть"); + } + } + } +} diff --git a/SushiBar/SushiBarListImplement/ComponentStorage.cs b/SushiBar/SushiBarListImplement/ComponentStorage.cs index 463d75c..e06268f 100644 --- a/SushiBar/SushiBarListImplement/ComponentStorage.cs +++ b/SushiBar/SushiBarListImplement/ComponentStorage.cs @@ -50,7 +50,6 @@ namespace SushiBarListImplement.Implements { return null; } - 23 foreach (var component in _source.Components) { if ((!string.IsNullOrEmpty(model.ComponentName) && diff --git a/SushiBar/SushiBarListImplement_/DataListSingleton.cs b/SushiBar/SushiBarListImplement_/DataListSingleton.cs new file mode 100644 index 0000000..6eabe76 --- /dev/null +++ b/SushiBar/SushiBarListImplement_/DataListSingleton.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SushiBarListImplement.Models; + +namespace SushiBarListImplement +{ + public class DataListSingleton + { + private static DataListSingleton? _instance; + public List Components { get; set; } + public List Orders { get; set; } + public List Sushis { get; set; } + private DataListSingleton() + { + Components = new List(); + Orders = new List(); + Sushis = new List(); + } + public static DataListSingleton GetInstance() + { + if (_instance == null) + { + _instance = new DataListSingleton(); + } + return _instance; + } + } +} diff --git a/SushiBar/SushiBarListImplement_/Implements/ComponentStorage.cs b/SushiBar/SushiBarListImplement_/Implements/ComponentStorage.cs new file mode 100644 index 0000000..9ce66c4 --- /dev/null +++ b/SushiBar/SushiBarListImplement_/Implements/ComponentStorage.cs @@ -0,0 +1,110 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SushiBarContracts.BindingModels; +using SushiBarContracts.SearchModels; +using SushiBarContracts.StoragesContracts; +using SushiBarContracts.ViewModels; +using SushiBarListImplement.Models; + +namespace SushiBarListImplement.Implements +{ + public class ComponentStorage : IComponentStorage + { + private readonly DataListSingleton _source; + public ComponentStorage() + { + _source = DataListSingleton.GetInstance(); + } + public List GetFullList() + { + var result = new List(); + foreach (var component in _source.Components) + { + result.Add(component.GetViewModel); + } + return result; + } + public List GetFilteredList(ComponentSearchModel + model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.ComponentName)) + { + return result; + } + foreach (var component in _source.Components) + { + if (component.ComponentName.Contains(model.ComponentName)) + { + result.Add(component.GetViewModel); + } + } + return result; + } + public ComponentViewModel? GetElement(ComponentSearchModel model) + { + if (string.IsNullOrEmpty(model.ComponentName) && !model.Id.HasValue) + { + return null; + } + foreach (var component in _source.Components) + { + if ((!string.IsNullOrEmpty(model.ComponentName) && + component.ComponentName == model.ComponentName) || + (model.Id.HasValue && component.Id == model.Id)) + { + return component.GetViewModel; + } + } + return null; + } + public ComponentViewModel? Insert(ComponentBindingModel model) + { + model.Id = 1; + foreach (var component in _source.Components) + { + if (model.Id <= component.Id) + { + model.Id = component.Id + 1; + } + } + var newComponent = Component.Create(model); + if (newComponent == null) + { + return null; + } + _source.Components.Add(newComponent); + return newComponent.GetViewModel; + } + public ComponentViewModel? Update(ComponentBindingModel model) + { + foreach (var component in _source.Components) + { + if (component.Id == model.Id) + { + component.Update(model); + return component.GetViewModel; + } + } + return null; + } + public ComponentViewModel? Delete(ComponentBindingModel model) + { + for (int i = 0; i < _source.Components.Count; ++i) + { + if (_source.Components[i].Id == model.Id) + { + var element = _source.Components[i]; + _source.Components.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + } + +} + diff --git a/SushiBar/SushiBarListImplement_/Implements/OrderStorage.cs b/SushiBar/SushiBarListImplement_/Implements/OrderStorage.cs new file mode 100644 index 0000000..957b9fa --- /dev/null +++ b/SushiBar/SushiBarListImplement_/Implements/OrderStorage.cs @@ -0,0 +1,125 @@ +using SushiBarContracts.BindingModels; +using SushiBarContracts.SearchModels; +using SushiBarContracts.StoragesContracts; +using SushiBarContracts.ViewModels; +using SushiBarListImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarListImplement.Implements +{ + public class OrderStorage : IOrderStorage + { + private readonly DataListSingleton _source; + + public OrderStorage() + { + _source = DataListSingleton.GetInstance(); + } + + public List GetFullList() + { + var result = new List(); + foreach (var order in _source.Orders) + { + result.Add(AttachSushiName(order.GetViewModel)); + } + return result; + } + + public List GetFilteredList(OrderSearchModel model) + { + var result = new List(); + if (model == null || !model.Id.HasValue) + { + return result; + } + foreach (var order in _source.Orders) + { + if (order.Id == model.Id) + { + result.Add(AttachSushiName(order.GetViewModel)); + } + } + return result; + } + + public OrderViewModel? GetElement(OrderSearchModel model) + { + if (!model.Id.HasValue) + { + return null; + } + foreach (var order in _source.Orders) + { + if (model.Id.HasValue && order.Id == model.Id) + { + return AttachSushiName(order.GetViewModel); + } + } + return null; + } + + public OrderViewModel? Insert(OrderBindingModel model) + { + model.Id = 1; + foreach (var order in _source.Orders) + { + if (model.Id <= order.Id) + { + model.Id = order.Id + 1; + } + } + var newOrder = Order.Create(model); + if (newOrder == null) + { + return null; + } + _source.Orders.Add(newOrder); + return AttachSushiName(newOrder.GetViewModel); + } + + public OrderViewModel? Update(OrderBindingModel model) + { + foreach (var order in _source.Orders) + { + if (order.Id == model.Id) + { + order.Update(model); + return AttachSushiName(order.GetViewModel); + } + } + return null; + } + + public OrderViewModel? Delete(OrderBindingModel model) + { + for (int i = 0; i < _source.Orders.Count; ++i) + { + if (_source.Orders[i].Id == model.Id) + { + var element = _source.Orders[i]; + _source.Orders.RemoveAt(i); + return AttachSushiName(element.GetViewModel); + } + } + return null; + } + + private OrderViewModel AttachSushiName(OrderViewModel model) + { + foreach (var sushi in _source.Sushis) + { + if (sushi.Id == model.SushiId) + { + model.SushiName = sushi.SushiName; + return model; + } + } + return model; + } + } +} diff --git a/SushiBar/SushiBarListImplement_/Implements/SushiStorage.cs b/SushiBar/SushiBarListImplement_/Implements/SushiStorage.cs new file mode 100644 index 0000000..005e5c7 --- /dev/null +++ b/SushiBar/SushiBarListImplement_/Implements/SushiStorage.cs @@ -0,0 +1,113 @@ +using SushiBarContracts.StoragesContracts; +using SushiBarContracts.BindingModels; +using SushiBarContracts.SearchModels; +using SushiBarContracts.ViewModels; +using SushiBarListImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarListImplement.Implements +{ + public class SushiStorage : ISushiStorage + { + private readonly DataListSingleton _source; + + public SushiStorage() + { + _source = DataListSingleton.GetInstance(); + } + + public List GetFullList() + { + var result = new List(); + foreach (var Sushis in _source.Sushis) + { + result.Add(Sushis.GetViewModel); + } + return result; + } + + public List GetFilteredList(SushiSearchModel model) + { + var result = new List(); + if (string.IsNullOrEmpty(model.SushiName)) + { + return result; + } + foreach (var Sushis in _source.Sushis) + { + if (Sushis.SushiName.Contains(model.SushiName)) + { + result.Add(Sushis.GetViewModel); + } + } + return result; + } + + public SushiViewModel? GetElement(SushiSearchModel model) + { + if (string.IsNullOrEmpty(model.SushiName) && !model.Id.HasValue) + { + return null; + } + foreach (var sushis in _source.Sushis) + { + if ((!string.IsNullOrEmpty(model.SushiName) && sushis.SushiName == model.SushiName) || + (model.Id.HasValue && sushis.Id == model.Id)) + { + return sushis.GetViewModel; + } + } + return null; + } + + public SushiViewModel? Insert(SushiBindingModel model) + { + model.Id = 1; + foreach (var sushis in _source.Sushis) + { + if (model.Id <= sushis.Id) + { + model.Id = sushis.Id + 1; + } + } + var newSushis = Sushi.Create(model); + if (newSushis == null) + { + return null; + } + _source.Sushis.Add(newSushis); + return newSushis.GetViewModel; + } + + public SushiViewModel? Update(SushiBindingModel model) + { + foreach (var sushis in _source.Sushis) + { + if (sushis.Id == model.Id) + { + sushis.Update(model); + return sushis.GetViewModel; + } + } + return null; + } + + public SushiViewModel? Delete(SushiBindingModel model) + { + for (int i = 0; i < _source.Sushis.Count; ++i) + { + if (_source.Sushis[i].Id == model.Id) + { + var element = _source.Sushis[i]; + _source.Sushis.RemoveAt(i); + return element.GetViewModel; + } + } + return null; + } + } +} diff --git a/SushiBar/SushiBarListImplement_/Models/Component.cs b/SushiBar/SushiBarListImplement_/Models/Component.cs new file mode 100644 index 0000000..ecebaf6 --- /dev/null +++ b/SushiBar/SushiBarListImplement_/Models/Component.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SushiBarContracts; +using SushiBarDataModels; +using SushiBarContracts.BindingModels; +using SushiBarContracts.ViewModels; +using SushiBarDataModels.Models; + +namespace SushiBarListImplement.Models +{ + public class Component : IComponentModel + { + public int Id { get; private set; } + public string ComponentName { get; private set; } = string.Empty; + public double Cost { get; set; } + public static Component? Create(ComponentBindingModel? model) + { + if (model == null) + { + return null; + } + return new Component() + { + Id = model.Id, + ComponentName = model.ComponentName, + Cost = model.Cost + }; + } + public void Update(ComponentBindingModel? model) + { + if (model == null) + { + return; + } + ComponentName = model.ComponentName; + Cost = model.Cost; + } + public ComponentViewModel GetViewModel => new() + { + Id = Id, + ComponentName = ComponentName, + Cost = Cost + }; + } +} diff --git a/SushiBar/SushiBarListImplement_/Models/Order.cs b/SushiBar/SushiBarListImplement_/Models/Order.cs new file mode 100644 index 0000000..f1d69d4 --- /dev/null +++ b/SushiBar/SushiBarListImplement_/Models/Order.cs @@ -0,0 +1,62 @@ +using SushiBarContracts.BindingModels; +using SushiBarContracts.ViewModels; +using SushiBarDataModels.Enums; +using SushiBarDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace SushiBarListImplement.Models +{ + public class Order : IOrderModel + { + public int Id { get; private set; } + public int SushiId { get; private set; } + public int Count { get; private set; } + public double Sum { get; private set; } + public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; + public DateTime DateCreate { get; private set; } = DateTime.Now; + public DateTime? DateImplement { get; private set; } + + public static Order? Create(OrderBindingModel? model) + { + if (model == null) + { + return null; + } + return new Order() + { + Id = model.Id, + SushiId = model.SushiId, + Count = model.Count, + Sum = model.Sum, + Status = model.Status, + DateCreate = model.DateCreate, + DateImplement = model.DateImplement, + }; + } + + public void Update(OrderBindingModel? model) + { + if (model == null) + { + return; + } + Status = model.Status; + if (model.Status == OrderStatus.Выдан) DateImplement = model.DateImplement; + } + + public OrderViewModel GetViewModel => new() + { + Id = Id, + SushiId = SushiId, + Count = Count, + Sum = Sum, + Status = Status, + DateCreate = DateCreate, + DateImplement = DateImplement, + }; + } +} diff --git a/SushiBar/SushiBarListImplement_/Models/Sushi.cs b/SushiBar/SushiBarListImplement_/Models/Sushi.cs new file mode 100644 index 0000000..6f6bce2 --- /dev/null +++ b/SushiBar/SushiBarListImplement_/Models/Sushi.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using SushiBarContracts.BindingModels; +using SushiBarContracts.ViewModels; +using SushiBarDataModels.Models; + +namespace SushiBarListImplement.Models +{ + public class Sushi : ISushiModel + { + public int Id { get; private set; } + public string SushiName { get; private set; } = string.Empty; + public double Price { get; private set; } + public Dictionary SushiComponents + { + get; + private set; + } = new Dictionary(); + public static Sushi? Create(SushiBindingModel? model) + { + if (model == null) + { + return null; + } + return new Sushi() + { + Id = model.Id, + SushiName = model.SushiName, + Price = model.Price, + SushiComponents = model.SushiComponents + }; + } + public void Update(SushiBindingModel? model) + { + if (model == null) + { + return; + } + SushiName = model.SushiName; + Price = model.Price; + SushiComponents = model.SushiComponents; + } + public SushiViewModel GetViewModel => new() + { + Id = Id, + SushiName = SushiName, + Price = Price, + SushiComponents = SushiComponents + }; + + } +} diff --git a/SushiBar/SushiBarListImplement_/SushiBarListImplement.csproj b/SushiBar/SushiBarListImplement_/SushiBarListImplement.csproj new file mode 100644 index 0000000..ec020c5 --- /dev/null +++ b/SushiBar/SushiBarListImplement_/SushiBarListImplement.csproj @@ -0,0 +1,14 @@ + + + + net6.0 + enable + enable + + + + + + + + diff --git a/SushiBar/SushiBarView/FormComponent.Designer.cs b/SushiBar/SushiBarView/FormComponent.Designer.cs index f8da578..e12b999 100644 --- a/SushiBar/SushiBarView/FormComponent.Designer.cs +++ b/SushiBar/SushiBarView/FormComponent.Designer.cs @@ -77,21 +77,21 @@ // this.textBoxName.Location = new System.Drawing.Point(83, 21); this.textBoxName.Name = "textBoxName"; - this.textBoxName.Size = new System.Drawing.Size(133, 23); + this.textBoxName.Size = new System.Drawing.Size(262, 23); this.textBoxName.TabIndex = 4; // // textBoxCost // this.textBoxCost.Location = new System.Drawing.Point(83, 57); this.textBoxCost.Name = "textBoxCost"; - this.textBoxCost.Size = new System.Drawing.Size(133, 23); + this.textBoxCost.Size = new System.Drawing.Size(262, 23); this.textBoxCost.TabIndex = 5; // // FormComponent // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(357, 137); + this.ClientSize = new System.Drawing.Size(354, 131); this.Controls.Add(this.textBoxCost); this.Controls.Add(this.textBoxName); this.Controls.Add(this.labelCost); @@ -100,6 +100,7 @@ this.Controls.Add(this.ButtonSave); this.Name = "FormComponent"; this.Text = "Компонент"; + this.Load += new System.EventHandler(this.FormComponent_Load); this.ResumeLayout(false); this.PerformLayout(); diff --git a/SushiBar/SushiBarView/FormComponent.cs b/SushiBar/SushiBarView/FormComponent.cs index 2b7fce4..dfacef0 100644 --- a/SushiBar/SushiBarView/FormComponent.cs +++ b/SushiBar/SushiBarView/FormComponent.cs @@ -66,8 +66,7 @@ namespace SushiBarView _logger.LogInformation(" "); var view = _logic.ReadElement(new ComponentSearchModel { - Id = - _id.Value + Id = _id.Value }); if (view != null) { diff --git a/SushiBar/SushiBarView/FormComponents.Designer.cs b/SushiBar/SushiBarView/FormComponents.Designer.cs new file mode 100644 index 0000000..27db7a7 --- /dev/null +++ b/SushiBar/SushiBarView/FormComponents.Designer.cs @@ -0,0 +1,115 @@ +namespace SushiBarView +{ + partial class FormComponents + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.ButtonUpd = new System.Windows.Forms.Button(); + this.ButtonDel = new System.Windows.Forms.Button(); + this.ButtonAdd = new System.Windows.Forms.Button(); + this.ButtonRef = new System.Windows.Forms.Button(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // ButtonUpd + // + this.ButtonUpd.Location = new System.Drawing.Point(499, 74); + this.ButtonUpd.Name = "ButtonUpd"; + this.ButtonUpd.Size = new System.Drawing.Size(112, 35); + this.ButtonUpd.TabIndex = 0; + this.ButtonUpd.Text = "Изменить"; + this.ButtonUpd.UseVisualStyleBackColor = true; + this.ButtonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); + // + // ButtonDel + // + this.ButtonDel.Location = new System.Drawing.Point(499, 126); + this.ButtonDel.Name = "ButtonDel"; + this.ButtonDel.Size = new System.Drawing.Size(112, 35); + this.ButtonDel.TabIndex = 1; + this.ButtonDel.Text = "Удалить"; + this.ButtonDel.UseVisualStyleBackColor = true; + this.ButtonDel.Click += new System.EventHandler(this.ButtonDel_Click); + // + // ButtonAdd + // + this.ButtonAdd.Location = new System.Drawing.Point(499, 23); + this.ButtonAdd.Name = "ButtonAdd"; + this.ButtonAdd.Size = new System.Drawing.Size(112, 35); + this.ButtonAdd.TabIndex = 2; + this.ButtonAdd.Text = "Добавить"; + this.ButtonAdd.UseVisualStyleBackColor = true; + this.ButtonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // ButtonRef + // + this.ButtonRef.Location = new System.Drawing.Point(499, 177); + this.ButtonRef.Name = "ButtonRef"; + this.ButtonRef.Size = new System.Drawing.Size(112, 35); + this.ButtonRef.TabIndex = 3; + this.ButtonRef.Text = "Обновить"; + this.ButtonRef.UseVisualStyleBackColor = true; + this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click); + // + // dataGridView + // + this.dataGridView.BackgroundColor = System.Drawing.Color.White; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(12, 12); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(454, 365); + this.dataGridView.TabIndex = 4; + // + // FormComponents + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(623, 389); + this.Controls.Add(this.dataGridView); + this.Controls.Add(this.ButtonRef); + this.Controls.Add(this.ButtonAdd); + this.Controls.Add(this.ButtonDel); + this.Controls.Add(this.ButtonUpd); + this.Name = "FormComponents"; + this.Text = "FormComponents"; + this.Load += new System.EventHandler(this.FormComponents_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private Button ButtonUpd; + private Button ButtonDel; + private Button ButtonAdd; + private Button ButtonRef; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/SushiBar/SushiBarView/FormComponents.cs b/SushiBar/SushiBarView/FormComponents.cs new file mode 100644 index 0000000..704c8e0 --- /dev/null +++ b/SushiBar/SushiBarView/FormComponents.cs @@ -0,0 +1,123 @@ +using Microsoft.Extensions.Logging; +using SushiBarContracts.BindingModels; +using SushiBarContracts.BusinessLogicsContracts; +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 SushiBarView +{ + public partial class FormComponents : Form + { + public FormComponents() + { + InitializeComponent(); + } + private readonly ILogger _logger; + private readonly IComponentLogic _logic; + public FormComponents(ILogger logger, IComponentLogic + logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormComponents_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + try + { + var list = _logic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["ComponentName"].AutoSizeMode = + DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Загрузка компонентов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки компонентов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormComponent)); + if (service is FormComponent form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = + Program.ServiceProvider?.GetService(typeof(FormComponent)); + if (service is FormComponent form) + { + form.Id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + } + private void ButtonDel_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 ComponentBindingModel + { + Id = id + })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления компонента"); + MessageBox.Show(ex.Message, "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + + } +} diff --git a/SushiBar/SushiBarView/FormComponents.resx b/SushiBar/SushiBarView/FormComponents.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/SushiBar/SushiBarView/FormComponents.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SushiBar/SushiBarView/FormCreateOrder.Designer.cs b/SushiBar/SushiBarView/FormCreateOrder.Designer.cs new file mode 100644 index 0000000..fe9c140 --- /dev/null +++ b/SushiBar/SushiBarView/FormCreateOrder.Designer.cs @@ -0,0 +1,145 @@ +namespace SushiBarView +{ + partial class FormCreateOrder + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.textBoxCount = new System.Windows.Forms.TextBox(); + this.labelCost = new System.Windows.Forms.Label(); + this.labelName = new System.Windows.Forms.Label(); + this.textBoxSum = new System.Windows.Forms.TextBox(); + this.label1 = new System.Windows.Forms.Label(); + this.ButtonCancel = new System.Windows.Forms.Button(); + this.ButtonSave = new System.Windows.Forms.Button(); + this.comboBoxSushi = new System.Windows.Forms.ComboBox(); + this.SuspendLayout(); + // + // textBoxCount + // + this.textBoxCount.Location = new System.Drawing.Point(83, 42); + this.textBoxCount.Name = "textBoxCount"; + this.textBoxCount.Size = new System.Drawing.Size(262, 23); + this.textBoxCount.TabIndex = 9; + this.textBoxCount.TextChanged += new System.EventHandler(this.textBoxCost_TextChanged); + // + // labelCost + // + this.labelCost.AutoSize = true; + this.labelCost.Location = new System.Drawing.Point(5, 45); + this.labelCost.Name = "labelCost"; + this.labelCost.Size = new System.Drawing.Size(72, 15); + this.labelCost.TabIndex = 7; + this.labelCost.Text = "Количество"; + this.labelCost.Click += new System.EventHandler(this.labelCost_Click); + // + // labelName + // + this.labelName.AutoSize = true; + this.labelName.Location = new System.Drawing.Point(5, 12); + this.labelName.Name = "labelName"; + this.labelName.Size = new System.Drawing.Size(53, 15); + this.labelName.TabIndex = 6; + this.labelName.Text = "Изделие"; + // + // textBoxSum + // + this.textBoxSum.Location = new System.Drawing.Point(83, 80); + this.textBoxSum.Name = "textBoxSum"; + this.textBoxSum.Size = new System.Drawing.Size(262, 23); + this.textBoxSum.TabIndex = 11; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(5, 83); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(45, 15); + this.label1.TabIndex = 10; + this.label1.Text = "Сумма"; + // + // ButtonCancel + // + this.ButtonCancel.Location = new System.Drawing.Point(258, 120); + this.ButtonCancel.Name = "ButtonCancel"; + this.ButtonCancel.Size = new System.Drawing.Size(87, 26); + this.ButtonCancel.TabIndex = 13; + this.ButtonCancel.Text = "Отмена"; + this.ButtonCancel.UseVisualStyleBackColor = true; + this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // ButtonSave + // + this.ButtonSave.Location = new System.Drawing.Point(165, 120); + this.ButtonSave.Name = "ButtonSave"; + this.ButtonSave.Size = new System.Drawing.Size(87, 26); + this.ButtonSave.TabIndex = 12; + this.ButtonSave.Text = "Сохранить"; + this.ButtonSave.UseVisualStyleBackColor = true; + this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // comboBoxSushi + // + this.comboBoxSushi.FormattingEnabled = true; + this.comboBoxSushi.Location = new System.Drawing.Point(83, 9); + this.comboBoxSushi.Name = "comboBoxSushi"; + this.comboBoxSushi.Size = new System.Drawing.Size(262, 23); + this.comboBoxSushi.TabIndex = 14; + this.comboBoxSushi.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); + // + // FormCreateOrder + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(354, 158); + this.Controls.Add(this.comboBoxSushi); + this.Controls.Add(this.ButtonCancel); + this.Controls.Add(this.ButtonSave); + this.Controls.Add(this.textBoxSum); + this.Controls.Add(this.label1); + this.Controls.Add(this.textBoxCount); + this.Controls.Add(this.labelCost); + this.Controls.Add(this.labelName); + this.Name = "FormCreateOrder"; + this.Text = "FormCreateOrder"; + this.Load += new System.EventHandler(this.FormCreateOrder_Load); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private TextBox textBoxCount; + private Label labelCost; + private Label labelName; + private TextBox textBoxSum; + private Label label1; + private Button ButtonCancel; + private Button ButtonSave; + private ComboBox comboBoxSushi; + } +} \ No newline at end of file diff --git a/SushiBar/SushiBarView/FormCreateOrder.cs b/SushiBar/SushiBarView/FormCreateOrder.cs new file mode 100644 index 0000000..fd23448 --- /dev/null +++ b/SushiBar/SushiBarView/FormCreateOrder.cs @@ -0,0 +1,136 @@ +using Microsoft.Extensions.Logging; +using SushiBarContracts.BindingModels; +using SushiBarContracts.BusinessLogicsContracts; +using SushiBarContracts.SearchModels; +using SushiBarContracts.ViewModels; +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 SushiBarView +{ + public partial class FormCreateOrder : Form + { + private readonly ILogger _logger; + private readonly ISushiLogic _logicP; + private readonly IOrderLogic _logicO; + private List? _list; + public FormCreateOrder() + { + InitializeComponent(); + } + public FormCreateOrder(ILogger logger, ISushiLogic logicP, IOrderLogic logicO) + { + InitializeComponent(); + _logger = logger; + _logicP = logicP; + _logicO = logicO; + } + private void FormCreateOrder_Load(object sender, EventArgs e) + { + _logger.LogInformation("Загрузка изделий для заказа"); + _list = _logicP.ReadList(null); + if (_list != null) + { + comboBoxSushi.DisplayMember = "SushiName"; + comboBoxSushi.ValueMember = "Id"; + comboBoxSushi.DataSource = _list; + comboBoxSushi.SelectedItem = null; + _logger.LogInformation("Загрузка суши для заказа"); + } + } + private void labelCost_Click(object sender, EventArgs e) + { + + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxCount.Text)) + { + MessageBox.Show("Заполните поле Количество", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxSushi.SelectedValue == null) + { + MessageBox.Show("Выберите изделие", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Создание заказа"); + try + { + var operationResult = _logicO.CreateOrder(new OrderBindingModel + { + SushiId = Convert.ToInt32(comboBoxSushi.SelectedValue), + Count = Convert.ToInt32(textBoxCount.Text), + Sum = Convert.ToDouble(textBoxSum.Text) + }); + 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); + } + } + private void CalcSum() + { + if (comboBoxSushi.SelectedValue != null && + !string.IsNullOrEmpty(textBoxCount.Text)) + { + try + { + int id = Convert.ToInt32(comboBoxSushi.SelectedValue); + var sushi = _logicP.ReadElement(new SushiSearchModel + { + Id + = id + }); + int count = Convert.ToInt32(textBoxCount.Text); + textBoxSum.Text = Math.Round(count * (sushi?.Price ?? 0), + 2).ToString(); + _logger.LogInformation("Расчет суммы заказа"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка расчета суммы заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + + private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) + { + CalcSum(); + } + + private void textBoxCost_TextChanged(object sender, EventArgs e) + { + CalcSum(); + } + + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + } +} diff --git a/SushiBar/SushiBarView/FormCreateOrder.resx b/SushiBar/SushiBarView/FormCreateOrder.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/SushiBar/SushiBarView/FormCreateOrder.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SushiBar/SushiBarView/FormMain.Designer.cs b/SushiBar/SushiBarView/FormMain.Designer.cs new file mode 100644 index 0000000..0c2348d --- /dev/null +++ b/SushiBar/SushiBarView/FormMain.Designer.cs @@ -0,0 +1,175 @@ +namespace SushiBarView +{ + partial class FormMain + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.ButtonCreateOrder = new System.Windows.Forms.Button(); + this.ButtonOrderReady = new System.Windows.Forms.Button(); + this.ButtonRef = new System.Windows.Forms.Button(); + this.ButtonIssuedOrder = new System.Windows.Forms.Button(); + this.ButtonTakeOrderInWork = new System.Windows.Forms.Button(); + this.menuStrip = new System.Windows.Forms.MenuStrip(); + this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); + this.componentsToolStripMenuItemToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.sushiToolStripMenuItemToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.menuStrip.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // ButtonCreateOrder + // + this.ButtonCreateOrder.Location = new System.Drawing.Point(676, 37); + this.ButtonCreateOrder.Name = "ButtonCreateOrder"; + this.ButtonCreateOrder.Size = new System.Drawing.Size(217, 29); + this.ButtonCreateOrder.TabIndex = 0; + this.ButtonCreateOrder.Text = "Создать заказ"; + this.ButtonCreateOrder.UseVisualStyleBackColor = true; + this.ButtonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click); + // + // ButtonOrderReady + // + this.ButtonOrderReady.Location = new System.Drawing.Point(676, 180); + this.ButtonOrderReady.Name = "ButtonOrderReady"; + this.ButtonOrderReady.Size = new System.Drawing.Size(217, 29); + this.ButtonOrderReady.TabIndex = 1; + this.ButtonOrderReady.Text = "Заказ готов"; + this.ButtonOrderReady.UseVisualStyleBackColor = true; + this.ButtonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click); + // + // ButtonRef + // + this.ButtonRef.Location = new System.Drawing.Point(676, 323); + this.ButtonRef.Name = "ButtonRef"; + this.ButtonRef.Size = new System.Drawing.Size(217, 29); + this.ButtonRef.TabIndex = 2; + this.ButtonRef.Text = "Обновить список"; + this.ButtonRef.UseVisualStyleBackColor = true; + this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click); + // + // ButtonIssuedOrder + // + this.ButtonIssuedOrder.Location = new System.Drawing.Point(676, 256); + this.ButtonIssuedOrder.Name = "ButtonIssuedOrder"; + this.ButtonIssuedOrder.Size = new System.Drawing.Size(217, 29); + this.ButtonIssuedOrder.TabIndex = 3; + this.ButtonIssuedOrder.Text = "Заказ выполнен"; + this.ButtonIssuedOrder.UseVisualStyleBackColor = true; + this.ButtonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click); + // + // ButtonTakeOrderInWork + // + this.ButtonTakeOrderInWork.Location = new System.Drawing.Point(676, 109); + this.ButtonTakeOrderInWork.Name = "ButtonTakeOrderInWork"; + this.ButtonTakeOrderInWork.Size = new System.Drawing.Size(217, 29); + this.ButtonTakeOrderInWork.TabIndex = 4; + this.ButtonTakeOrderInWork.Text = "Отдать на выполнение"; + this.ButtonTakeOrderInWork.UseVisualStyleBackColor = true; + this.ButtonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click); + // + // menuStrip + // + this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.toolStripMenuItem1}); + this.menuStrip.Location = new System.Drawing.Point(0, 0); + this.menuStrip.Name = "menuStrip"; + this.menuStrip.Size = new System.Drawing.Size(922, 24); + this.menuStrip.TabIndex = 5; + this.menuStrip.Text = "menuStrip1"; + // + // toolStripMenuItem1 + // + this.toolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.componentsToolStripMenuItemToolStripMenuItem, + this.sushiToolStripMenuItemToolStripMenuItem}); + this.toolStripMenuItem1.Name = "toolStripMenuItem1"; + this.toolStripMenuItem1.Size = new System.Drawing.Size(94, 20); + this.toolStripMenuItem1.Text = "Справочники"; + // + // componentsToolStripMenuItemToolStripMenuItem + // + this.componentsToolStripMenuItemToolStripMenuItem.Name = "componentsToolStripMenuItemToolStripMenuItem"; + this.componentsToolStripMenuItemToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.componentsToolStripMenuItemToolStripMenuItem.Text = "Компоненты"; + this.componentsToolStripMenuItemToolStripMenuItem.Click += new System.EventHandler(this.componentsToolStripMenuItem_Click); + // + // sushiToolStripMenuItemToolStripMenuItem + // + this.sushiToolStripMenuItemToolStripMenuItem.Name = "sushiToolStripMenuItemToolStripMenuItem"; + this.sushiToolStripMenuItemToolStripMenuItem.Size = new System.Drawing.Size(180, 22); + this.sushiToolStripMenuItemToolStripMenuItem.Text = "Суши"; + this.sushiToolStripMenuItemToolStripMenuItem.Click += new System.EventHandler(this.sushiToolStripMenuItem_Click); + // + // dataGridView + // + this.dataGridView.BackgroundColor = System.Drawing.Color.White; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(12, 27); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(647, 344); + this.dataGridView.TabIndex = 6; + // + // FormMain + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(922, 383); + this.Controls.Add(this.dataGridView); + this.Controls.Add(this.ButtonTakeOrderInWork); + this.Controls.Add(this.ButtonIssuedOrder); + this.Controls.Add(this.ButtonRef); + this.Controls.Add(this.ButtonOrderReady); + this.Controls.Add(this.ButtonCreateOrder); + this.Controls.Add(this.menuStrip); + this.MainMenuStrip = this.menuStrip; + this.Name = "FormMain"; + this.Text = "FormMain"; + this.Load += new System.EventHandler(this.FormMain_Load); + this.menuStrip.ResumeLayout(false); + this.menuStrip.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private Button ButtonCreateOrder; + private Button ButtonOrderReady; + private Button ButtonRef; + private Button ButtonIssuedOrder; + private Button ButtonTakeOrderInWork; + private MenuStrip menuStrip; + private ToolStripMenuItem toolStripMenuItem1; + private ToolStripMenuItem componentsToolStripMenuItemToolStripMenuItem; + private ToolStripMenuItem sushiToolStripMenuItemToolStripMenuItem; + private DataGridView dataGridView; + } +} \ No newline at end of file diff --git a/SushiBar/SushiBarView/FormMain.cs b/SushiBar/SushiBarView/FormMain.cs new file mode 100644 index 0000000..0ca85b9 --- /dev/null +++ b/SushiBar/SushiBarView/FormMain.cs @@ -0,0 +1,171 @@ +using Microsoft.Extensions.Logging; +using SushiBarContracts.BindingModels; +using SushiBarContracts.BusinessLogicsContracts; +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 SushiBarView +{ + public partial class FormMain : Form + { + public FormMain() + { + InitializeComponent(); + } + + private void ButtonCreateOrder_Click(object sender, EventArgs e) + { + var service = + Program.ServiceProvider?.GetService(typeof(FormCreateOrder)); + if (service is FormCreateOrder form) + { + form.ShowDialog(); + LoadData(); + } + } + + private readonly ILogger _logger; + private readonly IOrderLogic _orderLogic; + public FormMain(ILogger logger, IOrderLogic orderLogic) + { + InitializeComponent(); + _logger = logger; + _orderLogic = orderLogic; + } + private void FormMain_Load(object sender, EventArgs e) + { + LoadData(); + } + private void LoadData() + { + _logger.LogInformation("Загрузка заказов"); + try + { + var list = _orderLogic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["SushiId"].Visible = false; + dataGridView.Columns["SushiName"].AutoSizeMode = + DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Загрузка заказов"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки заказов"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + private void componentsToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormComponents)); + if (service is FormComponents form) + { + form.ShowDialog(); + } + } + private void sushiToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormSushis)); + if (service is FormSushis form) + { + form.ShowDialog(); + } + } + + private void ButtonTakeOrderInWork_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); + try + { + var operationResult = _orderLogic.TakeOrderInWork(new + OrderBindingModel + { Id = id }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка передачи заказа в работу"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void ButtonOrderReady_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", + id); + try + { + var operationResult = _orderLogic.FinishOrder(new + OrderBindingModel + { Id = id }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о готовности заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, +MessageBoxIcon.Error); + } + } + } + private void ButtonIssuedOrder_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", + id); + try + { + var operationResult = _orderLogic.DeliveryOrder(new + OrderBindingModel + { Id = id }); + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + _logger.LogInformation("Заказ №{id} выдан", id); + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о выдачи заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + + } +} diff --git a/SushiBar/SushiBarView/FormMain.resx b/SushiBar/SushiBarView/FormMain.resx new file mode 100644 index 0000000..81a9e3d --- /dev/null +++ b/SushiBar/SushiBarView/FormMain.resx @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/SushiBar/SushiBarView/FormSushi.Designer.cs b/SushiBar/SushiBarView/FormSushi.Designer.cs new file mode 100644 index 0000000..3f53aec --- /dev/null +++ b/SushiBar/SushiBarView/FormSushi.Designer.cs @@ -0,0 +1,198 @@ +namespace SushiBarView +{ + partial class FormSushi + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.textBoxPrice = new System.Windows.Forms.TextBox(); + this.textBoxName = new System.Windows.Forms.TextBox(); + this.labelCost = new System.Windows.Forms.Label(); + this.labelName = new System.Windows.Forms.Label(); + this.panel1 = new System.Windows.Forms.Panel(); + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.ButtonRef = new System.Windows.Forms.Button(); + this.ButtonAdd = new System.Windows.Forms.Button(); + this.ButtonDel = new System.Windows.Forms.Button(); + this.ButtonUpd = new System.Windows.Forms.Button(); + this.ButtonCancel = new System.Windows.Forms.Button(); + this.ButtonSave = new System.Windows.Forms.Button(); + this.panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // textBoxPrice + // + this.textBoxPrice.Location = new System.Drawing.Point(84, 48); + this.textBoxPrice.Name = "textBoxPrice"; + this.textBoxPrice.Size = new System.Drawing.Size(262, 23); + this.textBoxPrice.TabIndex = 9; + // + // textBoxName + // + this.textBoxName.Location = new System.Drawing.Point(84, 12); + this.textBoxName.Name = "textBoxName"; + this.textBoxName.Size = new System.Drawing.Size(262, 23); + this.textBoxName.TabIndex = 8; + // + // labelCost + // + this.labelCost.AutoSize = true; + this.labelCost.Location = new System.Drawing.Point(13, 56); + this.labelCost.Name = "labelCost"; + this.labelCost.Size = new System.Drawing.Size(35, 15); + this.labelCost.TabIndex = 7; + this.labelCost.Text = "Цена"; + // + // labelName + // + this.labelName.AutoSize = true; + this.labelName.Location = new System.Drawing.Point(13, 15); + this.labelName.Name = "labelName"; + this.labelName.Size = new System.Drawing.Size(59, 15); + this.labelName.TabIndex = 6; + this.labelName.Text = "Название"; + // + // panel1 + // + this.panel1.Controls.Add(this.dataGridView); + this.panel1.Controls.Add(this.ButtonRef); + this.panel1.Controls.Add(this.ButtonAdd); + this.panel1.Controls.Add(this.ButtonDel); + this.panel1.Controls.Add(this.ButtonUpd); + this.panel1.Location = new System.Drawing.Point(13, 100); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(725, 282); + this.panel1.TabIndex = 10; + // + // dataGridView + // + this.dataGridView.BackgroundColor = System.Drawing.Color.White; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(18, 13); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(566, 255); + this.dataGridView.TabIndex = 8; + // + // ButtonRef + // + this.ButtonRef.Location = new System.Drawing.Point(598, 198); + this.ButtonRef.Name = "ButtonRef"; + this.ButtonRef.Size = new System.Drawing.Size(112, 35); + this.ButtonRef.TabIndex = 7; + this.ButtonRef.Text = "Обновить"; + this.ButtonRef.UseVisualStyleBackColor = true; + this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click); + // + // ButtonAdd + // + this.ButtonAdd.Location = new System.Drawing.Point(598, 44); + this.ButtonAdd.Name = "ButtonAdd"; + this.ButtonAdd.Size = new System.Drawing.Size(112, 35); + this.ButtonAdd.TabIndex = 6; + this.ButtonAdd.Text = "Добавить"; + this.ButtonAdd.UseVisualStyleBackColor = true; + this.ButtonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // ButtonDel + // + this.ButtonDel.Location = new System.Drawing.Point(598, 147); + this.ButtonDel.Name = "ButtonDel"; + this.ButtonDel.Size = new System.Drawing.Size(112, 35); + this.ButtonDel.TabIndex = 5; + this.ButtonDel.Text = "Удалить"; + this.ButtonDel.UseVisualStyleBackColor = true; + this.ButtonDel.Click += new System.EventHandler(this.ButtonDel_Click); + // + // ButtonUpd + // + this.ButtonUpd.Location = new System.Drawing.Point(598, 95); + this.ButtonUpd.Name = "ButtonUpd"; + this.ButtonUpd.Size = new System.Drawing.Size(112, 35); + this.ButtonUpd.TabIndex = 4; + this.ButtonUpd.Text = "Изменить"; + this.ButtonUpd.UseVisualStyleBackColor = true; + this.ButtonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); + // + // ButtonCancel + // + this.ButtonCancel.Location = new System.Drawing.Point(651, 412); + this.ButtonCancel.Name = "ButtonCancel"; + this.ButtonCancel.Size = new System.Drawing.Size(87, 26); + this.ButtonCancel.TabIndex = 12; + this.ButtonCancel.Text = "Отмена"; + this.ButtonCancel.UseVisualStyleBackColor = true; + this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // ButtonSave + // + this.ButtonSave.Location = new System.Drawing.Point(558, 412); + this.ButtonSave.Name = "ButtonSave"; + this.ButtonSave.Size = new System.Drawing.Size(87, 26); + this.ButtonSave.TabIndex = 11; + this.ButtonSave.Text = "Сохранить"; + this.ButtonSave.UseVisualStyleBackColor = true; + this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // FormSushi + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(750, 450); + this.Controls.Add(this.ButtonCancel); + this.Controls.Add(this.ButtonSave); + this.Controls.Add(this.panel1); + this.Controls.Add(this.textBoxPrice); + this.Controls.Add(this.textBoxName); + this.Controls.Add(this.labelCost); + this.Controls.Add(this.labelName); + this.Name = "FormSushi"; + this.Text = "FormSushi"; + this.Load += new System.EventHandler(this.FormSushi_Load); + this.panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private TextBox textBoxPrice; + private TextBox textBoxName; + private Label labelCost; + private Label labelName; + private Panel panel1; + private Button ButtonRef; + private Button ButtonAdd; + private Button ButtonDel; + private Button ButtonUpd; + private DataGridView dataGridView; + private Button ButtonCancel; + private Button ButtonSave; + } +} \ No newline at end of file diff --git a/SushiBar/SushiBarView/FormSushi.cs b/SushiBar/SushiBarView/FormSushi.cs new file mode 100644 index 0000000..ed76a83 --- /dev/null +++ b/SushiBar/SushiBarView/FormSushi.cs @@ -0,0 +1,251 @@ +using Microsoft.Extensions.Logging; +using SushiBarDataModels.Models; +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; +using SushiBarContracts.BindingModels; +using SushiBarContracts.BusinessLogicsContracts; +using SushiBarContracts.SearchModels; + + +namespace SushiBarView +{ + public partial class FormSushi : Form + { + private readonly ILogger _logger; + private readonly ISushiLogic _logic; + private int? _id; + private Dictionary _sushiComponents; + public int Id { set { _id = value; } } + + public FormSushi() + { + InitializeComponent(); + } + public FormSushi(ILogger logger, ISushiLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + _sushiComponents = new Dictionary(); + } + + private void FormSushi_Load(object sender, EventArgs e) + { + var list = _logic.ReadList(null); + if (list != null) + { + DataGridViewTextBoxColumn Id = new DataGridViewTextBoxColumn(); + DataGridViewTextBoxColumn Component = new DataGridViewTextBoxColumn(); + DataGridViewTextBoxColumn Number = new DataGridViewTextBoxColumn(); + Component.HeaderText = "Количество"; + Number.HeaderText = "Компонент"; + Number.Name = "Number"; + Id.Name = "Id"; + dataGridView.Columns.Add(Id); + dataGridView.Columns.Add(Number); + dataGridView.Columns.Add(Component); + dataGridView.Columns["Id"].Visible = false; + + dataGridView.Columns["Number"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; + } + if (_id.HasValue) + { + _logger.LogInformation("Загрузка суши"); + try + { + var view = _logic.ReadElement(new SushiSearchModel + { + Id = _id.Value + }); + if (view != null) + { + textBoxName.Text = view.SushiName; + textBoxPrice.Text = view.Price.ToString(); + _sushiComponents = view.SushiComponents ?? new + Dictionary(); + LoadData(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки изделия"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + } + private void LoadData() + { + _logger.LogInformation("Загрузка компонент изделия"); + try + { + if (_sushiComponents != null) + { + dataGridView.Rows.Clear(); + foreach (var pc in _sushiComponents) + { + dataGridView.Rows.Add(new object[] { pc.Key, +pc.Value.Item1.ComponentName, pc.Value.Item2 }); + } + textBoxPrice.Text = CalcPrice().ToString(); + } + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки компонент изделия"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + } + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormSushiComponent)); + if (service is FormSushiComponent form) + { + if (form.ShowDialog() == DialogResult.OK) + { + if (form.ComponentModel == null) + { + return; + } + _logger.LogInformation("Добавление нового компонента: { ComponentName} - { Count}", form.ComponentModel.ComponentName, form.Count); + if (_sushiComponents.ContainsKey(form.Id)) + { + _sushiComponents[form.Id] = (form.ComponentModel, form.Count); + } + else + { + _sushiComponents.Add(form.Id, (form.ComponentModel, form.Count)); + } + LoadData(); + } + } + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = + Program.ServiceProvider?.GetService(typeof(FormSushiComponent)); + if (service is FormSushiComponent form) + { + int id = + Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value); + form.Id = id; + form.Count = _sushiComponents[id].Item2; + if (form.ShowDialog() == DialogResult.OK) + { + if (form.ComponentModel == null) + { + return; + } + _logger.LogInformation("Изменение компонента: { ComponentName} - { Count} ", form.ComponentModel.ComponentName, form.Count); + _sushiComponents[form.Id] = (form.ComponentModel, form.Count); + LoadData(); + } + } + } + } + + private void ButtonDel_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + if (MessageBox.Show("Удалить запись?", "Вопрос", + MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) + { + try + { + _logger.LogInformation("Удаление компонента: { ComponentName} - { Count}", dataGridView.SelectedRows[0].Cells[1].Value); + _sushiComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value)); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message, "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } + LoadData(); + } + } + } + + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxName.Text)) + { + MessageBox.Show("Заполните название", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (string.IsNullOrEmpty(textBoxPrice.Text)) + { + MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK, + MessageBoxIcon.Error); + return; + } + if (_sushiComponents == null || _sushiComponents.Count == 0) + { + MessageBox.Show("Заполните компоненты", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + _logger.LogInformation("Сохранение изделия"); + try + { + var model = new SushiBindingModel + { + Id = _id ?? 0, + SushiName = textBoxName.Text, + Price = Convert.ToDouble(textBoxPrice.Text), + SushiComponents = _sushiComponents + }; + 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); + } + + } + + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + private double CalcPrice() + { + double price = 0; + foreach (var elem in _sushiComponents) + { + price += ((elem.Value.Item1?.Cost ?? 0) * elem.Value.Item2); + } + return Math.Round(price * 1.1, 2); + } + } +} diff --git a/SushiBar/SushiBarView/FormSushi.resx b/SushiBar/SushiBarView/FormSushi.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/SushiBar/SushiBarView/FormSushi.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SushiBar/SushiBarView/FormSushiComponent.Designer.cs b/SushiBar/SushiBarView/FormSushiComponent.Designer.cs new file mode 100644 index 0000000..17b2956 --- /dev/null +++ b/SushiBar/SushiBarView/FormSushiComponent.Designer.cs @@ -0,0 +1,119 @@ +namespace SushiBarView +{ + partial class FormSushiComponent + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.textBoxCount = new System.Windows.Forms.TextBox(); + this.labelCost = new System.Windows.Forms.Label(); + this.labelName = new System.Windows.Forms.Label(); + this.ButtonCancel = new System.Windows.Forms.Button(); + this.ButtonSave = new System.Windows.Forms.Button(); + this.comboBoxComponent = new System.Windows.Forms.ComboBox(); + this.SuspendLayout(); + // + // textBoxCount + // + this.textBoxCount.Location = new System.Drawing.Point(87, 54); + this.textBoxCount.Name = "textBoxCount"; + this.textBoxCount.Size = new System.Drawing.Size(262, 23); + this.textBoxCount.TabIndex = 11; + // + // labelCost + // + this.labelCost.AutoSize = true; + this.labelCost.Location = new System.Drawing.Point(12, 57); + this.labelCost.Name = "labelCost"; + this.labelCost.Size = new System.Drawing.Size(72, 15); + this.labelCost.TabIndex = 9; + this.labelCost.Text = "Количество"; + // + // labelName + // + this.labelName.AutoSize = true; + this.labelName.Location = new System.Drawing.Point(12, 24); + this.labelName.Name = "labelName"; + this.labelName.Size = new System.Drawing.Size(69, 15); + this.labelName.TabIndex = 8; + this.labelName.Text = "Компонент"; + // + // ButtonCancel + // + this.ButtonCancel.Location = new System.Drawing.Point(271, 96); + this.ButtonCancel.Name = "ButtonCancel"; + this.ButtonCancel.Size = new System.Drawing.Size(87, 26); + this.ButtonCancel.TabIndex = 7; + this.ButtonCancel.Text = "Отмена"; + this.ButtonCancel.UseVisualStyleBackColor = true; + this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); + // + // ButtonSave + // + this.ButtonSave.Location = new System.Drawing.Point(178, 96); + this.ButtonSave.Name = "ButtonSave"; + this.ButtonSave.Size = new System.Drawing.Size(87, 26); + this.ButtonSave.TabIndex = 6; + this.ButtonSave.Text = "Сохранить"; + this.ButtonSave.UseVisualStyleBackColor = true; + this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click); + // + // comboBoxComponent + // + this.comboBoxComponent.FormattingEnabled = true; + this.comboBoxComponent.Location = new System.Drawing.Point(87, 21); + this.comboBoxComponent.Name = "comboBoxComponent"; + this.comboBoxComponent.Size = new System.Drawing.Size(262, 23); + this.comboBoxComponent.TabIndex = 12; + // + // FormSushiComponent + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(375, 141); + this.Controls.Add(this.comboBoxComponent); + this.Controls.Add(this.textBoxCount); + this.Controls.Add(this.labelCost); + this.Controls.Add(this.labelName); + this.Controls.Add(this.ButtonCancel); + this.Controls.Add(this.ButtonSave); + this.Name = "FormSushiComponent"; + this.Text = "FormSushiComponent"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private TextBox textBoxCount; + private Label labelCost; + private Label labelName; + private Button ButtonCancel; + private Button ButtonSave; + private ComboBox comboBoxComponent; + } +} \ No newline at end of file diff --git a/SushiBar/SushiBarView/FormSushiComponent.cs b/SushiBar/SushiBarView/FormSushiComponent.cs new file mode 100644 index 0000000..a7a020a --- /dev/null +++ b/SushiBar/SushiBarView/FormSushiComponent.cs @@ -0,0 +1,99 @@ +using SushiBarContracts.BusinessLogicsContracts; +using SushiBarContracts.ViewModels; +using SushiBarDataModels.Models; +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 SushiBarView +{ + public partial class FormSushiComponent : Form + { + private readonly List? _list; + public int Id + { + get + { + return + Convert.ToInt32(comboBoxComponent.SelectedValue); + } + set + { + comboBoxComponent.SelectedValue = value; + } + } + + public IComponentModel? ComponentModel + { + get + { + if (_list == null) + { + return null; + } + foreach (var elem in _list) + { + if (elem.Id == Id) + { + return elem; + } + } + return null; + } + } + + public int Count + { + get { return Convert.ToInt32(textBoxCount.Text); } + set + { textBoxCount.Text = value.ToString(); } + } + public FormSushiComponent(IComponentLogic logic) + { + InitializeComponent(); + _list = logic.ReadList(null); + if (_list != null) + { + comboBoxComponent.DisplayMember = "ComponentName"; + comboBoxComponent.ValueMember = "Id"; + comboBoxComponent.DataSource = _list; + comboBoxComponent.SelectedItem = null; + } + } + public FormSushiComponent() + { + InitializeComponent(); + } + + private void ButtonCancel_Click(object sender, EventArgs e) + { + DialogResult = DialogResult.Cancel; + Close(); + } + + private void ButtonSave_Click(object sender, EventArgs e) + { + if (string.IsNullOrEmpty(textBoxCount.Text)) + { + MessageBox.Show("Заполните поле Количество", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + if (comboBoxComponent.SelectedValue == null) + { + MessageBox.Show("Выберите компонент", "Ошибка", + MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + DialogResult = DialogResult.OK; + Close(); + + } + } +} diff --git a/SushiBar/SushiBarView/FormSushiComponent.resx b/SushiBar/SushiBarView/FormSushiComponent.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/SushiBar/SushiBarView/FormSushiComponent.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SushiBar/SushiBarView/FormSushis.Designer.cs b/SushiBar/SushiBarView/FormSushis.Designer.cs new file mode 100644 index 0000000..4cc40f2 --- /dev/null +++ b/SushiBar/SushiBarView/FormSushis.Designer.cs @@ -0,0 +1,115 @@ +namespace SushiBarView +{ + partial class FormSushis + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.dataGridView = new System.Windows.Forms.DataGridView(); + this.ButtonRef = new System.Windows.Forms.Button(); + this.ButtonAdd = new System.Windows.Forms.Button(); + this.ButtonDel = new System.Windows.Forms.Button(); + this.ButtonUpd = new System.Windows.Forms.Button(); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); + this.SuspendLayout(); + // + // dataGridView + // + this.dataGridView.BackgroundColor = System.Drawing.Color.White; + this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; + this.dataGridView.Location = new System.Drawing.Point(12, 12); + this.dataGridView.Name = "dataGridView"; + this.dataGridView.RowTemplate.Height = 25; + this.dataGridView.Size = new System.Drawing.Size(454, 365); + this.dataGridView.TabIndex = 9; + // + // ButtonRef + // + this.ButtonRef.Location = new System.Drawing.Point(499, 177); + this.ButtonRef.Name = "ButtonRef"; + this.ButtonRef.Size = new System.Drawing.Size(112, 35); + this.ButtonRef.TabIndex = 8; + this.ButtonRef.Text = "Обновить"; + this.ButtonRef.UseVisualStyleBackColor = true; + this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click); + // + // ButtonAdd + // + this.ButtonAdd.Location = new System.Drawing.Point(499, 23); + this.ButtonAdd.Name = "ButtonAdd"; + this.ButtonAdd.Size = new System.Drawing.Size(112, 35); + this.ButtonAdd.TabIndex = 7; + this.ButtonAdd.Text = "Добавить"; + this.ButtonAdd.UseVisualStyleBackColor = true; + this.ButtonAdd.Click += new System.EventHandler(this.ButtonAdd_Click); + // + // ButtonDel + // + this.ButtonDel.Location = new System.Drawing.Point(499, 126); + this.ButtonDel.Name = "ButtonDel"; + this.ButtonDel.Size = new System.Drawing.Size(112, 35); + this.ButtonDel.TabIndex = 6; + this.ButtonDel.Text = "Удалить"; + this.ButtonDel.UseVisualStyleBackColor = true; + this.ButtonDel.Click += new System.EventHandler(this.ButtonDel_Click); + // + // ButtonUpd + // + this.ButtonUpd.Location = new System.Drawing.Point(499, 74); + this.ButtonUpd.Name = "ButtonUpd"; + this.ButtonUpd.Size = new System.Drawing.Size(112, 35); + this.ButtonUpd.TabIndex = 5; + this.ButtonUpd.Text = "Изменить"; + this.ButtonUpd.UseVisualStyleBackColor = true; + this.ButtonUpd.Click += new System.EventHandler(this.ButtonUpd_Click); + // + // FormSushis + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(637, 390); + this.Controls.Add(this.dataGridView); + this.Controls.Add(this.ButtonRef); + this.Controls.Add(this.ButtonAdd); + this.Controls.Add(this.ButtonDel); + this.Controls.Add(this.ButtonUpd); + this.Name = "FormSushis"; + this.Text = "FormSushis"; + this.Load += new System.EventHandler(this.FormSushi_Load); + ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private DataGridView dataGridView; + private Button ButtonRef; + private Button ButtonAdd; + private Button ButtonDel; + private Button ButtonUpd; + } +} \ No newline at end of file diff --git a/SushiBar/SushiBarView/FormSushis.cs b/SushiBar/SushiBarView/FormSushis.cs new file mode 100644 index 0000000..d5933eb --- /dev/null +++ b/SushiBar/SushiBarView/FormSushis.cs @@ -0,0 +1,121 @@ +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; +using SushiBarContracts.BindingModels; +using SushiBarContracts.BusinessLogicsContracts; + +namespace SushiBarView +{ + public partial class FormSushis : Form + { + public FormSushis() + { + InitializeComponent(); + } + + private void ButtonAdd_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormSushi)); + if (service is FormSushi form) + { + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + + private readonly ILogger _logger; + private readonly ISushiLogic _logic; + + public FormSushis(ILogger logger, ISushiLogic logic) + { + InitializeComponent(); + _logger = logger; + _logic = logic; + } + + private void FormSushi_Load(object sender, EventArgs e) + { + LoadData(); + } + + private void LoadData() + { + try + { + var list = _logic.ReadList(null); + if (list != null) + { + dataGridView.DataSource = list; + dataGridView.Columns["Id"].Visible = false; + dataGridView.Columns["SushiComponents"].Visible = false; + dataGridView.Columns["SushiName"].AutoSizeMode = + DataGridViewAutoSizeColumnMode.Fill; + } + _logger.LogInformation("Загрузка суши"); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка загрузки суши"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + + private void ButtonUpd_Click(object sender, EventArgs e) + { + if (dataGridView.SelectedRows.Count == 1) + { + var service = Program.ServiceProvider?.GetService(typeof(FormSushi)); + if (service is FormSushi form) + { + form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); + if (form.ShowDialog() == DialogResult.OK) + { + LoadData(); + } + } + } + } + + private void ButtonDel_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 SushiBindingModel + { + Id = id + })) + { + throw new Exception("Ошибка при удалении. Дополнительная информация в логах."); + } + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка удаления пиццы"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + } + + private void ButtonRef_Click(object sender, EventArgs e) + { + LoadData(); + } + } +} diff --git a/SushiBar/SushiBarView/FormSushis.resx b/SushiBar/SushiBarView/FormSushis.resx new file mode 100644 index 0000000..f298a7b --- /dev/null +++ b/SushiBar/SushiBarView/FormSushis.resx @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/SushiBar/SushiBarView/Program.cs b/SushiBar/SushiBarView/Program.cs index 34ba1ed..8a031e0 100644 --- a/SushiBar/SushiBarView/Program.cs +++ b/SushiBar/SushiBarView/Program.cs @@ -1,17 +1,52 @@ +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using SushiBarContracts.BusinessLogicsContracts; +using System; +using SushiBarBusinessLogic.BusinessLogics; +using SushiBarListImplement.Implements; +using SushiBarContracts.StoragesContracts; +using SushiBarView; +using NLog.Extensions.Logging; + + namespace SushiBarView { internal static class Program { + private static ServiceProvider? _serviceProvider; + public static ServiceProvider? ServiceProvider => _serviceProvider; /// /// The main entry point for the application. /// [STAThread] static void Main() { - // To customize application configuration such as set high DPI settings or default font, - // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new FormComponent()); + var services = new ServiceCollection(); + ConfigureServices(services); + _serviceProvider = services.BuildServiceProvider(); + Application.Run(_serviceProvider.GetRequiredService()); + } + private static void ConfigureServices(ServiceCollection services) + { + services.AddLogging(option => + { + option.SetMinimumLevel(LogLevel.Information); + option.AddNLog("nlog.config"); + }); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); } } } \ No newline at end of file diff --git a/SushiBar/SushiBarView/SushiBarView.csproj b/SushiBar/SushiBarView/SushiBarView.csproj index cf6300c..091baa3 100644 --- a/SushiBar/SushiBarView/SushiBarView.csproj +++ b/SushiBar/SushiBarView/SushiBarView.csproj @@ -9,13 +9,26 @@ - + - + + Always + + + + + + + + + + + + - + \ No newline at end of file diff --git a/SushiBar/SushiBarView/nlog.config b/SushiBar/SushiBarView/nlog.config new file mode 100644 index 0000000..609afe6 --- /dev/null +++ b/SushiBar/SushiBarView/nlog.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + \ No newline at end of file -- 2.25.1 From 3b49da205f3e7611cb4f894a09b7c5ee930b7a3d Mon Sep 17 00:00:00 2001 From: ValAnn Date: Wed, 14 Feb 2024 11:13:28 +0400 Subject: [PATCH 4/4] nu tipa --- SushiBar/SushiBar/Form1.Designer.cs | 60 --------------------------- SushiBar/SushiBar/Form1.cs | 14 ------- SushiBar/SushiBar/Form1.resx | 60 --------------------------- SushiBar/SushiBar/Program.cs | 2 +- SushiBar/SushiBarDataModels/Class1.cs | 7 ---- SushiBar/SushiBarView/FormSushi.cs | 1 + 6 files changed, 2 insertions(+), 142 deletions(-) delete mode 100644 SushiBar/SushiBar/Form1.Designer.cs delete mode 100644 SushiBar/SushiBar/Form1.cs delete mode 100644 SushiBar/SushiBar/Form1.resx delete mode 100644 SushiBar/SushiBarDataModels/Class1.cs diff --git a/SushiBar/SushiBar/Form1.Designer.cs b/SushiBar/SushiBar/Form1.Designer.cs deleted file mode 100644 index 943ecea..0000000 --- a/SushiBar/SushiBar/Form1.Designer.cs +++ /dev/null @@ -1,60 +0,0 @@ -namespace SushiBar -{ - partial class Form1 - { - /// - /// Required designer variable. - /// - private System.ComponentModel.IContainer components = null; - - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - - #region Windows Form Designer generated code - - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - this.button1 = new System.Windows.Forms.Button(); - this.SuspendLayout(); - // - // button1 - // - this.button1.Location = new System.Drawing.Point(285, 116); - this.button1.Name = "button1"; - this.button1.Size = new System.Drawing.Size(300, 135); - this.button1.TabIndex = 0; - this.button1.Text = "button1"; - this.button1.UseVisualStyleBackColor = true; - this.button1.Click += new System.EventHandler(this.button1_Click); - // - // Form1 - // - this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.ClientSize = new System.Drawing.Size(800, 450); - this.Controls.Add(this.button1); - this.Name = "Form1"; - this.Text = "Form1"; - this.ResumeLayout(false); - - } - - #endregion - - private Button button1; - } -} \ No newline at end of file diff --git a/SushiBar/SushiBar/Form1.cs b/SushiBar/SushiBar/Form1.cs deleted file mode 100644 index 984f574..0000000 --- a/SushiBar/SushiBar/Form1.cs +++ /dev/null @@ -1,14 +0,0 @@ -namespace SushiBar -{ - public partial class Form1 : Form - { - public Form1() - { - InitializeComponent(); - } - - private void button1_Click(object sender, EventArgs e) - { - } - } -} \ No newline at end of file diff --git a/SushiBar/SushiBar/Form1.resx b/SushiBar/SushiBar/Form1.resx deleted file mode 100644 index f298a7b..0000000 --- a/SushiBar/SushiBar/Form1.resx +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/SushiBar/SushiBar/Program.cs b/SushiBar/SushiBar/Program.cs index 402417b..9e07955 100644 --- a/SushiBar/SushiBar/Program.cs +++ b/SushiBar/SushiBar/Program.cs @@ -11,7 +11,7 @@ namespace SushiBar // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new Form1()); + Application.Run(); } } } \ No newline at end of file diff --git a/SushiBar/SushiBarDataModels/Class1.cs b/SushiBar/SushiBarDataModels/Class1.cs deleted file mode 100644 index 08ec173..0000000 --- a/SushiBar/SushiBarDataModels/Class1.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace SushiBarDataModels -{ - public class Class1 - { - - } -} \ No newline at end of file diff --git a/SushiBar/SushiBarView/FormSushi.cs b/SushiBar/SushiBarView/FormSushi.cs index ed76a83..b265edb 100644 --- a/SushiBar/SushiBarView/FormSushi.cs +++ b/SushiBar/SushiBarView/FormSushi.cs @@ -41,6 +41,7 @@ namespace SushiBarView var list = _logic.ReadList(null); if (list != null) { + dataGridView.AllowUserToAddRows = false; DataGridViewTextBoxColumn Id = new DataGridViewTextBoxColumn(); DataGridViewTextBoxColumn Component = new DataGridViewTextBoxColumn(); DataGridViewTextBoxColumn Number = new DataGridViewTextBoxColumn(); -- 2.25.1