Guess iI'm done with forms

This commit is contained in:
Никита Волков 2024-05-20 01:21:34 +04:00
parent 3bf570b6f4
commit ea05f407fb
38 changed files with 3474 additions and 183 deletions

View File

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

View File

@ -1,120 +0,0 @@
<?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,232 @@
namespace PersonnelDepartmentView
{
partial class FormDeal
{
/// <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();
label1 = new Label();
label2 = new Label();
dateTimePickerFrom = new DateTimePicker();
dateTimePickerTo = new DateTimePicker();
label3 = new Label();
comboBoxType = new ComboBox();
label4 = new Label();
comboBoxEmployee = new ComboBox();
label5 = new Label();
comboBoxDepartment = new ComboBox();
label6 = new Label();
comboBoxPosition = new ComboBox();
label7 = new Label();
SuspendLayout();
//
// buttonCancel
//
buttonCancel.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonCancel.Location = new Point(230, 186);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 19;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
buttonSave.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonSave.Location = new Point(149, 186);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(75, 23);
buttonSave.TabIndex = 18;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(15, 20);
label1.Name = "label1";
label1.Size = new Size(44, 15);
label1.TabIndex = 20;
label1.Text = "Дата с:";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(15, 47);
label2.Name = "label2";
label2.Size = new Size(52, 15);
label2.TabIndex = 21;
label2.Text = "Дата по:";
//
// dateTimePickerFrom
//
dateTimePickerFrom.Anchor = AnchorStyles.Top | AnchorStyles.Right;
dateTimePickerFrom.Location = new Point(105, 12);
dateTimePickerFrom.Name = "dateTimePickerFrom";
dateTimePickerFrom.Size = new Size(200, 23);
dateTimePickerFrom.TabIndex = 22;
//
// dateTimePickerTo
//
dateTimePickerTo.Anchor = AnchorStyles.Top | AnchorStyles.Right;
dateTimePickerTo.Location = new Point(105, 41);
dateTimePickerTo.Name = "dateTimePickerTo";
dateTimePickerTo.Size = new Size(200, 23);
dateTimePickerTo.TabIndex = 23;
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(15, 73);
label3.Name = "label3";
label3.Size = new Size(84, 15);
label3.TabIndex = 24;
label3.Text = "Тип договора:";
//
// comboBoxType
//
comboBoxType.Anchor = AnchorStyles.Top | AnchorStyles.Right;
comboBoxType.FormattingEnabled = true;
comboBoxType.Location = new Point(105, 70);
comboBoxType.Name = "comboBoxType";
comboBoxType.Size = new Size(200, 23);
comboBoxType.TabIndex = 25;
//
// label4
//
label4.AutoSize = true;
label4.Location = new Point(114, 144);
label4.Name = "label4";
label4.Size = new Size(0, 15);
label4.TabIndex = 26;
//
// comboBoxEmployee
//
comboBoxEmployee.Anchor = AnchorStyles.Top | AnchorStyles.Right;
comboBoxEmployee.FormattingEnabled = true;
comboBoxEmployee.Location = new Point(105, 99);
comboBoxEmployee.Name = "comboBoxEmployee";
comboBoxEmployee.Size = new Size(200, 23);
comboBoxEmployee.TabIndex = 28;
//
// label5
//
label5.AutoSize = true;
label5.Location = new Point(15, 102);
label5.Name = "label5";
label5.Size = new Size(69, 15);
label5.TabIndex = 27;
label5.Text = "Сотрудник:";
//
// comboBoxDepartment
//
comboBoxDepartment.Anchor = AnchorStyles.Top | AnchorStyles.Right;
comboBoxDepartment.FormattingEnabled = true;
comboBoxDepartment.Location = new Point(105, 128);
comboBoxDepartment.Name = "comboBoxDepartment";
comboBoxDepartment.Size = new Size(200, 23);
comboBoxDepartment.TabIndex = 30;
//
// label6
//
label6.AutoSize = true;
label6.Location = new Point(15, 131);
label6.Name = "label6";
label6.Size = new Size(43, 15);
label6.TabIndex = 29;
label6.Text = "Отдел:";
//
// comboBoxPosition
//
comboBoxPosition.Anchor = AnchorStyles.Top | AnchorStyles.Right;
comboBoxPosition.FormattingEnabled = true;
comboBoxPosition.Location = new Point(105, 157);
comboBoxPosition.Name = "comboBoxPosition";
comboBoxPosition.Size = new Size(200, 23);
comboBoxPosition.TabIndex = 32;
//
// label7
//
label7.AutoSize = true;
label7.Location = new Point(15, 160);
label7.Name = "label7";
label7.Size = new Size(72, 15);
label7.TabIndex = 31;
label7.Text = "Должность:";
//
// FormDeal
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(324, 223);
Controls.Add(comboBoxPosition);
Controls.Add(label7);
Controls.Add(comboBoxDepartment);
Controls.Add(label6);
Controls.Add(comboBoxEmployee);
Controls.Add(label5);
Controls.Add(label4);
Controls.Add(comboBoxType);
Controls.Add(label3);
Controls.Add(dateTimePickerTo);
Controls.Add(dateTimePickerFrom);
Controls.Add(label2);
Controls.Add(label1);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
FormBorderStyle = FormBorderStyle.FixedSingle;
MinimumSize = new Size(340, 262);
Name = "FormDeal";
StartPosition = FormStartPosition.CenterScreen;
Text = "Договор";
Load += FormDeal_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonCancel;
private Button buttonSave;
private Label label1;
private Label label2;
private DateTimePicker dateTimePickerFrom;
private DateTimePicker dateTimePickerTo;
private Label label3;
private ComboBox comboBoxType;
private Label label4;
private ComboBox comboBoxEmployee;
private Label label5;
private ComboBox comboBoxDepartment;
private Label label6;
private ComboBox comboBoxPosition;
private Label label7;
}
}

View File

@ -0,0 +1,139 @@
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using PersonnelDepartmentContracts.BindingModels;
using PersonnelDepartmentContracts.BusinessLogicContracts;
using PersonnelDepartmentContracts.SearchModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PersonnelDepartmentView
{
public partial class FormDeal : Form
{
private readonly IDealLogic _dealLogic;
private readonly IDepartmentLogic _departmentLogic;
private readonly IEmployeeLogic _employeeLogic;
private readonly IPositionLogic _positionLogic;
private readonly ITypeLogic _typeLogic;
private int? _id;
public int Id { set { _id = value; } }
public FormDeal(IDealLogic dealLogic, IDepartmentLogic departmentLogic, IEmployeeLogic employeeLogic, IPositionLogic positionLogic, ITypeLogic typeLogic)
{
InitializeComponent();
_dealLogic = dealLogic;
_departmentLogic = departmentLogic;
_employeeLogic = employeeLogic;
_positionLogic = positionLogic;
_typeLogic = typeLogic;
}
private void FormDeal_Load(object sender, EventArgs e)
{
comboBoxDepartment.DisplayMember = "Name";
comboBoxDepartment.ValueMember = "Id";
comboBoxDepartment.DataSource = _departmentLogic.ReadList(null);
comboBoxEmployee.DisplayMember = "LastName";
comboBoxEmployee.ValueMember = "Id";
comboBoxEmployee.DataSource = _employeeLogic.ReadList(null);
comboBoxPosition.DisplayMember = "Name";
comboBoxPosition.ValueMember = "Id";
comboBoxPosition.DataSource = _positionLogic.ReadList(null);
comboBoxType.DisplayMember = "Name";
comboBoxType.ValueMember = "Id";
comboBoxType.DataSource = _typeLogic.ReadList(null);
if (_id.HasValue)
{
try
{
var view = _dealLogic.ReadElement(new DealSearchModel
{
Id = _id.Value
});
if (view != null)
{
dateTimePickerFrom.Value = view.DateFrom;
dateTimePickerTo.Value = view.DateTo;
comboBoxDepartment.SelectedItem = view.DepartmentId;
comboBoxEmployee.SelectedItem = view.EmployeeId;
comboBoxPosition.SelectedItem = view.PositionId;
comboBoxType.SelectedItem = view.TypeId;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
else
{
comboBoxDepartment.SelectedItem = null;
comboBoxEmployee.SelectedItem = null;
comboBoxPosition.SelectedItem = null;
comboBoxType.SelectedItem = null;
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (comboBoxDepartment.SelectedItem == null)
{
MessageBox.Show("Выберите отдел", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxEmployee.SelectedItem == null)
{
MessageBox.Show("Выберите сотрудника", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxPosition.SelectedItem == null)
{
MessageBox.Show("Выберите должность", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxType.SelectedItem == null)
{
MessageBox.Show("Выберите тип договора", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
var model = new DealBindingModel
{
Id = _id ?? 0,
DateFrom = DateTime.SpecifyKind(dateTimePickerFrom.Value, DateTimeKind.Utc),
DateTo = DateTime.SpecifyKind(dateTimePickerTo.Value, DateTimeKind.Utc),
DepartmentId = Convert.ToInt32(comboBoxDepartment.SelectedValue),
EmployeeId = Convert.ToInt32(comboBoxEmployee.SelectedValue),
PositionId = Convert.ToInt32(comboBoxPosition.SelectedValue),
TypeId = Convert.ToInt32(comboBoxType.SelectedValue)
};
var operationResult = _id.HasValue ? _dealLogic.Update(model) : _dealLogic.Create(model);
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<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,206 @@
namespace PersonnelDepartmentView
{
partial class FormDeals
{
/// <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()
{
dataGridView = new DataGridView();
buttonAdd = new Button();
buttonChange = new Button();
buttonDelete = new Button();
buttonUpdate = new Button();
buttonDepartment = new Button();
buttonEmployee = new Button();
buttonPosition = new Button();
buttonType = new Button();
buttonGenerate = new Button();
buttonBackUp = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// dataGridView
//
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
dataGridView.BackgroundColor = Color.DarkSeaGreen;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 41);
dataGridView.Name = "dataGridView";
dataGridView.RowTemplate.Height = 25;
dataGridView.Size = new Size(888, 368);
dataGridView.TabIndex = 0;
//
// buttonAdd
//
buttonAdd.Anchor = AnchorStyles.Top;
buttonAdd.Location = new Point(12, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(75, 23);
buttonAdd.TabIndex = 1;
buttonAdd.Text = "Создать";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// buttonChange
//
buttonChange.Anchor = AnchorStyles.Top;
buttonChange.Location = new Point(93, 12);
buttonChange.Name = "buttonChange";
buttonChange.Size = new Size(75, 23);
buttonChange.TabIndex = 2;
buttonChange.Text = "Изменить";
buttonChange.UseVisualStyleBackColor = true;
buttonChange.Click += ButtonChange_Click;
//
// buttonDelete
//
buttonDelete.Anchor = AnchorStyles.Top;
buttonDelete.Location = new Point(174, 12);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(75, 23);
buttonDelete.TabIndex = 3;
buttonDelete.Text = "Удалить";
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += ButtonDelete_Click;
//
// buttonUpdate
//
buttonUpdate.Anchor = AnchorStyles.Top;
buttonUpdate.Location = new Point(255, 12);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(75, 23);
buttonUpdate.TabIndex = 4;
buttonUpdate.Text = "Обновить";
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
//
// buttonDepartment
//
buttonDepartment.Anchor = AnchorStyles.Top;
buttonDepartment.Location = new Point(336, 12);
buttonDepartment.Name = "buttonDepartment";
buttonDepartment.Size = new Size(128, 23);
buttonDepartment.TabIndex = 5;
buttonDepartment.Text = "Таблица с отделами";
buttonDepartment.UseVisualStyleBackColor = true;
buttonDepartment.Click += ButtonDepartment_Click;
//
// buttonEmployee
//
buttonEmployee.Anchor = AnchorStyles.Top;
buttonEmployee.Location = new Point(470, 12);
buttonEmployee.Name = "buttonEmployee";
buttonEmployee.Size = new Size(152, 23);
buttonEmployee.TabIndex = 6;
buttonEmployee.Text = "Таблица с сотрудниками";
buttonEmployee.UseVisualStyleBackColor = true;
buttonEmployee.Click += ButtonEmployee_Click;
//
// buttonPosition
//
buttonPosition.Anchor = AnchorStyles.Top;
buttonPosition.Location = new Point(628, 12);
buttonPosition.Name = "buttonPosition";
buttonPosition.Size = new Size(149, 23);
buttonPosition.TabIndex = 7;
buttonPosition.Text = "Таблица с должностями";
buttonPosition.UseVisualStyleBackColor = true;
buttonPosition.Click += ButtonPosition_Click;
//
// buttonType
//
buttonType.Anchor = AnchorStyles.Top;
buttonType.Location = new Point(783, 12);
buttonType.Name = "buttonType";
buttonType.Size = new Size(117, 23);
buttonType.TabIndex = 8;
buttonType.Text = "Таблица с типами";
buttonType.UseVisualStyleBackColor = true;
buttonType.Click += ButtonType_Click;
//
// buttonGenerate
//
buttonGenerate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonGenerate.Location = new Point(12, 415);
buttonGenerate.Name = "buttonGenerate";
buttonGenerate.Size = new Size(163, 23);
buttonGenerate.TabIndex = 9;
buttonGenerate.Text = "Сгенерировать сущности";
buttonGenerate.UseVisualStyleBackColor = true;
buttonGenerate.Click += ButtonGenerate_Click;
//
// buttonBackUp
//
buttonBackUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonBackUp.Location = new Point(783, 415);
buttonBackUp.Name = "buttonBackUp";
buttonBackUp.Size = new Size(117, 23);
buttonBackUp.TabIndex = 10;
buttonBackUp.Text = "Создать BackUp";
buttonBackUp.UseVisualStyleBackColor = true;
buttonBackUp.Click += CreateBackup_Click;
//
// FormDeals
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
BackColor = SystemColors.Control;
ClientSize = new Size(914, 446);
Controls.Add(buttonBackUp);
Controls.Add(buttonGenerate);
Controls.Add(buttonType);
Controls.Add(buttonPosition);
Controls.Add(buttonEmployee);
Controls.Add(buttonDepartment);
Controls.Add(buttonUpdate);
Controls.Add(buttonDelete);
Controls.Add(buttonChange);
Controls.Add(buttonAdd);
Controls.Add(dataGridView);
MinimumSize = new Size(930, 240);
Name = "FormDeals";
StartPosition = FormStartPosition.CenterScreen;
Text = "Таблица Договоров";
Load += FormDeals_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button buttonAdd;
private Button buttonChange;
private Button buttonDelete;
private Button buttonUpdate;
private Button buttonDepartment;
private Button buttonEmployee;
private Button buttonPosition;
private Button buttonType;
private Button buttonGenerate;
private Button buttonBackUp;
}
}

View File

@ -0,0 +1,180 @@
using PersonnelDepartmentContracts.BindingModels;
using PersonnelDepartmentContracts.BusinessLogicContracts;
namespace PersonnelDepartmentView
{
public partial class FormDeals : Form
{
private readonly IDealLogic _dealLogic;
private readonly IBackUpLogic _backUpLogic;
public FormDeals(IDealLogic dealLogic, IBackUpLogic backUpLogic)
{
InitializeComponent();
_dealLogic = dealLogic;
_backUpLogic = backUpLogic;
}
private void LoadData()
{
try
{
var list = _dealLogic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["EmployeeId"].Visible = false;
dataGridView.Columns["PositionId"].Visible = false;
dataGridView.Columns["DepartmentId"].Visible = false;
dataGridView.Columns["TypeId"].Visible = false;
dataGridView.Columns["DateFrom"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["DateTo"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["TypeName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["EmployeeName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["DepartmentName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["PositionName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà çàãðóçêè", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void FormDeals_Load(object sender, EventArgs e)
{
LoadData();
}
private void ButtonDepartment_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormDepartments));
if (service is FormDepartments form)
{
form.ShowDialog();
}
}
private void ButtonEmployee_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormEmployees));
if (service is FormEmployees form)
{
form.ShowDialog();
}
}
private void ButtonPosition_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormPositions));
if (service is FormPositions form)
{
form.ShowDialog();
}
}
private void ButtonType_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormTypes));
if (service is FormTypes form)
{
form.ShowDialog();
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormDeal));
if (service is FormDeal form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonChange_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormDeal));
if (service is FormDeal form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDelete_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Óäàëèòü çàïèñü?", "Âîïðîñ", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
try
{
if (!_dealLogic.Delete(new DealBindingModel
{
Id = id
}))
{
throw new Exception("Îøèáêà ïðè óäàëåíèè.");
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
LoadData();
}
private void ButtonGenerate_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormGeneration));
if (service is FormGeneration form)
{
form.ShowDialog();
}
}
private void CreateBackup_Click(object sender, EventArgs e)
{
try
{
if (_backUpLogic != null)
{
var fbd = new FolderBrowserDialog();
if (fbd.ShowDialog() == DialogResult.OK)
{
_backUpLogic.CreateBackUp(new BackUpBinidngModel
{
FolderName = fbd.SelectedPath
});
MessageBox.Show("Áåêàï ñîçäàí", "Ñîîáùåíèå",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Îøèáêà", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<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 PersonnelDepartmentView
{
partial class FormDepartment
{
/// <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()
{
label2 = new Label();
textBoxTelephone = new TextBox();
buttonCancel = new Button();
buttonSave = new Button();
label1 = new Label();
textBoxName = new TextBox();
SuspendLayout();
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(20, 44);
label2.Name = "label2";
label2.Size = new Size(126, 15);
label2.TabIndex = 19;
label2.Text = "Контактный телефон:";
//
// textBoxTelephone
//
textBoxTelephone.Location = new Point(153, 41);
textBoxTelephone.Name = "textBoxTelephone";
textBoxTelephone.Size = new Size(202, 23);
textBoxTelephone.TabIndex = 18;
//
// buttonCancel
//
buttonCancel.Location = new Point(280, 70);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 17;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(199, 70);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(75, 23);
buttonSave.TabIndex = 16;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(20, 15);
label1.Name = "label1";
label1.Size = new Size(102, 15);
label1.TabIndex = 15;
label1.Text = "Название отдела:";
//
// textBoxName
//
textBoxName.Location = new Point(153, 12);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(202, 23);
textBoxName.TabIndex = 14;
//
// FormDepartment
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(375, 108);
Controls.Add(label2);
Controls.Add(textBoxTelephone);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(label1);
Controls.Add(textBoxName);
FormBorderStyle = FormBorderStyle.FixedSingle;
Name = "FormDepartment";
StartPosition = FormStartPosition.CenterScreen;
Text = "Отдел";
Load += FormDepartment_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label label2;
private TextBox textBoxTelephone;
private Button buttonCancel;
private Button buttonSave;
private Label label1;
private TextBox textBoxName;
}
}

View File

@ -0,0 +1,93 @@
using PersonnelDepartmentBusinessLogic.BusinessLogics;
using PersonnelDepartmentContracts.BindingModels;
using PersonnelDepartmentContracts.BusinessLogicContracts;
using PersonnelDepartmentContracts.SearchModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PersonnelDepartmentView
{
public partial class FormDepartment : Form
{
private readonly IDepartmentLogic _departmentLogic;
private int? _id;
public int Id { set { _id = value; } }
public FormDepartment(IDepartmentLogic departmentLogic)
{
InitializeComponent();
_departmentLogic = departmentLogic;
}
private void FormDepartment_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
var view = _departmentLogic.ReadElement(new DepartmentSearchModel
{
Id = _id.Value
});
if (view != null)
{
textBoxName.Text = view.Name;
textBoxTelephone.Text = view.Telephone.ToString();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxName.Text))
{
MessageBox.Show("Введите название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxTelephone.Text))
{
MessageBox.Show("Введите контактный номер", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
var model = new DepartmentBindingModel
{
Id = _id ?? 0,
Name = textBoxName.Text,
Telephone = long.Parse(textBoxTelephone.Text)
};
var operationResult = _id.HasValue ? _departmentLogic.Update(model) : _departmentLogic.Create(model);
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,117 @@
namespace PersonnelDepartmentView
{
partial class FormDepartments
{
/// <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()
{
buttonUpdate = new Button();
buttonDelete = new Button();
buttonChange = new Button();
buttonAdd = new Button();
dataGridView = new DataGridView();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// buttonUpdate
//
buttonUpdate.Location = new Point(255, 9);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(75, 23);
buttonUpdate.TabIndex = 9;
buttonUpdate.Text = "Обновить";
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
//
// buttonDelete
//
buttonDelete.Location = new Point(174, 9);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(75, 23);
buttonDelete.TabIndex = 8;
buttonDelete.Text = "Удалить";
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += ButtonDelete_Click;
//
// buttonChange
//
buttonChange.Location = new Point(93, 9);
buttonChange.Name = "buttonChange";
buttonChange.Size = new Size(75, 23);
buttonChange.TabIndex = 7;
buttonChange.Text = "Изменить";
buttonChange.UseVisualStyleBackColor = true;
buttonChange.Click += ButtonChange_Click;
//
// buttonAdd
//
buttonAdd.Location = new Point(12, 9);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(75, 23);
buttonAdd.TabIndex = 6;
buttonAdd.Text = "Создать";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// dataGridView
//
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
dataGridView.BackgroundColor = Color.DarkSeaGreen;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 38);
dataGridView.Name = "dataGridView";
dataGridView.RowTemplate.Height = 25;
dataGridView.Size = new Size(564, 368);
dataGridView.TabIndex = 5;
//
// FormDepartments
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(590, 418);
Controls.Add(buttonUpdate);
Controls.Add(buttonDelete);
Controls.Add(buttonChange);
Controls.Add(buttonAdd);
Controls.Add(dataGridView);
MinimumSize = new Size(400, 200);
Name = "FormDepartments";
StartPosition = FormStartPosition.CenterScreen;
Text = "Таблица Отделов";
Load += FormDepartments_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Button buttonUpdate;
private Button buttonDelete;
private Button buttonChange;
private Button buttonAdd;
private DataGridView dataGridView;
}
}

View File

@ -0,0 +1,108 @@
using PersonnelDepartmentBusinessLogic.BusinessLogics;
using PersonnelDepartmentContracts.BindingModels;
using PersonnelDepartmentContracts.BusinessLogicContracts;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PersonnelDepartmentView
{
public partial class FormDepartments : Form
{
private readonly IDepartmentLogic _departmentLogic;
public FormDepartments(IDepartmentLogic departmentLogic)
{
InitializeComponent();
_departmentLogic = departmentLogic;
}
private void LoadData()
{
try
{
var list = _departmentLogic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["Telephone"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка загрузки", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormDepartment));
if (service is FormDepartment form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonChange_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormDepartment));
if (service is FormDepartment form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDelete_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
try
{
if (!_departmentLogic.Delete(new DepartmentBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении.");
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
LoadData();
}
private void FormDepartments_Load(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<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,142 @@
namespace PersonnelDepartmentView
{
partial class FormEmployee
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
buttonCancel = new Button();
buttonSave = new Button();
label1 = new Label();
textBoxFirstName = new TextBox();
label2 = new Label();
textBoxLastName = new TextBox();
label3 = new Label();
textBoxPatronymic = new TextBox();
SuspendLayout();
//
// buttonCancel
//
buttonCancel.Location = new Point(276, 99);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 11;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(195, 99);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(75, 23);
buttonSave.TabIndex = 10;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(16, 15);
label1.Name = "label1";
label1.Size = new Size(100, 15);
label1.TabIndex = 9;
label1.Text = "Имя сотрудника:";
//
// textBoxFirstName
//
textBoxFirstName.Location = new Point(149, 12);
textBoxFirstName.Name = "textBoxFirstName";
textBoxFirstName.Size = new Size(202, 23);
textBoxFirstName.TabIndex = 8;
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(16, 44);
label2.Name = "label2";
label2.Size = new Size(127, 15);
label2.TabIndex = 13;
label2.Text = "Фамилия сотрудника:";
//
// textBoxLastName
//
textBoxLastName.Location = new Point(149, 41);
textBoxLastName.Name = "textBoxLastName";
textBoxLastName.Size = new Size(202, 23);
textBoxLastName.TabIndex = 12;
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(16, 73);
label3.Name = "label3";
label3.Size = new Size(127, 15);
label3.TabIndex = 15;
label3.Text = "Отчество сотрудника:";
//
// textBoxPatronymic
//
textBoxPatronymic.Location = new Point(149, 70);
textBoxPatronymic.Name = "textBoxPatronymic";
textBoxPatronymic.Size = new Size(202, 23);
textBoxPatronymic.TabIndex = 14;
//
// FormEmployee
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(369, 136);
Controls.Add(label3);
Controls.Add(textBoxPatronymic);
Controls.Add(label2);
Controls.Add(textBoxLastName);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(label1);
Controls.Add(textBoxFirstName);
FormBorderStyle = FormBorderStyle.FixedSingle;
Name = "FormEmployee";
StartPosition = FormStartPosition.CenterScreen;
Text = "Сотрудник";
Load += FormEmployee_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonCancel;
private Button buttonSave;
private Label label1;
private TextBox textBoxFirstName;
private Label label2;
private TextBox textBoxLastName;
private Label label3;
private TextBox textBoxPatronymic;
}
}

View File

@ -0,0 +1,95 @@
using PersonnelDepartmentBusinessLogic.BusinessLogics;
using PersonnelDepartmentContracts.BindingModels;
using PersonnelDepartmentContracts.BusinessLogicContracts;
using PersonnelDepartmentContracts.SearchModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PersonnelDepartmentView
{
public partial class FormEmployee : Form
{
private readonly IEmployeeLogic _employeeLogic;
private int? _id;
public int Id { set { _id = value; } }
public FormEmployee(IEmployeeLogic employeeLogic)
{
InitializeComponent();
_employeeLogic = employeeLogic;
}
private void FormEmployee_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
var view = _employeeLogic.ReadElement(new EmployeeSearchModel
{
Id = _id.Value
});
if (view != null)
{
textBoxFirstName.Text = view.FirstName;
textBoxLastName.Text = view.LastName;
textBoxPatronymic.Text = view.Patronymic;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxFirstName.Text))
{
MessageBox.Show("Введите название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxLastName.Text))
{
MessageBox.Show("Введите контактный номер", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
var model = new EmployeeBindingModel
{
Id = _id ?? 0,
FirstName = textBoxFirstName.Text,
LastName = textBoxLastName.Text,
Patronymic = textBoxPatronymic.Text
};
var operationResult = _id.HasValue ? _employeeLogic.Update(model) : _employeeLogic.Create(model);
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,117 @@
namespace PersonnelDepartmentView
{
partial class FormEmployees
{
/// <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()
{
buttonUpdate = new Button();
buttonDelete = new Button();
buttonChange = new Button();
buttonAdd = new Button();
dataGridView = new DataGridView();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// buttonUpdate
//
buttonUpdate.Location = new Point(255, 9);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(75, 23);
buttonUpdate.TabIndex = 9;
buttonUpdate.Text = "Обновить";
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
//
// buttonDelete
//
buttonDelete.Location = new Point(174, 9);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(75, 23);
buttonDelete.TabIndex = 8;
buttonDelete.Text = "Удалить";
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += ButtonDelete_Click;
//
// buttonChange
//
buttonChange.Location = new Point(93, 9);
buttonChange.Name = "buttonChange";
buttonChange.Size = new Size(75, 23);
buttonChange.TabIndex = 7;
buttonChange.Text = "Изменить";
buttonChange.UseVisualStyleBackColor = true;
buttonChange.Click += ButtonChange_Click;
//
// buttonAdd
//
buttonAdd.Location = new Point(12, 9);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(75, 23);
buttonAdd.TabIndex = 6;
buttonAdd.Text = "Создать";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// dataGridView
//
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
dataGridView.BackgroundColor = Color.DarkSeaGreen;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 38);
dataGridView.Name = "dataGridView";
dataGridView.RowTemplate.Height = 25;
dataGridView.Size = new Size(564, 368);
dataGridView.TabIndex = 5;
//
// FormEmployees
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(589, 418);
Controls.Add(buttonUpdate);
Controls.Add(buttonDelete);
Controls.Add(buttonChange);
Controls.Add(buttonAdd);
Controls.Add(dataGridView);
MinimumSize = new Size(400, 200);
Name = "FormEmployees";
StartPosition = FormStartPosition.CenterScreen;
Text = "Таблица Сотрудников";
Load += FormEmployees_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Button buttonUpdate;
private Button buttonDelete;
private Button buttonChange;
private Button buttonAdd;
private DataGridView dataGridView;
}
}

View File

@ -0,0 +1,109 @@
using PersonnelDepartmentBusinessLogic.BusinessLogics;
using PersonnelDepartmentContracts.BindingModels;
using PersonnelDepartmentContracts.BusinessLogicContracts;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PersonnelDepartmentView
{
public partial class FormEmployees : Form
{
private readonly IEmployeeLogic _employeeLogic;
public FormEmployees(IEmployeeLogic employeeLogic)
{
InitializeComponent();
_employeeLogic = employeeLogic;
}
private void LoadData()
{
try
{
var list = _employeeLogic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["FirstName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["LastName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["Patronymic"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка загрузки", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormEmployee));
if (service is FormEmployee form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonChange_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormEmployee));
if (service is FormEmployee form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDelete_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
try
{
if (!_employeeLogic.Delete(new EmployeeBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении.");
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
LoadData();
}
private void FormEmployees_Load(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<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,229 @@
namespace PersonnelDepartmentView
{
partial class FormGeneration
{
/// <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()
{
groupBox1 = new GroupBox();
textBoxGet = new TextBox();
numericGet = new NumericUpDown();
buttonGetTest = new Button();
groupBox2 = new GroupBox();
textBoxDiffGet = new TextBox();
numericDiffGet = new NumericUpDown();
buttonDiffGetTest = new Button();
groupBox3 = new GroupBox();
textBoxSet = new TextBox();
numericSet = new NumericUpDown();
buttonSetTest = new Button();
buttonClear = new Button();
groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericGet).BeginInit();
groupBox2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericDiffGet).BeginInit();
groupBox3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericSet).BeginInit();
SuspendLayout();
//
// groupBox1
//
groupBox1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
groupBox1.Controls.Add(textBoxGet);
groupBox1.Controls.Add(numericGet);
groupBox1.Controls.Add(buttonGetTest);
groupBox1.Location = new Point(12, 12);
groupBox1.Name = "groupBox1";
groupBox1.Size = new Size(470, 93);
groupBox1.TabIndex = 0;
groupBox1.TabStop = false;
groupBox1.Text = "Тест обычного запроса:";
//
// textBoxGet
//
textBoxGet.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
textBoxGet.Location = new Point(221, 51);
textBoxGet.Name = "textBoxGet";
textBoxGet.ReadOnly = true;
textBoxGet.Size = new Size(243, 23);
textBoxGet.TabIndex = 2;
//
// numericGet
//
numericGet.Anchor = AnchorStyles.Top | AnchorStyles.Right;
numericGet.Location = new Point(221, 22);
numericGet.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
numericGet.Name = "numericGet";
numericGet.Size = new Size(243, 23);
numericGet.TabIndex = 1;
//
// buttonGetTest
//
buttonGetTest.Anchor = AnchorStyles.Left | AnchorStyles.Right;
buttonGetTest.Location = new Point(6, 22);
buttonGetTest.Name = "buttonGetTest";
buttonGetTest.Size = new Size(209, 52);
buttonGetTest.TabIndex = 0;
buttonGetTest.Text = "GetTest";
buttonGetTest.UseVisualStyleBackColor = true;
buttonGetTest.Click += ButtonGetTest_Click;
//
// groupBox2
//
groupBox2.Anchor = AnchorStyles.Left | AnchorStyles.Right;
groupBox2.Controls.Add(textBoxDiffGet);
groupBox2.Controls.Add(numericDiffGet);
groupBox2.Controls.Add(buttonDiffGetTest);
groupBox2.Location = new Point(12, 111);
groupBox2.Name = "groupBox2";
groupBox2.Size = new Size(470, 93);
groupBox2.TabIndex = 1;
groupBox2.TabStop = false;
groupBox2.Text = "Тест сложного запроса:";
//
// textBoxDiffGet
//
textBoxDiffGet.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
textBoxDiffGet.Location = new Point(221, 51);
textBoxDiffGet.Name = "textBoxDiffGet";
textBoxDiffGet.ReadOnly = true;
textBoxDiffGet.Size = new Size(243, 23);
textBoxDiffGet.TabIndex = 2;
//
// numericDiffGet
//
numericDiffGet.Anchor = AnchorStyles.Top | AnchorStyles.Right;
numericDiffGet.Location = new Point(221, 22);
numericDiffGet.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
numericDiffGet.Name = "numericDiffGet";
numericDiffGet.Size = new Size(243, 23);
numericDiffGet.TabIndex = 1;
//
// buttonDiffGetTest
//
buttonDiffGetTest.Anchor = AnchorStyles.Left | AnchorStyles.Right;
buttonDiffGetTest.Location = new Point(6, 22);
buttonDiffGetTest.Name = "buttonDiffGetTest";
buttonDiffGetTest.Size = new Size(209, 52);
buttonDiffGetTest.TabIndex = 0;
buttonDiffGetTest.Text = "GetDiffTest";
buttonDiffGetTest.UseVisualStyleBackColor = true;
buttonDiffGetTest.Click += ButtonDiffGetTest_Click;
//
// groupBox3
//
groupBox3.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
groupBox3.Controls.Add(textBoxSet);
groupBox3.Controls.Add(numericSet);
groupBox3.Controls.Add(buttonSetTest);
groupBox3.Location = new Point(12, 210);
groupBox3.Name = "groupBox3";
groupBox3.Size = new Size(470, 93);
groupBox3.TabIndex = 3;
groupBox3.TabStop = false;
groupBox3.Text = "Тест на заполнение:";
//
// textBoxSet
//
textBoxSet.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
textBoxSet.Location = new Point(221, 51);
textBoxSet.Name = "textBoxSet";
textBoxSet.ReadOnly = true;
textBoxSet.Size = new Size(243, 23);
textBoxSet.TabIndex = 2;
//
// numericSet
//
numericSet.Anchor = AnchorStyles.Top | AnchorStyles.Right;
numericSet.Location = new Point(221, 22);
numericSet.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
numericSet.Name = "numericSet";
numericSet.Size = new Size(243, 23);
numericSet.TabIndex = 1;
//
// buttonSetTest
//
buttonSetTest.Anchor = AnchorStyles.Left | AnchorStyles.Right;
buttonSetTest.Location = new Point(6, 22);
buttonSetTest.Name = "buttonSetTest";
buttonSetTest.Size = new Size(209, 52);
buttonSetTest.TabIndex = 0;
buttonSetTest.Text = "SetTest";
buttonSetTest.UseVisualStyleBackColor = true;
buttonSetTest.Click += ButtonSetTest_Click;
//
// buttonClear
//
buttonClear.Anchor = AnchorStyles.Bottom;
buttonClear.Location = new Point(149, 309);
buttonClear.Name = "buttonClear";
buttonClear.Size = new Size(162, 23);
buttonClear.TabIndex = 4;
buttonClear.Text = "Очистить сущность";
buttonClear.UseVisualStyleBackColor = true;
buttonClear.Click += ButtonClear_Click;
//
// FormGeneration
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(493, 344);
Controls.Add(buttonClear);
Controls.Add(groupBox3);
Controls.Add(groupBox2);
Controls.Add(groupBox1);
Name = "FormGeneration";
StartPosition = FormStartPosition.CenterScreen;
Text = "FormGeneration";
groupBox1.ResumeLayout(false);
groupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)numericGet).EndInit();
groupBox2.ResumeLayout(false);
groupBox2.PerformLayout();
((System.ComponentModel.ISupportInitialize)numericDiffGet).EndInit();
groupBox3.ResumeLayout(false);
groupBox3.PerformLayout();
((System.ComponentModel.ISupportInitialize)numericSet).EndInit();
ResumeLayout(false);
}
#endregion
private GroupBox groupBox1;
private TextBox textBoxGet;
private NumericUpDown numericGet;
private Button buttonGetTest;
private GroupBox groupBox2;
private TextBox textBoxDiffGet;
private NumericUpDown numericDiffGet;
private Button buttonDiffGetTest;
private GroupBox groupBox3;
private TextBox textBoxSet;
private NumericUpDown numericSet;
private Button buttonSetTest;
private Button buttonClear;
}
}

View File

@ -0,0 +1,48 @@
using PersonnelDepartmentContracts.BusinessLogicContracts;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PersonnelDepartmentView
{
public partial class FormGeneration : Form
{
private readonly IDealLogic _dealLogic;
public FormGeneration(IDealLogic dealLogic)
{
InitializeComponent();
_dealLogic = dealLogic;
}
private void ButtonGetTest_Click(object sender, EventArgs e)
{
textBoxGet.Text = _dealLogic.GetTest(Convert.ToInt32(numericGet.Value)) + "мс";
}
private void ButtonDiffGetTest_Click(object sender, EventArgs e)
{
textBoxDiffGet.Text = _dealLogic.DiffGetTest(Convert.ToInt32(numericDiffGet.Value)) + "мс";
}
private void ButtonSetTest_Click(object sender, EventArgs e)
{
textBoxSet.Text = _dealLogic.SetTest(Convert.ToInt32(numericSet.Value)) + "мс";
}
private void ButtonClear_Click(object sender, EventArgs e)
{
if (_dealLogic.ClearList())
{
MessageBox.Show("Удаление записей завершено", "Успешно", MessageBoxButtons.OK, MessageBoxIcon.Information);
return;
}
MessageBox.Show("Удаление записей провалилось", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<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 PersonnelDepartmentView
{
partial class FormPosition
{
/// <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();
label1 = new Label();
textBoxName = new TextBox();
SuspendLayout();
//
// buttonCancel
//
buttonCancel.Location = new Point(112, 56);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 7;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(31, 56);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(75, 23);
buttonSave.TabIndex = 6;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(15, 15);
label1.Name = "label1";
label1.Size = new Size(62, 15);
label1.TabIndex = 5;
label1.Text = "Название:";
//
// textBoxName
//
textBoxName.Location = new Point(80, 12);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(107, 23);
textBoxName.TabIndex = 4;
//
// FormPosition
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(205, 92);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(label1);
Controls.Add(textBoxName);
FormBorderStyle = FormBorderStyle.FixedSingle;
Name = "FormPosition";
StartPosition = FormStartPosition.CenterScreen;
Text = "Должность";
Load += FormPosition_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonCancel;
private Button buttonSave;
private Label label1;
private TextBox textBoxName;
}
}

View File

@ -0,0 +1,86 @@
using PersonnelDepartmentBusinessLogic.BusinessLogics;
using PersonnelDepartmentContracts.BindingModels;
using PersonnelDepartmentContracts.BusinessLogicContracts;
using PersonnelDepartmentContracts.SearchModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PersonnelDepartmentView
{
public partial class FormPosition : Form
{
private readonly IPositionLogic _positionLogic;
private int? _id;
public int Id { set { _id = value; } }
public FormPosition(IPositionLogic positionLogic)
{
InitializeComponent();
_positionLogic = positionLogic;
}
private void FormPosition_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
var view = _positionLogic.ReadElement(new PositionSearchModel
{
Id = _id.Value
});
if (view != null)
{
textBoxName.Text = view.Name;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxName.Text))
{
MessageBox.Show("Введите название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
var model = new PositionBindingModel
{
Id = _id ?? 0,
Name = textBoxName.Text
};
var operationResult = _id.HasValue ? _positionLogic.Update(model) : _positionLogic.Create(model);
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,117 @@
namespace PersonnelDepartmentView
{
partial class FormPositions
{
/// <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()
{
buttonUpdate = new Button();
buttonDelete = new Button();
buttonChange = new Button();
buttonAdd = new Button();
dataGridView = new DataGridView();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// buttonUpdate
//
buttonUpdate.Location = new Point(255, 9);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(75, 23);
buttonUpdate.TabIndex = 9;
buttonUpdate.Text = "Обновить";
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
//
// buttonDelete
//
buttonDelete.Location = new Point(174, 9);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(75, 23);
buttonDelete.TabIndex = 8;
buttonDelete.Text = "Удалить";
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += ButtonDelete_Click;
//
// buttonChange
//
buttonChange.Location = new Point(93, 9);
buttonChange.Name = "buttonChange";
buttonChange.Size = new Size(75, 23);
buttonChange.TabIndex = 7;
buttonChange.Text = "Изменить";
buttonChange.UseVisualStyleBackColor = true;
buttonChange.Click += ButtonChange_Click;
//
// buttonAdd
//
buttonAdd.Location = new Point(12, 9);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(75, 23);
buttonAdd.TabIndex = 6;
buttonAdd.Text = "Создать";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// dataGridView
//
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
dataGridView.BackgroundColor = Color.DarkSeaGreen;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 38);
dataGridView.Name = "dataGridView";
dataGridView.RowTemplate.Height = 25;
dataGridView.Size = new Size(564, 368);
dataGridView.TabIndex = 5;
//
// FormPositions
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(590, 418);
Controls.Add(buttonUpdate);
Controls.Add(buttonDelete);
Controls.Add(buttonChange);
Controls.Add(buttonAdd);
Controls.Add(dataGridView);
MinimumSize = new Size(400, 200);
Name = "FormPositions";
StartPosition = FormStartPosition.CenterScreen;
Text = "Таблица Должностей";
Load += FormPositions_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Button buttonUpdate;
private Button buttonDelete;
private Button buttonChange;
private Button buttonAdd;
private DataGridView dataGridView;
}
}

View File

@ -0,0 +1,108 @@
using PersonnelDepartmentBusinessLogic.BusinessLogics;
using PersonnelDepartmentContracts.BindingModels;
using PersonnelDepartmentContracts.BusinessLogicContracts;
using PersonnelDepartmentContracts.SearchModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PersonnelDepartmentView
{
public partial class FormPositions : Form
{
private readonly IPositionLogic _positionLogic;
public FormPositions(IPositionLogic positionLogic)
{
InitializeComponent();
_positionLogic = positionLogic;
}
private void LoadData()
{
try
{
var list = _positionLogic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка загрузки", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormPosition));
if (service is FormPosition form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonChange_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormPosition));
if (service is FormPosition form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDelete_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
try
{
if (!_positionLogic.Delete(new PositionBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении.");
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
LoadData();
}
private void FormPositions_Load(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<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 PersonnelDepartmentView
{
partial class FormType
{
/// <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()
{
textBoxName = new TextBox();
label1 = new Label();
buttonSave = new Button();
buttonCancel = new Button();
SuspendLayout();
//
// textBoxName
//
textBoxName.Location = new Point(78, 12);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(107, 23);
textBoxName.TabIndex = 0;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(13, 15);
label1.Name = "label1";
label1.Size = new Size(62, 15);
label1.TabIndex = 1;
label1.Text = "Название:";
//
// buttonSave
//
buttonSave.Location = new Point(29, 56);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(75, 23);
buttonSave.TabIndex = 2;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += ButtonSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(110, 56);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 3;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += ButtonCancel_Click;
//
// FormType
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(204, 91);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(label1);
Controls.Add(textBoxName);
FormBorderStyle = FormBorderStyle.FixedSingle;
Name = "FormType";
StartPosition = FormStartPosition.CenterScreen;
Text = "Тип договора";
Load += FormType_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private TextBox textBoxName;
private Label label1;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,86 @@
using PersonnelDepartmentBusinessLogic.BusinessLogics;
using PersonnelDepartmentContracts.BindingModels;
using PersonnelDepartmentContracts.BusinessLogicContracts;
using PersonnelDepartmentContracts.SearchModels;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PersonnelDepartmentView
{
public partial class FormType : Form
{
private readonly ITypeLogic _typeLogic;
private int? _id;
public int Id { set { _id = value; } }
public FormType(ITypeLogic typeLogic)
{
InitializeComponent();
_typeLogic = typeLogic;
}
private void FormType_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
var view = _typeLogic.ReadElement(new TypeSearchModel
{
Id = _id.Value
});
if (view != null)
{
textBoxName.Text = view.Name;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
private void ButtonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxName.Text))
{
MessageBox.Show("Введите название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
var model = new TypeBindingModel
{
Id = _id ?? 0,
Name = textBoxName.Text
};
var operationResult = _id.HasValue ? _typeLogic.Update(model) : _typeLogic.Create(model);
if (!operationResult)
{
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -0,0 +1,117 @@
namespace PersonnelDepartmentView
{
partial class FormTypes
{
/// <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()
{
buttonUpdate = new Button();
buttonDelete = new Button();
buttonChange = new Button();
buttonAdd = new Button();
dataGridView = new DataGridView();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// buttonUpdate
//
buttonUpdate.Location = new Point(255, 9);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(75, 23);
buttonUpdate.TabIndex = 9;
buttonUpdate.Text = "Обновить";
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
//
// buttonDelete
//
buttonDelete.Location = new Point(174, 9);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(75, 23);
buttonDelete.TabIndex = 8;
buttonDelete.Text = "Удалить";
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += ButtonDelete_Click;
//
// buttonChange
//
buttonChange.Location = new Point(93, 9);
buttonChange.Name = "buttonChange";
buttonChange.Size = new Size(75, 23);
buttonChange.TabIndex = 7;
buttonChange.Text = "Изменить";
buttonChange.UseVisualStyleBackColor = true;
buttonChange.Click += ButtonChange_Click;
//
// buttonAdd
//
buttonAdd.Location = new Point(12, 9);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(75, 23);
buttonAdd.TabIndex = 6;
buttonAdd.Text = "Создать";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
//
// dataGridView
//
dataGridView.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
dataGridView.BackgroundColor = Color.DarkSeaGreen;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 38);
dataGridView.Name = "dataGridView";
dataGridView.RowTemplate.Height = 25;
dataGridView.Size = new Size(564, 368);
dataGridView.TabIndex = 5;
//
// FormTypes
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(590, 420);
Controls.Add(buttonUpdate);
Controls.Add(buttonDelete);
Controls.Add(buttonChange);
Controls.Add(buttonAdd);
Controls.Add(dataGridView);
MinimumSize = new Size(400, 200);
Name = "FormTypes";
StartPosition = FormStartPosition.CenterScreen;
Text = "Таблица Типов";
Load += FormTypes_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Button buttonUpdate;
private Button buttonDelete;
private Button buttonChange;
private Button buttonAdd;
private DataGridView dataGridView;
}
}

View File

@ -0,0 +1,107 @@
using PersonnelDepartmentBusinessLogic.BusinessLogics;
using PersonnelDepartmentContracts.BindingModels;
using PersonnelDepartmentContracts.BusinessLogicContracts;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace PersonnelDepartmentView
{
public partial class FormTypes : Form
{
private readonly ITypeLogic _typeLogic;
public FormTypes(ITypeLogic typeLogic)
{
InitializeComponent();
_typeLogic = typeLogic;
}
private void LoadData()
{
try
{
var list = _typeLogic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка загрузки", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormType));
if (service is FormType form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void ButtonChange_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormType));
if (service is FormType form)
{
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
}
private void ButtonDelete_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
try
{
if (!_typeLogic.Delete(new TypeBindingModel
{
Id = id
}))
{
throw new Exception("Ошибка при удалении.");
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void ButtonUpdate_Click(object sender, EventArgs e)
{
LoadData();
}
private void FormTypes_Load(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

@ -0,0 +1,60 @@
<root>
<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

@ -16,4 +16,10 @@
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<ProjectReference Include="..\PersonnelDepartmentBusinessLogic\PersonnelDepartmentBusinessLogic.csproj" />
<ProjectReference Include="..\PersonnelDepartmentContracts\PersonnelDepartmentContracts.csproj" />
<ProjectReference Include="..\PersonnelDepartmentDatabaseImplement\PersonnelDepartmentDatabaseImplement.csproj" />
</ItemGroup>
</Project> </Project>

View File

@ -1,7 +1,17 @@
using System;
using Microsoft.Extensions.DependencyInjection;
using PersonnelDepartmentBusinessLogic.BusinessLogics;
using PersonnelDepartmentContracts.BusinessLogicContracts;
using PersonnelDepartmentContracts.StoragesContracts;
using PersonnelDepartmentDatabaseImplement.Implements;
using PersonnelTypeContracts.StoragesContracts;
namespace PersonnelDepartmentView namespace PersonnelDepartmentView
{ {
internal static class Program internal static class Program
{ {
private static ServiceProvider? _serviceProvider;
public static ServiceProvider? ServiceProvider => _serviceProvider;
/// <summary> /// <summary>
/// The main entry point for the application. /// The main entry point for the application.
/// </summary> /// </summary>
@ -11,7 +21,39 @@ namespace PersonnelDepartmentView
// 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()); var services = new ServiceCollection();
ConfigureServices(services);
_serviceProvider = services.BuildServiceProvider();
Application.Run(_serviceProvider.GetRequiredService<FormDeals>());
}
private static void ConfigureServices(ServiceCollection services)
{
services.AddTransient<IDealLogic, DealLogic>();
services.AddTransient<IDepartmentLogic, DepartmentLogic>();
services.AddTransient<IEmployeeLogic, EmployeeLogic>();
services.AddTransient<IPositionLogic, PositionLogic>();
services.AddTransient<ITypeLogic, TypeLogic>();
services.AddTransient<IBackUpLogic, BackUpLogic>();
services.AddTransient<IDealStorage, DealStorage>();
services.AddTransient<IDepartmentStorage, DepartmentStorage>();
services.AddTransient<IEmployeeStorage, EmployeeStorage>();
services.AddTransient<ITypeStorage, TypeStorage>();
services.AddTransient<IPositionStorage, PositionStorage>();
services.AddTransient<IBackUpInfo, BackUpInfo>();
services.AddTransient<FormDeal>();
services.AddTransient<FormDeals>();
services.AddTransient<FormDepartment>();
services.AddTransient<FormDepartments>();
services.AddTransient<FormEmployee>();
services.AddTransient<FormEmployees>();
services.AddTransient<FormPosition>();
services.AddTransient<FormPositions>();
services.AddTransient<FormType>();
services.AddTransient<FormTypes>();
services.AddTransient<FormGeneration>();
} }
} }
} }