Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
3cfbc952b7 | ||
|
a2531a745c | ||
|
d74bbe43a0 |
28
TransportEnterprise/TransportEnterprise/Entities/Bus.cs
Normal file
28
TransportEnterprise/TransportEnterprise/Entities/Bus.cs
Normal file
@ -0,0 +1,28 @@
|
||||
using TransportEnterprise.Entities.Enums;
|
||||
|
||||
namespace TransportEnterprise.Entities;
|
||||
|
||||
public class Bus
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string Model { get; private set; } = string.Empty;
|
||||
public int Capacity { get; private set; }
|
||||
public string LicensePlate { get; private set; } = string.Empty;
|
||||
public string Brand { get; private set; } = string.Empty;
|
||||
public int Year { get; private set; }
|
||||
public TechnicalCondition TechnicalCondition { get; private set; }
|
||||
|
||||
public static Bus CreateBus(int id, string model, int capacity, string licensePlate, string brand, int year, TechnicalCondition technicalCondition)
|
||||
{
|
||||
return new Bus
|
||||
{
|
||||
Id = id,
|
||||
Model = model ?? string.Empty,
|
||||
Capacity = capacity,
|
||||
LicensePlate = licensePlate ?? string.Empty,
|
||||
Brand = brand ?? string.Empty,
|
||||
Year = year,
|
||||
TechnicalCondition = technicalCondition
|
||||
};
|
||||
}
|
||||
}
|
23
TransportEnterprise/TransportEnterprise/Entities/Employee.cs
Normal file
23
TransportEnterprise/TransportEnterprise/Entities/Employee.cs
Normal file
@ -0,0 +1,23 @@
|
||||
using TransportEnterprise.Entities.Enums;
|
||||
|
||||
namespace TransportEnterprise.Entities;
|
||||
|
||||
public class Employee
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string Name { get; private set; } = string.Empty;
|
||||
public int Number { get; private set; }
|
||||
public PositionOfEmployee PositionOfEmployee { get; private set; }
|
||||
public string PhoneNumber { get; private set; } = string.Empty;
|
||||
public static Employee CreateEmployee(int id, string name, int number, PositionOfEmployee positionOfEmployee, string phoheNumber)
|
||||
{
|
||||
return new Employee
|
||||
{
|
||||
Id = id,
|
||||
Name = name ?? string.Empty,
|
||||
Number = number,
|
||||
PositionOfEmployee = positionOfEmployee,
|
||||
PhoneNumber = phoheNumber ?? string.Empty
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
namespace TransportEnterprise.Entities.Enums;
|
||||
[Flags]
|
||||
public enum BreakDownType
|
||||
{
|
||||
None = 0,
|
||||
RunningGear =1,
|
||||
Enginee = 2,
|
||||
Backseat = 4
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
namespace TransportEnterprise.Entities.Enums;
|
||||
|
||||
public enum PositionOfEmployee
|
||||
{
|
||||
None = 0,
|
||||
Enginer = 1,
|
||||
Conductor = 2,
|
||||
Driver = 3,
|
||||
Admin = 4
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
namespace TransportEnterprise.Entities.Enums;
|
||||
public enum TechnicalCondition
|
||||
{
|
||||
None = 0,
|
||||
ReadyToGo = 1,
|
||||
RequiresRepair = 2,
|
||||
ReadyToGo_NeedsRepair=4
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
using TransportEnterprise.Entities.Enums;
|
||||
|
||||
namespace TransportEnterprise.Entities;
|
||||
|
||||
public class RepairRequest
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public int BusId { get; private set; }
|
||||
public BreakDownType BreakDownType { get; private set; }
|
||||
public DateTime DateTime { get; private set; }
|
||||
public int EmployeeId { get; private set; }
|
||||
public static RepairRequest CreateRepairRequest(int id, int busId, BreakDownType breakDownType, DateTime dateTime, int employeeId)
|
||||
{
|
||||
return new RepairRequest
|
||||
{
|
||||
Id = id,
|
||||
BusId = busId,
|
||||
BreakDownType = breakDownType,
|
||||
DateTime = dateTime,
|
||||
EmployeeId = employeeId
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
namespace TransportEnterprise.Entities.Repositories;
|
||||
|
||||
public interface IBusRepository
|
||||
{
|
||||
IEnumerable<Bus> ReadBuses();
|
||||
Bus ReadBusById(int id);
|
||||
void CreateBus(Bus bus);
|
||||
void UpdateBus(Bus bus);
|
||||
void DeleteBus(int id);
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
namespace TransportEnterprise.Entities.Repositories;
|
||||
|
||||
public interface IConnectionString
|
||||
{
|
||||
public string ConnectionString { get; }
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
namespace TransportEnterprise.Entities.Repositories;
|
||||
|
||||
public interface IEmployeeRepository
|
||||
{
|
||||
IEnumerable<Employee> ReadEmployees();
|
||||
Employee ReadEmployeeById(int id);
|
||||
void CreateEmployee(Employee employee);
|
||||
void UpdateEmployee(Employee employee);
|
||||
void DeleteEmployee(int id);
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
namespace TransportEnterprise.Entities.Repositories;
|
||||
|
||||
public interface IRepairRequestRepository
|
||||
{
|
||||
IEnumerable<RepairRequest> ReadRepairRequests();
|
||||
RepairRequest ReadRepairRequestById(int id);
|
||||
void CreateRepairRequest(RepairRequest repairRequest);
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
namespace TransportEnterprise.Entities.Repositories;
|
||||
public interface IRouteRepository
|
||||
{
|
||||
IEnumerable<Route> ReadRoutes();
|
||||
Route ReadRouteById(int id);
|
||||
void CreateRoute(Route route);
|
||||
void UpdateRoute(Route route);
|
||||
void DeleteRoute(int id);
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
namespace TransportEnterprise.Entities.Repositories;
|
||||
public interface IRouteSheetRepository
|
||||
{
|
||||
IEnumerable<RouteSheet> ReadRouteSheets();
|
||||
RouteSheet ReadRouteSheeteById(int id);
|
||||
IEnumerable<RouteSheet_Employee> ReadRouteSheets_Employee();
|
||||
void CreateRouteSheet(RouteSheet routeSheet);
|
||||
void UpdateRouteSheet(RouteSheet routeSheet);
|
||||
void DeleteRouteSheet(int id);
|
||||
}
|
@ -0,0 +1,119 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Dapper;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
|
||||
namespace TransportEnterprise.Entities.Repositories.Implementations;
|
||||
public class BusRepository : IBusRepository
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
private readonly ILogger<BusRepository> _logger;
|
||||
public BusRepository(IConnectionString connectionString, ILogger<BusRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public void CreateBus(Bus bus)
|
||||
{
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(bus));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"
|
||||
INSERT INTO Bus (Model, Capacity, Licenseplate, Brand, Year, Technicalcondition)
|
||||
VALUES (@Model, @Capacity, @Licenseplate, @Brand, @Year, @Technicalcondition)";
|
||||
connection.Execute(queryInsert, bus);
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public void UpdateBus(Bus bus)
|
||||
{
|
||||
_logger.LogInformation("Редактирование объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(bus));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryUpdate = @"
|
||||
UPDATE Bus
|
||||
SET Model=@Model, Capacity=@Capacity, Licenseplate=@Licenseplate, Brand=@Brand, Year=@Year, Technicalcondition=@Technicalcondition
|
||||
WHERE Id=@Id";
|
||||
connection.Execute(queryUpdate, bus);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public void DeleteBus(int id)
|
||||
{
|
||||
_logger.LogInformation("Удаление объекта");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new
|
||||
NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryDelete = @"
|
||||
DELETE FROM Bus
|
||||
WHERE Id=@id";
|
||||
connection.Execute(queryDelete, new { id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public Bus ReadBusById(int id)
|
||||
{
|
||||
_logger.LogInformation("Получение объекта по идентификатору");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new
|
||||
NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"
|
||||
SELECT * FROM Bus
|
||||
WHERE Id=@id";
|
||||
var bus = connection.QueryFirst<Bus>(querySelect, new
|
||||
{
|
||||
id
|
||||
});
|
||||
_logger.LogDebug("Найденный объект: {json}",
|
||||
JsonConvert.SerializeObject(bus));
|
||||
return bus;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Bus> ReadBuses()
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new
|
||||
NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM Bus";
|
||||
var buses = connection.Query<Bus>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
JsonConvert.SerializeObject(buses));
|
||||
return buses;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
namespace TransportEnterprise.Entities.Repositories.Implementations;
|
||||
|
||||
public class ConnectionString : IConnectionString
|
||||
{
|
||||
string IConnectionString.ConnectionString => "Server=localhost;Port=5432;Database=TransportEnterprise;User Id=postgres;Password=kuslo123;";
|
||||
}
|
@ -0,0 +1,127 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Dapper;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
using TransportEnterprise.Entities.Enums;
|
||||
|
||||
namespace TransportEnterprise.Entities.Repositories.Implementations;
|
||||
|
||||
public class EmployeeRepository : IEmployeeRepository
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
private readonly ILogger<EmployeeRepository> _logger;
|
||||
|
||||
public EmployeeRepository(IConnectionString connectionString, ILogger<EmployeeRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
public void CreateEmployee(Employee employee)
|
||||
{
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(employee));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"
|
||||
INSERT INTO Employee(Name, Number, PositionOfEmployee, PhoneNumber)
|
||||
VALUES (@Name, @Number, @PositionOfEmployee, @PhoneNumber)";
|
||||
connection.Execute(queryInsert, employee);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
public void UpdateEmployee(Employee employee)
|
||||
{
|
||||
_logger.LogInformation("Редактирование объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(employee));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryUpdate = @"
|
||||
UPDATE Employee
|
||||
SET Name=@Name, Number=@Number, PositionOfEmployee=@PositionOfEmployee, PhoneNumber=@PhoneNumber
|
||||
WHERE Id=@Id";
|
||||
connection.Execute(queryUpdate, employee);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public void DeleteEmployee(int id)
|
||||
{
|
||||
_logger.LogInformation("Удаление объекта");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new
|
||||
NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryDelete = @"
|
||||
DELETE FROM Employee
|
||||
WHERE Id=@id";
|
||||
connection.Execute(queryDelete, new { id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public Employee ReadEmployeeById(int id)
|
||||
{
|
||||
_logger.LogInformation("Получение объекта по идентификатору");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new
|
||||
NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"
|
||||
SELECT * FROM Employee
|
||||
WHERE Id=@id";
|
||||
var employee = connection.QueryFirst<Employee>(querySelect, new
|
||||
{
|
||||
id
|
||||
});
|
||||
_logger.LogDebug("Найденный объект: {json}",
|
||||
JsonConvert.SerializeObject(employee));
|
||||
return employee;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Employee> ReadEmployees()
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new
|
||||
NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM Employee";
|
||||
var employees = connection.Query<Employee>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
JsonConvert.SerializeObject(employees));
|
||||
return employees;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,84 @@
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Dapper;
|
||||
using Npgsql;
|
||||
using TransportEnterprise.Entities.Enums;
|
||||
|
||||
namespace TransportEnterprise.Entities.Repositories.Implementations;
|
||||
|
||||
public class RepairRequestRepository : IRepairRequestRepository
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
private readonly ILogger<RepairRequestRepository> _logger;
|
||||
public RepairRequestRepository(IConnectionString connectionString, ILogger<RepairRequestRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
public void CreateRepairRequest(RepairRequest repairRequest)
|
||||
{
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(repairRequest));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"
|
||||
INSERT INTO RepairRequest (EmployeeId, BusId, BreakDownType, Datetime)
|
||||
VALUES (@EmployeeId, @BusId, @BreakDownType, @Datetime)";
|
||||
connection.Execute(queryInsert, repairRequest);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public RepairRequest ReadRepairRequestById(int id)
|
||||
{
|
||||
_logger.LogInformation("Получение объекта по идентификатору");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new
|
||||
NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"
|
||||
SELECT * FROM RepairRequest
|
||||
WHERE Id=@id";
|
||||
var repairRequest = connection.QueryFirst<RepairRequest>(querySelect, new
|
||||
{
|
||||
id
|
||||
});
|
||||
_logger.LogDebug("Найденный объект: {json}",
|
||||
JsonConvert.SerializeObject(repairRequest));
|
||||
return repairRequest;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<RepairRequest> ReadRepairRequests()
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new
|
||||
NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM RepairRequest";
|
||||
var repairRequests = connection.Query<RepairRequest>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
JsonConvert.SerializeObject(repairRequests));
|
||||
return repairRequests;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Dapper;
|
||||
using Newtonsoft.Json;
|
||||
using Npgsql;
|
||||
|
||||
namespace TransportEnterprise.Entities.Repositories.Implementations;
|
||||
|
||||
public class RouteRepository : IRouteRepository
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
private readonly ILogger<RouteRepository> _logger;
|
||||
public RouteRepository(IConnectionString connectionString, ILogger<RouteRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
public void CreateRoute(Route route)
|
||||
{
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(route));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryInsert = @"
|
||||
INSERT INTO Route (Name, Number, Interval, Schedule)
|
||||
VALUES (@Name, @Number, @Interval, @Schedule)";
|
||||
connection.Execute(queryInsert, route);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public void UpdateRoute(Route route)
|
||||
{
|
||||
_logger.LogInformation("Редактирование объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(route));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryUpdate = @"
|
||||
UPDATE Route
|
||||
SET Name=@Name, Number=@Number, Interval=@Interval, Schedule=@Schedule
|
||||
WHERE Id=@Id";
|
||||
connection.Execute(queryUpdate, route);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public void DeleteRoute(int id)
|
||||
{
|
||||
_logger.LogInformation("Удаление объекта");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new
|
||||
NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryDelete = @"
|
||||
DELETE FROM Route
|
||||
WHERE Id=@id";
|
||||
connection.Execute(queryDelete, new { id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public Route ReadRouteById(int id)
|
||||
{
|
||||
_logger.LogInformation("Получение объекта по идентификатору");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new
|
||||
NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"
|
||||
SELECT * FROM Route
|
||||
WHERE Id=@id";
|
||||
var route = connection.QueryFirst<Route>(querySelect, new
|
||||
{
|
||||
id
|
||||
});
|
||||
_logger.LogDebug("Найденный объект: {json}",
|
||||
JsonConvert.SerializeObject(route));
|
||||
return route;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<Route> ReadRoutes()
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new
|
||||
NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM Route";
|
||||
var routes = connection.Query<Route>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
JsonConvert.SerializeObject(routes));
|
||||
return routes;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,166 @@
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Newtonsoft.Json;
|
||||
using Dapper;
|
||||
using Npgsql;
|
||||
using System.Transactions;
|
||||
|
||||
namespace TransportEnterprise.Entities.Repositories.Implementations;
|
||||
|
||||
public class RouteSheetRepository : IRouteSheetRepository
|
||||
|
||||
{
|
||||
private readonly IConnectionString _connectionString;
|
||||
private readonly ILogger<RouteSheetRepository> _logger;
|
||||
|
||||
public RouteSheetRepository(IConnectionString connectionString, ILogger<RouteSheetRepository> logger)
|
||||
{
|
||||
_connectionString = connectionString;
|
||||
_logger = logger;
|
||||
}
|
||||
public void CreateRouteSheet(RouteSheet routeSheet)
|
||||
{
|
||||
_logger.LogInformation("Добавление объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(routeSheet));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
|
||||
connection.Open();
|
||||
using var transaction = connection.BeginTransaction();
|
||||
|
||||
var queryInsert = @"
|
||||
INSERT INTO RouteSheet (Datetime, RouteId, BusId)
|
||||
VALUES (@Datetime, @RouteId, @BusId);
|
||||
SELECT MAX(Id) FROM RouteSheet";
|
||||
|
||||
|
||||
var routeSheetId = connection.QueryFirst<int>(queryInsert, routeSheet, transaction);
|
||||
|
||||
var querySubInsert = @"
|
||||
INSERT INTO RouteSheet_Employee (RouteSheetId, EmployeeId, Count)
|
||||
VALUES (@RouteSheetId, @EmployeeId, @Count)";
|
||||
foreach (var elem in routeSheet.RouteSheet_Employee)
|
||||
{
|
||||
connection.Execute(querySubInsert, new
|
||||
{
|
||||
routeSheetId,
|
||||
elem.EmployeeId,
|
||||
elem.Count
|
||||
}, transaction);
|
||||
}
|
||||
transaction.Commit();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при добавлении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public void UpdateRouteSheet(RouteSheet routeSheet)
|
||||
{
|
||||
_logger.LogInformation("Редактирование объекта");
|
||||
_logger.LogDebug("Объект: {json}", JsonConvert.SerializeObject(routeSheet));
|
||||
try
|
||||
{
|
||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryUpdate = @"
|
||||
UPDATE RouteSheet
|
||||
SET Datetime=@Datetime, RouteId=@RouteId, BusId=@BusId
|
||||
WHERE Id=@Id";
|
||||
connection.Execute(queryUpdate, routeSheet);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при редактировании объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public void DeleteRouteSheet(int id)
|
||||
{
|
||||
_logger.LogInformation("Удаление объекта");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new
|
||||
NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var queryDelete = @"
|
||||
DELETE FROM RouteSheet
|
||||
WHERE Id=@id";
|
||||
connection.Execute(queryDelete, new { id });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при удалении объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public RouteSheet ReadRouteSheeteById(int id)
|
||||
{
|
||||
_logger.LogInformation("Получение объекта по идентификатору");
|
||||
_logger.LogDebug("Объект: {id}", id);
|
||||
try
|
||||
{
|
||||
using var connection = new
|
||||
NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = @"
|
||||
SELECT * FROM RouteSheet
|
||||
WHERE Id=@id";
|
||||
var routeSheet = connection.QueryFirst<RouteSheet>(querySelect, new
|
||||
{
|
||||
id
|
||||
});
|
||||
_logger.LogDebug("Найденный объект: {json}",
|
||||
JsonConvert.SerializeObject(routeSheet));
|
||||
return routeSheet;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при поиске объекта");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<RouteSheet> ReadRouteSheets()
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new
|
||||
NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM RouteSheet";
|
||||
var routeSheets = connection.Query<RouteSheet>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
JsonConvert.SerializeObject(routeSheets));
|
||||
return routeSheets;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<RouteSheet_Employee> ReadRouteSheets_Employee()
|
||||
{
|
||||
_logger.LogInformation("Получение всех объектов");
|
||||
try
|
||||
{
|
||||
using var connection = new
|
||||
NpgsqlConnection(_connectionString.ConnectionString);
|
||||
var querySelect = "SELECT * FROM RouteSheet_Employee";
|
||||
var routeSheets = connection.Query<RouteSheet_Employee>(querySelect);
|
||||
_logger.LogDebug("Полученные объекты: {json}",
|
||||
JsonConvert.SerializeObject(routeSheets));
|
||||
return routeSheets;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при чтении объектов");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
21
TransportEnterprise/TransportEnterprise/Entities/Route.cs
Normal file
21
TransportEnterprise/TransportEnterprise/Entities/Route.cs
Normal file
@ -0,0 +1,21 @@
|
||||
namespace TransportEnterprise.Entities;
|
||||
|
||||
public class Route
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string Name { get; private set; } = string.Empty;
|
||||
public int Number { get; private set; }
|
||||
public int Interval { get; private set; }
|
||||
public string Schedule { get; private set; } = string.Empty;
|
||||
public static Route CreateRoute (int id, string name, int number, int interval, string schedule)
|
||||
{
|
||||
return new Route
|
||||
{
|
||||
Id = id,
|
||||
Name = name ?? string.Empty,
|
||||
Number = number,
|
||||
Interval = interval,
|
||||
Schedule = schedule ?? string.Empty
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
|
||||
namespace TransportEnterprise.Entities;
|
||||
|
||||
public class RouteSheet
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public DateTime DateTime { get; private set; }
|
||||
public int BusId { get; private set; }
|
||||
public int RouteId { get; private set; }
|
||||
public IEnumerable<RouteSheet_Employee> RouteSheet_Employee { get; private set; } = [];
|
||||
|
||||
|
||||
public static RouteSheet CreateRouteSheet(int id, DateTime dateTime, int bus, int route, IEnumerable<RouteSheet_Employee> routeSheetEmployees)
|
||||
{
|
||||
return new RouteSheet
|
||||
{
|
||||
Id = id,
|
||||
DateTime = dateTime,
|
||||
BusId = bus,
|
||||
RouteId = route,
|
||||
RouteSheet_Employee = routeSheetEmployees
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
namespace TransportEnterprise.Entities;
|
||||
|
||||
public class RouteSheet_Employee
|
||||
{
|
||||
public int RouteSheetId { get; private set; }
|
||||
public int EmployeeId { get; private set; }
|
||||
public int Count { get; private set; }
|
||||
|
||||
public static RouteSheet_Employee CreateOperation(int id, int employeeId, int count)
|
||||
{
|
||||
return new RouteSheet_Employee { RouteSheetId = id, EmployeeId = employeeId, Count = count};
|
||||
}
|
||||
}
|
@ -1,39 +0,0 @@
|
||||
namespace TransportEnterprise
|
||||
{
|
||||
partial class Form1
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Text = "Form1";
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
namespace TransportEnterprise
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
100
TransportEnterprise/TransportEnterprise/Forms/FormAddingRouteSheet.Designer.cs
generated
Normal file
100
TransportEnterprise/TransportEnterprise/Forms/FormAddingRouteSheet.Designer.cs
generated
Normal file
@ -0,0 +1,100 @@
|
||||
namespace TransportEnterprise.Forms
|
||||
{
|
||||
partial class FormAddingRouteSheet
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormAddingRouteSheet));
|
||||
dataGridView = new DataGridView();
|
||||
panel1 = new Panel();
|
||||
buttonAdd = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
panel1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.AllowUserToResizeColumns = false;
|
||||
dataGridView.AllowUserToResizeRows = false;
|
||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Dock = DockStyle.Left;
|
||||
dataGridView.Location = new Point(0, 0);
|
||||
dataGridView.MultiSelect = false;
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.ReadOnly = true;
|
||||
dataGridView.RowHeadersVisible = false;
|
||||
dataGridView.RowHeadersWidth = 62;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(1113, 832);
|
||||
dataGridView.TabIndex = 3;
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Controls.Add(buttonAdd);
|
||||
panel1.Dock = DockStyle.Right;
|
||||
panel1.Location = new Point(1119, 0);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(194, 832);
|
||||
panel1.TabIndex = 2;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.BackgroundImage = (Image)resources.GetObject("buttonAdd.BackgroundImage");
|
||||
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonAdd.Location = new Point(28, 47);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(127, 108);
|
||||
buttonAdd.TabIndex = 0;
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// FormAddingRouteSheet
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1313, 832);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(panel1);
|
||||
Name = "FormAddingRouteSheet";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Добавление маршрутного листа";
|
||||
Load += FormAddingRouteSheet_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
panel1.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Panel panel1;
|
||||
private Button buttonAdd;
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.ConstrainedExecution;
|
||||
using TransportEnterprise.Entities;
|
||||
using TransportEnterprise.Entities.Repositories;
|
||||
using Unity;
|
||||
|
||||
namespace TransportEnterprise.Forms;
|
||||
|
||||
public partial class FormAddingRouteSheet : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
private readonly IRouteSheetRepository _routeSheetRepository;
|
||||
public FormAddingRouteSheet(IUnityContainer container, IRouteSheetRepository routeSheetRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
_routeSheetRepository = routeSheetRepository ?? throw new ArgumentNullException(nameof(routeSheetRepository));
|
||||
}
|
||||
private void FormAddingRouteSheet_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<FormRouteSheet>().ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при добавлении",MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void LoadList() {
|
||||
var data = _routeSheetRepository.ReadRouteSheets();
|
||||
var data1 = _routeSheetRepository.ReadRouteSheets_Employee();
|
||||
var filteredData = data.Select(rs => new
|
||||
{
|
||||
|
||||
rs.Id,
|
||||
rs.BusId,
|
||||
rs.RouteId,
|
||||
|
||||
|
||||
}).ToList();
|
||||
|
||||
dataGridView.DataSource = filteredData;
|
||||
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
212
TransportEnterprise/TransportEnterprise/Forms/FormBus.Designer.cs
generated
Normal file
212
TransportEnterprise/TransportEnterprise/Forms/FormBus.Designer.cs
generated
Normal file
@ -0,0 +1,212 @@
|
||||
namespace TransportEnterprise.Forms
|
||||
{
|
||||
partial class FormBus
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
labelModel = new Label();
|
||||
labelBrand = new Label();
|
||||
labelCapacity = new Label();
|
||||
labelLicensePlate = new Label();
|
||||
labelYear = new Label();
|
||||
labelTechnicalCondition = new Label();
|
||||
textBoxBrand = new TextBox();
|
||||
textBoxModel = new TextBox();
|
||||
numericUpDownCapacity = new NumericUpDown();
|
||||
textBoxLicensePlate = new TextBox();
|
||||
numericUpDownYear = new NumericUpDown();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
comboBoxTechnicalCondition = new ComboBox();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownCapacity).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownYear).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelModel
|
||||
//
|
||||
labelModel.AutoSize = true;
|
||||
labelModel.Location = new Point(46, 82);
|
||||
labelModel.Name = "labelModel";
|
||||
labelModel.Size = new Size(76, 25);
|
||||
labelModel.TabIndex = 0;
|
||||
labelModel.Text = "Модель";
|
||||
//
|
||||
// labelBrand
|
||||
//
|
||||
labelBrand.AutoSize = true;
|
||||
labelBrand.Location = new Point(46, 38);
|
||||
labelBrand.Name = "labelBrand";
|
||||
labelBrand.Size = new Size(62, 25);
|
||||
labelBrand.TabIndex = 2;
|
||||
labelBrand.Text = "Бренд";
|
||||
//
|
||||
// labelCapacity
|
||||
//
|
||||
labelCapacity.AutoSize = true;
|
||||
labelCapacity.Location = new Point(46, 137);
|
||||
labelCapacity.Name = "labelCapacity";
|
||||
labelCapacity.Size = new Size(117, 25);
|
||||
labelCapacity.TabIndex = 4;
|
||||
labelCapacity.Text = "Вместимость";
|
||||
//
|
||||
// labelLicensePlate
|
||||
//
|
||||
labelLicensePlate.AutoSize = true;
|
||||
labelLicensePlate.Location = new Point(46, 190);
|
||||
labelLicensePlate.Name = "labelLicensePlate";
|
||||
labelLicensePlate.Size = new Size(141, 25);
|
||||
labelLicensePlate.TabIndex = 6;
|
||||
labelLicensePlate.Text = "Номерной знак";
|
||||
//
|
||||
// labelYear
|
||||
//
|
||||
labelYear.AutoSize = true;
|
||||
labelYear.Location = new Point(46, 246);
|
||||
labelYear.Name = "labelYear";
|
||||
labelYear.Size = new Size(114, 25);
|
||||
labelYear.TabIndex = 8;
|
||||
labelYear.Text = "Год выпуска";
|
||||
//
|
||||
// labelTechnicalCondition
|
||||
//
|
||||
labelTechnicalCondition.AutoSize = true;
|
||||
labelTechnicalCondition.Location = new Point(46, 302);
|
||||
labelTechnicalCondition.Name = "labelTechnicalCondition";
|
||||
labelTechnicalCondition.Size = new Size(202, 25);
|
||||
labelTechnicalCondition.TabIndex = 10;
|
||||
labelTechnicalCondition.Text = "Техническое состояние";
|
||||
//
|
||||
// textBoxBrand
|
||||
//
|
||||
textBoxBrand.Location = new Point(291, 38);
|
||||
textBoxBrand.Name = "textBoxBrand";
|
||||
textBoxBrand.Size = new Size(180, 31);
|
||||
textBoxBrand.TabIndex = 11;
|
||||
//
|
||||
// textBoxModel
|
||||
//
|
||||
textBoxModel.Location = new Point(291, 82);
|
||||
textBoxModel.Name = "textBoxModel";
|
||||
textBoxModel.Size = new Size(180, 31);
|
||||
textBoxModel.TabIndex = 12;
|
||||
//
|
||||
// numericUpDownCapacity
|
||||
//
|
||||
numericUpDownCapacity.Location = new Point(291, 131);
|
||||
numericUpDownCapacity.Name = "numericUpDownCapacity";
|
||||
numericUpDownCapacity.Size = new Size(180, 31);
|
||||
numericUpDownCapacity.TabIndex = 13;
|
||||
//
|
||||
// textBoxLicensePlate
|
||||
//
|
||||
textBoxLicensePlate.Location = new Point(291, 187);
|
||||
textBoxLicensePlate.Name = "textBoxLicensePlate";
|
||||
textBoxLicensePlate.Size = new Size(180, 31);
|
||||
textBoxLicensePlate.TabIndex = 14;
|
||||
//
|
||||
// numericUpDownYear
|
||||
//
|
||||
numericUpDownYear.Location = new Point(291, 246);
|
||||
numericUpDownYear.Name = "numericUpDownYear";
|
||||
numericUpDownYear.Size = new Size(180, 31);
|
||||
numericUpDownYear.TabIndex = 15;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(46, 447);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(112, 34);
|
||||
buttonSave.TabIndex = 17;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(359, 447);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(112, 34);
|
||||
buttonCancel.TabIndex = 18;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// comboBoxTechnicalCondition
|
||||
//
|
||||
comboBoxTechnicalCondition.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxTechnicalCondition.FormattingEnabled = true;
|
||||
comboBoxTechnicalCondition.Location = new Point(289, 302);
|
||||
comboBoxTechnicalCondition.Name = "comboBoxTechnicalCondition";
|
||||
comboBoxTechnicalCondition.Size = new Size(182, 33);
|
||||
comboBoxTechnicalCondition.TabIndex = 19;
|
||||
//
|
||||
// FormBus
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(629, 617);
|
||||
Controls.Add(comboBoxTechnicalCondition);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(numericUpDownYear);
|
||||
Controls.Add(textBoxLicensePlate);
|
||||
Controls.Add(numericUpDownCapacity);
|
||||
Controls.Add(textBoxModel);
|
||||
Controls.Add(textBoxBrand);
|
||||
Controls.Add(labelTechnicalCondition);
|
||||
Controls.Add(labelYear);
|
||||
Controls.Add(labelLicensePlate);
|
||||
Controls.Add(labelCapacity);
|
||||
Controls.Add(labelBrand);
|
||||
Controls.Add(labelModel);
|
||||
Name = "FormBus";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Автобус";
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownCapacity).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownYear).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelModel;
|
||||
private Label labelBrand;
|
||||
private Label labelCapacity;
|
||||
private Label labelLicensePlate;
|
||||
private Label labelYear;
|
||||
private Label labelTechnicalCondition;
|
||||
private TextBox textBoxBrand;
|
||||
private TextBox textBoxModel;
|
||||
private NumericUpDown numericUpDownCapacity;
|
||||
private TextBox textBoxLicensePlate;
|
||||
private NumericUpDown numericUpDownYear;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private ComboBox comboBoxTechnicalCondition;
|
||||
}
|
||||
}
|
82
TransportEnterprise/TransportEnterprise/Forms/FormBus.cs
Normal file
82
TransportEnterprise/TransportEnterprise/Forms/FormBus.cs
Normal file
@ -0,0 +1,82 @@
|
||||
using TransportEnterprise.Entities;
|
||||
using TransportEnterprise.Entities.Enums;
|
||||
using TransportEnterprise.Entities.Repositories;
|
||||
|
||||
namespace TransportEnterprise.Forms
|
||||
{
|
||||
public partial class FormBus : Form
|
||||
{
|
||||
private readonly IBusRepository _busRepository;
|
||||
private int? _busId;
|
||||
|
||||
public int Id
|
||||
{
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
var bus = _busRepository.ReadBusById(value);
|
||||
if (bus == null)
|
||||
{
|
||||
throw new InvalidDataException(nameof(bus));
|
||||
}
|
||||
|
||||
textBoxBrand.Text = bus.Brand;
|
||||
textBoxModel.Text = bus.Model;
|
||||
numericUpDownCapacity.Value = bus.Capacity;
|
||||
numericUpDownYear.Value = bus.Year;
|
||||
textBoxLicensePlate.Text= bus.LicensePlate;
|
||||
comboBoxTechnicalCondition.SelectedItem= bus.TechnicalCondition;
|
||||
|
||||
_busId = value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
public FormBus(IBusRepository busRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_busRepository = busRepository ?? throw new ArgumentNullException(nameof(busRepository));
|
||||
comboBoxTechnicalCondition.DataSource = Enum.GetValues(typeof(TechnicalCondition)).Cast<TechnicalCondition>().Where(p => p != TechnicalCondition.None).ToArray();
|
||||
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if(string.IsNullOrWhiteSpace(textBoxModel.Text) || string.IsNullOrWhiteSpace(textBoxLicensePlate.Text) || comboBoxTechnicalCondition.SelectedIndex<0)
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
|
||||
if (_busId.HasValue)
|
||||
{
|
||||
_busRepository.UpdateBus(CreateBus(_busId.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
_busRepository.CreateBus(CreateBus(0));
|
||||
}
|
||||
Close();
|
||||
}
|
||||
catch(Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
private Bus CreateBus(int id) => Bus.CreateBus(id,
|
||||
textBoxModel.Text,
|
||||
Convert.ToInt32(numericUpDownCapacity.Value),
|
||||
textBoxLicensePlate.Text, textBoxBrand.Text,
|
||||
Convert.ToInt32(numericUpDownYear.Value),
|
||||
(TechnicalCondition)comboBoxTechnicalCondition.SelectedItem!);
|
||||
}
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
<!--
|
||||
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
|
||||
|
||||
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>
|
||||
@ -26,36 +26,36 @@
|
||||
<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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
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
|
||||
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
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
128
TransportEnterprise/TransportEnterprise/Forms/FormBuses.Designer.cs
generated
Normal file
128
TransportEnterprise/TransportEnterprise/Forms/FormBuses.Designer.cs
generated
Normal file
@ -0,0 +1,128 @@
|
||||
namespace TransportEnterprise.Forms
|
||||
{
|
||||
partial class FormBuses
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormBuses));
|
||||
panel1 = new Panel();
|
||||
buttonUpd = new Button();
|
||||
buttonDel = new Button();
|
||||
buttonAdd = new Button();
|
||||
dataGridView = new DataGridView();
|
||||
panel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Controls.Add(buttonUpd);
|
||||
panel1.Controls.Add(buttonDel);
|
||||
panel1.Controls.Add(buttonAdd);
|
||||
panel1.Dock = DockStyle.Right;
|
||||
panel1.Location = new Point(978, 0);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(300, 894);
|
||||
panel1.TabIndex = 0;
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
buttonUpd.BackgroundImage = (Image)resources.GetObject("buttonUpd.BackgroundImage");
|
||||
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonUpd.Location = new Point(89, 325);
|
||||
buttonUpd.Name = "buttonUpd";
|
||||
buttonUpd.Size = new Size(127, 108);
|
||||
buttonUpd.TabIndex = 2;
|
||||
buttonUpd.UseVisualStyleBackColor = true;
|
||||
buttonUpd.Click += buttonUpd_Click;
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
buttonDel.BackgroundImage = (Image)resources.GetObject("buttonDel.BackgroundImage");
|
||||
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonDel.Location = new Point(89, 184);
|
||||
buttonDel.Name = "buttonDel";
|
||||
buttonDel.Size = new Size(127, 108);
|
||||
buttonDel.TabIndex = 1;
|
||||
buttonDel.UseVisualStyleBackColor = true;
|
||||
buttonDel.Click += buttonDel_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.BackgroundImage = (Image)resources.GetObject("buttonAdd.BackgroundImage");
|
||||
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonAdd.Location = new Point(89, 47);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(127, 108);
|
||||
buttonAdd.TabIndex = 0;
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.AllowUserToResizeColumns = false;
|
||||
dataGridView.AllowUserToResizeRows = false;
|
||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
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 = 62;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(978, 894);
|
||||
dataGridView.TabIndex = 1;
|
||||
//
|
||||
// FormBuses
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1278, 894);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(panel1);
|
||||
Name = "FormBuses";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Автобусы";
|
||||
Load += FormBuses_Load;
|
||||
panel1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel panel1;
|
||||
private Button buttonUpd;
|
||||
private Button buttonDel;
|
||||
private Button buttonAdd;
|
||||
private DataGridView dataGridView;
|
||||
}
|
||||
}
|
109
TransportEnterprise/TransportEnterprise/Forms/FormBuses.cs
Normal file
109
TransportEnterprise/TransportEnterprise/Forms/FormBuses.cs
Normal file
@ -0,0 +1,109 @@
|
||||
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 TransportEnterprise.Entities.Repositories;
|
||||
using Unity;
|
||||
|
||||
namespace TransportEnterprise.Forms
|
||||
{
|
||||
public partial class FormBuses : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
private readonly IBusRepository _busRepository;
|
||||
public FormBuses(IUnityContainer container, IBusRepository busRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
_busRepository = busRepository ?? throw new ArgumentNullException(nameof(busRepository));
|
||||
|
||||
}
|
||||
private void FormBuses_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<FormBus>().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
|
||||
{
|
||||
_busRepository.DeleteBus(findId);
|
||||
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<FormBus>();
|
||||
form.Id = findId;
|
||||
form.ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при изменении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void LoadList() => dataGridView.DataSource = _busRepository.ReadBuses();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
2821
TransportEnterprise/TransportEnterprise/Forms/FormBuses.resx
Normal file
2821
TransportEnterprise/TransportEnterprise/Forms/FormBuses.resx
Normal file
File diff suppressed because it is too large
Load Diff
99
TransportEnterprise/TransportEnterprise/Forms/FormDirectoryReport.Designer.cs
generated
Normal file
99
TransportEnterprise/TransportEnterprise/Forms/FormDirectoryReport.Designer.cs
generated
Normal file
@ -0,0 +1,99 @@
|
||||
namespace TransportEnterprise.Forms
|
||||
{
|
||||
partial class FormDirectoryReport
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
checkBoxBuses = new CheckBox();
|
||||
checkBoxEmployees = new CheckBox();
|
||||
checkBoxRoutes = new CheckBox();
|
||||
buttonBuild = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// checkBoxBuses
|
||||
//
|
||||
checkBoxBuses.AutoSize = true;
|
||||
checkBoxBuses.Location = new Point(54, 92);
|
||||
checkBoxBuses.Name = "checkBoxBuses";
|
||||
checkBoxBuses.Size = new Size(118, 29);
|
||||
checkBoxBuses.TabIndex = 0;
|
||||
checkBoxBuses.Text = "Автобусы";
|
||||
checkBoxBuses.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxEmployees
|
||||
//
|
||||
checkBoxEmployees.AutoSize = true;
|
||||
checkBoxEmployees.Location = new Point(54, 177);
|
||||
checkBoxEmployees.Name = "checkBoxEmployees";
|
||||
checkBoxEmployees.Size = new Size(124, 29);
|
||||
checkBoxEmployees.TabIndex = 1;
|
||||
checkBoxEmployees.Text = "Работники";
|
||||
checkBoxEmployees.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxRoutes
|
||||
//
|
||||
checkBoxRoutes.AutoSize = true;
|
||||
checkBoxRoutes.Location = new Point(54, 265);
|
||||
checkBoxRoutes.Name = "checkBoxRoutes";
|
||||
checkBoxRoutes.Size = new Size(128, 29);
|
||||
checkBoxRoutes.TabIndex = 2;
|
||||
checkBoxRoutes.Text = "Маршруты";
|
||||
checkBoxRoutes.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonBuild
|
||||
//
|
||||
buttonBuild.Location = new Point(302, 173);
|
||||
buttonBuild.Name = "buttonBuild";
|
||||
buttonBuild.Size = new Size(189, 34);
|
||||
buttonBuild.TabIndex = 3;
|
||||
buttonBuild.Text = "Сформировать";
|
||||
buttonBuild.UseVisualStyleBackColor = true;
|
||||
buttonBuild.Click += buttonBuild_Click;
|
||||
//
|
||||
// FormDirectoryReport
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(522, 393);
|
||||
Controls.Add(buttonBuild);
|
||||
Controls.Add(checkBoxRoutes);
|
||||
Controls.Add(checkBoxEmployees);
|
||||
Controls.Add(checkBoxBuses);
|
||||
Name = "FormDirectoryReport";
|
||||
Text = "Выгрузка справочников";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private CheckBox checkBoxBuses;
|
||||
private CheckBox checkBoxEmployees;
|
||||
private CheckBox checkBoxRoutes;
|
||||
private Button buttonBuild;
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
using TransportEnterprise.Reports;
|
||||
using Unity;
|
||||
|
||||
namespace TransportEnterprise.Forms;
|
||||
public partial class FormDirectoryReport : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
public FormDirectoryReport(IUnityContainer container)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ??
|
||||
throw new ArgumentNullException(nameof(container));
|
||||
}
|
||||
private void buttonBuild_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!checkBoxBuses.Checked && !checkBoxEmployees.Checked && !checkBoxRoutes.Checked)
|
||||
{
|
||||
throw new Exception("Не выбран ни один справочник для выгрузки");
|
||||
}
|
||||
var sfd = new SaveFileDialog()
|
||||
{
|
||||
Filter = "Docx Files | *.docx"
|
||||
};
|
||||
if (sfd.ShowDialog() != DialogResult.OK)
|
||||
{
|
||||
throw new Exception("Не выбран файла для отчета");
|
||||
}
|
||||
if
|
||||
(_container.Resolve<DocReport>().CreateDoc(sfd.FileName, checkBoxBuses.Checked, checkBoxEmployees.Checked, checkBoxRoutes.Checked))
|
||||
{
|
||||
MessageBox.Show("Документ сформирован", "Формирование документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах", "Формирование документа", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при создании отчета", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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>
|
164
TransportEnterprise/TransportEnterprise/Forms/FormEmployee.Designer.cs
generated
Normal file
164
TransportEnterprise/TransportEnterprise/Forms/FormEmployee.Designer.cs
generated
Normal file
@ -0,0 +1,164 @@
|
||||
namespace TransportEnterprise.Forms
|
||||
{
|
||||
partial class FormEmployee
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
textBoxPhoneNumber = new TextBox();
|
||||
numericUpDownNumber = new NumericUpDown();
|
||||
textBoxName = new TextBox();
|
||||
labelPhoneNumber = new Label();
|
||||
labelPositionOfEmployee = new Label();
|
||||
labelNumber = new Label();
|
||||
labelName = new Label();
|
||||
comboBoxPositionOfEmployee = new ComboBox();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownNumber).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(452, 350);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(180, 46);
|
||||
buttonCancel.TabIndex = 19;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(169, 341);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(178, 46);
|
||||
buttonSave.TabIndex = 18;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// textBoxPhoneNumber
|
||||
//
|
||||
textBoxPhoneNumber.Location = new Point(452, 245);
|
||||
textBoxPhoneNumber.Name = "textBoxPhoneNumber";
|
||||
textBoxPhoneNumber.Size = new Size(180, 31);
|
||||
textBoxPhoneNumber.TabIndex = 17;
|
||||
//
|
||||
// numericUpDownNumber
|
||||
//
|
||||
numericUpDownNumber.Location = new Point(452, 114);
|
||||
numericUpDownNumber.Name = "numericUpDownNumber";
|
||||
numericUpDownNumber.Size = new Size(180, 31);
|
||||
numericUpDownNumber.TabIndex = 15;
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(452, 55);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(180, 31);
|
||||
textBoxName.TabIndex = 14;
|
||||
//
|
||||
// labelPhoneNumber
|
||||
//
|
||||
labelPhoneNumber.AutoSize = true;
|
||||
labelPhoneNumber.Location = new Point(169, 245);
|
||||
labelPhoneNumber.Name = "labelPhoneNumber";
|
||||
labelPhoneNumber.Size = new Size(150, 25);
|
||||
labelPhoneNumber.TabIndex = 13;
|
||||
labelPhoneNumber.Text = "Номер телефона";
|
||||
//
|
||||
// labelPositionOfEmployee
|
||||
//
|
||||
labelPositionOfEmployee.AutoSize = true;
|
||||
labelPositionOfEmployee.Location = new Point(169, 181);
|
||||
labelPositionOfEmployee.Name = "labelPositionOfEmployee";
|
||||
labelPositionOfEmployee.Size = new Size(102, 25);
|
||||
labelPositionOfEmployee.TabIndex = 12;
|
||||
labelPositionOfEmployee.Text = "Должность";
|
||||
//
|
||||
// labelNumber
|
||||
//
|
||||
labelNumber.AutoSize = true;
|
||||
labelNumber.Location = new Point(169, 116);
|
||||
labelNumber.Name = "labelNumber";
|
||||
labelNumber.Size = new Size(159, 25);
|
||||
labelNumber.TabIndex = 11;
|
||||
labelNumber.Text = "Табельный номер";
|
||||
//
|
||||
// labelName
|
||||
//
|
||||
labelName.AutoSize = true;
|
||||
labelName.Location = new Point(169, 55);
|
||||
labelName.Name = "labelName";
|
||||
labelName.Size = new Size(52, 25);
|
||||
labelName.TabIndex = 10;
|
||||
labelName.Text = "ФИО";
|
||||
//
|
||||
// comboBoxPositionOfEmployee
|
||||
//
|
||||
comboBoxPositionOfEmployee.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxPositionOfEmployee.FormattingEnabled = true;
|
||||
comboBoxPositionOfEmployee.Location = new Point(452, 178);
|
||||
comboBoxPositionOfEmployee.Name = "comboBoxPositionOfEmployee";
|
||||
comboBoxPositionOfEmployee.Size = new Size(182, 33);
|
||||
comboBoxPositionOfEmployee.TabIndex = 20;
|
||||
//
|
||||
// FormEmployee
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(comboBoxPositionOfEmployee);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(textBoxPhoneNumber);
|
||||
Controls.Add(numericUpDownNumber);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(labelPhoneNumber);
|
||||
Controls.Add(labelPositionOfEmployee);
|
||||
Controls.Add(labelNumber);
|
||||
Controls.Add(labelName);
|
||||
Name = "FormEmployee";
|
||||
Text = "FormEmployee";
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownNumber).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
private TextBox textBoxPhoneNumber;
|
||||
private NumericUpDown numericUpDownNumber;
|
||||
private TextBox textBoxName;
|
||||
private Label labelPhoneNumber;
|
||||
private Label labelPositionOfEmployee;
|
||||
private Label labelNumber;
|
||||
private Label labelName;
|
||||
private ComboBox comboBoxPositionOfEmployee;
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
|
||||
using TransportEnterprise.Entities.Repositories;
|
||||
using TransportEnterprise.Entities;
|
||||
using TransportEnterprise.Entities.Enums;
|
||||
|
||||
namespace TransportEnterprise.Forms;
|
||||
|
||||
public partial class FormEmployee : Form
|
||||
{
|
||||
private readonly IEmployeeRepository _employeeRepository;
|
||||
private int? _employeeId;
|
||||
public int Id
|
||||
{
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
var employee =
|
||||
_employeeRepository.ReadEmployeeById(value);
|
||||
if (employee == null)
|
||||
{
|
||||
throw new
|
||||
InvalidDataException(nameof(employee));
|
||||
}
|
||||
textBoxName.Text = employee.Name;
|
||||
numericUpDownNumber.Value = employee.Number;
|
||||
comboBoxPositionOfEmployee.SelectedItem = employee.PositionOfEmployee;
|
||||
textBoxPhoneNumber.Text = employee.PhoneNumber;
|
||||
_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));
|
||||
comboBoxPositionOfEmployee.DataSource = Enum.GetValues(typeof(PositionOfEmployee)).Cast<PositionOfEmployee>().Where(p => p != PositionOfEmployee.None).ToArray();
|
||||
}
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textBoxName.Text) || comboBoxPositionOfEmployee.SelectedIndex < 0)
|
||||
{
|
||||
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 bttonCancel_Click(object sender, EventArgs e) => Close();
|
||||
private Employee CreateEmployee(int id) => Employee.CreateEmployee(id,
|
||||
textBoxName.Text,
|
||||
Convert.ToInt32(numericUpDownNumber.Value),
|
||||
(PositionOfEmployee)comboBoxPositionOfEmployee.SelectedItem!,
|
||||
textBoxPhoneNumber.Text);
|
||||
}
|
120
TransportEnterprise/TransportEnterprise/Forms/FormEmployee.resx
Normal file
120
TransportEnterprise/TransportEnterprise/Forms/FormEmployee.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>
|
128
TransportEnterprise/TransportEnterprise/Forms/FormEmployees.Designer.cs
generated
Normal file
128
TransportEnterprise/TransportEnterprise/Forms/FormEmployees.Designer.cs
generated
Normal file
@ -0,0 +1,128 @@
|
||||
namespace TransportEnterprise.Forms
|
||||
{
|
||||
partial class FormEmployees
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormEmployees));
|
||||
dataGridView = new DataGridView();
|
||||
panel1 = new Panel();
|
||||
buttonUpd = new Button();
|
||||
buttonDel = new Button();
|
||||
buttonAdd = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
panel1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.AllowUserToResizeColumns = false;
|
||||
dataGridView.AllowUserToResizeRows = false;
|
||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
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 = 62;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(978, 894);
|
||||
dataGridView.TabIndex = 3;
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Controls.Add(buttonUpd);
|
||||
panel1.Controls.Add(buttonDel);
|
||||
panel1.Controls.Add(buttonAdd);
|
||||
panel1.Dock = DockStyle.Right;
|
||||
panel1.Location = new Point(978, 0);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(300, 894);
|
||||
panel1.TabIndex = 2;
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
buttonUpd.BackgroundImage = (Image)resources.GetObject("buttonUpd.BackgroundImage");
|
||||
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonUpd.Location = new Point(89, 325);
|
||||
buttonUpd.Name = "buttonUpd";
|
||||
buttonUpd.Size = new Size(127, 108);
|
||||
buttonUpd.TabIndex = 2;
|
||||
buttonUpd.UseVisualStyleBackColor = true;
|
||||
buttonUpd.Click += buttonUpd_Click;
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
buttonDel.BackgroundImage = (Image)resources.GetObject("buttonDel.BackgroundImage");
|
||||
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonDel.Location = new Point(89, 184);
|
||||
buttonDel.Name = "buttonDel";
|
||||
buttonDel.Size = new Size(127, 108);
|
||||
buttonDel.TabIndex = 1;
|
||||
buttonDel.UseVisualStyleBackColor = true;
|
||||
buttonDel.Click += buttonDel_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.BackgroundImage = (Image)resources.GetObject("buttonAdd.BackgroundImage");
|
||||
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonAdd.Location = new Point(89, 47);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(127, 108);
|
||||
buttonAdd.TabIndex = 0;
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// FormEmployees
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1278, 894);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(panel1);
|
||||
Name = "FormEmployees";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Работники";
|
||||
Load += FormEmployees_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
panel1.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Panel panel1;
|
||||
private Button buttonUpd;
|
||||
private Button buttonDel;
|
||||
private Button buttonAdd;
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
using TransportEnterprise.Entities.Repositories;
|
||||
using Unity;
|
||||
|
||||
namespace TransportEnterprise.Forms;
|
||||
|
||||
public partial class FormEmployees : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
private readonly IEmployeeRepository _employeeRepository;
|
||||
public FormEmployees(IUnityContainer container, IEmployeeRepository
|
||||
employeeRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
_employeeRepository = employeeRepository ?? throw new(nameof(employeeRepository));
|
||||
}
|
||||
private void FormEmployees_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<FormEmployee>().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<FormEmployee>();
|
||||
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
|
||||
{
|
||||
_employeeRepository.DeleteEmployee(findId);
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void LoadList() => dataGridView.DataSource = _employeeRepository.ReadEmployees();
|
||||
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;
|
||||
}
|
||||
}
|
2821
TransportEnterprise/TransportEnterprise/Forms/FormEmployees.resx
Normal file
2821
TransportEnterprise/TransportEnterprise/Forms/FormEmployees.resx
Normal file
File diff suppressed because it is too large
Load Diff
166
TransportEnterprise/TransportEnterprise/Forms/FormRepairRequest.Designer.cs
generated
Normal file
166
TransportEnterprise/TransportEnterprise/Forms/FormRepairRequest.Designer.cs
generated
Normal file
@ -0,0 +1,166 @@
|
||||
namespace TransportEnterprise.Forms
|
||||
{
|
||||
partial class FormRepairRequest
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
comboBoxBus = new ComboBox();
|
||||
comboBoxEmployee = new ComboBox();
|
||||
dateTimePicker = new DateTimePicker();
|
||||
labelBus = new Label();
|
||||
labelEmployee = new Label();
|
||||
labelDate = new Label();
|
||||
label1 = new Label();
|
||||
checkedListBoxBreakDownType = new CheckedListBox();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(361, 432);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(181, 60);
|
||||
buttonCancel.TabIndex = 19;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(68, 432);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(181, 60);
|
||||
buttonSave.TabIndex = 18;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// comboBoxBus
|
||||
//
|
||||
comboBoxBus.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxBus.FormattingEnabled = true;
|
||||
comboBoxBus.Location = new Point(242, 35);
|
||||
comboBoxBus.Name = "comboBoxBus";
|
||||
comboBoxBus.Size = new Size(300, 33);
|
||||
comboBoxBus.TabIndex = 17;
|
||||
//
|
||||
// comboBoxEmployee
|
||||
//
|
||||
comboBoxEmployee.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxEmployee.FormattingEnabled = true;
|
||||
comboBoxEmployee.Location = new Point(242, 363);
|
||||
comboBoxEmployee.Name = "comboBoxEmployee";
|
||||
comboBoxEmployee.Size = new Size(300, 33);
|
||||
comboBoxEmployee.TabIndex = 15;
|
||||
//
|
||||
// dateTimePicker
|
||||
//
|
||||
dateTimePicker.Location = new Point(242, 276);
|
||||
dateTimePicker.Name = "dateTimePicker";
|
||||
dateTimePicker.Size = new Size(300, 31);
|
||||
dateTimePicker.TabIndex = 14;
|
||||
//
|
||||
// labelBus
|
||||
//
|
||||
labelBus.AutoSize = true;
|
||||
labelBus.Location = new Point(68, 43);
|
||||
labelBus.Name = "labelBus";
|
||||
labelBus.Size = new Size(79, 25);
|
||||
labelBus.TabIndex = 13;
|
||||
labelBus.Text = "Автобус";
|
||||
//
|
||||
// labelEmployee
|
||||
//
|
||||
labelEmployee.AutoSize = true;
|
||||
labelEmployee.Location = new Point(68, 371);
|
||||
labelEmployee.Name = "labelEmployee";
|
||||
labelEmployee.Size = new Size(98, 25);
|
||||
labelEmployee.TabIndex = 12;
|
||||
labelEmployee.Text = "Работники";
|
||||
//
|
||||
// labelDate
|
||||
//
|
||||
labelDate.AutoSize = true;
|
||||
labelDate.Location = new Point(68, 293);
|
||||
labelDate.Name = "labelDate";
|
||||
labelDate.Size = new Size(49, 25);
|
||||
labelDate.TabIndex = 10;
|
||||
labelDate.Text = "Дата";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(68, 114);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(119, 25);
|
||||
label1.TabIndex = 20;
|
||||
label1.Text = "Тип поломки";
|
||||
//
|
||||
// checkedListBoxBreakDownType
|
||||
//
|
||||
checkedListBoxBreakDownType.FormattingEnabled = true;
|
||||
checkedListBoxBreakDownType.Location = new Point(242, 114);
|
||||
checkedListBoxBreakDownType.Name = "checkedListBoxBreakDownType";
|
||||
checkedListBoxBreakDownType.Size = new Size(300, 144);
|
||||
checkedListBoxBreakDownType.TabIndex = 21;
|
||||
//
|
||||
// FormRepairRequest
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(685, 565);
|
||||
Controls.Add(checkedListBoxBreakDownType);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(comboBoxBus);
|
||||
Controls.Add(comboBoxEmployee);
|
||||
Controls.Add(dateTimePicker);
|
||||
Controls.Add(labelBus);
|
||||
Controls.Add(labelEmployee);
|
||||
Controls.Add(labelDate);
|
||||
Name = "FormRepairRequest";
|
||||
Text = "Заявка на ремонт";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
private ComboBox comboBoxBus;
|
||||
private ComboBox comboBoxEmployee;
|
||||
private DateTimePicker dateTimePicker;
|
||||
private Label labelBus;
|
||||
private Label labelEmployee;
|
||||
private Label labelDate;
|
||||
private Label label1;
|
||||
private CheckedListBox checkedListBoxBreakDownType;
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
using TransportEnterprise.Entities.Enums;
|
||||
using TransportEnterprise.Entities.Repositories;
|
||||
using TransportEnterprise.Entities;
|
||||
|
||||
namespace TransportEnterprise.Forms;
|
||||
|
||||
public partial class FormRepairRequest : Form
|
||||
{
|
||||
private readonly IRepairRequestRepository _repairRequestRepository;
|
||||
private int? _repairRequestId;
|
||||
|
||||
public FormRepairRequest(IRepairRequestRepository repairRequestRepository, IEmployeeRepository employeeRepository, IBusRepository busRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_repairRequestRepository = repairRequestRepository ?? throw new ArgumentNullException(nameof(repairRequestRepository));
|
||||
comboBoxBus.DataSource = busRepository.ReadBuses();
|
||||
comboBoxBus.DisplayMember = "LicensePlate";
|
||||
comboBoxBus.ValueMember = "Id";
|
||||
|
||||
comboBoxEmployee.DataSource = employeeRepository.ReadEmployees();
|
||||
comboBoxEmployee.DisplayMember = "Name";
|
||||
comboBoxEmployee.ValueMember = "Id";
|
||||
|
||||
foreach (var elem in Enum.GetValues(typeof(BreakDownType)))
|
||||
{
|
||||
if(!elem.Equals(BreakDownType.None)) checkedListBoxBreakDownType.Items.Add(elem);
|
||||
}
|
||||
}
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (comboBoxBus.SelectedIndex < 0 || comboBoxEmployee.SelectedIndex < 0 || checkedListBoxBreakDownType.CheckedItems.Count == 0)
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
|
||||
_repairRequestRepository.CreateRepairRequest(CreateRepairRequest(0));
|
||||
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void buttonCancel_Click(object sender, EventArgs e) => Close();
|
||||
private RepairRequest CreateRepairRequest(int id)
|
||||
{
|
||||
BreakDownType breakDownType = BreakDownType.None;
|
||||
foreach (var elem in checkedListBoxBreakDownType.CheckedItems)
|
||||
{
|
||||
breakDownType |= (BreakDownType)elem;
|
||||
}
|
||||
|
||||
return RepairRequest.CreateRepairRequest(id,
|
||||
(int)comboBoxBus.SelectedValue!,
|
||||
breakDownType,
|
||||
dateTimePicker.Value,
|
||||
(int)comboBoxEmployee.SelectedValue!);
|
||||
}
|
||||
|
||||
}
|
@ -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>
|
100
TransportEnterprise/TransportEnterprise/Forms/FormRepairRequests.Designer.cs
generated
Normal file
100
TransportEnterprise/TransportEnterprise/Forms/FormRepairRequests.Designer.cs
generated
Normal file
@ -0,0 +1,100 @@
|
||||
namespace TransportEnterprise.Forms
|
||||
{
|
||||
partial class FormRepairRequests
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormRepairRequests));
|
||||
dataGridView = new DataGridView();
|
||||
panel1 = new Panel();
|
||||
buttonAdd = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
panel1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.AllowUserToResizeColumns = false;
|
||||
dataGridView.AllowUserToResizeRows = false;
|
||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
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 = 62;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(1091, 894);
|
||||
dataGridView.TabIndex = 5;
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Controls.Add(buttonAdd);
|
||||
panel1.Dock = DockStyle.Right;
|
||||
panel1.Location = new Point(1091, 0);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(187, 894);
|
||||
panel1.TabIndex = 4;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.BackgroundImage = (Image)resources.GetObject("buttonAdd.BackgroundImage");
|
||||
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonAdd.Location = new Point(38, 50);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(127, 108);
|
||||
buttonAdd.TabIndex = 0;
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// FormRepairRequests
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1278, 894);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(panel1);
|
||||
Name = "FormRepairRequests";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Заявки на ремонт";
|
||||
Load += FormRepairRequests_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
panel1.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Panel panel1;
|
||||
private Button buttonAdd;
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
using TransportEnterprise.Entities.Repositories;
|
||||
using Unity;
|
||||
|
||||
namespace TransportEnterprise.Forms
|
||||
{
|
||||
public partial class FormRepairRequests: Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
private readonly IRepairRequestRepository _repairRequestRepository;
|
||||
public FormRepairRequests(IUnityContainer container, IRepairRequestRepository repairRequestRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
_repairRequestRepository = repairRequestRepository ?? throw new(nameof(repairRequestRepository));
|
||||
}
|
||||
private void FormRepairRequests_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<FormRepairRequest>().ShowDialog();
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при добавлении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadList() => dataGridView.DataSource = _repairRequestRepository.ReadRepairRequests();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
166
TransportEnterprise/TransportEnterprise/Forms/FormRoute.Designer.cs
generated
Normal file
166
TransportEnterprise/TransportEnterprise/Forms/FormRoute.Designer.cs
generated
Normal file
@ -0,0 +1,166 @@
|
||||
namespace TransportEnterprise.Forms
|
||||
{
|
||||
partial class FormRoute
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
labelName = new Label();
|
||||
labelNumber = new Label();
|
||||
labelInterval = new Label();
|
||||
labelSchedule = new Label();
|
||||
textBoxName = new TextBox();
|
||||
numericUpDownNumber = new NumericUpDown();
|
||||
numericUpDownInterval = new NumericUpDown();
|
||||
textBoxSchedule = new TextBox();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownNumber).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownInterval).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelName
|
||||
//
|
||||
labelName.AutoSize = true;
|
||||
labelName.Location = new Point(68, 70);
|
||||
labelName.Name = "labelName";
|
||||
labelName.Size = new Size(178, 25);
|
||||
labelName.TabIndex = 0;
|
||||
labelName.Text = "Название маршрута";
|
||||
//
|
||||
// labelNumber
|
||||
//
|
||||
labelNumber.AutoSize = true;
|
||||
labelNumber.Location = new Point(68, 131);
|
||||
labelNumber.Name = "labelNumber";
|
||||
labelNumber.Size = new Size(157, 25);
|
||||
labelNumber.TabIndex = 1;
|
||||
labelNumber.Text = "Номер маршрута";
|
||||
//
|
||||
// labelInterval
|
||||
//
|
||||
labelInterval.AutoSize = true;
|
||||
labelInterval.Location = new Point(68, 196);
|
||||
labelInterval.Name = "labelInterval";
|
||||
labelInterval.Size = new Size(90, 25);
|
||||
labelInterval.TabIndex = 2;
|
||||
labelInterval.Text = "Интервал";
|
||||
//
|
||||
// labelSchedule
|
||||
//
|
||||
labelSchedule.AutoSize = true;
|
||||
labelSchedule.Location = new Point(68, 260);
|
||||
labelSchedule.Name = "labelSchedule";
|
||||
labelSchedule.Size = new Size(133, 25);
|
||||
labelSchedule.TabIndex = 3;
|
||||
labelSchedule.Text = "Режим работы";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(351, 70);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(180, 31);
|
||||
textBoxName.TabIndex = 4;
|
||||
//
|
||||
// numericUpDownNumber
|
||||
//
|
||||
numericUpDownNumber.Location = new Point(351, 129);
|
||||
numericUpDownNumber.Name = "numericUpDownNumber";
|
||||
numericUpDownNumber.Size = new Size(180, 31);
|
||||
numericUpDownNumber.TabIndex = 5;
|
||||
//
|
||||
// numericUpDownInterval
|
||||
//
|
||||
numericUpDownInterval.Location = new Point(351, 196);
|
||||
numericUpDownInterval.Name = "numericUpDownInterval";
|
||||
numericUpDownInterval.Size = new Size(180, 31);
|
||||
numericUpDownInterval.TabIndex = 6;
|
||||
//
|
||||
// textBoxSchedule
|
||||
//
|
||||
textBoxSchedule.Location = new Point(351, 260);
|
||||
textBoxSchedule.Name = "textBoxSchedule";
|
||||
textBoxSchedule.Size = new Size(180, 31);
|
||||
textBoxSchedule.TabIndex = 7;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(68, 356);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(178, 46);
|
||||
buttonSave.TabIndex = 8;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(351, 365);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(180, 46);
|
||||
buttonCancel.TabIndex = 9;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// FormRoute
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(566, 445);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(textBoxSchedule);
|
||||
Controls.Add(numericUpDownInterval);
|
||||
Controls.Add(numericUpDownNumber);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(labelSchedule);
|
||||
Controls.Add(labelInterval);
|
||||
Controls.Add(labelNumber);
|
||||
Controls.Add(labelName);
|
||||
Name = "FormRoute";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Маршрут";
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownNumber).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)numericUpDownInterval).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelName;
|
||||
private Label labelNumber;
|
||||
private Label labelInterval;
|
||||
private Label labelSchedule;
|
||||
private TextBox textBoxName;
|
||||
private NumericUpDown numericUpDownNumber;
|
||||
private NumericUpDown numericUpDownInterval;
|
||||
private TextBox textBoxSchedule;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
75
TransportEnterprise/TransportEnterprise/Forms/FormRoute.cs
Normal file
75
TransportEnterprise/TransportEnterprise/Forms/FormRoute.cs
Normal file
@ -0,0 +1,75 @@
|
||||
using TransportEnterprise.Entities.Repositories;
|
||||
using TransportEnterprise.Entities;
|
||||
|
||||
namespace TransportEnterprise.Forms
|
||||
{
|
||||
public partial class FormRoute : Form
|
||||
{
|
||||
private readonly IRouteRepository _routeRepository;
|
||||
private int? _routeId;
|
||||
public int Id
|
||||
{
|
||||
set
|
||||
{
|
||||
try
|
||||
{
|
||||
var route = _routeRepository.ReadRouteById(value);
|
||||
if (route == null)
|
||||
{
|
||||
throw new
|
||||
InvalidDataException(nameof(route));
|
||||
}
|
||||
textBoxName.Text = route.Name;
|
||||
numericUpDownNumber.Value = route.Number;
|
||||
numericUpDownInterval.Value = route.Interval;
|
||||
textBoxSchedule.Text= route.Schedule;
|
||||
_routeId = value;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при получении данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public FormRoute(IRouteRepository routeRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_routeRepository = routeRepository ?? throw new ArgumentNullException(nameof(routeRepository));
|
||||
|
||||
}
|
||||
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textBoxName.Text) || numericUpDownNumber.Value == 0)
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
if (_routeId.HasValue)
|
||||
{
|
||||
_routeRepository.UpdateRoute(CreateRoute(_routeId.Value));
|
||||
}
|
||||
else
|
||||
{
|
||||
_routeRepository.CreateRoute(CreateRoute(0));
|
||||
}
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при сохранении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
}
|
||||
private void buttonCancel_Click(object sender, EventArgs e) => Close();
|
||||
private Route CreateRoute(int id) => Route.CreateRoute(id,
|
||||
textBoxName.Text,
|
||||
Convert.ToInt32(numericUpDownNumber.Value),
|
||||
Convert.ToInt32(numericUpDownInterval.Value),
|
||||
textBoxSchedule.Text);
|
||||
}
|
||||
}
|
||||
|
120
TransportEnterprise/TransportEnterprise/Forms/FormRoute.resx
Normal file
120
TransportEnterprise/TransportEnterprise/Forms/FormRoute.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>
|
191
TransportEnterprise/TransportEnterprise/Forms/FormRouteSheet.Designer.cs
generated
Normal file
191
TransportEnterprise/TransportEnterprise/Forms/FormRouteSheet.Designer.cs
generated
Normal file
@ -0,0 +1,191 @@
|
||||
namespace TransportEnterprise.Forms
|
||||
{
|
||||
partial class FormRouteSheet
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
labelDate = new Label();
|
||||
labelRoute = new Label();
|
||||
labelEmployee = new Label();
|
||||
labelBus = new Label();
|
||||
dateTimePicker = new DateTimePicker();
|
||||
comboBoxRoute = new ComboBox();
|
||||
comboBoxBus = new ComboBox();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
dataGridViewEmployees = new DataGridView();
|
||||
ColumnName = new DataGridViewComboBoxColumn();
|
||||
ColumnCount = new DataGridViewTextBoxColumn();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewEmployees).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelDate
|
||||
//
|
||||
labelDate.AutoSize = true;
|
||||
labelDate.Location = new Point(76, 53);
|
||||
labelDate.Name = "labelDate";
|
||||
labelDate.Size = new Size(49, 25);
|
||||
labelDate.TabIndex = 0;
|
||||
labelDate.Text = "Дата";
|
||||
//
|
||||
// labelRoute
|
||||
//
|
||||
labelRoute.AutoSize = true;
|
||||
labelRoute.Location = new Point(76, 103);
|
||||
labelRoute.Name = "labelRoute";
|
||||
labelRoute.Size = new Size(89, 25);
|
||||
labelRoute.TabIndex = 1;
|
||||
labelRoute.Text = "Маршрут";
|
||||
//
|
||||
// labelEmployee
|
||||
//
|
||||
labelEmployee.AutoSize = true;
|
||||
labelEmployee.Location = new Point(76, 150);
|
||||
labelEmployee.Name = "labelEmployee";
|
||||
labelEmployee.Size = new Size(98, 25);
|
||||
labelEmployee.TabIndex = 2;
|
||||
labelEmployee.Text = "Работники";
|
||||
//
|
||||
// labelBus
|
||||
//
|
||||
labelBus.AutoSize = true;
|
||||
labelBus.Location = new Point(65, 451);
|
||||
labelBus.Name = "labelBus";
|
||||
labelBus.Size = new Size(79, 25);
|
||||
labelBus.TabIndex = 3;
|
||||
labelBus.Text = "Автобус";
|
||||
//
|
||||
// dateTimePicker
|
||||
//
|
||||
dateTimePicker.Location = new Point(250, 47);
|
||||
dateTimePicker.Name = "dateTimePicker";
|
||||
dateTimePicker.Size = new Size(300, 31);
|
||||
dateTimePicker.TabIndex = 4;
|
||||
//
|
||||
// comboBoxRoute
|
||||
//
|
||||
comboBoxRoute.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxRoute.FormattingEnabled = true;
|
||||
comboBoxRoute.Location = new Point(250, 95);
|
||||
comboBoxRoute.Name = "comboBoxRoute";
|
||||
comboBoxRoute.Size = new Size(300, 33);
|
||||
comboBoxRoute.TabIndex = 5;
|
||||
//
|
||||
// comboBoxBus
|
||||
//
|
||||
comboBoxBus.FormattingEnabled = true;
|
||||
comboBoxBus.Location = new Point(239, 443);
|
||||
comboBoxBus.Name = "comboBoxBus";
|
||||
comboBoxBus.Size = new Size(300, 33);
|
||||
comboBoxBus.TabIndex = 7;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(65, 531);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(181, 60);
|
||||
buttonSave.TabIndex = 8;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(358, 531);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(181, 60);
|
||||
buttonCancel.TabIndex = 9;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// dataGridViewEmployees
|
||||
//
|
||||
dataGridViewEmployees.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridViewEmployees.Columns.AddRange(new DataGridViewColumn[] { ColumnName, ColumnCount });
|
||||
dataGridViewEmployees.Location = new Point(250, 150);
|
||||
dataGridViewEmployees.Name = "dataGridViewEmployees";
|
||||
dataGridViewEmployees.RowHeadersVisible = false;
|
||||
dataGridViewEmployees.RowHeadersWidth = 62;
|
||||
dataGridViewEmployees.Size = new Size(300, 225);
|
||||
dataGridViewEmployees.TabIndex = 10;
|
||||
//
|
||||
// ColumnName
|
||||
//
|
||||
ColumnName.HeaderText = "ФИО";
|
||||
ColumnName.MinimumWidth = 8;
|
||||
ColumnName.Name = "ColumnName";
|
||||
ColumnName.Resizable = DataGridViewTriState.True;
|
||||
ColumnName.SortMode = DataGridViewColumnSortMode.Automatic;
|
||||
ColumnName.Width = 150;
|
||||
//
|
||||
// ColumnCount
|
||||
//
|
||||
ColumnCount.HeaderText = "Количество рейсов";
|
||||
ColumnCount.MinimumWidth = 8;
|
||||
ColumnCount.Name = "ColumnCount";
|
||||
ColumnCount.Resizable = DataGridViewTriState.True;
|
||||
ColumnCount.Width = 150;
|
||||
//
|
||||
// FormRouteSheet
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(658, 722);
|
||||
Controls.Add(dataGridViewEmployees);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(comboBoxBus);
|
||||
Controls.Add(comboBoxRoute);
|
||||
Controls.Add(dateTimePicker);
|
||||
Controls.Add(labelBus);
|
||||
Controls.Add(labelEmployee);
|
||||
Controls.Add(labelRoute);
|
||||
Controls.Add(labelDate);
|
||||
Name = "FormRouteSheet";
|
||||
Text = "Маршрутный лист";
|
||||
((System.ComponentModel.ISupportInitialize)dataGridViewEmployees).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelDate;
|
||||
private Label labelRoute;
|
||||
private Label labelEmployee;
|
||||
private Label labelBus;
|
||||
private DateTimePicker dateTimePicker;
|
||||
private ComboBox comboBoxRoute;
|
||||
private ComboBox comboBoxBus;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private DataGridView dataGridViewEmployees;
|
||||
private DataGridViewComboBoxColumn ColumnName;
|
||||
private DataGridViewTextBoxColumn ColumnCount;
|
||||
}
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
using TransportEnterprise.Entities;
|
||||
using TransportEnterprise.Entities.Repositories;
|
||||
|
||||
namespace TransportEnterprise.Forms;
|
||||
|
||||
public partial class FormRouteSheet : Form
|
||||
{
|
||||
|
||||
private readonly IRouteSheetRepository _routeSheetRepository;
|
||||
public FormRouteSheet(IRouteSheetRepository routeSheetRepository, IEmployeeRepository employeeRepository, IBusRepository busRepository, IRouteRepository routeRepository) {
|
||||
|
||||
InitializeComponent();
|
||||
_routeSheetRepository = routeSheetRepository ?? throw new ArgumentNullException(nameof(routeSheetRepository));
|
||||
comboBoxRoute.DataSource = routeRepository.ReadRoutes();
|
||||
comboBoxRoute.DisplayMember = "Name";
|
||||
comboBoxRoute.ValueMember = "Id";
|
||||
|
||||
ColumnName.DataSource = employeeRepository.ReadEmployees();
|
||||
ColumnName.DisplayMember = "Name";
|
||||
ColumnName.ValueMember = "Id";
|
||||
|
||||
|
||||
comboBoxBus.DataSource = busRepository.ReadBuses();
|
||||
comboBoxBus.DisplayMember = "LicensePlate";
|
||||
comboBoxBus.ValueMember = "Id";
|
||||
}
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (dataGridViewEmployees.RowCount < 1)
|
||||
{
|
||||
throw new Exception("Имеются незаполненные поля");
|
||||
}
|
||||
|
||||
|
||||
_routeSheetRepository.CreateRouteSheet(RouteSheet.CreateRouteSheet(
|
||||
0,
|
||||
dateTimePicker.Value,
|
||||
(int)comboBoxBus.SelectedValue!,
|
||||
(int)comboBoxRoute.SelectedValue!,
|
||||
CreateListRouteSheetEmployeeFromDataGrid()));
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при сохранении",MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e) => Close();
|
||||
|
||||
private List<RouteSheet_Employee> CreateListRouteSheetEmployeeFromDataGrid()
|
||||
{
|
||||
var list = new List<RouteSheet_Employee>();
|
||||
foreach (DataGridViewRow row in dataGridViewEmployees.Rows)
|
||||
{
|
||||
if (row.Cells["ColumnName"].Value == null || row.Cells["ColumnCount"].Value == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
list.Add(RouteSheet_Employee.CreateOperation(0,
|
||||
Convert.ToInt32(row.Cells["ColumnName"].Value),
|
||||
Convert.ToInt32(row.Cells["ColumnCount"].Value)));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,126 @@
|
||||
<?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>
|
||||
<metadata name="ColumnName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
164
TransportEnterprise/TransportEnterprise/Forms/FormRouteSheetEmployeeReport.Designer.cs
generated
Normal file
164
TransportEnterprise/TransportEnterprise/Forms/FormRouteSheetEmployeeReport.Designer.cs
generated
Normal file
@ -0,0 +1,164 @@
|
||||
namespace TransportEnterprise.Forms
|
||||
{
|
||||
partial class FormRouteSheetEmployeeReport
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
labelSelectFile = new Label();
|
||||
labelEmployee = new Label();
|
||||
labelStartDate = new Label();
|
||||
labelEndDate = new Label();
|
||||
textBoxFilePath = new TextBox();
|
||||
buttonSelectFilePath = new Button();
|
||||
comboBoxEmployees = new ComboBox();
|
||||
dateTimePickerStartDate = new DateTimePicker();
|
||||
dateTimePickerEndDate = new DateTimePicker();
|
||||
buttonMakeReport = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelSelectFile
|
||||
//
|
||||
labelSelectFile.AutoSize = true;
|
||||
labelSelectFile.Location = new Point(70, 92);
|
||||
labelSelectFile.Name = "labelSelectFile";
|
||||
labelSelectFile.Size = new Size(130, 25);
|
||||
labelSelectFile.TabIndex = 0;
|
||||
labelSelectFile.Text = "Путь до файла";
|
||||
//
|
||||
// labelEmployee
|
||||
//
|
||||
labelEmployee.AutoSize = true;
|
||||
labelEmployee.Location = new Point(70, 158);
|
||||
labelEmployee.Name = "labelEmployee";
|
||||
labelEmployee.Size = new Size(88, 25);
|
||||
labelEmployee.TabIndex = 1;
|
||||
labelEmployee.Text = "Работник";
|
||||
//
|
||||
// labelStartDate
|
||||
//
|
||||
labelStartDate.AutoSize = true;
|
||||
labelStartDate.Location = new Point(70, 225);
|
||||
labelStartDate.Name = "labelStartDate";
|
||||
labelStartDate.Size = new Size(110, 25);
|
||||
labelStartDate.TabIndex = 2;
|
||||
labelStartDate.Text = "Дата начала";
|
||||
//
|
||||
// labelEndDate
|
||||
//
|
||||
labelEndDate.AutoSize = true;
|
||||
labelEndDate.Location = new Point(70, 293);
|
||||
labelEndDate.Name = "labelEndDate";
|
||||
labelEndDate.Size = new Size(104, 25);
|
||||
labelEndDate.TabIndex = 3;
|
||||
labelEndDate.Text = "Дата конца";
|
||||
//
|
||||
// textBoxFilePath
|
||||
//
|
||||
textBoxFilePath.Location = new Point(243, 92);
|
||||
textBoxFilePath.Name = "textBoxFilePath";
|
||||
textBoxFilePath.ReadOnly = true;
|
||||
textBoxFilePath.Size = new Size(150, 31);
|
||||
textBoxFilePath.TabIndex = 4;
|
||||
//
|
||||
// buttonSelectFilePath
|
||||
//
|
||||
buttonSelectFilePath.Location = new Point(427, 92);
|
||||
buttonSelectFilePath.Name = "buttonSelectFilePath";
|
||||
buttonSelectFilePath.Size = new Size(32, 34);
|
||||
buttonSelectFilePath.TabIndex = 5;
|
||||
buttonSelectFilePath.Text = "..";
|
||||
buttonSelectFilePath.UseVisualStyleBackColor = true;
|
||||
buttonSelectFilePath.Click += buttonSelectFilePath_Click;
|
||||
//
|
||||
// comboBoxEmployees
|
||||
//
|
||||
comboBoxEmployees.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
comboBoxEmployees.FormattingEnabled = true;
|
||||
comboBoxEmployees.Location = new Point(243, 155);
|
||||
comboBoxEmployees.Name = "comboBoxEmployees";
|
||||
comboBoxEmployees.Size = new Size(182, 33);
|
||||
comboBoxEmployees.TabIndex = 6;
|
||||
//
|
||||
// dateTimePickerStartDate
|
||||
//
|
||||
dateTimePickerStartDate.Location = new Point(243, 225);
|
||||
dateTimePickerStartDate.Name = "dateTimePickerStartDate";
|
||||
dateTimePickerStartDate.Size = new Size(300, 31);
|
||||
dateTimePickerStartDate.TabIndex = 7;
|
||||
//
|
||||
// dateTimePickerEndDate
|
||||
//
|
||||
dateTimePickerEndDate.Location = new Point(243, 293);
|
||||
dateTimePickerEndDate.Name = "dateTimePickerEndDate";
|
||||
dateTimePickerEndDate.Size = new Size(300, 31);
|
||||
dateTimePickerEndDate.TabIndex = 8;
|
||||
//
|
||||
// buttonMakeReport
|
||||
//
|
||||
buttonMakeReport.Location = new Point(193, 372);
|
||||
buttonMakeReport.Name = "buttonMakeReport";
|
||||
buttonMakeReport.Size = new Size(200, 34);
|
||||
buttonMakeReport.TabIndex = 9;
|
||||
buttonMakeReport.Text = "Сформировать отчёт";
|
||||
buttonMakeReport.UseVisualStyleBackColor = true;
|
||||
buttonMakeReport.Click += buttonMakeReport_Click;
|
||||
//
|
||||
// RouteSheetEmployeeReport
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(567, 442);
|
||||
Controls.Add(buttonMakeReport);
|
||||
Controls.Add(dateTimePickerEndDate);
|
||||
Controls.Add(dateTimePickerStartDate);
|
||||
Controls.Add(comboBoxEmployees);
|
||||
Controls.Add(buttonSelectFilePath);
|
||||
Controls.Add(textBoxFilePath);
|
||||
Controls.Add(labelEndDate);
|
||||
Controls.Add(labelStartDate);
|
||||
Controls.Add(labelEmployee);
|
||||
Controls.Add(labelSelectFile);
|
||||
Name = "RouteSheetEmployeeReport";
|
||||
Text = "RouteSheetEmployeeReport";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelSelectFile;
|
||||
private Label labelEmployee;
|
||||
private Label labelStartDate;
|
||||
private Label labelEndDate;
|
||||
private TextBox textBoxFilePath;
|
||||
private Button buttonSelectFilePath;
|
||||
private ComboBox comboBoxEmployees;
|
||||
private DateTimePicker dateTimePickerStartDate;
|
||||
private DateTimePicker dateTimePickerEndDate;
|
||||
private Button buttonMakeReport;
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
using System.ComponentModel;
|
||||
using TransportEnterprise.Entities.Repositories;
|
||||
using Unity;
|
||||
|
||||
namespace TransportEnterprise.Forms;
|
||||
|
||||
public partial class FormRouteSheetEmployeeReport : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
public FormRouteSheetEmployeeReport(IUnityContainer container, IEmployeeRepository employeeRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
comboBoxEmployees.DataSource = employeeRepository.ReadEmployees();
|
||||
comboBoxEmployees.DisplayMember = "Name";
|
||||
comboBoxEmployees.ValueMember = "Id";
|
||||
}
|
||||
|
||||
private void buttonMakeReport_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(textBoxFilePath.Text))
|
||||
{
|
||||
throw new Exception("Отсутствует имя файла для отчета");
|
||||
}
|
||||
if (comboBoxEmployees.SelectedIndex < 0)
|
||||
{
|
||||
throw new Exception("Не выбран корм");
|
||||
}
|
||||
if (dateTimePickerEndDate.Value <= dateTimePickerStartDate.Value)
|
||||
{
|
||||
throw new Exception("Дата начала должна быть раньше даты окончания");
|
||||
}
|
||||
if
|
||||
(_container.Resolve<TableReport>().CreateTable(textBoxFilePath.Text, (int)comboBoxEmployees.SelectedValue!, dateTimePickerStartDate.Value, dateTimePickerEndDate.Value))
|
||||
{
|
||||
MessageBox.Show("Документ сформирован",
|
||||
"Формирование документа",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах",
|
||||
"Формирование документа",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при создании очета",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void buttonSelectFilePath_Click(object sender, EventArgs e)
|
||||
{
|
||||
var sfd = new SaveFileDialog()
|
||||
{
|
||||
Filter = "Excel Files | *.xlsx"
|
||||
};
|
||||
if (sfd.ShowDialog() != DialogResult.OK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
textBoxFilePath.Text = sfd.FileName;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -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>
|
107
TransportEnterprise/TransportEnterprise/Forms/FormRouteSheetEmployeesDistributionReport.Designer.cs
generated
Normal file
107
TransportEnterprise/TransportEnterprise/Forms/FormRouteSheetEmployeesDistributionReport.Designer.cs
generated
Normal file
@ -0,0 +1,107 @@
|
||||
namespace TransportEnterprise.Forms
|
||||
{
|
||||
partial class FormRouteSheetEmployeesDistributionReport
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
buttonSelectFileName = new Button();
|
||||
labelFileName = new Label();
|
||||
labelDate = new Label();
|
||||
dateTimePicker = new DateTimePicker();
|
||||
buttonCreate = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// buttonSelectFileName
|
||||
//
|
||||
buttonSelectFileName.Location = new Point(58, 64);
|
||||
buttonSelectFileName.Name = "buttonSelectFileName";
|
||||
buttonSelectFileName.Size = new Size(112, 34);
|
||||
buttonSelectFileName.TabIndex = 0;
|
||||
buttonSelectFileName.Text = "Выбрать";
|
||||
buttonSelectFileName.UseVisualStyleBackColor = true;
|
||||
buttonSelectFileName.Click += buttonSelectFileName_Click;
|
||||
//
|
||||
// labelFileName
|
||||
//
|
||||
labelFileName.AutoSize = true;
|
||||
labelFileName.Location = new Point(287, 69);
|
||||
labelFileName.Name = "labelFileName";
|
||||
labelFileName.Size = new Size(53, 25);
|
||||
labelFileName.TabIndex = 1;
|
||||
labelFileName.Text = "Файл";
|
||||
//
|
||||
// labelDate
|
||||
//
|
||||
labelDate.AutoSize = true;
|
||||
labelDate.Location = new Point(58, 153);
|
||||
labelDate.Name = "labelDate";
|
||||
labelDate.Size = new Size(49, 25);
|
||||
labelDate.TabIndex = 2;
|
||||
labelDate.Text = "Дата";
|
||||
//
|
||||
// dateTimePicker
|
||||
//
|
||||
dateTimePicker.Location = new Point(175, 148);
|
||||
dateTimePicker.Name = "dateTimePicker";
|
||||
dateTimePicker.Size = new Size(300, 31);
|
||||
dateTimePicker.TabIndex = 3;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
buttonCreate.Location = new Point(184, 236);
|
||||
buttonCreate.Name = "buttonCreate";
|
||||
buttonCreate.Size = new Size(167, 34);
|
||||
buttonCreate.TabIndex = 4;
|
||||
buttonCreate.Text = "Сформировать";
|
||||
buttonCreate.UseVisualStyleBackColor = true;
|
||||
buttonCreate.Click += buttonCreate_Click;
|
||||
//
|
||||
// RouteSheetEmployeesDistributionReport
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(552, 336);
|
||||
Controls.Add(buttonCreate);
|
||||
Controls.Add(dateTimePicker);
|
||||
Controls.Add(labelDate);
|
||||
Controls.Add(labelFileName);
|
||||
Controls.Add(buttonSelectFileName);
|
||||
Name = "RouteSheetEmployeesDistributionReport";
|
||||
Text = "RouteSheetEmployeesDistributionReport";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonSelectFileName;
|
||||
private Label labelFileName;
|
||||
private Label labelDate;
|
||||
private DateTimePicker dateTimePicker;
|
||||
private Button buttonCreate;
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
using TransportEnterprise.Reports;
|
||||
using Unity;
|
||||
|
||||
namespace TransportEnterprise.Forms;
|
||||
|
||||
public partial class FormRouteSheetEmployeesDistributionReport : Form
|
||||
{
|
||||
private string _fileName = string.Empty;
|
||||
private readonly IUnityContainer _container;
|
||||
public FormRouteSheetEmployeesDistributionReport(IUnityContainer container)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
|
||||
}
|
||||
|
||||
private void buttonSelectFileName_Click(object sender, EventArgs e)
|
||||
{
|
||||
var sfd = new SaveFileDialog()
|
||||
{
|
||||
Filter = "Pdf Files | *.pdf"
|
||||
};
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_fileName = sfd.FileName;
|
||||
labelFileName.Text = Path.GetFileName(_fileName);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_fileName))
|
||||
{
|
||||
throw new Exception("Отсутствует имя файла для отчета");
|
||||
}
|
||||
if
|
||||
(_container.Resolve<ChartReport>().CreateChart(_fileName, dateTimePicker.Value))
|
||||
{
|
||||
MessageBox.Show("Документ сформирован",
|
||||
"Формирование документа",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Возникли ошибки при формировании документа.Подробности в логах",
|
||||
"Формирование документа",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при создании очета",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -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>
|
128
TransportEnterprise/TransportEnterprise/Forms/FormRoutes.Designer.cs
generated
Normal file
128
TransportEnterprise/TransportEnterprise/Forms/FormRoutes.Designer.cs
generated
Normal file
@ -0,0 +1,128 @@
|
||||
namespace TransportEnterprise.Forms
|
||||
{
|
||||
partial class FormRoutes
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormRoutes));
|
||||
dataGridView = new DataGridView();
|
||||
panel1 = new Panel();
|
||||
buttonUpd = new Button();
|
||||
buttonDel = new Button();
|
||||
buttonAdd = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
panel1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.AllowUserToResizeColumns = false;
|
||||
dataGridView.AllowUserToResizeRows = false;
|
||||
dataGridView.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
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 = 62;
|
||||
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dataGridView.Size = new Size(978, 894);
|
||||
dataGridView.TabIndex = 5;
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Controls.Add(buttonUpd);
|
||||
panel1.Controls.Add(buttonDel);
|
||||
panel1.Controls.Add(buttonAdd);
|
||||
panel1.Dock = DockStyle.Right;
|
||||
panel1.Location = new Point(978, 0);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(300, 894);
|
||||
panel1.TabIndex = 4;
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
buttonUpd.BackgroundImage = (Image)resources.GetObject("buttonUpd.BackgroundImage");
|
||||
buttonUpd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonUpd.Location = new Point(89, 325);
|
||||
buttonUpd.Name = "buttonUpd";
|
||||
buttonUpd.Size = new Size(127, 108);
|
||||
buttonUpd.TabIndex = 2;
|
||||
buttonUpd.UseVisualStyleBackColor = true;
|
||||
buttonUpd.Click += buttonUpd_Click;
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
buttonDel.BackgroundImage = (Image)resources.GetObject("buttonDel.BackgroundImage");
|
||||
buttonDel.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonDel.Location = new Point(89, 184);
|
||||
buttonDel.Name = "buttonDel";
|
||||
buttonDel.Size = new Size(127, 108);
|
||||
buttonDel.TabIndex = 1;
|
||||
buttonDel.UseVisualStyleBackColor = true;
|
||||
buttonDel.Click += buttonDel_Click;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.BackgroundImage = (Image)resources.GetObject("buttonAdd.BackgroundImage");
|
||||
buttonAdd.BackgroundImageLayout = ImageLayout.Stretch;
|
||||
buttonAdd.Location = new Point(89, 47);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(127, 108);
|
||||
buttonAdd.TabIndex = 0;
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// FormRoutes
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1278, 894);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(panel1);
|
||||
Name = "FormRoutes";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "Маршруты";
|
||||
Load += FormRoutes_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
panel1.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Panel panel1;
|
||||
private Button buttonUpd;
|
||||
private Button buttonDel;
|
||||
private Button buttonAdd;
|
||||
}
|
||||
}
|
91
TransportEnterprise/TransportEnterprise/Forms/FormRoutes.cs
Normal file
91
TransportEnterprise/TransportEnterprise/Forms/FormRoutes.cs
Normal file
@ -0,0 +1,91 @@
|
||||
|
||||
using TransportEnterprise.Entities.Repositories;
|
||||
using Unity;
|
||||
|
||||
namespace TransportEnterprise.Forms;
|
||||
|
||||
public partial class FormRoutes : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
private readonly IRouteRepository _routeRepository;
|
||||
public FormRoutes(IUnityContainer container, IRouteRepository routeRepository)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
_routeRepository = routeRepository ?? throw new(nameof(routeRepository));
|
||||
}
|
||||
private void FormRoutes_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<FormRoute>().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<FormRoute>();
|
||||
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
|
||||
{
|
||||
_routeRepository.DeleteRoute(findId);
|
||||
LoadList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Ошибка при удалении", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void LoadList() => dataGridView.DataSource = _routeRepository.ReadRoutes();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
2821
TransportEnterprise/TransportEnterprise/Forms/FormRoutes.resx
Normal file
2821
TransportEnterprise/TransportEnterprise/Forms/FormRoutes.resx
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,11 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Serilog;
|
||||
using TransportEnterprise.Entities.Repositories;
|
||||
using TransportEnterprise.Entities.Repositories.Implementations;
|
||||
using Unity;
|
||||
using Unity.Microsoft.Logging;
|
||||
|
||||
namespace TransportEnterprise
|
||||
{
|
||||
internal static class Program
|
||||
@ -11,7 +19,36 @@ namespace TransportEnterprise
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
Application.Run(CreateContainer().Resolve<TransportEnterprise>());
|
||||
}
|
||||
|
||||
private static IUnityContainer CreateContainer()
|
||||
{
|
||||
var container = new UnityContainer();
|
||||
|
||||
container.AddExtension(new LoggingExtension(CreateLoggerFactory()));
|
||||
|
||||
container.RegisterType<IBusRepository, BusRepository>();
|
||||
container.RegisterType<IEmployeeRepository, EmployeeRepository>();
|
||||
container.RegisterType<IRouteRepository, RouteRepository>();
|
||||
container.RegisterType<IRouteSheetRepository, RouteSheetRepository>();
|
||||
container.RegisterType<IRepairRequestRepository, RepairRequestRepository>();
|
||||
|
||||
container.RegisterType<IConnectionString, ConnectionString>();
|
||||
|
||||
return container;
|
||||
}
|
||||
private static LoggerFactory CreateLoggerFactory()
|
||||
{
|
||||
var loggerFactory = new LoggerFactory();
|
||||
loggerFactory.AddSerilog(new LoggerConfiguration()
|
||||
.ReadFrom.Configuration(new ConfigurationBuilder()
|
||||
.SetBasePath(Directory.GetCurrentDirectory())
|
||||
.AddJsonFile("appsettings.json")
|
||||
.Build())
|
||||
.CreateLogger());
|
||||
return loggerFactory;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
93
TransportEnterprise/TransportEnterprise/Properties/Resources.Designer.cs
generated
Normal file
93
TransportEnterprise/TransportEnterprise/Properties/Resources.Designer.cs
generated
Normal file
@ -0,0 +1,93 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// Этот код создан программой.
|
||||
// Исполняемая версия:4.0.30319.42000
|
||||
//
|
||||
// Изменения в этом файле могут привести к неправильной работе и будут потеряны в случае
|
||||
// повторной генерации кода.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace TransportEnterprise.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Класс ресурса со строгой типизацией для поиска локализованных строк и т.д.
|
||||
/// </summary>
|
||||
// Этот класс создан автоматически классом StronglyTypedResourceBuilder
|
||||
// с помощью такого средства, как ResGen или Visual Studio.
|
||||
// Чтобы добавить или удалить член, измените файл .ResX и снова запустите ResGen
|
||||
// с параметром /str или перестройте свой проект VS.
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Возвращает кэшированный экземпляр ResourceManager, использованный этим классом.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TransportEnterprise.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Перезаписывает свойство CurrentUICulture текущего потока для всех
|
||||
/// обращений к ресурсу с помощью этого класса ресурса со строгой типизацией.
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap PAZ {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("PAZ", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap pngegg__1_ {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("pngegg (1)", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Поиск локализованного ресурса типа System.Drawing.Bitmap.
|
||||
/// </summary>
|
||||
internal static System.Drawing.Bitmap pngegg__2_ {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("pngegg (2)", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,130 @@
|
||||
<?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>
|
||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<data name="pngegg (1)" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\pngegg (1).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="PAZ" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\PAZ.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="pngegg (2)" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\pngegg (2).png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
@ -0,0 +1,71 @@
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using TransportEnterprise.Entities.Repositories;
|
||||
|
||||
namespace TransportEnterprise.Reports;
|
||||
|
||||
internal class ChartReport
|
||||
{
|
||||
private readonly IRouteSheetRepository _routeSheetRepository;
|
||||
private readonly IEmployeeRepository _employeeRepository;
|
||||
private readonly ILogger<ChartReport> _logger;
|
||||
|
||||
public ChartReport(IRouteSheetRepository routeSheetRepository, IEmployeeRepository employeeRepository, ILogger<ChartReport> logger)
|
||||
{
|
||||
_routeSheetRepository = routeSheetRepository ?? throw new ArgumentNullException(nameof(routeSheetRepository));
|
||||
_employeeRepository = employeeRepository ?? throw new ArgumentNullException(nameof(employeeRepository));
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
|
||||
public bool CreateChart(string filePath, DateTime dateTime)
|
||||
{
|
||||
try
|
||||
{
|
||||
new PdfBuilder(filePath)
|
||||
.AddHeader("Рейсы работников")
|
||||
.AddPieChart("Работники", GetData(dateTime))
|
||||
.Build();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
private List<(string Caption, double Value)> GetData(DateTime dateTime)
|
||||
{
|
||||
|
||||
var routeSheets = _routeSheetRepository.ReadRouteSheets()
|
||||
.Where(x => x.DateTime.Date == dateTime.Date) .ToList();
|
||||
|
||||
var routeSheetEmployees = _routeSheetRepository.ReadRouteSheets_Employee();
|
||||
|
||||
|
||||
var data = from x in routeSheets
|
||||
join y in routeSheetEmployees on x.Id equals y.RouteSheetId
|
||||
select new
|
||||
{
|
||||
EmployeeName = _employeeRepository.ReadEmployeeById(y.EmployeeId).Name,
|
||||
Count = y.Count
|
||||
};
|
||||
|
||||
|
||||
var groupedData = data
|
||||
.GroupBy(x => x.EmployeeName)
|
||||
.Select(g => new
|
||||
{
|
||||
EmployeeName = g.Key,
|
||||
TotalCount = g.Sum(x => x.Count)
|
||||
})
|
||||
.ToList();
|
||||
|
||||
|
||||
var result = groupedData
|
||||
.Select(x => (x.EmployeeName, (double)x.TotalCount))
|
||||
.ToList();
|
||||
|
||||
return result;
|
||||
|
||||
}
|
||||
}
|
76
TransportEnterprise/TransportEnterprise/Reports/DocReport.cs
Normal file
76
TransportEnterprise/TransportEnterprise/Reports/DocReport.cs
Normal file
@ -0,0 +1,76 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using TransportEnterprise.Entities.Repositories;
|
||||
|
||||
namespace TransportEnterprise.Reports;
|
||||
internal class DocReport
|
||||
{
|
||||
private readonly IBusRepository _busRepository;
|
||||
private readonly IEmployeeRepository _employeeRepository;
|
||||
private readonly IRouteRepository _routeRepository;
|
||||
private readonly ILogger<DocReport> _logger;
|
||||
public DocReport(IBusRepository busRepository, IEmployeeRepository employeeRepository, IRouteRepository routeRepository, ILogger<DocReport> logger)
|
||||
{
|
||||
_busRepository = busRepository ?? throw new ArgumentNullException(nameof(busRepository));
|
||||
_employeeRepository = employeeRepository ?? throw new ArgumentNullException(nameof(employeeRepository));
|
||||
_routeRepository = routeRepository ?? throw new ArgumentNullException(nameof(routeRepository));
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
public bool CreateDoc(string filePath, bool includeBuses, bool
|
||||
includeEmployees, bool includeRoutes)
|
||||
{
|
||||
try
|
||||
{
|
||||
var builder = new WordBuilder(filePath)
|
||||
.AddHeader("Документ со справочниками");
|
||||
if (includeBuses)
|
||||
{
|
||||
builder.AddParagraph("Автобусы")
|
||||
.AddTable([1200, 1200, 1200, 2400, 1200, 2400], GetBuses());
|
||||
}
|
||||
if (includeEmployees)
|
||||
{
|
||||
builder.AddParagraph("Работники")
|
||||
.AddTable([2400, 1200, 2400, 2400], GetEmployess());
|
||||
}
|
||||
if (includeRoutes)
|
||||
{
|
||||
builder.AddParagraph("Маршруты")
|
||||
.AddTable([2400, 1200, 1200, 2400], GetRoutes());
|
||||
}
|
||||
builder.Build();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
private List<string[]> GetBuses()
|
||||
{
|
||||
return [
|
||||
["Бренд", "Модель", "Вместимость", "Номерной знак", "Год выпуска", "Тех. состояние"],
|
||||
.. _busRepository
|
||||
.ReadBuses()
|
||||
.Select(x => new string[] { x.Brand, x.Model, x.Capacity.ToString(), x.LicensePlate, x.Year.ToString(), x.TechnicalCondition.ToString()}),
|
||||
];
|
||||
}
|
||||
private List<string[]> GetEmployess()
|
||||
{
|
||||
return [
|
||||
["ФИО", "Табельный номер", "Должность", "Контактный номер телефона"],
|
||||
.. _employeeRepository
|
||||
.ReadEmployees()
|
||||
.Select(x => new string[] { x.Name, x.Number.ToString(), x.PositionOfEmployee.ToString(), x.PhoneNumber}),
|
||||
];
|
||||
}
|
||||
private List<string[]> GetRoutes()
|
||||
{
|
||||
return [
|
||||
["Название", "Номер", "Интервал движения", "График"],
|
||||
.. _routeRepository
|
||||
.ReadRoutes()
|
||||
.Select(x => new string[] { x.Name, x.Number.ToString(), x.Interval.ToString(), x.Schedule}),
|
||||
];
|
||||
}
|
||||
}
|
311
TransportEnterprise/TransportEnterprise/Reports/ExcelBuilder.cs
Normal file
311
TransportEnterprise/TransportEnterprise/Reports/ExcelBuilder.cs
Normal file
@ -0,0 +1,311 @@
|
||||
using DocumentFormat.OpenXml;
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
|
||||
namespace TransportEnterprise.Reports;
|
||||
|
||||
internal class ExcelBuilder
|
||||
{
|
||||
private readonly string _filePath;
|
||||
private readonly SheetData _sheetData;
|
||||
private readonly MergeCells _mergeCells;
|
||||
private readonly Columns _columns;
|
||||
private uint _rowIndex = 0;
|
||||
|
||||
public ExcelBuilder(string filePath)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(filePath))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(filePath));
|
||||
}
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
File.Delete(filePath);
|
||||
}
|
||||
_filePath = filePath;
|
||||
_sheetData = new SheetData();
|
||||
_mergeCells = new MergeCells();
|
||||
_columns = new Columns();
|
||||
_rowIndex = 1;
|
||||
}
|
||||
|
||||
public ExcelBuilder AddHeader(string header, int startIndex, int count)
|
||||
{
|
||||
CreateCell(startIndex, _rowIndex, header, StyleIndex.BoldTextWithoutBorder);
|
||||
for (int i = startIndex + 1; i < startIndex + count; ++i)
|
||||
{
|
||||
CreateCell(i, _rowIndex, "", StyleIndex.SimpleTextWithoutBorder);
|
||||
}
|
||||
_mergeCells.Append(new MergeCell()
|
||||
{
|
||||
Reference = new StringValue($"{GetExcelColumnName(startIndex)}{_rowIndex}:{GetExcelColumnName(startIndex + count - 1)}{_rowIndex}")
|
||||
});
|
||||
_rowIndex++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExcelBuilder AddParagraph(string text, int columnIndex)
|
||||
{
|
||||
CreateCell(columnIndex, _rowIndex++, text, StyleIndex.SimpleTextWithoutBorder);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ExcelBuilder AddTable(int[] columnsWidths, List<string[]> data)
|
||||
{
|
||||
if (columnsWidths == null || columnsWidths.Length == 0)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(columnsWidths));
|
||||
}
|
||||
if (data == null || data.Count == 0)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(data));
|
||||
}
|
||||
if (data.Any(x => x.Length != columnsWidths.Length))
|
||||
{
|
||||
throw new InvalidOperationException("widths.Length != data.Length");
|
||||
}
|
||||
|
||||
uint counter = 1;
|
||||
int coef = 2;
|
||||
_columns.Append(columnsWidths.Select(x => new Column
|
||||
{
|
||||
Min = counter,
|
||||
Max = counter++,
|
||||
Width = x * coef,
|
||||
CustomWidth = true
|
||||
}));
|
||||
for (var j = 0; j < data.First().Length; ++j)
|
||||
{
|
||||
CreateCell(j, _rowIndex, data.First()[j], StyleIndex.BoldTextWithBorder);
|
||||
}
|
||||
_rowIndex++;
|
||||
|
||||
for (var i = 1; i < data.Count - 1; ++i)
|
||||
{
|
||||
for (var j = 0; j < data[i].Length; ++j)
|
||||
{
|
||||
CreateCell(j, _rowIndex, data[i][j], StyleIndex.SimpleTextWithBorder);
|
||||
}
|
||||
_rowIndex++;
|
||||
}
|
||||
for (var j = 0; j < data.Last().Length; ++j)
|
||||
{
|
||||
CreateCell(j, _rowIndex, data.Last()[j], StyleIndex.BoldTextWithBorder);
|
||||
}
|
||||
_rowIndex++;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void Build()
|
||||
{
|
||||
using var spreadsheetDocument = SpreadsheetDocument.Create(_filePath, SpreadsheetDocumentType.Workbook);
|
||||
var workbookpart = spreadsheetDocument.AddWorkbookPart();
|
||||
GenerateStyle(workbookpart);
|
||||
workbookpart.Workbook = new Workbook();
|
||||
var worksheetPart = workbookpart.AddNewPart<WorksheetPart>();
|
||||
worksheetPart.Worksheet = new Worksheet();
|
||||
|
||||
if (_columns.HasChildren)
|
||||
{
|
||||
worksheetPart.Worksheet.Append(_columns);
|
||||
}
|
||||
|
||||
worksheetPart.Worksheet.Append(_sheetData);
|
||||
var sheets = spreadsheetDocument.WorkbookPart!.Workbook.AppendChild(new Sheets());
|
||||
var sheet = new Sheet()
|
||||
{
|
||||
Id = spreadsheetDocument.WorkbookPart.GetIdOfPart(worksheetPart),
|
||||
SheetId = 1,
|
||||
Name = "Лист 1"
|
||||
};
|
||||
sheets.Append(sheet);
|
||||
if (_mergeCells.HasChildren)
|
||||
{
|
||||
worksheetPart.Worksheet.InsertAfter(_mergeCells,
|
||||
worksheetPart.Worksheet.Elements<SheetData>().First());
|
||||
}
|
||||
}
|
||||
|
||||
private static void GenerateStyle(WorkbookPart workbookPart)
|
||||
{
|
||||
var workbookStylesPart = workbookPart.AddNewPart<WorkbookStylesPart>();
|
||||
workbookStylesPart.Stylesheet = new Stylesheet();
|
||||
|
||||
var fonts = new Fonts()
|
||||
{
|
||||
Count = 2,
|
||||
KnownFonts = BooleanValue.FromBoolean(true)
|
||||
};
|
||||
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
|
||||
{
|
||||
FontSize = new FontSize() { Val = 11 },
|
||||
FontName = new FontName() { Val = "Calibri" },
|
||||
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
|
||||
FontScheme = new FontScheme()
|
||||
{
|
||||
Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor)
|
||||
}
|
||||
});
|
||||
fonts.Append(new DocumentFormat.OpenXml.Spreadsheet.Font
|
||||
{
|
||||
FontSize = new FontSize() { Val = 11 },
|
||||
FontName = new FontName() { Val = "Calibri" },
|
||||
FontFamilyNumbering = new FontFamilyNumbering() { Val = 2 },
|
||||
FontScheme = new FontScheme()
|
||||
{
|
||||
Val = new EnumValue<FontSchemeValues>(FontSchemeValues.Minor)
|
||||
},
|
||||
Bold = new Bold() { Val = true }
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(fonts);
|
||||
|
||||
// Default Fill
|
||||
var fills = new Fills() { Count = 1 };
|
||||
fills.Append(new Fill
|
||||
{
|
||||
PatternFill = new PatternFill()
|
||||
{
|
||||
PatternType = new EnumValue<PatternValues>(PatternValues.None)
|
||||
}
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(fills);
|
||||
|
||||
// Default Border
|
||||
var borders = new Borders() { Count = 2 };
|
||||
borders.Append(new Border
|
||||
{
|
||||
LeftBorder = new LeftBorder(),
|
||||
RightBorder = new RightBorder(),
|
||||
TopBorder = new TopBorder(),
|
||||
BottomBorder = new BottomBorder(),
|
||||
DiagonalBorder = new DiagonalBorder()
|
||||
});
|
||||
borders.Append(new Border
|
||||
{
|
||||
LeftBorder = new LeftBorder() { Style = BorderStyleValues.Thin },
|
||||
RightBorder = new RightBorder() { Style = BorderStyleValues.Thin },
|
||||
TopBorder = new TopBorder() { Style = BorderStyleValues.Thin },
|
||||
BottomBorder = new BottomBorder() { Style = BorderStyleValues.Thin },
|
||||
DiagonalBorder = new DiagonalBorder()
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(borders);
|
||||
|
||||
// Default cell format and a date cell format
|
||||
var cellFormats = new CellFormats() { Count = 4 };
|
||||
cellFormats.Append(new CellFormat
|
||||
{
|
||||
NumberFormatId = 0,
|
||||
FormatId = 0,
|
||||
FontId = 0,
|
||||
BorderId = 0,
|
||||
FillId = 0,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Horizontal = HorizontalAlignmentValues.Left,
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true
|
||||
}
|
||||
});
|
||||
cellFormats.Append(new CellFormat
|
||||
{
|
||||
NumberFormatId = 0,
|
||||
FormatId = 0,
|
||||
FontId = 0,
|
||||
BorderId = 1,
|
||||
FillId = 0,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Horizontal = HorizontalAlignmentValues.Right,
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true
|
||||
}
|
||||
});
|
||||
cellFormats.Append(new CellFormat
|
||||
{
|
||||
NumberFormatId = 0,
|
||||
FormatId = 0,
|
||||
FontId = 1,
|
||||
BorderId = 0,
|
||||
FillId = 0,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Horizontal = HorizontalAlignmentValues.Center,
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true
|
||||
}
|
||||
});
|
||||
cellFormats.Append(new CellFormat
|
||||
{
|
||||
NumberFormatId = 0,
|
||||
FormatId = 0,
|
||||
FontId = 1,
|
||||
BorderId = 1,
|
||||
FillId = 0,
|
||||
Alignment = new Alignment()
|
||||
{
|
||||
Horizontal = HorizontalAlignmentValues.Center,
|
||||
Vertical = VerticalAlignmentValues.Center,
|
||||
WrapText = true
|
||||
}
|
||||
});
|
||||
workbookStylesPart.Stylesheet.Append(cellFormats);
|
||||
}
|
||||
|
||||
private enum StyleIndex
|
||||
{
|
||||
SimpleTextWithoutBorder = 0,
|
||||
SimpleTextWithBorder = 1,
|
||||
BoldTextWithoutBorder = 2,
|
||||
BoldTextWithBorder = 3,
|
||||
}
|
||||
|
||||
private void CreateCell(int columnIndex, uint rowIndex, string text, StyleIndex styleIndex)
|
||||
{
|
||||
var columnName = GetExcelColumnName(columnIndex);
|
||||
var cellReference = columnName + rowIndex;
|
||||
var row = _sheetData.Elements<Row>().FirstOrDefault(r => r.RowIndex! == rowIndex);
|
||||
if (row == null)
|
||||
{
|
||||
row = new Row() { RowIndex = rowIndex };
|
||||
_sheetData.Append(row);
|
||||
}
|
||||
var newCell = row.Elements<Cell>().FirstOrDefault(c => c.CellReference != null &&
|
||||
c.CellReference.Value == columnName + rowIndex);
|
||||
if (newCell == null)
|
||||
{
|
||||
Cell? refCell = null;
|
||||
foreach (Cell cell in row.Elements<Cell>())
|
||||
{
|
||||
if (cell.CellReference?.Value != null &&
|
||||
cell.CellReference.Value.Length == cellReference.Length)
|
||||
{
|
||||
if (string.Compare(cell.CellReference.Value, cellReference, true) > 0)
|
||||
{
|
||||
refCell = cell;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
newCell = new Cell() { CellReference = cellReference };
|
||||
row.InsertBefore(newCell, refCell);
|
||||
}
|
||||
newCell.CellValue = new CellValue(text);
|
||||
newCell.DataType = CellValues.String;
|
||||
newCell.StyleIndex = (uint)styleIndex;
|
||||
}
|
||||
|
||||
private static string GetExcelColumnName(int columnNumber)
|
||||
{
|
||||
columnNumber += 1;
|
||||
int dividend = columnNumber;
|
||||
string columnName = string.Empty;
|
||||
int modulo;
|
||||
while (dividend > 0)
|
||||
{
|
||||
modulo = (dividend - 1) % 26;
|
||||
columnName = Convert.ToChar(65 + modulo).ToString() + columnName;
|
||||
dividend = (dividend - modulo) / 26;
|
||||
}
|
||||
return columnName;
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
using MigraDoc.DocumentObjectModel;
|
||||
using MigraDoc.DocumentObjectModel.Shapes.Charts;
|
||||
using MigraDoc.Rendering;
|
||||
using System.Text;
|
||||
|
||||
namespace TransportEnterprise.Reports;
|
||||
|
||||
internal class PdfBuilder
|
||||
{
|
||||
private readonly string _filePath;
|
||||
private readonly Document _document;
|
||||
public PdfBuilder(string filePath)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(filePath))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(filePath));
|
||||
}
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
File.Delete(filePath);
|
||||
}
|
||||
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
|
||||
_filePath = filePath;
|
||||
_document = new Document();
|
||||
DefineStyles();
|
||||
}
|
||||
public PdfBuilder AddHeader(string header)
|
||||
{
|
||||
_document.AddSection().AddParagraph(header, "NormalBold");
|
||||
return this;
|
||||
}
|
||||
public PdfBuilder AddPieChart(string title, List<(string Caption, double
|
||||
Value)> data)
|
||||
{
|
||||
if (data == null || data.Count == 0)
|
||||
{
|
||||
return this;
|
||||
}
|
||||
var chart = new Chart(ChartType.Pie2D);
|
||||
var series = chart.SeriesCollection.AddSeries();
|
||||
series.Add(data.Select(x => x.Value).ToArray());
|
||||
var xseries = chart.XValues.AddXSeries();
|
||||
xseries.Add(data.Select(x => x.Caption).ToArray());
|
||||
chart.DataLabel.Type = DataLabelType.Percent;
|
||||
chart.DataLabel.Position = DataLabelPosition.OutsideEnd;
|
||||
chart.Width = Unit.FromCentimeter(16);
|
||||
chart.Height = Unit.FromCentimeter(12);
|
||||
chart.TopArea.AddParagraph(title);
|
||||
chart.XAxis.MajorTickMark = TickMarkType.Outside;
|
||||
chart.YAxis.MajorTickMark = TickMarkType.Outside;
|
||||
chart.YAxis.HasMajorGridlines = true;
|
||||
chart.PlotArea.LineFormat.Width = 1;
|
||||
chart.PlotArea.LineFormat.Visible = true;
|
||||
chart.TopArea.AddLegend();
|
||||
_document.LastSection.Add(chart);
|
||||
return this;
|
||||
}
|
||||
public void Build()
|
||||
{
|
||||
var renderer = new PdfDocumentRenderer(true)
|
||||
{
|
||||
Document = _document
|
||||
};
|
||||
renderer.RenderDocument();
|
||||
renderer.PdfDocument.Save(_filePath);
|
||||
}
|
||||
private void DefineStyles()
|
||||
{
|
||||
// TODO задать стиль для заголовка (жирный)
|
||||
var headerStyle = _document.Styles.AddStyle("NormalBold", "Normal");
|
||||
headerStyle.Font.Bold = true;
|
||||
headerStyle.Font.Size = 14;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,86 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using TransportEnterprise.Entities;
|
||||
using TransportEnterprise.Entities.Repositories;
|
||||
using TransportEnterprise.Reports;
|
||||
|
||||
internal class TableReport
|
||||
{
|
||||
private readonly IRouteSheetRepository _routeSheetRepository;
|
||||
private readonly IEmployeeRepository _employeeRepository;
|
||||
private readonly ILogger<TableReport> _logger;
|
||||
|
||||
internal static readonly string[] item = ["Сотрудник", "Дата", "Количество рейсов"];
|
||||
|
||||
public TableReport(IRouteSheetRepository routeSheetRepository, IEmployeeRepository employeeRepository, ILogger<TableReport> logger)
|
||||
{
|
||||
_routeSheetRepository = routeSheetRepository ?? throw new ArgumentNullException(nameof(routeSheetRepository));
|
||||
_employeeRepository = employeeRepository ?? throw new ArgumentNullException(nameof(employeeRepository));
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
}
|
||||
|
||||
public bool CreateTable(string filePath, int employeeId, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
try
|
||||
{
|
||||
var data = GetData(employeeId, startDate, endDate);
|
||||
new ExcelBuilder(filePath)
|
||||
.AddHeader("Сводка по движению рейсов", 0, 2)
|
||||
.AddParagraph("за период", 0)
|
||||
.AddTable([10, 15, 15], data)
|
||||
.Build();
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка при формировании документа");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private List<string[]> GetData(int employeeId, DateTime startDate, DateTime endDate)
|
||||
{
|
||||
var routeSheets = _routeSheetRepository.ReadRouteSheets()
|
||||
.Where(x => x.DateTime >= startDate && x.DateTime <= endDate)
|
||||
.ToList();
|
||||
|
||||
var routeSheetEmployees = _routeSheetRepository.ReadRouteSheets_Employee()
|
||||
.Where(x => x.EmployeeId == employeeId)
|
||||
.ToList();
|
||||
var Employee = _employeeRepository.ReadEmployeeById(employeeId);
|
||||
|
||||
|
||||
var data1 = from x in routeSheets
|
||||
join y in routeSheetEmployees on x.Id equals y.RouteSheetId
|
||||
select new
|
||||
{
|
||||
Employee.Name,
|
||||
Date = x.DateTime,
|
||||
Count = y.Count
|
||||
};
|
||||
|
||||
var groupedData = data1
|
||||
.GroupBy(x => new { x.Name, x.Date })
|
||||
.Select(g => new
|
||||
{
|
||||
EmployeeId = g.Key.Name,
|
||||
Date = g.Key.Date,
|
||||
Count = g.Sum(x => x.Count)
|
||||
})
|
||||
.OrderBy(x => x.Date)
|
||||
.ToList();
|
||||
|
||||
var totalCount = groupedData.Sum(x => x.Count);
|
||||
|
||||
var result = new List<string[]>() { item }
|
||||
.Union(
|
||||
data1
|
||||
.Select(x => new string[] {
|
||||
x.Name.ToString(), x.Date.ToString(), x.Count.ToString()
|
||||
}))
|
||||
.Union(
|
||||
[["Всего", "", totalCount.ToString()]])
|
||||
.ToList();
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
125
TransportEnterprise/TransportEnterprise/Reports/WordBuilder.cs
Normal file
125
TransportEnterprise/TransportEnterprise/Reports/WordBuilder.cs
Normal file
@ -0,0 +1,125 @@
|
||||
using DocumentFormat.OpenXml.Packaging;
|
||||
using DocumentFormat.OpenXml.Wordprocessing;
|
||||
using DocumentFormat.OpenXml;
|
||||
|
||||
namespace TransportEnterprise.Reports;
|
||||
|
||||
internal class WordBuilder
|
||||
{
|
||||
private readonly string _filePath;
|
||||
private readonly Document _document;
|
||||
private readonly Body _body;
|
||||
public WordBuilder(string filePath)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(filePath))
|
||||
{
|
||||
throw new ArgumentNullException(nameof(filePath));
|
||||
}
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
File.Delete(filePath);
|
||||
}
|
||||
_filePath = filePath;
|
||||
_document = new Document();
|
||||
_body = _document.AppendChild(new Body());
|
||||
}
|
||||
public WordBuilder AddHeader(string header)
|
||||
{
|
||||
var paragraph = _body.AppendChild(new Paragraph());
|
||||
var run = paragraph.AppendChild(new Run());
|
||||
// TODO прописать настройки под жирный текст
|
||||
run.AppendChild(new RunProperties(new Bold()));
|
||||
run.AppendChild(new Text(header));
|
||||
return this;
|
||||
}
|
||||
public WordBuilder AddParagraph(string text)
|
||||
{
|
||||
var paragraph = _body.AppendChild(new Paragraph());
|
||||
var run = paragraph.AppendChild(new Run());
|
||||
run.AppendChild(new Text(text));
|
||||
return this;
|
||||
}
|
||||
public WordBuilder AddTable(int[] widths, List<string[]> data)
|
||||
{
|
||||
if (widths == null || widths.Length == 0)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(widths));
|
||||
}
|
||||
if (data == null || data.Count == 0)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(data));
|
||||
}
|
||||
if (data.Any(x => x.Length != widths.Length))
|
||||
{
|
||||
throw new InvalidOperationException("widths.Length !=data.Length");
|
||||
}
|
||||
var table = new Table();
|
||||
table.AppendChild(new TableProperties(
|
||||
new TableBorders(
|
||||
new TopBorder()
|
||||
{
|
||||
Val = new
|
||||
EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new BottomBorder()
|
||||
{
|
||||
Val = new
|
||||
EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new LeftBorder()
|
||||
{
|
||||
Val = new
|
||||
EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new RightBorder()
|
||||
{
|
||||
Val = new
|
||||
EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new InsideHorizontalBorder()
|
||||
{
|
||||
Val = new
|
||||
EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
},
|
||||
new InsideVerticalBorder()
|
||||
{
|
||||
Val = new
|
||||
EnumValue<BorderValues>(BorderValues.Single),
|
||||
Size = 12
|
||||
}
|
||||
)
|
||||
));
|
||||
// Заголовок
|
||||
var tr = new TableRow();
|
||||
for (var j = 0; j < widths.Length; ++j)
|
||||
{
|
||||
tr.Append(new TableCell(
|
||||
new TableCellProperties(new TableCellWidth()
|
||||
{
|
||||
Width =
|
||||
widths[j].ToString()
|
||||
}),
|
||||
new Paragraph(new Run(new RunProperties(new Bold()), new
|
||||
Text(data.First()[j])))));
|
||||
}
|
||||
table.Append(tr);
|
||||
// Данные
|
||||
table.Append(data.Skip(1).Select(x =>
|
||||
new TableRow(x.Select(y => new TableCell(new Paragraph(new
|
||||
Run(new Text(y))))))));
|
||||
_body.Append(table);
|
||||
return this;
|
||||
}
|
||||
public void Build()
|
||||
{
|
||||
using var wordDocument = WordprocessingDocument.Create(_filePath,
|
||||
WordprocessingDocumentType.Document);
|
||||
var mainPart = wordDocument.AddMainDocumentPart();
|
||||
mainPart.Document = _document;
|
||||
}
|
||||
}
|
BIN
TransportEnterprise/TransportEnterprise/Resources/PAZ.jpg
Normal file
BIN
TransportEnterprise/TransportEnterprise/Resources/PAZ.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 70 KiB |
BIN
TransportEnterprise/TransportEnterprise/Resources/pngegg (1).png
Normal file
BIN
TransportEnterprise/TransportEnterprise/Resources/pngegg (1).png
Normal file
Binary file not shown.
After Width: | Height: | Size: 39 KiB |
BIN
TransportEnterprise/TransportEnterprise/Resources/pngegg (2).png
Normal file
BIN
TransportEnterprise/TransportEnterprise/Resources/pngegg (2).png
Normal file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
170
TransportEnterprise/TransportEnterprise/TransportEnterprise.Designer.cs
generated
Normal file
170
TransportEnterprise/TransportEnterprise/TransportEnterprise.Designer.cs
generated
Normal file
@ -0,0 +1,170 @@
|
||||
namespace TransportEnterprise
|
||||
{
|
||||
partial class TransportEnterprise
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TransportEnterprise));
|
||||
menuStrip1 = new MenuStrip();
|
||||
справочникToolStripMenuItem = new ToolStripMenuItem();
|
||||
RoutesToolStripMenuItem = new ToolStripMenuItem();
|
||||
BusesToolStripMenuItem = new ToolStripMenuItem();
|
||||
EmployeesToolStripMenuItem = new ToolStripMenuItem();
|
||||
операцииToolStripMenuItem = new ToolStripMenuItem();
|
||||
AddRouteSheetМарToolStripMenuItem = new ToolStripMenuItem();
|
||||
AddRepairRequestToolStripMenuItem = new ToolStripMenuItem();
|
||||
отчётыToolStripMenuItem = new ToolStripMenuItem();
|
||||
directoryReportToolStripMenuItem = new ToolStripMenuItem();
|
||||
reportEmployeesToolStripMenuItem = new ToolStripMenuItem();
|
||||
RouteSheetEmployeesDistributionReportToolStripMenuItem = new ToolStripMenuItem();
|
||||
menuStrip1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
menuStrip1.ImageScalingSize = new Size(24, 24);
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { справочникToolStripMenuItem, операцииToolStripMenuItem, отчётыToolStripMenuItem });
|
||||
menuStrip1.Location = new Point(0, 0);
|
||||
menuStrip1.Name = "menuStrip1";
|
||||
menuStrip1.Size = new Size(1478, 33);
|
||||
menuStrip1.TabIndex = 0;
|
||||
menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// справочникToolStripMenuItem
|
||||
//
|
||||
справочникToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { RoutesToolStripMenuItem, BusesToolStripMenuItem, EmployeesToolStripMenuItem });
|
||||
справочникToolStripMenuItem.Name = "справочникToolStripMenuItem";
|
||||
справочникToolStripMenuItem.Size = new Size(139, 29);
|
||||
справочникToolStripMenuItem.Text = "Справочники";
|
||||
//
|
||||
// RoutesToolStripMenuItem
|
||||
//
|
||||
RoutesToolStripMenuItem.Name = "RoutesToolStripMenuItem";
|
||||
RoutesToolStripMenuItem.Size = new Size(204, 34);
|
||||
RoutesToolStripMenuItem.Text = "Маршруты";
|
||||
RoutesToolStripMenuItem.Click += RoutesToolStripMenuItem_Click;
|
||||
//
|
||||
// BusesToolStripMenuItem
|
||||
//
|
||||
BusesToolStripMenuItem.Name = "BusesToolStripMenuItem";
|
||||
BusesToolStripMenuItem.Size = new Size(204, 34);
|
||||
BusesToolStripMenuItem.Text = "Автобусы";
|
||||
BusesToolStripMenuItem.Click += BusesToolStripMenuItem_Click;
|
||||
//
|
||||
// EmployeesToolStripMenuItem
|
||||
//
|
||||
EmployeesToolStripMenuItem.Name = "EmployeesToolStripMenuItem";
|
||||
EmployeesToolStripMenuItem.Size = new Size(204, 34);
|
||||
EmployeesToolStripMenuItem.Text = "Работники";
|
||||
EmployeesToolStripMenuItem.Click += EmployeesToolStripMenuItem_Click;
|
||||
//
|
||||
// операцииToolStripMenuItem
|
||||
//
|
||||
операцииToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { AddRouteSheetМарToolStripMenuItem, AddRepairRequestToolStripMenuItem });
|
||||
операцииToolStripMenuItem.Name = "операцииToolStripMenuItem";
|
||||
операцииToolStripMenuItem.Size = new Size(112, 29);
|
||||
операцииToolStripMenuItem.Text = "Операции";
|
||||
//
|
||||
// AddRouteSheetМарToolStripMenuItem
|
||||
//
|
||||
AddRouteSheetМарToolStripMenuItem.Name = "AddRouteSheetМарToolStripMenuItem";
|
||||
AddRouteSheetМарToolStripMenuItem.Size = new Size(343, 34);
|
||||
AddRouteSheetМарToolStripMenuItem.Text = "Добавить маршрутный лист";
|
||||
AddRouteSheetМарToolStripMenuItem.Click += AddRouteSheetМарToolStripMenuItem_Click;
|
||||
//
|
||||
// AddRepairRequestToolStripMenuItem
|
||||
//
|
||||
AddRepairRequestToolStripMenuItem.Name = "AddRepairRequestToolStripMenuItem";
|
||||
AddRepairRequestToolStripMenuItem.Size = new Size(343, 34);
|
||||
AddRepairRequestToolStripMenuItem.Text = "Добавить заявку на ремонт";
|
||||
AddRepairRequestToolStripMenuItem.Click += AddRepairRequestToolStripMenuItem_Click;
|
||||
//
|
||||
// отчётыToolStripMenuItem
|
||||
//
|
||||
отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { directoryReportToolStripMenuItem, reportEmployeesToolStripMenuItem, RouteSheetEmployeesDistributionReportToolStripMenuItem });
|
||||
отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
|
||||
отчётыToolStripMenuItem.Size = new Size(88, 29);
|
||||
отчётыToolStripMenuItem.Text = "Отчёты";
|
||||
//
|
||||
// directoryReportToolStripMenuItem
|
||||
//
|
||||
directoryReportToolStripMenuItem.Name = "directoryReportToolStripMenuItem";
|
||||
directoryReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.W;
|
||||
directoryReportToolStripMenuItem.Size = new Size(421, 34);
|
||||
directoryReportToolStripMenuItem.Text = "Документ со справочниками";
|
||||
directoryReportToolStripMenuItem.Click += directoryReportToolStripMenuItem_Click;
|
||||
//
|
||||
// reportEmployeesToolStripMenuItem
|
||||
//
|
||||
reportEmployeesToolStripMenuItem.Name = "reportEmployeesToolStripMenuItem";
|
||||
reportEmployeesToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.E;
|
||||
reportEmployeesToolStripMenuItem.Size = new Size(421, 34);
|
||||
reportEmployeesToolStripMenuItem.Text = "Отчёт по работникам";
|
||||
reportEmployeesToolStripMenuItem.Click += reportEmployeesToolStripMenuItem_Click;
|
||||
//
|
||||
// RouteSheetEmployeesDistributionReportToolStripMenuItem
|
||||
//
|
||||
RouteSheetEmployeesDistributionReportToolStripMenuItem.Name = "RouteSheetEmployeesDistributionReportToolStripMenuItem";
|
||||
RouteSheetEmployeesDistributionReportToolStripMenuItem.ShortcutKeys = Keys.Control | Keys.P;
|
||||
RouteSheetEmployeesDistributionReportToolStripMenuItem.Size = new Size(421, 34);
|
||||
RouteSheetEmployeesDistributionReportToolStripMenuItem.Text = "Отчёт среди работников";
|
||||
RouteSheetEmployeesDistributionReportToolStripMenuItem.Click += RouteSheetEmployeesDistributionReportToolStripMenuItem_Click;
|
||||
//
|
||||
// TransportEnterprise
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(10F, 25F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
BackgroundImage = (Image)resources.GetObject("$this.BackgroundImage");
|
||||
BackgroundImageLayout = ImageLayout.Stretch;
|
||||
ClientSize = new Size(1478, 794);
|
||||
Controls.Add(menuStrip1);
|
||||
MainMenuStrip = menuStrip1;
|
||||
Name = "TransportEnterprise";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "Автопредприятие";
|
||||
menuStrip1.ResumeLayout(false);
|
||||
menuStrip1.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem справочникToolStripMenuItem;
|
||||
private ToolStripMenuItem RoutesToolStripMenuItem;
|
||||
private ToolStripMenuItem BusesToolStripMenuItem;
|
||||
private ToolStripMenuItem EmployeesToolStripMenuItem;
|
||||
private ToolStripMenuItem операцииToolStripMenuItem;
|
||||
private ToolStripMenuItem отчётыToolStripMenuItem;
|
||||
private ToolStripMenuItem AddRouteSheetМарToolStripMenuItem;
|
||||
private ToolStripMenuItem AddRepairRequestToolStripMenuItem;
|
||||
private ToolStripMenuItem directoryReportToolStripMenuItem;
|
||||
private ToolStripMenuItem reportEmployeesToolStripMenuItem;
|
||||
private ToolStripMenuItem RouteSheetEmployeesDistributionReportToolStripMenuItem;
|
||||
}
|
||||
}
|
113
TransportEnterprise/TransportEnterprise/TransportEnterprise.cs
Normal file
113
TransportEnterprise/TransportEnterprise/TransportEnterprise.cs
Normal file
@ -0,0 +1,113 @@
|
||||
using System.ComponentModel;
|
||||
using TransportEnterprise.Forms;
|
||||
using Unity;
|
||||
|
||||
namespace TransportEnterprise
|
||||
{
|
||||
public partial class TransportEnterprise : Form
|
||||
{
|
||||
private readonly IUnityContainer _container;
|
||||
public TransportEnterprise(IUnityContainer container)
|
||||
{
|
||||
InitializeComponent();
|
||||
_container = container ?? throw new ArgumentNullException(nameof(container));
|
||||
|
||||
}
|
||||
|
||||
private void RoutesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormRoutes>().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 BusesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormBuses>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddRouteSheetÌàðToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormAddingRouteSheet>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddRepairRequestToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormRepairRequests>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void directoryReportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormDirectoryReport>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void reportEmployeesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormRouteSheetEmployeeReport>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void RouteSheetEmployeesDistributionReportToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
_container.Resolve<FormRouteSheetEmployeesDistributionReport>().ShowDialog();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(ex.Message, "Îøèáêà ïðè çàãðóçêå", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +1,49 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Dapper" Version="2.1.35" />
|
||||
<PackageReference Include="DocumentFormat.OpenXml" Version="3.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="8.0.1" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="8.0.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
<PackageReference Include="Npgsql" Version="8.0.5" />
|
||||
<PackageReference Include="PdfSharp.MigraDoc.Standard" Version="1.51.15" />
|
||||
<PackageReference Include="Serilog" Version="4.1.0" />
|
||||
<PackageReference Include="Serilog.Extensions.Logging" Version="8.0.0" />
|
||||
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.4" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
|
||||
<PackageReference Include="Unity" Version="5.11.10" />
|
||||
<PackageReference Include="Unity.Microsoft.Logging" Version="5.11.1" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Update="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="appsettings.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
1325
TransportEnterprise/TransportEnterprise/TransportEnterprise.resx
Normal file
1325
TransportEnterprise/TransportEnterprise/TransportEnterprise.resx
Normal file
File diff suppressed because it is too large
Load Diff
15
TransportEnterprise/TransportEnterprise/appsettings.json
Normal file
15
TransportEnterprise/TransportEnterprise/appsettings.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"Serilog": {
|
||||
"Using": [ "Serilog.Sinks.File" ],
|
||||
"MinimumLevel": "Debug",
|
||||
"WriteTo": [
|
||||
{
|
||||
"Name": "File",
|
||||
"Args": {
|
||||
"path": "Logs/transportEnterprise_log.txt",
|
||||
"rollingInterval": "Day"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user