add full logic, missed few forms

This commit is contained in:
Ivan Gutorov 2024-11-11 11:02:06 +04:00
parent 714dcec5b7
commit e5f4eda60a
47 changed files with 2593 additions and 69 deletions

View File

@ -0,0 +1,34 @@
using PIbd_23_Gutorov_I.A._IT_Company.Entities.Enums;
namespace PIbd_23_Gutorov_I.A._IT_Company.Entities;
public class Contract
{
public int Id { get; private set; }
public int CustomerID { get; private set; }
public int ExecutorID { get; private set; }
public ContractCategory Category { get; private set; }
public DateTime ConclusionDate { get; private set; }
public DateTime Deadline { get; private set; }
public int PaymentAmount { get; private set; }
public static Contract CreateEntity(int id, int customerID, int executorID, ContractCategory category, DateTime deadline, int paymentAmount)
{
return new Contract
{
Id = id,
CustomerID = customerID,
ExecutorID = executorID,
Category = category,
ConclusionDate = DateTime.Now,
Deadline = deadline,
PaymentAmount = paymentAmount
};
}
}

View File

@ -0,0 +1,23 @@
namespace PIbd_23_Gutorov_I.A._IT_Company.Entities;
public class Customer
{
public int Id { get; private set; }
public string Name { get; private set; } = string.Empty;
public string Contact { get; private set; } = string.Empty;
public string Address { get; private set; } = string.Empty;
public static Customer CreateEntity(int id, string name, string contact, string address)
{
return new Customer
{
Id = id,
Name = name ?? String.Empty,
Contact = contact ?? String.Empty,
Address = address ?? String.Empty
};
}
}

View File

@ -0,0 +1,26 @@
namespace PIbd_23_Gutorov_I.A._IT_Company.Entities;
public class CustomerContractReview
{
public int Id { get; private set; }
public int CustomerId { get; private set; }
public int ContractId { get; private set; }
public string Review { get; private set; } = string.Empty;
public int Grade { get; private set; }
public static CustomerContractReview CreateElement(int id, int customerId, int contractId, string review, int grade)
{
return new CustomerContractReview
{
Id = id,
CustomerId = customerId,
ContractId = contractId,
Review = review ?? String.Empty,
Grade = grade
};
}
}

View File

@ -0,0 +1,11 @@
namespace PIbd_23_Gutorov_I.A._IT_Company.Entities.Enums;
[Flags]
public enum ContractCategory
{
None = 0,
Support = 1,
Development = 2
}

View File

@ -0,0 +1,14 @@
namespace PIbd_23_Gutorov_I.A._IT_Company.Entities.Enums;
public enum ExecutorPost
{
None = 0,
Junior = 1,
Middle = 2,
Senior = 3,
TeamLead = 4
}

View File

@ -0,0 +1,22 @@
using PIbd_23_Gutorov_I.A._IT_Company.Entities.Enums;
namespace PIbd_23_Gutorov_I.A._IT_Company.Entities;
public class Executor
{
public int Id { get; private set; }
public string Name { get; private set; } = string.Empty;
public ExecutorPost Post { get; private set; }
public static Executor CreateEntity(int id, string name, ExecutorPost post)
{
return new Executor
{
Id = id,
Name = name ?? String.Empty,
Post = post
};
}
}

View File

@ -0,0 +1,20 @@
namespace PIbd_23_Gutorov_I.A._IT_Company.Entities;
public class Service
{
public int Id { get; private set; }
public string Description { get; private set; } = string.Empty;
public int ContractId { get; private set; }
public static Service CreateEntity(int id, string description, int contractId)
{
return new Service
{
Id = id,
Description = description,
ContractId = contractId
};
}
}

View File

@ -0,0 +1,29 @@
namespace PIbd_23_Gutorov_I.A._IT_Company.Entities;
public class ServiceExecution
{
public int Id { get; private set; }
public int ContractId { get; private set; }
public int ServiceId { get; private set; }
public int ExecutorId { get; private set; }
public int Completion { get; private set; }
public DateTime Deadline { get; private set; }
public static ServiceExecution CreateOperation(int id, int contractId, int serviceId, int executorId, int completion, DateTime deadline)
{
return new ServiceExecution
{
Id = id,
ContractId = contractId,
ServiceId = serviceId,
ExecutorId = executorId,
Completion = completion,
Deadline = deadline
};
}
}

View File

@ -1,39 +0,0 @@
namespace PIbd_23_Gutorov_I.A._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

@ -0,0 +1,140 @@
namespace PIbd_23_Gutorov_I.A._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();
справочникиToolStripMenuItem = new ToolStripMenuItem();
заказчикиToolStripMenuItem = new ToolStripMenuItem();
исполнителиToolStripMenuItem = new ToolStripMenuItem();
услугиToolStripMenuItem = new ToolStripMenuItem();
контрактыToolStripMenuItem = new ToolStripMenuItem();
операцииToolStripMenuItem = new ToolStripMenuItem();
выполнениеУслугиToolStripMenuItem = new ToolStripMenuItem();
отзывыКлиентовToolStripMenuItem = new ToolStripMenuItem();
отчетыToolStripMenuItem = new ToolStripMenuItem();
menuStrip.SuspendLayout();
SuspendLayout();
//
// menuStrip
//
menuStrip.Items.AddRange(new ToolStripItem[] { справочникиToolStripMenuItem, операцииToolStripMenuItem, отчетыToolStripMenuItem });
menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip";
menuStrip.Size = new Size(734, 24);
menuStrip.TabIndex = 0;
menuStrip.Text = "menuStrip1";
//
// справочникиToolStripMenuItem
//
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { заказчикиToolStripMenuItem, исполнителиToolStripMenuItem, услугиToolStripMenuItem, контрактыToolStripMenuItem });
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
справочникиToolStripMenuItem.Size = new Size(94, 20);
справочникиToolStripMenuItem.Text = "Справочники";
//
// заказчикиToolStripMenuItem
//
заказчикиToolStripMenuItem.Name = аказчикиToolStripMenuItem";
заказчикиToolStripMenuItem.Size = new Size(149, 22);
заказчикиToolStripMenuItem.Text = "Заказчики";
//
// исполнителиToolStripMenuItem
//
исполнителиToolStripMenuItem.Name = сполнителиToolStripMenuItem";
исполнителиToolStripMenuItem.Size = new Size(149, 22);
исполнителиToolStripMenuItem.Text = "Исполнители";
//
// услугиToolStripMenuItem
//
услугиToolStripMenuItem.Name = "услугиToolStripMenuItem";
услугиToolStripMenuItem.Size = new Size(149, 22);
услугиToolStripMenuItem.Text = "Услуги";
//
// контрактыToolStripMenuItem
//
контрактыToolStripMenuItem.Name = онтрактыToolStripMenuItem";
контрактыToolStripMenuItem.Size = new Size(149, 22);
контрактыToolStripMenuItem.Text = "Контракты";
//
// операцииToolStripMenuItem
//
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { выполнениеУслугиToolStripMenuItem, отзывыКлиентовToolStripMenuItem });
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
операцииToolStripMenuItem.Size = new Size(75, 20);
операцииToolStripMenuItem.Text = "Операции";
//
// выполнениеУслугиToolStripMenuItem
//
выполнениеУслугиToolStripMenuItem.Name = "выполнениеУслугиToolStripMenuItem";
выполнениеУслугиToolStripMenuItem.Size = new Size(184, 22);
выполнениеУслугиToolStripMenuItem.Text = "Выполнение услуги";
//
// отзывыКлиентовToolStripMenuItem
//
отзывыКлиентовToolStripMenuItem.Name = "отзывыКлиентовToolStripMenuItem";
отзывыКлиентовToolStripMenuItem.Size = new Size(184, 22);
отзывыКлиентовToolStripMenuItem.Text = "Отзывы заказчиков";
//
// отчетыToolStripMenuItem
//
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
отчетыToolStripMenuItem.Size = new Size(60, 20);
отчетыToolStripMenuItem.Text = "Отчеты";
//
// FormItCompany
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
BackgroundImage = Properties.Resources.modern_equipped_computer_lab;
BackgroundImageLayout = ImageLayout.Stretch;
ClientSize = new Size(734, 461);
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 справочникиToolStripMenuItem;
private ToolStripMenuItem заказчикиToolStripMenuItem;
private ToolStripMenuItem исполнителиToolStripMenuItem;
private ToolStripMenuItem услугиToolStripMenuItem;
private ToolStripMenuItem контрактыToolStripMenuItem;
private ToolStripMenuItem операцииToolStripMenuItem;
private ToolStripMenuItem отчетыToolStripMenuItem;
private ToolStripMenuItem выполнениеУслугиToolStripMenuItem;
private ToolStripMenuItem отзывыКлиентовToolStripMenuItem;
}
}

View File

@ -1,8 +1,8 @@
namespace PIbd_23_Gutorov_I.A._IT_Company namespace PIbd_23_Gutorov_I.A._IT_Company
{ {
public partial class Form1 : Form public partial class FormItCompany : Form
{ {
public Form1() public FormItCompany()
{ {
InitializeComponent(); InitializeComponent();
} }

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,190 @@
namespace PIbd_23_Gutorov_I.A._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()
{
checkedListBoxContractCategory = new CheckedListBox();
dateTimePickerContractDeadline = new DateTimePicker();
numericUpDownContractPaymentAmount = new NumericUpDown();
buttonCancel = new Button();
buttonSave = new Button();
labelContractCustomerId = new Label();
labelContractExecutorId = new Label();
labelContractCategory = new Label();
comboBoxContractCustomerId = new ComboBox();
comboBoxContractExecutorId = new ComboBox();
labelContractDeadline = new Label();
labelContractPaymentAmount = new Label();
((System.ComponentModel.ISupportInitialize)numericUpDownContractPaymentAmount).BeginInit();
SuspendLayout();
//
// checkedListBoxContractCategory
//
checkedListBoxContractCategory.FormattingEnabled = true;
checkedListBoxContractCategory.Location = new Point(169, 64);
checkedListBoxContractCategory.Name = "checkedListBoxContractCategory";
checkedListBoxContractCategory.Size = new Size(202, 40);
checkedListBoxContractCategory.TabIndex = 0;
//
// dateTimePickerContractDeadline
//
dateTimePickerContractDeadline.Location = new Point(169, 110);
dateTimePickerContractDeadline.Name = "dateTimePickerContractDeadline";
dateTimePickerContractDeadline.Size = new Size(202, 23);
dateTimePickerContractDeadline.TabIndex = 1;
//
// numericUpDownContractPaymentAmount
//
numericUpDownContractPaymentAmount.Location = new Point(169, 139);
numericUpDownContractPaymentAmount.Name = "numericUpDownContractPaymentAmount";
numericUpDownContractPaymentAmount.Size = new Size(202, 23);
numericUpDownContractPaymentAmount.TabIndex = 2;
//
// buttonCancel
//
buttonCancel.Location = new Point(12, 197);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(358, 23);
buttonCancel.TabIndex = 9;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(12, 168);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(358, 23);
buttonSave.TabIndex = 8;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// labelContractCustomerId
//
labelContractCustomerId.AutoSize = true;
labelContractCustomerId.Location = new Point(12, 9);
labelContractCustomerId.Name = "labelContractCustomerId";
labelContractCustomerId.Size = new Size(60, 15);
labelContractCustomerId.TabIndex = 10;
labelContractCustomerId.Text = "Заказчик:";
//
// labelContractExecutorId
//
labelContractExecutorId.AutoSize = true;
labelContractExecutorId.Location = new Point(12, 38);
labelContractExecutorId.Name = "labelContractExecutorId";
labelContractExecutorId.Size = new Size(84, 15);
labelContractExecutorId.TabIndex = 11;
labelContractExecutorId.Text = "Исполнитель:";
//
// labelContractCategory
//
labelContractCategory.AutoSize = true;
labelContractCategory.Location = new Point(12, 64);
labelContractCategory.Name = "labelContractCategory";
labelContractCategory.Size = new Size(66, 15);
labelContractCategory.TabIndex = 12;
labelContractCategory.Text = "Категория:";
//
// comboBoxContractCustomerId
//
comboBoxContractCustomerId.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxContractCustomerId.FormattingEnabled = true;
comboBoxContractCustomerId.Location = new Point(169, 6);
comboBoxContractCustomerId.Name = "comboBoxContractCustomerId";
comboBoxContractCustomerId.Size = new Size(202, 23);
comboBoxContractCustomerId.TabIndex = 13;
//
// comboBoxContractExecutorId
//
comboBoxContractExecutorId.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxContractExecutorId.FormattingEnabled = true;
comboBoxContractExecutorId.Location = new Point(169, 35);
comboBoxContractExecutorId.Name = "comboBoxContractExecutorId";
comboBoxContractExecutorId.Size = new Size(202, 23);
comboBoxContractExecutorId.TabIndex = 14;
//
// labelContractDeadline
//
labelContractDeadline.AutoSize = true;
labelContractDeadline.Location = new Point(12, 116);
labelContractDeadline.Name = "labelContractDeadline";
labelContractDeadline.Size = new Size(110, 15);
labelContractDeadline.TabIndex = 15;
labelContractDeadline.Text = "Срок выполнения:";
//
// labelContractPaymentAmount
//
labelContractPaymentAmount.AutoSize = true;
labelContractPaymentAmount.Location = new Point(12, 141);
labelContractPaymentAmount.Name = "labelContractPaymentAmount";
labelContractPaymentAmount.Size = new Size(97, 15);
labelContractPaymentAmount.TabIndex = 16;
labelContractPaymentAmount.Text = "Сумма платежа:";
//
// FormContract
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(382, 231);
Controls.Add(labelContractPaymentAmount);
Controls.Add(labelContractDeadline);
Controls.Add(comboBoxContractExecutorId);
Controls.Add(comboBoxContractCustomerId);
Controls.Add(labelContractCategory);
Controls.Add(labelContractExecutorId);
Controls.Add(labelContractCustomerId);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(numericUpDownContractPaymentAmount);
Controls.Add(dateTimePickerContractDeadline);
Controls.Add(checkedListBoxContractCategory);
Name = "FormContract";
Text = "Контракт";
((System.ComponentModel.ISupportInitialize)numericUpDownContractPaymentAmount).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private CheckedListBox checkedListBoxContractCategory;
private DateTimePicker dateTimePickerContractDeadline;
private NumericUpDown numericUpDownContractPaymentAmount;
private Button buttonCancel;
private Button buttonSave;
private Label labelContractCustomerId;
private Label labelContractExecutorId;
private Label labelContractCategory;
private ComboBox comboBoxContractCustomerId;
private ComboBox comboBoxContractExecutorId;
private Label labelContractDeadline;
private Label labelContractPaymentAmount;
}
}

View File

@ -0,0 +1,87 @@
using PIbd_23_Gutorov_I.A._IT_Company.Entities;
using PIbd_23_Gutorov_I.A._IT_Company.Entities.Enums;
using PIbd_23_Gutorov_I.A._IT_Company.Repositories;
namespace PIbd_23_Gutorov_I.A._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));
foreach (ContractCategory elem in Enum.GetValues(typeof(ContractCategory)))
{
if ((elem & contract.Category) != 0)
{
checkedListBoxContractCategory.SetItemChecked(checkedListBoxContractCategory.Items.IndexOf(elem), true);
}
}
dateTimePickerContractDeadline.Value = contract.Deadline;
numericUpDownContractPaymentAmount.Value = contract.PaymentAmount;
_contractId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormContract(IContractRepository contractRepository)
{
InitializeComponent();
_contractRepository = contractRepository ?? throw new ArgumentNullException(nameof(contractRepository));
foreach (var elem in Enum.GetValues(typeof(ContractCategory)))
{
checkedListBoxContractCategory.Items.Add(elem);
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(textBoxCustomerName.Text) ||
string.IsNullOrEmpty(textBoxCustomerContact.Text) ||
string.IsNullOrEmpty(textBoxCustomerAddress.Text))
{
throw new Exception("Имеются незаполненные поля");
}
if (_contractId.HasValue) _contractRepository.UpdateContract(CreateContract(_contractId.Value));
else _contractRepository.UpdateContract(CreateContract(0));
}
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)
{
ContractCategory contractCategory = ContractCategory.None;
foreach (var elem in checkedListBoxContractCategory.CheckedItems)
{
contractCategory |= (ContractCategory)elem;
}
return Contract.CreateEntity(id)
}
}
}

View File

@ -0,0 +1,140 @@
namespace PIbd_23_Gutorov_I.A._IT_Company.Forms
{
partial class FormCustomer
{
/// <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()
{
labelCustomerName = new Label();
labelCustomerContact = new Label();
labelCustomerAddress = new Label();
textBoxCustomerName = new TextBox();
textBoxCustomerContact = new TextBox();
textBoxCustomerAddress = new TextBox();
buttonSave = new Button();
buttonCancel = new Button();
SuspendLayout();
//
// labelCustomerName
//
labelCustomerName.AutoSize = true;
labelCustomerName.Location = new Point(12, 9);
labelCustomerName.Name = "labelCustomerName";
labelCustomerName.Size = new Size(34, 15);
labelCustomerName.TabIndex = 0;
labelCustomerName.Text = "Имя:";
//
// labelCustomerContact
//
labelCustomerContact.AutoSize = true;
labelCustomerContact.Location = new Point(12, 38);
labelCustomerContact.Name = "labelCustomerContact";
labelCustomerContact.Size = new Size(107, 15);
labelCustomerContact.TabIndex = 1;
labelCustomerContact.Text = "Контактная почта:";
//
// labelCustomerAddress
//
labelCustomerAddress.AutoSize = true;
labelCustomerAddress.Location = new Point(12, 67);
labelCustomerAddress.Name = "labelCustomerAddress";
labelCustomerAddress.Size = new Size(43, 15);
labelCustomerAddress.TabIndex = 2;
labelCustomerAddress.Text = "Адрес:";
//
// textBoxCustomerName
//
textBoxCustomerName.Location = new Point(125, 6);
textBoxCustomerName.Name = "textBoxCustomerName";
textBoxCustomerName.Size = new Size(168, 23);
textBoxCustomerName.TabIndex = 3;
//
// textBoxCustomerContact
//
textBoxCustomerContact.Location = new Point(125, 35);
textBoxCustomerContact.Name = "textBoxCustomerContact";
textBoxCustomerContact.Size = new Size(168, 23);
textBoxCustomerContact.TabIndex = 4;
//
// textBoxCustomerAddress
//
textBoxCustomerAddress.Location = new Point(125, 64);
textBoxCustomerAddress.Name = "textBoxCustomerAddress";
textBoxCustomerAddress.Size = new Size(168, 23);
textBoxCustomerAddress.TabIndex = 5;
//
// buttonSave
//
buttonSave.Location = new Point(12, 93);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(281, 23);
buttonSave.TabIndex = 6;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(12, 122);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(281, 23);
buttonCancel.TabIndex = 7;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// FormCustomer
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(309, 159);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(textBoxCustomerAddress);
Controls.Add(textBoxCustomerContact);
Controls.Add(textBoxCustomerName);
Controls.Add(labelCustomerAddress);
Controls.Add(labelCustomerContact);
Controls.Add(labelCustomerName);
Name = "FormCustomer";
StartPosition = FormStartPosition.CenterParent;
Text = "Заказчик";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelCustomerName;
private Label labelCustomerContact;
private Label labelCustomerAddress;
private TextBox textBoxCustomerName;
private TextBox textBoxCustomerContact;
private TextBox textBoxCustomerAddress;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,66 @@
using PIbd_23_Gutorov_I.A._IT_Company.Entities;
using PIbd_23_Gutorov_I.A._IT_Company.Repositories;
namespace PIbd_23_Gutorov_I.A._IT_Company.Forms
{
public partial class FormCustomer : Form
{
private readonly ICustomerRepository _customerRepository;
private int? _customerId;
public int Id
{
set
{
try
{
var customer = _customerRepository.ReadCustomerById(value);
if (customer == null) throw new InvalidDataException(nameof(customer));
textBoxCustomerName.Text = customer.Name;
textBoxCustomerContact.Text = customer.Contact;
textBoxCustomerAddress.Text = customer.Address;
_customerId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormCustomer(ICustomerRepository customerRepository)
{
InitializeComponent();
_customerRepository = customerRepository ?? throw new ArgumentNullException(nameof(customerRepository));
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(textBoxCustomerName.Text) ||
string.IsNullOrEmpty(textBoxCustomerContact.Text) ||
string.IsNullOrEmpty(textBoxCustomerAddress.Text))
{
throw new Exception("Имеются незаполненные поля");
}
if (_customerId.HasValue) _customerRepository.UpdateCustomer(CreateCustomer(_customerId.Value));
else _customerRepository.UpdateCustomer(CreateCustomer(0));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
private Customer CreateCustomer(int id) => Customer.CreateEntity(
id, textBoxCustomerName.Text, textBoxCustomerContact.Text,
textBoxCustomerAddress.Text);
}
}

View File

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

View File

@ -0,0 +1,126 @@
namespace PIbd_23_Gutorov_I.A._IT_Company.Forms
{
partial class FormCustomers
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
panel = new Panel();
buttonDel = new Button();
buttonUpd = new Button();
buttonAdd = new Button();
dataGridViewData = new DataGridView();
panel.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridViewData).BeginInit();
SuspendLayout();
//
// panel
//
panel.Controls.Add(buttonDel);
panel.Controls.Add(buttonUpd);
panel.Controls.Add(buttonAdd);
panel.Dock = DockStyle.Right;
panel.Location = new Point(677, 0);
panel.Name = "panel";
panel.Size = new Size(123, 450);
panel.TabIndex = 0;
//
// buttonDel
//
buttonDel.BackgroundImage = Properties.Resources.icon_remove_button;
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_button;
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_button;
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;
//
// 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(677, 450);
dataGridViewData.TabIndex = 1;
//
// FormCustomers
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(dataGridViewData);
Controls.Add(panel);
Name = "FormCustomers";
StartPosition = FormStartPosition.CenterParent;
Text = "Заказчики";
Load += FormCustomers_Load;
panel.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridViewData).EndInit();
ResumeLayout(false);
}
#endregion
private Panel panel;
private Button buttonAdd;
private Button buttonDel;
private Button buttonUpd;
private DataGridView dataGridViewData;
}
}

View File

@ -0,0 +1,96 @@
using PIbd_23_Gutorov_I.A._IT_Company.Repositories;
using Unity;
namespace PIbd_23_Gutorov_I.A._IT_Company.Forms
{
public partial class FormCustomers : Form
{
private readonly IUnityContainer _container;
private readonly ICustomerRepository _customerRepository;
public FormCustomers(IUnityContainer container, ICustomerRepository customerRepository)
{
InitializeComponent();
_container = container ?? throw new ArgumentException(nameof(container));
_customerRepository = customerRepository ?? throw new ArgumentException(nameof(customerRepository));
}
private void FormCustomers_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<FormCustomer>().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<FormCustomer>();
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
{
_customerRepository.DeleteCustomer(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewData.DataSource = _customerRepository.ReadCustomers();
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,119 @@
namespace PIbd_23_Gutorov_I.A._IT_Company.Forms
{
partial class FormExecutor
{
/// <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()
{
comboBoxExecutorPost = new ComboBox();
LabelExecutorName = new Label();
labelExecutorPost = new Label();
textBoxExecutorName = new TextBox();
buttonSave = new Button();
buttonCancel = new Button();
SuspendLayout();
//
// comboBoxExecutorPost
//
comboBoxExecutorPost.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxExecutorPost.FormattingEnabled = true;
comboBoxExecutorPost.Location = new Point(101, 41);
comboBoxExecutorPost.Name = "comboBoxExecutorPost";
comboBoxExecutorPost.Size = new Size(168, 23);
comboBoxExecutorPost.TabIndex = 0;
//
// LabelExecutorName
//
LabelExecutorName.AutoSize = true;
LabelExecutorName.Location = new Point(12, 15);
LabelExecutorName.Name = "LabelExecutorName";
LabelExecutorName.Size = new Size(34, 15);
LabelExecutorName.TabIndex = 1;
LabelExecutorName.Text = "Имя:";
//
// labelExecutorPost
//
labelExecutorPost.AutoSize = true;
labelExecutorPost.Location = new Point(12, 44);
labelExecutorPost.Name = "labelExecutorPost";
labelExecutorPost.Size = new Size(72, 15);
labelExecutorPost.TabIndex = 2;
labelExecutorPost.Text = "Должность:";
//
// textBoxExecutorName
//
textBoxExecutorName.Location = new Point(101, 12);
textBoxExecutorName.Name = "textBoxExecutorName";
textBoxExecutorName.Size = new Size(168, 23);
textBoxExecutorName.TabIndex = 4;
//
// buttonSave
//
buttonSave.Location = new Point(12, 70);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(257, 23);
buttonSave.TabIndex = 7;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(12, 99);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(257, 23);
buttonCancel.TabIndex = 8;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// FormExecutor
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(281, 133);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(textBoxExecutorName);
Controls.Add(labelExecutorPost);
Controls.Add(LabelExecutorName);
Controls.Add(comboBoxExecutorPost);
Name = "FormExecutor";
Text = "FormExecutor";
ResumeLayout(false);
PerformLayout();
}
#endregion
private ComboBox comboBoxExecutorPost;
private Label LabelExecutorName;
private Label labelExecutorPost;
private TextBox textBoxExecutorName;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,66 @@
using PIbd_23_Gutorov_I.A._IT_Company.Entities;
using PIbd_23_Gutorov_I.A._IT_Company.Entities.Enums;
using PIbd_23_Gutorov_I.A._IT_Company.Repositories;
namespace PIbd_23_Gutorov_I.A._IT_Company.Forms
{
public partial class FormExecutor : Form
{
private readonly IExecutorRepository _executorRepository;
private int? _executorId;
public int Id
{
set
{
try
{
var executor = _executorRepository.ReadExecutorById(value);
if (executor == null) throw new InvalidDataException(nameof(executor));
textBoxExecutorName.Text = executor.Name;
comboBoxExecutorPost.SelectedItem = executor.Post;
_executorId = value;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
}
}
public FormExecutor(IExecutorRepository executorRepository)
{
InitializeComponent();
_executorRepository = executorRepository ?? throw new ArgumentNullException(nameof(executorRepository));
comboBoxExecutorPost.DataSource = Enum.GetValues(typeof(ExecutorPost));
}
private void ButtonSave_Click(object sender, EventArgs e)
{
try
{
if (string.IsNullOrEmpty(textBoxExecutorName.Text) ||
comboBoxExecutorPost.SelectedIndex < 1)
{
throw new Exception("Имеются незаполненные поля");
}
if (_executorId.HasValue) _executorRepository.UpdateExecutor(CreateExecutor(_executorId.Value));
else _executorRepository.UpdateExecutor(CreateExecutor(0));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
private Executor CreateExecutor(int id) =>
Executor.CreateEntity(id, textBoxExecutorName.Text, (ExecutorPost)comboBoxExecutorPost.SelectedItem!);
}
}

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,125 @@
namespace PIbd_23_Gutorov_I.A._IT_Company.Forms
{
partial class FormExecutors
{
/// <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(677, 450);
dataGridViewData.TabIndex = 3;
//
// panel
//
panel.Controls.Add(buttonDel);
panel.Controls.Add(buttonUpd);
panel.Controls.Add(buttonAdd);
panel.Dock = DockStyle.Right;
panel.Location = new Point(677, 0);
panel.Name = "panel";
panel.Size = new Size(123, 450);
panel.TabIndex = 2;
//
// buttonDel
//
buttonDel.BackgroundImage = Properties.Resources.icon_remove_button;
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_button;
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_button;
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;
//
// FormExecutors
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(800, 450);
Controls.Add(dataGridViewData);
Controls.Add(panel);
Name = "FormExecutors";
Text = "FormExecutors";
Load += FormExecutors_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,107 @@
using PIbd_23_Gutorov_I.A._IT_Company.Repositories;
using PIbd_23_Gutorov_I.A._IT_Company.Repositories.Implementations;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
using Unity;
namespace PIbd_23_Gutorov_I.A._IT_Company.Forms
{
public partial class FormExecutors : Form
{
private readonly IUnityContainer _container;
private readonly IExecutorRepository _executorRepository;
public FormExecutors(IUnityContainer container, IExecutorRepository executorRepository)
{
InitializeComponent();
_container = container ?? throw new ArgumentException(nameof(container));
_executorRepository = executorRepository ?? throw new ArgumentException(nameof(executorRepository));
}
private void FormExecutors_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<FormExecutor>().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<FormExecutor>();
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
{
_executorRepository.DeleteExecutor(findId);
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadList() => dataGridViewData.DataSource = _executorRepository.ReadExecutors();
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,23 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Unity" Version="5.11.10" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
</Project> </Project>

View File

@ -1,3 +1,7 @@
using PIbd_23_Gutorov_I.A._IT_Company.Repositories;
using PIbd_23_Gutorov_I.A._IT_Company.Repositories.Implementations;
using Unity;
namespace PIbd_23_Gutorov_I.A._IT_Company namespace PIbd_23_Gutorov_I.A._IT_Company
{ {
internal static class Program internal static class Program
@ -11,7 +15,21 @@ namespace PIbd_23_Gutorov_I.A._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<IContractRepository, ContractRepository>();
container.RegisterType<ICustomerContractReviewRepository, CustomerContractReviewRepository>();
container.RegisterType<ICustomerRepository, CustomerRepository>();
container.RegisterType<IExecutorRepository, ExecutorRepository>();
container.RegisterType<IServiceExecutionRepository, ServiceExecutionRepository>();
container.RegisterType<IServiceRepository, ServiceRepository>();
return container;
} }
} }
} }

View File

@ -0,0 +1,103 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
// Исполняемая версия:4.0.30319.42000
//
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
// повторной генерации кода.
// </auto-generated>
//------------------------------------------------------------------------------
namespace PIbd_23_Gutorov_I.A._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("PIbd_23_Gutorov_I.A._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_button {
get {
object obj = ResourceManager.GetObject("icon-add-button", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icon_edit_button {
get {
object obj = ResourceManager.GetObject("icon-edit-button", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap icon_remove_button {
get {
object obj = ResourceManager.GetObject("icon-remove-button", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap modern_equipped_computer_lab {
get {
object obj = ResourceManager.GetObject("modern-equipped-computer-lab", 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="modern-equipped-computer-lab" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\modern-equipped-computer-lab.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icon-add-button" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icon-add-button.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icon-edit-button" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icon-edit-button.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="icon-remove-button" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\icon-remove-button.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 PIbd_23_Gutorov_I.A._IT_Company.Entities;
namespace PIbd_23_Gutorov_I.A._IT_Company.Repositories;
public interface IContractRepository
{
IEnumerable<Contract> ReadContracts(DateTime? dateFrom = null, DateTime? dateTo = null, int? customerId = null, int? executorId = null);
Contract ReadContractById(int id);
void CreateContract(Contract Contract);
void UpdateContract(Contract Contract);
void DeleteContract(int id);
}

View File

@ -0,0 +1,12 @@
using PIbd_23_Gutorov_I.A._IT_Company.Entities;
namespace PIbd_23_Gutorov_I.A._IT_Company.Repositories;
public interface ICustomerContractReviewRepository
{
IEnumerable<CustomerContractReview> ReadCustomerContractReviews(int? customerId = null);
CustomerContractReview ReadCustomerContractReviewById(int id);
void CreateCustomerContractReview(CustomerContractReview CustomerContractReview);
}

View File

@ -0,0 +1,16 @@
using PIbd_23_Gutorov_I.A._IT_Company.Entities;
namespace PIbd_23_Gutorov_I.A._IT_Company.Repositories;
public interface ICustomerRepository
{
IEnumerable<Customer> ReadCustomers();
Customer ReadCustomerById(int id);
void CreateCustomer(Customer customer);
void UpdateCustomer(Customer customer);
void DeleteCustomer(int id);
}

View File

@ -0,0 +1,16 @@
using PIbd_23_Gutorov_I.A._IT_Company.Entities;
namespace PIbd_23_Gutorov_I.A._IT_Company.Repositories;
public interface IExecutorRepository
{
IEnumerable<Executor> ReadExecutors();
Executor ReadExecutorById(int id);
void CreateExecutor(Executor Executor);
void UpdateExecutor(Executor Executor);
void DeleteExecutor(int id);
}

View File

@ -0,0 +1,14 @@
using PIbd_23_Gutorov_I.A._IT_Company.Entities;
namespace PIbd_23_Gutorov_I.A._IT_Company.Repositories;
public interface IServiceExecutionRepository
{
IEnumerable<ServiceExecution> ReadServiceExecutions();
ServiceExecution ReadServiceExecutionById(int id);
void CreateServiceExecution(ServiceExecution ServiceExecution);
void UpdateServiceExecution(ServiceExecution ServiceExecution);
}

View File

@ -0,0 +1,16 @@
using PIbd_23_Gutorov_I.A._IT_Company.Entities;
namespace PIbd_23_Gutorov_I.A._IT_Company.Repositories;
public interface IServiceRepository
{
IEnumerable<Service> ReadServices(int? contractId = null);
Service ReadServiceById(int id);
void CreateService(Service Service);
void UpdateService(Service Service);
void DeleteService(int id);
}

View File

@ -0,0 +1,28 @@
using PIbd_23_Gutorov_I.A._IT_Company.Entities;
namespace PIbd_23_Gutorov_I.A._IT_Company.Repositories.Implementations;
public class ContractRepository : IContractRepository
{
public void CreateContract(Contract Contract)
{
}
public void DeleteContract(int id)
{
}
public Contract ReadContractById(int id)
{
return Contract.CreateEntity(0, 0, 0, Entities.Enums.ContractCategory.None, DateTime.Now, 0);
}
public IEnumerable<Contract> ReadContracts(DateTime? dateFrom = null, DateTime? dateTo = null, int? customerId = null, int? executorId = null)
{
return [];
}
public void UpdateContract(Contract Contract)
{
}
}

View File

@ -0,0 +1,20 @@
using PIbd_23_Gutorov_I.A._IT_Company.Entities;
namespace PIbd_23_Gutorov_I.A._IT_Company.Repositories.Implementations;
public class CustomerContractReviewRepository : ICustomerContractReviewRepository
{
public void CreateCustomerContractReview(CustomerContractReview CustomerContractReview)
{
}
public CustomerContractReview ReadCustomerContractReviewById(int id)
{
return CustomerContractReview.CreateElement(0, 0, 0, string.Empty, 0);
}
public IEnumerable<CustomerContractReview> ReadCustomerContractReviews(int? customerId = null)
{
return [];
}
}

View File

@ -0,0 +1,28 @@
using PIbd_23_Gutorov_I.A._IT_Company.Entities;
namespace PIbd_23_Gutorov_I.A._IT_Company.Repositories.Implementations;
public class CustomerRepository : ICustomerRepository
{
public void CreateCustomer(Customer customer)
{
}
public void DeleteCustomer(int id)
{
}
public Customer ReadCustomerById(int id)
{
return Customer.CreateEntity(0, string.Empty, string.Empty, string.Empty);
}
public IEnumerable<Customer> ReadCustomers()
{
return [];
}
public void UpdateCustomer(Customer customer)
{
}
}

View File

@ -0,0 +1,28 @@
using PIbd_23_Gutorov_I.A._IT_Company.Entities;
namespace PIbd_23_Gutorov_I.A._IT_Company.Repositories.Implementations;
public class ExecutorRepository : IExecutorRepository
{
public void CreateExecutor(Executor Executor)
{
}
public void DeleteExecutor(int id)
{
}
public Executor ReadExecutorById(int id)
{
return Executor.CreateEntity(0, string.Empty, Entities.Enums.ExecutorPost.None);
}
public IEnumerable<Executor> ReadExecutors()
{
return [];
}
public void UpdateExecutor(Executor Executor)
{
}
}

View File

@ -0,0 +1,24 @@
using PIbd_23_Gutorov_I.A._IT_Company.Entities;
namespace PIbd_23_Gutorov_I.A._IT_Company.Repositories.Implementations;
public class ServiceExecutionRepository : IServiceExecutionRepository
{
public void CreateServiceExecution(ServiceExecution ServiceExecution)
{
}
public ServiceExecution ReadServiceExecutionById(int id)
{
return ServiceExecution.CreateOperation(0, 0, 0, 0, 0, DateTime.Now);
}
public IEnumerable<ServiceExecution> ReadServiceExecutions()
{
return [];
}
public void UpdateServiceExecution(ServiceExecution ServiceExecution)
{
}
}

View File

@ -0,0 +1,28 @@
using PIbd_23_Gutorov_I.A._IT_Company.Entities;
namespace PIbd_23_Gutorov_I.A._IT_Company.Repositories.Implementations;
internal class ServiceRepository : IServiceRepository
{
public void CreateService(Service Service)
{
}
public void DeleteService(int id)
{
}
public Service ReadServiceById(int id)
{
return Service.CreateEntity(0, string.Empty, 0);
}
public IEnumerable<Service> ReadServices(int? contractId = null)
{
return [];
}
public void UpdateService(Service Service)
{
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 MiB