diff --git a/Diner/Diner.sln b/Diner/Diner.sln index 04f27db..2895709 100644 --- a/Diner/Diner.sln +++ b/Diner/Diner.sln @@ -5,13 +5,15 @@ VisualStudioVersion = 17.7.34221.43 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DinerView", "DinerView\DinerView.csproj", "{7FC291E6-FE0A-4D25-B46F-724FB599F26F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DinerDataModels", "DinerDataModels\DinerDataModels.csproj", "{2AFAC265-13C0-432E-8F33-ABF764FD0877}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DinerDataModels", "DinerDataModels\DinerDataModels.csproj", "{2AFAC265-13C0-432E-8F33-ABF764FD0877}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DinerContracts", "DinerContracts\DinerContracts.csproj", "{89BA6B4F-1F08-4327-B88B-E48335742088}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DinerContracts", "DinerContracts\DinerContracts.csproj", "{89BA6B4F-1F08-4327-B88B-E48335742088}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DinerListImplement", "DinerListImplement\DinerListImplement.csproj", "{33BCF269-AF60-4E7E-9F3B-2ECEDCEBF8F9}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DinerListImplement", "DinerListImplement\DinerListImplement.csproj", "{33BCF269-AF60-4E7E-9F3B-2ECEDCEBF8F9}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DineryBusinessLogic", "DineryBusinessLogic\DineryBusinessLogic.csproj", "{2920D9E3-AE18-4914-BD43-C04D9123FBD7}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DineryBusinessLogic", "DineryBusinessLogic\DineryBusinessLogic.csproj", "{2920D9E3-AE18-4914-BD43-C04D9123FBD7}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DinerFileImplement", "DinerShopImplement\DinerFileImplement.csproj", "{E46007E3-F3EC-4551-A203-19361E7B1B8D}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -39,6 +41,10 @@ Global {2920D9E3-AE18-4914-BD43-C04D9123FBD7}.Debug|Any CPU.Build.0 = Debug|Any CPU {2920D9E3-AE18-4914-BD43-C04D9123FBD7}.Release|Any CPU.ActiveCfg = Release|Any CPU {2920D9E3-AE18-4914-BD43-C04D9123FBD7}.Release|Any CPU.Build.0 = Release|Any CPU + {E46007E3-F3EC-4551-A203-19361E7B1B8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E46007E3-F3EC-4551-A203-19361E7B1B8D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E46007E3-F3EC-4551-A203-19361E7B1B8D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E46007E3-F3EC-4551-A203-19361E7B1B8D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Diner/DinerShopImplement/DataFileSingleton.cs b/Diner/DinerShopImplement/DataFileSingleton.cs new file mode 100644 index 0000000..4edd6e5 --- /dev/null +++ b/Diner/DinerShopImplement/DataFileSingleton.cs @@ -0,0 +1,59 @@ +using DinerFileImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; + +namespace DinerFileImplement +{ + internal class DataFileSingleton + { + private static DataFileSingleton? instance; + + private readonly string FoodFileName = "Food.xml"; + + private readonly string OrderFileName = "Order.xml"; + + private readonly string SnackFileName = "Snack.xml"; + + public List Foods { get; set; } + public List Orders { get; private set; } + public List Snacks { get; private set; } + + private DataFileSingleton() { + Foods = LoadData(FoodFileName, "Food", x => Food.Create(x)!)!; + Snacks = LoadData(SnackFileName, "Snack", x => Snack.Create(x)!)!; + Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!; + } + public static DataFileSingleton GetInstance() { + if (instance == null) instance = new DataFileSingleton(); + return instance; + } + public void SaveFoods() => SaveData(Foods, FoodFileName, "Foods", + x => x.GetXElement); + public void SaveSnacks() => SaveData(Snacks, SnackFileName, "Snacks", + x => x.GetXElement); + public void SaveOrder() => SaveData(Orders, OrderFileName, "Orders", + x => x.GetXElement); + private static void SaveData(List data, string filename, string xmlNodeName, + Func selectFunction) + { + if (data != null) { + new XDocument(new XElement(xmlNodeName, data.Select(selectFunction).ToArray())) + .Save(filename); + } + } + private static List? LoadData(string filename, string xmlNodeName, + Func selectFunction) + { + if (File.Exists(filename)) + { + return XDocument.Load(filename)?.Root?.Elements(xmlNodeName)? + .Select(selectFunction)?.ToList(); + } + return new List(); + } + } +} diff --git a/Diner/DinerShopImplement/DinerFileImplement.csproj b/Diner/DinerShopImplement/DinerFileImplement.csproj new file mode 100644 index 0000000..cae5b14 --- /dev/null +++ b/Diner/DinerShopImplement/DinerFileImplement.csproj @@ -0,0 +1,14 @@ + + + + net8.0 + enable + enable + + + + + + + + diff --git a/Diner/DinerShopImplement/Implements/FoodStorage.cs b/Diner/DinerShopImplement/Implements/FoodStorage.cs new file mode 100644 index 0000000..b5d0ba3 --- /dev/null +++ b/Diner/DinerShopImplement/Implements/FoodStorage.cs @@ -0,0 +1,75 @@ +using DinerContracts.BindingModels; +using DinerContracts.SearchModels; +using DinerContracts.StoragesContracts; +using DinerContracts.ViewModels; +using DinerFileImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DinerFileImplement.Implements +{ + public class FoodStorage : IFoodStorage + { + private readonly DataFileSingleton _source; + + public FoodStorage() + { + _source = DataFileSingleton.GetInstance(); + } + + public FoodViewModel? Delete(FoodBindingModel model) + { + var element = _source.Foods.FirstOrDefault(x => x.ID == model.ID); + if (element != null) { + _source.Foods.Remove(element); + _source.SaveFoods(); + return element.GetViewModel; + } + return null; + } + + public FoodViewModel? GetElement(FoodSearchModel model) + { + if (string.IsNullOrEmpty(model.ComponentName) && !model.ID.HasValue) { return null; } + return _source.Foods + .FirstOrDefault(x => (!string.IsNullOrEmpty(model.ComponentName) && + x.ComponentName == model.ComponentName) || model.ID.HasValue && + x.ID == model.ID)?.GetViewModel; + } + + public List GetFilteredList(FoodSearchModel model) + { + if (string.IsNullOrEmpty(model.ComponentName)) { return new(); } + return _source.Foods.Where(x => x.ComponentName.Contains(model.ComponentName)) + .Select(x => x.GetViewModel).ToList(); + + } + + public List GetFullList() + { + return _source.Foods.Select(x => x.GetViewModel).ToList(); + } + + public FoodViewModel? Insert(FoodBindingModel model) + { + model.ID = _source.Foods.Count > 0 ? _source.Foods.Max(x => x.ID) + 1 : 1; + var newComponent = Food.Create(model); + if (newComponent == null) { return null; } + _source.Foods.Add(newComponent); + _source.SaveFoods(); + return newComponent.GetViewModel; + } + + public FoodViewModel? Update(FoodBindingModel model) + { + var component = _source.Foods.FirstOrDefault(x => x.ID == model.ID); + if (component == null) { return null; } + component.Update(model); + _source.SaveFoods(); + return component.GetViewModel; + } + } +} diff --git a/Diner/DinerShopImplement/Implements/OrderStorage.cs b/Diner/DinerShopImplement/Implements/OrderStorage.cs new file mode 100644 index 0000000..37e6edb --- /dev/null +++ b/Diner/DinerShopImplement/Implements/OrderStorage.cs @@ -0,0 +1,81 @@ +using DinerContracts.BindingModels; +using DinerContracts.SearchModels; +using DinerContracts.StoragesContracts; +using DinerContracts.ViewModels; +using DinerFileImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net.Http.Headers; +using System.Security.Cryptography; +using System.Text; +using System.Threading.Tasks; + +namespace DinerFileImplement.Implements +{ + public class OrderStorage : IOrderStorage + { + private readonly DataFileSingleton _source; + + public OrderStorage() + { + _source = DataFileSingleton.GetInstance(); + } + + public OrderViewModel? Delete(OrderBindingModel model) + { + var element = _source.Orders.FirstOrDefault(x => x.ID == model.ID); + if (element != null) { + _source.Orders.Remove(element); + _source.SaveOrder(); + return GetViewModel(element); + } + return null; + } + + public OrderViewModel? GetElement(OrderSearchModel model) + { + if (!model.ID.HasValue) { return null; } + return _source.Orders + .FirstOrDefault(x => model.ID.HasValue && x.ID == model.ID)?.GetViewModel; + } + + public List GetFilteredList(OrderSearchModel model) + { + if (!model.ID.HasValue) { return new(); } + return _source.Orders.Where(x => x.ID == model.ID).Select(GetViewModel).ToList(); + } + + public List GetFullList() + { + return _source.Orders.Select(GetViewModel).ToList(); + } + private OrderViewModel GetViewModel(Order order) + { + var viewModel = order.GetViewModel; + var tmp = from p in _source.Snacks + where p.ID == order.ProductID + select p.ProductName; + viewModel.ProductName = tmp.FirstOrDefault(string.Empty); + return viewModel; + } + public OrderViewModel? Insert(OrderBindingModel model) + { + model.ID = _source.Orders.Count > 0 ? _source.Orders.Max(x => x.ID) + 1 : 1; + var newOrder = Order.Create(model); + if (newOrder == null) { return null; } + _source.Orders.Add(newOrder); + _source.SaveOrder(); + return GetViewModel(newOrder); + } + + public OrderViewModel? Update(OrderBindingModel model) + { + var order = _source.Orders.FirstOrDefault(x => x.ID == model.ID); + if (order == null) { return null; } + order.Update(model); + _source.SaveOrder(); + return GetViewModel(order); + } + } +} diff --git a/Diner/DinerShopImplement/Implements/SnackStorage.cs b/Diner/DinerShopImplement/Implements/SnackStorage.cs new file mode 100644 index 0000000..8ec1fad --- /dev/null +++ b/Diner/DinerShopImplement/Implements/SnackStorage.cs @@ -0,0 +1,74 @@ +using DinerContracts.BindingModels; +using DinerContracts.SearchModels; +using DinerContracts.StoragesContracts; +using DinerContracts.ViewModels; +using DinerFileImplement.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DinerFileImplement.Implements +{ + public class SnackStorage : ISnackStorage + { + private readonly DataFileSingleton _source; + + public SnackStorage() + { + _source = DataFileSingleton.GetInstance(); + } + + public SnackViewModel? Delete(SnackBindingModel model) + { + var element = _source.Snacks.FirstOrDefault(x => x.ID == model.ID); + if (element != null) { + _source.Snacks.Remove(element); + _source.SaveSnacks(); + return element.GetViewModel; + } + return null; + } + + public SnackViewModel? GetElement(SnackSearchModel model) + { + if (string.IsNullOrEmpty(model.ProductName) && !model.ID.HasValue) { return null; } + return _source.Snacks + .FirstOrDefault(x => (!string.IsNullOrEmpty(model.ProductName) && + x.ProductName == model.ProductName) || model.ID.HasValue && + x.ID == model.ID)?.GetViewModel; + } + + public List GetFilteredList(SnackSearchModel model) + { + if (string.IsNullOrEmpty(model.ProductName)) { return new(); } + return _source.Snacks.Where(x => x.ProductName.Contains(model.ProductName)) + .Select(x => x.GetViewModel).ToList(); + } + + public List GetFullList() + { + return _source.Snacks.Select(x => x.GetViewModel).ToList(); + } + + public SnackViewModel? Insert(SnackBindingModel model) + { + model.ID = _source.Snacks.Count > 0 ? _source.Snacks.Max(x => x.ID) + 1 : 1; + var newProduct = Snack.Create(model); + if (newProduct == null) { return null; } + _source.Snacks.Add(newProduct); + _source.SaveSnacks(); + return newProduct.GetViewModel; + } + + public SnackViewModel? Update(SnackBindingModel model) + { + var product = _source.Snacks.FirstOrDefault(x => x.ID == model.ID); + if (product == null) { return null; } + product.Update(model); + _source.SaveSnacks(); + return product.GetViewModel; + } + } +} diff --git a/Diner/DinerShopImplement/Models/Food.cs b/Diner/DinerShopImplement/Models/Food.cs new file mode 100644 index 0000000..da459bd --- /dev/null +++ b/Diner/DinerShopImplement/Models/Food.cs @@ -0,0 +1,57 @@ +using DinerContracts.BindingModels; +using DinerContracts.ViewModels; +using DinerDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; + +namespace DinerFileImplement.Models +{ + internal class Food : IFoodModel + { + public string ComponentName { get; set; } = string.Empty; + + public double Price { get; set; } + + public int ID { get; set; } + + public static Food? Create(FoodBindingModel? model) + { + if (model == null) return null; + return new Food() + { + ID = model.ID, + ComponentName = model.ComponentName, + Price = model.Price, + }; + } + public static Food? Create(XElement element) { + if (element == null) return null; + return new Food() + { + ID = Convert.ToInt32(element.Attribute("ID")!.Value), + ComponentName = element.Element("ComponentName")!.Value, + Price = Convert.ToDouble(element.Element("Price")!.Value) + }; + } + public void Update(FoodBindingModel? model) + { + if (model == null) return; + ComponentName = model.ComponentName; + Price = model.Price; + } + public FoodViewModel GetViewModel => new() + { + ID = ID, + ComponentName = ComponentName, + Price = Price, + }; + + public XElement GetXElement => new("Food", new XAttribute("ID", ID), + new XElement("ComponentName", ComponentName), + new XElement("Price", Price.ToString())); + } +} diff --git a/Diner/DinerShopImplement/Models/Order.cs b/Diner/DinerShopImplement/Models/Order.cs new file mode 100644 index 0000000..f5069ca --- /dev/null +++ b/Diner/DinerShopImplement/Models/Order.cs @@ -0,0 +1,84 @@ +using DinerContracts.BindingModels; +using DinerContracts.ViewModels; +using DinerDataModels.Enums; +using DinerDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; + +namespace DinerFileImplement.Models +{ + internal class Order : IOrderModel + { + public int ProductID { get; private set; } + + public int Count { get; set; } + + public double Sum { get; private set; } + + public OrderStatus Status { get; set; } + + public DateTime DateCreate { get; private set; } + + public DateTime? DateImplement { get; set; } + + public int ID { get; private set; } + + + public static Order? Create(OrderBindingModel? model) + { + if (model == null) return null; + return new Order() + { + ID = model.ID, + ProductID = model.ProductID, + Count = model.Count, + Sum = model.Sum, + Status = model.Status, + DateCreate = model.DateCreate, + DateImplement = model.DateImplement, + }; + } + public static Order? Create(XElement element) { + if (element == null) return null; + return new Order() + { + ID = Convert.ToInt32(element.Attribute("ID")!.Value), + ProductID = Convert.ToInt32(element.Element("ProductID")!.Value), + Count = Convert.ToInt32(element.Element("Count")!.Value), + Sum = Convert.ToDouble(element.Element("Sum")!.Value), + Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value), + DateCreate = Convert.ToDateTime(element.Element("DateCreate")!.Value), + DateImplement = string.IsNullOrEmpty(element.Element("DateImplement")!.Value) ? null : + Convert.ToDateTime(element.Element("DateImplement")!.Value), + }; + } + public void Update(OrderBindingModel? model) + { + if (model == null) return; + Status = model.Status; + DateImplement = model?.DateImplement; + } + public OrderViewModel GetViewModel => new() + { + ID = ID, + ProductID = ProductID, + Count = Count, + Sum = Sum, + Status = Status, + DateCreate = DateCreate, + DateImplement = DateImplement, + }; + public XElement GetXElement => new("Order", new XAttribute("ID", ID), + new XElement("ProductID", ProductID), + new XElement("Count", Count.ToString()), + new XElement("Sum", Sum.ToString()), + new XElement("Status", Status.ToString()), + new XElement("DateCreate", DateCreate.ToString()), + new XElement("DateImplement", DateImplement.ToString())); + + } +} diff --git a/Diner/DinerShopImplement/Models/Snack.cs b/Diner/DinerShopImplement/Models/Snack.cs new file mode 100644 index 0000000..39b6b9b --- /dev/null +++ b/Diner/DinerShopImplement/Models/Snack.cs @@ -0,0 +1,83 @@ +using DinerContracts.BindingModels; +using DinerContracts.ViewModels; +using DinerDataModels.Models; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Linq; +using System.Xml.XPath; + +namespace DinerFileImplement.Models +{ + internal class Snack : ISnackModel + { + public string ProductName { get; private set; } = string.Empty; + + public double Price { get; private set; } + + public int ID { get; private set; } + + public Dictionary Components { get; private set; } = new(); + private Dictionary? _productComponents = null; + public Dictionary ProductComponents + { + get + { + if (_productComponents == null) { + var source = DataFileSingleton.GetInstance(); + _productComponents = Components.ToDictionary(x => x.Key, y => ((source.Foods.FirstOrDefault(z => z.ID == + y.Key) as IFoodModel)!, y.Value)); + } + return _productComponents; + } + } + + public static Snack? Create(SnackBindingModel? model) + { + if (model == null) return null; + return new Snack() + { + ID = model.ID, + ProductName = model.ProductName, + Price = model.Price, + Components = model.ProductComponents.ToDictionary(x => x.Key, x => x.Value.Item2) + }; + } + public static Snack? Create(XElement element) + { + if (element == null) return null; + return new Snack() + { + ID = Convert.ToInt32(element.Attribute("ID")!.Value), + ProductName = element.Element("ProductName")!.Value, + Price = Convert.ToDouble(element.Element("Price")!.Value), + Components = element.Element("ProductComponents")!.Elements("ProductComponent") + .ToDictionary(x => Convert.ToInt32(x.Element("Key")?.Value), x => Convert.ToInt32(x.Element("Value")?.Value)) + }; + } + public void Update(SnackBindingModel? model) + { + if (model == null) return; + ProductName = model.ProductName; + Price = model.Price; + Components = model.ProductComponents.ToDictionary(x => x.Key, x => x.Value.Item2); + _productComponents = null; + } + public SnackViewModel GetViewModel => new() + { + ID = ID, + ProductName = ProductName, + Price = Price, + ProductComponents = ProductComponents + }; + public XElement GetXElement => new("Snack", new XAttribute("ID", ID), + new XElement("ProductName", ProductName), + new XElement("Price", Price.ToString()), + new XElement("ProductComponents", Components.Select(x => new XElement("ProductComponent", + new XElement("Key", x.Key), + new XElement("Value", x.Value))).ToArray())); + } +} diff --git a/Diner/DinerView/DinerView.csproj b/Diner/DinerView/DinerView.csproj index 1c0790c..7cfe32a 100644 --- a/Diner/DinerView/DinerView.csproj +++ b/Diner/DinerView/DinerView.csproj @@ -27,7 +27,7 @@ - + diff --git a/Diner/DinerView/FormFood.Designer.cs b/Diner/DinerView/FormFood.Designer.cs index b103b0e..c839087 100644 --- a/Diner/DinerView/FormFood.Designer.cs +++ b/Diner/DinerView/FormFood.Designer.cs @@ -100,7 +100,7 @@ Controls.Add(labelPrice); Controls.Add(labelName); Name = "FormFood"; - Text = "Food"; + Text = "Продукт питания"; Load += FormComponent_Load; ResumeLayout(false); PerformLayout(); diff --git a/Diner/DinerView/FormFoods.Designer.cs b/Diner/DinerView/FormFoods.Designer.cs index 9771ab1..b3ca93b 100644 --- a/Diner/DinerView/FormFoods.Designer.cs +++ b/Diner/DinerView/FormFoods.Designer.cs @@ -105,7 +105,7 @@ Controls.Add(buttonAdd); Controls.Add(dataGridView); Name = "FormFoods"; - Text = "Foods"; + Text = "Продукты"; Load += FormComponents_Load; ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ResumeLayout(false); diff --git a/Diner/DinerView/FormMain.Designer.cs b/Diner/DinerView/FormMain.Designer.cs index 71c298a..6d9228f 100644 --- a/Diner/DinerView/FormMain.Designer.cs +++ b/Diner/DinerView/FormMain.Designer.cs @@ -62,14 +62,14 @@ // toolStripMenuItemFoods // toolStripMenuItemFoods.Name = "toolStripMenuItemFoods"; - toolStripMenuItemFoods.Size = new Size(129, 22); + toolStripMenuItemFoods.Size = new Size(180, 22); toolStripMenuItemFoods.Text = "Продукты"; toolStripMenuItemFoods.Click += toolStripMenuItemFoods_Click; // // toolStripMenuItemSnacks // toolStripMenuItemSnacks.Name = "toolStripMenuItemSnacks"; - toolStripMenuItemSnacks.Size = new Size(129, 22); + toolStripMenuItemSnacks.Size = new Size(180, 22); toolStripMenuItemSnacks.Text = "Снэки"; toolStripMenuItemSnacks.Click += toolStripMenuItemSnacks_Click; // @@ -155,7 +155,7 @@ Controls.Add(menuStrip); MainMenuStrip = menuStrip; Name = "FormMain"; - Text = "FormMain"; + Text = "Заказы"; Load += FormMain_Load; menuStrip.ResumeLayout(false); menuStrip.PerformLayout(); diff --git a/Diner/DinerView/FormMain.cs b/Diner/DinerView/FormMain.cs index a7d2786..b564de2 100644 --- a/Diner/DinerView/FormMain.cs +++ b/Diner/DinerView/FormMain.cs @@ -40,6 +40,7 @@ namespace DinerView { dataGridView.DataSource = list; dataGridView.Columns["ProductID"].Visible = false; + dataGridView.Columns["Sum"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; } _logger.LogInformation("Загрузка заказов"); } diff --git a/Diner/DinerView/FormSnack.Designer.cs b/Diner/DinerView/FormSnack.Designer.cs index 112185a..c3a97c4 100644 --- a/Diner/DinerView/FormSnack.Designer.cs +++ b/Diner/DinerView/FormSnack.Designer.cs @@ -38,11 +38,11 @@ buttonChange = new Button(); buttonAdd = new Button(); dataGridView = new DataGridView(); - buttonCancel = new Button(); - buttonSave = new Button(); ColumnID = new DataGridViewTextBoxColumn(); ColumnFood = new DataGridViewTextBoxColumn(); ColumnCount = new DataGridViewTextBoxColumn(); + buttonCancel = new Button(); + buttonSave = new Button(); groupBoxFoods.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); SuspendLayout(); @@ -160,26 +160,6 @@ dataGridView.Size = new Size(437, 351); dataGridView.TabIndex = 0; // - // buttonCancel - // - buttonCancel.Location = new Point(587, 30); - buttonCancel.Name = "buttonCancel"; - buttonCancel.Size = new Size(82, 27); - buttonCancel.TabIndex = 5; - buttonCancel.Text = "Отмена"; - buttonCancel.UseVisualStyleBackColor = true; - buttonCancel.Click += buttonCancel_Click; - // - // buttonSave - // - buttonSave.Location = new Point(499, 30); - buttonSave.Name = "buttonSave"; - buttonSave.Size = new Size(82, 27); - buttonSave.TabIndex = 6; - buttonSave.Text = "Сохранить"; - buttonSave.UseVisualStyleBackColor = true; - buttonSave.Click += buttonSave_Click; - // // ColumnID // ColumnID.HeaderText = "ID"; @@ -200,6 +180,26 @@ ColumnCount.Name = "ColumnCount"; ColumnCount.ReadOnly = true; // + // buttonCancel + // + buttonCancel.Location = new Point(587, 30); + buttonCancel.Name = "buttonCancel"; + buttonCancel.Size = new Size(82, 27); + buttonCancel.TabIndex = 5; + buttonCancel.Text = "Отмена"; + buttonCancel.UseVisualStyleBackColor = true; + buttonCancel.Click += buttonCancel_Click; + // + // buttonSave + // + buttonSave.Location = new Point(499, 30); + buttonSave.Name = "buttonSave"; + buttonSave.Size = new Size(82, 27); + buttonSave.TabIndex = 6; + buttonSave.Text = "Сохранить"; + buttonSave.UseVisualStyleBackColor = true; + buttonSave.Click += buttonSave_Click; + // // FormSnack // AutoScaleDimensions = new SizeF(7F, 15F); @@ -213,7 +213,7 @@ Controls.Add(labelPrice); Controls.Add(labelName); Name = "FormSnack"; - Text = "Snack"; + Text = "Снэки"; Load += FormSnack_Load; groupBoxFoods.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); diff --git a/Diner/DinerView/FormSnackFood.Designer.cs b/Diner/DinerView/FormSnackFood.Designer.cs index 93309e0..2d380ba 100644 --- a/Diner/DinerView/FormSnackFood.Designer.cs +++ b/Diner/DinerView/FormSnackFood.Designer.cs @@ -103,7 +103,7 @@ Controls.Add(labelCount); Controls.Add(labelComponent); Name = "FormSnackFood"; - Text = "Snack food"; + Text = "Продукты для снэков"; ResumeLayout(false); PerformLayout(); } diff --git a/Diner/DinerView/FormSnacks.Designer.cs b/Diner/DinerView/FormSnacks.Designer.cs index beecc90..36b26d9 100644 --- a/Diner/DinerView/FormSnacks.Designer.cs +++ b/Diner/DinerView/FormSnacks.Designer.cs @@ -105,7 +105,7 @@ Controls.Add(buttonAdd); Controls.Add(dataGridView); Name = "FormSnacks"; - Text = "FormSnacks"; + Text = "Снэки"; Load += FormSnacks_Load; ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); ResumeLayout(false); diff --git a/Diner/DinerView/Program.cs b/Diner/DinerView/Program.cs index d6e7583..72af453 100644 --- a/Diner/DinerView/Program.cs +++ b/Diner/DinerView/Program.cs @@ -1,6 +1,6 @@ using DinerContracts.BusinessLogicsContacts; using DinerContracts.StoragesContracts; -using DinerListImplement.Implements; +using DinerFileImplement.Implements; using DineryBusinessLogic.BusinessLogic; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Logging; diff --git a/Diner/DineryBusinessLogic/BusinessLogic/SnackLogic.cs b/Diner/DineryBusinessLogic/BusinessLogic/SnackLogic.cs index db9a8bc..699a6be 100644 --- a/Diner/DineryBusinessLogic/BusinessLogic/SnackLogic.cs +++ b/Diner/DineryBusinessLogic/BusinessLogic/SnackLogic.cs @@ -86,7 +86,7 @@ namespace DineryBusinessLogic.BusinessLogic if (model.Price <= 0) throw new ArgumentNullException("Цена продукта должна быть больше 0", nameof(model.Price)); _logger.LogInformation("Product. ProductName:{ProductName}. Price:{Price}. ID:{ID}", - model.ProductName, model.Price, model.Price); + model.ProductName, model.Price, model.ID); var element = _productStorage.GetElement(new SnackSearchModel { ProductName = model.ProductName }); if (element != null && element.ID != model.ID) throw new InvalidOperationException("Продукт с таким названием уже есть");