сделанный вариант
This commit is contained in:
parent
aa3d58bb15
commit
dff96e44cf
@ -8,10 +8,8 @@ public class Order
|
|||||||
public decimal OrderPrice { get; private set; }
|
public decimal OrderPrice { get; private set; }
|
||||||
|
|
||||||
public IEnumerable<OrderService> OrderService { get; private set; } = [];
|
public IEnumerable<OrderService> OrderService { get; private set; } = [];
|
||||||
public IEnumerable<Appointment> Appointments { get; private set; } = [];
|
|
||||||
|
|
||||||
public static Order CreateOperation(int id, int companyId, decimal orderPrice, IEnumerable<OrderService> orderService,
|
public static Order CreateOperation(int id, int companyId, decimal orderPrice, IEnumerable<OrderService> orderService)
|
||||||
IEnumerable<Appointment> appointments)
|
|
||||||
{
|
{
|
||||||
return new Order
|
return new Order
|
||||||
{
|
{
|
||||||
@ -19,8 +17,7 @@ public class Order
|
|||||||
CompanyId = companyId,
|
CompanyId = companyId,
|
||||||
OrderDate = DateTime.Now,
|
OrderDate = DateTime.Now,
|
||||||
OrderPrice = orderPrice,
|
OrderPrice = orderPrice,
|
||||||
OrderService = orderService,
|
OrderService = orderService
|
||||||
Appointments = appointments
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ public class OrderService
|
|||||||
Id = id,
|
Id = id,
|
||||||
OrderId = orderId,
|
OrderId = orderId,
|
||||||
ServiceId = serviceId,
|
ServiceId = serviceId,
|
||||||
|
Quantity = serviceQuantity,
|
||||||
ExecutionDate = executionDate
|
ExecutionDate = executionDate
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -6,15 +6,12 @@ public class Service
|
|||||||
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 string Description { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public IEnumerable<OrderService> OrderService { get; private set; } = [];
|
public static Service CreateEntity(int id, string serviceName, string description)
|
||||||
|
|
||||||
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,
|
|
||||||
Description = description
|
Description = description
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -30,13 +30,13 @@
|
|||||||
{
|
{
|
||||||
menuStrip1 = new MenuStrip();
|
menuStrip1 = new MenuStrip();
|
||||||
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
операцииToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
компанииToolStripMenuItem = new ToolStripMenuItem();
|
компанииToolStripMenuItem = new ToolStripMenuItem();
|
||||||
сотрудникиToolStripMenuItem = new ToolStripMenuItem();
|
сотрудникиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
услугиToolStripMenuItem = new ToolStripMenuItem();
|
услугиToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
операцииToolStripMenuItem = new ToolStripMenuItem();
|
||||||
заказыToolStripMenuItem = new ToolStripMenuItem();
|
заказыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
назначениеСотрудниковToolStripMenuItem = new ToolStripMenuItem();
|
назначениеСотрудниковToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
menuStrip1.SuspendLayout();
|
menuStrip1.SuspendLayout();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -56,6 +56,27 @@
|
|||||||
справочникиToolStripMenuItem.Size = new Size(94, 20);
|
справочникиToolStripMenuItem.Size = new Size(94, 20);
|
||||||
справочникиToolStripMenuItem.Text = "Справочники";
|
справочникиToolStripMenuItem.Text = "Справочники";
|
||||||
//
|
//
|
||||||
|
// компанииToolStripMenuItem
|
||||||
|
//
|
||||||
|
компанииToolStripMenuItem.Name = "компанииToolStripMenuItem";
|
||||||
|
компанииToolStripMenuItem.Size = new Size(180, 22);
|
||||||
|
компанииToolStripMenuItem.Text = "Компании";
|
||||||
|
компанииToolStripMenuItem.Click += CompaniesToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// сотрудникиToolStripMenuItem
|
||||||
|
//
|
||||||
|
сотрудникиToolStripMenuItem.Name = "сотрудникиToolStripMenuItem";
|
||||||
|
сотрудникиToolStripMenuItem.Size = new Size(180, 22);
|
||||||
|
сотрудникиToolStripMenuItem.Text = "Сотрудники";
|
||||||
|
сотрудникиToolStripMenuItem.Click += EmployeesToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// услугиToolStripMenuItem
|
||||||
|
//
|
||||||
|
услугиToolStripMenuItem.Name = "услугиToolStripMenuItem";
|
||||||
|
услугиToolStripMenuItem.Size = new Size(180, 22);
|
||||||
|
услугиToolStripMenuItem.Text = "Услуги";
|
||||||
|
услугиToolStripMenuItem.Click += ServicesToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// операцииToolStripMenuItem
|
// операцииToolStripMenuItem
|
||||||
//
|
//
|
||||||
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { заказыToolStripMenuItem, назначениеСотрудниковToolStripMenuItem });
|
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { заказыToolStripMenuItem, назначениеСотрудниковToolStripMenuItem });
|
||||||
@ -63,41 +84,25 @@
|
|||||||
операцииToolStripMenuItem.Size = new Size(75, 20);
|
операцииToolStripMenuItem.Size = new Size(75, 20);
|
||||||
операцииToolStripMenuItem.Text = "Операции";
|
операцииToolStripMenuItem.Text = "Операции";
|
||||||
//
|
//
|
||||||
// отчетыToolStripMenuItem
|
|
||||||
//
|
|
||||||
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
|
||||||
отчетыToolStripMenuItem.Size = new Size(60, 20);
|
|
||||||
отчетыToolStripMenuItem.Text = "Отчеты";
|
|
||||||
//
|
|
||||||
// компанииToolStripMenuItem
|
|
||||||
//
|
|
||||||
компанииToolStripMenuItem.Name = "компанииToolStripMenuItem";
|
|
||||||
компанииToolStripMenuItem.Size = new Size(180, 22);
|
|
||||||
компанииToolStripMenuItem.Text = "Компании";
|
|
||||||
//
|
|
||||||
// сотрудникиToolStripMenuItem
|
|
||||||
//
|
|
||||||
сотрудникиToolStripMenuItem.Name = "сотрудникиToolStripMenuItem";
|
|
||||||
сотрудникиToolStripMenuItem.Size = new Size(180, 22);
|
|
||||||
сотрудникиToolStripMenuItem.Text = "Сотрудники";
|
|
||||||
//
|
|
||||||
// услугиToolStripMenuItem
|
|
||||||
//
|
|
||||||
услугиToolStripMenuItem.Name = "услугиToolStripMenuItem";
|
|
||||||
услугиToolStripMenuItem.Size = new Size(180, 22);
|
|
||||||
услугиToolStripMenuItem.Text = "Услуги";
|
|
||||||
//
|
|
||||||
// заказыToolStripMenuItem
|
// заказыToolStripMenuItem
|
||||||
//
|
//
|
||||||
заказыToolStripMenuItem.Name = "заказыToolStripMenuItem";
|
заказыToolStripMenuItem.Name = "заказыToolStripMenuItem";
|
||||||
заказыToolStripMenuItem.Size = new Size(213, 22);
|
заказыToolStripMenuItem.Size = new Size(213, 22);
|
||||||
заказыToolStripMenuItem.Text = "Заказы";
|
заказыToolStripMenuItem.Text = "Заказы";
|
||||||
|
заказыToolStripMenuItem.Click += OrdersToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// назначениеСотрудниковToolStripMenuItem
|
// назначениеСотрудниковToolStripMenuItem
|
||||||
//
|
//
|
||||||
назначениеСотрудниковToolStripMenuItem.Name = "назначениеСотрудниковToolStripMenuItem";
|
назначениеСотрудниковToolStripMenuItem.Name = "назначениеСотрудниковToolStripMenuItem";
|
||||||
назначениеСотрудниковToolStripMenuItem.Size = new Size(213, 22);
|
назначениеСотрудниковToolStripMenuItem.Size = new Size(213, 22);
|
||||||
назначениеСотрудниковToolStripMenuItem.Text = "Назначение сотрудников";
|
назначениеСотрудниковToolStripMenuItem.Text = "Назначение сотрудников";
|
||||||
|
назначениеСотрудниковToolStripMenuItem.Click += AppointmentsToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// отчетыToolStripMenuItem
|
||||||
|
//
|
||||||
|
отчетыToolStripMenuItem.Name = "отчетыToolStripMenuItem";
|
||||||
|
отчетыToolStripMenuItem.Size = new Size(60, 20);
|
||||||
|
отчетыToolStripMenuItem.Text = "Отчеты";
|
||||||
//
|
//
|
||||||
// FormItCompany
|
// FormItCompany
|
||||||
//
|
//
|
||||||
|
@ -1,10 +1,76 @@
|
|||||||
|
using ITServiceManager.Forms;
|
||||||
|
using Unity;
|
||||||
|
|
||||||
namespace ITServiceManager
|
namespace ITServiceManager
|
||||||
{
|
{
|
||||||
public partial class FormItCompany : Form
|
public partial class FormItCompany : Form
|
||||||
{
|
{
|
||||||
public FormItCompany()
|
private readonly IUnityContainer _container;
|
||||||
|
public FormItCompany(IUnityContainer container)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CompaniesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormCompanies>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void EmployeesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormEmployees>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ServicesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormServices>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OrdersToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormOrders>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AppointmentsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_container.Resolve<FormAppointments>().ShowDialog();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,12 +28,140 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.components = new System.ComponentModel.Container();
|
label1 = new Label();
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
label2 = new Label();
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
comboBoxEmployee = new ComboBox();
|
||||||
this.Text = "FormAppointment";
|
comboBoxOrder = new ComboBox();
|
||||||
|
dateTimePickerStart = new DateTimePicker();
|
||||||
|
label3 = new Label();
|
||||||
|
label4 = new Label();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
dateTimePickerEnd = new DateTimePicker();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(46, 46);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(40, 15);
|
||||||
|
label1.TabIndex = 0;
|
||||||
|
label1.Text = "Заказ:";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(46, 141);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(69, 15);
|
||||||
|
label2.TabIndex = 1;
|
||||||
|
label2.Text = "Сотрудник:";
|
||||||
|
//
|
||||||
|
// comboBoxEmployee
|
||||||
|
//
|
||||||
|
comboBoxEmployee.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
|
comboBoxEmployee.FormattingEnabled = true;
|
||||||
|
comboBoxEmployee.Location = new Point(214, 138);
|
||||||
|
comboBoxEmployee.Name = "comboBoxEmployee";
|
||||||
|
comboBoxEmployee.Size = new Size(207, 23);
|
||||||
|
comboBoxEmployee.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// comboBoxOrder
|
||||||
|
//
|
||||||
|
comboBoxOrder.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
|
comboBoxOrder.FormattingEnabled = true;
|
||||||
|
comboBoxOrder.Location = new Point(214, 46);
|
||||||
|
comboBoxOrder.Name = "comboBoxOrder";
|
||||||
|
comboBoxOrder.Size = new Size(207, 23);
|
||||||
|
comboBoxOrder.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// dateTimePickerStart
|
||||||
|
//
|
||||||
|
dateTimePickerStart.ImeMode = ImeMode.Disable;
|
||||||
|
dateTimePickerStart.Location = new Point(214, 228);
|
||||||
|
dateTimePickerStart.Name = "dateTimePickerStart";
|
||||||
|
dateTimePickerStart.Size = new Size(207, 23);
|
||||||
|
dateTimePickerStart.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
label3.AutoSize = true;
|
||||||
|
label3.Location = new Point(46, 234);
|
||||||
|
label3.Name = "label3";
|
||||||
|
label3.Size = new Size(149, 15);
|
||||||
|
label3.TabIndex = 5;
|
||||||
|
label3.Text = "Дата назначения на заказ:";
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
label4.AutoSize = true;
|
||||||
|
label4.Location = new Point(46, 328);
|
||||||
|
label4.Name = "label4";
|
||||||
|
label4.Size = new Size(95, 15);
|
||||||
|
label4.TabIndex = 6;
|
||||||
|
label4.Text = "Дата окончания";
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(285, 442);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(112, 28);
|
||||||
|
buttonCancel.TabIndex = 9;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += ButtonCancel_Click;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.Location = new Point(59, 442);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(112, 28);
|
||||||
|
buttonAdd.TabIndex = 8;
|
||||||
|
buttonAdd.Text = "Добавить";
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += ButtonAdd_Click;
|
||||||
|
//
|
||||||
|
// dateTimePickerEnd
|
||||||
|
//
|
||||||
|
dateTimePickerEnd.ImeMode = ImeMode.Disable;
|
||||||
|
dateTimePickerEnd.Location = new Point(214, 328);
|
||||||
|
dateTimePickerEnd.Name = "dateTimePickerEnd";
|
||||||
|
dateTimePickerEnd.Size = new Size(207, 23);
|
||||||
|
dateTimePickerEnd.TabIndex = 10;
|
||||||
|
//
|
||||||
|
// FormAppointment
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(476, 505);
|
||||||
|
Controls.Add(dateTimePickerEnd);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonAdd);
|
||||||
|
Controls.Add(label4);
|
||||||
|
Controls.Add(label3);
|
||||||
|
Controls.Add(dateTimePickerStart);
|
||||||
|
Controls.Add(comboBoxOrder);
|
||||||
|
Controls.Add(comboBoxEmployee);
|
||||||
|
Controls.Add(label2);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Name = "FormAppointment";
|
||||||
|
Text = "Назначение";
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
private Label label1;
|
||||||
|
private Label label2;
|
||||||
|
private ComboBox comboBoxEmployee;
|
||||||
|
private ComboBox comboBoxOrder;
|
||||||
|
private DateTimePicker dateTimePickerStart;
|
||||||
|
private Label label3;
|
||||||
|
private Label label4;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private DateTimePicker dateTimePickerEnd;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,7 @@
|
|||||||
using System;
|
using ITServiceManager.Entities;
|
||||||
|
using ITServiceManager.Repositories;
|
||||||
|
using ITServiceManager.Repositories.Implementations;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
@ -12,9 +15,72 @@ namespace ITServiceManager.Forms
|
|||||||
{
|
{
|
||||||
public partial class FormAppointment : Form
|
public partial class FormAppointment : Form
|
||||||
{
|
{
|
||||||
public FormAppointment()
|
private readonly IAppointmentRepository _appointmentRepository;
|
||||||
|
private int? _appointmentId;
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
set
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var appointment =
|
||||||
|
_appointmentRepository.ReadAppointmentById(value);
|
||||||
|
if (appointment == null)
|
||||||
|
{
|
||||||
|
throw new
|
||||||
|
InvalidDataException(nameof(appointment));
|
||||||
|
}
|
||||||
|
comboBoxEmployee.SelectedIndex = appointment.EmployeeId;
|
||||||
|
comboBoxOrder.SelectedIndex = appointment.OrderId;
|
||||||
|
_appointmentId = value;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public FormAppointment(IAppointmentRepository appointmentRepository, IEmployeeRepository employeeRepository, IOrderRepository orderRepository)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_appointmentRepository = appointmentRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(appointmentRepository));
|
||||||
|
|
||||||
|
comboBoxOrder.DataSource = orderRepository.ReadOrders();
|
||||||
|
comboBoxOrder.DisplayMember = "Name";
|
||||||
|
comboBoxOrder.ValueMember = "Id";
|
||||||
|
|
||||||
|
comboBoxEmployee.DataSource = employeeRepository.ReadEmployees();
|
||||||
|
comboBoxEmployee.DisplayMember = "Name";
|
||||||
|
comboBoxEmployee.ValueMember = "Id";
|
||||||
}
|
}
|
||||||
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (comboBoxEmployee.SelectedIndex < 0 || comboBoxOrder.SelectedIndex < 0 || dateTimePickerStart.CustomFormat != " ")
|
||||||
|
{
|
||||||
|
throw new Exception("Имеются незаполненные поля");
|
||||||
|
}
|
||||||
|
if (_appointmentId.HasValue)
|
||||||
|
{
|
||||||
|
_appointmentRepository.UpdateAppointment(CreateAppointment(_appointmentId.Value));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_appointmentRepository.CreateAppointment(CreateAppointment(0));
|
||||||
|
}
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при сохранении",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||||
|
private Appointment CreateAppointment(int id) => Appointment.CreateOperation(id, comboBoxOrder.SelectedIndex, comboBoxEmployee.SelectedIndex, Convert.ToDateTime(dateTimePickerStart) ,
|
||||||
|
Convert.ToDateTime(dateTimePickerEnd));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.
|
||||||
-->
|
-->
|
||||||
|
112
ITServiceManager/ITServiceManager/Forms/FormAppointments.Designer.cs
generated
Normal file
112
ITServiceManager/ITServiceManager/Forms/FormAppointments.Designer.cs
generated
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
namespace ITServiceManager.Forms
|
||||||
|
{
|
||||||
|
partial class FormAppointments
|
||||||
|
{
|
||||||
|
/// <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();
|
||||||
|
panel = new Panel();
|
||||||
|
buttonUpdate = new Button();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
panel.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// 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.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(652, 450);
|
||||||
|
dataGridView.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// panel
|
||||||
|
//
|
||||||
|
panel.Controls.Add(buttonUpdate);
|
||||||
|
panel.Controls.Add(buttonAdd);
|
||||||
|
panel.Dock = DockStyle.Right;
|
||||||
|
panel.Location = new Point(652, 0);
|
||||||
|
panel.Name = "panel";
|
||||||
|
panel.Size = new Size(148, 450);
|
||||||
|
panel.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// buttonUpdate
|
||||||
|
//
|
||||||
|
buttonUpdate.BackgroundImage = Properties.Resources.edit;
|
||||||
|
buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonUpdate.Location = new Point(33, 269);
|
||||||
|
buttonUpdate.Name = "buttonUpdate";
|
||||||
|
buttonUpdate.Size = new Size(81, 80);
|
||||||
|
buttonUpdate.TabIndex = 2;
|
||||||
|
buttonUpdate.UseVisualStyleBackColor = true;
|
||||||
|
buttonUpdate.Click += ButtonUpd_Click;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.BackgroundImage = Properties.Resources.plus;
|
||||||
|
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonAdd.Location = new Point(33, 43);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(81, 71);
|
||||||
|
buttonAdd.TabIndex = 0;
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += ButtonAdd_Click;
|
||||||
|
//
|
||||||
|
// FormAppointments
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Controls.Add(panel);
|
||||||
|
Name = "FormAppointments";
|
||||||
|
Text = "Назначения";
|
||||||
|
Load += FormAppointments_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
panel.ResumeLayout(false);
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private Panel panel;
|
||||||
|
private Button buttonUpdate;
|
||||||
|
private Button buttonAdd;
|
||||||
|
}
|
||||||
|
}
|
81
ITServiceManager/ITServiceManager/Forms/FormAppointments.cs
Normal file
81
ITServiceManager/ITServiceManager/Forms/FormAppointments.cs
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
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 FormAppointments : Form
|
||||||
|
{
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
private readonly IAppointmentRepository _appointmentRepository;
|
||||||
|
public FormAppointments(IUnityContainer container, IAppointmentRepository appointmentRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
|
_appointmentRepository = appointmentRepository ?? throw new ArgumentNullException(nameof(appointmentRepository));
|
||||||
|
}
|
||||||
|
private void FormAppointments_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<FormAppointment>().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<FormAppointment>();
|
||||||
|
form.Id = findId;
|
||||||
|
form.ShowDialog();
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при изменении",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void LoadList() => dataGridView.DataSource = _appointmentRepository.ReadAppointments();
|
||||||
|
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/FormAppointments.resx
Normal file
120
ITServiceManager/ITServiceManager/Forms/FormAppointments.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>
|
@ -39,27 +39,25 @@
|
|||||||
// labelName
|
// labelName
|
||||||
//
|
//
|
||||||
labelName.AutoSize = true;
|
labelName.AutoSize = true;
|
||||||
labelName.Location = new Point(102, 135);
|
labelName.Location = new Point(89, 101);
|
||||||
labelName.Name = "labelName";
|
labelName.Name = "labelName";
|
||||||
labelName.Size = new Size(152, 20);
|
labelName.Size = new Size(118, 15);
|
||||||
labelName.TabIndex = 0;
|
labelName.TabIndex = 0;
|
||||||
labelName.Text = "Название компании";
|
labelName.Text = "Название компании";
|
||||||
//
|
//
|
||||||
// textBoxName
|
// textBoxName
|
||||||
//
|
//
|
||||||
textBoxName.Location = new Point(306, 131);
|
textBoxName.Location = new Point(268, 98);
|
||||||
textBoxName.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
textBoxName.Name = "textBoxName";
|
textBoxName.Name = "textBoxName";
|
||||||
textBoxName.Size = new Size(201, 27);
|
textBoxName.Size = new Size(200, 23);
|
||||||
textBoxName.TabIndex = 1;
|
textBoxName.TabIndex = 1;
|
||||||
textBoxName.TextChanged += textBoxName_TextChanged;
|
textBoxName.TextChanged += textBoxName_TextChanged;
|
||||||
//
|
//
|
||||||
// buttonAdd
|
// buttonAdd
|
||||||
//
|
//
|
||||||
buttonAdd.Location = new Point(109, 317);
|
buttonAdd.Location = new Point(95, 238);
|
||||||
buttonAdd.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
buttonAdd.Name = "buttonAdd";
|
buttonAdd.Name = "buttonAdd";
|
||||||
buttonAdd.Size = new Size(128, 37);
|
buttonAdd.Size = new Size(112, 28);
|
||||||
buttonAdd.TabIndex = 2;
|
buttonAdd.TabIndex = 2;
|
||||||
buttonAdd.Text = "Добавить";
|
buttonAdd.Text = "Добавить";
|
||||||
buttonAdd.UseVisualStyleBackColor = true;
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
@ -67,10 +65,9 @@
|
|||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
buttonCancel.Location = new Point(367, 317);
|
buttonCancel.Location = new Point(321, 238);
|
||||||
buttonCancel.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(128, 37);
|
buttonCancel.Size = new Size(112, 28);
|
||||||
buttonCancel.TabIndex = 3;
|
buttonCancel.TabIndex = 3;
|
||||||
buttonCancel.Text = "Отмена";
|
buttonCancel.Text = "Отмена";
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
@ -79,32 +76,30 @@
|
|||||||
// labelAddres
|
// labelAddres
|
||||||
//
|
//
|
||||||
labelAddres.AutoSize = true;
|
labelAddres.AutoSize = true;
|
||||||
labelAddres.Location = new Point(121, 195);
|
labelAddres.Location = new Point(106, 146);
|
||||||
labelAddres.Name = "labelAddres";
|
labelAddres.Name = "labelAddres";
|
||||||
labelAddres.Size = new Size(133, 20);
|
labelAddres.Size = new Size(105, 15);
|
||||||
labelAddres.TabIndex = 4;
|
labelAddres.TabIndex = 4;
|
||||||
labelAddres.Text = "Адресс компании";
|
labelAddres.Text = "Адресс компании";
|
||||||
//
|
//
|
||||||
// textBoxAddress
|
// textBoxAddress
|
||||||
//
|
//
|
||||||
textBoxAddress.Location = new Point(306, 188);
|
textBoxAddress.Location = new Point(268, 141);
|
||||||
textBoxAddress.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
textBoxAddress.Name = "textBoxAddress";
|
textBoxAddress.Name = "textBoxAddress";
|
||||||
textBoxAddress.Size = new Size(201, 27);
|
textBoxAddress.Size = new Size(200, 23);
|
||||||
textBoxAddress.TabIndex = 5;
|
textBoxAddress.TabIndex = 5;
|
||||||
//
|
//
|
||||||
// FormCompany
|
// FormCompany
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(613, 408);
|
ClientSize = new Size(570, 306);
|
||||||
Controls.Add(textBoxAddress);
|
Controls.Add(textBoxAddress);
|
||||||
Controls.Add(labelAddres);
|
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 = "Компания";
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
buttonCancel.TabIndex = 7;
|
buttonCancel.TabIndex = 7;
|
||||||
buttonCancel.Text = "Отмена";
|
buttonCancel.Text = "Отмена";
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += ButtonCancel_Click;
|
||||||
//
|
//
|
||||||
// buttonAdd
|
// buttonAdd
|
||||||
//
|
//
|
||||||
@ -122,7 +123,7 @@
|
|||||||
Controls.Add(labelFirstName);
|
Controls.Add(labelFirstName);
|
||||||
Name = "FormEmployee";
|
Name = "FormEmployee";
|
||||||
StartPosition = FormStartPosition.CenterScreen;
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
Text = "FormEmployee";
|
Text = "Сотрудник";
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
@ -1,86 +1,74 @@
|
|||||||
using ITServiceManager.Entities;
|
using ITServiceManager.Entities;
|
||||||
using ITServiceManager.Entities.Enums;
|
using ITServiceManager.Entities.Enums;
|
||||||
using ITServiceManager.Repositories;
|
using ITServiceManager.Repositories;
|
||||||
using System;
|
namespace ITServiceManager.Forms;
|
||||||
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 ITServiceManager.Forms
|
public partial class FormEmployee : Form
|
||||||
{
|
{
|
||||||
public partial class FormEmployee : Form
|
private readonly IEmployeeRepository _employeeRepository;
|
||||||
|
private int? _employeeId;
|
||||||
|
public int Id
|
||||||
{
|
{
|
||||||
private readonly IEmployeeRepository _employeeRepository;
|
set
|
||||||
private int? _employeeId;
|
|
||||||
public int Id
|
|
||||||
{
|
|
||||||
set
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var employee =
|
|
||||||
_employeeRepository.ReadEmployeeById(value);
|
|
||||||
if (employee == null)
|
|
||||||
{
|
|
||||||
throw new
|
|
||||||
InvalidDataException(nameof(employee));
|
|
||||||
}
|
|
||||||
textBoxFirstName.Text = employee.FirstName;
|
|
||||||
textBoxLastName.Text = employee.LastName;
|
|
||||||
comboBoxPost.SelectedItem =
|
|
||||||
employee.Position;
|
|
||||||
_employeeId = value;
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public FormEmployee(IEmployeeRepository employeeRepository)
|
|
||||||
{
|
|
||||||
InitializeComponent();
|
|
||||||
_employeeRepository = employeeRepository ??
|
|
||||||
throw new
|
|
||||||
ArgumentNullException(nameof(employeeRepository));
|
|
||||||
comboBoxPost.DataSource =
|
|
||||||
Enum.GetValues(typeof(EmployeePost));
|
|
||||||
}
|
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) ||
|
var employee =
|
||||||
string.IsNullOrWhiteSpace(textBoxLastName.Text)
|
_employeeRepository.ReadEmployeeById(value);
|
||||||
||
|
if (employee == null)
|
||||||
comboBoxPost.SelectedIndex < 1)
|
|
||||||
{
|
{
|
||||||
throw new Exception("Имеются незаполненные поля");
|
throw new
|
||||||
|
InvalidDataException(nameof(employee));
|
||||||
}
|
}
|
||||||
if (_employeeId.HasValue)
|
textBoxFirstName.Text = employee.FirstName;
|
||||||
{
|
textBoxLastName.Text = employee.LastName;
|
||||||
_employeeRepository.UpdateEmployee(CreateEmployee(_employeeId.Value));
|
comboBoxPost.SelectedItem =
|
||||||
}
|
employee.Position;
|
||||||
else
|
_employeeId = value;
|
||||||
{
|
|
||||||
_employeeRepository.CreateEmployee(CreateEmployee(0));
|
|
||||||
}
|
|
||||||
Close();
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
MessageBox.Show(ex.Message, "Ошибка при сохранении",
|
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
|
||||||
private Employee CreateEmployee(int id) => Employee.CreateEntity(id, textBoxFirstName.Text, textBoxLastName.Text, (EmployeePost)comboBoxPost.SelectedItem!);
|
|
||||||
}
|
}
|
||||||
|
public FormEmployee(IEmployeeRepository employeeRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_employeeRepository = employeeRepository ??
|
||||||
|
throw new
|
||||||
|
ArgumentNullException(nameof(employeeRepository));
|
||||||
|
comboBoxPost.DataSource =
|
||||||
|
Enum.GetValues(typeof(EmployeePost));
|
||||||
|
}
|
||||||
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(textBoxFirstName.Text) ||
|
||||||
|
string.IsNullOrWhiteSpace(textBoxLastName.Text)
|
||||||
|
||
|
||||||
|
comboBoxPost.SelectedIndex < 1)
|
||||||
|
{
|
||||||
|
throw new Exception("Имеются незаполненные поля");
|
||||||
|
}
|
||||||
|
if (_employeeId.HasValue)
|
||||||
|
{
|
||||||
|
_employeeRepository.UpdateEmployee(CreateEmployee(_employeeId.Value));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_employeeRepository.CreateEmployee(CreateEmployee(0));
|
||||||
|
}
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при сохранении",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||||
|
private Employee CreateEmployee(int id) => Employee.CreateEntity(id, textBoxFirstName.Text, textBoxLastName.Text, (EmployeePost)comboBoxPost.SelectedItem!);
|
||||||
}
|
}
|
||||||
|
@ -43,44 +43,43 @@
|
|||||||
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 = 2;
|
panel.TabIndex = 2;
|
||||||
//
|
//
|
||||||
// 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 += ButtonUpd_Click;
|
||||||
//
|
//
|
||||||
// buttonRemove
|
// buttonRemove
|
||||||
//
|
//
|
||||||
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 += ButtonDel_Click;
|
||||||
//
|
//
|
||||||
// buttonAdd
|
// buttonAdd
|
||||||
//
|
//
|
||||||
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;
|
||||||
//
|
//
|
||||||
// dataGridView
|
// dataGridView
|
||||||
//
|
//
|
||||||
@ -91,7 +90,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;
|
||||||
@ -99,19 +97,21 @@
|
|||||||
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 = 3;
|
dataGridView.TabIndex = 3;
|
||||||
//
|
//
|
||||||
// FormEmployees
|
// FormEmployees
|
||||||
//
|
//
|
||||||
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, 2, 3, 2);
|
||||||
Name = "FormEmployees";
|
Name = "FormEmployees";
|
||||||
StartPosition = FormStartPosition.CenterScreen;
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
Text = "FormEmployees";
|
Text = "Сотрудники";
|
||||||
|
Load += FormEmployees_Load;
|
||||||
panel.ResumeLayout(false);
|
panel.ResumeLayout(false);
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
|
@ -28,12 +28,146 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.components = new System.ComponentModel.Container();
|
DataGridViewCellStyle dataGridViewCellStyle1 = new DataGridViewCellStyle();
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
dataGridView = new DataGridView();
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
ColumnService = new DataGridViewComboBoxColumn();
|
||||||
this.Text = "FormOrder";
|
ColumnQuantity = new DataGridViewTextBoxColumn();
|
||||||
|
ColumnExecutionDate = new DataGridViewTextBoxColumn();
|
||||||
|
buttonCancel = new Button();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
label1 = new Label();
|
||||||
|
comboBoxCompany = new ComboBox();
|
||||||
|
label2 = new Label();
|
||||||
|
numericUpDownPrice = new NumericUpDown();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.AllowUserToAddRows = false;
|
||||||
|
dataGridView.AllowUserToDeleteRows = false;
|
||||||
|
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnService, ColumnQuantity, ColumnExecutionDate });
|
||||||
|
dataGridView.Location = new Point(12, 232);
|
||||||
|
dataGridView.MultiSelect = false;
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.ReadOnly = true;
|
||||||
|
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
dataGridView.Size = new Size(492, 263);
|
||||||
|
dataGridView.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// ColumnService
|
||||||
|
//
|
||||||
|
ColumnService.HeaderText = "Услуга";
|
||||||
|
ColumnService.Name = "ColumnService";
|
||||||
|
ColumnService.ReadOnly = true;
|
||||||
|
//
|
||||||
|
// ColumnQuantity
|
||||||
|
//
|
||||||
|
ColumnQuantity.HeaderText = "Количество";
|
||||||
|
ColumnQuantity.Name = "ColumnQuantity";
|
||||||
|
ColumnQuantity.ReadOnly = true;
|
||||||
|
//
|
||||||
|
// ColumnExecutionDate
|
||||||
|
//
|
||||||
|
dataGridViewCellStyle1.Format = "F";
|
||||||
|
dataGridViewCellStyle1.NullValue = null;
|
||||||
|
ColumnExecutionDate.DefaultCellStyle = dataGridViewCellStyle1;
|
||||||
|
ColumnExecutionDate.HeaderText = "Срок";
|
||||||
|
ColumnExecutionDate.Name = "ColumnExecutionDate";
|
||||||
|
ColumnExecutionDate.ReadOnly = true;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
buttonCancel.Location = new Point(320, 514);
|
||||||
|
buttonCancel.Name = "buttonCancel";
|
||||||
|
buttonCancel.Size = new Size(112, 28);
|
||||||
|
buttonCancel.TabIndex = 9;
|
||||||
|
buttonCancel.Text = "Отмена";
|
||||||
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += ButtonCancel_Click;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.Location = new Point(64, 514);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(112, 28);
|
||||||
|
buttonAdd.TabIndex = 8;
|
||||||
|
buttonAdd.Text = "Добавить";
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += ButtonAdd_Click;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(52, 45);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(63, 15);
|
||||||
|
label1.TabIndex = 10;
|
||||||
|
label1.Text = "Компания";
|
||||||
|
//
|
||||||
|
// comboBoxCompany
|
||||||
|
//
|
||||||
|
comboBoxCompany.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
|
comboBoxCompany.FormattingEnabled = true;
|
||||||
|
comboBoxCompany.Location = new Point(181, 42);
|
||||||
|
comboBoxCompany.Name = "comboBoxCompany";
|
||||||
|
comboBoxCompany.Size = new Size(240, 23);
|
||||||
|
comboBoxCompany.TabIndex = 11;
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(52, 123);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(99, 15);
|
||||||
|
label2.TabIndex = 12;
|
||||||
|
label2.Text = "Сумма договора";
|
||||||
|
//
|
||||||
|
// numericUpDownPrice
|
||||||
|
//
|
||||||
|
numericUpDownPrice.DecimalPlaces = 2;
|
||||||
|
numericUpDownPrice.Location = new Point(181, 121);
|
||||||
|
numericUpDownPrice.Maximum = new decimal(new int[] { 1000000, 0, 0, 0 });
|
||||||
|
numericUpDownPrice.Name = "numericUpDownPrice";
|
||||||
|
numericUpDownPrice.Size = new Size(240, 23);
|
||||||
|
numericUpDownPrice.TabIndex = 13;
|
||||||
|
//
|
||||||
|
// FormOrder
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(516, 576);
|
||||||
|
Controls.Add(numericUpDownPrice);
|
||||||
|
Controls.Add(label2);
|
||||||
|
Controls.Add(comboBoxCompany);
|
||||||
|
Controls.Add(label1);
|
||||||
|
Controls.Add(buttonCancel);
|
||||||
|
Controls.Add(buttonAdd);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Name = "FormOrder";
|
||||||
|
Text = "Заказ";
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)numericUpDownPrice).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
private Label label1;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private DataGridViewComboBoxColumn ColumnProducts;
|
||||||
|
private DataGridViewTextBoxColumn ColumnCount;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private ComboBox comboBoxCompany;
|
||||||
|
private Label label2;
|
||||||
|
private NumericUpDown numericUpDownPrice;
|
||||||
|
private DataGridViewComboBoxColumn ColumnService;
|
||||||
|
private DataGridViewTextBoxColumn ColumnQuantity;
|
||||||
|
private DataGridViewTextBoxColumn ColumnExecutionDate;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,6 @@
|
|||||||
using System;
|
using ITServiceManager.Entities;
|
||||||
|
using ITServiceManager.Repositories;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
@ -7,14 +9,56 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
|
using System.Windows.Forms.VisualStyles;
|
||||||
|
|
||||||
namespace ITServiceManager.Forms
|
namespace ITServiceManager.Forms
|
||||||
{
|
{
|
||||||
public partial class FormOrder : Form
|
public partial class FormOrder : Form
|
||||||
{
|
{
|
||||||
public FormOrder()
|
private readonly IOrderRepository _orderRepository;
|
||||||
|
public FormOrder(IOrderRepository orderRepository, IServiceRepository serviceRepository, ICompanyRepository companyRepository)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
_orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
|
||||||
|
|
||||||
|
comboBoxCompany.DataSource = companyRepository.ReadCompanies();
|
||||||
|
comboBoxCompany.DisplayMember = "Name";
|
||||||
|
comboBoxCompany.ValueMember = "Id";
|
||||||
|
|
||||||
|
ColumnService.DataSource = serviceRepository.ReadServices();
|
||||||
|
ColumnService.DisplayMember = "Name";
|
||||||
|
ColumnService.ValueMember = "Id";
|
||||||
|
}
|
||||||
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.RowCount < 1 || comboBoxCompany.SelectedIndex < 0 || numericUpDownPrice.Value <= 0)
|
||||||
|
{
|
||||||
|
throw new Exception("Имеются незаполненны поля");
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_orderRepository.CreateOrder(Order.CreateOperation(0, comboBoxCompany.SelectedIndex, numericUpDownPrice.Value, CreateListProductFromDataGrid()));
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||||
|
private List<OrderService> CreateListProductFromDataGrid()
|
||||||
|
{
|
||||||
|
var list = new List<OrderService>();
|
||||||
|
foreach (DataGridViewRow row in dataGridView.Rows)
|
||||||
|
{
|
||||||
|
if (row.Cells["ColumService"].Value == null || row.Cells["ColumQuantity"].Value == null || row.Cells["ColumnExecutionDate"].Value == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
list.Add(OrderService.CreateOperation(0, 0, Convert.ToInt32(row.Cells["ColumnServices"].Value), Convert.ToInt32(row.Cells["ColumnQuantity"].Value), Convert.ToDateTime(row.Cells["ColumnExecutionDate"].Value)));
|
||||||
|
}
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.
|
||||||
-->
|
-->
|
||||||
@ -117,4 +117,13 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<metadata name="ColumnService.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnQuantity.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="ColumnExecutionDate.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
113
ITServiceManager/ITServiceManager/Forms/FormOrders.Designer.cs
generated
Normal file
113
ITServiceManager/ITServiceManager/Forms/FormOrders.Designer.cs
generated
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
namespace ITServiceManager.Forms
|
||||||
|
{
|
||||||
|
partial class FormOrders
|
||||||
|
{
|
||||||
|
/// <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();
|
||||||
|
buttonRemove = new Button();
|
||||||
|
buttonAdd = new Button();
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
panel.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// panel
|
||||||
|
//
|
||||||
|
panel.Controls.Add(buttonRemove);
|
||||||
|
panel.Controls.Add(buttonAdd);
|
||||||
|
panel.Dock = DockStyle.Right;
|
||||||
|
panel.Location = new Point(652, 0);
|
||||||
|
panel.Name = "panel";
|
||||||
|
panel.Size = new Size(148, 450);
|
||||||
|
panel.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// buttonRemove
|
||||||
|
//
|
||||||
|
buttonRemove.BackgroundImage = Properties.Resources.minus;
|
||||||
|
buttonRemove.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonRemove.Location = new Point(39, 265);
|
||||||
|
buttonRemove.Name = "buttonRemove";
|
||||||
|
buttonRemove.Size = new Size(75, 76);
|
||||||
|
buttonRemove.TabIndex = 1;
|
||||||
|
buttonRemove.UseVisualStyleBackColor = true;
|
||||||
|
buttonRemove.Click += ButtonRemove_Click;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.BackgroundImage = Properties.Resources.plus;
|
||||||
|
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonAdd.Location = new Point(33, 92);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(81, 71);
|
||||||
|
buttonAdd.TabIndex = 0;
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += ButtonAdd_Click;
|
||||||
|
//
|
||||||
|
// 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.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(652, 450);
|
||||||
|
dataGridView.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// FormOrders
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Controls.Add(panel);
|
||||||
|
Name = "FormOrders";
|
||||||
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
|
Text = "Заказы";
|
||||||
|
Load += FormOrders_Load;
|
||||||
|
panel.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Panel panel;
|
||||||
|
private Button buttonRemove;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
}
|
||||||
|
}
|
81
ITServiceManager/ITServiceManager/Forms/FormOrders.cs
Normal file
81
ITServiceManager/ITServiceManager/Forms/FormOrders.cs
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
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 FormOrders : Form
|
||||||
|
{
|
||||||
|
private readonly IUnityContainer _container;
|
||||||
|
private readonly IOrderRepository _orderRepository;
|
||||||
|
public FormOrders(IUnityContainer container, IOrderRepository orderRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||||
|
_orderRepository = orderRepository ?? throw new ArgumentNullException(nameof(orderRepository));
|
||||||
|
}
|
||||||
|
private void FormOrders_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<FormOrder>().ShowDialog();
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ButtonRemove_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (!TryGetIdentifierFromSelectedRow(out var findId))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Удаление", MessageBoxButtons.YesNo) != DialogResult.Yes)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_orderRepository.DeleteOrder(findId);
|
||||||
|
LoadList();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void LoadList() => dataGridView.DataSource = _orderRepository.ReadOrders();
|
||||||
|
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/FormOrders.resx
Normal file
120
ITServiceManager/ITServiceManager/Forms/FormOrders.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>
|
@ -31,78 +31,102 @@
|
|||||||
buttonCancel = new Button();
|
buttonCancel = new Button();
|
||||||
buttonAdd = new Button();
|
buttonAdd = new Button();
|
||||||
textBoxName = new TextBox();
|
textBoxName = new TextBox();
|
||||||
labelName = new Label();
|
|
||||||
labelDescription = new Label();
|
labelDescription = new Label();
|
||||||
richTextBoxDescription = new RichTextBox();
|
richTextBoxDescription = new RichTextBox();
|
||||||
|
label1 = new Label();
|
||||||
|
label2 = new Label();
|
||||||
|
labelName = new Label();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
buttonCancel.Location = new Point(463, 300);
|
buttonCancel.Location = new Point(313, 275);
|
||||||
buttonCancel.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(128, 37);
|
buttonCancel.Size = new Size(112, 28);
|
||||||
buttonCancel.TabIndex = 7;
|
buttonCancel.TabIndex = 7;
|
||||||
buttonCancel.Text = "Отмена";
|
buttonCancel.Text = "Отмена";
|
||||||
buttonCancel.UseVisualStyleBackColor = true;
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
buttonCancel.Click += ButtonCancel_Click;
|
||||||
//
|
//
|
||||||
// buttonAdd
|
// buttonAdd
|
||||||
//
|
//
|
||||||
buttonAdd.Location = new Point(205, 300);
|
buttonAdd.Location = new Point(87, 275);
|
||||||
buttonAdd.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
buttonAdd.Name = "buttonAdd";
|
buttonAdd.Name = "buttonAdd";
|
||||||
buttonAdd.Size = new Size(128, 37);
|
buttonAdd.Size = new Size(112, 28);
|
||||||
buttonAdd.TabIndex = 6;
|
buttonAdd.TabIndex = 6;
|
||||||
buttonAdd.Text = "Добавить";
|
buttonAdd.Text = "Добавить";
|
||||||
buttonAdd.UseVisualStyleBackColor = true;
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += ButtonAdd_Click;
|
||||||
//
|
//
|
||||||
// textBoxName
|
// textBoxName
|
||||||
//
|
//
|
||||||
textBoxName.Location = new Point(402, 114);
|
textBoxName.Location = new Point(243, 22);
|
||||||
textBoxName.Margin = new Padding(3, 4, 3, 4);
|
|
||||||
textBoxName.Name = "textBoxName";
|
textBoxName.Name = "textBoxName";
|
||||||
textBoxName.Size = new Size(264, 27);
|
textBoxName.Size = new Size(232, 23);
|
||||||
textBoxName.TabIndex = 5;
|
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
|
||||||
//
|
//
|
||||||
labelDescription.AutoSize = true;
|
labelDescription.AutoSize = true;
|
||||||
labelDescription.Location = new Point(132, 193);
|
labelDescription.Location = new Point(21, 134);
|
||||||
labelDescription.Name = "labelDescription";
|
labelDescription.Name = "labelDescription";
|
||||||
labelDescription.Size = new Size(127, 20);
|
labelDescription.Size = new Size(102, 15);
|
||||||
labelDescription.TabIndex = 8;
|
labelDescription.TabIndex = 8;
|
||||||
labelDescription.Text = "Описание услуги";
|
labelDescription.Text = "Описание услуги";
|
||||||
//
|
//
|
||||||
// richTextBoxDescription
|
// richTextBoxDescription
|
||||||
//
|
//
|
||||||
richTextBoxDescription.Location = new Point(402, 161);
|
richTextBoxDescription.Location = new Point(243, 106);
|
||||||
|
richTextBoxDescription.Margin = new Padding(3, 2, 3, 2);
|
||||||
richTextBoxDescription.Name = "richTextBoxDescription";
|
richTextBoxDescription.Name = "richTextBoxDescription";
|
||||||
richTextBoxDescription.Size = new Size(264, 120);
|
richTextBoxDescription.Size = new Size(232, 132);
|
||||||
richTextBoxDescription.TabIndex = 9;
|
richTextBoxDescription.TabIndex = 9;
|
||||||
richTextBoxDescription.Text = "";
|
richTextBoxDescription.Text = "";
|
||||||
//
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(24, 25);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(99, 15);
|
||||||
|
label1.TabIndex = 4;
|
||||||
|
label1.Text = "Название услуги";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(24, 134);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(102, 15);
|
||||||
|
label2.TabIndex = 8;
|
||||||
|
label2.Text = "Описание услуги";
|
||||||
|
//
|
||||||
|
// labelName
|
||||||
|
//
|
||||||
|
labelName.AutoSize = true;
|
||||||
|
labelName.Location = new Point(21, 22);
|
||||||
|
labelName.Name = "labelName";
|
||||||
|
labelName.Size = new Size(99, 15);
|
||||||
|
labelName.TabIndex = 4;
|
||||||
|
labelName.Text = "Название услуги";
|
||||||
|
//
|
||||||
// FormService
|
// FormService
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(800, 450);
|
ClientSize = new Size(511, 338);
|
||||||
Controls.Add(richTextBoxDescription);
|
Controls.Add(richTextBoxDescription);
|
||||||
|
Controls.Add(label2);
|
||||||
Controls.Add(labelDescription);
|
Controls.Add(labelDescription);
|
||||||
Controls.Add(buttonCancel);
|
Controls.Add(buttonCancel);
|
||||||
Controls.Add(buttonAdd);
|
Controls.Add(buttonAdd);
|
||||||
Controls.Add(textBoxName);
|
Controls.Add(textBoxName);
|
||||||
|
Controls.Add(label1);
|
||||||
Controls.Add(labelName);
|
Controls.Add(labelName);
|
||||||
|
Margin = new Padding(3, 2, 3, 2);
|
||||||
Name = "FormService";
|
Name = "FormService";
|
||||||
Text = "FormService";
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
|
Text = "Услуга";
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
PerformLayout();
|
||||||
}
|
}
|
||||||
@ -112,8 +136,10 @@
|
|||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
private Button buttonAdd;
|
private Button buttonAdd;
|
||||||
private TextBox textBoxName;
|
private TextBox textBoxName;
|
||||||
private Label labelName;
|
|
||||||
private Label labelDescription;
|
private Label labelDescription;
|
||||||
private RichTextBox richTextBoxDescription;
|
private RichTextBox richTextBoxDescription;
|
||||||
|
private Label label1;
|
||||||
|
private Label label2;
|
||||||
|
private Label labelName;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,20 +1,68 @@
|
|||||||
using System;
|
using ITServiceManager.Entities.Enums;
|
||||||
using System.Collections.Generic;
|
using ITServiceManager.Entities;
|
||||||
using System.ComponentModel;
|
using ITServiceManager.Repositories;
|
||||||
using System.Data;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Forms;
|
|
||||||
|
|
||||||
namespace ITServiceManager.Forms
|
namespace ITServiceManager.Forms;
|
||||||
|
|
||||||
|
public partial class FormService : Form
|
||||||
{
|
{
|
||||||
public partial class FormService : Form
|
private readonly IServiceRepository _serviceRepository;
|
||||||
|
private int? _serviceId;
|
||||||
|
public int Id
|
||||||
{
|
{
|
||||||
public FormService()
|
set
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
try
|
||||||
|
{
|
||||||
|
var service =
|
||||||
|
_serviceRepository.ReadServiceById(value);
|
||||||
|
if (service == null)
|
||||||
|
{
|
||||||
|
throw new
|
||||||
|
InvalidDataException(nameof(service));
|
||||||
|
}
|
||||||
|
textBoxName.Text = service.Name;
|
||||||
|
richTextBoxDescription.Text = service.Description;
|
||||||
|
_serviceId = value;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public FormService(IServiceRepository serviceRepository)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_serviceRepository = serviceRepository ??
|
||||||
|
throw new ArgumentNullException(nameof(serviceRepository));
|
||||||
|
}
|
||||||
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(textBoxName.Text) ||
|
||||||
|
string.IsNullOrWhiteSpace(richTextBoxDescription.Text))
|
||||||
|
{
|
||||||
|
throw new Exception("Имеются незаполненные поля");
|
||||||
|
}
|
||||||
|
if (_serviceId.HasValue)
|
||||||
|
{
|
||||||
|
_serviceRepository.UpdateService(CreateService(_serviceId.Value));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_serviceRepository.CreateService(CreateService(0));
|
||||||
|
}
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка при сохранении",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||||
|
private Service CreateService(int id) => Service.CreateEntity(id, textBoxName.Text, richTextBoxDescription.Text);
|
||||||
}
|
}
|
||||||
|
127
ITServiceManager/ITServiceManager/Forms/FormServices.Designer.cs
generated
Normal file
127
ITServiceManager/ITServiceManager/Forms/FormServices.Designer.cs
generated
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
namespace ITServiceManager.Forms
|
||||||
|
{
|
||||||
|
partial class FormServices
|
||||||
|
{
|
||||||
|
/// <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(652, 0);
|
||||||
|
panel.Name = "panel";
|
||||||
|
panel.Size = new Size(148, 450);
|
||||||
|
panel.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// buttonUpdate
|
||||||
|
//
|
||||||
|
buttonUpdate.BackgroundImage = Properties.Resources.edit;
|
||||||
|
buttonUpdate.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonUpdate.Location = new Point(36, 249);
|
||||||
|
buttonUpdate.Name = "buttonUpdate";
|
||||||
|
buttonUpdate.Size = new Size(78, 80);
|
||||||
|
buttonUpdate.TabIndex = 2;
|
||||||
|
buttonUpdate.UseVisualStyleBackColor = true;
|
||||||
|
buttonUpdate.Click += ButtonUpd_Click;
|
||||||
|
//
|
||||||
|
// buttonRemove
|
||||||
|
//
|
||||||
|
buttonRemove.BackgroundImage = Properties.Resources.minus;
|
||||||
|
buttonRemove.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonRemove.Location = new Point(36, 141);
|
||||||
|
buttonRemove.Name = "buttonRemove";
|
||||||
|
buttonRemove.Size = new Size(75, 76);
|
||||||
|
buttonRemove.TabIndex = 1;
|
||||||
|
buttonRemove.UseVisualStyleBackColor = true;
|
||||||
|
buttonRemove.Click += ButtonDel_Click;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
buttonAdd.BackgroundImage = Properties.Resources.plus;
|
||||||
|
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||||
|
buttonAdd.Location = new Point(33, 43);
|
||||||
|
buttonAdd.Name = "buttonAdd";
|
||||||
|
buttonAdd.Size = new Size(81, 71);
|
||||||
|
buttonAdd.TabIndex = 0;
|
||||||
|
buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
buttonAdd.Click += ButtonAdd_Click;
|
||||||
|
//
|
||||||
|
// 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.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(652, 450);
|
||||||
|
dataGridView.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// FormServices
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(800, 450);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Controls.Add(panel);
|
||||||
|
Name = "FormServices";
|
||||||
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
|
Text = "Услуги";
|
||||||
|
Load += FormServices_Load;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
118
ITServiceManager/ITServiceManager/Forms/FormServices.cs
Normal file
118
ITServiceManager/ITServiceManager/Forms/FormServices.cs
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
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 FormServices : Form
|
||||||
|
{
|
||||||
|
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
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
120
ITServiceManager/ITServiceManager/Forms/FormServices.resx
Normal file
120
ITServiceManager/ITServiceManager/Forms/FormServices.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>
|
Loading…
x
Reference in New Issue
Block a user