Рефакторинг, добавил ServiceName
This commit is contained in:
parent
39fc7769eb
commit
08ad5292f5
@ -6,14 +6,16 @@ public class Service
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public ServiceType ServiceType { get; private set; }
|
||||
public string ServiceName { get; private set; } = string.Empty;
|
||||
public string Description { get; private set; } = string.Empty;
|
||||
|
||||
public static Service CreateEntity(int id, ServiceType type, string description)
|
||||
public static Service CreateEntity(int id, ServiceType type, string name, string description)
|
||||
{
|
||||
return new Service
|
||||
{
|
||||
Id = id,
|
||||
ServiceType = type,
|
||||
ServiceName = name,
|
||||
Description = description
|
||||
};
|
||||
}
|
||||
|
@ -1,20 +1,10 @@
|
||||
using ITServiceManager.Entities;
|
||||
using ITServiceManager.Repositories;
|
||||
using ITServiceManager.Repositories.Implementations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ITServiceManager.Forms
|
||||
namespace ITServiceManager.Forms;
|
||||
|
||||
public partial class FormAppointment : Form
|
||||
{
|
||||
public partial class FormAppointment : Form
|
||||
{
|
||||
private readonly IAppointmentRepository _appointmentRepository;
|
||||
private int? _appointmentId;
|
||||
public int Id
|
||||
@ -82,5 +72,4 @@ namespace ITServiceManager.Forms
|
||||
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,19 +1,10 @@
|
||||
using ITServiceManager.Repositories;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Unity;
|
||||
|
||||
namespace ITServiceManager.Forms
|
||||
namespace ITServiceManager.Forms;
|
||||
|
||||
public partial class FormAppointments : Form
|
||||
{
|
||||
public partial class FormAppointments : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
private readonly IAppointmentRepository _appointmentRepository;
|
||||
public FormAppointments(IUnityContainer container, IAppointmentRepository appointmentRepository)
|
||||
@ -76,6 +67,5 @@ namespace ITServiceManager.Forms
|
||||
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,19 +1,10 @@
|
||||
using ITServiceManager.Repositories;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Unity;
|
||||
|
||||
namespace ITServiceManager.Forms
|
||||
namespace ITServiceManager.Forms;
|
||||
|
||||
public partial class FormCompanies : Form
|
||||
{
|
||||
public partial class FormCompanies : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
private readonly ICompanyRepository _companyRepository;
|
||||
|
||||
@ -102,5 +93,4 @@ namespace ITServiceManager.Forms
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,6 @@
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(200, 23);
|
||||
textBoxName.TabIndex = 1;
|
||||
textBoxName.TextChanged += textBoxName_TextChanged;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
|
@ -1,20 +1,10 @@
|
||||
using ITServiceManager.Entities;
|
||||
using ITServiceManager.Repositories;
|
||||
using ITServiceManager.Repositories.Implementations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ITServiceManager.Forms
|
||||
namespace ITServiceManager.Forms;
|
||||
|
||||
public partial class FormCompany : Form
|
||||
{
|
||||
public partial class FormCompany : Form
|
||||
{
|
||||
private readonly ICompanyRepository _companyRepository;
|
||||
private int? _companyId;
|
||||
public int Id
|
||||
@ -71,9 +61,4 @@ namespace ITServiceManager.Forms
|
||||
private void ButtonCancel_Click(object sender, EventArgs e) => Close();
|
||||
private Company CreateCompany(int id) => Company.CreateEntity(id, textBoxName.Text, textBoxAddress.Text);
|
||||
|
||||
private void textBoxName_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,10 @@
|
||||
using ITServiceManager.Repositories;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Unity;
|
||||
|
||||
namespace ITServiceManager.Forms
|
||||
namespace ITServiceManager.Forms;
|
||||
|
||||
public partial class FormEmployees : Form
|
||||
{
|
||||
public partial class FormEmployees : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
private readonly IEmployeeRepository _employeeRepository;
|
||||
public FormEmployees(IUnityContainer container, IEmployeeRepository
|
||||
@ -111,7 +102,4 @@ namespace ITServiceManager.Forms
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,10 @@
|
||||
using ITServiceManager.Entities;
|
||||
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 System.Windows.Forms.VisualStyles;
|
||||
|
||||
namespace ITServiceManager.Forms
|
||||
namespace ITServiceManager.Forms;
|
||||
|
||||
public partial class FormOrder : Form
|
||||
{
|
||||
public partial class FormOrder : Form
|
||||
{
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
public FormOrder(IOrderRepository orderRepository, IServiceRepository serviceRepository, ICompanyRepository companyRepository)
|
||||
{
|
||||
@ -26,7 +16,7 @@ namespace ITServiceManager.Forms
|
||||
comboBoxCompany.ValueMember = "Id";
|
||||
|
||||
ColumnService.DataSource = serviceRepository.ReadServices();
|
||||
ColumnService.DisplayMember = "ServiceType";
|
||||
ColumnService.DisplayMember = "ServiceName";
|
||||
ColumnService.ValueMember = "Id";
|
||||
}
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
@ -59,6 +49,5 @@ namespace ITServiceManager.Forms
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,19 +1,10 @@
|
||||
using ITServiceManager.Repositories;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using Unity;
|
||||
|
||||
namespace ITServiceManager.Forms
|
||||
namespace ITServiceManager.Forms;
|
||||
|
||||
public partial class FormOrders : Form
|
||||
{
|
||||
public partial class FormOrders : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
private readonly IOrderRepository _orderRepository;
|
||||
public FormOrders(IUnityContainer container, IOrderRepository orderRepository)
|
||||
@ -77,5 +68,4 @@ namespace ITServiceManager.Forms
|
||||
id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -34,14 +34,15 @@
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
checkedListBoxType = new CheckedListBox();
|
||||
textBoxName = new TextBox();
|
||||
labelName = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(358, 367);
|
||||
buttonCancel.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonCancel.Location = new Point(310, 318);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(128, 37);
|
||||
buttonCancel.Size = new Size(112, 28);
|
||||
buttonCancel.TabIndex = 7;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
@ -49,10 +50,9 @@
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(99, 367);
|
||||
buttonAdd.Margin = new Padding(3, 4, 3, 4);
|
||||
buttonAdd.Location = new Point(84, 318);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(128, 37);
|
||||
buttonAdd.Size = new Size(112, 28);
|
||||
buttonAdd.TabIndex = 6;
|
||||
buttonAdd.Text = "Добавить";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
@ -60,49 +60,70 @@
|
||||
//
|
||||
// richTextBoxDescription
|
||||
//
|
||||
richTextBoxDescription.Location = new Point(278, 159);
|
||||
richTextBoxDescription.Location = new Point(240, 207);
|
||||
richTextBoxDescription.Margin = new Padding(3, 2, 3, 2);
|
||||
richTextBoxDescription.Name = "richTextBoxDescription";
|
||||
richTextBoxDescription.Size = new Size(265, 175);
|
||||
richTextBoxDescription.Size = new Size(232, 87);
|
||||
richTextBoxDescription.TabIndex = 9;
|
||||
richTextBoxDescription.Text = "";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(68, 36);
|
||||
label1.Location = new Point(57, 52);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(83, 20);
|
||||
label1.Size = new Size(67, 15);
|
||||
label1.TabIndex = 4;
|
||||
label1.Text = "Тип услуги";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(52, 179);
|
||||
label2.Location = new Point(57, 239);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(127, 20);
|
||||
label2.Size = new Size(102, 15);
|
||||
label2.TabIndex = 8;
|
||||
label2.Text = "Описание услуги";
|
||||
//
|
||||
// checkedListBoxType
|
||||
//
|
||||
checkedListBoxType.FormattingEnabled = true;
|
||||
checkedListBoxType.Location = new Point(278, 12);
|
||||
checkedListBoxType.Location = new Point(240, 29);
|
||||
checkedListBoxType.Margin = new Padding(3, 2, 3, 2);
|
||||
checkedListBoxType.Name = "checkedListBoxType";
|
||||
checkedListBoxType.Size = new Size(265, 114);
|
||||
checkedListBoxType.Size = new Size(232, 76);
|
||||
checkedListBoxType.TabIndex = 10;
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(240, 142);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(232, 23);
|
||||
textBoxName.TabIndex = 11;
|
||||
//
|
||||
// labelName
|
||||
//
|
||||
labelName.AutoSize = true;
|
||||
labelName.Location = new Point(57, 142);
|
||||
labelName.Name = "labelName";
|
||||
labelName.Size = new Size(59, 15);
|
||||
labelName.TabIndex = 12;
|
||||
labelName.Text = "Название";
|
||||
//
|
||||
// FormService
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(584, 451);
|
||||
ClientSize = new Size(511, 362);
|
||||
Controls.Add(labelName);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(checkedListBoxType);
|
||||
Controls.Add(richTextBoxDescription);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(label1);
|
||||
Margin = new Padding(3, 2, 3, 2);
|
||||
Name = "FormService";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Услуга";
|
||||
@ -118,5 +139,7 @@
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private CheckedListBox checkedListBoxType;
|
||||
private TextBox textBoxName;
|
||||
private Label labelName;
|
||||
}
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
using ITServiceManager.Entities.Enums;
|
||||
using ITServiceManager.Entities;
|
||||
using ITServiceManager.Repositories;
|
||||
using Microsoft.VisualBasic.FileIO;
|
||||
|
||||
namespace ITServiceManager.Forms;
|
||||
|
||||
@ -31,7 +30,7 @@ public partial class FormService : Form
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
textBoxName.Text = service.ServiceName;
|
||||
richTextBoxDescription.Text = service.Description;
|
||||
_serviceId = value;
|
||||
}
|
||||
@ -58,7 +57,7 @@ public partial class FormService : Form
|
||||
try
|
||||
{
|
||||
if (checkedListBoxType.CheckedItems.Count == 0 ||
|
||||
string.IsNullOrWhiteSpace(richTextBoxDescription.Text))
|
||||
string.IsNullOrWhiteSpace(richTextBoxDescription.Text) || string.IsNullOrWhiteSpace(textBoxName.Text))
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
@ -87,6 +86,6 @@ public partial class FormService : Form
|
||||
serviceType |= (ServiceType)elem;
|
||||
}
|
||||
|
||||
return Service.CreateEntity(id, serviceType, richTextBoxDescription.Text);
|
||||
return Service.CreateEntity(id, serviceType, textBoxName.Text, richTextBoxDescription.Text);
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,10 @@ using ITServiceManager.Repositories.Implementations;
|
||||
using ITServiceManager.Repositories;
|
||||
using Unity;
|
||||
|
||||
namespace ITServiceManager
|
||||
namespace ITServiceManager;
|
||||
|
||||
internal static class Program
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
@ -32,5 +32,4 @@ namespace ITServiceManager
|
||||
|
||||
return container;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user