This commit is contained in:
Егор Пыжов 2024-12-15 02:59:57 +04:00
commit 4cee06143d
4 changed files with 63 additions and 84 deletions

View File

@ -43,20 +43,18 @@
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.Location = new Point(652, 0);
panel.Name = "panel";
panel.Size = new Size(169, 600);
panel.Size = new Size(148, 450);
panel.TabIndex = 1;
//
// 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.Location = new Point(36, 249);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(89, 107);
buttonUpdate.Size = new Size(78, 80);
buttonUpdate.TabIndex = 2;
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += ButtonUpdate_Click;
@ -65,10 +63,9 @@
//
buttonRemove.BackgroundImage = Properties.Resources.minus;
buttonRemove.BackgroundImageLayout = ImageLayout.Stretch;
buttonRemove.Location = new Point(41, 188);
buttonRemove.Margin = new Padding(3, 4, 3, 4);
buttonRemove.Location = new Point(36, 141);
buttonRemove.Name = "buttonRemove";
buttonRemove.Size = new Size(86, 101);
buttonRemove.Size = new Size(75, 76);
buttonRemove.TabIndex = 1;
buttonRemove.UseVisualStyleBackColor = true;
buttonRemove.Click += ButtonRemove_Click;
@ -77,10 +74,9 @@
//
buttonAdd.BackgroundImage = Properties.Resources.plus;
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
buttonAdd.Location = new Point(38, 57);
buttonAdd.Margin = new Padding(3, 4, 3, 4);
buttonAdd.Location = new Point(33, 43);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(93, 95);
buttonAdd.Size = new Size(81, 71);
buttonAdd.TabIndex = 0;
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += ButtonAdd_Click;
@ -95,7 +91,6 @@
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;
@ -103,18 +98,16 @@
dataGridView.RowHeadersWidth = 51;
dataGridView.RowTemplate.Height = 25;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(745, 600);
dataGridView.Size = new Size(652, 450);
dataGridView.TabIndex = 1;
dataGridView.CellContentClick += dataGridView_CellContentClick;
//
// FormCompanies
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(914, 600);
ClientSize = new Size(800, 450);
Controls.Add(dataGridView);
Controls.Add(panel);
Margin = new Padding(3, 4, 3, 4);
Name = "FormCompanies";
StartPosition = FormStartPosition.CenterParent;
Text = "Компании";

View File

@ -93,8 +93,4 @@ public partial class FormCompanies : Form
return true;
}
private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
}
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Microsoft ResX Schema
Version 2.0
@ -48,7 +48,7 @@
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

View File

@ -1,77 +1,68 @@
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
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;
private readonly IServiceRepository _serviceRepository;
public FormServices(IUnityContainer container, IServiceRepository
serviceRepository)
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_serviceRepository = serviceRepository ??
throw new
ArgumentNullException(nameof(serviceRepository));
}
private void FormServices_Load(object sender, EventArgs e)
{
try
{
InitializeComponent();
_container = container ??
throw new ArgumentNullException(nameof(container));
_serviceRepository = serviceRepository ??
throw new
ArgumentNullException(nameof(serviceRepository));
LoadList();
}
private void FormServices_Load(object sender, EventArgs e)
catch (Exception ex)
{
try
{
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при загрузке",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
MessageBox.Show(ex.Message, "Ошибка при загрузке",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonAdd_Click(object sender, EventArgs e)
private void ButtonAdd_Click(object sender, EventArgs e)
{
try
{
try
{
_container.Resolve<FormService>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
_container.Resolve<FormService>().ShowDialog();
LoadList();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка при добавлении",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonUpd_Click(object sender, EventArgs e)
private void ButtonUpd_Click(object sender, EventArgs e)
{
if (!TryGetIdentifierFromSelectedRow(out var findId))
{
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);
}
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)
{
@ -114,6 +105,5 @@ namespace ITServiceManager.Forms
return true;
}
}
}