Лабораторная работа №1

This commit is contained in:
ENDORFIT 2024-12-18 23:52:39 +04:00
parent 5369f396bf
commit 37900bdff3
63 changed files with 4699 additions and 75 deletions

View File

@ -8,4 +8,23 @@
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Unity" Version="5.11.10" />
</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 ProjectOptika.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("ProjectOptika.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 Add {
get {
object obj = ResourceManager.GetObject("Add", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap optika {
get {
object obj = ResourceManager.GetObject("optika", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Remove {
get {
object obj = ResourceManager.GetObject("Remove", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap Update {
get {
object obj = ResourceManager.GetObject("Update", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -0,0 +1,136 @@
<?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="Add" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Add.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Remove" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Remove.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="optika" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\optika.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Update" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\Update.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="optika" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\optika1.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 156 KiB

View File

@ -0,0 +1,38 @@
using ProjectOptika.Scripts.Entities.Enums;
namespace ProjectOptika.Scripts.Entities
{
public class Accessories
{
public int ID { get; private set; }
public string Name { get; private set; }
public string Brand { get; private set; }
public int Cost { get; private set; }
public int StockAvailability { get; private set; }
public int AvailabilityStore { get; private set; }
public DateTime DeliveryDate { get; private set; }
public CategoryType CategoryName { get; private set; }
public static Accessories CreateEntity(int id, string name, string brand, int cost, int stockAvailability, int availabilityStore, DateTime deliveryDate, CategoryType categoryName)
{
return new Accessories
{
ID = id,
Name = name,
Brand = brand,
Cost = cost,
StockAvailability = stockAvailability,
AvailabilityStore = availabilityStore,
DeliveryDate = deliveryDate,
CategoryName = categoryName
};
}
}
}

View File

@ -0,0 +1,21 @@
namespace ProjectOptika.Scripts.Entities
{
public class AccessoriesOrder
{
public int ID { get; private set; }
public int AccesoryId { get; private set; }
public int Count { get; private set; }
public static AccessoriesOrder CreateElement(int id, int accesoryId, int count)
{
return new AccessoriesOrder
{
ID = id,
AccesoryId = accesoryId,
Count = count
};
}
}
}

View File

@ -0,0 +1,32 @@
using ProjectOptika.Scripts.Entities.Enums;
namespace ProjectOptika.Scripts.Entities
{
public class Client
{
public int ID { get; private set; }
public ClientType ClientType { get; private set; }
public string FirstName { get; private set; }
public string SecondName { get; private set; }
public string Surname { get; private set; }
public string PhoneNumber { get; private set; }
public static Client CreateEntity(int id, ClientType clientType, string firstName, string secondName, string surname, string phoneNumber)
{
return new Client
{
ID = id,
ClientType = clientType,
FirstName = firstName,
SecondName = secondName,
Surname = surname,
PhoneNumber = phoneNumber
};
}
}
}

View File

@ -0,0 +1,28 @@
using ProjectOptika.Scripts.Entities.Enums;
namespace ProjectOptika.Scripts.Entities
{
public class Employee
{
public int ID { get; private set; }
public PositionEmployee PositionEmployee { get; private set; }
public string FirstName { get; private set; }
public string SecondName { get; private set; }
public string Surname { get; private set; }
public static Employee CreateEntity(int id, PositionEmployee positionEmployee, string firstName, string secondName, string surname) {
return new Employee
{
ID = id,
PositionEmployee = positionEmployee,
FirstName = firstName,
SecondName = secondName,
Surname = surname
};
}
}
}

View File

@ -0,0 +1,13 @@
namespace ProjectOptika.Scripts.Entities.Enums
{
public enum CategoryType
{
None = 0,
Lenses = 1,
Glasses = 2,
Accessories = 3
}
}

View File

@ -0,0 +1,9 @@
namespace ProjectOptika.Scripts.Entities.Enums
{
public enum ClientType
{
Regular,
VIP,
Corporate
}
}

View File

@ -0,0 +1,13 @@
namespace ProjectOptika.Scripts.Entities.Enums
{
[System.Flags]
public enum PositionEmployee
{
None = 0,
SeniorSalesman = 1,
Salesman = 2,
SellerCashier = 4,
Administrator = 8,
Accountant = 16
}
}

View File

@ -0,0 +1,29 @@
namespace ProjectOptika.Scripts.Entities
{
public class Order
{
public int ID { get; private set; }
public int EmployeeID { get; private set; }
public int ClientID { get; private set; }
public DateTime OrderDate { get; private set; }
public double TotalCost { get; private set; }
public IEnumerable<AccessoriesOrder> AccesoriesOrders { get; private set; } = [];
public static Order CreateOperation(int id, int employeeID, int clientID, double totalCost, IEnumerable<AccessoriesOrder> accesoriesOrders)
{
return new Order {
ID = id,
EmployeeID = employeeID,
ClientID = clientID,
OrderDate = DateTime.Now,
TotalCost = totalCost,
AccesoriesOrders = accesoriesOrders
};
}
}
}

View File

@ -0,0 +1,33 @@
namespace ProjectOptika.Scripts.Entities
{
public class Specifications
{
public int ID { get; private set; }
public int AccessoriesID { get; private set; }
public string Material { get; private set; }
public string Astigmatism { get; private set; }
public string Dioptericity { get; private set; }
public string OriginCountry { get; private set; }
public double TimeProduction { get; private set; }
public static Specifications CreateEntity(int id, int accessoriesID, string material, string astigmatism, string dioptericity, string originCountry, double timeProduction)
{
return new Specifications
{
ID = id,
AccessoriesID = accessoriesID,
Material = material,
Astigmatism = astigmatism,
Dioptericity = dioptericity,
OriginCountry = originCountry,
TimeProduction = timeProduction
};
}
}
}

View File

@ -1,39 +0,0 @@
namespace ProjectOptika
{
partial class Form1
{
/// <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()
{
this.components = new System.ComponentModel.Container();
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Text = "Form1";
}
#endregion
}
}

View File

@ -1,10 +0,0 @@
namespace ProjectOptika
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,127 @@
namespace ProjectOptika.Scripts.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()
{
buttonRemove = new Button();
buttonUpdate = new Button();
buttonAdd = new Button();
dataGridView = new DataGridView();
panel = new Panel();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
panel.SuspendLayout();
SuspendLayout();
//
// buttonRemove
//
buttonRemove.BackgroundImage = Properties.Resources.Remove;
buttonRemove.BackgroundImageLayout = ImageLayout.Stretch;
buttonRemove.Location = new Point(3, 166);
buttonRemove.Name = "buttonRemove";
buttonRemove.Size = new Size(96, 71);
buttonRemove.TabIndex = 2;
buttonRemove.UseVisualStyleBackColor = true;
buttonRemove.Click += ButtonRemove_Click;
//
// buttonUpdate
//
buttonUpdate.BackgroundImage = Properties.Resources.Update;
buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpdate.Location = new Point(3, 89);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(96, 71);
buttonUpdate.TabIndex = 1;
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Add;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(3, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(96, 71);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(0, 0);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(670, 390);
dataGridView.TabIndex = 5;
//
// panel
//
panel.Controls.Add(buttonRemove);
panel.Controls.Add(buttonUpdate);
panel.Controls.Add(buttonAdd);
panel.Dock = DockStyle.Right;
panel.Location = new Point(670, 0);
panel.Name = "panel";
panel.Size = new Size(104, 390);
panel.TabIndex = 4;
//
// FormAccessories
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(774, 390);
Controls.Add(dataGridView);
Controls.Add(panel);
Name = "FormAccessories";
StartPosition = FormStartPosition.CenterParent;
Text = "Аксессуары";
Load += Form_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
panel.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private Button buttonRemove;
private Button buttonUpdate;
private Button buttonAdd;
private DataGridView dataGridView;
private Panel panel;
}
}

View File

@ -0,0 +1,97 @@
using ProjectOptika.Scripts.Repositories;
using Unity;
namespace ProjectOptika.Scripts.Forms
{
public partial class FormAccessories : Form
{
private readonly IUnityContainer _container;
private readonly IAccessoriesRepository _accessoriesRepositories;
public FormAccessories(IUnityContainer container, IAccessoriesRepository accessoriesRepositories)
{
InitializeComponent();
_container = container ??
throw new ArgumentException(nameof(container));
_accessoriesRepositories = accessoriesRepositories ??
throw new ArgumentException(nameof(accessoriesRepositories));
}
private void Form_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormAccessory>().ShowDialog();
LoadList();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRows(out var findID)) return;
try
{
var form = _container.Resolve<FormAccessory>();
form.ID = findID;
form.ShowDialog();
LoadList();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonRemove_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRows(out var findID)) return;
if (MessageBox.Show("Удалить запись?", "Удалить", MessageBoxButtons.YesNo) != DialogResult.Yes) return;
try
{
_accessoriesRepositories.DeleteAccessories(findID);
LoadList();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView.DataSource = _accessoriesRepositories.GetAccessories();
private bool TryGetIdentifierFromSelectedRows(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

@ -1,17 +1,17 @@
<?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
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>
@ -26,36 +26,36 @@
<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
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
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
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
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
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
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
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->

View File

@ -0,0 +1,236 @@
namespace ProjectOptika.Scripts.Forms
{
partial class FormAccessory
{
/// <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();
labelBrand = new Label();
labelCost = new Label();
labelStockAvailability = new Label();
labelAvailabilityStore = new Label();
labelDeliveryDate = new Label();
buttonCancel = new Button();
buttonSave = new Button();
textBoxName = new TextBox();
textBoxBrand = new TextBox();
dateTimePickerDeliveryDate = new DateTimePicker();
numericUpDownAvailabilityStore = new NumericUpDown();
numericUpDownStockAvailability = new NumericUpDown();
numericUpDownCost = new NumericUpDown();
labelCategory = new Label();
comboBoxCategoryName = new ComboBox();
((System.ComponentModel.ISupportInitialize)numericUpDownAvailabilityStore).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownStockAvailability).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownCost).BeginInit();
SuspendLayout();
//
// labelName
//
labelName.AutoSize = true;
labelName.Location = new Point(27, 26);
labelName.Name = "labelName";
labelName.Size = new Size(77, 20);
labelName.TabIndex = 0;
labelName.Text = "Название";
//
// labelBrand
//
labelBrand.AutoSize = true;
labelBrand.Location = new Point(27, 83);
labelBrand.Name = "labelBrand";
labelBrand.Size = new Size(52, 20);
labelBrand.TabIndex = 1;
labelBrand.Text = "Бренд";
//
// labelCost
//
labelCost.AutoSize = true;
labelCost.Location = new Point(21, 137);
labelCost.Name = "labelCost";
labelCost.Size = new Size(83, 20);
labelCost.TabIndex = 2;
labelCost.Text = "Стоимость";
//
// labelStockAvailability
//
labelStockAvailability.AutoSize = true;
labelStockAvailability.Location = new Point(289, 26);
labelStockAvailability.Name = "labelStockAvailability";
labelStockAvailability.Size = new Size(152, 20);
labelStockAvailability.TabIndex = 3;
labelStockAvailability.Text = "Наличие в магазине";
//
// labelAvailabilityStore
//
labelAvailabilityStore.AutoSize = true;
labelAvailabilityStore.Location = new Point(289, 83);
labelAvailabilityStore.Name = "labelAvailabilityStore";
labelAvailabilityStore.Size = new Size(141, 20);
labelAvailabilityStore.TabIndex = 4;
labelAvailabilityStore.Text = "Наличие на складе";
//
// labelDeliveryDate
//
labelDeliveryDate.AutoSize = true;
labelDeliveryDate.Location = new Point(289, 137);
labelDeliveryDate.Name = "labelDeliveryDate";
labelDeliveryDate.Size = new Size(107, 20);
labelDeliveryDate.TabIndex = 5;
labelDeliveryDate.Text = "Дата доставки";
//
// buttonCancel
//
buttonCancel.Location = new Point(145, 261);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 7;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(20, 261);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 6;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// textBoxName
//
textBoxName.Location = new Point(110, 23);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(156, 27);
textBoxName.TabIndex = 8;
//
// textBoxBrand
//
textBoxBrand.Location = new Point(110, 80);
textBoxBrand.Name = "textBoxBrand";
textBoxBrand.Size = new Size(156, 27);
textBoxBrand.TabIndex = 9;
//
// dateTimePickerDeliveryDate
//
dateTimePickerDeliveryDate.Location = new Point(447, 130);
dateTimePickerDeliveryDate.Name = "dateTimePickerDeliveryDate";
dateTimePickerDeliveryDate.Size = new Size(171, 27);
dateTimePickerDeliveryDate.TabIndex = 10;
//
// numericUpDownAvailabilityStore
//
numericUpDownAvailabilityStore.Location = new Point(447, 80);
numericUpDownAvailabilityStore.Name = "numericUpDownAvailabilityStore";
numericUpDownAvailabilityStore.Size = new Size(171, 27);
numericUpDownAvailabilityStore.TabIndex = 11;
//
// numericUpDownStockAvailability
//
numericUpDownStockAvailability.Location = new Point(447, 19);
numericUpDownStockAvailability.Name = "numericUpDownStockAvailability";
numericUpDownStockAvailability.Size = new Size(171, 27);
numericUpDownStockAvailability.TabIndex = 12;
//
// numericUpDownCost
//
numericUpDownCost.Location = new Point(110, 135);
numericUpDownCost.Name = "numericUpDownCost";
numericUpDownCost.Size = new Size(156, 27);
numericUpDownCost.TabIndex = 13;
//
// labelCategory
//
labelCategory.AutoSize = true;
labelCategory.Location = new Point(27, 191);
labelCategory.Name = "labelCategory";
labelCategory.Size = new Size(35, 20);
labelCategory.TabIndex = 14;
labelCategory.Text = "Тип";
//
// comboBoxCategoryName
//
comboBoxCategoryName.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxCategoryName.FormattingEnabled = true;
comboBoxCategoryName.Location = new Point(110, 191);
comboBoxCategoryName.Name = "comboBoxCategoryName";
comboBoxCategoryName.Size = new Size(151, 28);
comboBoxCategoryName.TabIndex = 15;
//
// FormAccessory
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(670, 302);
Controls.Add(comboBoxCategoryName);
Controls.Add(labelCategory);
Controls.Add(numericUpDownCost);
Controls.Add(numericUpDownStockAvailability);
Controls.Add(numericUpDownAvailabilityStore);
Controls.Add(dateTimePickerDeliveryDate);
Controls.Add(textBoxBrand);
Controls.Add(textBoxName);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(labelDeliveryDate);
Controls.Add(labelAvailabilityStore);
Controls.Add(labelStockAvailability);
Controls.Add(labelCost);
Controls.Add(labelBrand);
Controls.Add(labelName);
Name = "FormAccessory";
StartPosition = FormStartPosition.CenterParent;
Text = "Аксессуар";
((System.ComponentModel.ISupportInitialize)numericUpDownAvailabilityStore).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownStockAvailability).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownCost).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelName;
private Label labelBrand;
private Label labelCost;
private Label labelStockAvailability;
private Label labelAvailabilityStore;
private Label labelDeliveryDate;
private Button buttonCancel;
private Button buttonSave;
private TextBox textBoxName;
private TextBox textBoxBrand;
private DateTimePicker dateTimePickerDeliveryDate;
private NumericUpDown numericUpDownAvailabilityStore;
private NumericUpDown numericUpDownStockAvailability;
private NumericUpDown numericUpDownCost;
private Label labelCategory;
private ComboBox comboBoxCategoryName;
}
}

View File

@ -0,0 +1,86 @@
using ProjectOptika.Scripts.Entities;
using ProjectOptika.Scripts.Entities.Enums;
using ProjectOptika.Scripts.Repositories;
namespace ProjectOptika.Scripts.Forms
{
public partial class FormAccessory : Form
{
private readonly IAccessoriesRepository _accessoriesRepositories;
private int? _accessoriesID;
public int ID
{
set
{
try
{
var accessory = _accessoriesRepositories.GetAccessoriesByID(value);
if (accessory == null) throw new InvalidDataException(nameof(accessory));
_accessoriesID = accessory.ID;
textBoxBrand.Text = accessory.Brand;
textBoxName.Text = accessory.Name;
numericUpDownCost.Value = accessory.Cost;
numericUpDownAvailabilityStore.Value = accessory.AvailabilityStore;
numericUpDownStockAvailability.Value = accessory.StockAvailability;
dateTimePickerDeliveryDate.Value = accessory.DeliveryDate;
comboBoxCategoryName.SelectedIndex = (int)accessory.CategoryName;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormAccessory(IAccessoriesRepository accessoriesRepositories)
{
InitializeComponent();
_accessoriesRepositories = accessoriesRepositories
?? throw new ArgumentNullException(nameof(accessoriesRepositories));
comboBoxCategoryName.DataSource = Enum.GetValues(typeof(CategoryType));
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (comboBoxCategoryName.SelectedIndex < 1 || string.IsNullOrEmpty(textBoxName.Text) || string.IsNullOrEmpty(textBoxBrand.Text))
{
throw new Exception("Имеются незаполненные данные");
}
if (_accessoriesID.HasValue)
{
_accessoriesRepositories.UpdateAccessories(CreateAccessories(_accessoriesID.Value));
}
else
{
_accessoriesRepositories.CreateAccessories(CreateAccessories(0));
}
Close();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
Close();
}
private Accessories CreateAccessories(int id)
{
return Accessories.CreateEntity(id, textBoxName.Text, textBoxBrand.Text, (int)numericUpDownCost.Value, (int)numericUpDownStockAvailability.Value, (int)numericUpDownAvailabilityStore.Value, dateTimePickerDeliveryDate.Value, (CategoryType)comboBoxCategoryName.SelectedIndex);
}
}
}

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,186 @@
namespace ProjectOptika.Scripts.Forms
{
partial class FormClient
{
/// <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()
{
buttonCancel = new Button();
buttonSave = new Button();
textBoxSurname = new TextBox();
labelSurname = new Label();
textBoxSecondName = new TextBox();
labelSecondName = new Label();
textBoxFirstName = new TextBox();
labelFirstName = new Label();
labelPhoneNumber = new Label();
textBoxPhoneNumber = new TextBox();
labelClientType = new Label();
comboBoxClientType = new ComboBox();
SuspendLayout();
//
// buttonCancel
//
buttonCancel.Location = new Point(426, 114);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 23;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(314, 114);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 22;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// textBoxSurname
//
textBoxSurname.Location = new Point(108, 111);
textBoxSurname.Name = "textBoxSurname";
textBoxSurname.Size = new Size(125, 27);
textBoxSurname.TabIndex = 21;
//
// labelSurname
//
labelSurname.AutoSize = true;
labelSurname.Location = new Point(11, 114);
labelSurname.Name = "labelSurname";
labelSurname.Size = new Size(74, 20);
labelSurname.TabIndex = 20;
labelSurname.Text = "Фимилия";
//
// textBoxSecondName
//
textBoxSecondName.Location = new Point(108, 60);
textBoxSecondName.Name = "textBoxSecondName";
textBoxSecondName.Size = new Size(125, 27);
textBoxSecondName.TabIndex = 19;
//
// labelSecondName
//
labelSecondName.AutoSize = true;
labelSecondName.Location = new Point(11, 63);
labelSecondName.Name = "labelSecondName";
labelSecondName.Size = new Size(72, 20);
labelSecondName.TabIndex = 18;
labelSecondName.Text = "Отчество";
//
// textBoxFirstName
//
textBoxFirstName.Location = new Point(108, 12);
textBoxFirstName.Name = "textBoxFirstName";
textBoxFirstName.Size = new Size(125, 27);
textBoxFirstName.TabIndex = 17;
//
// labelFirstName
//
labelFirstName.AutoSize = true;
labelFirstName.Location = new Point(11, 15);
labelFirstName.Name = "labelFirstName";
labelFirstName.Size = new Size(39, 20);
labelFirstName.TabIndex = 16;
labelFirstName.Text = "Имя";
//
// labelPhoneNumber
//
labelPhoneNumber.AutoSize = true;
labelPhoneNumber.Location = new Point(249, 15);
labelPhoneNumber.Name = "labelPhoneNumber";
labelPhoneNumber.Size = new Size(127, 20);
labelPhoneNumber.TabIndex = 24;
labelPhoneNumber.Text = "Номер телефона";
//
// textBoxPhoneNumber
//
textBoxPhoneNumber.Location = new Point(399, 12);
textBoxPhoneNumber.Name = "textBoxPhoneNumber";
textBoxPhoneNumber.Size = new Size(183, 27);
textBoxPhoneNumber.TabIndex = 25;
//
// labelClientType
//
labelClientType.AutoSize = true;
labelClientType.Location = new Point(249, 70);
labelClientType.Name = "labelClientType";
labelClientType.Size = new Size(94, 20);
labelClientType.TabIndex = 26;
labelClientType.Text = "Тип клиента";
//
// comboBoxClientType
//
comboBoxClientType.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxClientType.FormattingEnabled = true;
comboBoxClientType.Location = new Point(399, 67);
comboBoxClientType.Name = "comboBoxClientType";
comboBoxClientType.Size = new Size(183, 28);
comboBoxClientType.TabIndex = 27;
//
// FormClient
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(594, 152);
Controls.Add(comboBoxClientType);
Controls.Add(labelClientType);
Controls.Add(textBoxPhoneNumber);
Controls.Add(labelPhoneNumber);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(textBoxSurname);
Controls.Add(labelSurname);
Controls.Add(textBoxSecondName);
Controls.Add(labelSecondName);
Controls.Add(textBoxFirstName);
Controls.Add(labelFirstName);
Name = "FormClient";
StartPosition = FormStartPosition.CenterParent;
Text = "Клиент";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonCancel;
private Button buttonSave;
private TextBox textBoxSurname;
private Label labelSurname;
private TextBox textBoxSecondName;
private Label labelSecondName;
private TextBox textBoxFirstName;
private Label labelFirstName;
private Label labelPhoneNumber;
private TextBox textBoxPhoneNumber;
private Label labelClientType;
private ComboBox comboBoxClientType;
}
}

View File

@ -0,0 +1,84 @@
using ProjectOptika.Scripts.Entities;
using ProjectOptika.Scripts.Entities.Enums;
using ProjectOptika.Scripts.Repositories;
namespace ProjectOptika.Scripts.Forms
{
public partial class FormClient : Form
{
private readonly IClientRepositiory _clientRepositories;
private int? _clientID;
public int ID
{
set
{
try
{
var client = _clientRepositories.GetClientById(value);
if (client == null) throw new InvalidDataException(nameof(client));
_clientID = client.ID;
textBoxFirstName.Text = client.FirstName;
textBoxSecondName.Text = client.SecondName;
textBoxSurname.Text = client.Surname;
textBoxPhoneNumber.Text = client.PhoneNumber;
comboBoxClientType.SelectedIndex = (int)client.ClientType;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormClient(IClientRepositiory clientRepositories)
{
InitializeComponent();
_clientRepositories = clientRepositories ??
throw new ArgumentNullException(nameof(clientRepositories));
comboBoxClientType.DataSource = Enum.GetValues(typeof(ClientType));
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(textBoxSecondName.Text) || string.IsNullOrEmpty(textBoxSurname.Text) || string.IsNullOrEmpty(textBoxFirstName.Text))
{
throw new Exception("Имеются незаполненные данные");
}
if (_clientID.HasValue)
{
_clientRepositories.UpdateClient(CreateClient(_clientID.Value));
}
else
{
_clientRepositories.CreateClient(CreateClient(0));
}
Close();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
Close();
}
private Client CreateClient(int id)
{
return Client.CreateEntity(id, (ClientType)comboBoxClientType.SelectedIndex, textBoxFirstName.Text, textBoxSecondName.Text, textBoxSurname.Text, textBoxPhoneNumber.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,127 @@
namespace ProjectOptika.Scripts.Forms
{
partial class FormClients
{
/// <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()
{
buttonRemove = new Button();
buttonUpdate = new Button();
buttonAdd = new Button();
panel = new Panel();
dataGridView = new DataGridView();
panel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// buttonRemove
//
buttonRemove.BackgroundImage = Properties.Resources.Remove;
buttonRemove.BackgroundImageLayout = ImageLayout.Stretch;
buttonRemove.Location = new Point(3, 166);
buttonRemove.Name = "buttonRemove";
buttonRemove.Size = new Size(96, 71);
buttonRemove.TabIndex = 2;
buttonRemove.UseVisualStyleBackColor = true;
buttonRemove.Click += ButtonRemove_Click;
//
// buttonUpdate
//
buttonUpdate.BackgroundImage = Properties.Resources.Update;
buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpdate.Location = new Point(3, 89);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(96, 71);
buttonUpdate.TabIndex = 1;
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Add;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(3, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(96, 71);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// panel
//
panel.Controls.Add(buttonRemove);
panel.Controls.Add(buttonUpdate);
panel.Controls.Add(buttonAdd);
panel.Dock = DockStyle.Right;
panel.Location = new Point(696, 0);
panel.Name = "panel";
panel.Size = new Size(104, 450);
panel.TabIndex = 8;
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(0, 0);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(800, 450);
dataGridView.TabIndex = 9;
//
// FormClients
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(panel);
Controls.Add(dataGridView);
Name = "FormClients";
StartPosition = FormStartPosition.CenterParent;
Text = "Клиенты";
Load += Form_Load;
panel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Button buttonRemove;
private Button buttonUpdate;
private Button buttonAdd;
private Panel panel;
private DataGridView dataGridView;
}
}

View File

@ -0,0 +1,97 @@
using ProjectOptika.Scripts.Repositories;
using Unity;
namespace ProjectOptika.Scripts.Forms
{
public partial class FormClients : Form
{
private readonly IUnityContainer _container;
private readonly IClientRepositiory _clientRepositories;
public FormClients(IUnityContainer container, IClientRepositiory clientRepositories)
{
InitializeComponent();
_container = container ??
throw new ArgumentException(nameof(container));
_clientRepositories = clientRepositories ??
throw new ArgumentException(nameof(clientRepositories));
}
private void Form_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormClient>().ShowDialog();
LoadList();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRows(out var findID)) return;
try
{
var form = _container.Resolve<FormClient>();
form.ID = findID;
form.ShowDialog();
LoadList();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonRemove_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRows(out var findID)) return;
if (MessageBox.Show("Удалить запись?", "Удалить", MessageBoxButtons.YesNo) != DialogResult.Yes) return;
try
{
_clientRepositories.DeleteClient(findID);
LoadList();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView.DataSource = _clientRepositories.GetClients();
private bool TryGetIdentifierFromSelectedRows(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,163 @@
namespace ProjectOptika.Scripts.Forms
{
partial class FormEmployee
{
/// <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()
{
checkedListBoxPositionEmployee = new CheckedListBox();
labelFirstName = new Label();
textBoxFirstName = new TextBox();
textBoxSecondName = new TextBox();
labelSecondName = new Label();
textBoxSurname = new TextBox();
labelSurname = new Label();
labelPositionEmployee = new Label();
buttonCancel = new Button();
buttonSave = new Button();
SuspendLayout();
//
// checkedListBoxPositionEmployee
//
checkedListBoxPositionEmployee.FormattingEnabled = true;
checkedListBoxPositionEmployee.Location = new Point(298, 45);
checkedListBoxPositionEmployee.Name = "checkedListBoxPositionEmployee";
checkedListBoxPositionEmployee.Size = new Size(225, 180);
checkedListBoxPositionEmployee.TabIndex = 0;
//
// labelFirstName
//
labelFirstName.AutoSize = true;
labelFirstName.Location = new Point(12, 9);
labelFirstName.Name = "labelFirstName";
labelFirstName.Size = new Size(39, 20);
labelFirstName.TabIndex = 1;
labelFirstName.Text = "Имя";
//
// textBoxFirstName
//
textBoxFirstName.Location = new Point(109, 6);
textBoxFirstName.Name = "textBoxFirstName";
textBoxFirstName.Size = new Size(125, 27);
textBoxFirstName.TabIndex = 2;
//
// textBoxSecondName
//
textBoxSecondName.Location = new Point(109, 54);
textBoxSecondName.Name = "textBoxSecondName";
textBoxSecondName.Size = new Size(125, 27);
textBoxSecondName.TabIndex = 4;
//
// labelSecondName
//
labelSecondName.AutoSize = true;
labelSecondName.Location = new Point(12, 57);
labelSecondName.Name = "labelSecondName";
labelSecondName.Size = new Size(72, 20);
labelSecondName.TabIndex = 3;
labelSecondName.Text = "Отчество";
//
// textBoxSurname
//
textBoxSurname.Location = new Point(109, 105);
textBoxSurname.Name = "textBoxSurname";
textBoxSurname.Size = new Size(125, 27);
textBoxSurname.TabIndex = 6;
//
// labelSurname
//
labelSurname.AutoSize = true;
labelSurname.Location = new Point(12, 108);
labelSurname.Name = "labelSurname";
labelSurname.Size = new Size(74, 20);
labelSurname.TabIndex = 5;
labelSurname.Text = "Фимилия";
//
// labelPositionEmployee
//
labelPositionEmployee.AutoSize = true;
labelPositionEmployee.Location = new Point(298, 13);
labelPositionEmployee.Name = "labelPositionEmployee";
labelPositionEmployee.Size = new Size(86, 20);
labelPositionEmployee.TabIndex = 7;
labelPositionEmployee.Text = "Должность";
//
// buttonCancel
//
buttonCancel.Location = new Point(151, 196);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 15;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(12, 196);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 14;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// FormEmployee
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(537, 255);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(labelPositionEmployee);
Controls.Add(textBoxSurname);
Controls.Add(labelSurname);
Controls.Add(textBoxSecondName);
Controls.Add(labelSecondName);
Controls.Add(textBoxFirstName);
Controls.Add(labelFirstName);
Controls.Add(checkedListBoxPositionEmployee);
Name = "FormEmployee";
StartPosition = FormStartPosition.CenterParent;
Text = "Сотрудник";
ResumeLayout(false);
PerformLayout();
}
#endregion
private CheckedListBox checkedListBoxPositionEmployee;
private Label labelFirstName;
private TextBox textBoxFirstName;
private TextBox textBoxSecondName;
private Label labelSecondName;
private TextBox textBoxSurname;
private Label labelSurname;
private Label labelPositionEmployee;
private Button buttonCancel;
private Button buttonSave;
}
}

View File

@ -0,0 +1,99 @@
using ProjectOptika.Scripts.Entities.Enums;
using ProjectOptika.Scripts.Entities;
using ProjectOptika.Scripts.Repositories;
namespace ProjectOptika.Scripts.Forms
{
public partial class FormEmployee : Form
{
private readonly IEmployeeRepository _employeeRepositories;
private int? _employeeID;
public int ID
{
set
{
try
{
var employee = _employeeRepositories.GetEmployeerByID(value);
if (employee == null) throw new InvalidDataException(nameof(employee));
_employeeID = employee.ID;
textBoxFirstName.Text = employee.FirstName;
textBoxSecondName.Text = employee.SecondName;
textBoxSurname.Text = employee.Surname;
foreach(PositionEmployee element in Enum.GetValues(typeof(PositionEmployee)))
{
if ((element & employee.PositionEmployee) != 0)
{
checkedListBoxPositionEmployee.SetItemChecked(checkedListBoxPositionEmployee.Items.IndexOf(element), true);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormEmployee(IEmployeeRepository employeeRepositories)
{
InitializeComponent();
_employeeRepositories = employeeRepositories ??
throw new ArgumentNullException(nameof(employeeRepositories));
foreach (var i in Enum.GetValues(typeof(PositionEmployee)))
{
checkedListBoxPositionEmployee.Items.Add(i);
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(textBoxSecondName.Text) || string.IsNullOrEmpty(textBoxSurname.Text) || string.IsNullOrEmpty(textBoxFirstName.Text))
{
throw new Exception("Имеются незаполненные данные");
}
if (_employeeID.HasValue)
{
_employeeRepositories.UpdateEmployee(CreateEmployee(_employeeID.Value));
}
else
{
_employeeRepositories.CreateEmployee(CreateEmployee(0));
}
Close();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
Close();
}
private Employee CreateEmployee(int id)
{
PositionEmployee positionEmployee = PositionEmployee.None;
foreach(var element in checkedListBoxPositionEmployee.CheckedItems)
{
positionEmployee |= (PositionEmployee)element;
}
return Employee.CreateEntity(id, positionEmployee, textBoxFirstName.Text, textBoxSecondName.Text, textBoxSurname.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,127 @@
namespace ProjectOptika.Scripts.Forms
{
partial class FormEmplyees
{
/// <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()
{
panel = new Panel();
buttonRemove = new Button();
buttonUpdate = new Button();
buttonAdd = new Button();
dataGridView = new DataGridView();
panel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// panel
//
panel.Controls.Add(buttonRemove);
panel.Controls.Add(buttonUpdate);
panel.Controls.Add(buttonAdd);
panel.Dock = DockStyle.Right;
panel.Location = new Point(696, 0);
panel.Name = "panel";
panel.Size = new Size(104, 450);
panel.TabIndex = 6;
//
// buttonRemove
//
buttonRemove.BackgroundImage = Properties.Resources.Remove;
buttonRemove.BackgroundImageLayout = ImageLayout.Stretch;
buttonRemove.Location = new Point(3, 166);
buttonRemove.Name = "buttonRemove";
buttonRemove.Size = new Size(96, 71);
buttonRemove.TabIndex = 2;
buttonRemove.UseVisualStyleBackColor = true;
buttonRemove.Click += ButtonRemove_Click;
//
// buttonUpdate
//
buttonUpdate.BackgroundImage = Properties.Resources.Update;
buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpdate.Location = new Point(3, 89);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(96, 71);
buttonUpdate.TabIndex = 1;
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Add;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(3, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(96, 71);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(0, 0);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(800, 450);
dataGridView.TabIndex = 7;
//
// FormEmplyees
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(panel);
Controls.Add(dataGridView);
Name = "FormEmplyees";
StartPosition = FormStartPosition.CenterParent;
Text = "Сотрудники";
Load += Form_Load;
panel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel;
private Button buttonRemove;
private Button buttonUpdate;
private Button buttonAdd;
private DataGridView dataGridView;
}
}

View File

@ -0,0 +1,97 @@
using ProjectOptika.Scripts.Repositories;
using Unity;
namespace ProjectOptika.Scripts.Forms
{
public partial class FormEmplyees : Form
{
private readonly IUnityContainer _container;
private readonly IEmployeeRepository _employeeRepositories;
public FormEmplyees(IUnityContainer container, IEmployeeRepository employeeRepositories)
{
InitializeComponent();
_container = container ??
throw new ArgumentException(nameof(container));
_employeeRepositories = employeeRepositories ??
throw new ArgumentException(nameof(employeeRepositories));
}
private void Form_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormEmployee>().ShowDialog();
LoadList();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRows(out var findID)) return;
try
{
var form = _container.Resolve<FormEmployee>();
form.ID = findID;
form.ShowDialog();
LoadList();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonRemove_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRows(out var findID)) return;
if (MessageBox.Show("Удалить запись?", "Удалить", MessageBoxButtons.YesNo) != DialogResult.Yes) return;
try
{
_employeeRepositories.DeleteEmployee(findID);
LoadList();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView.DataSource = _employeeRepositories.GetEmployees();
private bool TryGetIdentifierFromSelectedRows(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,217 @@
namespace ProjectOptika.Scripts.Forms
{
partial class FormItemOrder
{
/// <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()
{
buttonCancel = new Button();
buttonSave = new Button();
groupBoxAccessories = new GroupBox();
dataGridViewAccessories = new DataGridView();
ColumnAccessory = new DataGridViewComboBoxColumn();
ColumnCount = new DataGridViewTextBoxColumn();
labelEmployee = new Label();
labelClient = new Label();
labelDate = new Label();
labelTotalCost = new Label();
comboBoxEmployee = new ComboBox();
comboBoxClient = new ComboBox();
dateTimePickerData = new DateTimePicker();
numericUpDownNumTotalCost = new NumericUpDown();
groupBoxAccessories.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewAccessories).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDownNumTotalCost).BeginInit();
SuspendLayout();
//
// buttonCancel
//
buttonCancel.Location = new Point(215, 445);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(122, 41);
buttonCancel.TabIndex = 8;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(12, 445);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(122, 41);
buttonSave.TabIndex = 7;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// groupBoxAccessories
//
groupBoxAccessories.Controls.Add(dataGridViewAccessories);
groupBoxAccessories.Location = new Point(464, 12);
groupBoxAccessories.Name = "groupBoxAccessories";
groupBoxAccessories.Size = new Size(307, 445);
groupBoxAccessories.TabIndex = 13;
groupBoxAccessories.TabStop = false;
groupBoxAccessories.Text = "Аксессуары:";
//
// dataGridViewAccessories
//
dataGridViewAccessories.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewAccessories.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewAccessories.Columns.AddRange(new DataGridViewColumn[] { ColumnAccessory, ColumnCount });
dataGridViewAccessories.Location = new Point(6, 26);
dataGridViewAccessories.Name = "dataGridViewAccessories";
dataGridViewAccessories.RowHeadersVisible = false;
dataGridViewAccessories.RowHeadersWidth = 51;
dataGridViewAccessories.Size = new Size(295, 413);
dataGridViewAccessories.TabIndex = 0;
//
// ColumnAccessory
//
ColumnAccessory.HeaderText = "Аксессуары";
ColumnAccessory.MinimumWidth = 6;
ColumnAccessory.Name = "ColumnAccessory";
//
// ColumnCount
//
ColumnCount.HeaderText = "Количество";
ColumnCount.MinimumWidth = 6;
ColumnCount.Name = "ColumnCount";
//
// labelEmployee
//
labelEmployee.AutoSize = true;
labelEmployee.Location = new Point(12, 24);
labelEmployee.Name = "labelEmployee";
labelEmployee.Size = new Size(82, 20);
labelEmployee.TabIndex = 14;
labelEmployee.Text = "Сотрудник";
//
// labelClient
//
labelClient.AutoSize = true;
labelClient.Location = new Point(12, 104);
labelClient.Name = "labelClient";
labelClient.Size = new Size(58, 20);
labelClient.TabIndex = 15;
labelClient.Text = "Клиент";
//
// labelDate
//
labelDate.AutoSize = true;
labelDate.Location = new Point(12, 192);
labelDate.Name = "labelDate";
labelDate.Size = new Size(41, 20);
labelDate.TabIndex = 16;
labelDate.Text = "Дата";
//
// labelTotalCost
//
labelTotalCost.AutoSize = true;
labelTotalCost.Location = new Point(12, 274);
labelTotalCost.Name = "labelTotalCost";
labelTotalCost.Size = new Size(133, 20);
labelTotalCost.TabIndex = 17;
labelTotalCost.Text = "Общая стоимость";
//
// comboBoxEmployee
//
comboBoxEmployee.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxEmployee.FormattingEnabled = true;
comboBoxEmployee.Location = new Point(194, 21);
comboBoxEmployee.Name = "comboBoxEmployee";
comboBoxEmployee.Size = new Size(238, 28);
comboBoxEmployee.TabIndex = 18;
//
// comboBoxClient
//
comboBoxClient.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxClient.FormattingEnabled = true;
comboBoxClient.Location = new Point(194, 101);
comboBoxClient.Name = "comboBoxClient";
comboBoxClient.Size = new Size(238, 28);
comboBoxClient.TabIndex = 19;
//
// dateTimePickerData
//
dateTimePickerData.Enabled = false;
dateTimePickerData.Location = new Point(194, 187);
dateTimePickerData.Name = "dateTimePickerData";
dateTimePickerData.Size = new Size(238, 27);
dateTimePickerData.TabIndex = 20;
//
// numericUpDownNumTotalCost
//
numericUpDownNumTotalCost.Location = new Point(194, 272);
numericUpDownNumTotalCost.Name = "numericUpDownNumTotalCost";
numericUpDownNumTotalCost.Size = new Size(238, 27);
numericUpDownNumTotalCost.TabIndex = 21;
numericUpDownNumTotalCost.Value = new decimal(new int[] { 1, 0, 0, 0 });
//
// FormItemOrder
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 498);
Controls.Add(numericUpDownNumTotalCost);
Controls.Add(dateTimePickerData);
Controls.Add(comboBoxClient);
Controls.Add(comboBoxEmployee);
Controls.Add(labelTotalCost);
Controls.Add(labelDate);
Controls.Add(labelClient);
Controls.Add(labelEmployee);
Controls.Add(groupBoxAccessories);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Name = "FormItemOrder";
StartPosition = FormStartPosition.CenterParent;
Text = "Заказ";
groupBoxAccessories.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewAccessories).EndInit();
((System.ComponentModel.ISupportInitialize)numericUpDownNumTotalCost).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonCancel;
private Button buttonSave;
private GroupBox groupBoxAccessories;
private DataGridView dataGridViewAccessories;
private DataGridViewComboBoxColumn ColumnAccessory;
private DataGridViewTextBoxColumn ColumnCount;
private Label labelEmployee;
private Label labelClient;
private Label labelDate;
private Label labelTotalCost;
private ComboBox comboBoxEmployee;
private ComboBox comboBoxClient;
private DateTimePicker dateTimePickerData;
private NumericUpDown numericUpDownNumTotalCost;
}
}

View File

@ -0,0 +1,77 @@

using ProjectOptika.Scripts.Entities;
using ProjectOptika.Scripts.Repositories;
using ProjectOptika.Scripts.Repositories.Implementations;
namespace ProjectOptika.Scripts.Forms
{
public partial class FormItemOrder : Form
{
private readonly IOrderRepository _orderRepository;
public FormItemOrder(IOrderRepository orderRepository, IEmployeeRepository employeeRepository, IClientRepositiory clientRepositiory, IAccessoriesRepository accessoriesRepository)
{
InitializeComponent();
_orderRepository = orderRepository ??
throw new ArgumentNullException(nameof(orderRepository));
comboBoxEmployee.DataSource = employeeRepository.GetEmployees();
comboBoxEmployee.DisplayMember = "Surname";
comboBoxEmployee.ValueMember = "ID";
comboBoxClient.DataSource = clientRepositiory.GetClients();
comboBoxClient.DisplayMember = "Surname";
comboBoxClient.ValueMember = "ID";
ColumnAccessory.DataSource = accessoriesRepository.GetAccessories();
ColumnAccessory.DisplayMember = "Name";
ColumnAccessory.ValueMember = "ID";
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (comboBoxClient.SelectedIndex < 0 ||
comboBoxEmployee.SelectedIndex < 0 ||
dataGridViewAccessories.RowCount < 1)
{
throw new Exception("Имеются незаполненные поля");
}
_orderRepository.CreateOrder(Order.CreateOperation(0,
(int)comboBoxEmployee.SelectedValue!,
(int)comboBoxClient.SelectedValue!,
(double)numericUpDownNumTotalCost.Value,
CreateListAccessoriesOrderReceptionsFromDataGrid()));
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private List<AccessoriesOrder> CreateListAccessoriesOrderReceptionsFromDataGrid()
{
var list = new List<AccessoriesOrder>();
foreach (DataGridViewRow row in dataGridViewAccessories.Rows)
{
if (row.Cells["ColumnAccessory"].Value == null ||
row.Cells["ColumnCount"].Value == null)
{
continue;
}
list.Add(AccessoriesOrder.CreateElement(0,
Convert.ToInt32(row.Cells["ColumnAccessory"].Value),
Convert.ToInt32(row.Cells["ColumnCount"].Value)));
}
return list;
}
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
}
}

View File

@ -0,0 +1,126 @@
<?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="ColumnAccessory.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>
</root>

View File

@ -0,0 +1,113 @@
namespace ProjectOptika.Scripts.Forms
{
partial class FormItemOrders
{
/// <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()
{
panel = new Panel();
buttonRemove = new Button();
buttonAdd = new Button();
dataGridView = new DataGridView();
panel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// panel
//
panel.Controls.Add(buttonRemove);
panel.Controls.Add(buttonAdd);
panel.Dock = DockStyle.Right;
panel.Location = new Point(696, 0);
panel.Name = "panel";
panel.Size = new Size(104, 450);
panel.TabIndex = 8;
//
// buttonRemove
//
buttonRemove.BackgroundImage = Properties.Resources.Remove;
buttonRemove.BackgroundImageLayout = ImageLayout.Stretch;
buttonRemove.Location = new Point(3, 89);
buttonRemove.Name = "buttonRemove";
buttonRemove.Size = new Size(96, 71);
buttonRemove.TabIndex = 2;
buttonRemove.UseVisualStyleBackColor = true;
buttonRemove.Click += ButtonDel_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Add;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(3, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(96, 71);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(0, 0);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(800, 450);
dataGridView.TabIndex = 9;
//
// FormItemOrders
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(panel);
Controls.Add(dataGridView);
Name = "FormItemOrders";
StartPosition = FormStartPosition.CenterParent;
Text = "Заказы";
Load += Form_Load;
panel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel;
private Button buttonRemove;
private Button buttonAdd;
private DataGridView dataGridView;
}
}

View File

@ -0,0 +1,88 @@
using ProjectOptika.Scripts.Repositories;
using Unity;
namespace ProjectOptika.Scripts.Forms
{
public partial class FormItemOrders : Form
{
private readonly IUnityContainer _container;
private readonly IOrderRepository _orderRepository;
public FormItemOrders(IUnityContainer container, IOrderRepository orderRepository)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_orderRepository = orderRepository ??
throw new ArgumentNullException(nameof(orderRepository));
}
private void Form_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView.DataSource =
_orderRepository.GetOrders();
private bool TryGetIdentifierFromSelectedRow(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;
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormItemOrder>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(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);
}
}
}
}

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,138 @@
namespace ProjectOptika
{
partial class FormOptika
{
/// <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()
{
menuStrip = new MenuStrip();
справочникиToolStripMenuItem = new ToolStripMenuItem();
аксессуарыToolStripMenuItem = new ToolStripMenuItem();
характеристикиToolStripMenuItem = new ToolStripMenuItem();
сотрудникToolStripMenuItem = new ToolStripMenuItem();
клиентToolStripMenuItem = new ToolStripMenuItem();
операцииToolStripMenuItem = new ToolStripMenuItem();
заказToolStripMenuItem = 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.Size = new Size(800, 28);
menuStrip.TabIndex = 0;
menuStrip.Text = "menuStrip1";
//
// справочникиToolStripMenuItem
//
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { аксессуарыToolStripMenuItem, характеристикиToolStripMenuItem, сотрудникToolStripMenuItem, клиентToolStripMenuItem });
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
справочникиToolStripMenuItem.Size = new Size(117, 24);
справочникиToolStripMenuItem.Text = "Справочники";
//
// аксессуарыToolStripMenuItem
//
аксессуарыToolStripMenuItem.Name = "аксессуарыToolStripMenuItem";
аксессуарыToolStripMenuItem.Size = new Size(203, 26);
аксессуарыToolStripMenuItem.Text = "Аксессуар";
аксессуарыToolStripMenuItem.Click += AccessoriesToolStripMenuItem_Click;
//
// характеристикиToolStripMenuItem
//
характеристикиToolStripMenuItem.Name = "характеристикиToolStripMenuItem";
характеристикиToolStripMenuItem.Size = new Size(203, 26);
характеристикиToolStripMenuItem.Text = "Характеристики";
характеристикиToolStripMenuItem.Click += SpecificationToolStripMenuItem_Click;
//
// сотрудникToolStripMenuItem
//
сотрудникToolStripMenuItem.Name = "сотрудникToolStripMenuItem";
сотрудникToolStripMenuItem.Size = new Size(203, 26);
сотрудникToolStripMenuItem.Text = "Сотрудник";
сотрудникToolStripMenuItem.Click += EmplyeeToolStripMenuItem_Click;
//
// клиентToolStripMenuItem
//
клиентToolStripMenuItem.Name = "клиентToolStripMenuItem";
клиентToolStripMenuItem.Size = new Size(203, 26);
клиентToolStripMenuItem.Text = "Клиент";
клиентToolStripMenuItem.Click += ClientToolStripMenuItem_Click;
//
// операцииToolStripMenuItem
//
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { заказToolStripMenuItem });
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
операцииToolStripMenuItem.Size = new Size(95, 24);
операцииToolStripMenuItem.Text = "Операции";
//
// заказToolStripMenuItem
//
заказToolStripMenuItem.Name = аказToolStripMenuItem";
заказToolStripMenuItem.Size = new Size(196, 26);
заказToolStripMenuItem.Text = "Оптовый заказ";
заказToolStripMenuItem.Click += ItemOrderToolStripMenuItem_Click;
//
// отчетToolStripMenuItem
//
отчетToolStripMenuItem.Name = "отчетToolStripMenuItem";
отчетToolStripMenuItem.Size = new Size(73, 24);
отчетToolStripMenuItem.Text = "Отчеты";
//
// FormOptika
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
BackgroundImage = Properties.Resources.optika;
BackgroundImageLayout = ImageLayout.Stretch;
ClientSize = new Size(800, 450);
Controls.Add(menuStrip);
MainMenuStrip = menuStrip;
Name = "FormOptika";
StartPosition = FormStartPosition.CenterParent;
Text = "Оптика";
menuStrip.ResumeLayout(false);
menuStrip.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
private MenuStrip menuStrip;
private ToolStripMenuItem справочникиToolStripMenuItem;
private ToolStripMenuItem операцииToolStripMenuItem;
private ToolStripMenuItem отчетToolStripMenuItem;
private ToolStripMenuItem аксессуарыToolStripMenuItem;
private ToolStripMenuItem заказToolStripMenuItem;
private ToolStripMenuItem характеристикиToolStripMenuItem;
private ToolStripMenuItem сотрудникToolStripMenuItem;
private ToolStripMenuItem клиентToolStripMenuItem;
}
}

View File

@ -0,0 +1,78 @@
using ProjectOptika.Scripts.Forms;
using Unity;
namespace ProjectOptika
{
public partial class FormOptika : Form
{
private IUnityContainer _container;
public FormOptika(IUnityContainer container)
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
}
private void AccessoriesToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormAccessories>().ShowDialog();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void SpecificationToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormSpecifications>().ShowDialog();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ItemOrderToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormItemOrders>().ShowDialog();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void EmplyeeToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormEmplyees>().ShowDialog();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ClientToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormClients>().ShowDialog();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}

View File

@ -0,0 +1,123 @@
<?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="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,210 @@
namespace ProjectOptika.Scripts.Forms
{
partial class FormSpecification
{
/// <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()
{
labelMaterial = new Label();
textBoxMaterial = new TextBox();
textBoxAstigmatism = new TextBox();
labelAstigmatism = new Label();
textBoxDioptericity = new TextBox();
labelDioptericity = new Label();
textBoxOriginCountry = new TextBox();
labelOriginCountry = new Label();
labelTimeProduction = new Label();
numericUpDownTimeProduction = new NumericUpDown();
buttonCancel = new Button();
buttonSave = new Button();
comboBoxAccessory = new ComboBox();
labelAccessory = new Label();
((System.ComponentModel.ISupportInitialize)numericUpDownTimeProduction).BeginInit();
SuspendLayout();
//
// labelMaterial
//
labelMaterial.AutoSize = true;
labelMaterial.Location = new Point(12, 69);
labelMaterial.Name = "labelMaterial";
labelMaterial.Size = new Size(78, 20);
labelMaterial.TabIndex = 0;
labelMaterial.Text = "Материал";
//
// textBoxMaterial
//
textBoxMaterial.Location = new Point(175, 66);
textBoxMaterial.Name = "textBoxMaterial";
textBoxMaterial.Size = new Size(125, 27);
textBoxMaterial.TabIndex = 1;
//
// textBoxAstigmatism
//
textBoxAstigmatism.Location = new Point(175, 122);
textBoxAstigmatism.Name = "textBoxAstigmatism";
textBoxAstigmatism.Size = new Size(125, 27);
textBoxAstigmatism.TabIndex = 3;
//
// labelAstigmatism
//
labelAstigmatism.AutoSize = true;
labelAstigmatism.Location = new Point(12, 125);
labelAstigmatism.Name = "labelAstigmatism";
labelAstigmatism.Size = new Size(99, 20);
labelAstigmatism.TabIndex = 2;
labelAstigmatism.Text = "Астигматизм";
//
// textBoxDioptericity
//
textBoxDioptericity.Location = new Point(175, 178);
textBoxDioptericity.Name = "textBoxDioptericity";
textBoxDioptericity.Size = new Size(125, 27);
textBoxDioptericity.TabIndex = 5;
//
// labelDioptericity
//
labelDioptericity.AutoSize = true;
labelDioptericity.Location = new Point(12, 181);
labelDioptericity.Name = "labelDioptericity";
labelDioptericity.Size = new Size(118, 20);
labelDioptericity.TabIndex = 4;
labelDioptericity.Text = "Диоптрийность";
//
// textBoxOriginCountry
//
textBoxOriginCountry.Location = new Point(175, 227);
textBoxOriginCountry.Name = "textBoxOriginCountry";
textBoxOriginCountry.Size = new Size(125, 27);
textBoxOriginCountry.TabIndex = 7;
//
// labelOriginCountry
//
labelOriginCountry.AutoSize = true;
labelOriginCountry.Location = new Point(12, 230);
labelOriginCountry.Name = "labelOriginCountry";
labelOriginCountry.Size = new Size(155, 20);
labelOriginCountry.TabIndex = 6;
labelOriginCountry.Text = "Страна изготовителя";
//
// labelTimeProduction
//
labelTimeProduction.AutoSize = true;
labelTimeProduction.Location = new Point(12, 280);
labelTimeProduction.Name = "labelTimeProduction";
labelTimeProduction.Size = new Size(121, 20);
labelTimeProduction.TabIndex = 8;
labelTimeProduction.Text = "Время поставки";
//
// numericUpDownTimeProduction
//
numericUpDownTimeProduction.Location = new Point(175, 278);
numericUpDownTimeProduction.Name = "numericUpDownTimeProduction";
numericUpDownTimeProduction.Size = new Size(125, 27);
numericUpDownTimeProduction.TabIndex = 9;
//
// buttonCancel
//
buttonCancel.Location = new Point(175, 331);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(94, 29);
buttonCancel.TabIndex = 11;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(36, 331);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(94, 29);
buttonSave.TabIndex = 10;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// comboBoxAccessory
//
comboBoxAccessory.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxAccessory.FormattingEnabled = true;
comboBoxAccessory.Location = new Point(175, 12);
comboBoxAccessory.Name = "comboBoxAccessory";
comboBoxAccessory.Size = new Size(125, 28);
comboBoxAccessory.TabIndex = 20;
//
// labelAccessory
//
labelAccessory.AutoSize = true;
labelAccessory.Location = new Point(12, 20);
labelAccessory.Name = "labelAccessory";
labelAccessory.Size = new Size(79, 20);
labelAccessory.TabIndex = 19;
labelAccessory.Text = "Аксессуар";
//
// FormSpecification
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(316, 378);
Controls.Add(comboBoxAccessory);
Controls.Add(labelAccessory);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(numericUpDownTimeProduction);
Controls.Add(labelTimeProduction);
Controls.Add(textBoxOriginCountry);
Controls.Add(labelOriginCountry);
Controls.Add(textBoxDioptericity);
Controls.Add(labelDioptericity);
Controls.Add(textBoxAstigmatism);
Controls.Add(labelAstigmatism);
Controls.Add(textBoxMaterial);
Controls.Add(labelMaterial);
Name = "FormSpecification";
StartPosition = FormStartPosition.CenterParent;
Text = "Характеристика";
((System.ComponentModel.ISupportInitialize)numericUpDownTimeProduction).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelMaterial;
private TextBox textBoxMaterial;
private TextBox textBoxAstigmatism;
private Label labelAstigmatism;
private TextBox textBoxDioptericity;
private Label labelDioptericity;
private TextBox textBoxOriginCountry;
private Label labelOriginCountry;
private Label labelTimeProduction;
private NumericUpDown numericUpDownTimeProduction;
private Button buttonCancel;
private Button buttonSave;
private ComboBox comboBoxAccessory;
private Label labelAccessory;
}
}

View File

@ -0,0 +1,85 @@
using ProjectOptika.Scripts.Entities;
using ProjectOptika.Scripts.Repositories;
namespace ProjectOptika.Scripts.Forms
{
public partial class FormSpecification : Form
{
private readonly ISpecificationsRepository _specificationsRepositories;
private int? _specificationsID;
public int ID
{
set
{
try
{
var specifications = _specificationsRepositories.GetSpecificationsByID(value);
if (specifications == null) throw new InvalidDataException(nameof(specifications));
_specificationsID = specifications.ID;
textBoxMaterial.Text = specifications.Material;
textBoxAstigmatism.Text = specifications.Astigmatism;
textBoxDioptericity.Text = specifications.Dioptericity;
textBoxOriginCountry.Text = specifications.OriginCountry;
numericUpDownTimeProduction.Value = (decimal)specifications.TimeProduction;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormSpecification(ISpecificationsRepository specifications, IAccessoriesRepository accessories)
{
InitializeComponent();
_specificationsRepositories = specifications
?? throw new ArgumentNullException(nameof(specifications));
comboBoxAccessory.DataSource = accessories.GetAccessories();
comboBoxAccessory.DisplayMember = "Name";
comboBoxAccessory.ValueMember = "ID";
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(textBoxMaterial.Text) || string.IsNullOrEmpty(textBoxAstigmatism.Text) ||
string.IsNullOrEmpty(textBoxDioptericity.Text) || string.IsNullOrEmpty(textBoxOriginCountry.Text))
{
throw new Exception("Имеются незаполненные данные");
}
if (_specificationsID.HasValue)
{
_specificationsRepositories.UpdateSpecifications(CreateSpecifications(_specificationsID.Value));
}
else
{
_specificationsRepositories.CreateSpecifications(CreateSpecifications(0));
}
Close();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
Close();
}
private Specifications CreateSpecifications(int id)
{
return Specifications.CreateEntity(id, (int)comboBoxAccessory.SelectedValue!, textBoxMaterial.Text, textBoxAstigmatism.Text, textBoxDioptericity.Text, textBoxOriginCountry.Text, (double)numericUpDownTimeProduction.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,127 @@
namespace ProjectOptika.Scripts.Forms
{
partial class FormSpecifications
{
/// <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()
{
panel = new Panel();
buttonRemove = new Button();
buttonUpdate = new Button();
buttonAdd = new Button();
dataGridView = new DataGridView();
panel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// panel
//
panel.Controls.Add(buttonRemove);
panel.Controls.Add(buttonUpdate);
panel.Controls.Add(buttonAdd);
panel.Dock = DockStyle.Right;
panel.Location = new Point(696, 0);
panel.Name = "panel";
panel.Size = new Size(104, 450);
panel.TabIndex = 6;
//
// buttonRemove
//
buttonRemove.BackgroundImage = Properties.Resources.Remove;
buttonRemove.BackgroundImageLayout = ImageLayout.Stretch;
buttonRemove.Location = new Point(3, 166);
buttonRemove.Name = "buttonRemove";
buttonRemove.Size = new Size(96, 71);
buttonRemove.TabIndex = 2;
buttonRemove.UseVisualStyleBackColor = true;
buttonRemove.Click += ButtonRemove_Click;
//
// buttonUpdate
//
buttonUpdate.BackgroundImage = Properties.Resources.Update;
buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpdate.Location = new Point(3, 89);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(96, 71);
buttonUpdate.TabIndex = 1;
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.Add;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(3, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(96, 71);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.AllowUserToResizeColumns = false;
dataGridView.AllowUserToResizeRows = false;
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Fill;
dataGridView.Location = new Point(0, 0);
dataGridView.MultiSelect = false;
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(800, 450);
dataGridView.TabIndex = 7;
//
// FormSpecifications
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(panel);
Controls.Add(dataGridView);
Name = "FormSpecifications";
StartPosition = FormStartPosition.CenterParent;
Text = "Характеристики";
Load += Form_Load;
panel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel;
private Button buttonRemove;
private Button buttonUpdate;
private Button buttonAdd;
private DataGridView dataGridView;
}
}

View File

@ -0,0 +1,97 @@
using ProjectOptika.Scripts.Repositories;
using Unity;
namespace ProjectOptika.Scripts.Forms
{
public partial class FormSpecifications : Form
{
private readonly IUnityContainer _container;
private readonly ISpecificationsRepository _specificationRepositories;
public FormSpecifications(IUnityContainer container, ISpecificationsRepository lensRepositories)
{
InitializeComponent();
_container = container ??
throw new ArgumentException(nameof(container));
_specificationRepositories = lensRepositories ??
throw new ArgumentException(nameof(lensRepositories));
}
private void Form_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormSpecification>().ShowDialog();
LoadList();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRows(out var findID)) return;
try
{
var form = _container.Resolve<FormSpecification>();
form.ID = findID;
form.ShowDialog();
LoadList();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonRemove_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRows(out var findID)) return;
if (MessageBox.Show("Удалить запись?", "Удалить", MessageBoxButtons.YesNo) != DialogResult.Yes) return;
try
{
_specificationRepositories.DeleteSpecifications(findID);
LoadList();
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridView.DataSource = _specificationRepositories.GetSpecifications();
private bool TryGetIdentifierFromSelectedRows(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,7 @@
using ProjectOptika.Scripts.Repositories;
using ProjectOptika.Scripts.Repositories.Implementations;
using Unity;
namespace ProjectOptika.Scripts
{
internal static class Program
@ -11,7 +15,19 @@ namespace ProjectOptika.Scripts
// 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<FormOptika>());
}
private static UnityContainer CreateContainer () {
var container = new UnityContainer ();
container.RegisterType<IAccessoriesRepository, AccessoriesRepository>();
container.RegisterType<IClientRepositiory, ClientRepositiory>();
container.RegisterType<IEmployeeRepository, EmployeeRepository>();
container.RegisterType<ISpecificationsRepository, SpecificationsRepository>();
container.RegisterType<IOrderRepository, OrderRepository>();
return container;
}
}
}

View File

@ -0,0 +1,17 @@
using ProjectOptika.Scripts.Entities;
namespace ProjectOptika.Scripts.Repositories
{
public interface IAccessoriesRepository
{
IEnumerable<Accessories> GetAccessories();
Accessories GetAccessoriesByID(int id);
void CreateAccessories(Accessories accessories);
void UpdateAccessories(Accessories accessories);
void DeleteAccessories(int id);
}
}

View File

@ -0,0 +1,18 @@
using ProjectOptika.Scripts.Entities;
namespace ProjectOptika.Scripts.Repositories
{
public interface IClientRepositiory
{
IEnumerable<Client> GetClients();
Client GetClientById(int id);
void CreateClient(Client client);
void UpdateClient(Client client);
void DeleteClient(int id);
}
}

View File

@ -0,0 +1,17 @@
using ProjectOptika.Scripts.Entities;
namespace ProjectOptika.Scripts.Repositories
{
public interface IEmployeeRepository
{
IEnumerable<Employee> GetEmployees();
Employee GetEmployeerByID(int id);
void CreateEmployee(Employee employee);
void UpdateEmployee(Employee employee);
void DeleteEmployee(int id);
}
}

View File

@ -0,0 +1,13 @@
using ProjectOptika.Scripts.Entities;
namespace ProjectOptika.Scripts.Repositories
{
public interface IOrderRepository
{
IEnumerable<Order> GetOrders(DateTime? startDate = null, DateTime? endDate = null, double? totalCost = null, int? id = null, int? employeeID = null, int? clientID = null);
void CreateOrder(Order order);
void DeleteOrder(int id);
}
}

View File

@ -0,0 +1,17 @@
using ProjectOptika.Scripts.Entities;
namespace ProjectOptika.Scripts.Repositories
{
public interface ISpecificationsRepository
{
IEnumerable<Specifications> GetSpecifications();
Specifications GetSpecificationsByID(int id);
void CreateSpecifications(Specifications specifications);
void UpdateSpecifications(Specifications specifications);
void DeleteSpecifications(int id);
}
}

View File

@ -0,0 +1,29 @@
using ProjectOptika.Scripts.Entities;
namespace ProjectOptika.Scripts.Repositories.Implementations
{
public class AccessoriesRepository : IAccessoriesRepository
{
public void CreateAccessories(Accessories order)
{
}
public void DeleteAccessories(int id)
{
}
public IEnumerable<Accessories> GetAccessories()
{
return [];
}
public Accessories GetAccessoriesByID(int id)
{
return Accessories.CreateEntity(0, string.Empty, string.Empty, 0, 0, 0, DateTime.Now, 0);
}
public void UpdateAccessories(Accessories order)
{
}
}
}

View File

@ -0,0 +1,29 @@
using ProjectOptika.Scripts.Entities;
namespace ProjectOptika.Scripts.Repositories.Implementations
{
public class ClientRepositiory : IClientRepositiory
{
public void CreateClient(Client client)
{
}
public void DeleteClient(int id)
{
}
public Client GetClientById(int id)
{
return Client.CreateEntity(0, Entities.Enums.ClientType.Corporate, string.Empty, string.Empty, string.Empty, string.Empty);
}
public IEnumerable<Client> GetClients()
{
return [];
}
public void UpdateClient(Client client)
{
}
}
}

View File

@ -0,0 +1,29 @@
using ProjectOptika.Scripts.Entities;
namespace ProjectOptika.Scripts.Repositories.Implementations
{
public class EmployeeRepository : IEmployeeRepository
{
public void CreateEmployee(Employee employee)
{
}
public void DeleteEmployee(int id)
{
}
public Employee GetEmployeerByID(int id)
{
return Employee.CreateEntity(0, Entities.Enums.PositionEmployee.None, string.Empty, string.Empty, string.Empty);
}
public IEnumerable<Employee> GetEmployees()
{
return [];
}
public void UpdateEmployee(Employee employee)
{
}
}
}

View File

@ -0,0 +1,20 @@
using ProjectOptika.Scripts.Entities;
namespace ProjectOptika.Scripts.Repositories.Implementations
{
public class OrderRepository : IOrderRepository
{
public void CreateOrder(Order order)
{
}
public void DeleteOrder(int id)
{
}
public IEnumerable<Order> GetOrders(DateTime? startDate = null, DateTime? endDate = null, double? totalCost = null, int? id = null, int? employeeID = null, int? clientID = null)
{
return [];
}
}
}

View File

@ -0,0 +1,29 @@
using ProjectOptika.Scripts.Entities;
namespace ProjectOptika.Scripts.Repositories.Implementations
{
public class SpecificationsRepository : ISpecificationsRepository
{
public void CreateSpecifications(Specifications specification)
{
}
public void DeleteSpecifications(int id)
{
}
public IEnumerable<Specifications> GetSpecifications()
{
return [];
}
public Specifications GetSpecificationsByID(int id)
{
return Specifications.CreateEntity(0, 0, string.Empty, string.Empty, string.Empty, string.Empty, 0.0);
}
public void UpdateSpecifications(Specifications specification)
{
}
}
}