merge
This commit is contained in:
commit
a7180a1556
@ -43,20 +43,18 @@
|
|||||||
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(745, 0);
|
panel.Location = new Point(652, 0);
|
||||||
panel.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
panel.Name = "panel";
|
panel.Name = "panel";
|
||||||
panel.Size = new Size(169, 600);
|
panel.Size = new Size(148, 450);
|
||||||
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(41, 332);
|
buttonUpdate.Location = new Point(36, 249);
|
||||||
buttonUpdate.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
buttonUpdate.Name = "buttonUpdate";
|
buttonUpdate.Name = "buttonUpdate";
|
||||||
buttonUpdate.Size = new Size(89, 107);
|
buttonUpdate.Size = new Size(78, 80);
|
||||||
buttonUpdate.TabIndex = 2;
|
buttonUpdate.TabIndex = 2;
|
||||||
buttonUpdate.UseVisualStyleBackColor = true;
|
buttonUpdate.UseVisualStyleBackColor = true;
|
||||||
buttonUpdate.Click += ButtonUpdate_Click;
|
buttonUpdate.Click += ButtonUpdate_Click;
|
||||||
@ -65,10 +63,9 @@
|
|||||||
//
|
//
|
||||||
buttonRemove.BackgroundImage = Properties.Resources.minus;
|
buttonRemove.BackgroundImage = Properties.Resources.minus;
|
||||||
buttonRemove.BackgroundImageLayout = ImageLayout.Stretch;
|
buttonRemove.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
buttonRemove.Location = new Point(41, 188);
|
buttonRemove.Location = new Point(36, 141);
|
||||||
buttonRemove.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
buttonRemove.Name = "buttonRemove";
|
buttonRemove.Name = "buttonRemove";
|
||||||
buttonRemove.Size = new Size(86, 101);
|
buttonRemove.Size = new Size(75, 76);
|
||||||
buttonRemove.TabIndex = 1;
|
buttonRemove.TabIndex = 1;
|
||||||
buttonRemove.UseVisualStyleBackColor = true;
|
buttonRemove.UseVisualStyleBackColor = true;
|
||||||
buttonRemove.Click += ButtonRemove_Click;
|
buttonRemove.Click += ButtonRemove_Click;
|
||||||
@ -77,10 +74,9 @@
|
|||||||
//
|
//
|
||||||
buttonAdd.BackgroundImage = Properties.Resources.plus;
|
buttonAdd.BackgroundImage = Properties.Resources.plus;
|
||||||
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
buttonAdd.Location = new Point(38, 57);
|
buttonAdd.Location = new Point(33, 43);
|
||||||
buttonAdd.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
buttonAdd.Name = "buttonAdd";
|
buttonAdd.Name = "buttonAdd";
|
||||||
buttonAdd.Size = new Size(93, 95);
|
buttonAdd.Size = new Size(81, 71);
|
||||||
buttonAdd.TabIndex = 0;
|
buttonAdd.TabIndex = 0;
|
||||||
buttonAdd.UseVisualStyleBackColor = true;
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
buttonAdd.Click += ButtonAdd_Click;
|
buttonAdd.Click += ButtonAdd_Click;
|
||||||
@ -95,7 +91,6 @@
|
|||||||
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;
|
||||||
@ -103,18 +98,16 @@
|
|||||||
dataGridView.RowHeadersWidth = 51;
|
dataGridView.RowHeadersWidth = 51;
|
||||||
dataGridView.RowTemplate.Height = 25;
|
dataGridView.RowTemplate.Height = 25;
|
||||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
dataGridView.Size = new Size(745, 600);
|
dataGridView.Size = new Size(652, 450);
|
||||||
dataGridView.TabIndex = 1;
|
dataGridView.TabIndex = 1;
|
||||||
dataGridView.CellContentClick += dataGridView_CellContentClick;
|
|
||||||
//
|
//
|
||||||
// FormCompanies
|
// FormCompanies
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(914, 600);
|
ClientSize = new Size(800, 450);
|
||||||
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 = "Компании";
|
||||||
|
@ -89,8 +89,4 @@ public partial class FormCompanies : Form
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?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
|
||||||
|
|
||||||
@ -48,7 +48,7 @@
|
|||||||
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
|
||||||
|
@ -1,116 +1,106 @@
|
|||||||
using ITServiceManager.Repositories;
|
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;
|
using Unity;
|
||||||
|
|
||||||
namespace ITServiceManager.Forms
|
namespace ITServiceManager.Forms;
|
||||||
|
|
||||||
|
public partial class FormServices : Form
|
||||||
{
|
{
|
||||||
public partial class FormServices : Form
|
private readonly IUnityContainer _container;
|
||||||
|
private readonly IServiceRepository _serviceRepository;
|
||||||
|
public FormServices(IUnityContainer container, IServiceRepository
|
||||||
|
serviceRepository)
|
||||||
{
|
{
|
||||||
private readonly IUnityContainer _container;
|
InitializeComponent();
|
||||||
private readonly IServiceRepository _serviceRepository;
|
_container = container ??
|
||||||
public FormServices(IUnityContainer container, IServiceRepository
|
throw new ArgumentNullException(nameof(container));
|
||||||
serviceRepository)
|
_serviceRepository = serviceRepository ??
|
||||||
{
|
throw new
|
||||||
InitializeComponent();
|
ArgumentNullException(nameof(serviceRepository));
|
||||||
_container = container ??
|
|
||||||
throw new ArgumentNullException(nameof(container));
|
|
||||||
_serviceRepository = serviceRepository ??
|
|
||||||
throw new
|
|
||||||
ArgumentNullException(nameof(serviceRepository));
|
|
||||||
}
|
|
||||||
private void FormServices_Load(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при загрузке",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_container.Resolve<FormService>().ShowDialog();
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при добавлении",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var form = _container.Resolve<FormService>();
|
|
||||||
form.Id = findId;
|
|
||||||
form.ShowDialog();
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при изменении",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void ButtonDel_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (MessageBox.Show("Удалить запись?", "Удаление",
|
|
||||||
MessageBoxButtons.YesNo) != DialogResult.Yes)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
_serviceRepository.DeleteService(findId);
|
|
||||||
LoadList();
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при удалении",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void LoadList() => dataGridView.DataSource =
|
|
||||||
_serviceRepository.ReadServices();
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
|
||||||
{
|
|
||||||
id = 0;
|
|
||||||
if (dataGridView.SelectedRows.Count < 1)
|
|
||||||
{
|
|
||||||
MessageBox.Show("Нет выбранной записи", "Ошибка",
|
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
id =
|
|
||||||
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
private void FormServices_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при загрузке",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormService>().ShowDialog();
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при добавлении",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var form = _container.Resolve<FormService>();
|
||||||
|
form.Id = findId;
|
||||||
|
form.ShowDialog();
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при изменении",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonDel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Удаление",
|
||||||
|
MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_serviceRepository.DeleteService(findId);
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при удалении",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void LoadList() => dataGridView.DataSource =
|
||||||
|
_serviceRepository.ReadServices();
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user