Compare commits

...

4 Commits

Author SHA1 Message Date
nezui1
95d2100685 сдал 2024-11-25 14:49:17 +04:00
nezui1
09557899c2 вторая почти готовая 2024-11-25 11:59:33 +04:00
nezui1
ab83e06788 Готовая первая лаба 2024-11-24 18:25:32 +04:00
nezui1
26c76e03d3 надо доделать 2024-10-28 00:49:35 +04:00
57 changed files with 4309 additions and 33 deletions

View File

@ -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};
}
}

View File

@ -0,0 +1,30 @@
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 Accessories
{
public int Id { get; private set; }
public AccessoriesType AccessoriesType { get; private set; }
public int Count { get; private set; }
public float Price { get; private set; }
public static Accessories CreateEntity(int id, AccessoriesType accessoriesType, int count, float price)
{
return new Accessories
{
Id = id,
AccessoriesType = accessoriesType,
Count = count,
Price = price
};
}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectCompRepair.Entities.Enums;
public enum AccessoriesType
{
None = 0,
Processor = 1,
AccessMemory = 2,
VideoCard = 3,
Cooler = 4
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectCompRepair.Entities.Enums;
[Flags]
public enum ServiceType
{
None = 0,
Replacement = 1,
Installation = 2,
Repair = 4
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectCompRepair.Entities;
public class Master
{
public int Id { get; private set; }
public string Name { get; private set; }
public static Master CreateEntity(int id, string name)
{
return new Master
{
Id = id,
Name = name
};
}
}

View File

@ -0,0 +1,40 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectCompRepair.Entities;
public class Order
{
public int Id { get; private set; }
public string Name { get; private set; }
public string Coment { get; private set; }
public DateTime Date { get; private set; }
public int MasterID { get; private set; }
public IEnumerable<AccessoiresOrder> AccessoiresOrders { get; private set; } = [];
public IEnumerable<ServicesOrder> ServicesOrders { get; private set; } = [];
public static Order CreateElement(int id, string name,DateTime date, string coment, int masterId, IEnumerable<AccessoiresOrder> accessoiresOrders, IEnumerable<ServicesOrder> servicesOrder)
{
return new Order()
{
Id = id,
Name = name,
Coment = coment,
Date = date,
MasterID = masterId,
AccessoiresOrders = accessoiresOrders,
ServicesOrders = servicesOrder
};
}
}

View File

@ -0,0 +1,27 @@
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 Service
{
public int Id { get; private set; }
public ServiceType ServiceType { get; private set; }
public float Price { get; private set; }
public static Service CreateEntity(int id, ServiceType serviceType, float price)
{
return new Service
{
Id = id,
ServiceType = serviceType,
Price = price
};
}
}

View File

@ -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 };
}
}

View File

@ -1,6 +1,6 @@
namespace ProjectCompRepair
{
partial class Form1
partial class FormCompRepair
{
/// <summary>
/// Required designer variable.
@ -28,12 +28,104 @@
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
menuStrip = new MenuStrip();
справочникToolStripMenuItem = new ToolStripMenuItem();
AccossoriesToolStripMenuItem = new ToolStripMenuItem();
MasterToolStripMenuItem = new ToolStripMenuItem();
ServiceToolStripMenuItem = new ToolStripMenuItem();
операцииToolStripMenuItem = new ToolStripMenuItem();
OrderToolStripMenuItem = new ToolStripMenuItem();
отчетыToolStripMenuItem = new ToolStripMenuItem();
menuStrip.SuspendLayout();
SuspendLayout();
//
// menuStrip
//
menuStrip.ImageScalingSize = new Size(20, 20);
menuStrip.Items.AddRange(new ToolStripItem[] { справочникToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem });
menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip";
menuStrip.Padding = new Padding(7, 3, 0, 3);
menuStrip.Size = new Size(896, 30);
menuStrip.TabIndex = 0;
menuStrip.Text = "menuStrip1";
//
// справочникToolStripMenuItem
//
справочникToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { AccossoriesToolStripMenuItem, MasterToolStripMenuItem, ServiceToolStripMenuItem });
справочникToolStripMenuItem.Name = "справочникToolStripMenuItem";
справочникToolStripMenuItem.Size = new Size(117, 24);
справочникToolStripMenuItem.Text = "Справочники";
//
// AccossoriesToolStripMenuItem
//
AccossoriesToolStripMenuItem.Name = "AccossoriesToolStripMenuItem";
AccossoriesToolStripMenuItem.Size = new Size(224, 26);
AccossoriesToolStripMenuItem.Text = "Комплектующие";
AccossoriesToolStripMenuItem.Click += AccossoriesToolStripMenuItem_Click;
//
// MasterToolStripMenuItem
//
MasterToolStripMenuItem.Name = "MasterToolStripMenuItem";
MasterToolStripMenuItem.Size = new Size(224, 26);
MasterToolStripMenuItem.Text = "Мастер";
MasterToolStripMenuItem.Click += MasterToolStripMenuItem_Click;
//
// ServiceToolStripMenuItem
//
ServiceToolStripMenuItem.Name = "ServiceToolStripMenuItem";
ServiceToolStripMenuItem.Size = new Size(224, 26);
ServiceToolStripMenuItem.Text = "Услуга";
ServiceToolStripMenuItem.Click += ServiceToolStripMenuItem_Click;
//
// операцииToolStripMenuItem
//
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { OrderToolStripMenuItem });
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
операцииToolStripMenuItem.Size = new Size(95, 24);
операцииToolStripMenuItem.Text = "Операции";
//
// OrderToolStripMenuItem
//
OrderToolStripMenuItem.Name = "OrderToolStripMenuItem";
OrderToolStripMenuItem.Size = new Size(224, 26);
OrderToolStripMenuItem.Text = "Заказ";
OrderToolStripMenuItem.Click += OrderToolStripMenuItem_Click;
//
// отчетыToolStripMenuItem
//
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
отчетыToolStripMenuItem.Size = new Size(73, 24);
отчетыToolStripMenuItem.Text = "Отчеты";
//
// FormCompRepair
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
BackgroundImage = Properties.Resources.morskie_kamni_raznocvetnaya_galka;
BackgroundImageLayout = ImageLayout.Stretch;
ClientSize = new Size(896, 548);
Controls.Add(menuStrip);
MainMenuStrip = menuStrip;
Margin = new Padding(3, 4, 3, 4);
Name = "FormCompRepair";
StartPosition = FormStartPosition.CenterScreen;
Text = "Фирма по ремонту техники";
menuStrip.ResumeLayout(false);
menuStrip.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
private MenuStrip menuStrip;
private ToolStripMenuItem справочникToolStripMenuItem;
private ToolStripMenuItem AccossoriesToolStripMenuItem;
private ToolStripMenuItem операцииToolStripMenuItem;
private ToolStripMenuItem отчетыToolStripMenuItem;
private ToolStripMenuItem OrderToolStripMenuItem;
private ToolStripMenuItem MasterToolStripMenuItem;
private ToolStripMenuItem ServiceToolStripMenuItem;
}
}

View File

@ -1,10 +1,65 @@
using ProjectCompRepair.Forms;
using Unity;
namespace ProjectCompRepair
{
public partial class Form1 : Form
public partial class FormCompRepair : Form
{
public Form1()
private readonly IUnityContainer _container;
public FormCompRepair(IUnityContainer container)
{
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);
}
}
}
}

View File

@ -117,4 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="menuStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

View File

@ -0,0 +1,154 @@
namespace ProjectCompRepair.Forms
{
partial class FormAccessorie
{
/// <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>
#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();
labelCount = new Label();
labelPrice = new Label();
numericUpDownPrice = new NumericUpDown();
numericUpDownCount = new NumericUpDown();
buttonCreate = new Button();
buttonCancel = new Button();
comboBoxType = new ComboBox();
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownCount).BeginInit();
SuspendLayout();
//
// labelType
//
labelType.Anchor = AnchorStyles.Right;
labelType.AutoSize = true;
labelType.Location = new Point(54, 75);
labelType.Name = "labelType";
labelType.Size = new Size(158, 20);
labelType.TabIndex = 0;
labelType.Text = "Вид комплектующего";
//
// labelCount
//
labelCount.Anchor = AnchorStyles.Right;
labelCount.AutoSize = true;
labelCount.Location = new Point(54, 152);
labelCount.Name = "labelCount";
labelCount.Size = new Size(98, 20);
labelCount.TabIndex = 2;
labelCount.Text = "Колличество";
//
// labelPrice
//
labelPrice.Anchor = AnchorStyles.Right;
labelPrice.AutoSize = true;
labelPrice.Location = new Point(54, 231);
labelPrice.Name = "labelPrice";
labelPrice.Size = new Size(45, 20);
labelPrice.TabIndex = 4;
labelPrice.Text = "Цена";
//
// numericUpDownPrice
//
numericUpDownPrice.Anchor = AnchorStyles.Right;
numericUpDownPrice.DecimalPlaces = 2;
numericUpDownPrice.Location = new Point(252, 235);
numericUpDownPrice.Margin = new Padding(3, 4, 3, 4);
numericUpDownPrice.Name = "numericUpDownPrice";
numericUpDownPrice.Size = new Size(119, 27);
numericUpDownPrice.TabIndex = 5;
//
// numericUpDownCount
//
numericUpDownCount.Anchor = AnchorStyles.Right;
numericUpDownCount.Location = new Point(252, 156);
numericUpDownCount.Margin = new Padding(3, 4, 3, 4);
numericUpDownCount.Name = "numericUpDownCount";
numericUpDownCount.Size = new Size(119, 27);
numericUpDownCount.TabIndex = 6;
//
// buttonCreate
//
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.Size = new Size(98, 33);
buttonCreate.TabIndex = 8;
buttonCreate.Text = "Сохранить";
buttonCreate.UseVisualStyleBackColor = true;
buttonCreate.Click += ButtonSave_Click;
//
// buttonCancel
//
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Location = new Point(310, 416);
buttonCancel.Margin = new Padding(3, 4, 3, 4);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(101, 31);
buttonCancel.TabIndex = 10;
buttonCancel.Text = "Отмена";
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
//
AllowDrop = true;
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
AutoSizeMode = AutoSizeMode.GrowAndShrink;
AutoValidate = AutoValidate.EnableAllowFocusChange;
ClientSize = new Size(448, 478);
Controls.Add(comboBoxType);
Controls.Add(buttonCancel);
Controls.Add(buttonCreate);
Controls.Add(numericUpDownCount);
Controls.Add(numericUpDownPrice);
Controls.Add(labelPrice);
Controls.Add(labelCount);
Controls.Add(labelType);
Margin = new Padding(3, 4, 3, 4);
Name = "FormAccessorie";
Text = "Комплектующое";
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownCount).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelType;
private Label labelCount;
private Label labelPrice;
private NumericUpDown numericUpDownPrice;
private NumericUpDown numericUpDownCount;
private Button buttonCreate;
private Button buttonUpdate;
private Button buttonCancel;
private ComboBox comboBoxType;
}
}

View File

@ -0,0 +1,86 @@
using ProjectCompRepair.Entities;
using ProjectCompRepair.Entities.Enums;
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;
namespace ProjectCompRepair.Forms
{
public partial class FormAccessorie : Form
{
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();
_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);
}
Close();
}
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
private Accessories CreateAccessories(int id) => Accessories.CreateEntity(id, (AccessoriesType)comboBoxType.SelectedItem! , (int)numericUpDownCount.Value, (float)numericUpDownPrice.Value);
}
}

View 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>

View 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;
}
}

View 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;
}
}
}

View 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>

View File

@ -0,0 +1,104 @@
namespace ProjectCompRepair.Forms
{
partial class FormMaster
{
/// <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();
textBoxName = new TextBox();
buttonSave = new Button();
buttonCancel = new Button();
SuspendLayout();
//
// labelName
//
labelName.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
labelName.AutoSize = true;
labelName.Location = new Point(87, 73);
labelName.Name = "labelName";
labelName.Size = new Size(39, 20);
labelName.TabIndex = 0;
labelName.Text = "Имя";
//
// textBoxName
//
textBoxName.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
textBoxName.Location = new Point(160, 73);
textBoxName.Margin = new Padding(3, 4, 3, 4);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(114, 27);
textBoxName.TabIndex = 1;
//
// buttonSave
//
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonSave.Location = new Point(31, 273);
buttonSave.Margin = new Padding(3, 4, 3, 4);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(97, 31);
buttonSave.TabIndex = 2;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// buttonCancel
//
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Location = new Point(208, 275);
buttonCancel.Margin = new Padding(3, 4, 3, 4);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(86, 31);
buttonCancel.TabIndex = 3;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// FormMaster
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(331, 337);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(textBoxName);
Controls.Add(labelName);
Margin = new Padding(3, 4, 3, 4);
Name = "FormMaster";
StartPosition = FormStartPosition.CenterScreen;
Text = "Мастер";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelName;
private TextBox textBoxName;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,79 @@
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 FormMaster : Form
{
private readonly IMasterRepository _masterRepository;
private int? _masterId;
public int Id
{
set
{
try
{
var master = _masterRepository.ReadMasterById(value);
if (master == null)
{
throw new InvalidOperationException(nameof(master));
}
textBoxName.Text = master.Name;
_masterId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormMaster(IMasterRepository masterRepository)
{
InitializeComponent();
_masterRepository = masterRepository ??
throw new ArgumentNullException(nameof(masterRepository));
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(textBoxName.Text))
{
throw new Exception("Имеются незаполненные поля");
}
if (_masterId.HasValue)
{
_masterRepository.UpdateMaster(CreateMaster(_masterId.Value));
}
else
{
_masterRepository.CreateMaster(CreateMaster(0));
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Close();
}
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
private Master CreateMaster(int id) => Master.CreateEntity(id, textBoxName.Text);
}

View 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>

View File

@ -0,0 +1,118 @@
namespace ProjectCompRepair.Forms
{
partial class FormMasters
{
/// <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(551, 403);
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
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(706, 403);
Controls.Add(dataGridView);
Controls.Add(panelButtons);
Margin = new Padding(3, 4, 3, 4);
Name = "FormMasters";
Text = "Мастера";
Load += FormMasters_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;
}
}

View 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 FormMasters : Form
{
private readonly IUnityContainer _container;
private readonly IMasterRepository _masterRepository;
public FormMasters(IUnityContainer container, IMasterRepository masterRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentException(nameof(container));
_masterRepository = masterRepository
?? throw new ArgumentException(nameof(masterRepository));
}
private void FormMasters_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<FormMaster>().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
{
_masterRepository.DeleteMaster(findId);
LoadList();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView.DataSource = _masterRepository.ReadMaster();
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;
}
}
}

View 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>

View 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;
}
}

View 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,dateTimePicker.Value, textBoxComent.Text, (int)comboBoxMaster.SelectedValue!, CreateListAccessoiresOrderFromDataGrid(), CreateListServicesOrderFromDataGrid()));
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Close();
}
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["ColumnAccessories"].Value == null ||
row.Cells["ColumnCount"].Value == null)
{
continue;
}
list.Add(AccessoiresOrder.CreateElement(0,
Convert.ToInt32(row.Cells["ColumnAccessories"].Value),
Convert.ToInt32(row.Cells["ColumnCount"].Value)));
}
return list;
}
private List<ServicesOrder> CreateListServicesOrderFromDataGrid()
{
var list = new List<ServicesOrder>();
foreach (DataGridViewRow row in dataGridViewServices.Rows)
{
if (row.Cells["ColumnService"].Value == null ||
row.Cells["ColumnCountServ"].Value == null)
{
continue;
}
list.Add(ServicesOrder.CreateElement(0,
Convert.ToInt32(row.Cells["ColumnService"].Value),
Convert.ToInt32(row.Cells["ColumnCountServ"].Value)));
}
return list;
}
}

View File

@ -0,0 +1,132 @@
<?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="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>

View File

@ -0,0 +1,103 @@
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();
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, 173);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(94, 91);
buttonDel.TabIndex = 2;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += ButtonDel_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(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 buttonCreate;
private DataGridView dataGridView;
private Panel panelButtons;
}
}

View 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;
}
}

View 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>

View 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;
}
}

View File

@ -0,0 +1,120 @@
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;
numericUpDownPrice.Value = (int)service.Price;
}
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);
}
Close();
}
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, (float)numericUpDownPrice.Value);
}
}
}

View 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>

View 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;
}
}

View 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<FormService>();
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;
}
}
}

View 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>

View File

@ -1,3 +1,15 @@
using Microsoft.Extensions.Logging;
using ProjectCompRepair.Repositories;
using ProjectCompRepair.Repositories.Implemantations;
using Serilog;
using System;
using Unity;
using Microsoft.Extensions.Configuration;
using Unity.Microsoft.Logging;
using Unity.Lifetime;
namespace ProjectCompRepair
{
internal static class Program
@ -11,7 +23,36 @@ namespace ProjectCompRepair
// To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize();
Application.Run(new Form1());
}
Application.Run(CreateContainer().Resolve<FormCompRepair>());
}
private static IUnityContainer CreateContainer()
{
var container = new UnityContainer();
container.AddExtension(new LoggingExtension(CreateLoggerFactory()));
container.RegisterType<IAccessoriesRepository, AccessoriesRepository>(new TransientLifetimeManager());
container.RegisterType<IMasterRepository, MasterRepository>(new TransientLifetimeManager());
container.RegisterType<IOrderRepository, OrderRepository>(new TransientLifetimeManager());
container.RegisterType<IServiceRepository, ServiceRepository>(new TransientLifetimeManager());
container.RegisterType<IConnectionString, ConnectionString >(new TransientLifetimeManager());
return container;
}
private static LoggerFactory CreateLoggerFactory()
{
var loggerFactory = new LoggerFactory();
loggerFactory.AddSerilog(new LoggerConfiguration()
.ReadFrom.Configuration(new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json")
.Build())
.CreateLogger());
return loggerFactory;
}
}
}

View File

@ -8,4 +8,35 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Dapper" Version="2.1.35" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="9.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Npgsql" Version="9.0.1" />
<PackageReference Include="Serilog" Version="4.1.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.9.0" />
<PackageReference Include="Unity" Version="5.11.10" />
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project>

View File

@ -0,0 +1,103 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ProjectCompRepair.Properties {
using System;
/// <summary>
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
/// </summary>
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
// с помощью такого средства, как ResGen или Visual Studio.
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
// с параметром /str или перестройте свой проект VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProjectCompRepair.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap morskie_kamni_raznocvetnaya_galka {
get {
object obj = ResourceManager.GetObject("morskie-kamni-raznocvetnaya-galka", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap pngwing_com__6_ {
get {
object obj = ResourceManager.GetObject("pngwing.com (6)", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap pngwing_com__7_ {
get {
object obj = ResourceManager.GetObject("pngwing.com (7)", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap pngwing_com__8_ {
get {
object obj = ResourceManager.GetObject("pngwing.com (8)", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -0,0 +1,133 @@
<?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>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="morskie-kamni-raznocvetnaya-galka" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\morskie-kamni-raznocvetnaya-galka.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="pngwing.com (8)" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\pngwing.com (8).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="pngwing.com (7)" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\pngwing.com (7).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="pngwing.com (6)" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\pngwing.com (6).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@ -0,0 +1,19 @@
using ProjectCompRepair.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectCompRepair.Repositories;
public interface IAccessoriesOrder
{
void CreateAccessoriesOrder(AccessoiresOrder accessoriesOrder);
void DeleteAccessoriesOrder(int id);
IEnumerable<AccessoiresOrder> ReadAccessoiresOrder(int? Id = 0, int? orderId = 0, int? count = 0);
}

View File

@ -0,0 +1,21 @@
using System;
using ProjectCompRepair.Entities;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectCompRepair.Repositories;
public interface IAccessoriesRepository
{
IEnumerable<Accessories> ReadAccessories();
Accessories ReadAccessoriesById(int id);
void CreateAccessories(Accessories accessories);
void UpdateAccessories(Accessories accessories);
void DeleteAccessories(int id);
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectCompRepair.Repositories;
public interface IConnectionString
{
public string ConnectionString {get;}
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using ProjectCompRepair.Entities;
using System.Text;
using System.Threading.Tasks;
namespace ProjectCompRepair.Repositories;
public interface IMasterRepository
{
IEnumerable<Master> ReadMaster();
Master ReadMasterById(int id);
void CreateMaster(Master Master);
void UpdateMaster(Master master);
void DeleteMaster(int id);
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using ProjectCompRepair.Entities;
using System.Text;
using System.Threading.Tasks;
namespace ProjectCompRepair.Repositories;
public interface IOrderRepository
{
IEnumerable<Order> ReadOrder();
Order ReadOrderById(int id);
void CreateOrder(Order order);
void DeleteOrder(int id);
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using ProjectCompRepair.Entities;
using System.Text;
using System.Threading.Tasks;
namespace ProjectCompRepair.Repositories;
public interface IServiceRepository
{
IEnumerable<Service> ReadService();
Service ReadServiceById(int id);
void CreateService(Service service);
void UpdateService(Service service);
void DeleteService(int id);
}

View File

@ -0,0 +1,142 @@
using System;
using ProjectCompRepair.Entities;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System.Data.SqlClient;
using Dapper;
using Npgsql;
using System.Xml.Linq;
namespace ProjectCompRepair.Repositories.Implemantations;
public class AccessoriesRepository : IAccessoriesRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<AccessoriesRepository> _logger;
public AccessoriesRepository(IConnectionString connectionString, ILogger<AccessoriesRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateAccessories(Accessories accessories)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект : {json}", JsonConvert.SerializeObject(accessories));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var queryInsert = @"
INSERT INTO Accessories (AccessoriesType, Count, Price)
VALUES (@AccessoriesType, @Count, @Price)";
connection.Execute(queryInsert, accessories);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void UpdateAccessories(Accessories accessories)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект : {json}", JsonConvert.SerializeObject(accessories));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var queryUpdate = @"UPDATE Accessories
SET
AccessoriesType = @AccessoriesType,
Count = @Count,
Price = @Price
WHERE ID = @Id;";
connection.Execute(queryUpdate, accessories);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
public void DeleteAccessories(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект : {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var queryDelete = @"
DELETE FROM Accessories
WHERE ID = @id
"
;
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public Accessories ReadAccessoriesById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект : {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var querySelect = @"
SELECT * FROM Accessories
WHERE ID = @id
";
var accessories = connection.QueryFirst<Accessories>(querySelect, new { id });
_logger.LogDebug("Найденный объект {json}", JsonConvert.SerializeObject(accessories));
return accessories;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public IEnumerable<Accessories> ReadAccessories()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var querySelect = @"SELECT * FROM Accessories";
var accessories = connection.Query<Accessories>(querySelect);
_logger.LogDebug("Полученные объекты : {json}", JsonConvert.SerializeObject(accessories));
return accessories;
}
catch(Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectCompRepair.Repositories.Implemantations;
public class ConnectionString : IConnectionString
{
string IConnectionString.ConnectionString => "host=localhost;port=5432;username=postgres;password=123;Database=otp;";
}

View File

@ -0,0 +1,136 @@
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
using ProjectCompRepair.Entities;
using System;
using System.Collections.Generic;
using System.Diagnostics.Metrics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProjectCompRepair.Repositories.Implemantations;
public class MasterRepository : IMasterRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<AccessoriesRepository> _logger;
public MasterRepository(IConnectionString connectionString, ILogger<AccessoriesRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateMaster(Master master)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект : {json}", JsonConvert.SerializeObject(master));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var queryInsert = @"
INSERT INTO Master (Name)
VALUES (@Name)";
connection.Execute(queryInsert, master);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void DeleteMaster(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект : {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var queryDelete = @"
DELETE FROM Master
WHERE ID = @id
"
;
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public IEnumerable<Master> ReadMaster()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var querySelect = @"SELECT * FROM Master";
var master = connection.Query<Master>(querySelect);
_logger.LogDebug("Полученные объекты : {json}", JsonConvert.SerializeObject(master));
return master;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
public Master ReadMasterById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект : {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var querySelect = @"
SELECT * FROM Master
WHERE ID = @id
";
var master = connection.QueryFirst<Master>(querySelect, new { id });
_logger.LogDebug("Найденный объект {json}", JsonConvert.SerializeObject(master));
return master;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public void UpdateMaster(Master master)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект : {json}", JsonConvert.SerializeObject(master));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var queryUpdate = @"UPDATE Master
SET
Name = @Name
WHERE ID = @Id;";
connection.Execute(queryUpdate, master);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
}

View File

@ -0,0 +1,148 @@
 using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
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 OrderRepository : IOrderRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<AccessoriesRepository> _logger;
public OrderRepository(IConnectionString connectionString, ILogger<AccessoriesRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateOrder(Order order)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект : {json}", JsonConvert.SerializeObject(order));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
using var transaction = connection.BeginTransaction();
var queryInsert = @"
INSERT INTO Orderl (Name, Coment, Date, MasterId)
VALUES (@Name, @Coment, @Date, @MasterId);
SELECT MAX(ID) FROM Orderl";
var orderId = connection.QueryFirst<int>(queryInsert, order, transaction);
var querySubInsertAccessories = @"
INSERT INTO AccessoriesOrder (OrderId, Count)
VALUES (@OrderId, @Count)";
foreach (var elem in order.AccessoiresOrders)
{
connection.Execute(querySubInsertAccessories, new
{
OrderId = orderId,
elem.Count
}, transaction);
}
var querySubInsertServices = @"
INSERT INTO ServicesOrder (OrderId, Count)
VALUES (@OrderId, @Count)";
foreach (var elem in order.ServicesOrders)
{
connection.Execute(querySubInsertServices, new
{
OrderId = orderId,
elem.Count
}, transaction);
}
transaction.Commit();
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void DeleteOrder(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект : {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var queryDelete = @"
DELETE FROM Orderl
WHERE ID = @id
"
;
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public Order ReadOrderById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект : {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var querySelect = @"
SELECT * FROM Orderl
WHERE ID = @id
";
var order = connection.QueryFirst<Order>(querySelect, new { id });
_logger.LogDebug("Найденный объект {json}", JsonConvert.SerializeObject(order));
return order;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public IEnumerable<Order> ReadOrder()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var querySelect = @"SELECT * FROM Orderl";
var order = connection.Query<Order>(querySelect);
_logger.LogDebug("Полученные объекты : {json}", JsonConvert.SerializeObject(order));
return order;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
}

View File

@ -0,0 +1,136 @@
using Dapper;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Npgsql;
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 ServiceRepository : IServiceRepository
{
private readonly IConnectionString _connectionString;
private readonly ILogger<AccessoriesRepository> _logger;
public ServiceRepository(IConnectionString connectionString, ILogger<AccessoriesRepository> logger)
{
_connectionString = connectionString;
_logger = logger;
}
public void CreateService(Service service)
{
_logger.LogInformation("Добавление объекта");
_logger.LogDebug("Объект : {json}", JsonConvert.SerializeObject(service));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var queryInsert = @"
INSERT INTO Service (ServiceType, Price)
VALUES (@ServiceType, @Price)";
connection.Execute(queryInsert, service);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при добавлении объекта");
throw;
}
}
public void UpdateService(Service service)
{
_logger.LogInformation("Редактирование объекта");
_logger.LogDebug("Объект : {json}", JsonConvert.SerializeObject(service));
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var queryUpdate = @"UPDATE Service
SET
ServiceType = @ServiceType,
Price = @Price
WHERE ID = @Id;";
connection.Execute(queryUpdate, service);
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при редактировании объекта");
throw;
}
}
public void DeleteService(int id)
{
_logger.LogInformation("Удаление объекта");
_logger.LogDebug("Объект : {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var queryDelete = @"
DELETE FROM Service
WHERE ID = @id
"
;
connection.Execute(queryDelete, new { id });
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при удалении объекта");
throw;
}
}
public Service ReadServiceById(int id)
{
_logger.LogInformation("Получение объекта по идентификатору");
_logger.LogDebug("Объект : {id}", id);
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var querySelect = @"
SELECT * FROM Service
WHERE ID = @id
";
var service = connection.QueryFirst<Service>(querySelect, new { id });
_logger.LogDebug("Найденный объект {json}", JsonConvert.SerializeObject(service));
return service;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при поиске объекта");
throw;
}
}
public IEnumerable<Service> ReadService()
{
_logger.LogInformation("Получение всех объектов");
try
{
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
connection.Open();
var querySelect = @"SELECT * FROM Service";
var service = connection.Query<Service>(querySelect);
_logger.LogDebug("Полученные объекты : {json}", JsonConvert.SerializeObject(service));
return service;
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка при чтении объектов");
throw;
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 770 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.3 KiB