diff --git a/MotorPlant/MotorPlantDatabaseImplement/Implements/OrderStorage.cs b/MotorPlant/MotorPlantDatabaseImplement/Implements/OrderStorage.cs index f61c9ac..25fd2e5 100644 --- a/MotorPlant/MotorPlantDatabaseImplement/Implements/OrderStorage.cs +++ b/MotorPlant/MotorPlantDatabaseImplement/Implements/OrderStorage.cs @@ -1,4 +1,5 @@ -using MotorPlantContracts.BindingModels; +using Microsoft.EntityFrameworkCore; +using MotorPlantContracts.BindingModels; using MotorPlantContracts.SearchModels; using MotorPlantContracts.StoragesContracts; using MotorPlantContracts.ViewModels; diff --git a/MotorPlant/MotorPlantDatabaseImplement/Models/Order.cs b/MotorPlant/MotorPlantDatabaseImplement/Models/Order.cs index 9635b5e..907cf8c 100644 --- a/MotorPlant/MotorPlantDatabaseImplement/Models/Order.cs +++ b/MotorPlant/MotorPlantDatabaseImplement/Models/Order.cs @@ -31,8 +31,6 @@ namespace MotorPlantDatabaseImplement.Models public DateTime? DateImplement { get; private set; } public static Order Create(MotorPlantDatabase context, OrderBindingModel model) - { - public static Order? Create(OrderBindingModel? model) { if (model == null) { @@ -43,7 +41,6 @@ namespace MotorPlantDatabaseImplement.Models Id = model.Id, EngineId = model.EngineId, Engine = context.Engines.First(x => x.Id == model.EngineId), - Count = model.Count, ClientId = model.ClientId, Count = model.Count, Sum = model.Sum, @@ -67,7 +64,6 @@ namespace MotorPlantDatabaseImplement.Models Id = Id, EngineId = EngineId, EngineName = Engine.EngineName, - Count = Count, ClientId = ClientId, Count = Count, Sum = Sum, diff --git a/MotorPlant/MotorPlantDatabaseImplement/MotorPlantDatabase.cs b/MotorPlant/MotorPlantDatabaseImplement/MotorPlantDatabase.cs index a56fc23..45a307c 100644 --- a/MotorPlant/MotorPlantDatabaseImplement/MotorPlantDatabase.cs +++ b/MotorPlant/MotorPlantDatabaseImplement/MotorPlantDatabase.cs @@ -21,7 +21,6 @@ namespace MotorPlantDatabaseImplement public virtual DbSet Orders { get; set; } public virtual DbSet Shops { get; set; } public virtual DbSet ShopEngines { get; set; } - } - public virtual DbSet Clients { set; get; } - } + public virtual DbSet Clients { set; get; } + } } \ No newline at end of file diff --git a/MotorPlant/MotorPlantFileImplement/DataFileSingleton.cs b/MotorPlant/MotorPlantFileImplement/DataFileSingleton.cs index 20e7f76..8c5f6d7 100644 --- a/MotorPlant/MotorPlantFileImplement/DataFileSingleton.cs +++ b/MotorPlant/MotorPlantFileImplement/DataFileSingleton.cs @@ -16,9 +16,8 @@ namespace MotorPlantFileImplement private readonly string ShopFileName = "Shop.xml"; public List Components { get; private set; } - private readonly string ClientFileName = "Client.xml"; - public List Components { get; private set; } + private readonly string ClientFileName = "Client.xml"; public List Orders { get; private set; } @@ -26,10 +25,9 @@ namespace MotorPlantFileImplement public List Shops { get; private set; } - public static DataFileSingleton GetInstance() public List Clients { get; private set; } - public static DataFileSingleton GetInstance() + public static DataFileSingleton GetInstance() { if (instance == null) { @@ -37,16 +35,16 @@ namespace MotorPlantFileImplement } return instance; } + public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement); public void SaveEngines() => SaveData(Engines, EngineFileName, "Engines", x => x.GetXElement); public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement); - public void SaveShops() => SaveData(Shops, ShopFileName, "Shops", x => x.GetXElement); + public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement); - private DataFileSingleton() - public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement); + public void SaveShops() => SaveData(Shops, ShopFileName, "Shops", x => x.GetXElement); private DataFileSingleton() { @@ -54,9 +52,8 @@ namespace MotorPlantFileImplement Engines = LoadData(EngineFileName, "Engine", x => Engine.Create(x)!)!; Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!; Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!; - } - Shops = LoadData(ShopFileName, "Shop", x => Shop.Create(x)!)!; - } + Shops = LoadData(ShopFileName, "Shop", x => Shop.Create(x)!)!; + } private static List? LoadData(string filename, string xmlNodeName, Func selectFunction) { diff --git a/MotorPlant/MotorPlantListImplement/DataListSingleton.cs b/MotorPlant/MotorPlantListImplement/DataListSingleton.cs index cdd9430..fa1c572 100644 --- a/MotorPlant/MotorPlantListImplement/DataListSingleton.cs +++ b/MotorPlant/MotorPlantListImplement/DataListSingleton.cs @@ -14,7 +14,6 @@ namespace MotorPlantListImplement public List Shops { get; set; } - private DataListSingleton() public List Clients { get; set; } private DataListSingleton() @@ -23,9 +22,8 @@ namespace MotorPlantListImplement Orders = new List(); Engines = new List(); Shops = new List(); + Clients = new List(); } - Clients = new List(); - } public static DataListSingleton GetInstance() { diff --git a/MotorPlant/MotorPlantListImplement/Implements/OrderStorage.cs b/MotorPlant/MotorPlantListImplement/Implements/OrderStorage.cs index 90b6ebc..00cf390 100644 --- a/MotorPlant/MotorPlantListImplement/Implements/OrderStorage.cs +++ b/MotorPlant/MotorPlantListImplement/Implements/OrderStorage.cs @@ -24,7 +24,7 @@ namespace MotorPlantListImplement.Implements var result = new List(); foreach (var order in _source.Orders) { - result.Add(AttachEngineName(order.GetViewModel)); + result.Add(AttachNames(order.GetViewModel)); } return result; } diff --git a/MotorPlant/MotorPlantView/FormMain.Designer.cs b/MotorPlant/MotorPlantView/FormMain.Designer.cs index ca693dd..c17609f 100644 --- a/MotorPlant/MotorPlantView/FormMain.Designer.cs +++ b/MotorPlant/MotorPlantView/FormMain.Designer.cs @@ -48,6 +48,7 @@ buttonIssuedOrder = new Button(); buttonRef = new Button(); dataGridView = new DataGridView(); + клиентыToolStripMenuItem = new ToolStripMenuItem(); toolStrip1.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); SuspendLayout(); @@ -229,6 +230,13 @@ dataGridView.Size = new Size(780, 441); dataGridView.TabIndex = 6; // + // клиентыToolStripMenuItem + // + клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem"; + клиентыToolStripMenuItem.Size = new Size(180, 22); + клиентыToolStripMenuItem.Text = "Клиенты"; + клиентыToolStripMenuItem.Click += клиентыToolStripMenuItem_Click; + // // FormMain // AutoScaleDimensions = new SizeF(7F, 15F); @@ -250,195 +258,6 @@ ResumeLayout(false); PerformLayout(); } - /// - /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - private void InitializeComponent() - { - toolStrip1 = new ToolStrip(); - toolStripDropDownButton1 = new ToolStripDropDownButton(); - КомпонентыToolStripMenuItem = new ToolStripMenuItem(); - ДвигателиToolStripMenuItem = new ToolStripMenuItem(); - отчетыToolStripMenuItem = new ToolStripMenuItem(); - списокДвигателейToolStripMenuItem = new ToolStripMenuItem(); - компонентыПоДвигателямToolStripMenuItem = new ToolStripMenuItem(); - списокЗаказовToolStripMenuItem = new ToolStripMenuItem(); - buttonCreateOrder = new Button(); - buttonTakeOrderInWork = new Button(); - buttonOrderReady = new Button(); - buttonIssuedOrder = new Button(); - buttonRef = new Button(); - dataGridView = new DataGridView(); - клиентыToolStripMenuItem = new ToolStripMenuItem(); - toolStrip1.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); - SuspendLayout(); - // - // toolStrip1 - // - toolStrip1.ImageScalingSize = new Size(20, 20); - toolStrip1.Items.AddRange(new ToolStripItem[] { toolStripDropDownButton1, отчетыToolStripMenuItem }); - toolStrip1.Location = new Point(0, 0); - toolStrip1.Name = "toolStrip1"; - toolStrip1.Size = new Size(985, 25); - toolStrip1.TabIndex = 0; - toolStrip1.Text = "toolStrip1"; - // - // toolStripDropDownButton1 - // - toolStripDropDownButton1.DisplayStyle = ToolStripItemDisplayStyle.Text; - toolStripDropDownButton1.DropDownItems.AddRange(new ToolStripItem[] { КомпонентыToolStripMenuItem, ДвигателиToolStripMenuItem, клиентыToolStripMenuItem }); - toolStripDropDownButton1.ImageTransparentColor = Color.Magenta; - toolStripDropDownButton1.Name = "toolStripDropDownButton1"; - toolStripDropDownButton1.Size = new Size(88, 22); - toolStripDropDownButton1.Text = "Справочник"; - // - // КомпонентыToolStripMenuItem - // - КомпонентыToolStripMenuItem.Name = "КомпонентыToolStripMenuItem"; - КомпонентыToolStripMenuItem.Size = new Size(180, 22); - КомпонентыToolStripMenuItem.Text = "Компоненты"; - КомпонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click; - // - // ДвигателиToolStripMenuItem - // - ДвигателиToolStripMenuItem.Name = "ДвигателиToolStripMenuItem"; - ДвигателиToolStripMenuItem.Size = new Size(180, 22); - ДвигателиToolStripMenuItem.Text = "Двигатели"; - ДвигателиToolStripMenuItem.Click += ИзделияToolStripMenuItem_Click; - // - // отчетыToolStripMenuItem - // - отчетыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { списокДвигателейToolStripMenuItem, компонентыПоДвигателямToolStripMenuItem, списокЗаказовToolStripMenuItem }); - отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem"; - отчетыToolStripMenuItem.Size = new Size(60, 25); - отчетыToolStripMenuItem.Text = "Отчеты"; - // - // списокДвигателейToolStripMenuItem - // - списокДвигателейToolStripMenuItem.Name = "списокДвигателейToolStripMenuItem"; - списокДвигателейToolStripMenuItem.Size = new Size(228, 22); - списокДвигателейToolStripMenuItem.Text = "Список двигателей"; - списокДвигателейToolStripMenuItem.Click += списокДвигателейToolStripMenuItem_Click; - // - // компонентыПоДвигателямToolStripMenuItem - // - компонентыПоДвигателямToolStripMenuItem.Name = "компонентыПоДвигателямToolStripMenuItem"; - компонентыПоДвигателямToolStripMenuItem.Size = new Size(228, 22); - компонентыПоДвигателямToolStripMenuItem.Text = "Компоненты по двигателям"; - компонентыПоДвигателямToolStripMenuItem.Click += компонентыПоДвигателямToolStripMenuItem_Click; - // - // списокЗаказовToolStripMenuItem - // - списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem"; - списокЗаказовToolStripMenuItem.Size = new Size(228, 22); - списокЗаказовToolStripMenuItem.Text = "Список заказов"; - списокЗаказовToolStripMenuItem.Click += списокЗаказовToolStripMenuItem_Click; - // - // buttonCreateOrder - // - buttonCreateOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right; - buttonCreateOrder.BackColor = SystemColors.ControlLight; - buttonCreateOrder.Location = new Point(797, 146); - buttonCreateOrder.Name = "buttonCreateOrder"; - buttonCreateOrder.Size = new Size(178, 30); - buttonCreateOrder.TabIndex = 1; - buttonCreateOrder.Text = "Создать заказ"; - buttonCreateOrder.UseVisualStyleBackColor = false; - buttonCreateOrder.Click += buttonCreateOrder_Click; - // - // buttonTakeOrderInWork - // - buttonTakeOrderInWork.Anchor = AnchorStyles.Top | AnchorStyles.Right; - buttonTakeOrderInWork.BackColor = SystemColors.ControlLight; - buttonTakeOrderInWork.Location = new Point(797, 194); - buttonTakeOrderInWork.Name = "buttonTakeOrderInWork"; - buttonTakeOrderInWork.Size = new Size(178, 30); - buttonTakeOrderInWork.TabIndex = 2; - buttonTakeOrderInWork.Text = "Отдать на выполнение"; - buttonTakeOrderInWork.UseVisualStyleBackColor = false; - buttonTakeOrderInWork.Click += buttonTakeOrderInWork_Click; - // - // buttonOrderReady - // - buttonOrderReady.Anchor = AnchorStyles.Top | AnchorStyles.Right; - buttonOrderReady.BackColor = SystemColors.ControlLight; - buttonOrderReady.Location = new Point(797, 242); - buttonOrderReady.Name = "buttonOrderReady"; - buttonOrderReady.Size = new Size(178, 30); - buttonOrderReady.TabIndex = 3; - buttonOrderReady.Text = "Заказ готов"; - buttonOrderReady.UseVisualStyleBackColor = false; - buttonOrderReady.Click += buttonOrderReady_Click; - // - // buttonIssuedOrder - // - buttonIssuedOrder.Anchor = AnchorStyles.Top | AnchorStyles.Right; - buttonIssuedOrder.BackColor = SystemColors.ControlLight; - buttonIssuedOrder.Location = new Point(797, 287); - buttonIssuedOrder.Name = "buttonIssuedOrder"; - buttonIssuedOrder.Size = new Size(178, 30); - buttonIssuedOrder.TabIndex = 4; - buttonIssuedOrder.Text = "Заказ выдан"; - buttonIssuedOrder.UseVisualStyleBackColor = false; - buttonIssuedOrder.Click += buttonIssuedOrder_Click; - // - // buttonRef - // - buttonRef.Anchor = AnchorStyles.Top | AnchorStyles.Right; - buttonRef.BackColor = SystemColors.ControlLight; - buttonRef.Location = new Point(797, 100); - buttonRef.Name = "buttonRef"; - buttonRef.Size = new Size(178, 30); - buttonRef.TabIndex = 5; - buttonRef.Text = "Обновить список"; - buttonRef.UseVisualStyleBackColor = false; - buttonRef.Click += buttonRef_Click; - // - // dataGridView - // - dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; - dataGridView.BackgroundColor = SystemColors.ButtonHighlight; - dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize; - dataGridView.Location = new Point(0, 26); - dataGridView.Name = "dataGridView"; - dataGridView.ReadOnly = true; - dataGridView.RowHeadersWidth = 51; - dataGridView.RowTemplate.Height = 24; - dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; - dataGridView.Size = new Size(780, 441); - dataGridView.TabIndex = 6; - // - // клиентыToolStripMenuItem - // - клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem"; - клиентыToolStripMenuItem.Size = new Size(180, 22); - клиентыToolStripMenuItem.Text = "Клиенты"; - клиентыToolStripMenuItem.Click += клиентыToolStripMenuItem_Click; - // - // FormMain - // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(985, 467); - Controls.Add(dataGridView); - Controls.Add(buttonRef); - Controls.Add(buttonIssuedOrder); - Controls.Add(buttonOrderReady); - Controls.Add(buttonTakeOrderInWork); - Controls.Add(buttonCreateOrder); - Controls.Add(toolStrip1); - Name = "FormMain"; - Text = "Моторный завод"; - Load += FormMain_Load; - toolStrip1.ResumeLayout(false); - toolStrip1.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit(); - ResumeLayout(false); - PerformLayout(); - } - #endregion private ToolStrip toolStrip1; @@ -456,21 +275,6 @@ private ToolStripMenuItem компонентыПоДвигателямToolStripMenuItem; private ToolStripMenuItem списокЗаказовToolStripMenuItem; private ToolStripMenuItem клиентыToolStripMenuItem; - } - private ToolStrip toolStrip1; - private Button buttonCreateOrder; - private Button buttonTakeOrderInWork; - private Button buttonOrderReady; - private Button buttonIssuedOrder; - private Button buttonRef; - private DataGridView dataGridView; - private ToolStripDropDownButton toolStripDropDownButton1; - private ToolStripMenuItem КомпонентыToolStripMenuItem; - private ToolStripMenuItem ДвигателиToolStripMenuItem; - private ToolStripMenuItem отчетыToolStripMenuItem; - private ToolStripMenuItem списокДвигателейToolStripMenuItem; - private ToolStripMenuItem компонентыПоДвигателямToolStripMenuItem; - private ToolStripMenuItem списокЗаказовToolStripMenuItem; private ToolStripMenuItem магазиныToolStripMenuItem; private ToolStripMenuItem поставкаToolStripMenuItem; private ToolStripMenuItem продажаToolStripMenuItem; diff --git a/MotorPlant/MotorPlantView/FormMain.cs b/MotorPlant/MotorPlantView/FormMain.cs index 88c3bd4..30e1fce 100644 --- a/MotorPlant/MotorPlantView/FormMain.cs +++ b/MotorPlant/MotorPlantView/FormMain.cs @@ -231,23 +231,14 @@ namespace MotorPlantView.Forms form.ShowDialog(); } } - } - private void списокЗаказовToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormReportOrders)); - if (service is FormReportOrders form) - { - form.ShowDialog(); - } - } - private void клиентыToolStripMenuItem_Click(object sender, EventArgs e) - { - var service = Program.ServiceProvider?.GetService(typeof(FormClients)); - if (service is FormClients form) - { - form.ShowDialog(); - } - } - } + private void клиентыToolStripMenuItem_Click(object sender, EventArgs e) + { + var service = Program.ServiceProvider?.GetService(typeof(FormClients)); + if (service is FormClients form) + { + form.ShowDialog(); + } + } + } }