Psql implement done + models for many-to-many relationships + Buisness logic and forms for materials (testing purpouses)
This commit is contained in:
parent
1a0cb1756b
commit
49325d73b2
@ -11,6 +11,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConstructionCompanyContract
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConstructionCompanyBusinessLogic", "ConstructionCompanyBusiness\ConstructionCompanyBusinessLogic.csproj", "{FB447245-07E1-4E0D-A4FC-701E295B7575}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConstructionCompanyPsqlImplement", "ConstructionCompanyPsqlImplement\ConstructionCompanyPsqlImplement.csproj", "{A92A2186-2021-4B42-B632-447A45EC3A58}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@ -33,6 +35,10 @@ Global
|
||||
{FB447245-07E1-4E0D-A4FC-701E295B7575}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FB447245-07E1-4E0D-A4FC-701E295B7575}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FB447245-07E1-4E0D-A4FC-701E295B7575}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A92A2186-2021-4B42-B632-447A45EC3A58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A92A2186-2021-4B42-B632-447A45EC3A58}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A92A2186-2021-4B42-B632-447A45EC3A58}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A92A2186-2021-4B42-B632-447A45EC3A58}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -0,0 +1,110 @@
|
||||
using ConstructionCompanyContracts.BindingModels;
|
||||
using ConstructionCompanyContracts.BusinessLogicContracts;
|
||||
using ConstructionCompanyContracts.SearchModels;
|
||||
using ConstructionCompanyContracts.StorageContracts;
|
||||
using ConstructionCompanyContracts.ViewModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionCompanyBusinessLogic.BusinessLogics
|
||||
{
|
||||
public class MaterialLogic : IMaterialLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IMaterialStorage _materialStorage;
|
||||
|
||||
public MaterialLogic(ILogger<MaterialLogic> logger, IMaterialStorage materialStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_materialStorage = materialStorage;
|
||||
}
|
||||
|
||||
public List<MaterialViewModel>? ReadList(MaterialSearchModel? model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. MaterialName:{MaterialName}. Id:{Id}", model?.MaterialName, model?.Id);
|
||||
var list = model == null ? _materialStorage.GetFullList() : _materialStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
|
||||
public MaterialViewModel? ReadElement(MaterialSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. MaterialName:{MaterialName}. Id:{Id}", model.MaterialName, model.Id);
|
||||
var element = _materialStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
|
||||
public bool Create(MaterialBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_materialStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(MaterialBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_materialStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(MaterialBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_materialStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(MaterialBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.MaterialName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия материала", nameof(model.MaterialName));
|
||||
}
|
||||
if (model.Quantity < 0)
|
||||
{
|
||||
throw new ArgumentNullException("Количество материалов должна быть не меньше 0!", nameof(model.Quantity));
|
||||
}
|
||||
_logger.LogInformation("Material. IngredietnName:{MaterialName}. Cost:{Quantity}. Id:{Id}", model.MaterialName, model.Quantity, model.Id);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ConstructionCompanyContracts\ConstructionCompanyContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,15 @@
|
||||
using ConstructionCompanyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionCompanyContracts.BindingModels
|
||||
{
|
||||
public class EmployeeOrderBindingModel : IEmployeeOrderModel
|
||||
{
|
||||
public int EmployeeId { get; set; }
|
||||
public int OrderId { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
using ConstructionCompanyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionCompanyContracts.BindingModels
|
||||
{
|
||||
public class MaterialOrderBindingModel : IMaterialOrderModel
|
||||
{
|
||||
public int MaterialId { get; set; }
|
||||
public int OrderId { get; set; }
|
||||
public int Quantity { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using ConstructionCompanyContracts.BindingModels;
|
||||
using ConstructionCompanyContracts.SearchModels;
|
||||
using ConstructionCompanyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionCompanyContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IEmployeeOrderLogic
|
||||
{
|
||||
List<EmployeeOrderViewModel>? ReadList(EmployeeOrderSearchModel? model);
|
||||
EmployeeOrderViewModel? ReadElement(EmployeeOrderSearchModel model);
|
||||
bool Create(EmployeeOrderBindingModel model);
|
||||
bool Update(EmployeeOrderBindingModel model);
|
||||
bool Delete(EmployeeOrderBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using ConstructionCompanyContracts.BindingModels;
|
||||
using ConstructionCompanyContracts.SearchModels;
|
||||
using ConstructionCompanyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionCompanyContracts.BusinessLogicContracts
|
||||
{
|
||||
public interface IMaterialOrderLogic
|
||||
{
|
||||
List<MaterialOrderViewModel>? ReadList(MaterialOrderSearchModel? model);
|
||||
MaterialOrderViewModel? ReadElement(MaterialOrderSearchModel model);
|
||||
bool Create(MaterialOrderBindingModel model);
|
||||
bool Update(MaterialOrderBindingModel model);
|
||||
bool Delete(MaterialOrderBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionCompanyContracts.SearchModels
|
||||
{
|
||||
public class EmployeeOrderSearchModel
|
||||
{
|
||||
public int? EmployeeId { get; set; }
|
||||
public int? OrderId { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionCompanyContracts.SearchModels
|
||||
{
|
||||
public class MaterialOrderSearchModel
|
||||
{
|
||||
public int? MaterialId { get; set; }
|
||||
public int? OrderId { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using ConstructionCompanyContracts.BindingModels;
|
||||
using ConstructionCompanyContracts.SearchModels;
|
||||
using ConstructionCompanyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionCompanyContracts.StorageContracts
|
||||
{
|
||||
public interface IEmployeeOrderStorage
|
||||
{
|
||||
List<EmployeeOrderViewModel> GetFullList();
|
||||
List<EmployeeOrderViewModel> GetFilteredList(EmployeeOrderSearchModel model);
|
||||
EmployeeOrderViewModel? GetElement(EmployeeOrderSearchModel model);
|
||||
EmployeeOrderViewModel? Insert(EmployeeOrderBindingModel model);
|
||||
EmployeeOrderViewModel? Delete(EmployeeOrderBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using ConstructionCompanyContracts.BindingModels;
|
||||
using ConstructionCompanyContracts.SearchModels;
|
||||
using ConstructionCompanyContracts.ViewModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionCompanyContracts.StorageContracts
|
||||
{
|
||||
public interface IMaterialOrderStorage
|
||||
{
|
||||
List<MaterialOrderViewModel> GetFullList();
|
||||
List<MaterialOrderViewModel> GetFilteredList(MaterialOrderSearchModel model);
|
||||
MaterialOrderViewModel? GetElement(MaterialOrderSearchModel model);
|
||||
MaterialOrderViewModel? Insert(MaterialOrderBindingModel model);
|
||||
MaterialOrderViewModel? Delete(MaterialOrderBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
using ConstructionCompanyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionCompanyContracts.ViewModels
|
||||
{
|
||||
public class EmployeeOrderViewModel : IEmployeeOrderModel
|
||||
{
|
||||
public int EmployeeId { get; set; }
|
||||
[DisplayName("ФИО сотрудника")]
|
||||
public string EmployeeName { get; set; } = string.Empty;
|
||||
public int OrderId { get; set; }
|
||||
[DisplayName("Адресс заказа")]
|
||||
public string OrderAdress { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using ConstructionCompanyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionCompanyContracts.ViewModels
|
||||
{
|
||||
public class MaterialOrderViewModel : IMaterialOrderModel
|
||||
{
|
||||
public int MaterialId { get; set; }
|
||||
[DisplayName("Название материала")]
|
||||
public string MaterialName { get; set; } = string.Empty;
|
||||
public int OrderId { get; set; }
|
||||
[DisplayName("Адресс заказа")]
|
||||
public string OrderAdress { get; set; } = string.Empty;
|
||||
[DisplayName("Количество")]
|
||||
public int Quantity { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionCompanyDataModels.Models
|
||||
{
|
||||
public interface IEmployeeOrderModel
|
||||
{
|
||||
int EmployeeId { get; }
|
||||
int OrderId { get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionCompanyDataModels.Models
|
||||
{
|
||||
public interface IMaterialOrderModel
|
||||
{
|
||||
int MaterialId { get; }
|
||||
int OrderId { get; }
|
||||
int Quantity { get; }
|
||||
}
|
||||
}
|
@ -0,0 +1,208 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ConstructionCompanyPsqlImplement.Models;
|
||||
using ConstructionCompanyContracts.BindingModels;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Npgsql;
|
||||
using ConstructionCompanyDataModels.Enums;
|
||||
|
||||
namespace ConstructionCompanyPsqlImplement
|
||||
{
|
||||
public class ConstructionCompanyDatabase
|
||||
{
|
||||
static string connectionString = "Server=192.168.1.35;Port=5432;Database=ConstructionCompanyForwardEngineerd;User Id=postgres;Password=postgres;";
|
||||
|
||||
private static ConstructionCompanyDatabase? _instance;
|
||||
private List<Material> _materials = new List<Material>();
|
||||
private List<Employee> _employees = new List<Employee>();
|
||||
private List<Position> _positions = new List<Position>();
|
||||
private List<Order> _orders = new List<Order>();
|
||||
private List<EmployeeOrder> _employeeOrders = new List<EmployeeOrder>();
|
||||
private List<MaterialOrder> _materialOrders = new List<MaterialOrder>();
|
||||
public List<Material> Materials
|
||||
{
|
||||
get
|
||||
{
|
||||
refreshDb();
|
||||
return _materials;
|
||||
}
|
||||
}
|
||||
public List<Employee> Employees
|
||||
{
|
||||
get
|
||||
{
|
||||
refreshDb();
|
||||
return _employees;
|
||||
}
|
||||
}
|
||||
public List<Position> Positions
|
||||
{
|
||||
get
|
||||
{
|
||||
refreshDb();
|
||||
return _positions;
|
||||
}
|
||||
}
|
||||
public List<Order> Orders
|
||||
{
|
||||
get
|
||||
{
|
||||
refreshDb();
|
||||
return _orders;
|
||||
}
|
||||
}
|
||||
|
||||
public List<EmployeeOrder> EmployeeOrders
|
||||
{
|
||||
get
|
||||
{
|
||||
refreshDb();
|
||||
return _employeeOrders;
|
||||
}
|
||||
}
|
||||
|
||||
public List<MaterialOrder> MaterialOrders
|
||||
{
|
||||
get
|
||||
{
|
||||
refreshDb();
|
||||
return _materialOrders;
|
||||
}
|
||||
}
|
||||
|
||||
public static ConstructionCompanyDatabase GetInstance()
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
_instance = new ConstructionCompanyDatabase();
|
||||
}
|
||||
return _instance;
|
||||
}
|
||||
|
||||
public void ExecuteSql(string commandString)
|
||||
{
|
||||
using var connection = new NpgsqlConnection(connectionString);
|
||||
connection.Open();
|
||||
using var command = connection.CreateCommand();
|
||||
command.CommandText = commandString;
|
||||
command.ExecuteNonQuery();
|
||||
refreshDb();
|
||||
connection.Close();
|
||||
}
|
||||
|
||||
private void refreshDb()
|
||||
{
|
||||
_materials.Clear();
|
||||
_positions.Clear();
|
||||
_employees.Clear();
|
||||
_orders.Clear();
|
||||
_employeeOrders.Clear();
|
||||
_materialOrders.Clear();
|
||||
using var connection = new NpgsqlConnection(connectionString);
|
||||
connection.Open();
|
||||
|
||||
using var commandMaterials = connection.CreateCommand();
|
||||
commandMaterials.CommandText = "SELECT * FROM material;";
|
||||
using var readerMaterials = commandMaterials.ExecuteReader();
|
||||
while (readerMaterials.Read())
|
||||
{
|
||||
int id = readerMaterials.GetInt32(0);
|
||||
string name = readerMaterials.GetString(1);
|
||||
int quantity = readerMaterials.GetInt32(2);
|
||||
Material? mat = Material.Create(new MaterialBindingModel { Id = id, MaterialName = name, Quantity = quantity });
|
||||
if (mat != null) _materials.Add(mat);
|
||||
}
|
||||
readerMaterials.Close();
|
||||
|
||||
using var commandPositions = connection.CreateCommand();
|
||||
commandPositions.CommandText = "SELECT * FROM position;";
|
||||
using var readerPositions = commandPositions.ExecuteReader();
|
||||
while (readerPositions.Read())
|
||||
{
|
||||
int id = readerPositions.GetInt32(0);
|
||||
string name = readerPositions.GetString(1);
|
||||
double salary = readerPositions.GetDouble(2);
|
||||
Position? position = Position.Create(new PositionBindingModel { Id = id, PositionName = name, Salary = salary });
|
||||
if (position != null) _positions.Add(position);
|
||||
}
|
||||
readerPositions.Close();
|
||||
|
||||
using var commandEmployees = connection.CreateCommand();
|
||||
commandEmployees.CommandText = "SELECT * FROM employee;";
|
||||
using var readerEmployees = commandEmployees.ExecuteReader();
|
||||
while (readerEmployees.Read())
|
||||
{
|
||||
int id = readerEmployees.GetInt32(0);
|
||||
string name = readerEmployees.GetString(1);
|
||||
int positionId = readerEmployees.GetInt32(2);
|
||||
Employee? employee = Employee.Create(new EmployeeBindingModel { Id = id, EmployeeName = name, PositionID = positionId }, _positions);
|
||||
if (employee != null) _employees.Add(employee);
|
||||
}
|
||||
readerEmployees.Close();
|
||||
|
||||
using var commandOrders = connection.CreateCommand();
|
||||
commandOrders.CommandText = "SELECT * FROM \"order\";";
|
||||
using var readerOrders = commandOrders.ExecuteReader();
|
||||
while (readerOrders.Read())
|
||||
{
|
||||
int id = readerOrders.GetInt32(0);
|
||||
string description = readerOrders.GetString(1);
|
||||
string adress = readerOrders.GetString(2);
|
||||
double price = readerOrders.GetDouble(3);
|
||||
string statusString = readerOrders.GetString(4);
|
||||
OrderStatus status;
|
||||
switch (statusString)
|
||||
{
|
||||
case "Принят":
|
||||
status = OrderStatus.Принят;
|
||||
break;
|
||||
case "Выполняется":
|
||||
status = OrderStatus.Выполняется;
|
||||
break;
|
||||
case "Завершён":
|
||||
status = OrderStatus.Завершён;
|
||||
break;
|
||||
default:
|
||||
status = OrderStatus.Неизвестен;
|
||||
break;
|
||||
}
|
||||
string customerNumber = readerOrders.GetString(5);
|
||||
DateTime dateBegin = readerOrders.GetDateTime(6);
|
||||
DateTime? dateEnd = readerOrders.GetDateTime(7);
|
||||
Order? order = Order.Create(new OrderBindingModel { Id = id, Description = description, Adress = adress, Price = price, Status = status, CustomerNumber = customerNumber, DateBegin = dateBegin, DateEnd = dateEnd});
|
||||
if (order != null) _orders.Add(order);
|
||||
}
|
||||
readerOrders.Close();
|
||||
|
||||
using var commandEmployeeOrders = connection.CreateCommand();
|
||||
commandEmployeeOrders.CommandText = "SELECT * FROM employee_order;";
|
||||
using var readerEmployeeOrders = commandEmployeeOrders.ExecuteReader();
|
||||
while (readerEmployeeOrders.Read())
|
||||
{
|
||||
int employeeId = readerEmployeeOrders.GetInt32(0);
|
||||
int orderId = readerEmployeeOrders.GetInt32(1);
|
||||
EmployeeOrder? employeeOrder = EmployeeOrder.Create(new EmployeeOrderBindingModel { EmployeeId = employeeId, OrderId = orderId}, _employees, _orders);
|
||||
if (employeeOrder != null) _employeeOrders.Add(employeeOrder);
|
||||
}
|
||||
readerEmployeeOrders.Close();
|
||||
|
||||
using var commandMaterialOrders = connection.CreateCommand();
|
||||
commandMaterialOrders.CommandText = "SELECT * FROM material_order;";
|
||||
using var readerMaterialOrders = commandMaterialOrders.ExecuteReader();
|
||||
while (readerMaterialOrders.Read())
|
||||
{
|
||||
int materialId = readerMaterialOrders.GetInt32(0);
|
||||
int orderId = readerMaterialOrders.GetInt32(1);
|
||||
int quantity = readerMaterialOrders.GetInt32(2);
|
||||
MaterialOrder? materialOrder = MaterialOrder.Create(new MaterialOrderBindingModel { MaterialId = materialId, OrderId = orderId, Quantity = quantity}, _materials, _orders);
|
||||
if (materialOrder != null) _materialOrders.Add(materialOrder);
|
||||
}
|
||||
readerMaterialOrders.Close();
|
||||
|
||||
connection.Close();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<UserSecretsId>9152d6ad-e687-4e3f-836c-fd7263918b1d</UserSecretsId>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Npgsql" Version="7.0.2" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="7.0.3" />
|
||||
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.NodaTime" Version="7.0.3" />
|
||||
<PackageReference Include="Npgsql.NodaTime" Version="7.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ConstructionCompanyContracts\ConstructionCompanyContracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -0,0 +1,78 @@
|
||||
using ConstructionCompanyContracts.BindingModels;
|
||||
using ConstructionCompanyContracts.SearchModels;
|
||||
using ConstructionCompanyContracts.StorageContracts;
|
||||
using ConstructionCompanyContracts.ViewModels;
|
||||
using ConstructionCompanyPsqlImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionCompanyPsqlImplement.Implements
|
||||
{
|
||||
public class EmployeeOrderStorage : IEmployeeOrderStorage
|
||||
{
|
||||
private readonly ConstructionCompanyDatabase _source;
|
||||
public EmployeeOrderStorage()
|
||||
{
|
||||
_source = ConstructionCompanyDatabase.GetInstance();
|
||||
}
|
||||
public List<EmployeeOrderViewModel> GetFullList()
|
||||
{
|
||||
List<EmployeeOrderViewModel> result = new List<EmployeeOrderViewModel>();
|
||||
foreach (var material in _source.EmployeeOrders)
|
||||
{
|
||||
result.Add(material.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<EmployeeOrderViewModel> GetFilteredList(EmployeeOrderSearchModel model)
|
||||
{
|
||||
if (model == null || !model.OrderId.HasValue || !model.EmployeeId.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
List<EmployeeOrderViewModel> result = new List<EmployeeOrderViewModel>();
|
||||
foreach (var material in _source.EmployeeOrders)
|
||||
{
|
||||
if (material.EmployeeId == model.EmployeeId && material.OrderId == model.OrderId) result.Add(material.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public EmployeeOrderViewModel? GetElement(EmployeeOrderSearchModel model)
|
||||
{
|
||||
if (model == null || !model.OrderId.HasValue || !model.EmployeeId.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return _source.EmployeeOrders.FirstOrDefault(x => x.EmployeeId == model.EmployeeId && x.OrderId == model.OrderId)?.GetViewModel;
|
||||
}
|
||||
|
||||
public EmployeeOrderViewModel? Insert(EmployeeOrderBindingModel model)
|
||||
{
|
||||
var command = EmployeeOrder.CreateCommand(model);
|
||||
if (string.IsNullOrEmpty(command))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.ExecuteSql(command);
|
||||
var newEmployeeOrder = _source.EmployeeOrders[_source.EmployeeOrders.Count - 1];
|
||||
return newEmployeeOrder.GetViewModel;
|
||||
}
|
||||
|
||||
public EmployeeOrderViewModel? Delete(EmployeeOrderBindingModel model)
|
||||
{
|
||||
var command = EmployeeOrder.DeleteCommand(model);
|
||||
if (string.IsNullOrEmpty(command))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var deletedEmployeeOrder = _source.EmployeeOrders.First(x => x.EmployeeId == model.EmployeeId && x.OrderId == model.OrderId).GetViewModel;
|
||||
_source.ExecuteSql(command);
|
||||
return deletedEmployeeOrder;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
using ConstructionCompanyContracts.BindingModels;
|
||||
using ConstructionCompanyContracts.SearchModels;
|
||||
using ConstructionCompanyContracts.StorageContracts;
|
||||
using ConstructionCompanyContracts.ViewModels;
|
||||
using ConstructionCompanyPsqlImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionCompanyPsqlImplement.Implements
|
||||
{
|
||||
public class EmployeeStorage : IEmployeeStorage
|
||||
{
|
||||
private readonly ConstructionCompanyDatabase _source;
|
||||
public EmployeeStorage()
|
||||
{
|
||||
_source = ConstructionCompanyDatabase.GetInstance();
|
||||
}
|
||||
public List<EmployeeViewModel> GetFullList()
|
||||
{
|
||||
List<EmployeeViewModel> result = new List<EmployeeViewModel>();
|
||||
foreach (var material in _source.Employees)
|
||||
{
|
||||
result.Add(material.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<EmployeeViewModel> GetFilteredList(EmployeeSearchModel model)
|
||||
{
|
||||
if (model == null || !model.Id.HasValue && string.IsNullOrEmpty(model.EmployeeName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
List<EmployeeViewModel> result = new List<EmployeeViewModel>();
|
||||
if (!string.IsNullOrEmpty(model.EmployeeName))
|
||||
{
|
||||
foreach (var material in _source.Employees)
|
||||
{
|
||||
if (material.EmployeeName.Equals(model.EmployeeName)) result.Add(material.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var material in _source.Employees)
|
||||
{
|
||||
if (material.Id == model.Id) result.Add(material.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public EmployeeViewModel? GetElement(EmployeeSearchModel model)
|
||||
{
|
||||
if (model == null || !model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return _source.Employees.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public EmployeeViewModel? Insert(EmployeeBindingModel model)
|
||||
{
|
||||
var command = Employee.CreateCommand(model);
|
||||
if (string.IsNullOrEmpty(command))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.ExecuteSql(command);
|
||||
var newEmployee = _source.Employees[_source.Employees.Count - 1];
|
||||
return newEmployee.GetViewModel;
|
||||
}
|
||||
|
||||
public EmployeeViewModel? Update(EmployeeBindingModel model)
|
||||
{
|
||||
var command = Employee.UpdateCommand(model);
|
||||
if (string.IsNullOrEmpty(command))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.ExecuteSql(command);
|
||||
var updatedEmployee = _source.Employees.First(x => x.Id == model.Id);
|
||||
return updatedEmployee.GetViewModel;
|
||||
}
|
||||
|
||||
public EmployeeViewModel? Delete(EmployeeBindingModel model)
|
||||
{
|
||||
var command = Employee.DeleteCommand(model);
|
||||
if (string.IsNullOrEmpty(command))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var deletedEmployee = _source.Employees.First(x => x.Id == model.Id).GetViewModel;
|
||||
_source.ExecuteSql(command);
|
||||
return deletedEmployee;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
using ConstructionCompanyContracts.BindingModels;
|
||||
using ConstructionCompanyContracts.BusinessLogicContracts;
|
||||
using ConstructionCompanyContracts.SearchModels;
|
||||
using ConstructionCompanyContracts.StorageContracts;
|
||||
using ConstructionCompanyContracts.ViewModels;
|
||||
using ConstructionCompanyPsqlImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionCompanyPsqlImplement.Implements
|
||||
{
|
||||
public class MaterialOrderStorage : IMaterialOrderStorage
|
||||
{
|
||||
private readonly ConstructionCompanyDatabase _source;
|
||||
public MaterialOrderStorage()
|
||||
{
|
||||
_source = ConstructionCompanyDatabase.GetInstance();
|
||||
}
|
||||
public List<MaterialOrderViewModel> GetFullList()
|
||||
{
|
||||
List<MaterialOrderViewModel> result = new List<MaterialOrderViewModel>();
|
||||
foreach (var material in _source.MaterialOrders)
|
||||
{
|
||||
result.Add(material.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<MaterialOrderViewModel> GetFilteredList(MaterialOrderSearchModel model)
|
||||
{
|
||||
if (model == null || !model.OrderId.HasValue || !model.MaterialId.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
List<MaterialOrderViewModel> result = new List<MaterialOrderViewModel>();
|
||||
foreach (var material in _source.MaterialOrders)
|
||||
{
|
||||
if (material.MaterialId == model.MaterialId && material.OrderId == model.OrderId) result.Add(material.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public MaterialOrderViewModel? GetElement(MaterialOrderSearchModel model)
|
||||
{
|
||||
if (model == null || !model.OrderId.HasValue || !model.MaterialId.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return _source.MaterialOrders.FirstOrDefault(x => x.MaterialId == model.MaterialId && x.OrderId == model.OrderId)?.GetViewModel;
|
||||
}
|
||||
|
||||
public MaterialOrderViewModel? Insert(MaterialOrderBindingModel model)
|
||||
{
|
||||
var command = MaterialOrder.CreateCommand(model);
|
||||
if (string.IsNullOrEmpty(command))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.ExecuteSql(command);
|
||||
var newMaterialOrder = _source.MaterialOrders[_source.MaterialOrders.Count - 1];
|
||||
return newMaterialOrder.GetViewModel;
|
||||
}
|
||||
|
||||
public MaterialOrderViewModel? Delete(MaterialOrderBindingModel model)
|
||||
{
|
||||
var command = MaterialOrder.DeleteCommand(model);
|
||||
if (string.IsNullOrEmpty(command))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var deletedMaterialOrder = _source.MaterialOrders.First(x => x.MaterialId == model.MaterialId && x.OrderId == model.OrderId).GetViewModel;
|
||||
_source.ExecuteSql(command);
|
||||
return deletedMaterialOrder;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
using ConstructionCompanyContracts.BindingModels;
|
||||
using ConstructionCompanyContracts.SearchModels;
|
||||
using ConstructionCompanyContracts.StorageContracts;
|
||||
using ConstructionCompanyContracts.ViewModels;
|
||||
using ConstructionCompanyPsqlImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionCompanyPsqlImplement.Implements
|
||||
{
|
||||
public class MaterialStorage : IMaterialStorage
|
||||
{
|
||||
private readonly ConstructionCompanyDatabase _source;
|
||||
public MaterialStorage()
|
||||
{
|
||||
_source = ConstructionCompanyDatabase.GetInstance();
|
||||
}
|
||||
public List<MaterialViewModel> GetFullList()
|
||||
{
|
||||
List<MaterialViewModel> result = new List<MaterialViewModel>();
|
||||
foreach (var material in _source.Materials)
|
||||
{
|
||||
result.Add(material.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<MaterialViewModel> GetFilteredList(MaterialSearchModel model)
|
||||
{
|
||||
if (model == null || !model.Id.HasValue || string.IsNullOrEmpty(model.MaterialName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
List<MaterialViewModel> result = new List<MaterialViewModel>();
|
||||
if (!string.IsNullOrEmpty(model.MaterialName))
|
||||
{
|
||||
foreach (var material in _source.Materials)
|
||||
{
|
||||
if (material.MaterialName.Equals(model.MaterialName)) result.Add(material.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var material in _source.Materials)
|
||||
{
|
||||
if (material.Id == model.Id) result.Add(material.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public MaterialViewModel? GetElement(MaterialSearchModel model)
|
||||
{
|
||||
if (model == null || !model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return _source.Materials.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public MaterialViewModel? Insert(MaterialBindingModel model)
|
||||
{
|
||||
var command = Material.CreateCommand(model);
|
||||
if (string.IsNullOrEmpty(command))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.ExecuteSql(command);
|
||||
var newMaterial = _source.Materials[_source.Materials.Count - 1];
|
||||
return newMaterial.GetViewModel;
|
||||
}
|
||||
|
||||
public MaterialViewModel? Update(MaterialBindingModel model)
|
||||
{
|
||||
var command = Material.UpdateCommand(model);
|
||||
if (string.IsNullOrEmpty(command))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.ExecuteSql(command);
|
||||
var updatedMaterial = _source.Materials.First(x => x.Id == model.Id);
|
||||
return updatedMaterial.GetViewModel;
|
||||
}
|
||||
|
||||
public MaterialViewModel? Delete(MaterialBindingModel model)
|
||||
{
|
||||
var command = Material.DeleteCommand(model);
|
||||
if (string.IsNullOrEmpty(command))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var deletedMaterial = _source.Materials.First(x => x.Id == model.Id).GetViewModel;
|
||||
_source.ExecuteSql(command);
|
||||
return deletedMaterial;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
using ConstructionCompanyContracts.BindingModels;
|
||||
using ConstructionCompanyContracts.SearchModels;
|
||||
using ConstructionCompanyContracts.StorageContracts;
|
||||
using ConstructionCompanyContracts.ViewModels;
|
||||
using ConstructionCompanyPsqlImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionCompanyPsqlImplement.Implements
|
||||
{
|
||||
public class OrderStorage : IOrderStorage
|
||||
{
|
||||
private readonly ConstructionCompanyDatabase _source;
|
||||
public OrderStorage()
|
||||
{
|
||||
_source = ConstructionCompanyDatabase.GetInstance();
|
||||
}
|
||||
public List<OrderViewModel> GetFullList()
|
||||
{
|
||||
List<OrderViewModel> result = new List<OrderViewModel>();
|
||||
foreach (var material in _source.Orders)
|
||||
{
|
||||
result.Add(material.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||
{
|
||||
if (model == null || !model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
List<OrderViewModel> result = new List<OrderViewModel>();
|
||||
foreach (var material in _source.Orders)
|
||||
{
|
||||
if (material.Id == model.Id) result.Add(material.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||
{
|
||||
if (model == null || !model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return _source.Orders.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
{
|
||||
var command = Order.CreateCommand(model);
|
||||
if (string.IsNullOrEmpty(command))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.ExecuteSql(command);
|
||||
var newOrder = _source.Orders[_source.Orders.Count - 1];
|
||||
return newOrder.GetViewModel;
|
||||
}
|
||||
|
||||
public OrderViewModel? Update(OrderBindingModel model)
|
||||
{
|
||||
var command = Order.UpdateCommand(model);
|
||||
if (string.IsNullOrEmpty(command))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.ExecuteSql(command);
|
||||
var updatedOrder = _source.Orders.First(x => x.Id == model.Id);
|
||||
return updatedOrder.GetViewModel;
|
||||
}
|
||||
|
||||
public OrderViewModel? Delete(OrderBindingModel model)
|
||||
{
|
||||
var command = Order.DeleteCommand(model);
|
||||
if (string.IsNullOrEmpty(command))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var deletedOrder = _source.Orders.First(x => x.Id == model.Id).GetViewModel;
|
||||
_source.ExecuteSql(command);
|
||||
return deletedOrder;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
using ConstructionCompanyContracts.BindingModels;
|
||||
using ConstructionCompanyContracts.SearchModels;
|
||||
using ConstructionCompanyContracts.StorageContracts;
|
||||
using ConstructionCompanyContracts.ViewModels;
|
||||
using ConstructionCompanyPsqlImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionCompanyPsqlImplement.Implements
|
||||
{
|
||||
public class PositionStorage : IPositionStorage
|
||||
{
|
||||
private readonly ConstructionCompanyDatabase _source;
|
||||
public PositionStorage()
|
||||
{
|
||||
_source = ConstructionCompanyDatabase.GetInstance();
|
||||
}
|
||||
public List<PositionViewModel> GetFullList()
|
||||
{
|
||||
List<PositionViewModel> result = new List<PositionViewModel>();
|
||||
foreach (var material in _source.Positions)
|
||||
{
|
||||
result.Add(material.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public List<PositionViewModel> GetFilteredList(PositionSearchModel model)
|
||||
{
|
||||
if (model == null || !model.Id.HasValue && string.IsNullOrEmpty(model.PositionName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
List<PositionViewModel> result = new List<PositionViewModel>();
|
||||
if (!string.IsNullOrEmpty(model.PositionName))
|
||||
{
|
||||
foreach (var material in _source.Positions)
|
||||
{
|
||||
if (material.PositionName.Equals(model.PositionName)) result.Add(material.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var material in _source.Positions)
|
||||
{
|
||||
if (material.Id == model.Id) result.Add(material.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public PositionViewModel? GetElement(PositionSearchModel model)
|
||||
{
|
||||
if (model == null || !model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
return _source.Positions.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public PositionViewModel? Insert(PositionBindingModel model)
|
||||
{
|
||||
var command = Position.CreateCommand(model);
|
||||
if (string.IsNullOrEmpty(command))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.ExecuteSql(command);
|
||||
var newPosition = _source.Positions[_source.Positions.Count - 1];
|
||||
return newPosition.GetViewModel;
|
||||
}
|
||||
|
||||
public PositionViewModel? Update(PositionBindingModel model)
|
||||
{
|
||||
var command = Position.UpdateCommand(model);
|
||||
if (string.IsNullOrEmpty(command))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.ExecuteSql(command);
|
||||
var updatedPosition = _source.Positions.First(x => x.Id == model.Id);
|
||||
return updatedPosition.GetViewModel;
|
||||
}
|
||||
|
||||
public PositionViewModel? Delete(PositionBindingModel model)
|
||||
{
|
||||
var command = Position.DeleteCommand(model);
|
||||
if (string.IsNullOrEmpty(command))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var deletedPosition = _source.Positions.First(x => x.Id == model.Id).GetViewModel;
|
||||
_source.ExecuteSql(command);
|
||||
return deletedPosition;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
using ConstructionCompanyContracts.BindingModels;
|
||||
using ConstructionCompanyContracts.ViewModels;
|
||||
using ConstructionCompanyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionCompanyPsqlImplement.Models
|
||||
{
|
||||
public class Employee : IEmployeeModel
|
||||
{
|
||||
public string EmployeeName { get; private set; } = string.Empty;
|
||||
|
||||
public int Id { get; private set; }
|
||||
public int PositionID { get; private set; }
|
||||
public Position Position { get; set; } = new();
|
||||
|
||||
public static Employee? Create(EmployeeBindingModel? model, List<Position> positions)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Employee()
|
||||
{
|
||||
Id = model.Id,
|
||||
EmployeeName = model.EmployeeName,
|
||||
PositionID = model.PositionID,
|
||||
Position = positions.First(x => x.Id == model.PositionID)
|
||||
};
|
||||
}
|
||||
public void Update(EmployeeBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
EmployeeName = model.EmployeeName;
|
||||
PositionID = model.PositionID;
|
||||
}
|
||||
public static string CreateCommand(EmployeeBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return $"INSERT INTO employee(name, position_id) VALUES(\'{model.EmployeeName}\', {model.PositionID});";
|
||||
}
|
||||
public static string UpdateCommand(EmployeeBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return $"UPDATE employee SET \"name\" = \'{model.EmployeeName}\', position_id = {model.PositionID} WHERE id = {model.Id}";
|
||||
}
|
||||
public static string DeleteCommand(EmployeeBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return $"DELETE FROM employee WHERE id = {model.Id}";
|
||||
}
|
||||
|
||||
public EmployeeViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
EmployeeName = EmployeeName,
|
||||
PositionID = PositionID,
|
||||
PositionName = Position.PositionName
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
using ConstructionCompanyContracts.BindingModels;
|
||||
using ConstructionCompanyContracts.ViewModels;
|
||||
using ConstructionCompanyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionCompanyPsqlImplement.Models
|
||||
{
|
||||
public class EmployeeOrder : IEmployeeOrderModel
|
||||
{
|
||||
public int EmployeeId { get; set; }
|
||||
public int OrderId { get; set; }
|
||||
public Employee Employee { get; set; } = new();
|
||||
public Order Order { get; set; } = new();
|
||||
public static EmployeeOrder? Create(EmployeeOrderBindingModel? model, List<Employee> employees, List<Order> orders)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new EmployeeOrder()
|
||||
{
|
||||
EmployeeId = model.EmployeeId,
|
||||
OrderId = model.OrderId,
|
||||
Employee = employees.First(x => x.Id == model.EmployeeId),
|
||||
Order = orders.First(x => x.Id == model.OrderId),
|
||||
};
|
||||
}
|
||||
public static string CreateCommand(EmployeeOrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return $"INSERT INTO employee_order(employee_id, order_id) VALUES({model.EmployeeId}, {model.OrderId});";
|
||||
}
|
||||
public static string DeleteCommand(EmployeeOrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return $"DELETE FROM material WHERE employee_id = {model.EmployeeId} AND order_id = {model.OrderId}";
|
||||
}
|
||||
public EmployeeOrderViewModel GetViewModel => new()
|
||||
{
|
||||
OrderId = OrderId,
|
||||
EmployeeId = EmployeeId,
|
||||
OrderAdress = Order.Adress,
|
||||
EmployeeName = Employee.EmployeeName
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,73 @@
|
||||
using ConstructionCompanyContracts.BindingModels;
|
||||
using ConstructionCompanyContracts.ViewModels;
|
||||
using ConstructionCompanyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionCompanyPsqlImplement.Models
|
||||
{
|
||||
public class Material : IMaterialModel
|
||||
{
|
||||
public string MaterialName {get; private set;} = string.Empty;
|
||||
|
||||
public int Quantity { get; set; }
|
||||
|
||||
public int Id { get; private set; }
|
||||
|
||||
public static Material? Create(MaterialBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Material()
|
||||
{
|
||||
Id = model.Id,
|
||||
MaterialName = model.MaterialName,
|
||||
Quantity = model.Quantity
|
||||
};
|
||||
}
|
||||
public static string CreateCommand(MaterialBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return $"INSERT INTO material(name, quantity) VALUES(\'{model.MaterialName}\', {model.Quantity});";
|
||||
}
|
||||
public static string UpdateCommand(MaterialBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return $"UPDATE material SET \"name\" = \'{model.MaterialName}\', quantity = {model.Quantity} WHERE id = {model.Id}";
|
||||
}
|
||||
public static string DeleteCommand(MaterialBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return $"DELETE FROM material WHERE id = {model.Id}";
|
||||
}
|
||||
public void Update(MaterialBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
MaterialName = model.MaterialName;
|
||||
Quantity = model.Quantity;
|
||||
}
|
||||
public MaterialViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
MaterialName = MaterialName,
|
||||
Quantity = Quantity
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
using ConstructionCompanyContracts.BindingModels;
|
||||
using ConstructionCompanyContracts.ViewModels;
|
||||
using ConstructionCompanyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionCompanyPsqlImplement.Models
|
||||
{
|
||||
public class MaterialOrder : IMaterialOrderModel
|
||||
{
|
||||
public int MaterialId { get; set; }
|
||||
public int OrderId { get; set; }
|
||||
public int Quantity { get; set; }
|
||||
public Material Material { get; set; } = new();
|
||||
public Order Order { get; set; } = new();
|
||||
public static MaterialOrder? Create(MaterialOrderBindingModel? model, List<Material> materials, List<Order> orders)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new MaterialOrder()
|
||||
{
|
||||
MaterialId = model.MaterialId,
|
||||
OrderId = model.OrderId,
|
||||
Quantity = model.Quantity,
|
||||
Material = materials.First(x => x.Id == model.MaterialId),
|
||||
Order = orders.First(x => x.Id == model.OrderId),
|
||||
};
|
||||
}
|
||||
public static string CreateCommand(MaterialOrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return $"INSERT INTO material_order(material_id, order_id, quantity) VALUES({model.MaterialId}, {model.OrderId}, {model.Quantity});";
|
||||
}
|
||||
public static string DeleteCommand(MaterialOrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return $"DELETE FROM material WHERE material_id = {model.MaterialId} AND order_id = {model.OrderId}";
|
||||
}
|
||||
public MaterialOrderViewModel GetViewModel => new()
|
||||
{
|
||||
OrderId = OrderId,
|
||||
MaterialId = MaterialId,
|
||||
Quantity = Quantity,
|
||||
OrderAdress = Order.Adress,
|
||||
MaterialName = Material.MaterialName
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
using ConstructionCompanyContracts.BindingModels;
|
||||
using ConstructionCompanyContracts.ViewModels;
|
||||
using ConstructionCompanyDataModels.Enums;
|
||||
using ConstructionCompanyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionCompanyPsqlImplement.Models
|
||||
{
|
||||
public class Order : IOrderModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string Description { get; private set; } = string.Empty;
|
||||
public string Adress { get; private set; } = string.Empty;
|
||||
public string CustomerNumber { get; private set; } = string.Empty;
|
||||
public double Price { get; private set; }
|
||||
public Dictionary<int, IOrderModel> OrderEmolyees { get; private set; } = new Dictionary<int, IOrderModel>();
|
||||
public Dictionary<int, (IMaterialModel, int)> OrderMaterials { get; private set; } = new Dictionary<int, (IMaterialModel, int)>();
|
||||
|
||||
public OrderStatus Status { get; private set; }
|
||||
|
||||
public DateTime DateBegin { get; private set; }
|
||||
|
||||
public DateTime? DateEnd { get; private set; }
|
||||
|
||||
public static Order? Create(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Order()
|
||||
{
|
||||
Id = model.Id,
|
||||
Description = model.Description,
|
||||
Adress = model.Adress,
|
||||
CustomerNumber = model.CustomerNumber,
|
||||
Price = model.Price,
|
||||
Status = model.Status,
|
||||
DateBegin = model.DateBegin,
|
||||
DateEnd = model.DateEnd,
|
||||
};
|
||||
}
|
||||
public void Update(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Status = model.Status;
|
||||
if (model.DateEnd.HasValue) DateEnd = model.DateEnd;
|
||||
}
|
||||
public static string CreateCommand(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return $"INSERT INTO \"order\"(description, adress, price, status, " +
|
||||
$"customer_number, date_begin, date_end) VALUES(\'{model.Description}\', \'{model.Adress}\', {model.Price}, " +
|
||||
$"\'{model.Status}\', \'{model.CustomerNumber}\', \'{model.DateBegin}\', " +
|
||||
$"{(model.DateEnd.HasValue ? $"\'{model.DateEnd}\'" : "null")});";
|
||||
}
|
||||
public static string UpdateCommand(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return $"UPDATE \"order\" SET description = \'{model.Description}\', adress = \'{model.Adress}\', " +
|
||||
$"price = {model.Price}, status = \'{model.Status}\', customer_number = \'{model.CustomerNumber}\', " +
|
||||
$"date_begin = \'{model.CustomerNumber}\', date_end = {(model.DateEnd.HasValue ? $"\'{model.DateEnd}\'" : "null")} " +
|
||||
$"WHERE id = {model.Id}";
|
||||
|
||||
}
|
||||
public static string DeleteCommand(OrderBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return $"DELETE FROM \"order\" WHERE id = {model.Id}";
|
||||
}
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Description = Description,
|
||||
Adress = Adress,
|
||||
CustomerNumber = CustomerNumber,
|
||||
Price = Price,
|
||||
Status = Status,
|
||||
DateBegin = DateBegin,
|
||||
DateEnd = DateEnd
|
||||
};
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
using ConstructionCompanyContracts.BindingModels;
|
||||
using ConstructionCompanyContracts.ViewModels;
|
||||
using ConstructionCompanyDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ConstructionCompanyPsqlImplement.Models
|
||||
{
|
||||
public class Position : IPositionModel
|
||||
{
|
||||
public string PositionName { get; private set; } = string.Empty;
|
||||
|
||||
public double Salary { get; set; }
|
||||
|
||||
public int Id { get; private set; }
|
||||
|
||||
public static Position? Create(PositionBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Position()
|
||||
{
|
||||
Id = model.Id,
|
||||
PositionName = model.PositionName,
|
||||
Salary = model.Salary
|
||||
};
|
||||
}
|
||||
public void Update(PositionBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
PositionName = model.PositionName;
|
||||
Salary = model.Salary;
|
||||
}
|
||||
public static string CreateCommand(PositionBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return $"INSERT INTO position(name, salary) VALUES(\'{model.PositionName}\', {model.Salary});";
|
||||
}
|
||||
public static string UpdateCommand(PositionBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return $"UPDATE position SET \"name\" = \'{model.PositionName}\', salary = {model.Salary} WHERE id = {model.Id}";
|
||||
}
|
||||
public static string DeleteCommand(PositionBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return $"DELETE FROM postition WHERE id = {model.Id}";
|
||||
}
|
||||
|
||||
public PositionViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
PositionName = PositionName,
|
||||
Salary = Salary
|
||||
};
|
||||
}
|
||||
}
|
@ -8,4 +8,20 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="7.0.0" />
|
||||
<PackageReference Include="NLog" Version="5.1.3" />
|
||||
<PackageReference Include="NLog.Config" Version="4.7.15" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.2.3" />
|
||||
<PackageReference Include="NLog.Schema" Version="5.1.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ConstructionCompanyBusiness\ConstructionCompanyBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\ConstructionCompanyContracts\ConstructionCompanyContracts.csproj" />
|
||||
<ProjectReference Include="..\ConstructionCompanyPsqlImplement\ConstructionCompanyPsqlImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -1,39 +0,0 @@
|
||||
namespace ConstructionCompanyView
|
||||
{
|
||||
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 ConstructionCompanyView
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
public Form1()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,120 +0,0 @@
|
||||
<?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>
|
119
ConstructionCompany/ConstructionCompanyView/FormMaterial.Designer.cs
generated
Normal file
119
ConstructionCompany/ConstructionCompanyView/FormMaterial.Designer.cs
generated
Normal file
@ -0,0 +1,119 @@
|
||||
namespace ConstructionCompanyView
|
||||
{
|
||||
partial class FormMaterial
|
||||
{
|
||||
/// <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.label1 = new System.Windows.Forms.Label();
|
||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||
this.textBoxQuantity = new System.Windows.Forms.TextBox();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.buttonCreate = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(12, 9);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(77, 20);
|
||||
this.label1.TabIndex = 0;
|
||||
this.label1.Text = "Название";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
this.textBoxName.Location = new System.Drawing.Point(108, 6);
|
||||
this.textBoxName.Name = "textBoxName";
|
||||
this.textBoxName.Size = new System.Drawing.Size(276, 27);
|
||||
this.textBoxName.TabIndex = 1;
|
||||
//
|
||||
// textBoxQuantity
|
||||
//
|
||||
this.textBoxQuantity.Location = new System.Drawing.Point(108, 56);
|
||||
this.textBoxQuantity.Name = "textBoxQuantity";
|
||||
this.textBoxQuantity.Size = new System.Drawing.Size(113, 27);
|
||||
this.textBoxQuantity.TabIndex = 3;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(12, 59);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(90, 20);
|
||||
this.label2.TabIndex = 2;
|
||||
this.label2.Text = "Количество";
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
this.buttonCreate.Location = new System.Drawing.Point(202, 117);
|
||||
this.buttonCreate.Name = "buttonCreate";
|
||||
this.buttonCreate.Size = new System.Drawing.Size(94, 29);
|
||||
this.buttonCreate.TabIndex = 4;
|
||||
this.buttonCreate.Text = "Создать";
|
||||
this.buttonCreate.UseVisualStyleBackColor = true;
|
||||
this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(307, 117);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(94, 29);
|
||||
this.buttonCancel.TabIndex = 5;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
|
||||
//
|
||||
// FormMaterial
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(413, 158);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonCreate);
|
||||
this.Controls.Add(this.textBoxQuantity);
|
||||
this.Controls.Add(this.label2);
|
||||
this.Controls.Add(this.textBoxName);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Name = "FormMaterial";
|
||||
this.Text = "Материал";
|
||||
this.Load += new System.EventHandler(this.FormMaterial_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private TextBox textBoxName;
|
||||
private TextBox textBoxQuantity;
|
||||
private Label label2;
|
||||
private Button buttonCreate;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
96
ConstructionCompany/ConstructionCompanyView/FormMaterial.cs
Normal file
96
ConstructionCompany/ConstructionCompanyView/FormMaterial.cs
Normal file
@ -0,0 +1,96 @@
|
||||
using ConstructionCompanyContracts.BindingModels;
|
||||
using ConstructionCompanyContracts.BusinessLogicContracts;
|
||||
using ConstructionCompanyContracts.SearchModels;
|
||||
using ConstructionCompanyContracts.StorageContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ConstructionCompanyView
|
||||
{
|
||||
public partial class FormMaterial : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IMaterialLogic _logic;
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
public FormMaterial(ILogger<FormMaterial> logger, IMaterialLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void buttonCreate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxQuantity.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Сохранение материала");
|
||||
try
|
||||
{
|
||||
var model = new MaterialBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
MaterialName = textBoxName.Text,
|
||||
Quantity = Convert.ToInt32(textBoxQuantity.Text)
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения компонента");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void FormMaterial_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Получение материала");
|
||||
var view = _logic.ReadElement(new MaterialSearchModel { Id = _id.Value });
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.MaterialName;
|
||||
textBoxQuantity.Text = view.Quantity.ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения материала");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<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>
|
120
ConstructionCompany/ConstructionCompanyView/FormMaterials.Designer.cs
generated
Normal file
120
ConstructionCompany/ConstructionCompanyView/FormMaterials.Designer.cs
generated
Normal file
@ -0,0 +1,120 @@
|
||||
namespace ConstructionCompanyView
|
||||
{
|
||||
partial class FormMaterials
|
||||
{
|
||||
/// <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.buttonRef = new System.Windows.Forms.Button();
|
||||
this.buttonDel = new System.Windows.Forms.Button();
|
||||
this.buttonUpd = new System.Windows.Forms.Button();
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonRef
|
||||
//
|
||||
this.buttonRef.Location = new System.Drawing.Point(523, 186);
|
||||
this.buttonRef.Name = "buttonRef";
|
||||
this.buttonRef.Size = new System.Drawing.Size(94, 29);
|
||||
this.buttonRef.TabIndex = 9;
|
||||
this.buttonRef.Text = "Обновить";
|
||||
this.buttonRef.UseVisualStyleBackColor = true;
|
||||
this.buttonRef.Click += new System.EventHandler(this.buttonRef_Click);
|
||||
//
|
||||
// buttonDel
|
||||
//
|
||||
this.buttonDel.Location = new System.Drawing.Point(523, 128);
|
||||
this.buttonDel.Name = "buttonDel";
|
||||
this.buttonDel.Size = new System.Drawing.Size(94, 29);
|
||||
this.buttonDel.TabIndex = 8;
|
||||
this.buttonDel.Text = "Удалить";
|
||||
this.buttonDel.UseVisualStyleBackColor = true;
|
||||
this.buttonDel.Click += new System.EventHandler(this.buttonDel_Click);
|
||||
//
|
||||
// buttonUpd
|
||||
//
|
||||
this.buttonUpd.Location = new System.Drawing.Point(523, 71);
|
||||
this.buttonUpd.Name = "buttonUpd";
|
||||
this.buttonUpd.Size = new System.Drawing.Size(94, 29);
|
||||
this.buttonUpd.TabIndex = 7;
|
||||
this.buttonUpd.Text = "Изменить";
|
||||
this.buttonUpd.UseVisualStyleBackColor = true;
|
||||
this.buttonUpd.Click += new System.EventHandler(this.buttonUpd_Click);
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(523, 14);
|
||||
this.buttonAdd.Name = "buttonAdd";
|
||||
this.buttonAdd.Size = new System.Drawing.Size(94, 29);
|
||||
this.buttonAdd.TabIndex = 6;
|
||||
this.buttonAdd.Text = "Добавить";
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.BackgroundColor = System.Drawing.Color.White;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.dataGridView.Location = new System.Drawing.Point(0, 0);
|
||||
this.dataGridView.MultiSelect = false;
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowHeadersVisible = false;
|
||||
this.dataGridView.RowHeadersWidth = 51;
|
||||
this.dataGridView.RowTemplate.Height = 29;
|
||||
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
||||
this.dataGridView.Size = new System.Drawing.Size(489, 452);
|
||||
this.dataGridView.TabIndex = 5;
|
||||
//
|
||||
// FormMaterials
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 20F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(641, 452);
|
||||
this.Controls.Add(this.buttonRef);
|
||||
this.Controls.Add(this.buttonDel);
|
||||
this.Controls.Add(this.buttonUpd);
|
||||
this.Controls.Add(this.buttonAdd);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Name = "FormMaterials";
|
||||
this.Text = "Материалы";
|
||||
this.Load += new System.EventHandler(this.FormMaterials_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Button buttonRef;
|
||||
private Button buttonDel;
|
||||
private Button buttonUpd;
|
||||
private Button buttonAdd;
|
||||
private DataGridView dataGridView;
|
||||
}
|
||||
}
|
110
ConstructionCompany/ConstructionCompanyView/FormMaterials.cs
Normal file
110
ConstructionCompany/ConstructionCompanyView/FormMaterials.cs
Normal file
@ -0,0 +1,110 @@
|
||||
using ConstructionCompanyContracts.BindingModels;
|
||||
using ConstructionCompanyContracts.BusinessLogicContracts;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ConstructionCompanyView
|
||||
{
|
||||
public partial class FormMaterials : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IMaterialLogic _logic;
|
||||
|
||||
public FormMaterials(ILogger<FormMaterials> logger, IMaterialLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormMaterials_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["MaterialName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка материалов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки материалов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormMaterial));
|
||||
if (service is FormMaterial form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormMaterial));
|
||||
if (service is FormMaterial form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Удаление изделия");
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new MaterialBindingModel { Id = id }))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления изделия");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonRef_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
<root>
|
||||
<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>
|
@ -1,7 +1,17 @@
|
||||
using ConstructionCompanyBusinessLogic.BusinessLogics;
|
||||
using ConstructionCompanyContracts.BusinessLogicContracts;
|
||||
using ConstructionCompanyContracts.StorageContracts;
|
||||
using ConstructionCompanyPsqlImplement.Implements;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NLog.Extensions.Logging;
|
||||
|
||||
namespace ConstructionCompanyView
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
private static ServiceProvider? _serviceProvider;
|
||||
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
@ -11,7 +21,23 @@ namespace ConstructionCompanyView
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
Application.Run(_serviceProvider.GetRequiredService<FormMaterials>());
|
||||
}
|
||||
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
services.AddLogging(option =>
|
||||
{
|
||||
option.SetMinimumLevel(LogLevel.Information);
|
||||
option.AddNLog("nlogConstruction.config");
|
||||
});
|
||||
services.AddTransient<IMaterialStorage, MaterialStorage>();
|
||||
services.AddTransient<IMaterialLogic, MaterialLogic>();
|
||||
services.AddTransient<FormMaterials>();
|
||||
services.AddTransient<FormMaterial>();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
autoReload="true" internalLogLevel="Info">
|
||||
|
||||
<targets>
|
||||
<target xsi:type="File" name="tofile" fileName="${basedir}/${shortdate}.log" />
|
||||
</targets>
|
||||
|
||||
<rules>
|
||||
<logger name="*" minlevel="Debug" writeTo="tofile" />
|
||||
</rules>
|
||||
</nlog>
|
||||
</configuration>
|
Loading…
Reference in New Issue
Block a user