Готовая первая лаба
This commit is contained in:
parent
26c76e03d3
commit
ab83e06788
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Entities;
|
||||||
|
|
||||||
|
public class AccessoiresOrder
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public int OrderId { get; private set; }
|
||||||
|
|
||||||
|
public int Count { get; private set; }
|
||||||
|
|
||||||
|
public static AccessoiresOrder CreateElement(int id, int orderId, int count)
|
||||||
|
{
|
||||||
|
return new AccessoiresOrder { Id = id, OrderId = orderId, Count = count};
|
||||||
|
}
|
||||||
|
}
|
@ -17,12 +17,13 @@ public class Accessories
|
|||||||
|
|
||||||
public double Price { get; private set; }
|
public double Price { get; private set; }
|
||||||
|
|
||||||
public static Accessories CreateEntity(int id, AccessoriesType accessoriesType, double price)
|
public static Accessories CreateEntity(int id, AccessoriesType accessoriesType, int count, double price)
|
||||||
{
|
{
|
||||||
return new Accessories
|
return new Accessories
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
AccessoriesType = accessoriesType,
|
AccessoriesType = accessoriesType,
|
||||||
|
Count = count,
|
||||||
Price = price
|
Price = price
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
using ProjectCompRepair.Entities.Enums;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectCompRepair.Entities;
|
|
||||||
|
|
||||||
public class DeliveryToTheWarehouse
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
|
|
||||||
public DateTime Date { get; private set; }
|
|
||||||
|
|
||||||
public AccessoriesType AccessoriesType { get; private set; }
|
|
||||||
public int Count { get; private set; }
|
|
||||||
|
|
||||||
public static DeliveryToTheWarehouse CreateOperation(int id, AccessoriesType accessoriesType, int count)
|
|
||||||
{
|
|
||||||
return new DeliveryToTheWarehouse()
|
|
||||||
{
|
|
||||||
Id = id,
|
|
||||||
AccessoriesType = accessoriesType,
|
|
||||||
Date = DateTime.Now,
|
|
||||||
Count = count,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace ProjectCompRepair.Entities.Enums;
|
namespace ProjectCompRepair.Entities.Enums;
|
||||||
|
|
||||||
[Flags]
|
|
||||||
public enum AccessoriesType
|
public enum AccessoriesType
|
||||||
{
|
{
|
||||||
None = 0,
|
None = 0,
|
||||||
@ -15,8 +15,8 @@ public enum AccessoriesType
|
|||||||
|
|
||||||
AccessMemory = 2,
|
AccessMemory = 2,
|
||||||
|
|
||||||
VideoCard = 4,
|
VideoCard = 3,
|
||||||
|
|
||||||
Cooler = 8
|
Cooler = 4
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,19 +9,21 @@ namespace ProjectCompRepair.Entities;
|
|||||||
public class Order
|
public class Order
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
public string Name { get; private set; }
|
public string Name { get; private set; }
|
||||||
|
|
||||||
public string Coment { get; private set; }
|
public string Coment { get; private set; }
|
||||||
|
|
||||||
public DateTime Date { get; private set; }
|
public DateTime Date { get; private set; }
|
||||||
|
|
||||||
public int CountAccessories { get; private set; }
|
|
||||||
|
|
||||||
public int CountService { get; private set; }
|
|
||||||
|
|
||||||
public int MasterID { get; private set; }
|
public int MasterID { get; private set; }
|
||||||
|
|
||||||
public static Order CreateOperation(int id, string name, string coment, int countAccessories, int countService, int masterId)
|
public IEnumerable<AccessoiresOrder> AccessoiresOrders { get; private set; } = [];
|
||||||
|
|
||||||
|
public IEnumerable<ServicesOrder> ServicesOrders { get; private set; } = [];
|
||||||
|
|
||||||
|
|
||||||
|
public static Order CreateElement(int id, string name, string coment, int masterId)
|
||||||
{
|
{
|
||||||
return new Order()
|
return new Order()
|
||||||
{
|
{
|
||||||
@ -29,9 +31,8 @@ public class Order
|
|||||||
Name = name,
|
Name = name,
|
||||||
Coment = coment,
|
Coment = coment,
|
||||||
Date = DateTime.Now,
|
Date = DateTime.Now,
|
||||||
CountAccessories = countAccessories,
|
|
||||||
CountService = countService,
|
|
||||||
MasterID = masterId
|
MasterID = masterId
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ public class Service
|
|||||||
|
|
||||||
public double Price { get; private set; }
|
public double Price { get; private set; }
|
||||||
|
|
||||||
public static Service CreateOperation(int id, ServiceType serviceType, int count, double price)
|
public static Service CreateEntity(int id, ServiceType serviceType, double price)
|
||||||
{
|
{
|
||||||
return new Service
|
return new Service
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Entities;
|
||||||
|
|
||||||
|
public class ServicesOrder
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public int OrderId { get; private set; }
|
||||||
|
|
||||||
|
public int Count { get; private set; }
|
||||||
|
|
||||||
|
public static ServicesOrder CreateElement(int id, int orderId, int count)
|
||||||
|
{
|
||||||
|
return new ServicesOrder { Id = id, OrderId = orderId, Count = count };
|
||||||
|
}
|
||||||
|
}
|
@ -1,26 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectCompRepair.Entities;
|
|
||||||
|
|
||||||
public class Warehouse
|
|
||||||
{
|
|
||||||
public int Id { get; private set; }
|
|
||||||
|
|
||||||
public string Name { get; private set; }
|
|
||||||
|
|
||||||
public int Capacity { get; private set; }
|
|
||||||
|
|
||||||
public static Warehouse CreateEntity(int id, string name, int capacity)
|
|
||||||
{
|
|
||||||
return new Warehouse()
|
|
||||||
{
|
|
||||||
Id = id,
|
|
||||||
Name = name,
|
|
||||||
Capacity = capacity
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -30,91 +30,84 @@
|
|||||||
{
|
{
|
||||||
menuStrip = new MenuStrip();
|
menuStrip = new MenuStrip();
|
||||||
справочникToolStripMenuItem = new ToolStripMenuItem();
|
справочникToolStripMenuItem = new ToolStripMenuItem();
|
||||||
комплектующиеToolStripMenuItem = new ToolStripMenuItem();
|
AccossoriesToolStripMenuItem = new ToolStripMenuItem();
|
||||||
складToolStripMenuItem = new ToolStripMenuItem();
|
MasterToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
ServiceToolStripMenuItem = new ToolStripMenuItem();
|
||||||
операцииToolStripMenuItem = new ToolStripMenuItem();
|
операцииToolStripMenuItem = new ToolStripMenuItem();
|
||||||
заказToolStripMenuItem = new ToolStripMenuItem();
|
OrderToolStripMenuItem = new ToolStripMenuItem();
|
||||||
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
мастерToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
завозНаСкладToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
услугаToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
menuStrip.SuspendLayout();
|
menuStrip.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// menuStrip
|
// menuStrip
|
||||||
//
|
//
|
||||||
|
menuStrip.ImageScalingSize = new Size(20, 20);
|
||||||
menuStrip.Items.AddRange(new ToolStripItem[] { справочникToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem });
|
menuStrip.Items.AddRange(new ToolStripItem[] { справочникToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem });
|
||||||
menuStrip.Location = new Point(0, 0);
|
menuStrip.Location = new Point(0, 0);
|
||||||
menuStrip.Name = "menuStrip";
|
menuStrip.Name = "menuStrip";
|
||||||
menuStrip.Size = new Size(784, 24);
|
menuStrip.Padding = new Padding(7, 3, 0, 3);
|
||||||
|
menuStrip.Size = new Size(896, 30);
|
||||||
menuStrip.TabIndex = 0;
|
menuStrip.TabIndex = 0;
|
||||||
menuStrip.Text = "menuStrip1";
|
menuStrip.Text = "menuStrip1";
|
||||||
//
|
//
|
||||||
// справочникToolStripMenuItem
|
// справочникToolStripMenuItem
|
||||||
//
|
//
|
||||||
справочникToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { комплектующиеToolStripMenuItem, складToolStripMenuItem, мастерToolStripMenuItem, услугаToolStripMenuItem });
|
справочникToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { AccossoriesToolStripMenuItem, MasterToolStripMenuItem, ServiceToolStripMenuItem });
|
||||||
справочникToolStripMenuItem.Name = "справочникToolStripMenuItem";
|
справочникToolStripMenuItem.Name = "справочникToolStripMenuItem";
|
||||||
справочникToolStripMenuItem.Size = new Size(94, 20);
|
справочникToolStripMenuItem.Size = new Size(117, 24);
|
||||||
справочникToolStripMenuItem.Text = "Справочники";
|
справочникToolStripMenuItem.Text = "Справочники";
|
||||||
//
|
//
|
||||||
// комплектующиеToolStripMenuItem
|
// AccossoriesToolStripMenuItem
|
||||||
//
|
//
|
||||||
комплектующиеToolStripMenuItem.Name = "комплектующиеToolStripMenuItem";
|
AccossoriesToolStripMenuItem.Name = "AccossoriesToolStripMenuItem";
|
||||||
комплектующиеToolStripMenuItem.Size = new Size(180, 22);
|
AccossoriesToolStripMenuItem.Size = new Size(224, 26);
|
||||||
комплектующиеToolStripMenuItem.Text = "Комплектующие";
|
AccossoriesToolStripMenuItem.Text = "Комплектующие";
|
||||||
|
AccossoriesToolStripMenuItem.Click += AccossoriesToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// складToolStripMenuItem
|
// MasterToolStripMenuItem
|
||||||
//
|
//
|
||||||
складToolStripMenuItem.Name = "складToolStripMenuItem";
|
MasterToolStripMenuItem.Name = "MasterToolStripMenuItem";
|
||||||
складToolStripMenuItem.Size = new Size(180, 22);
|
MasterToolStripMenuItem.Size = new Size(224, 26);
|
||||||
складToolStripMenuItem.Text = "Склад";
|
MasterToolStripMenuItem.Text = "Мастер";
|
||||||
|
MasterToolStripMenuItem.Click += MasterToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// ServiceToolStripMenuItem
|
||||||
|
//
|
||||||
|
ServiceToolStripMenuItem.Name = "ServiceToolStripMenuItem";
|
||||||
|
ServiceToolStripMenuItem.Size = new Size(224, 26);
|
||||||
|
ServiceToolStripMenuItem.Text = "Услуга";
|
||||||
|
ServiceToolStripMenuItem.Click += ServiceToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// операцииToolStripMenuItem
|
// операцииToolStripMenuItem
|
||||||
//
|
//
|
||||||
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { заказToolStripMenuItem, завозНаСкладToolStripMenuItem });
|
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { OrderToolStripMenuItem });
|
||||||
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
|
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
|
||||||
операцииToolStripMenuItem.Size = new Size(75, 20);
|
операцииToolStripMenuItem.Size = new Size(95, 24);
|
||||||
операцииToolStripMenuItem.Text = "Операции";
|
операцииToolStripMenuItem.Text = "Операции";
|
||||||
//
|
//
|
||||||
// заказToolStripMenuItem
|
// OrderToolStripMenuItem
|
||||||
//
|
//
|
||||||
заказToolStripMenuItem.Name = "заказToolStripMenuItem";
|
OrderToolStripMenuItem.Name = "OrderToolStripMenuItem";
|
||||||
заказToolStripMenuItem.Size = new Size(180, 22);
|
OrderToolStripMenuItem.Size = new Size(224, 26);
|
||||||
заказToolStripMenuItem.Text = "Заказ";
|
OrderToolStripMenuItem.Text = "Заказ";
|
||||||
|
OrderToolStripMenuItem.Click += OrderToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// отчетыToolStripMenuItem
|
// отчетыToolStripMenuItem
|
||||||
//
|
//
|
||||||
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
||||||
отчетыToolStripMenuItem.Size = new Size(60, 20);
|
отчетыToolStripMenuItem.Size = new Size(73, 24);
|
||||||
отчетыToolStripMenuItem.Text = "Отчеты";
|
отчетыToolStripMenuItem.Text = "Отчеты";
|
||||||
//
|
//
|
||||||
// мастерToolStripMenuItem
|
|
||||||
//
|
|
||||||
мастерToolStripMenuItem.Name = "мастерToolStripMenuItem";
|
|
||||||
мастерToolStripMenuItem.Size = new Size(180, 22);
|
|
||||||
мастерToolStripMenuItem.Text = "Мастер";
|
|
||||||
//
|
|
||||||
// завозНаСкладToolStripMenuItem
|
|
||||||
//
|
|
||||||
завозНаСкладToolStripMenuItem.Name = "завозНаСкладToolStripMenuItem";
|
|
||||||
завозНаСкладToolStripMenuItem.Size = new Size(180, 22);
|
|
||||||
завозНаСкладToolStripMenuItem.Text = "Завоз на склад";
|
|
||||||
//
|
|
||||||
// услугаToolStripMenuItem
|
|
||||||
//
|
|
||||||
услугаToolStripMenuItem.Name = "услугаToolStripMenuItem";
|
|
||||||
услугаToolStripMenuItem.Size = new Size(180, 22);
|
|
||||||
услугаToolStripMenuItem.Text = "Услуга";
|
|
||||||
//
|
|
||||||
// FormCompRepair
|
// FormCompRepair
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
BackgroundImage = Properties.Resources.morskie_kamni_raznocvetnaya_galka;
|
BackgroundImage = Properties.Resources.morskie_kamni_raznocvetnaya_galka;
|
||||||
BackgroundImageLayout = ImageLayout.Stretch;
|
BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
ClientSize = new Size(784, 411);
|
ClientSize = new Size(896, 548);
|
||||||
Controls.Add(menuStrip);
|
Controls.Add(menuStrip);
|
||||||
MainMenuStrip = menuStrip;
|
MainMenuStrip = menuStrip;
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
Name = "FormCompRepair";
|
Name = "FormCompRepair";
|
||||||
StartPosition = FormStartPosition.CenterScreen;
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
Text = "Фирма по ремонту техники";
|
Text = "Фирма по ремонту техники";
|
||||||
@ -128,13 +121,11 @@
|
|||||||
|
|
||||||
private MenuStrip menuStrip;
|
private MenuStrip menuStrip;
|
||||||
private ToolStripMenuItem справочникToolStripMenuItem;
|
private ToolStripMenuItem справочникToolStripMenuItem;
|
||||||
private ToolStripMenuItem комплектующиеToolStripMenuItem;
|
private ToolStripMenuItem AccossoriesToolStripMenuItem;
|
||||||
private ToolStripMenuItem операцииToolStripMenuItem;
|
private ToolStripMenuItem операцииToolStripMenuItem;
|
||||||
private ToolStripMenuItem отчетыToolStripMenuItem;
|
private ToolStripMenuItem отчетыToolStripMenuItem;
|
||||||
private ToolStripMenuItem складToolStripMenuItem;
|
private ToolStripMenuItem OrderToolStripMenuItem;
|
||||||
private ToolStripMenuItem заказToolStripMenuItem;
|
private ToolStripMenuItem MasterToolStripMenuItem;
|
||||||
private ToolStripMenuItem мастерToolStripMenuItem;
|
private ToolStripMenuItem ServiceToolStripMenuItem;
|
||||||
private ToolStripMenuItem услугаToolStripMenuItem;
|
|
||||||
private ToolStripMenuItem завозНаСкладToolStripMenuItem;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,65 @@
|
|||||||
|
using ProjectCompRepair.Forms;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
namespace ProjectCompRepair
|
namespace ProjectCompRepair
|
||||||
{
|
{
|
||||||
public partial class FormCompRepair : Form
|
public partial class FormCompRepair : Form
|
||||||
{
|
{
|
||||||
public FormCompRepair()
|
private readonly IUnityContainer _container;
|
||||||
|
public FormCompRepair(IUnityContainer container)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_container = container ??
|
||||||
|
throw new ArgumentNullException(nameof(container));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AccossoriesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormAccessories>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void MasterToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormMasters>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ServiceToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormServices>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OrderToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormOrders>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,14 +11,6 @@
|
|||||||
/// Clean up any resources being used.
|
/// Clean up any resources being used.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (disposing && (components != null))
|
|
||||||
{
|
|
||||||
components.Dispose();
|
|
||||||
}
|
|
||||||
base.Dispose(disposing);
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Windows Form Designer generated code
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
@ -33,99 +25,116 @@
|
|||||||
labelPrice = new Label();
|
labelPrice = new Label();
|
||||||
numericUpDownPrice = new NumericUpDown();
|
numericUpDownPrice = new NumericUpDown();
|
||||||
numericUpDownCount = new NumericUpDown();
|
numericUpDownCount = new NumericUpDown();
|
||||||
numericUpDownType = new NumericUpDown();
|
|
||||||
buttonCreate = new Button();
|
buttonCreate = new Button();
|
||||||
buttonCancel = new Button();
|
buttonCancel = new Button();
|
||||||
|
comboBoxType = new ComboBox();
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownCount).BeginInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDownCount).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownType).BeginInit();
|
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// labelType
|
// labelType
|
||||||
//
|
//
|
||||||
|
labelType.Anchor = AnchorStyles.Right;
|
||||||
labelType.AutoSize = true;
|
labelType.AutoSize = true;
|
||||||
labelType.Location = new Point(46, 50);
|
labelType.Location = new Point(54, 75);
|
||||||
labelType.Name = "labelType";
|
labelType.Name = "labelType";
|
||||||
labelType.Size = new Size(128, 15);
|
labelType.Size = new Size(158, 20);
|
||||||
labelType.TabIndex = 0;
|
labelType.TabIndex = 0;
|
||||||
labelType.Text = "Вид комплектующего";
|
labelType.Text = "Вид комплектующего";
|
||||||
//
|
//
|
||||||
// labelCount
|
// labelCount
|
||||||
//
|
//
|
||||||
|
labelCount.Anchor = AnchorStyles.Right;
|
||||||
labelCount.AutoSize = true;
|
labelCount.AutoSize = true;
|
||||||
labelCount.Location = new Point(46, 108);
|
labelCount.Location = new Point(54, 152);
|
||||||
labelCount.Name = "labelCount";
|
labelCount.Name = "labelCount";
|
||||||
labelCount.Size = new Size(79, 15);
|
labelCount.Size = new Size(98, 20);
|
||||||
labelCount.TabIndex = 2;
|
labelCount.TabIndex = 2;
|
||||||
labelCount.Text = "Колличество";
|
labelCount.Text = "Колличество";
|
||||||
//
|
//
|
||||||
// labelPrice
|
// labelPrice
|
||||||
//
|
//
|
||||||
|
labelPrice.Anchor = AnchorStyles.Right;
|
||||||
labelPrice.AutoSize = true;
|
labelPrice.AutoSize = true;
|
||||||
labelPrice.Location = new Point(46, 167);
|
labelPrice.Location = new Point(54, 231);
|
||||||
labelPrice.Name = "labelPrice";
|
labelPrice.Name = "labelPrice";
|
||||||
labelPrice.Size = new Size(35, 15);
|
labelPrice.Size = new Size(45, 20);
|
||||||
labelPrice.TabIndex = 4;
|
labelPrice.TabIndex = 4;
|
||||||
labelPrice.Text = "Цена";
|
labelPrice.Text = "Цена";
|
||||||
//
|
//
|
||||||
// numericUpDownPrice
|
// numericUpDownPrice
|
||||||
//
|
//
|
||||||
|
numericUpDownPrice.Anchor = AnchorStyles.Right;
|
||||||
numericUpDownPrice.DecimalPlaces = 2;
|
numericUpDownPrice.DecimalPlaces = 2;
|
||||||
numericUpDownPrice.Location = new Point(191, 165);
|
numericUpDownPrice.Location = new Point(252, 235);
|
||||||
|
numericUpDownPrice.Margin = new Padding(3, 4, 3, 4);
|
||||||
numericUpDownPrice.Name = "numericUpDownPrice";
|
numericUpDownPrice.Name = "numericUpDownPrice";
|
||||||
numericUpDownPrice.Size = new Size(120, 23);
|
numericUpDownPrice.Size = new Size(119, 27);
|
||||||
numericUpDownPrice.TabIndex = 5;
|
numericUpDownPrice.TabIndex = 5;
|
||||||
//
|
//
|
||||||
// numericUpDownCount
|
// numericUpDownCount
|
||||||
//
|
//
|
||||||
numericUpDownCount.Location = new Point(191, 106);
|
numericUpDownCount.Anchor = AnchorStyles.Right;
|
||||||
|
numericUpDownCount.Location = new Point(252, 156);
|
||||||
|
numericUpDownCount.Margin = new Padding(3, 4, 3, 4);
|
||||||
numericUpDownCount.Name = "numericUpDownCount";
|
numericUpDownCount.Name = "numericUpDownCount";
|
||||||
numericUpDownCount.Size = new Size(120, 23);
|
numericUpDownCount.Size = new Size(119, 27);
|
||||||
numericUpDownCount.TabIndex = 6;
|
numericUpDownCount.TabIndex = 6;
|
||||||
//
|
//
|
||||||
// numericUpDownType
|
|
||||||
//
|
|
||||||
numericUpDownType.Location = new Point(191, 50);
|
|
||||||
numericUpDownType.Name = "numericUpDownType";
|
|
||||||
numericUpDownType.Size = new Size(120, 23);
|
|
||||||
numericUpDownType.TabIndex = 7;
|
|
||||||
//
|
|
||||||
// buttonCreate
|
// buttonCreate
|
||||||
//
|
//
|
||||||
buttonCreate.Location = new Point(46, 297);
|
buttonCreate.AllowDrop = true;
|
||||||
|
buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
|
buttonCreate.Location = new Point(53, 417);
|
||||||
|
buttonCreate.Margin = new Padding(3, 4, 3, 4);
|
||||||
buttonCreate.Name = "buttonCreate";
|
buttonCreate.Name = "buttonCreate";
|
||||||
buttonCreate.Size = new Size(75, 23);
|
buttonCreate.Size = new Size(98, 33);
|
||||||
buttonCreate.TabIndex = 8;
|
buttonCreate.TabIndex = 8;
|
||||||
buttonCreate.Text = "Создать";
|
buttonCreate.Text = "Сохранить";
|
||||||
buttonCreate.UseVisualStyleBackColor = true;
|
buttonCreate.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreate.Click += ButtonSave_Click;
|
||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
buttonCancel.Location = new Point(236, 297);
|
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonCancel.Location = new Point(310, 416);
|
||||||
|
buttonCancel.Margin = new Padding(3, 4, 3, 4);
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(75, 23);
|
buttonCancel.Size = new Size(101, 31);
|
||||||
buttonCancel.TabIndex = 10;
|
buttonCancel.TabIndex = 10;
|
||||||
buttonCancel.Text = "Отмена";
|
buttonCancel.Text = "Отмена";
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += ButtonCancel_Click;
|
||||||
|
//
|
||||||
|
// comboBoxType
|
||||||
|
//
|
||||||
|
comboBoxType.FormattingEnabled = true;
|
||||||
|
comboBoxType.Location = new Point(250, 78);
|
||||||
|
comboBoxType.Name = "comboBoxType";
|
||||||
|
comboBoxType.Size = new Size(151, 28);
|
||||||
|
comboBoxType.TabIndex = 11;
|
||||||
//
|
//
|
||||||
// FormAccessorie
|
// FormAccessorie
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AllowDrop = true;
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(346, 340);
|
AutoSizeMode = AutoSizeMode.GrowAndShrink;
|
||||||
|
AutoValidate = AutoValidate.EnableAllowFocusChange;
|
||||||
|
ClientSize = new Size(448, 478);
|
||||||
|
Controls.Add(comboBoxType);
|
||||||
Controls.Add(buttonCancel);
|
Controls.Add(buttonCancel);
|
||||||
Controls.Add(buttonCreate);
|
Controls.Add(buttonCreate);
|
||||||
Controls.Add(numericUpDownType);
|
|
||||||
Controls.Add(numericUpDownCount);
|
Controls.Add(numericUpDownCount);
|
||||||
Controls.Add(numericUpDownPrice);
|
Controls.Add(numericUpDownPrice);
|
||||||
Controls.Add(labelPrice);
|
Controls.Add(labelPrice);
|
||||||
Controls.Add(labelCount);
|
Controls.Add(labelCount);
|
||||||
Controls.Add(labelType);
|
Controls.Add(labelType);
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
Name = "FormAccessorie";
|
Name = "FormAccessorie";
|
||||||
Text = "Комплектующое";
|
Text = "Комплектующое";
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownCount).EndInit();
|
((System.ComponentModel.ISupportInitialize)numericUpDownCount).EndInit();
|
||||||
((System.ComponentModel.ISupportInitialize)numericUpDownType).EndInit();
|
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
@ -137,9 +146,9 @@
|
|||||||
private Label labelPrice;
|
private Label labelPrice;
|
||||||
private NumericUpDown numericUpDownPrice;
|
private NumericUpDown numericUpDownPrice;
|
||||||
private NumericUpDown numericUpDownCount;
|
private NumericUpDown numericUpDownCount;
|
||||||
private NumericUpDown numericUpDownType;
|
|
||||||
private Button buttonCreate;
|
private Button buttonCreate;
|
||||||
private Button buttonUpdate;
|
private Button buttonUpdate;
|
||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
|
private ComboBox comboBoxType;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,8 @@
|
|||||||
using System;
|
using ProjectCompRepair.Entities;
|
||||||
|
using ProjectCompRepair.Entities.Enums;
|
||||||
|
using ProjectCompRepair.Repositories;
|
||||||
|
using ProjectCompRepair.Repositories.Implemantations;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
@ -12,9 +16,73 @@ namespace ProjectCompRepair.Forms
|
|||||||
{
|
{
|
||||||
public partial class FormAccessorie : Form
|
public partial class FormAccessorie : Form
|
||||||
{
|
{
|
||||||
public FormAccessorie()
|
private readonly IAccessoriesRepository _accessoriesRepository;
|
||||||
|
|
||||||
|
private int? _accessorieId;
|
||||||
|
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var accessorie = _accessoriesRepository.ReadAccessoriesById(value);
|
||||||
|
if (accessorie == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException(nameof(accessorie));
|
||||||
|
}
|
||||||
|
|
||||||
|
numericUpDownCount.Value = accessorie.Count;
|
||||||
|
numericUpDownPrice.Value = (int)accessorie.Price;
|
||||||
|
_accessorieId = value;
|
||||||
|
comboBoxType.SelectedItem = accessorie.AccessoriesType;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FormAccessorie(IAccessoriesRepository accessoriesRepository)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_accessoriesRepository = accessoriesRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(accessoriesRepository));
|
||||||
|
comboBoxType.DataSource = Enum.GetValues(typeof(AccessoriesType));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (comboBoxType.SelectedIndex < 1 || numericUpDownPrice.Value == 0 || numericUpDownCount.Value == 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Имеются незаполненные поля");
|
||||||
|
}
|
||||||
|
if (_accessorieId.HasValue)
|
||||||
|
{
|
||||||
|
_accessoriesRepository.UpdateAccessories(CreateAccessories(_accessorieId.Value));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_accessoriesRepository.CreateAccessories(CreateAccessories(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||||
|
|
||||||
|
private Accessories CreateAccessories(int id)
|
||||||
|
{
|
||||||
|
return Accessories.CreateEntity(id, (AccessoriesType)comboBoxType.SelectedItem! , (int)numericUpDownCount.Value, (double)numericUpDownPrice.Value);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
117
ProjectCompRepair/ProjectCompRepair/Forms/FormAccessories.Designer.cs
generated
Normal file
117
ProjectCompRepair/ProjectCompRepair/Forms/FormAccessories.Designer.cs
generated
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
namespace ProjectCompRepair.Forms
|
||||||
|
{
|
||||||
|
partial class FormAccessories
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
panelButtons = new Panel();
|
||||||
|
buttonDel = new Button();
|
||||||
|
buttonChange = new Button();
|
||||||
|
buttonCreate = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
panelButtons.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// panelButtons
|
||||||
|
//
|
||||||
|
panelButtons.Controls.Add(buttonDel);
|
||||||
|
panelButtons.Controls.Add(buttonChange);
|
||||||
|
panelButtons.Controls.Add(buttonCreate);
|
||||||
|
panelButtons.Dock = DockStyle.Right;
|
||||||
|
panelButtons.Location = new Point(645, 0);
|
||||||
|
panelButtons.Name = "panelButtons";
|
||||||
|
panelButtons.Size = new Size(155, 450);
|
||||||
|
panelButtons.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
buttonDel.BackgroundImage = Properties.Resources.pngwing_com__7_;
|
||||||
|
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonDel.Location = new Point(40, 255);
|
||||||
|
buttonDel.Name = "buttonDel";
|
||||||
|
buttonDel.Size = new Size(94, 91);
|
||||||
|
buttonDel.TabIndex = 2;
|
||||||
|
buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
buttonDel.Click += ButtonDel_Click;
|
||||||
|
//
|
||||||
|
// buttonChange
|
||||||
|
//
|
||||||
|
buttonChange.BackgroundImage = Properties.Resources.pngwing_com__8_;
|
||||||
|
buttonChange.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonChange.Location = new Point(40, 149);
|
||||||
|
buttonChange.Name = "buttonChange";
|
||||||
|
buttonChange.Size = new Size(94, 89);
|
||||||
|
buttonChange.TabIndex = 1;
|
||||||
|
buttonChange.UseVisualStyleBackColor = true;
|
||||||
|
buttonChange.Click += ButtonChange_Click;
|
||||||
|
//
|
||||||
|
// buttonCreate
|
||||||
|
//
|
||||||
|
buttonCreate.BackgroundImage = Properties.Resources.pngwing_com__6_;
|
||||||
|
buttonCreate.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonCreate.Location = new Point(40, 43);
|
||||||
|
buttonCreate.Name = "buttonCreate";
|
||||||
|
buttonCreate.Size = new Size(94, 88);
|
||||||
|
buttonCreate.TabIndex = 0;
|
||||||
|
buttonCreate.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreate.Click += ButtonCreate_Click;
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Dock = DockStyle.Fill;
|
||||||
|
dataGridView.Location = new Point(0, 0);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.RowHeadersWidth = 51;
|
||||||
|
dataGridView.Size = new Size(800, 450);
|
||||||
|
dataGridView.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// FormAccessories
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(panelButtons);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Name = "FormAccessories";
|
||||||
|
Text = "Комплектующие";
|
||||||
|
Load += FormAccessories_Load;
|
||||||
|
panelButtons.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Panel panelButtons;
|
||||||
|
private Button buttonDel;
|
||||||
|
private Button buttonChange;
|
||||||
|
private Button buttonCreate;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
115
ProjectCompRepair/ProjectCompRepair/Forms/FormAccessories.cs
Normal file
115
ProjectCompRepair/ProjectCompRepair/Forms/FormAccessories.cs
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
using ProjectCompRepair.Repositories;
|
||||||
|
using ProjectCompRepair.Repositories.Implemantations;
|
||||||
|
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 System.Xml.Linq;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Forms
|
||||||
|
{
|
||||||
|
public partial class FormAccessories : Form
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
|
||||||
|
private readonly IAccessoriesRepository _accessoriesRepository;
|
||||||
|
|
||||||
|
public FormAccessories(IUnityContainer container, IAccessoriesRepository accessoriesRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ??
|
||||||
|
throw new ArgumentException(nameof(container));
|
||||||
|
_accessoriesRepository = accessoriesRepository
|
||||||
|
?? throw new ArgumentException(nameof(accessoriesRepository));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormAccessories_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormAccessorie>().ShowDialog();
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonChange_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!TryGetIdentifierFromSelectRow(out var findId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var form = _container.Resolve<FormAccessorie>();
|
||||||
|
form.Id = findId;
|
||||||
|
form.ShowDialog();
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonDel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!TryGetIdentifierFromSelectRow(out var findId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (MessageBox.Show("Удалить запись", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_accessoriesRepository.DeleteAccessories(findId);
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadList() => dataGridView.DataSource = _accessoriesRepository.ReadAccessories();
|
||||||
|
|
||||||
|
private bool TryGetIdentifierFromSelectRow(out int id)
|
||||||
|
{
|
||||||
|
id = 0;
|
||||||
|
if (dataGridView.SelectedRows.Count < 1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
ProjectCompRepair/ProjectCompRepair/Forms/FormAccessories.resx
Normal file
120
ProjectCompRepair/ProjectCompRepair/Forms/FormAccessories.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
@ -36,25 +36,30 @@
|
|||||||
//
|
//
|
||||||
// labelName
|
// labelName
|
||||||
//
|
//
|
||||||
|
labelName.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
labelName.AutoSize = true;
|
labelName.AutoSize = true;
|
||||||
labelName.Location = new Point(27, 55);
|
labelName.Location = new Point(87, 73);
|
||||||
labelName.Name = "labelName";
|
labelName.Name = "labelName";
|
||||||
labelName.Size = new Size(31, 15);
|
labelName.Size = new Size(39, 20);
|
||||||
labelName.TabIndex = 0;
|
labelName.TabIndex = 0;
|
||||||
labelName.Text = "Имя";
|
labelName.Text = "Имя";
|
||||||
//
|
//
|
||||||
// textBoxName
|
// textBoxName
|
||||||
//
|
//
|
||||||
textBoxName.Location = new Point(91, 55);
|
textBoxName.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
textBoxName.Location = new Point(160, 73);
|
||||||
|
textBoxName.Margin = new Padding(3, 4, 3, 4);
|
||||||
textBoxName.Name = "textBoxName";
|
textBoxName.Name = "textBoxName";
|
||||||
textBoxName.Size = new Size(100, 23);
|
textBoxName.Size = new Size(114, 27);
|
||||||
textBoxName.TabIndex = 1;
|
textBoxName.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// buttonSave
|
// buttonSave
|
||||||
//
|
//
|
||||||
buttonSave.Location = new Point(27, 205);
|
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
|
buttonSave.Location = new Point(31, 273);
|
||||||
|
buttonSave.Margin = new Padding(3, 4, 3, 4);
|
||||||
buttonSave.Name = "buttonSave";
|
buttonSave.Name = "buttonSave";
|
||||||
buttonSave.Size = new Size(75, 23);
|
buttonSave.Size = new Size(97, 31);
|
||||||
buttonSave.TabIndex = 2;
|
buttonSave.TabIndex = 2;
|
||||||
buttonSave.Text = "Сохранить";
|
buttonSave.Text = "Сохранить";
|
||||||
buttonSave.UseVisualStyleBackColor = true;
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
@ -62,9 +67,11 @@
|
|||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
buttonCancel.Location = new Point(133, 206);
|
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
|
buttonCancel.Location = new Point(208, 275);
|
||||||
|
buttonCancel.Margin = new Padding(3, 4, 3, 4);
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(75, 23);
|
buttonCancel.Size = new Size(86, 31);
|
||||||
buttonCancel.TabIndex = 3;
|
buttonCancel.TabIndex = 3;
|
||||||
buttonCancel.Text = "Отмена";
|
buttonCancel.Text = "Отмена";
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
@ -72,13 +79,14 @@
|
|||||||
//
|
//
|
||||||
// FormMaster
|
// FormMaster
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(241, 253);
|
ClientSize = new Size(331, 337);
|
||||||
Controls.Add(buttonCancel);
|
Controls.Add(buttonCancel);
|
||||||
Controls.Add(buttonSave);
|
Controls.Add(buttonSave);
|
||||||
Controls.Add(textBoxName);
|
Controls.Add(textBoxName);
|
||||||
Controls.Add(labelName);
|
Controls.Add(labelName);
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
Name = "FormMaster";
|
Name = "FormMaster";
|
||||||
StartPosition = FormStartPosition.CenterScreen;
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
Text = "Мастер";
|
Text = "Мастер";
|
||||||
|
@ -28,33 +28,22 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
panelButtons = new Panel();
|
|
||||||
buttonDel = new Button();
|
buttonDel = new Button();
|
||||||
buttonChange = new Button();
|
buttonChange = new Button();
|
||||||
buttonCreate = new Button();
|
buttonCreate = new Button();
|
||||||
dataGridView = new DataGridView();
|
dataGridView = new DataGridView();
|
||||||
panelButtons.SuspendLayout();
|
panelButtons = new Panel();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
panelButtons.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// panelButtons
|
|
||||||
//
|
|
||||||
panelButtons.Controls.Add(buttonDel);
|
|
||||||
panelButtons.Controls.Add(buttonChange);
|
|
||||||
panelButtons.Controls.Add(buttonCreate);
|
|
||||||
panelButtons.Dock = DockStyle.Right;
|
|
||||||
panelButtons.Location = new Point(598, 0);
|
|
||||||
panelButtons.Name = "panelButtons";
|
|
||||||
panelButtons.Size = new Size(202, 450);
|
|
||||||
panelButtons.TabIndex = 0;
|
|
||||||
//
|
|
||||||
// buttonDel
|
// buttonDel
|
||||||
//
|
//
|
||||||
buttonDel.BackgroundImage = Properties.Resources.pngwing_com__7_;
|
buttonDel.BackgroundImage = Properties.Resources.pngwing_com__7_;
|
||||||
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
|
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
buttonDel.Location = new Point(77, 193);
|
buttonDel.Location = new Point(40, 255);
|
||||||
buttonDel.Name = "buttonDel";
|
buttonDel.Name = "buttonDel";
|
||||||
buttonDel.Size = new Size(61, 57);
|
buttonDel.Size = new Size(94, 91);
|
||||||
buttonDel.TabIndex = 2;
|
buttonDel.TabIndex = 2;
|
||||||
buttonDel.UseVisualStyleBackColor = true;
|
buttonDel.UseVisualStyleBackColor = true;
|
||||||
buttonDel.Click += ButtonDel_Click;
|
buttonDel.Click += ButtonDel_Click;
|
||||||
@ -63,9 +52,9 @@
|
|||||||
//
|
//
|
||||||
buttonChange.BackgroundImage = Properties.Resources.pngwing_com__8_;
|
buttonChange.BackgroundImage = Properties.Resources.pngwing_com__8_;
|
||||||
buttonChange.BackgroundImageLayout = ImageLayout.Stretch;
|
buttonChange.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
buttonChange.Location = new Point(77, 104);
|
buttonChange.Location = new Point(40, 149);
|
||||||
buttonChange.Name = "buttonChange";
|
buttonChange.Name = "buttonChange";
|
||||||
buttonChange.Size = new Size(61, 59);
|
buttonChange.Size = new Size(94, 89);
|
||||||
buttonChange.TabIndex = 1;
|
buttonChange.TabIndex = 1;
|
||||||
buttonChange.UseVisualStyleBackColor = true;
|
buttonChange.UseVisualStyleBackColor = true;
|
||||||
buttonChange.Click += ButtonChange_Click;
|
buttonChange.Click += ButtonChange_Click;
|
||||||
@ -74,48 +63,56 @@
|
|||||||
//
|
//
|
||||||
buttonCreate.BackgroundImage = Properties.Resources.pngwing_com__6_;
|
buttonCreate.BackgroundImage = Properties.Resources.pngwing_com__6_;
|
||||||
buttonCreate.BackgroundImageLayout = ImageLayout.Stretch;
|
buttonCreate.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
buttonCreate.Location = new Point(77, 12);
|
buttonCreate.Location = new Point(40, 43);
|
||||||
buttonCreate.Name = "buttonCreate";
|
buttonCreate.Name = "buttonCreate";
|
||||||
buttonCreate.Size = new Size(61, 63);
|
buttonCreate.Size = new Size(94, 88);
|
||||||
buttonCreate.TabIndex = 0;
|
buttonCreate.TabIndex = 0;
|
||||||
buttonCreate.UseVisualStyleBackColor = true;
|
buttonCreate.UseVisualStyleBackColor = true;
|
||||||
buttonCreate.Click += ButtonCreate_Click;
|
buttonCreate.Click += ButtonCreate_Click;
|
||||||
//
|
//
|
||||||
// dataGridView
|
// dataGridView
|
||||||
//
|
//
|
||||||
dataGridView.AllowUserToResizeColumns = false;
|
|
||||||
dataGridView.AllowUserToResizeRows = false;
|
|
||||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
|
||||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView.Dock = DockStyle.Fill;
|
dataGridView.Dock = DockStyle.Fill;
|
||||||
dataGridView.Location = new Point(0, 0);
|
dataGridView.Location = new Point(0, 0);
|
||||||
dataGridView.MultiSelect = false;
|
|
||||||
dataGridView.Name = "dataGridView";
|
dataGridView.Name = "dataGridView";
|
||||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
dataGridView.RowHeadersWidth = 51;
|
||||||
dataGridView.Size = new Size(598, 450);
|
dataGridView.Size = new Size(551, 403);
|
||||||
dataGridView.TabIndex = 1;
|
dataGridView.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// panelButtons
|
||||||
|
//
|
||||||
|
panelButtons.Controls.Add(buttonDel);
|
||||||
|
panelButtons.Controls.Add(buttonChange);
|
||||||
|
panelButtons.Controls.Add(buttonCreate);
|
||||||
|
panelButtons.Dock = DockStyle.Right;
|
||||||
|
panelButtons.Location = new Point(551, 0);
|
||||||
|
panelButtons.Name = "panelButtons";
|
||||||
|
panelButtons.Size = new Size(155, 403);
|
||||||
|
panelButtons.TabIndex = 2;
|
||||||
//
|
//
|
||||||
// FormMasters
|
// FormMasters
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(800, 450);
|
ClientSize = new Size(706, 403);
|
||||||
Controls.Add(dataGridView);
|
Controls.Add(dataGridView);
|
||||||
Controls.Add(panelButtons);
|
Controls.Add(panelButtons);
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
Name = "FormMasters";
|
Name = "FormMasters";
|
||||||
Text = "FormMasters";
|
Text = "Мастера";
|
||||||
Load += FormMasters_Load;
|
Load += FormMasters_Load;
|
||||||
panelButtons.ResumeLayout(false);
|
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
panelButtons.ResumeLayout(false);
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private Panel panelButtons;
|
|
||||||
private Button buttonDel;
|
private Button buttonDel;
|
||||||
private Button buttonChange;
|
private Button buttonChange;
|
||||||
private Button buttonCreate;
|
private Button buttonCreate;
|
||||||
private DataGridView dataGridView;
|
private DataGridView dataGridView;
|
||||||
|
private Panel panelButtons;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -22,9 +22,9 @@ namespace ProjectCompRepair.Forms
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_container = container ??
|
_container = container ??
|
||||||
throw new ArgumentException(nameof(masterRepository));
|
throw new ArgumentException(nameof(container));
|
||||||
_masterRepository = masterRepository
|
_masterRepository = masterRepository
|
||||||
?? throw new ArgumentException(nameof(_masterRepository));
|
?? throw new ArgumentException(nameof(masterRepository));
|
||||||
}
|
}
|
||||||
private void FormMasters_Load(object sender, EventArgs e)
|
private void FormMasters_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
259
ProjectCompRepair/ProjectCompRepair/Forms/FormOrder.Designer.cs
generated
Normal file
259
ProjectCompRepair/ProjectCompRepair/Forms/FormOrder.Designer.cs
generated
Normal file
@ -0,0 +1,259 @@
|
|||||||
|
namespace ProjectCompRepair.Forms
|
||||||
|
{
|
||||||
|
partial class FormOrder
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
labelName = new Label();
|
||||||
|
labelComent = new Label();
|
||||||
|
textBoxComent = new TextBox();
|
||||||
|
textBoxName = new TextBox();
|
||||||
|
labelDate = new Label();
|
||||||
|
dateTimePicker = new DateTimePicker();
|
||||||
|
comboBoxMaster = new ComboBox();
|
||||||
|
labelMaster = new Label();
|
||||||
|
buttonSave = new Button();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
groupBox1 = new GroupBox();
|
||||||
|
dataGridViewAccessories = new DataGridView();
|
||||||
|
ColumnAccessories = new DataGridViewComboBoxColumn();
|
||||||
|
ColumnCount = new DataGridViewTextBoxColumn();
|
||||||
|
groupBoxServices = new GroupBox();
|
||||||
|
dataGridViewServices = new DataGridView();
|
||||||
|
ColumnService = new DataGridViewComboBoxColumn();
|
||||||
|
ColumnCountServ = new DataGridViewTextBoxColumn();
|
||||||
|
groupBox1.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridViewAccessories).BeginInit();
|
||||||
|
groupBoxServices.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridViewServices).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelName
|
||||||
|
//
|
||||||
|
labelName.AutoSize = true;
|
||||||
|
labelName.Location = new Point(19, 35);
|
||||||
|
labelName.Name = "labelName";
|
||||||
|
labelName.Size = new Size(77, 20);
|
||||||
|
labelName.TabIndex = 0;
|
||||||
|
labelName.Text = "Название";
|
||||||
|
//
|
||||||
|
// labelComent
|
||||||
|
//
|
||||||
|
labelComent.AutoSize = true;
|
||||||
|
labelComent.Location = new Point(19, 109);
|
||||||
|
labelComent.Name = "labelComent";
|
||||||
|
labelComent.Size = new Size(79, 20);
|
||||||
|
labelComent.TabIndex = 1;
|
||||||
|
labelComent.Text = "Описание";
|
||||||
|
//
|
||||||
|
// textBoxComent
|
||||||
|
//
|
||||||
|
textBoxComent.Location = new Point(208, 81);
|
||||||
|
textBoxComent.Multiline = true;
|
||||||
|
textBoxComent.Name = "textBoxComent";
|
||||||
|
textBoxComent.Size = new Size(125, 72);
|
||||||
|
textBoxComent.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// textBoxName
|
||||||
|
//
|
||||||
|
textBoxName.Location = new Point(208, 28);
|
||||||
|
textBoxName.Name = "textBoxName";
|
||||||
|
textBoxName.Size = new Size(125, 27);
|
||||||
|
textBoxName.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// labelDate
|
||||||
|
//
|
||||||
|
labelDate.AutoSize = true;
|
||||||
|
labelDate.Location = new Point(19, 192);
|
||||||
|
labelDate.Name = "labelDate";
|
||||||
|
labelDate.Size = new Size(183, 20);
|
||||||
|
labelDate.TabIndex = 4;
|
||||||
|
labelDate.Text = "Дата регистрации заказа";
|
||||||
|
//
|
||||||
|
// dateTimePicker
|
||||||
|
//
|
||||||
|
dateTimePicker.Location = new Point(208, 192);
|
||||||
|
dateTimePicker.Name = "dateTimePicker";
|
||||||
|
dateTimePicker.Size = new Size(192, 27);
|
||||||
|
dateTimePicker.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// comboBoxMaster
|
||||||
|
//
|
||||||
|
comboBoxMaster.FormattingEnabled = true;
|
||||||
|
comboBoxMaster.Location = new Point(208, 254);
|
||||||
|
comboBoxMaster.Name = "comboBoxMaster";
|
||||||
|
comboBoxMaster.Size = new Size(151, 28);
|
||||||
|
comboBoxMaster.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// labelMaster
|
||||||
|
//
|
||||||
|
labelMaster.AutoSize = true;
|
||||||
|
labelMaster.Location = new Point(21, 262);
|
||||||
|
labelMaster.Name = "labelMaster";
|
||||||
|
labelMaster.Size = new Size(60, 20);
|
||||||
|
labelMaster.TabIndex = 7;
|
||||||
|
labelMaster.Text = "Мастер";
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
buttonSave.Location = new Point(35, 389);
|
||||||
|
buttonSave.Name = "buttonSave";
|
||||||
|
buttonSave.Size = new Size(94, 29);
|
||||||
|
buttonSave.TabIndex = 8;
|
||||||
|
buttonSave.Text = "Сохранить";
|
||||||
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
buttonSave.Click += ButtonSave_Click;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(1077, 389);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(94, 29);
|
||||||
|
buttonCancel.TabIndex = 9;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += ButtonCancel_Click;
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
groupBox1.Controls.Add(dataGridViewAccessories);
|
||||||
|
groupBox1.Location = new Point(449, 35);
|
||||||
|
groupBox1.Name = "groupBox1";
|
||||||
|
groupBox1.Size = new Size(309, 247);
|
||||||
|
groupBox1.TabIndex = 10;
|
||||||
|
groupBox1.TabStop = false;
|
||||||
|
groupBox1.Text = "Комплектующие";
|
||||||
|
//
|
||||||
|
// dataGridViewAccessories
|
||||||
|
//
|
||||||
|
dataGridViewAccessories.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridViewAccessories.Columns.AddRange(new DataGridViewColumn[] { ColumnAccessories, ColumnCount });
|
||||||
|
dataGridViewAccessories.Dock = DockStyle.Fill;
|
||||||
|
dataGridViewAccessories.Location = new Point(3, 23);
|
||||||
|
dataGridViewAccessories.Name = "dataGridViewAccessories";
|
||||||
|
dataGridViewAccessories.RowHeadersWidth = 51;
|
||||||
|
dataGridViewAccessories.Size = new Size(303, 221);
|
||||||
|
dataGridViewAccessories.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// ColumnAccessories
|
||||||
|
//
|
||||||
|
ColumnAccessories.HeaderText = "Экземпляр";
|
||||||
|
ColumnAccessories.MinimumWidth = 6;
|
||||||
|
ColumnAccessories.Name = "ColumnAccessories";
|
||||||
|
ColumnAccessories.Width = 125;
|
||||||
|
//
|
||||||
|
// ColumnCount
|
||||||
|
//
|
||||||
|
ColumnCount.HeaderText = "Количество";
|
||||||
|
ColumnCount.MinimumWidth = 6;
|
||||||
|
ColumnCount.Name = "ColumnCount";
|
||||||
|
ColumnCount.Width = 125;
|
||||||
|
//
|
||||||
|
// groupBoxServices
|
||||||
|
//
|
||||||
|
groupBoxServices.Controls.Add(dataGridViewServices);
|
||||||
|
groupBoxServices.Location = new Point(789, 35);
|
||||||
|
groupBoxServices.Name = "groupBoxServices";
|
||||||
|
groupBoxServices.Size = new Size(310, 247);
|
||||||
|
groupBoxServices.TabIndex = 11;
|
||||||
|
groupBoxServices.TabStop = false;
|
||||||
|
groupBoxServices.Text = "Услуги";
|
||||||
|
//
|
||||||
|
// dataGridViewServices
|
||||||
|
//
|
||||||
|
dataGridViewServices.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridViewServices.Columns.AddRange(new DataGridViewColumn[] { ColumnService, ColumnCountServ });
|
||||||
|
dataGridViewServices.Dock = DockStyle.Fill;
|
||||||
|
dataGridViewServices.Location = new Point(3, 23);
|
||||||
|
dataGridViewServices.Name = "dataGridViewServices";
|
||||||
|
dataGridViewServices.RowHeadersWidth = 51;
|
||||||
|
dataGridViewServices.Size = new Size(304, 221);
|
||||||
|
dataGridViewServices.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// ColumnService
|
||||||
|
//
|
||||||
|
ColumnService.HeaderText = "Услуга";
|
||||||
|
ColumnService.MinimumWidth = 6;
|
||||||
|
ColumnService.Name = "ColumnService";
|
||||||
|
ColumnService.Width = 125;
|
||||||
|
//
|
||||||
|
// ColumnCountServ
|
||||||
|
//
|
||||||
|
ColumnCountServ.HeaderText = "Количество";
|
||||||
|
ColumnCountServ.MinimumWidth = 6;
|
||||||
|
ColumnCountServ.Name = "ColumnCountServ";
|
||||||
|
ColumnCountServ.Width = 125;
|
||||||
|
//
|
||||||
|
// FormOrder
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(1183, 430);
|
||||||
|
Controls.Add(groupBoxServices);
|
||||||
|
Controls.Add(groupBox1);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonSave);
|
||||||
|
Controls.Add(labelMaster);
|
||||||
|
Controls.Add(comboBoxMaster);
|
||||||
|
Controls.Add(dateTimePicker);
|
||||||
|
Controls.Add(labelDate);
|
||||||
|
Controls.Add(textBoxName);
|
||||||
|
Controls.Add(textBoxComent);
|
||||||
|
Controls.Add(labelComent);
|
||||||
|
Controls.Add(labelName);
|
||||||
|
Name = "FormOrder";
|
||||||
|
Text = "Заказ";
|
||||||
|
groupBox1.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridViewAccessories).EndInit();
|
||||||
|
groupBoxServices.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridViewServices).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label labelName;
|
||||||
|
private Label labelComent;
|
||||||
|
private TextBox textBoxComent;
|
||||||
|
private TextBox textBoxName;
|
||||||
|
private Label labelDate;
|
||||||
|
private DateTimePicker dateTimePicker;
|
||||||
|
private ComboBox comboBoxMaster;
|
||||||
|
private Label labelMaster;
|
||||||
|
private Button buttonSave;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private GroupBox groupBox1;
|
||||||
|
private DataGridView dataGridViewAccessories;
|
||||||
|
private GroupBox groupBoxServices;
|
||||||
|
private DataGridView dataGridViewServices;
|
||||||
|
private DataGridViewComboBoxColumn ColumnAccessories;
|
||||||
|
private DataGridViewTextBoxColumn ColumnCount;
|
||||||
|
private DataGridViewComboBoxColumn ColumnService;
|
||||||
|
private DataGridViewTextBoxColumn ColumnCountServ;
|
||||||
|
}
|
||||||
|
}
|
119
ProjectCompRepair/ProjectCompRepair/Forms/FormOrder.cs
Normal file
119
ProjectCompRepair/ProjectCompRepair/Forms/FormOrder.cs
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
using ProjectCompRepair.Entities;
|
||||||
|
using ProjectCompRepair.Repositories;
|
||||||
|
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 ProjectCompRepair.Forms;
|
||||||
|
|
||||||
|
public partial class FormOrder : Form
|
||||||
|
{
|
||||||
|
private readonly IOrderRepository _orderRepository;
|
||||||
|
|
||||||
|
private int? _orderId;
|
||||||
|
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var order = _orderRepository.ReadOrderById(value);
|
||||||
|
if (order == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException(nameof(order));
|
||||||
|
}
|
||||||
|
|
||||||
|
textBoxName.Text = order.Name;
|
||||||
|
textBoxComent.Text = order.Coment;
|
||||||
|
dateTimePicker.Value = order.Date;
|
||||||
|
_orderId = value;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FormOrder(IOrderRepository orderRepository, IMasterRepository masterRepository, IAccessoriesRepository accessoriesRepository, IServiceRepository serviceRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_orderRepository = orderRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(orderRepository));
|
||||||
|
|
||||||
|
comboBoxMaster.DataSource = masterRepository.ReadMaster();
|
||||||
|
comboBoxMaster.ValueMember = "Id";
|
||||||
|
comboBoxMaster.DisplayMember = "Name";
|
||||||
|
|
||||||
|
ColumnAccessories.DataSource = accessoriesRepository.ReadAccessories();
|
||||||
|
ColumnAccessories.DisplayMember = "AccessoriesType";
|
||||||
|
ColumnAccessories.ValueMember = "Id";
|
||||||
|
|
||||||
|
ColumnService.DataSource = serviceRepository.ReadService();
|
||||||
|
ColumnService.DisplayMember = "ServiceType";
|
||||||
|
ColumnService.ValueMember = "Id";
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if(dataGridViewAccessories.RowCount < 1 || comboBoxMaster.SelectedIndex < 0 || dataGridViewServices.RowCount < 1)
|
||||||
|
{
|
||||||
|
throw new Exception("Имеются незаполненые поля");
|
||||||
|
}
|
||||||
|
_orderRepository.CreateOrder(Order.CreateElement(0, textBoxName.Text, textBoxComent.Text, (int)comboBoxMaster.SelectedValue!));
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||||
|
|
||||||
|
private List<AccessoiresOrder> CreateListAccessoiresOrderFromDataGrid()
|
||||||
|
{
|
||||||
|
var list = new List<AccessoiresOrder>();
|
||||||
|
foreach (DataGridViewRow row in dataGridViewAccessories.Rows)
|
||||||
|
{
|
||||||
|
if (row.Cells["ColumnAccessoires"].Value == null ||
|
||||||
|
row.Cells["ColumnCount"].Value == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
list.Add(AccessoiresOrder.CreateElement(0,
|
||||||
|
Convert.ToInt32(row.Cells["ColumnAccessoires"].Value),
|
||||||
|
Convert.ToInt32(row.Cells["ColumnCount"].Value)));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<ServicesOrder> CreateListServicesOrderFromDataGrid()
|
||||||
|
{
|
||||||
|
var list = new List<ServicesOrder>();
|
||||||
|
foreach (DataGridViewRow row in dataGridViewAccessories.Rows)
|
||||||
|
{
|
||||||
|
if (row.Cells["ColumnServices"].Value == null ||
|
||||||
|
row.Cells["ColumnCountServices"].Value == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
list.Add(ServicesOrder.CreateElement(0,
|
||||||
|
Convert.ToInt32(row.Cells["ColumnAccessoires"].Value),
|
||||||
|
Convert.ToInt32(row.Cells["ColumnCount"].Value)));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
144
ProjectCompRepair/ProjectCompRepair/Forms/FormOrder.resx
Normal file
144
ProjectCompRepair/ProjectCompRepair/Forms/FormOrder.resx
Normal file
@ -0,0 +1,144 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="ColumnAccessories.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnAccessories.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnService.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnCountServ.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnService.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnCountServ.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
117
ProjectCompRepair/ProjectCompRepair/Forms/FormOrders.Designer.cs
generated
Normal file
117
ProjectCompRepair/ProjectCompRepair/Forms/FormOrders.Designer.cs
generated
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
namespace ProjectCompRepair.Forms
|
||||||
|
{
|
||||||
|
partial class FormOrders
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
buttonDel = new Button();
|
||||||
|
buttonChange = new Button();
|
||||||
|
buttonCreate = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
panelButtons = new Panel();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
panelButtons.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
buttonDel.BackgroundImage = Properties.Resources.pngwing_com__7_;
|
||||||
|
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonDel.Location = new Point(40, 255);
|
||||||
|
buttonDel.Name = "buttonDel";
|
||||||
|
buttonDel.Size = new Size(94, 91);
|
||||||
|
buttonDel.TabIndex = 2;
|
||||||
|
buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
buttonDel.Click += ButtonDel_Click;
|
||||||
|
//
|
||||||
|
// buttonChange
|
||||||
|
//
|
||||||
|
buttonChange.BackgroundImage = Properties.Resources.pngwing_com__8_;
|
||||||
|
buttonChange.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonChange.Location = new Point(40, 149);
|
||||||
|
buttonChange.Name = "buttonChange";
|
||||||
|
buttonChange.Size = new Size(94, 89);
|
||||||
|
buttonChange.TabIndex = 1;
|
||||||
|
buttonChange.UseVisualStyleBackColor = true;
|
||||||
|
buttonChange.Click += ButtonChange_Click;
|
||||||
|
//
|
||||||
|
// buttonCreate
|
||||||
|
//
|
||||||
|
buttonCreate.BackgroundImage = Properties.Resources.pngwing_com__6_;
|
||||||
|
buttonCreate.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonCreate.Location = new Point(40, 43);
|
||||||
|
buttonCreate.Name = "buttonCreate";
|
||||||
|
buttonCreate.Size = new Size(94, 88);
|
||||||
|
buttonCreate.TabIndex = 0;
|
||||||
|
buttonCreate.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreate.Click += ButtonCreate_Click;
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Dock = DockStyle.Fill;
|
||||||
|
dataGridView.Location = new Point(0, 0);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.RowHeadersWidth = 51;
|
||||||
|
dataGridView.Size = new Size(545, 400);
|
||||||
|
dataGridView.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// panelButtons
|
||||||
|
//
|
||||||
|
panelButtons.Controls.Add(buttonDel);
|
||||||
|
panelButtons.Controls.Add(buttonChange);
|
||||||
|
panelButtons.Controls.Add(buttonCreate);
|
||||||
|
panelButtons.Dock = DockStyle.Right;
|
||||||
|
panelButtons.Location = new Point(545, 0);
|
||||||
|
panelButtons.Name = "panelButtons";
|
||||||
|
panelButtons.Size = new Size(155, 400);
|
||||||
|
panelButtons.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// FormOrders
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(700, 400);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Controls.Add(panelButtons);
|
||||||
|
Name = "FormOrders";
|
||||||
|
Text = "Заказы";
|
||||||
|
Load += FormOrder_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
panelButtons.ResumeLayout(false);
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonDel;
|
||||||
|
private Button buttonChange;
|
||||||
|
private Button buttonCreate;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private Panel panelButtons;
|
||||||
|
}
|
||||||
|
}
|
114
ProjectCompRepair/ProjectCompRepair/Forms/FormOrders.cs
Normal file
114
ProjectCompRepair/ProjectCompRepair/Forms/FormOrders.cs
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
using ProjectCompRepair.Repositories;
|
||||||
|
using ProjectCompRepair.Repositories.Implemantations;
|
||||||
|
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 Unity;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Forms;
|
||||||
|
|
||||||
|
public partial class FormOrders : Form
|
||||||
|
{
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
|
||||||
|
private readonly IOrderRepository _orderRepository;
|
||||||
|
|
||||||
|
public FormOrders(IUnityContainer container, IOrderRepository orderRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ??
|
||||||
|
throw new ArgumentException(nameof(container));
|
||||||
|
_orderRepository = orderRepository
|
||||||
|
?? throw new ArgumentException(nameof(orderRepository));
|
||||||
|
}
|
||||||
|
private void FormOrder_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormOrder>().ShowDialog();
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonChange_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!TryGetIdentifierFromSelectRow(out var findId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var form = _container.Resolve<FormOrder>();
|
||||||
|
form.Id = findId;
|
||||||
|
form.ShowDialog();
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonDel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!TryGetIdentifierFromSelectRow(out var findId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (MessageBox.Show("Удалить запись", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_orderRepository.DeleteOrder(findId);
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadList() => dataGridView.DataSource = _orderRepository.ReadOrder();
|
||||||
|
|
||||||
|
private bool TryGetIdentifierFromSelectRow(out int id)
|
||||||
|
{
|
||||||
|
id = 0;
|
||||||
|
if (dataGridView.SelectedRows.Count < 1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
120
ProjectCompRepair/ProjectCompRepair/Forms/FormOrders.resx
Normal file
120
ProjectCompRepair/ProjectCompRepair/Forms/FormOrders.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
122
ProjectCompRepair/ProjectCompRepair/Forms/FormService.Designer.cs
generated
Normal file
122
ProjectCompRepair/ProjectCompRepair/Forms/FormService.Designer.cs
generated
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
namespace ProjectCompRepair.Forms
|
||||||
|
{
|
||||||
|
partial class FormService
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
labelType = new Label();
|
||||||
|
labelPrice = new Label();
|
||||||
|
checkedListBoxType = new CheckedListBox();
|
||||||
|
numericUpDownPrice = new NumericUpDown();
|
||||||
|
buttonSave = new Button();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelType
|
||||||
|
//
|
||||||
|
labelType.AutoSize = true;
|
||||||
|
labelType.Location = new Point(38, 70);
|
||||||
|
labelType.Name = "labelType";
|
||||||
|
labelType.Size = new Size(83, 20);
|
||||||
|
labelType.TabIndex = 0;
|
||||||
|
labelType.Text = "Тип услуги";
|
||||||
|
//
|
||||||
|
// labelPrice
|
||||||
|
//
|
||||||
|
labelPrice.AutoSize = true;
|
||||||
|
labelPrice.Location = new Point(38, 217);
|
||||||
|
labelPrice.Name = "labelPrice";
|
||||||
|
labelPrice.Size = new Size(45, 20);
|
||||||
|
labelPrice.TabIndex = 1;
|
||||||
|
labelPrice.Text = "Цена";
|
||||||
|
//
|
||||||
|
// checkedListBoxType
|
||||||
|
//
|
||||||
|
checkedListBoxType.FormattingEnabled = true;
|
||||||
|
checkedListBoxType.Location = new Point(145, 49);
|
||||||
|
checkedListBoxType.Name = "checkedListBoxType";
|
||||||
|
checkedListBoxType.Size = new Size(230, 114);
|
||||||
|
checkedListBoxType.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// numericUpDownPrice
|
||||||
|
//
|
||||||
|
numericUpDownPrice.DecimalPlaces = 2;
|
||||||
|
numericUpDownPrice.Location = new Point(145, 217);
|
||||||
|
numericUpDownPrice.Maximum = new decimal(new int[] { 100000, 0, 0, 0 });
|
||||||
|
numericUpDownPrice.Name = "numericUpDownPrice";
|
||||||
|
numericUpDownPrice.Size = new Size(230, 27);
|
||||||
|
numericUpDownPrice.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
buttonSave.Location = new Point(38, 324);
|
||||||
|
buttonSave.Name = "buttonSave";
|
||||||
|
buttonSave.Size = new Size(94, 29);
|
||||||
|
buttonSave.TabIndex = 5;
|
||||||
|
buttonSave.Text = "Сохранить";
|
||||||
|
buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
buttonSave.Click += ButtonSave_Click;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(281, 324);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(94, 29);
|
||||||
|
buttonCancel.TabIndex = 6;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += ButtonCancel_Click;
|
||||||
|
//
|
||||||
|
// FormService
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(424, 393);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonSave);
|
||||||
|
Controls.Add(numericUpDownPrice);
|
||||||
|
Controls.Add(checkedListBoxType);
|
||||||
|
Controls.Add(labelPrice);
|
||||||
|
Controls.Add(labelType);
|
||||||
|
Name = "FormService";
|
||||||
|
Text = "Услуга";
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label labelType;
|
||||||
|
private Label labelPrice;
|
||||||
|
private CheckedListBox checkedListBoxType;
|
||||||
|
private NumericUpDown numericUpDownPrice;
|
||||||
|
private Button buttonSave;
|
||||||
|
private Button buttonCancel;
|
||||||
|
}
|
||||||
|
}
|
119
ProjectCompRepair/ProjectCompRepair/Forms/FormService.cs
Normal file
119
ProjectCompRepair/ProjectCompRepair/Forms/FormService.cs
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
using ProjectCompRepair.Entities;
|
||||||
|
using ProjectCompRepair.Entities.Enums;
|
||||||
|
using ProjectCompRepair.Repositories;
|
||||||
|
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 ProjectCompRepair.Forms
|
||||||
|
{
|
||||||
|
public partial class FormService : Form
|
||||||
|
{
|
||||||
|
private readonly IServiceRepository _serviceRepository;
|
||||||
|
|
||||||
|
private int? _service;
|
||||||
|
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var service = _serviceRepository.ReadServiceById(value);
|
||||||
|
if (service == null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException(nameof(service));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
foreach(ServiceType elem in Enum.GetValues(typeof(ServiceType)))
|
||||||
|
{
|
||||||
|
if((elem & service.ServiceType) != 0)
|
||||||
|
{
|
||||||
|
checkedListBoxType.SetItemChecked(checkedListBoxType.Items.IndexOf(elem), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_service = value;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FormService(IServiceRepository serviceRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_serviceRepository = serviceRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(serviceRepository));
|
||||||
|
|
||||||
|
foreach(var elem in Enum.GetValues(typeof(ServiceType)))
|
||||||
|
{
|
||||||
|
checkedListBoxType.Items.Add(elem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public FormService(IServiceRepository serviceRepository, int id) : this(serviceRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var service = _serviceRepository.ReadServiceById(id);
|
||||||
|
if (service == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(serviceRepository));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (checkedListBoxType.CheckedItems.Count == 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Имеются незаполненные поля");
|
||||||
|
}
|
||||||
|
if (_service.HasValue)
|
||||||
|
{
|
||||||
|
_serviceRepository.UpdateService(CreateService(_service.Value));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_serviceRepository.CreateService(CreateService(0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||||
|
|
||||||
|
private Service CreateService(int id)
|
||||||
|
{
|
||||||
|
ServiceType serviceType = ServiceType.None;
|
||||||
|
foreach(var elem in checkedListBoxType.CheckedItems)
|
||||||
|
{
|
||||||
|
serviceType |= (ServiceType)elem;
|
||||||
|
}
|
||||||
|
return Service.CreateEntity(id, serviceType, (double)numericUpDownPrice.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
120
ProjectCompRepair/ProjectCompRepair/Forms/FormService.resx
Normal file
120
ProjectCompRepair/ProjectCompRepair/Forms/FormService.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
118
ProjectCompRepair/ProjectCompRepair/Forms/FormServices.Designer.cs
generated
Normal file
118
ProjectCompRepair/ProjectCompRepair/Forms/FormServices.Designer.cs
generated
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
namespace ProjectCompRepair.Forms
|
||||||
|
{
|
||||||
|
partial class FormServices
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
panelButtons = new Panel();
|
||||||
|
buttonDel = new Button();
|
||||||
|
buttonChange = new Button();
|
||||||
|
buttonCreate = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
panelButtons.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// panelButtons
|
||||||
|
//
|
||||||
|
panelButtons.Controls.Add(buttonDel);
|
||||||
|
panelButtons.Controls.Add(buttonChange);
|
||||||
|
panelButtons.Controls.Add(buttonCreate);
|
||||||
|
panelButtons.Dock = DockStyle.Right;
|
||||||
|
panelButtons.Location = new Point(536, 0);
|
||||||
|
panelButtons.Name = "panelButtons";
|
||||||
|
panelButtons.Size = new Size(155, 450);
|
||||||
|
panelButtons.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
buttonDel.BackgroundImage = Properties.Resources.pngwing_com__7_;
|
||||||
|
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonDel.Location = new Point(40, 255);
|
||||||
|
buttonDel.Name = "buttonDel";
|
||||||
|
buttonDel.Size = new Size(94, 91);
|
||||||
|
buttonDel.TabIndex = 2;
|
||||||
|
buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
buttonDel.Click += ButtonDel_Click;
|
||||||
|
//
|
||||||
|
// buttonChange
|
||||||
|
//
|
||||||
|
buttonChange.BackgroundImage = Properties.Resources.pngwing_com__8_;
|
||||||
|
buttonChange.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonChange.Location = new Point(40, 149);
|
||||||
|
buttonChange.Name = "buttonChange";
|
||||||
|
buttonChange.Size = new Size(94, 89);
|
||||||
|
buttonChange.TabIndex = 1;
|
||||||
|
buttonChange.UseVisualStyleBackColor = true;
|
||||||
|
buttonChange.Click += ButtonChange_Click;
|
||||||
|
//
|
||||||
|
// buttonCreate
|
||||||
|
//
|
||||||
|
buttonCreate.BackgroundImage = Properties.Resources.pngwing_com__6_;
|
||||||
|
buttonCreate.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonCreate.Location = new Point(40, 43);
|
||||||
|
buttonCreate.Name = "buttonCreate";
|
||||||
|
buttonCreate.Size = new Size(94, 88);
|
||||||
|
buttonCreate.TabIndex = 0;
|
||||||
|
buttonCreate.UseVisualStyleBackColor = true;
|
||||||
|
buttonCreate.Click += ButtonCreate_Click;
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Dock = DockStyle.Fill;
|
||||||
|
dataGridView.Location = new Point(0, 0);
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.RowHeadersWidth = 51;
|
||||||
|
dataGridView.Size = new Size(536, 450);
|
||||||
|
dataGridView.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// FormServices
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(691, 450);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Controls.Add(panelButtons);
|
||||||
|
Name = "FormServices";
|
||||||
|
SizeGripStyle = SizeGripStyle.Hide;
|
||||||
|
Text = "Услуги";
|
||||||
|
Load += FormService_Load;
|
||||||
|
panelButtons.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Panel panelButtons;
|
||||||
|
private Button buttonDel;
|
||||||
|
private Button buttonChange;
|
||||||
|
private Button buttonCreate;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
111
ProjectCompRepair/ProjectCompRepair/Forms/FormServices.cs
Normal file
111
ProjectCompRepair/ProjectCompRepair/Forms/FormServices.cs
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
using ProjectCompRepair.Repositories;
|
||||||
|
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 Unity;
|
||||||
|
|
||||||
|
namespace ProjectCompRepair.Forms
|
||||||
|
{
|
||||||
|
public partial class FormServices : Form
|
||||||
|
{
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
|
||||||
|
private readonly IServiceRepository _serviceRepository;
|
||||||
|
|
||||||
|
public FormServices(IUnityContainer container, IServiceRepository serviceRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ??
|
||||||
|
throw new ArgumentException(nameof(container));
|
||||||
|
_serviceRepository = serviceRepository
|
||||||
|
?? throw new ArgumentException(nameof(serviceRepository));
|
||||||
|
}
|
||||||
|
private void FormService_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
private void ButtonCreate_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormService>().ShowDialog();
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonChange_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!TryGetIdentifierFromSelectRow(out var findId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var form = _container.Resolve<FormMaster>();
|
||||||
|
form.Id = findId;
|
||||||
|
form.ShowDialog();
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonDel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!TryGetIdentifierFromSelectRow(out var findId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (MessageBox.Show("Удалить запись", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_serviceRepository.DeleteService(findId);
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadList() => dataGridView.DataSource = _serviceRepository.ReadService();
|
||||||
|
|
||||||
|
private bool TryGetIdentifierFromSelectRow(out int id)
|
||||||
|
{
|
||||||
|
id = 0;
|
||||||
|
if (dataGridView.SelectedRows.Count < 1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
ProjectCompRepair/ProjectCompRepair/Forms/FormServices.resx
Normal file
120
ProjectCompRepair/ProjectCompRepair/Forms/FormServices.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
@ -16,7 +16,7 @@ namespace ProjectCompRepair
|
|||||||
// To customize application configuration such as set high DPI settings or default font,
|
// To customize application configuration such as set high DPI settings or default font,
|
||||||
// see https://aka.ms/applicationconfiguration.
|
// see https://aka.ms/applicationconfiguration.
|
||||||
ApplicationConfiguration.Initialize();
|
ApplicationConfiguration.Initialize();
|
||||||
Application.Run(new FormCompRepair());
|
Application.Run(CreateContainer().Resolve<FormCompRepair>());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IUnityContainer CreateContainer()
|
private static IUnityContainer CreateContainer()
|
||||||
@ -27,7 +27,7 @@ namespace ProjectCompRepair
|
|||||||
container.RegisterType<IMasterRepository, MasterRepository>();
|
container.RegisterType<IMasterRepository, MasterRepository>();
|
||||||
container.RegisterType<IOrderRepository, OrderRepository>();
|
container.RegisterType<IOrderRepository, OrderRepository>();
|
||||||
container.RegisterType<IServiceRepository, ServiceRepository>();
|
container.RegisterType<IServiceRepository, ServiceRepository>();
|
||||||
container.RegisterType<IWarehouseRepository, WarehouseRepository>();
|
|
||||||
|
|
||||||
return container;
|
return container;
|
||||||
}
|
}
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using ProjectCompRepair.Entities;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectCompRepair.Repositories;
|
|
||||||
|
|
||||||
public interface IWarehouseRepository
|
|
||||||
{
|
|
||||||
IEnumerable<Warehouse> ReadWarehouse();
|
|
||||||
|
|
||||||
Warehouse ReadWarehouseById(int id);
|
|
||||||
|
|
||||||
void CreateWarehouse(Warehouse warehouse);
|
|
||||||
|
|
||||||
void UpdateWarehouse(Warehouse warehouse);
|
|
||||||
|
|
||||||
void DeleteWarehouse(int id);
|
|
||||||
}
|
|
||||||
|
|
@ -26,7 +26,7 @@ public class AccessoriesRepository : IAccessoriesRepository
|
|||||||
|
|
||||||
public Accessories ReadAccessoriesById(int id)
|
public Accessories ReadAccessoriesById(int id)
|
||||||
{
|
{
|
||||||
return Accessories.CreateEntity(0, 0, 0);
|
return Accessories.CreateEntity(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateAccessories(Accessories accessories)
|
public void UpdateAccessories(Accessories accessories)
|
||||||
|
@ -26,7 +26,7 @@ public class OrderRepository : IOrderRepository
|
|||||||
|
|
||||||
public Order ReadOrderById(int id)
|
public Order ReadOrderById(int id)
|
||||||
{
|
{
|
||||||
return Order.CreateOperation(0, string.Empty, string.Empty, 0, 0, 0);
|
return Order.CreateElement(0, string.Empty, string.Empty, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateOrder(Order order)
|
public void UpdateOrder(Order order)
|
||||||
|
@ -26,7 +26,7 @@ public class ServiceRepository : IServiceRepository
|
|||||||
|
|
||||||
public Service ReadServiceById(int id)
|
public Service ReadServiceById(int id)
|
||||||
{
|
{
|
||||||
return Service.CreateOperation(0, 0, 0, 0);
|
return Service.CreateEntity(0, Entities.Enums.ServiceType.None, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateService(Service service)
|
public void UpdateService(Service service)
|
||||||
|
@ -1,36 +0,0 @@
|
|||||||
using ProjectCompRepair.Entities;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProjectCompRepair.Repositories.Implemantations;
|
|
||||||
|
|
||||||
public class WarehouseRepository : IWarehouseRepository
|
|
||||||
{
|
|
||||||
public void CreateWarehouse(Warehouse warehouse)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DeleteWarehouse(int id)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable<Warehouse> ReadWarehouse()
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
public Warehouse ReadWarehouseById(int id)
|
|
||||||
{
|
|
||||||
return Warehouse.CreateEntity(0, string.Empty, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateWarehouse(Warehouse warehouse)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user