начало
This commit is contained in:
parent
e14cdc0cfc
commit
5dbc07fdc5
@ -1,11 +1,24 @@
|
|||||||
namespace ITServiceManager.Entities;
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace ITServiceManager.Entities;
|
||||||
|
|
||||||
public class Appointment
|
public class Appointment
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int EmployeeId { get; private set; }
|
public int EmployeeId { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int OrderId { get; private set; }
|
public int OrderId { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Сотрудник")]
|
||||||
|
public string EmployeeName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Дата назначения")]
|
||||||
public DateTime StartDate { get; private set; }
|
public DateTime StartDate { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Дата окончания")]
|
||||||
public DateTime? EndDate { get; private set; }
|
public DateTime? EndDate { get; private set; }
|
||||||
|
|
||||||
public static Appointment CreateOperation(int id, int orderId, int employeeId, DateTime appointmentStartDate, DateTime? appointmentEndDate)
|
public static Appointment CreateOperation(int id, int orderId, int employeeId, DateTime appointmentStartDate, DateTime? appointmentEndDate)
|
||||||
|
@ -1,10 +1,15 @@
|
|||||||
namespace ITServiceManager.Entities;
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace ITServiceManager.Entities;
|
||||||
|
|
||||||
public class Company
|
public class Company
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Название")]
|
||||||
public string Name { get; private set; } = string.Empty;
|
public string Name { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Адресс")]
|
||||||
public string Address { get; private set; } = string.Empty;
|
public string Address { get; private set; } = string.Empty;
|
||||||
|
|
||||||
public static Company CreateEntity(int id, string companyName, string addres)
|
public static Company CreateEntity(int id, string companyName, string addres)
|
||||||
|
@ -1,12 +1,21 @@
|
|||||||
using ITServiceManager.Entities.Enums;
|
using ITServiceManager.Entities.Enums;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace ITServiceManager.Entities;
|
namespace ITServiceManager.Entities;
|
||||||
|
|
||||||
public class Employee
|
public class Employee
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Имя")]
|
||||||
public string FirstName { get; private set; } = string.Empty;
|
public string FirstName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Фамилия")]
|
||||||
public string LastName { get; private set; } = string.Empty;
|
public string LastName { get; private set; } = string.Empty;
|
||||||
|
public string FullName => $"{LastName} {FirstName}";
|
||||||
|
|
||||||
|
|
||||||
|
[DisplayName("Должность")]
|
||||||
public EmployeePost? Position { get; private set; }
|
public EmployeePost? Position { get; private set; }
|
||||||
|
|
||||||
public static Employee CreateEntity(int id, string employeeFirstName, string employeeLastName, EmployeePost employeePosition)
|
public static Employee CreateEntity(int id, string employeeFirstName, string employeeLastName, EmployeePost employeePosition)
|
||||||
|
@ -1,12 +1,28 @@
|
|||||||
namespace ITServiceManager.Entities;
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace ITServiceManager.Entities;
|
||||||
|
|
||||||
public class Order
|
public class Order
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int CompanyId { get; private set; }
|
public int CompanyId { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Дата")]
|
||||||
public DateTime Date { get; private set; }
|
public DateTime Date { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Сумма")]
|
||||||
public decimal Price { get; private set; }
|
public decimal Price { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Название компании")]
|
||||||
|
public string CompanyName { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Услуги")]
|
||||||
|
public string Services => OrderService != null ?
|
||||||
|
string.Join(", ", OrderService.Select(x => $"{x.ServiceName} {x.Quantity}")) : string.Empty;
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public IEnumerable<OrderService> OrderService { get; private set; } = [];
|
public IEnumerable<OrderService> OrderService { 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)
|
||||||
|
@ -5,6 +5,7 @@ public class OrderService
|
|||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
public int OrderId { get; private set; }
|
public int OrderId { get; private set; }
|
||||||
public int ServiceId { get; private set; }
|
public int ServiceId { get; private set; }
|
||||||
|
public string ServiceName { get; private set; } = string.Empty;
|
||||||
public int Quantity { get; private set; }
|
public int Quantity { get; private set; }
|
||||||
public DateTime ExecutionDate { get; private set; }
|
public DateTime ExecutionDate { get; private set; }
|
||||||
|
|
||||||
|
@ -1,11 +1,16 @@
|
|||||||
using ITServiceManager.Entities.Enums;
|
using ITServiceManager.Entities.Enums;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace ITServiceManager.Entities;
|
namespace ITServiceManager.Entities;
|
||||||
|
|
||||||
public class Service
|
public class Service
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Тип услуги")]
|
||||||
public ServiceType ServiceType { get; private set; }
|
public ServiceType ServiceType { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Описание")]
|
||||||
public string Description { 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 description)
|
||||||
|
@ -38,7 +38,7 @@ namespace ITServiceManager.Forms
|
|||||||
throw new ArgumentNullException(nameof(appointmentRepository));
|
throw new ArgumentNullException(nameof(appointmentRepository));
|
||||||
|
|
||||||
comboBoxOrder.DataSource = orderRepository.ReadOrders();
|
comboBoxOrder.DataSource = orderRepository.ReadOrders();
|
||||||
comboBoxOrder.DisplayMember = "Name";
|
comboBoxOrder.DisplayMember = "FullName";
|
||||||
comboBoxOrder.ValueMember = "Id";
|
comboBoxOrder.ValueMember = "Id";
|
||||||
|
|
||||||
comboBoxEmployee.DataSource = employeeRepository.ReadEmployees();
|
comboBoxEmployee.DataSource = employeeRepository.ReadEmployees();
|
||||||
|
@ -65,7 +65,13 @@ namespace ITServiceManager.Forms
|
|||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void LoadList() => dataGridView.DataSource = _appointmentRepository.ReadAppointments();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = _appointmentRepository.ReadAppointments();
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
dataGridView.Columns["StartDate"].DefaultCellStyle.Format = "dd MMMM yyyy hh:mm";
|
||||||
|
dataGridView.Columns["EndDate"].DefaultCellStyle.Format = "dd MMMM yyyy hh:mm";
|
||||||
|
}
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
id = 0;
|
id = 0;
|
||||||
|
@ -85,7 +85,11 @@ namespace ITServiceManager.Forms
|
|||||||
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void LoadList() => dataGridView.DataSource = _companyRepository.ReadCompanies();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = _companyRepository.ReadCompanies();
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
}
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
id = 0;
|
id = 0;
|
||||||
|
@ -95,8 +95,13 @@ namespace ITServiceManager.Forms
|
|||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void LoadList() => dataGridView.DataSource =
|
private void LoadList()
|
||||||
_employeeRepository.ReadEmployees();
|
{
|
||||||
|
dataGridView.DataSource =_employeeRepository.ReadEmployees();
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
dataGridView.Columns["FullName"].Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
id = 0;
|
id = 0;
|
||||||
|
@ -65,7 +65,12 @@ namespace ITServiceManager.Forms
|
|||||||
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void LoadList() => dataGridView.DataSource = _orderRepository.ReadOrders();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = _orderRepository.ReadOrders();
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
dataGridView.Columns["Date"].DefaultCellStyle.Format = "dd MMMM yyyy hh:mm";
|
||||||
|
}
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
id = 0;
|
id = 0;
|
||||||
|
@ -22,6 +22,28 @@ public class OrderRepository : IOrderRepository
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
|
var builder = new QueryBuilder();
|
||||||
|
if (dateForm.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("fa.FeedingDate >= @dateForm");
|
||||||
|
}
|
||||||
|
if (dateTo.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("fa.FeedingDate <= @dateTo");
|
||||||
|
}
|
||||||
|
if (feedId.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("fa.FeedId = @feedId");
|
||||||
|
}
|
||||||
|
if (employeeId.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("fa.EmployeeId = @employeeId");
|
||||||
|
}
|
||||||
|
if (animalId.HasValue)
|
||||||
|
{
|
||||||
|
builder.AddCondition("fa.AnimalId = @animalId");
|
||||||
|
}
|
||||||
|
|
||||||
var querySelect = @"
|
var querySelect = @"
|
||||||
SELECT o.*, os.serviceId, os.quantity
|
SELECT o.*, os.serviceId, os.quantity
|
||||||
FROM Orders AS o
|
FROM Orders AS o
|
||||||
|
@ -0,0 +1,29 @@
|
|||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ITServiceManager.Repositories.Implementations;
|
||||||
|
|
||||||
|
public class QueryBuilder
|
||||||
|
{
|
||||||
|
private readonly StringBuilder _builder;
|
||||||
|
public QueryBuilder()
|
||||||
|
{
|
||||||
|
_builder = new();
|
||||||
|
}
|
||||||
|
public QueryBuilder AddCondition(string condition)
|
||||||
|
{
|
||||||
|
if (_builder.Length > 0)
|
||||||
|
{
|
||||||
|
_builder.Append(" AND ");
|
||||||
|
}
|
||||||
|
_builder.Append(condition);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
public string Build()
|
||||||
|
{
|
||||||
|
if (_builder.Length == 0)
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
return $"WHERE {_builder}";
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user