Чуть поделал формы
This commit is contained in:
parent
febeeef7b3
commit
5e71f46d73
@ -5,12 +5,15 @@ public class Company
|
|||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
public string Name { get; private set; } = string.Empty;
|
public string Name { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public static Company CreateEntity(int id, string companyName)
|
public string Address { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public static Company CreateEntity(int id, string companyName, string addres)
|
||||||
{
|
{
|
||||||
return new Company
|
return new Company
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
Name = companyName
|
Name = companyName,
|
||||||
|
Address = addres
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,18 @@ public class Service
|
|||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
public string Name { get; private set; } = string.Empty;
|
public string Name { get; private set; } = string.Empty;
|
||||||
|
public string Description { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public IEnumerable<OrderService> OrderService { get; private set; } = [];
|
public IEnumerable<OrderService> OrderService { get; private set; } = [];
|
||||||
|
|
||||||
public static Service CreateEntity(int id, string serviceName, IEnumerable<OrderService> orderService)
|
public static Service CreateEntity(int id, string serviceName, IEnumerable<OrderService> orderService, string description)
|
||||||
{
|
{
|
||||||
return new Service
|
return new Service
|
||||||
{
|
{
|
||||||
Id = id,
|
Id = id,
|
||||||
Name = serviceName,
|
Name = serviceName,
|
||||||
OrderService = orderService
|
OrderService = orderService,
|
||||||
|
Description = description
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,18 +43,20 @@
|
|||||||
panel.Controls.Add(buttonRemove);
|
panel.Controls.Add(buttonRemove);
|
||||||
panel.Controls.Add(buttonAdd);
|
panel.Controls.Add(buttonAdd);
|
||||||
panel.Dock = DockStyle.Right;
|
panel.Dock = DockStyle.Right;
|
||||||
panel.Location = new Point(652, 0);
|
panel.Location = new Point(745, 0);
|
||||||
|
panel.Margin = new Padding(3, 4, 3, 4);
|
||||||
panel.Name = "panel";
|
panel.Name = "panel";
|
||||||
panel.Size = new Size(148, 450);
|
panel.Size = new Size(169, 600);
|
||||||
panel.TabIndex = 1;
|
panel.TabIndex = 1;
|
||||||
//
|
//
|
||||||
// buttonUpdate
|
// buttonUpdate
|
||||||
//
|
//
|
||||||
buttonUpdate.BackgroundImage = Properties.Resources.edit;
|
buttonUpdate.BackgroundImage = Properties.Resources.edit;
|
||||||
buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
|
buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
buttonUpdate.Location = new Point(36, 249);
|
buttonUpdate.Location = new Point(41, 332);
|
||||||
|
buttonUpdate.Margin = new Padding(3, 4, 3, 4);
|
||||||
buttonUpdate.Name = "buttonUpdate";
|
buttonUpdate.Name = "buttonUpdate";
|
||||||
buttonUpdate.Size = new Size(78, 80);
|
buttonUpdate.Size = new Size(89, 107);
|
||||||
buttonUpdate.TabIndex = 2;
|
buttonUpdate.TabIndex = 2;
|
||||||
buttonUpdate.UseVisualStyleBackColor = true;
|
buttonUpdate.UseVisualStyleBackColor = true;
|
||||||
buttonUpdate.Click += ButtonUpdate_Click;
|
buttonUpdate.Click += ButtonUpdate_Click;
|
||||||
@ -63,9 +65,10 @@
|
|||||||
//
|
//
|
||||||
buttonRemove.BackgroundImage = Properties.Resources.minus;
|
buttonRemove.BackgroundImage = Properties.Resources.minus;
|
||||||
buttonRemove.BackgroundImageLayout = ImageLayout.Stretch;
|
buttonRemove.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
buttonRemove.Location = new Point(36, 141);
|
buttonRemove.Location = new Point(41, 188);
|
||||||
|
buttonRemove.Margin = new Padding(3, 4, 3, 4);
|
||||||
buttonRemove.Name = "buttonRemove";
|
buttonRemove.Name = "buttonRemove";
|
||||||
buttonRemove.Size = new Size(75, 76);
|
buttonRemove.Size = new Size(86, 101);
|
||||||
buttonRemove.TabIndex = 1;
|
buttonRemove.TabIndex = 1;
|
||||||
buttonRemove.UseVisualStyleBackColor = true;
|
buttonRemove.UseVisualStyleBackColor = true;
|
||||||
buttonRemove.Click += ButtonRemove_Click;
|
buttonRemove.Click += ButtonRemove_Click;
|
||||||
@ -74,9 +77,10 @@
|
|||||||
//
|
//
|
||||||
buttonAdd.BackgroundImage = Properties.Resources.plus;
|
buttonAdd.BackgroundImage = Properties.Resources.plus;
|
||||||
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
buttonAdd.Location = new Point(33, 43);
|
buttonAdd.Location = new Point(38, 57);
|
||||||
|
buttonAdd.Margin = new Padding(3, 4, 3, 4);
|
||||||
buttonAdd.Name = "buttonAdd";
|
buttonAdd.Name = "buttonAdd";
|
||||||
buttonAdd.Size = new Size(81, 71);
|
buttonAdd.Size = new Size(93, 95);
|
||||||
buttonAdd.TabIndex = 0;
|
buttonAdd.TabIndex = 0;
|
||||||
buttonAdd.UseVisualStyleBackColor = true;
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
buttonAdd.Click += ButtonAdd_Click;
|
buttonAdd.Click += ButtonAdd_Click;
|
||||||
@ -90,22 +94,26 @@
|
|||||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
dataGridView.Dock = DockStyle.Fill;
|
dataGridView.Dock = DockStyle.Fill;
|
||||||
dataGridView.Location = new Point(0, 0);
|
dataGridView.Location = new Point(0, 0);
|
||||||
|
dataGridView.Margin = new Padding(3, 4, 3, 4);
|
||||||
dataGridView.MultiSelect = false;
|
dataGridView.MultiSelect = false;
|
||||||
dataGridView.Name = "dataGridView";
|
dataGridView.Name = "dataGridView";
|
||||||
dataGridView.ReadOnly = true;
|
dataGridView.ReadOnly = true;
|
||||||
dataGridView.RowHeadersVisible = false;
|
dataGridView.RowHeadersVisible = false;
|
||||||
|
dataGridView.RowHeadersWidth = 51;
|
||||||
dataGridView.RowTemplate.Height = 25;
|
dataGridView.RowTemplate.Height = 25;
|
||||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
dataGridView.Size = new Size(652, 450);
|
dataGridView.Size = new Size(745, 600);
|
||||||
dataGridView.TabIndex = 1;
|
dataGridView.TabIndex = 1;
|
||||||
|
dataGridView.CellContentClick += dataGridView_CellContentClick;
|
||||||
//
|
//
|
||||||
// FormCompanies
|
// FormCompanies
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(800, 450);
|
ClientSize = new Size(914, 600);
|
||||||
Controls.Add(dataGridView);
|
Controls.Add(dataGridView);
|
||||||
Controls.Add(panel);
|
Controls.Add(panel);
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
Name = "FormCompanies";
|
Name = "FormCompanies";
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
Text = "Компании";
|
Text = "Компании";
|
||||||
|
@ -97,5 +97,10 @@ namespace ITServiceManager.Forms
|
|||||||
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,29 +32,35 @@
|
|||||||
textBoxName = new TextBox();
|
textBoxName = new TextBox();
|
||||||
buttonAdd = new Button();
|
buttonAdd = new Button();
|
||||||
buttonCancel = new Button();
|
buttonCancel = new Button();
|
||||||
|
labelAddres = new Label();
|
||||||
|
textBoxAddress = new TextBox();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// labelName
|
// labelName
|
||||||
//
|
//
|
||||||
labelName.AutoSize = true;
|
labelName.AutoSize = true;
|
||||||
labelName.Location = new Point(89, 101);
|
labelName.Location = new Point(102, 135);
|
||||||
labelName.Name = "labelName";
|
labelName.Name = "labelName";
|
||||||
labelName.Size = new Size(118, 15);
|
labelName.Size = new Size(152, 20);
|
||||||
labelName.TabIndex = 0;
|
labelName.TabIndex = 0;
|
||||||
labelName.Text = "Название компании";
|
labelName.Text = "Название компании";
|
||||||
|
labelName.Click += this.labelName_Click;
|
||||||
//
|
//
|
||||||
// textBoxName
|
// textBoxName
|
||||||
//
|
//
|
||||||
textBoxName.Location = new Point(268, 98);
|
textBoxName.Location = new Point(306, 131);
|
||||||
|
textBoxName.Margin = new Padding(3, 4, 3, 4);
|
||||||
textBoxName.Name = "textBoxName";
|
textBoxName.Name = "textBoxName";
|
||||||
textBoxName.Size = new Size(176, 23);
|
textBoxName.Size = new Size(201, 27);
|
||||||
textBoxName.TabIndex = 1;
|
textBoxName.TabIndex = 1;
|
||||||
|
textBoxName.TextChanged += textBoxName_TextChanged;
|
||||||
//
|
//
|
||||||
// buttonAdd
|
// buttonAdd
|
||||||
//
|
//
|
||||||
buttonAdd.Location = new Point(95, 238);
|
buttonAdd.Location = new Point(109, 317);
|
||||||
|
buttonAdd.Margin = new Padding(3, 4, 3, 4);
|
||||||
buttonAdd.Name = "buttonAdd";
|
buttonAdd.Name = "buttonAdd";
|
||||||
buttonAdd.Size = new Size(112, 28);
|
buttonAdd.Size = new Size(128, 37);
|
||||||
buttonAdd.TabIndex = 2;
|
buttonAdd.TabIndex = 2;
|
||||||
buttonAdd.Text = "Добавить";
|
buttonAdd.Text = "Добавить";
|
||||||
buttonAdd.UseVisualStyleBackColor = true;
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
@ -62,23 +68,44 @@
|
|||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
buttonCancel.Location = new Point(321, 238);
|
buttonCancel.Location = new Point(367, 317);
|
||||||
|
buttonCancel.Margin = new Padding(3, 4, 3, 4);
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(112, 28);
|
buttonCancel.Size = new Size(128, 37);
|
||||||
buttonCancel.TabIndex = 3;
|
buttonCancel.TabIndex = 3;
|
||||||
buttonCancel.Text = "Отмена";
|
buttonCancel.Text = "Отмена";
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
buttonCancel.Click += ButtonCancel_Click;
|
buttonCancel.Click += ButtonCancel_Click;
|
||||||
//
|
//
|
||||||
|
// labelAddres
|
||||||
|
//
|
||||||
|
labelAddres.AutoSize = true;
|
||||||
|
labelAddres.Location = new Point(121, 195);
|
||||||
|
labelAddres.Name = "labelAddres";
|
||||||
|
labelAddres.Size = new Size(133, 20);
|
||||||
|
labelAddres.TabIndex = 4;
|
||||||
|
labelAddres.Text = "Адресс компании";
|
||||||
|
//
|
||||||
|
// textBoxAddress
|
||||||
|
//
|
||||||
|
textBoxAddress.Location = new Point(306, 188);
|
||||||
|
textBoxAddress.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
textBoxAddress.Name = "textBoxAddress";
|
||||||
|
textBoxAddress.Size = new Size(201, 27);
|
||||||
|
textBoxAddress.TabIndex = 5;
|
||||||
|
//
|
||||||
// FormCompany
|
// FormCompany
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(536, 306);
|
ClientSize = new Size(613, 408);
|
||||||
|
Controls.Add(textBoxAddress);
|
||||||
|
Controls.Add(labelAddres);
|
||||||
Controls.Add(buttonCancel);
|
Controls.Add(buttonCancel);
|
||||||
Controls.Add(buttonAdd);
|
Controls.Add(buttonAdd);
|
||||||
Controls.Add(textBoxName);
|
Controls.Add(textBoxName);
|
||||||
Controls.Add(labelName);
|
Controls.Add(labelName);
|
||||||
|
Margin = new Padding(3, 4, 3, 4);
|
||||||
Name = "FormCompany";
|
Name = "FormCompany";
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
Text = "Компания";
|
Text = "Компания";
|
||||||
@ -92,5 +119,7 @@
|
|||||||
private TextBox textBoxName;
|
private TextBox textBoxName;
|
||||||
private Button buttonAdd;
|
private Button buttonAdd;
|
||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
|
private Label labelAddres;
|
||||||
|
private TextBox textBoxAddress;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -29,6 +29,7 @@ namespace ITServiceManager.Forms
|
|||||||
throw new InvalidDataException(nameof(company));
|
throw new InvalidDataException(nameof(company));
|
||||||
}
|
}
|
||||||
textBoxName.Text = company.Name;
|
textBoxName.Text = company.Name;
|
||||||
|
textBoxAddress.Text = company.Address;
|
||||||
_companyId = value;
|
_companyId = value;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -43,12 +44,12 @@ namespace ITServiceManager.Forms
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_companyRepository = companyRepository ?? throw new ArgumentNullException(nameof(companyRepository));
|
_companyRepository = companyRepository ?? throw new ArgumentNullException(nameof(companyRepository));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(textBoxName.Text))
|
if (string.IsNullOrWhiteSpace(textBoxName.Text) || string.IsNullOrWhiteSpace(textBoxAddress.Text))
|
||||||
{
|
{
|
||||||
throw new Exception("Имеются незаполненные поля");
|
throw new Exception("Имеются незаполненные поля");
|
||||||
}
|
}
|
||||||
@ -68,6 +69,11 @@ namespace ITServiceManager.Forms
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||||
private Company CreateCompany(int id) => Company.CreateEntity(id, textBoxName.Text);
|
private Company CreateCompany(int id) => Company.CreateEntity(id, textBoxName.Text, textBoxAddress.Text);
|
||||||
|
|
||||||
|
private void textBoxName_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
128
ITServiceManager/ITServiceManager/Forms/FormEmployees.Designer.cs
generated
Normal file
128
ITServiceManager/ITServiceManager/Forms/FormEmployees.Designer.cs
generated
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
namespace ITServiceManager.Forms
|
||||||
|
{
|
||||||
|
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()
|
||||||
|
{
|
||||||
|
panel = new Panel();
|
||||||
|
buttonUpdate = new Button();
|
||||||
|
buttonRemove = new Button();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
panel.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// panel
|
||||||
|
//
|
||||||
|
panel.Controls.Add(buttonUpdate);
|
||||||
|
panel.Controls.Add(buttonRemove);
|
||||||
|
panel.Controls.Add(buttonAdd);
|
||||||
|
panel.Dock = DockStyle.Right;
|
||||||
|
panel.Location = new Point(745, 0);
|
||||||
|
panel.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
panel.Name = "panel";
|
||||||
|
panel.Size = new Size(169, 600);
|
||||||
|
panel.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// buttonUpdate
|
||||||
|
//
|
||||||
|
buttonUpdate.BackgroundImage = Properties.Resources.edit;
|
||||||
|
buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonUpdate.Location = new Point(41, 332);
|
||||||
|
buttonUpdate.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonUpdate.Name = "buttonUpdate";
|
||||||
|
buttonUpdate.Size = new Size(89, 107);
|
||||||
|
buttonUpdate.TabIndex = 2;
|
||||||
|
buttonUpdate.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// buttonRemove
|
||||||
|
//
|
||||||
|
buttonRemove.BackgroundImage = Properties.Resources.minus;
|
||||||
|
buttonRemove.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonRemove.Location = new Point(41, 188);
|
||||||
|
buttonRemove.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonRemove.Name = "buttonRemove";
|
||||||
|
buttonRemove.Size = new Size(86, 101);
|
||||||
|
buttonRemove.TabIndex = 1;
|
||||||
|
buttonRemove.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.BackgroundImage = Properties.Resources.plus;
|
||||||
|
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonAdd.Location = new Point(38, 57);
|
||||||
|
buttonAdd.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(93, 95);
|
||||||
|
buttonAdd.TabIndex = 0;
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.AllowUserToAddRows = false;
|
||||||
|
dataGridView.AllowUserToDeleteRows = false;
|
||||||
|
dataGridView.AllowUserToResizeColumns = false;
|
||||||
|
dataGridView.AllowUserToResizeRows = false;
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Dock = DockStyle.Fill;
|
||||||
|
dataGridView.Location = new Point(0, 0);
|
||||||
|
dataGridView.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
dataGridView.MultiSelect = false;
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.ReadOnly = true;
|
||||||
|
dataGridView.RowHeadersVisible = false;
|
||||||
|
dataGridView.RowHeadersWidth = 51;
|
||||||
|
dataGridView.RowTemplate.Height = 25;
|
||||||
|
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
dataGridView.Size = new Size(745, 600);
|
||||||
|
dataGridView.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// FormEmployees
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(914, 600);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Controls.Add(panel);
|
||||||
|
Name = "FormEmployees";
|
||||||
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
|
Text = "FormEmployees";
|
||||||
|
panel.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Panel panel;
|
||||||
|
private Button buttonUpdate;
|
||||||
|
private Button buttonRemove;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
117
ITServiceManager/ITServiceManager/Forms/FormEmployees.cs
Normal file
117
ITServiceManager/ITServiceManager/Forms/FormEmployees.cs
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
using ITServiceManager.Repositories;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Data;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
|
namespace ITServiceManager.Forms
|
||||||
|
{
|
||||||
|
public partial class FormEmployees : Form
|
||||||
|
{
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
private readonly IEmployeeRepository _employeeRepository;
|
||||||
|
public FormEmployees(IUnityContainer container, IEmployeeRepository
|
||||||
|
employeeRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ??
|
||||||
|
throw new ArgumentNullException(nameof(container));
|
||||||
|
_employeeRepository = employeeRepository ??
|
||||||
|
throw new
|
||||||
|
ArgumentNullException(nameof(employeeRepository));
|
||||||
|
}
|
||||||
|
private void FormEmployees_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при загрузке",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormEmployee>().ShowDialog();
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при добавлении",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var form = _container.Resolve<FormEmployee>();
|
||||||
|
form.Id = findId;
|
||||||
|
form.ShowDialog();
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при изменении",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonDel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Удаление",
|
||||||
|
MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_employeeRepository.DeleteEmployee(findId);
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при удалении",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void LoadList() => dataGridView.DataSource =
|
||||||
|
_employeeRepository.ReadEmployees();
|
||||||
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
|
{
|
||||||
|
id = 0;
|
||||||
|
if (dataGridView.SelectedRows.Count < 1)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Нет выбранной записи", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
id =
|
||||||
|
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
120
ITServiceManager/ITServiceManager/Forms/FormEmployees.resx
Normal file
120
ITServiceManager/ITServiceManager/Forms/FormEmployees.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
@ -28,12 +28,92 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.components = new System.ComponentModel.Container();
|
buttonCancel = new Button();
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
buttonAdd = new Button();
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
textBoxName = new TextBox();
|
||||||
this.Text = "FormService";
|
labelName = new Label();
|
||||||
|
labelDescription = new Label();
|
||||||
|
richTextBoxDescription = new RichTextBox();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(463, 300);
|
||||||
|
buttonCancel.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(128, 37);
|
||||||
|
buttonCancel.TabIndex = 7;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.Location = new Point(205, 300);
|
||||||
|
buttonAdd.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(128, 37);
|
||||||
|
buttonAdd.TabIndex = 6;
|
||||||
|
buttonAdd.Text = "Добавить";
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// textBoxName
|
||||||
|
//
|
||||||
|
textBoxName.Location = new Point(402, 114);
|
||||||
|
textBoxName.Margin = new Padding(3, 4, 3, 4);
|
||||||
|
textBoxName.Name = "textBoxName";
|
||||||
|
textBoxName.Size = new Size(264, 27);
|
||||||
|
textBoxName.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// labelName
|
||||||
|
//
|
||||||
|
labelName.AutoSize = true;
|
||||||
|
labelName.Location = new Point(132, 117);
|
||||||
|
labelName.Name = "labelName";
|
||||||
|
labelName.Size = new Size(125, 20);
|
||||||
|
labelName.TabIndex = 4;
|
||||||
|
labelName.Text = "Название услуги";
|
||||||
|
//
|
||||||
|
// labelDescription
|
||||||
|
//
|
||||||
|
labelDescription.AutoSize = true;
|
||||||
|
labelDescription.Location = new Point(132, 193);
|
||||||
|
labelDescription.Name = "labelDescription";
|
||||||
|
labelDescription.Size = new Size(127, 20);
|
||||||
|
labelDescription.TabIndex = 8;
|
||||||
|
labelDescription.Text = "Описание услуги";
|
||||||
|
//
|
||||||
|
// richTextBoxDescription
|
||||||
|
//
|
||||||
|
richTextBoxDescription.Location = new Point(402, 161);
|
||||||
|
richTextBoxDescription.Name = "richTextBoxDescription";
|
||||||
|
richTextBoxDescription.Size = new Size(264, 120);
|
||||||
|
richTextBoxDescription.TabIndex = 9;
|
||||||
|
richTextBoxDescription.Text = "";
|
||||||
|
//
|
||||||
|
// FormService
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(richTextBoxDescription);
|
||||||
|
Controls.Add(labelDescription);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonAdd);
|
||||||
|
Controls.Add(textBoxName);
|
||||||
|
Controls.Add(labelName);
|
||||||
|
Name = "FormService";
|
||||||
|
Text = "FormService";
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private TextBox textBoxName;
|
||||||
|
private Label labelName;
|
||||||
|
private Label labelDescription;
|
||||||
|
private RichTextBox richTextBoxDescription;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,17 +1,17 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<root>
|
<root>
|
||||||
<!--
|
<!--
|
||||||
Microsoft ResX Schema
|
Microsoft ResX Schema
|
||||||
|
|
||||||
Version 2.0
|
Version 2.0
|
||||||
|
|
||||||
The primary goals of this format is to allow a simple XML format
|
The primary goals of this format is to allow a simple XML format
|
||||||
that is mostly human readable. The generation and parsing of the
|
that is mostly human readable. The generation and parsing of the
|
||||||
various data types are done through the TypeConverter classes
|
various data types are done through the TypeConverter classes
|
||||||
associated with the data types.
|
associated with the data types.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
... ado.net/XML headers & schema ...
|
... ado.net/XML headers & schema ...
|
||||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
<resheader name="version">2.0</resheader>
|
<resheader name="version">2.0</resheader>
|
||||||
@ -26,36 +26,36 @@
|
|||||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
<comment>This is a comment</comment>
|
<comment>This is a comment</comment>
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
There are any number of "resheader" rows that contain simple
|
There are any number of "resheader" rows that contain simple
|
||||||
name/value pairs.
|
name/value pairs.
|
||||||
|
|
||||||
Each data row contains a name, and value. The row also contains a
|
Each data row contains a name, and value. The row also contains a
|
||||||
type or mimetype. Type corresponds to a .NET class that support
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
text/value conversion through the TypeConverter architecture.
|
text/value conversion through the TypeConverter architecture.
|
||||||
Classes that don't support this are serialized and stored with the
|
Classes that don't support this are serialized and stored with the
|
||||||
mimetype set.
|
mimetype set.
|
||||||
|
|
||||||
The mimetype is used for serialized objects, and tells the
|
The mimetype is used for serialized objects, and tells the
|
||||||
ResXResourceReader how to depersist the object. This is currently not
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
extensible. For a given mimetype the value must be set accordingly:
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
that the ResXResourceWriter will generate, however the reader can
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
read any of the formats listed below.
|
read any of the formats listed below.
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.binary.base64
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
value : The object must be serialized with
|
value : The object must be serialized with
|
||||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.soap.base64
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
value : The object must be serialized with
|
value : The object must be serialized with
|
||||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
value : The object must be serialized into a byte array
|
value : The object must be serialized into a byte array
|
||||||
: using a System.ComponentModel.TypeConverter
|
: using a System.ComponentModel.TypeConverter
|
||||||
: and then encoded with base64 encoding.
|
: and then encoded with base64 encoding.
|
||||||
-->
|
-->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user