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

This commit is contained in:
Егор Васин 2024-12-03 22:15:31 +03:00
parent 875abd5254
commit 0c9c6f8496
70 changed files with 4861 additions and 77 deletions

View File

@ -0,0 +1,17 @@
namespace ISEbd_22_Vasin_E.D._It_Company.Entities;
public class Client
{
public int Id { get; private set; }
public string Name { get; private set; } = string.Empty;
public static Client CreateEntity(int id, string name)
{
return new Client
{
Id = id,
Name = name ?? string.Empty
};
}
}

View File

@ -0,0 +1,38 @@
using ISEbd_22_Vasin_E.D._It_Company.Entities.Enums;
namespace ISEbd_22_Vasin_E.D._It_Company.Entities;
public class Contract
{
public int Id { get; private set; }
public int ClientId { get; private set; }
public int ContractorId { get; private set; }
public int Amount { get; private set; }
public DateTime Deadline { get; private set; }
public Status Status { get; private set; }
public ContractType ContractType { get; private set; }
public IEnumerable<Service> Services { get; private set; } = [];
public static Contract CreateEntity(int id, int clientId, int contractorId, int amount,
DateTime deadline, Status status, ContractType contractType, IEnumerable<Service> services)
{
return new Contract
{
Id = id,
ClientId = clientId,
ContractorId = contractorId,
Amount = amount,
Deadline = deadline,
Status = status,
ContractType = contractType,
Services = services
};
}
}

View File

@ -0,0 +1,17 @@
namespace ISEbd_22_Vasin_E.D._It_Company.Entities;
public class Contractor
{
public int Id { get; private set; }
public string Name { get; private set; } = string.Empty;
public static Contractor CreateEntity(int id, string name)
{
return new Contractor
{
Id = id,
Name = name ?? string.Empty
};
}
}

View File

@ -0,0 +1,20 @@
namespace ISEbd_22_Vasin_E.D._It_Company.Entities;
public class ContractorVacation
{
public int Id { get; private set; }
public int ContractorId { get; private set; }
public int VacationId { get; private set; }
public static ContractorVacation CreateElement(int id, int contractorId, int vacationId)
{
return new ContractorVacation
{
Id = id,
ContractorId = contractorId,
VacationId = vacationId
};
}
}

View File

@ -0,0 +1,11 @@
namespace ISEbd_22_Vasin_E.D._It_Company.Entities.Enums;
[Flags]
public enum ContractType
{
None = 0,
Support = 1,
Development = 2
}

View File

@ -0,0 +1,12 @@
namespace ISEbd_22_Vasin_E.D._It_Company.Entities.Enums;
public enum Status
{
None = 0,
Started = 1,
InProgress = 2,
Finished = 3
}

View File

@ -0,0 +1,17 @@
namespace ISEbd_22_Vasin_E.D._It_Company.Entities;
public class Service
{
public int Id { get; private set; }
public string Name { get; private set; } = string.Empty;
public static Service CreateEntity(int id, string name)
{
return new Service
{
Id = id,
Name = name ?? string.Empty,
};
}
}

View File

@ -0,0 +1,20 @@
namespace OISEbd_22_Vasin_E.D._It_CompanyTP.Entities;
public class ServiceContract
{
public int Id { get; private set; }
public int ServiceId { get; private set; }
public int ContractId { get; private set; }
public static ServiceContract CreateElement(int id, int serviceId, int contractId)
{
return new ServiceContract
{
Id = id,
ServiceId = serviceId,
ContractId = contractId
};
}
}

View File

@ -0,0 +1,20 @@
namespace ISEbd_22_Vasin_E.D._It_Company.Entities;
public class Vacation
{
public int Id { get; private set; }
public DateTime StartDate { get; private set; }
public DateTime EndDate { get; private set; }
public static Vacation CreateEntity(int id, DateTime startDate, DateTime endDate)
{
return new Vacation
{
Id = id,
StartDate = startDate,
EndDate = endDate
};
}
}

View File

@ -1,39 +0,0 @@
namespace ISEbd_22_Vasin_E.D._It_Company
{
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 ISEbd_22_Vasin_E.D._It_Company
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,146 @@
namespace ISEbd_22_Vasin_E.D._It_Company
{
partial class FormItCompany
{
/// <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();
entitiesToolStripMenuItem = new ToolStripMenuItem();
clientsToolStripMenuItem = new ToolStripMenuItem();
contractorsToolStripMenuItem = new ToolStripMenuItem();
servicesToolStripMenuItem = new ToolStripMenuItem();
vacationsToolStripMenuItem = new ToolStripMenuItem();
operationsToolStripMenuItem = new ToolStripMenuItem();
contractsToolStripMenuItem = new ToolStripMenuItem();
contractorVacationsToolStripMenuItem = new ToolStripMenuItem();
reportsToolStripMenuItem = new ToolStripMenuItem();
menuStrip.SuspendLayout();
SuspendLayout();
//
// menuStrip
//
menuStrip.Items.AddRange(new ToolStripItem[] { entitiesToolStripMenuItem, operationsToolStripMenuItem, reportsToolStripMenuItem });
menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip";
menuStrip.Size = new Size(800, 24);
menuStrip.TabIndex = 0;
menuStrip.Text = "menuStrip1";
//
// entitiesToolStripMenuItem
//
entitiesToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { clientsToolStripMenuItem, contractorsToolStripMenuItem, servicesToolStripMenuItem, vacationsToolStripMenuItem });
entitiesToolStripMenuItem.Name = "entitiesToolStripMenuItem";
entitiesToolStripMenuItem.Size = new Size(94, 20);
entitiesToolStripMenuItem.Text = "Справочники";
//
// clientsToolStripMenuItem
//
clientsToolStripMenuItem.Name = "clientsToolStripMenuItem";
clientsToolStripMenuItem.Size = new Size(180, 22);
clientsToolStripMenuItem.Text = "Заказчики";
clientsToolStripMenuItem.Click += ClientsToolStripMenuItem_Click;
//
// contractorsToolStripMenuItem
//
contractorsToolStripMenuItem.Name = "contractorsToolStripMenuItem";
contractorsToolStripMenuItem.Size = new Size(180, 22);
contractorsToolStripMenuItem.Text = "Исполнители";
contractorsToolStripMenuItem.Click += ContractorsToolStripMenuItem_Click;
//
// servicesToolStripMenuItem
//
servicesToolStripMenuItem.Name = "servicesToolStripMenuItem";
servicesToolStripMenuItem.Size = new Size(180, 22);
servicesToolStripMenuItem.Text = "Услуги";
servicesToolStripMenuItem.Click += ServicesToolStripMenuItem_Click;
//
// vacationsToolStripMenuItem
//
vacationsToolStripMenuItem.Name = "vacationsToolStripMenuItem";
vacationsToolStripMenuItem.Size = new Size(180, 22);
vacationsToolStripMenuItem.Text = "Отпуска";
vacationsToolStripMenuItem.Click += VacationsToolStripMenuItem_Click;
//
// operationsToolStripMenuItem
//
operationsToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { contractsToolStripMenuItem, contractorVacationsToolStripMenuItem });
operationsToolStripMenuItem.Name = "operationsToolStripMenuItem";
operationsToolStripMenuItem.Size = new Size(75, 20);
operationsToolStripMenuItem.Text = "Операции";
//
// contractsToolStripMenuItem
//
contractsToolStripMenuItem.Name = "contractsToolStripMenuItem";
contractsToolStripMenuItem.Size = new Size(180, 22);
contractsToolStripMenuItem.Text = "Контракты";
contractsToolStripMenuItem.Click += ContractsToolStripMenuItem_Click;
//
// contractorVacationsToolStripMenuItem
//
contractorVacationsToolStripMenuItem.Name = "contractorVacationsToolStripMenuItem";
contractorVacationsToolStripMenuItem.Size = new Size(180, 22);
contractorVacationsToolStripMenuItem.Text = "Взятые отпуска";
contractorVacationsToolStripMenuItem.Click += ContractorVacationsToolStripMenuItem_Click;
//
// reportsToolStripMenuItem
//
reportsToolStripMenuItem.Name = "reportsToolStripMenuItem";
reportsToolStripMenuItem.Size = new Size(60, 20);
reportsToolStripMenuItem.Text = "Отчеты";
//
// FormItCompany
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
BackgroundImage = Properties.Resources.it_company;
BackgroundImageLayout = ImageLayout.Stretch;
ClientSize = new Size(800, 450);
Controls.Add(menuStrip);
MainMenuStrip = menuStrip;
Name = "FormItCompany";
StartPosition = FormStartPosition.CenterScreen;
Text = "IT-компания";
menuStrip.ResumeLayout(false);
menuStrip.PerformLayout();
ResumeLayout(false);
PerformLayout();
}
#endregion
private MenuStrip menuStrip;
private ToolStripMenuItem entitiesToolStripMenuItem;
private ToolStripMenuItem clientsToolStripMenuItem;
private ToolStripMenuItem contractorsToolStripMenuItem;
private ToolStripMenuItem servicesToolStripMenuItem;
private ToolStripMenuItem vacationsToolStripMenuItem;
private ToolStripMenuItem operationsToolStripMenuItem;
private ToolStripMenuItem contractsToolStripMenuItem;
private ToolStripMenuItem contractorVacationsToolStripMenuItem;
private ToolStripMenuItem reportsToolStripMenuItem;
}
}

View File

@ -0,0 +1,88 @@
using ISEbd_22_Vasin_E.D._It_Company.Forms;
using Unity;
namespace ISEbd_22_Vasin_E.D._It_Company
{
public partial class FormItCompany : Form
{
private readonly IUnityContainer _container;
public FormItCompany(IUnityContainer container)
{
InitializeComponent();
_container = container ?? throw new ArgumentNullException(nameof(container));
}
private void ClientsToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormClients>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ContractorsToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormContractors>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ServicesToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormServices>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void VacationsToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormVacations>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ContractsToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormContracts>().ShowDialog();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ContractorVacationsToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormContractorVacations>().ShowDialog();
}
catch (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,96 @@
namespace ISEbd_22_Vasin_E.D._It_Company.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()
{
labelName = new Label();
textBoxName = new TextBox();
buttonCancel = new Button();
buttonSave = new Button();
SuspendLayout();
//
// labelName
//
labelName.AutoSize = true;
labelName.Location = new Point(11, 15);
labelName.Name = "labelName";
labelName.Size = new Size(34, 15);
labelName.TabIndex = 0;
labelName.Text = "Имя:";
//
// textBoxName
//
textBoxName.Location = new Point(51, 12);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(217, 23);
textBoxName.TabIndex = 1;
//
// buttonCancel
//
buttonCancel.Location = new Point(151, 41);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(117, 23);
buttonCancel.TabIndex = 10;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(11, 41);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(117, 23);
buttonSave.TabIndex = 9;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// FormClient
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(283, 75);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(textBoxName);
Controls.Add(labelName);
Name = "FormClient";
StartPosition = FormStartPosition.CenterParent;
Text = "Заказчик";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelName;
private TextBox textBoxName;
private Button buttonCancel;
private Button buttonSave;
}
}

View File

@ -0,0 +1,71 @@
using ISEbd_22_Vasin_E.D._It_Company.Entities;
using ISEbd_22_Vasin_E.D._It_Company.Repositories;
namespace ISEbd_22_Vasin_E.D._It_Company.Forms
{
public partial class FormClient : Form
{
private readonly IClientRepository _clientRepository;
private int? _clientId;
public int Id
{
set
{
try
{
var client = _clientRepository.ReadClientById(value);
if (client == null)
{
throw new InvalidDataException(nameof(client));
}
textBoxName.Text = client.Name;
_clientId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormClient(IClientRepository clientRepository)
{
InitializeComponent();
_clientRepository = clientRepository ?? throw new ArgumentNullException(nameof(clientRepository));
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(textBoxName.Text))
{
throw new Exception("Имеются незаполненные поля");
}
if (_clientId.HasValue)
{
_clientRepository.UpdateClient(Client.CreateEntity(_clientId.Value,
textBoxName.Text));
}
else
{
_clientRepository.CreateClient(Client.CreateEntity(0,
textBoxName.Text));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
}
}

View File

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<root> <root>
<!-- <!--
Microsoft ResX Schema Microsoft ResX Schema
Version 2.0 Version 2.0
The primary goals of this format is to allow a simple XML format The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes various data types are done through the TypeConverter classes
associated with the data types. associated with the data types.
Example: Example:
... ado.net/XML headers & schema ... ... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader> <resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</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> <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment> <comment>This is a comment</comment>
</data> </data>
There are any number of "resheader" rows that contain simple There are any number of "resheader" rows that contain simple
name/value pairs. name/value pairs.
Each data row contains a name, and value. The row also contains a Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture. text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the Classes that don't support this are serialized and stored with the
mimetype set. mimetype set.
The mimetype is used for serialized objects, and tells the The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly: extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below. read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64 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 : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64 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 : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64 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 : using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding. : and then encoded with base64 encoding.
--> -->

View File

@ -0,0 +1,126 @@
namespace ISEbd_22_Vasin_E.D._It_Company.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()
{
dataGridViewData = new DataGridView();
panel = new Panel();
buttonDel = new Button();
buttonUpd = new Button();
buttonAdd = new Button();
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
panel.SuspendLayout();
SuspendLayout();
//
// dataGridViewData
//
dataGridViewData.AllowUserToAddRows = false;
dataGridViewData.AllowUserToDeleteRows = false;
dataGridViewData.AllowUserToResizeColumns = false;
dataGridViewData.AllowUserToResizeRows = false;
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewData.Dock = DockStyle.Fill;
dataGridViewData.Location = new Point(0, 0);
dataGridViewData.MultiSelect = false;
dataGridViewData.Name = "dataGridViewData";
dataGridViewData.ReadOnly = true;
dataGridViewData.RowHeadersVisible = false;
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewData.Size = new Size(861, 461);
dataGridViewData.TabIndex = 5;
//
// panel
//
panel.Controls.Add(buttonDel);
panel.Controls.Add(buttonUpd);
panel.Controls.Add(buttonAdd);
panel.Dock = DockStyle.Right;
panel.Location = new Point(861, 0);
panel.Name = "panel";
panel.Size = new Size(123, 461);
panel.TabIndex = 4;
//
// buttonDel
//
buttonDel.BackgroundImage = Properties.Resources.icon_remove;
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(16, 204);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(90, 90);
buttonDel.TabIndex = 2;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += ButtonDel_Click;
//
// buttonUpd
//
buttonUpd.BackgroundImage = Properties.Resources.icon_edit;
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpd.Location = new Point(16, 108);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(90, 90);
buttonUpd.TabIndex = 1;
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += ButtonUpd_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.icon_add;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(16, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(90, 90);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// FormClients
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(984, 461);
Controls.Add(dataGridViewData);
Controls.Add(panel);
Name = "FormClients";
StartPosition = FormStartPosition.CenterParent;
Text = "Заказчики";
Load += FormClients_Load;
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
panel.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridViewData;
private Panel panel;
private Button buttonDel;
private Button buttonUpd;
private Button buttonAdd;
}
}

View File

@ -0,0 +1,96 @@
using ISEbd_22_Vasin_E.D._It_Company.Repositories;
using Unity;
namespace ISEbd_22_Vasin_E.D._It_Company.Forms
{
public partial class FormClients : Form
{
private readonly IUnityContainer _container;
private readonly IClientRepository _clientRepository;
public FormClients(IUnityContainer container, IClientRepository clientRepository)
{
InitializeComponent();
_container = container ?? throw new ArgumentException(nameof(container));
_clientRepository = clientRepository ?? throw new ArgumentException(nameof(clientRepository));
}
private void FormClients_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (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 (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
return;
try
{
var form = _container.Resolve<FormClient>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
return;
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
return;
try
{
_clientRepository.DeleteClient(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewData.DataSource = _clientRepository.ReadClients();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridViewData.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridViewData.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,255 @@
namespace ISEbd_22_Vasin_E.D._It_Company.Forms
{
partial class FormContract
{
/// <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()
{
labelClient = new Label();
labelContractor = new Label();
numericUpDownAmount = new NumericUpDown();
labelAmount = new Label();
comboBoxClient = new ComboBox();
comboBoxContractor = new ComboBox();
labelDeadline = new Label();
dateTimePickerDeadline = new DateTimePicker();
labelStatus = new Label();
comboBoxStatus = new ComboBox();
checkedListBoxContractType = new CheckedListBox();
labelContractType = new Label();
groupBoxServices = new GroupBox();
dataGridViewServices = new DataGridView();
buttonCancel = new Button();
buttonSave = new Button();
ColumnServiceName = new DataGridViewComboBoxColumn();
((System.ComponentModel.ISupportInitialize)numericUpDownAmount).BeginInit();
groupBoxServices.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewServices).BeginInit();
SuspendLayout();
//
// labelClient
//
labelClient.AutoSize = true;
labelClient.Location = new Point(12, 15);
labelClient.Name = "labelClient";
labelClient.Size = new Size(60, 15);
labelClient.TabIndex = 0;
labelClient.Text = "Заказчик:";
//
// labelContractor
//
labelContractor.AutoSize = true;
labelContractor.Location = new Point(12, 44);
labelContractor.Name = "labelContractor";
labelContractor.Size = new Size(84, 15);
labelContractor.TabIndex = 1;
labelContractor.Text = "Исполнитель:";
//
// numericUpDownAmount
//
numericUpDownAmount.Location = new Point(117, 70);
numericUpDownAmount.Name = "numericUpDownAmount";
numericUpDownAmount.Size = new Size(199, 23);
numericUpDownAmount.TabIndex = 2;
//
// labelAmount
//
labelAmount.AutoSize = true;
labelAmount.Location = new Point(12, 72);
labelAmount.Name = "labelAmount";
labelAmount.Size = new Size(70, 15);
labelAmount.TabIndex = 3;
labelAmount.Text = "Стоимость:";
//
// comboBoxClient
//
comboBoxClient.FormattingEnabled = true;
comboBoxClient.Location = new Point(117, 12);
comboBoxClient.Name = "comboBoxClient";
comboBoxClient.Size = new Size(200, 23);
comboBoxClient.TabIndex = 4;
//
// comboBoxContractor
//
comboBoxContractor.FormattingEnabled = true;
comboBoxContractor.Location = new Point(117, 41);
comboBoxContractor.Name = "comboBoxContractor";
comboBoxContractor.Size = new Size(200, 23);
comboBoxContractor.TabIndex = 5;
//
// labelDeadline
//
labelDeadline.AutoSize = true;
labelDeadline.Location = new Point(12, 99);
labelDeadline.Name = "labelDeadline";
labelDeadline.Size = new Size(38, 15);
labelDeadline.TabIndex = 6;
labelDeadline.Text = "Срок:";
//
// dateTimePickerDeadline
//
dateTimePickerDeadline.Location = new Point(117, 99);
dateTimePickerDeadline.Name = "dateTimePickerDeadline";
dateTimePickerDeadline.Size = new Size(200, 23);
dateTimePickerDeadline.TabIndex = 7;
//
// labelStatus
//
labelStatus.AutoSize = true;
labelStatus.Location = new Point(12, 131);
labelStatus.Name = "labelStatus";
labelStatus.Size = new Size(46, 15);
labelStatus.TabIndex = 8;
labelStatus.Text = "Статус:";
//
// comboBoxStatus
//
comboBoxStatus.FormattingEnabled = true;
comboBoxStatus.Location = new Point(117, 128);
comboBoxStatus.Name = "comboBoxStatus";
comboBoxStatus.Size = new Size(200, 23);
comboBoxStatus.TabIndex = 9;
//
// checkedListBoxContractType
//
checkedListBoxContractType.FormattingEnabled = true;
checkedListBoxContractType.Location = new Point(117, 157);
checkedListBoxContractType.Name = "checkedListBoxContractType";
checkedListBoxContractType.Size = new Size(199, 58);
checkedListBoxContractType.TabIndex = 10;
//
// labelContractType
//
labelContractType.AutoSize = true;
labelContractType.Location = new Point(12, 166);
labelContractType.Name = "labelContractType";
labelContractType.Size = new Size(89, 15);
labelContractType.TabIndex = 11;
labelContractType.Text = "Тип контракта:";
//
// groupBoxServices
//
groupBoxServices.Controls.Add(dataGridViewServices);
groupBoxServices.Location = new Point(12, 221);
groupBoxServices.Name = "groupBoxServices";
groupBoxServices.Size = new Size(305, 246);
groupBoxServices.TabIndex = 12;
groupBoxServices.TabStop = false;
groupBoxServices.Text = "Услуги:";
//
// dataGridViewServices
//
dataGridViewServices.AllowUserToResizeColumns = false;
dataGridViewServices.AllowUserToResizeRows = false;
dataGridViewServices.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewServices.Columns.AddRange(new DataGridViewColumn[] { ColumnServiceName });
dataGridViewServices.Dock = DockStyle.Fill;
dataGridViewServices.Location = new Point(3, 19);
dataGridViewServices.Name = "dataGridViewServices";
dataGridViewServices.RowHeadersVisible = false;
dataGridViewServices.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewServices.Size = new Size(299, 224);
dataGridViewServices.TabIndex = 0;
//
// buttonCancel
//
buttonCancel.Location = new Point(200, 470);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(117, 23);
buttonCancel.TabIndex = 14;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(12, 470);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(117, 23);
buttonSave.TabIndex = 13;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// ColumnServiceName
//
ColumnServiceName.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
ColumnServiceName.HeaderText = "Название услуги";
ColumnServiceName.Name = "ColumnServiceName";
ColumnServiceName.Resizable = DataGridViewTriState.True;
ColumnServiceName.SortMode = DataGridViewColumnSortMode.Automatic;
//
// FormContract
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(332, 504);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(groupBoxServices);
Controls.Add(labelContractType);
Controls.Add(checkedListBoxContractType);
Controls.Add(comboBoxStatus);
Controls.Add(labelStatus);
Controls.Add(dateTimePickerDeadline);
Controls.Add(labelDeadline);
Controls.Add(comboBoxContractor);
Controls.Add(comboBoxClient);
Controls.Add(labelAmount);
Controls.Add(numericUpDownAmount);
Controls.Add(labelContractor);
Controls.Add(labelClient);
Name = "FormContract";
StartPosition = FormStartPosition.CenterParent;
Text = "Контракт";
((System.ComponentModel.ISupportInitialize)numericUpDownAmount).EndInit();
groupBoxServices.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewServices).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelClient;
private Label labelContractor;
private NumericUpDown numericUpDownAmount;
private Label labelAmount;
private ComboBox comboBoxClient;
private ComboBox comboBoxContractor;
private Label labelDeadline;
private DateTimePicker dateTimePickerDeadline;
private Label labelStatus;
private ComboBox comboBoxStatus;
private CheckedListBox checkedListBoxContractType;
private Label labelContractType;
private GroupBox groupBoxServices;
private DataGridView dataGridViewServices;
private Button buttonCancel;
private Button buttonSave;
private DataGridViewComboBoxColumn ColumnServiceName;
}
}

View File

@ -0,0 +1,128 @@
using ISEbd_22_Vasin_E.D._It_Company.Entities;
using ISEbd_22_Vasin_E.D._It_Company.Entities.Enums;
using ISEbd_22_Vasin_E.D._It_Company.Repositories;
namespace ISEbd_22_Vasin_E.D._It_Company.Forms
{
public partial class FormContract : Form
{
private readonly IContractRepository _contractRepository;
private int? _contractId;
public int Id
{
set
{
try
{
var contract = _contractRepository.ReadContractById(value);
if (contract == null)
{
throw new InvalidDataException(nameof(contract));
}
comboBoxClient.SelectedItem = contract.ClientId;
comboBoxContractor.SelectedItem = contract.ContractorId;
numericUpDownAmount.Value = contract.Amount;
dateTimePickerDeadline.Value = contract.Deadline;
comboBoxStatus.SelectedItem = contract.Status;
checkedListBoxContractType.Items.Clear();
foreach (ContractType type in Enum.GetValues(typeof(ContractType)))
{
checkedListBoxContractType.Items.Add(type, contract.ContractType.HasFlag(type));
}
_contractId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormContract(IContractRepository contractRepository, IClientRepository clientRepository,
IContractorRepository contractorRepository, IServiceRepository serviceRepository)
{
InitializeComponent();
_contractRepository = contractRepository ?? throw new ArgumentNullException(nameof(contractRepository));
comboBoxClient.DataSource = clientRepository.ReadClients();
comboBoxClient.DisplayMember = "Name";
comboBoxClient.ValueMember = "Id";
comboBoxContractor.DataSource = contractorRepository.ReadContractors();
comboBoxContractor.DisplayMember = "Name";
comboBoxContractor.ValueMember = "Id";
ColumnServiceName.DataSource = serviceRepository.ReadServices();
ColumnServiceName.DisplayMember = "Name";
ColumnServiceName.ValueMember = "Id";
foreach (var elem in Enum.GetValues(typeof(ContractType)))
{
checkedListBoxContractType.Items.Add(elem);
}
comboBoxStatus.DataSource = Enum.GetValues(typeof(Status));
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (checkedListBoxContractType.CheckedItems.Count == 0 ||
comboBoxContractor.SelectedIndex < 0 ||
comboBoxClient.SelectedIndex < 0 ||
comboBoxStatus.SelectedIndex < 0)
{
throw new Exception("Имеются незаполненные поля");
}
if (_contractId.HasValue)
{
_contractRepository.UpdateContract(CreateContract(_contractId.Value));
}
else
{
_contractRepository.CreateContract(CreateContract(0));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
private Contract CreateContract(int id)
{
ContractType contractType = ContractType.None;
foreach (var elem in checkedListBoxContractType.CheckedItems)
{
contractType |= (ContractType)elem;
}
return Contract.CreateEntity(id, (int)comboBoxClient.SelectedValue!,
(int)comboBoxContractor.SelectedValue!, Convert.ToInt32(numericUpDownAmount.Value),
dateTimePickerDeadline.Value, (Status)comboBoxStatus.SelectedItem!, contractType,
CreateListServicesFromDataGrid());
}
private List<Service> CreateListServicesFromDataGrid()
{
var list = new List<Service>();
foreach (DataGridViewRow row in dataGridViewServices.Rows)
if (row.Cells["ColumnServiceName"].Value != null &&
row.Cells["ColumnServiceDescription"].Value != null)
{
list.Add(Service.CreateEntity(0, Convert.ToString(row.Cells["ColumnServiceName"].Value)!));
}
return list;
}
}
}

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="ColumnServiceName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -0,0 +1,96 @@
namespace ISEbd_22_Vasin_E.D._It_Company.Forms
{
partial class FormContractor
{
/// <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();
textBoxName = new TextBox();
labelName = new Label();
SuspendLayout();
//
// buttonCancel
//
buttonCancel.Location = new Point(150, 41);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(117, 23);
buttonCancel.TabIndex = 14;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(10, 41);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(117, 23);
buttonSave.TabIndex = 13;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// textBoxName
//
textBoxName.Location = new Point(50, 12);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(217, 23);
textBoxName.TabIndex = 12;
//
// labelName
//
labelName.AutoSize = true;
labelName.Location = new Point(10, 15);
labelName.Name = "labelName";
labelName.Size = new Size(34, 15);
labelName.TabIndex = 11;
labelName.Text = "Имя:";
//
// FormContractor
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(286, 79);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(textBoxName);
Controls.Add(labelName);
Name = "FormContractor";
StartPosition = FormStartPosition.CenterParent;
Text = "Исполнитель";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonCancel;
private Button buttonSave;
private TextBox textBoxName;
private Label labelName;
}
}

View File

@ -0,0 +1,66 @@
using ISEbd_22_Vasin_E.D._It_Company.Entities;
using ISEbd_22_Vasin_E.D._It_Company.Repositories;
namespace ISEbd_22_Vasin_E.D._It_Company.Forms
{
public partial class FormContractor : Form
{
private readonly IContractorRepository _contractorRepository;
private int? _contractorId;
public int Id
{
set
{
try
{
var contractor = _contractorRepository.ReadContractorById(value);
if (contractor == null) throw new InvalidDataException(nameof(contractor));
textBoxName.Text = contractor.Name;
_contractorId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormContractor(IContractorRepository contractorRepository)
{
InitializeComponent();
_contractorRepository = contractorRepository ?? throw new ArgumentNullException(nameof(contractorRepository));
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(textBoxName.Text))
{
throw new Exception("Имеются незаполненные поля");
}
if (_contractorId.HasValue)
{
_contractorRepository.UpdateContractor(Contractor.CreateEntity(_contractorId.Value, textBoxName.Text));
}
else
{
_contractorRepository.CreateContractor(Contractor.CreateEntity(0, textBoxName.Text));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
}
}

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,120 @@
namespace ISEbd_22_Vasin_E.D._It_Company.Forms
{
partial class FormContractorVacation
{
/// <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()
{
labelContractor = new Label();
labelVacation = new Label();
comboBoxContractor = new ComboBox();
comboBoxVacation = new ComboBox();
buttonCancel = new Button();
buttonSave = new Button();
SuspendLayout();
//
// labelContractor
//
labelContractor.AutoSize = true;
labelContractor.Location = new Point(10, 15);
labelContractor.Name = "labelContractor";
labelContractor.Size = new Size(84, 15);
labelContractor.TabIndex = 0;
labelContractor.Text = "Исполнитель:";
//
// labelVacation
//
labelVacation.AutoSize = true;
labelVacation.Location = new Point(10, 44);
labelVacation.Name = "labelVacation";
labelVacation.Size = new Size(49, 15);
labelVacation.TabIndex = 1;
labelVacation.Text = "Отпуск:";
//
// comboBoxContractor
//
comboBoxContractor.FormattingEnabled = true;
comboBoxContractor.Location = new Point(100, 12);
comboBoxContractor.Name = "comboBoxContractor";
comboBoxContractor.Size = new Size(167, 23);
comboBoxContractor.TabIndex = 2;
//
// comboBoxVacation
//
comboBoxVacation.FormattingEnabled = true;
comboBoxVacation.Location = new Point(100, 41);
comboBoxVacation.Name = "comboBoxVacation";
comboBoxVacation.Size = new Size(167, 23);
comboBoxVacation.TabIndex = 3;
//
// buttonCancel
//
buttonCancel.Location = new Point(150, 70);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(117, 23);
buttonCancel.TabIndex = 12;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(10, 70);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(117, 23);
buttonSave.TabIndex = 11;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// FormContractorVacation
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(283, 109);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(comboBoxVacation);
Controls.Add(comboBoxContractor);
Controls.Add(labelVacation);
Controls.Add(labelContractor);
Name = "FormContractorVacation";
StartPosition = FormStartPosition.CenterParent;
Text = "Взятый отпуск";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelContractor;
private Label labelVacation;
private ComboBox comboBoxContractor;
private ComboBox comboBoxVacation;
private Button buttonCancel;
private Button buttonSave;
}
}

View File

@ -0,0 +1,57 @@
using ISEbd_22_Vasin_E.D._It_Company.Entities;
using ISEbd_22_Vasin_E.D._It_Company.Repositories;
namespace ISEbd_22_Vasin_E.D._It_Company.Forms
{
public partial class FormContractorVacation : Form
{
private readonly IContractorVacationRepository _contractorVacationRepository;
public FormContractorVacation(IContractorVacationRepository contractorVacationRepository,
IContractorRepository contractorRepository, IVacationRepository vacationRepository)
{
InitializeComponent();
_contractorVacationRepository = contractorVacationRepository ??
throw new ArgumentNullException(nameof(contractorVacationRepository));
comboBoxContractor.DataSource = contractorRepository.ReadContractors();
comboBoxContractor.DisplayMember = "Name";
comboBoxContractor.ValueMember = "Id";
var vacations = vacationRepository.ReadVacations()
.Select(v => new
{
Id = v.Id,
DisplayDate =
$"{v.StartDate.ToString("dd.MM.yyyy")} - {v.EndDate.ToString("dd.MM.yyyy")}"
})
.ToList();
comboBoxVacation.DataSource = vacations;
comboBoxVacation.DisplayMember = "DisplayDate";
comboBoxVacation.ValueMember = "Id";
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (comboBoxContractor.SelectedIndex < 0 ||
comboBoxVacation.SelectedIndex < 0)
{
throw new Exception("Имеются незаполненные поля");
}
_contractorVacationRepository.CreateContractorVacation(ContractorVacation.CreateElement(0,
(int)comboBoxContractor.SelectedValue!, (int)comboBoxContractor.SelectedValue!));
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
}
}

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,98 @@
namespace ISEbd_22_Vasin_E.D._It_Company.Forms
{
partial class FormContractorVacations
{
/// <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()
{
dataGridViewData = new DataGridView();
panel = new Panel();
buttonAdd = new Button();
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
panel.SuspendLayout();
SuspendLayout();
//
// dataGridViewData
//
dataGridViewData.AllowUserToAddRows = false;
dataGridViewData.AllowUserToDeleteRows = false;
dataGridViewData.AllowUserToResizeColumns = false;
dataGridViewData.AllowUserToResizeRows = false;
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewData.Dock = DockStyle.Fill;
dataGridViewData.Location = new Point(0, 0);
dataGridViewData.MultiSelect = false;
dataGridViewData.Name = "dataGridViewData";
dataGridViewData.ReadOnly = true;
dataGridViewData.RowHeadersVisible = false;
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewData.Size = new Size(861, 461);
dataGridViewData.TabIndex = 7;
//
// panel
//
panel.Controls.Add(buttonAdd);
panel.Dock = DockStyle.Right;
panel.Location = new Point(861, 0);
panel.Name = "panel";
panel.Size = new Size(123, 461);
panel.TabIndex = 6;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.icon_add;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(16, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(90, 90);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// FormContractorVacations
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(984, 461);
Controls.Add(dataGridViewData);
Controls.Add(panel);
Name = "FormContractorVacations";
StartPosition = FormStartPosition.CenterParent;
Text = "Взятые отпуска";
Load += FormContractorVacations_Load;
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
panel.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridViewData;
private Panel panel;
private Button buttonAdd;
}
}

View File

@ -0,0 +1,60 @@
using ISEbd_22_Vasin_E.D._It_Company.Repositories;
using Unity;
namespace ISEbd_22_Vasin_E.D._It_Company.Forms
{
public partial class FormContractorVacations : Form
{
private readonly IUnityContainer _container;
private readonly IContractorVacationRepository _contractorVacationRepository;
public FormContractorVacations(IUnityContainer container, IContractorVacationRepository contractorVacationRepository)
{
InitializeComponent();
_container = container ?? throw new ArgumentException(nameof(container));
_contractorVacationRepository = contractorVacationRepository ??
throw new ArgumentException(nameof(contractorVacationRepository));
}
private void FormContractorVacations_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormContractorVacation>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewData.DataSource = _contractorVacationRepository.ReadContractorVacations();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridViewData.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridViewData.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,126 @@
namespace ISEbd_22_Vasin_E.D._It_Company.Forms
{
partial class FormContractors
{
/// <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()
{
dataGridViewData = new DataGridView();
panel = new Panel();
buttonDel = new Button();
buttonUpd = new Button();
buttonAdd = new Button();
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
panel.SuspendLayout();
SuspendLayout();
//
// dataGridViewData
//
dataGridViewData.AllowUserToAddRows = false;
dataGridViewData.AllowUserToDeleteRows = false;
dataGridViewData.AllowUserToResizeColumns = false;
dataGridViewData.AllowUserToResizeRows = false;
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewData.Dock = DockStyle.Fill;
dataGridViewData.Location = new Point(0, 0);
dataGridViewData.MultiSelect = false;
dataGridViewData.Name = "dataGridViewData";
dataGridViewData.ReadOnly = true;
dataGridViewData.RowHeadersVisible = false;
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewData.Size = new Size(861, 461);
dataGridViewData.TabIndex = 7;
//
// panel
//
panel.Controls.Add(buttonDel);
panel.Controls.Add(buttonUpd);
panel.Controls.Add(buttonAdd);
panel.Dock = DockStyle.Right;
panel.Location = new Point(861, 0);
panel.Name = "panel";
panel.Size = new Size(123, 461);
panel.TabIndex = 6;
//
// buttonDel
//
buttonDel.BackgroundImage = Properties.Resources.icon_remove;
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(16, 204);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(90, 90);
buttonDel.TabIndex = 2;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += ButtonDel_Click;
//
// buttonUpd
//
buttonUpd.BackgroundImage = Properties.Resources.icon_edit;
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpd.Location = new Point(16, 108);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(90, 90);
buttonUpd.TabIndex = 1;
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += ButtonUpd_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.icon_add;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(16, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(90, 90);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// FormContractors
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(984, 461);
Controls.Add(dataGridViewData);
Controls.Add(panel);
Name = "FormContractors";
StartPosition = FormStartPosition.CenterParent;
Text = "Исполнители";
Load += FormContractors_Load;
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
panel.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridViewData;
private Panel panel;
private Button buttonDel;
private Button buttonUpd;
private Button buttonAdd;
}
}

View File

@ -0,0 +1,96 @@
using ISEbd_22_Vasin_E.D._It_Company.Repositories;
using Unity;
namespace ISEbd_22_Vasin_E.D._It_Company.Forms
{
public partial class FormContractors : Form
{
private readonly IUnityContainer _container;
private readonly IContractorRepository _contractorRepository;
public FormContractors(IUnityContainer container, IContractorRepository contractorRepository)
{
InitializeComponent();
_container = container ?? throw new ArgumentException(nameof(container));
_contractorRepository = contractorRepository ?? throw new ArgumentException(nameof(contractorRepository));
}
private void FormContractors_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormContractor>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
return;
try
{
var form = _container.Resolve<FormContractor>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
return;
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
return;
try
{
_contractorRepository.DeleteContractor(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewData.DataSource = _contractorRepository.ReadContractors();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridViewData.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridViewData.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,112 @@
namespace ISEbd_22_Vasin_E.D._It_Company.Forms
{
partial class FormContracts
{
/// <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()
{
dataGridViewData = new DataGridView();
panel = new Panel();
buttonUpd = new Button();
buttonAdd = new Button();
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
panel.SuspendLayout();
SuspendLayout();
//
// dataGridViewData
//
dataGridViewData.AllowUserToAddRows = false;
dataGridViewData.AllowUserToDeleteRows = false;
dataGridViewData.AllowUserToResizeColumns = false;
dataGridViewData.AllowUserToResizeRows = false;
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewData.Dock = DockStyle.Fill;
dataGridViewData.Location = new Point(0, 0);
dataGridViewData.MultiSelect = false;
dataGridViewData.Name = "dataGridViewData";
dataGridViewData.ReadOnly = true;
dataGridViewData.RowHeadersVisible = false;
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewData.Size = new Size(861, 461);
dataGridViewData.TabIndex = 7;
//
// panel
//
panel.Controls.Add(buttonUpd);
panel.Controls.Add(buttonAdd);
panel.Dock = DockStyle.Right;
panel.Location = new Point(861, 0);
panel.Name = "panel";
panel.Size = new Size(123, 461);
panel.TabIndex = 6;
//
// buttonUpd
//
buttonUpd.BackgroundImage = Properties.Resources.icon_edit;
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpd.Location = new Point(16, 108);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(90, 90);
buttonUpd.TabIndex = 1;
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += ButtonUpd_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.icon_add;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(16, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(90, 90);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// FormContracts
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(984, 461);
Controls.Add(dataGridViewData);
Controls.Add(panel);
Name = "FormContracts";
StartPosition = FormStartPosition.CenterParent;
Text = "Контракты";
Load += FormContracts_Load;
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
panel.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridViewData;
private Panel panel;
private Button buttonUpd;
private Button buttonAdd;
}
}

View File

@ -0,0 +1,77 @@
using ISEbd_22_Vasin_E.D._It_Company.Repositories;
using Unity;
namespace ISEbd_22_Vasin_E.D._It_Company.Forms
{
public partial class FormContracts : Form
{
private readonly IUnityContainer _container;
private readonly IContractRepository _contractRepository;
public FormContracts(IUnityContainer container, IContractRepository contractRepository)
{
InitializeComponent();
_container = container ?? throw new ArgumentException(nameof(container));
_contractRepository = contractRepository ?? throw new ArgumentException(nameof(contractRepository));
}
private void FormContracts_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormContract>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
return;
try
{
var form = _container.Resolve<FormContract>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewData.DataSource = _contractRepository.ReadContracts();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridViewData.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridViewData.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,96 @@
namespace ISEbd_22_Vasin_E.D._It_Company.Forms
{
partial class FormService
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
buttonCancel = new Button();
buttonSave = new Button();
textBoxName = new TextBox();
labelName = new Label();
SuspendLayout();
//
// buttonCancel
//
buttonCancel.Location = new Point(150, 41);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(117, 23);
buttonCancel.TabIndex = 14;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(10, 41);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(117, 23);
buttonSave.TabIndex = 13;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// textBoxName
//
textBoxName.Location = new Point(81, 12);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(186, 23);
textBoxName.TabIndex = 12;
//
// labelName
//
labelName.AutoSize = true;
labelName.Location = new Point(10, 15);
labelName.Name = "labelName";
labelName.Size = new Size(34, 15);
labelName.TabIndex = 11;
labelName.Text = "Имя:";
//
// FormService
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(284, 82);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(textBoxName);
Controls.Add(labelName);
Name = "FormService";
StartPosition = FormStartPosition.CenterParent;
Text = "Услуга";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonCancel;
private Button buttonSave;
private TextBox textBoxName;
private Label labelName;
}
}

View File

@ -0,0 +1,71 @@
using ISEbd_22_Vasin_E.D._It_Company.Entities;
using ISEbd_22_Vasin_E.D._It_Company.Repositories;
namespace ISEbd_22_Vasin_E.D._It_Company.Forms
{
public partial class FormService : Form
{
private readonly IServiceRepository _serviceRepository;
private int? _serviceId;
public int Id
{
set
{
try
{
var executor = _serviceRepository.ReadServiceById(value);
if (executor == null)
{
throw new InvalidDataException(nameof(executor));
}
textBoxName.Text = executor.Name;
_serviceId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormService(IServiceRepository serviceRepository)
{
InitializeComponent();
_serviceRepository = serviceRepository ?? throw new ArgumentNullException(nameof(serviceRepository));
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(textBoxName.Text))
{
throw new Exception("Имеются незаполненные поля");
}
if (_serviceId.HasValue)
{
_serviceRepository.UpdateService(Service.CreateEntity(_serviceId.Value,
textBoxName.Text));
}
else
{
_serviceRepository.CreateService(Service.CreateEntity(0,
textBoxName.Text));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
}
}

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,126 @@
namespace ISEbd_22_Vasin_E.D._It_Company.Forms
{
partial class FormServices
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
dataGridViewData = new DataGridView();
panel = new Panel();
buttonDel = new Button();
buttonUpd = new Button();
buttonAdd = new Button();
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
panel.SuspendLayout();
SuspendLayout();
//
// dataGridViewData
//
dataGridViewData.AllowUserToAddRows = false;
dataGridViewData.AllowUserToDeleteRows = false;
dataGridViewData.AllowUserToResizeColumns = false;
dataGridViewData.AllowUserToResizeRows = false;
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewData.Dock = DockStyle.Fill;
dataGridViewData.Location = new Point(0, 0);
dataGridViewData.MultiSelect = false;
dataGridViewData.Name = "dataGridViewData";
dataGridViewData.ReadOnly = true;
dataGridViewData.RowHeadersVisible = false;
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewData.Size = new Size(861, 461);
dataGridViewData.TabIndex = 7;
//
// panel
//
panel.Controls.Add(buttonDel);
panel.Controls.Add(buttonUpd);
panel.Controls.Add(buttonAdd);
panel.Dock = DockStyle.Right;
panel.Location = new Point(861, 0);
panel.Name = "panel";
panel.Size = new Size(123, 461);
panel.TabIndex = 6;
//
// buttonDel
//
buttonDel.BackgroundImage = Properties.Resources.icon_remove;
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(16, 204);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(90, 90);
buttonDel.TabIndex = 2;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += ButtonDel_Click;
//
// buttonUpd
//
buttonUpd.BackgroundImage = Properties.Resources.icon_edit;
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpd.Location = new Point(16, 108);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(90, 90);
buttonUpd.TabIndex = 1;
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += ButtonUpd_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.icon_add;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(16, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(90, 90);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// FormServices
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(984, 461);
Controls.Add(dataGridViewData);
Controls.Add(panel);
Name = "FormServices";
StartPosition = FormStartPosition.CenterParent;
Text = "Услуги";
Load += FormServices_Load;
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
panel.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridViewData;
private Panel panel;
private Button buttonDel;
private Button buttonUpd;
private Button buttonAdd;
}
}

View File

@ -0,0 +1,96 @@
using ISEbd_22_Vasin_E.D._It_Company.Repositories;
using Unity;
namespace ISEbd_22_Vasin_E.D._It_Company.Forms
{
public partial class FormServices : Form
{
private readonly IUnityContainer _container;
private readonly IServiceRepository _serviceRepository;
public FormServices(IUnityContainer container, IServiceRepository serviceRepository)
{
InitializeComponent();
_container = container ?? throw new ArgumentException(nameof(container));
_serviceRepository = serviceRepository ?? throw new ArgumentException(nameof(serviceRepository));
}
private void FormServices_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormService>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
return;
try
{
var form = _container.Resolve<FormService>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
return;
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
return;
try
{
_serviceRepository.DeleteService(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewData.DataSource = _serviceRepository.ReadServices();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridViewData.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridViewData.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,118 @@
namespace ISEbd_22_Vasin_E.D._It_Company.Forms
{
partial class FormVacation
{
/// <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()
{
labelStartDate = new Label();
dateTimePickerStartDate = new DateTimePicker();
dateTimePickerEndDate = new DateTimePicker();
labelEndDate = new Label();
buttonCancel = new Button();
buttonSave = new Button();
SuspendLayout();
//
// labelStartDate
//
labelStartDate.AutoSize = true;
labelStartDate.Location = new Point(12, 18);
labelStartDate.Name = "labelStartDate";
labelStartDate.Size = new Size(77, 15);
labelStartDate.TabIndex = 0;
labelStartDate.Text = "Дата начала:";
//
// dateTimePickerStartDate
//
dateTimePickerStartDate.Location = new Point(95, 12);
dateTimePickerStartDate.Name = "dateTimePickerStartDate";
dateTimePickerStartDate.Size = new Size(200, 23);
dateTimePickerStartDate.TabIndex = 1;
//
// dateTimePickerEndDate
//
dateTimePickerEndDate.Location = new Point(95, 41);
dateTimePickerEndDate.Name = "dateTimePickerEndDate";
dateTimePickerEndDate.Size = new Size(200, 23);
dateTimePickerEndDate.TabIndex = 3;
//
// labelEndDate
//
labelEndDate.AutoSize = true;
labelEndDate.Location = new Point(12, 47);
labelEndDate.Name = "labelEndDate";
labelEndDate.Size = new Size(71, 15);
labelEndDate.TabIndex = 2;
labelEndDate.Text = "Дата конца:";
//
// buttonCancel
//
buttonCancel.Location = new Point(178, 70);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(117, 23);
buttonCancel.TabIndex = 12;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(12, 70);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(117, 23);
buttonSave.TabIndex = 11;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// FormVacation
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(310, 102);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(dateTimePickerEndDate);
Controls.Add(labelEndDate);
Controls.Add(dateTimePickerStartDate);
Controls.Add(labelStartDate);
Name = "FormVacation";
StartPosition = FormStartPosition.CenterParent;
Text = "Отпуск";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelStartDate;
private DateTimePicker dateTimePickerStartDate;
private DateTimePicker dateTimePickerEndDate;
private Label labelEndDate;
private Button buttonCancel;
private Button buttonSave;
}
}

View File

@ -0,0 +1,67 @@
using ISEbd_22_Vasin_E.D._It_Company.Entities;
using ISEbd_22_Vasin_E.D._It_Company.Repositories;
namespace ISEbd_22_Vasin_E.D._It_Company.Forms
{
public partial class FormVacation : Form
{
private readonly IVacationRepository _vacationRepository;
private int? _vacationId;
public int Id
{
set
{
try
{
var vacation = _vacationRepository.ReadVacationById(value);
if (vacation == null)
{
throw new InvalidDataException(nameof(vacation));
}
dateTimePickerStartDate.Value = vacation.StartDate;
dateTimePickerEndDate.Value = vacation.EndDate;
_vacationId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormVacation(IVacationRepository vacationRepository)
{
InitializeComponent();
_vacationRepository = vacationRepository ?? throw new ArgumentNullException(nameof(vacationRepository));
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (_vacationId.HasValue)
{
_vacationRepository.UpdateVacation(Vacation.CreateEntity(_vacationId.Value,
dateTimePickerStartDate.Value, dateTimePickerEndDate.Value));
}
else
{
_vacationRepository.CreateVacation(Vacation.CreateEntity(0, dateTimePickerStartDate.Value,
dateTimePickerEndDate.Value));
}
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
}
}

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,126 @@
namespace ISEbd_22_Vasin_E.D._It_Company.Forms
{
partial class FormVacations
{
/// <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()
{
dataGridViewData = new DataGridView();
panel = new Panel();
buttonDel = new Button();
buttonUpd = new Button();
buttonAdd = new Button();
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
panel.SuspendLayout();
SuspendLayout();
//
// dataGridViewData
//
dataGridViewData.AllowUserToAddRows = false;
dataGridViewData.AllowUserToDeleteRows = false;
dataGridViewData.AllowUserToResizeColumns = false;
dataGridViewData.AllowUserToResizeRows = false;
dataGridViewData.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dataGridViewData.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridViewData.Dock = DockStyle.Fill;
dataGridViewData.Location = new Point(0, 0);
dataGridViewData.MultiSelect = false;
dataGridViewData.Name = "dataGridViewData";
dataGridViewData.ReadOnly = true;
dataGridViewData.RowHeadersVisible = false;
dataGridViewData.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridViewData.Size = new Size(861, 461);
dataGridViewData.TabIndex = 7;
//
// panel
//
panel.Controls.Add(buttonDel);
panel.Controls.Add(buttonUpd);
panel.Controls.Add(buttonAdd);
panel.Dock = DockStyle.Right;
panel.Location = new Point(861, 0);
panel.Name = "panel";
panel.Size = new Size(123, 461);
panel.TabIndex = 6;
//
// buttonDel
//
buttonDel.BackgroundImage = Properties.Resources.icon_remove;
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
buttonDel.Location = new Point(16, 204);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(90, 90);
buttonDel.TabIndex = 2;
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += ButtonDel_Click;
//
// buttonUpd
//
buttonUpd.BackgroundImage = Properties.Resources.icon_edit;
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
buttonUpd.Location = new Point(16, 108);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(90, 90);
buttonUpd.TabIndex = 1;
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += ButtonUpd_Click;
//
// buttonAdd
//
buttonAdd.BackgroundImage = Properties.Resources.icon_add;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(16, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(90, 90);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// FormVacations
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(984, 461);
Controls.Add(dataGridViewData);
Controls.Add(panel);
Name = "FormVacations";
StartPosition = FormStartPosition.CenterParent;
Text = "Отпуска";
Load += FormVacations_Load;
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
panel.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private DataGridView dataGridViewData;
private Panel panel;
private Button buttonDel;
private Button buttonUpd;
private Button buttonAdd;
}
}

View File

@ -0,0 +1,96 @@
using ISEbd_22_Vasin_E.D._It_Company.Repositories;
using Unity;
namespace ISEbd_22_Vasin_E.D._It_Company.Forms
{
public partial class FormVacations : Form
{
private readonly IUnityContainer _container;
private readonly IVacationRepository _vacationRepository;
public FormVacations(IUnityContainer container, IVacationRepository vacationRepository)
{
InitializeComponent();
_container = container ?? throw new ArgumentException(nameof(container));
_vacationRepository = vacationRepository ?? throw new ArgumentException(nameof(vacationRepository));
}
private void FormVacations_Load(object sender, EventArgs e)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
_container.Resolve<FormVacation>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
return;
try
{
var form = _container.Resolve<FormVacation>();
form.Id = findId;
form.ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
return;
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
return;
try
{
_vacationRepository.DeleteVacation(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewData.DataSource = _vacationRepository.ReadVacations();
private bool TryGetIdentifierFromSelectedRow(out int id)
{
id = 0;
if (dataGridViewData.SelectedRows.Count < 1)
{
MessageBox.Show("Нет выбранной записи", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return false;
}
id = Convert.ToInt32(dataGridViewData.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

@ -9,4 +9,8 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Unity" Version="5.11.10" />
</ItemGroup>
</Project> </Project>

View File

@ -1,3 +1,7 @@
using ISEbd_22_Vasin_E.D._It_Company;
using ISEbd_22_Vasin_E.D._It_Company.Repositories;
using Unity;
namespace ISEbd_22_Vasin_E.D._It_Company namespace ISEbd_22_Vasin_E.D._It_Company
{ {
internal static class Program internal static class Program
@ -11,7 +15,21 @@ namespace ISEbd_22_Vasin_E.D._It_Company
// To customize application configuration such as set high DPI settings or default font, // To customize application configuration such as set high DPI settings or default font,
// see https://aka.ms/applicationconfiguration. // see https://aka.ms/applicationconfiguration.
ApplicationConfiguration.Initialize(); ApplicationConfiguration.Initialize();
Application.Run(new Form1()); Application.Run(CreateContainer().Resolve<FormItCompany>());
}
private static IUnityContainer CreateContainer()
{
var container = new UnityContainer();
container.RegisterType<IClientRepository, ClientRepository>();
container.RegisterType<IContractorRepository, ContractorRepository>();
container.RegisterType<IContractorVacationRepository, ContractorVacationRepository>();
container.RegisterType<IContractRepository, ContractRepository>();
container.RegisterType<IServiceRepository, ServiceRepository>();
container.RegisterType<IVacationRepository, VacationRepository>();
return container;
} }
} }
} }

View File

@ -0,0 +1,103 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ISEbd_22_Vasin_E.D._It_Company.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("ISEbd_22_Vasin_E.D._It_Company.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 icon_add {
get {
object obj = ResourceManager.GetObject("icon-add", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icon_edit {
get {
object obj = ResourceManager.GetObject("icon-edit", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icon_remove {
get {
object obj = ResourceManager.GetObject("icon-remove", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap it_company {
get {
object obj = ResourceManager.GetObject("it-company", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
}
}

View File

@ -0,0 +1,133 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="it-company" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\it-company.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icon-edit" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icon-edit.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icon-add" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icon-add.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icon-remove" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icon-remove.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@ -0,0 +1,16 @@
using ISEbd_22_Vasin_E.D._It_Company.Entities;
namespace ISEbd_22_Vasin_E.D._It_Company.Repositories;
public interface IClientRepository
{
IEnumerable<Client> ReadClients();
Client ReadClientById(int id);
void CreateClient(Client client);
void UpdateClient(Client client);
void DeleteClient(int id);
}

View File

@ -0,0 +1,17 @@
using ISEbd_22_Vasin_E.D._It_Company.Entities;
using ISEbd_22_Vasin_E.D._It_Company.Entities.Enums;
namespace ISEbd_22_Vasin_E.D._It_Company.Repositories;
public interface IContractRepository
{
IEnumerable<Contract> ReadContracts(int? clientId = null, int? contractorId = null, int? amountFrom = null,
int? amountTo = null, DateTime? deadlineFrom = null, DateTime? deadlineTo = null,
Status? status = null, ContractType? contractType = null);
Contract ReadContractById(int id);
void CreateContract(Contract contract);
void UpdateContract(Contract contract);
}

View File

@ -0,0 +1,16 @@
using ISEbd_22_Vasin_E.D._It_Company.Entities;
namespace ISEbd_22_Vasin_E.D._It_Company.Repositories;
public interface IContractorRepository
{
IEnumerable<Contractor> ReadContractors();
Contractor ReadContractorById(int id);
void CreateContractor(Contractor contractor);
void UpdateContractor(Contractor contractor);
void DeleteContractor(int id);
}

View File

@ -0,0 +1,11 @@
using ISEbd_22_Vasin_E.D._It_Company.Entities;
namespace ISEbd_22_Vasin_E.D._It_Company.Repositories;
public interface IContractorVacationRepository
{
IEnumerable<ContractorVacation> ReadContractorVacations(int? contractorId = null,
int? vacationId = null);
void CreateContractorVacation(ContractorVacation contractorVacation);
}

View File

@ -0,0 +1,16 @@
using ISEbd_22_Vasin_E.D._It_Company.Entities;
namespace ISEbd_22_Vasin_E.D._It_Company.Repositories;
public interface IServiceRepository
{
IEnumerable<Service> ReadServices();
Service ReadServiceById(int id);
void CreateService(Service service);
void UpdateService(Service service);
void DeleteService(int id);
}

View File

@ -0,0 +1,16 @@
using ISEbd_22_Vasin_E.D._It_Company.Entities;
namespace ISEbd_22_Vasin_E.D._It_Company.Repositories;
public interface IVacationRepository
{
IEnumerable<Vacation> ReadVacations();
Vacation ReadVacationById(int id);
void CreateVacation(Vacation vacation);
void UpdateVacation(Vacation vacation);
void DeleteVacation(int id);
}

View File

@ -0,0 +1,28 @@
using ISEbd_22_Vasin_E.D._It_Company.Entities;
namespace ISEbd_22_Vasin_E.D._It_Company.Repositories;
public class ClientRepository : IClientRepository
{
public void CreateClient(Client client)
{
}
public void DeleteClient(int id)
{
}
public Client ReadClientById(int id)
{
return Client.CreateEntity(0, string.Empty);
}
public IEnumerable<Client> ReadClients()
{
return [];
}
public void UpdateClient(Client client)
{
}
}

View File

@ -0,0 +1,27 @@
using ISEbd_22_Vasin_E.D._It_Company.Entities;
using ISEbd_22_Vasin_E.D._It_Company.Entities.Enums;
namespace ISEbd_22_Vasin_E.D._It_Company.Repositories;
public class ContractRepository : IContractRepository
{
public void CreateContract(Contract contract)
{
}
public Contract ReadContractById(int id)
{
return Contract.CreateEntity(0, 0, 0, 0, DateTime.Now, Entities.Enums.Status.None, Entities.Enums.ContractType.None, []);
}
public IEnumerable<Contract> ReadContracts(int? clientId = null, int? contractorId = null, int? amountFrom = null,
int? amountTo = null, DateTime? deadlineFrom = null, DateTime? deadlineTo = null,
Status? status = null, ContractType? contractType = null)
{
return [];
}
public void UpdateContract(Contract contract)
{
}
}

View File

@ -0,0 +1,28 @@
using ISEbd_22_Vasin_E.D._It_Company.Entities;
namespace ISEbd_22_Vasin_E.D._It_Company.Repositories;
public class ContractorRepository : IContractorRepository
{
public void CreateContractor(Contractor contractor)
{
}
public void DeleteContractor(int id)
{
}
public Contractor ReadContractorById(int id)
{
return Contractor.CreateEntity(0, string.Empty);
}
public IEnumerable<Contractor> ReadContractors()
{
return [];
}
public void UpdateContractor(Contractor contractor)
{
}
}

View File

@ -0,0 +1,16 @@
using ISEbd_22_Vasin_E.D._It_Company.Entities;
namespace ISEbd_22_Vasin_E.D._It_Company.Repositories;
public class ContractorVacationRepository : IContractorVacationRepository
{
public void CreateContractorVacation(ContractorVacation contractorVacation)
{
}
public IEnumerable<ContractorVacation> ReadContractorVacations(int? contractorId = null,
int? vacationId = null)
{
return [];
}
}

View File

@ -0,0 +1,28 @@
using ISEbd_22_Vasin_E.D._It_Company.Entities;
namespace ISEbd_22_Vasin_E.D._It_Company.Repositories;
public class ServiceRepository : IServiceRepository
{
public void CreateService(Service service)
{
}
public void DeleteService(int id)
{
}
public Service ReadServiceById(int id)
{
return Service.CreateEntity(0, string.Empty);
}
public IEnumerable<Service> ReadServices()
{
return [];
}
public void UpdateService(Service service)
{
}
}

View File

@ -0,0 +1,28 @@
using ISEbd_22_Vasin_E.D._It_Company.Entities;
namespace ISEbd_22_Vasin_E.D._It_Company.Repositories;
public class VacationRepository : IVacationRepository
{
public void CreateVacation(Vacation vacation)
{
}
public void DeleteVacation(int id)
{
}
public Vacation ReadVacationById(int id)
{
return Vacation.CreateEntity(0, DateTime.Now, DateTime.Now);
}
public IEnumerable<Vacation> ReadVacations()
{
return [];
}
public void UpdateVacation(Vacation vacation)
{
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 KiB