возвращение легенды)
This commit is contained in:
parent
3072738732
commit
462f4104fe
@ -0,0 +1,125 @@
|
|||||||
|
using GarmentFactoryContracts.BindingModels;
|
||||||
|
using GarmentFactoryContracts.BusinessLogicsContracts;
|
||||||
|
using GarmentFactoryContracts.SearchModels;
|
||||||
|
using GarmentFactoryContracts.StoragesContracts;
|
||||||
|
using GarmentFactoryContracts.ViewModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace GarmentFactoryBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class ClientLogic : IClientLogic
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IClientStorage _clientStorage;
|
||||||
|
|
||||||
|
public ClientLogic(ILogger<ClientLogic> logger, IClientStorage clientStorage)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
_clientStorage = clientStorage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ClientViewModel>? ReadList(ClientSearchModel? model)
|
||||||
|
{
|
||||||
|
_logger.LogInformation("ReadList. Email: {Email}. Id: {Id} ", model?.Email, model?.Id);
|
||||||
|
var list = (model == null) ? _clientStorage.GetFullList() : _clientStorage.GetFilteredList(model);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("ReadList return null list");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadList. Count: {Count}", list.Count);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel? ReadElement(ClientSearchModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("ReadElement. Client email: {Email}. Client id: {Id}", model.Email, model.Id);
|
||||||
|
var element = _clientStorage.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(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_clientStorage.Insert(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Insert operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Update(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model);
|
||||||
|
if (_clientStorage.Update(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Update operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Delete(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
CheckModel(model, false);
|
||||||
|
_logger.LogInformation("Delete. Id: {Id}", model.Id);
|
||||||
|
if (_clientStorage.Delete(model) == null)
|
||||||
|
{
|
||||||
|
_logger.LogWarning("Delete operation failed");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckModel(ClientBindingModel model, bool withParams = true)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException(nameof(model));
|
||||||
|
}
|
||||||
|
if (!withParams)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.ClientFIO))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет ФИО клиента", nameof(model.ClientFIO));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Email))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет логина(почты) клиента", nameof(model.Email));
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(model.Password))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет пароля клиента", nameof(model.Password));
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Client. Id: {id}, FIO: {fio}, email: {email}, password: {password}", model.Id, model.ClientFIO, model.Email,
|
||||||
|
model.Password);
|
||||||
|
var element = _clientStorage.GetElement(new ClientSearchModel
|
||||||
|
{
|
||||||
|
Email = model.Email
|
||||||
|
});
|
||||||
|
if (element != null && element.Id != model.Id)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Клиент с таким логином(почтой) уже есть");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -84,6 +84,10 @@ namespace GarmentFactoryBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
throw new ArgumentNullException("Некорректный идентификатор изделия", nameof(model.TextileId));
|
throw new ArgumentNullException("Некорректный идентификатор изделия", nameof(model.TextileId));
|
||||||
}
|
}
|
||||||
|
if (model.ClientId <= 0)
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Некорректный идентификатор клиента", nameof(model.ClientId));
|
||||||
|
}
|
||||||
if (model.Count <= 0)
|
if (model.Count <= 0)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("В заказе должно быть хотя бы одно изделие", nameof(model.Count));
|
throw new ArgumentNullException("В заказе должно быть хотя бы одно изделие", nameof(model.Count));
|
||||||
@ -111,10 +115,6 @@ namespace GarmentFactoryBusinessLogic.BusinessLogics
|
|||||||
newStatus, order.Status);
|
newStatus, order.Status);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
model.TextileId = order.TextileId;
|
|
||||||
model.Count = order.Count;
|
|
||||||
model.Sum = order.Sum;
|
|
||||||
model.DateCreate = order.DateCreate;
|
|
||||||
model.Status = newStatus;
|
model.Status = newStatus;
|
||||||
if (model.Status == OrderStatus.Готов)
|
if (model.Status == OrderStatus.Готов)
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using GarmentFactoryDataModels.Models;
|
||||||
|
|
||||||
|
namespace GarmentFactoryContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class ClientBindingModel : IClientModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Email { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Password { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
@ -13,6 +13,7 @@ namespace GarmentFactoryContracts.BindingModels
|
|||||||
{
|
{
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
public int TextileId { get; set; }
|
public int TextileId { get; set; }
|
||||||
|
public int ClientId { get; set; }
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
public double Sum { get; set; }
|
public double Sum { get; set; }
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
using GarmentFactoryContracts.BindingModels;
|
||||||
|
using GarmentFactoryContracts.SearchModels;
|
||||||
|
using GarmentFactoryContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace GarmentFactoryContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IClientLogic
|
||||||
|
{
|
||||||
|
List<ClientViewModel>? ReadList(ClientSearchModel? model);
|
||||||
|
|
||||||
|
ClientViewModel? ReadElement(ClientSearchModel model);
|
||||||
|
|
||||||
|
bool Create(ClientBindingModel model);
|
||||||
|
|
||||||
|
bool Update(ClientBindingModel model);
|
||||||
|
|
||||||
|
bool Delete(ClientBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace GarmentFactoryContracts.SearchModels
|
||||||
|
{
|
||||||
|
public class ClientSearchModel
|
||||||
|
{
|
||||||
|
public int? Id { get; set; }
|
||||||
|
|
||||||
|
public string? ClientFIO { get; set; }
|
||||||
|
|
||||||
|
public string? Email { get; set; }
|
||||||
|
|
||||||
|
public string? Password { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -9,6 +9,7 @@ namespace GarmentFactoryContracts.SearchModels
|
|||||||
public class OrderSearchModel
|
public class OrderSearchModel
|
||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
|
public int? ClientId { get; set; }
|
||||||
public DateTime? DateFrom { get; set; }
|
public DateTime? DateFrom { get; set; }
|
||||||
|
|
||||||
public DateTime? DateTo { get; set; }
|
public DateTime? DateTo { get; set; }
|
||||||
|
@ -0,0 +1,26 @@
|
|||||||
|
using GarmentFactoryContracts.BindingModels;
|
||||||
|
using GarmentFactoryContracts.SearchModels;
|
||||||
|
using GarmentFactoryContracts.ViewModels;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace GarmentFactoryContracts.StoragesContracts
|
||||||
|
{
|
||||||
|
public interface IClientStorage
|
||||||
|
{
|
||||||
|
List<ClientViewModel> GetFullList();
|
||||||
|
|
||||||
|
List<ClientViewModel> GetFilteredList(ClientSearchModel model);
|
||||||
|
|
||||||
|
ClientViewModel? GetElement(ClientSearchModel model);
|
||||||
|
|
||||||
|
ClientViewModel? Insert(ClientBindingModel model);
|
||||||
|
|
||||||
|
ClientViewModel? Update(ClientBindingModel model);
|
||||||
|
|
||||||
|
ClientViewModel? Delete(ClientBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
using GarmentFactoryDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace GarmentFactoryContracts.ViewModels
|
||||||
|
{
|
||||||
|
public class ClientViewModel : IClientModel
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("ФИО клиента")]
|
||||||
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Логин (эл. почта)")]
|
||||||
|
public string Email { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[DisplayName("Пароль")]
|
||||||
|
public string Password { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
@ -16,6 +16,10 @@ namespace GarmentFactoryContracts.ViewModels
|
|||||||
public int TextileId { get; set; }
|
public int TextileId { get; set; }
|
||||||
[DisplayName("Изделие")]
|
[DisplayName("Изделие")]
|
||||||
public string TextileName { get; set; } = string.Empty;
|
public string TextileName { get; set; } = string.Empty;
|
||||||
|
public int ClientId { get; set; }
|
||||||
|
|
||||||
|
[DisplayName("ФИО клиента")]
|
||||||
|
public string ClientFIO { get; set; } = string.Empty;
|
||||||
[DisplayName("Количество")]
|
[DisplayName("Количество")]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
[DisplayName("Сумма")]
|
[DisplayName("Сумма")]
|
||||||
|
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace GarmentFactoryDataModels.Models
|
||||||
|
{
|
||||||
|
public interface IClientModel
|
||||||
|
{
|
||||||
|
string ClientFIO { get; }
|
||||||
|
|
||||||
|
string Email { get; }
|
||||||
|
|
||||||
|
string Password { get; }
|
||||||
|
}
|
||||||
|
}
|
@ -12,6 +12,7 @@ namespace GarmentFactoryDataModels.Models
|
|||||||
int TextileId { get; }
|
int TextileId { get; }
|
||||||
int Count { get; }
|
int Count { get; }
|
||||||
double Sum { get; }
|
double Sum { get; }
|
||||||
|
int ClientId { get; }
|
||||||
OrderStatus Status { get; }
|
OrderStatus Status { get; }
|
||||||
DateTime DateCreate { get; }
|
DateTime DateCreate { get; }
|
||||||
DateTime? DateImplement { get; }
|
DateTime? DateImplement { get; }
|
||||||
|
@ -22,5 +22,6 @@ namespace GarmentFactoryDatabaseImplement
|
|||||||
public virtual DbSet<Textile> Textiles { set; get; }
|
public virtual DbSet<Textile> Textiles { set; get; }
|
||||||
public virtual DbSet<TextileComponent> TextileComponents { set; get; }
|
public virtual DbSet<TextileComponent> TextileComponents { set; get; }
|
||||||
public virtual DbSet<Order> Orders { set; get; }
|
public virtual DbSet<Order> Orders { set; get; }
|
||||||
|
public virtual DbSet<Client> Clients { set; get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,88 @@
|
|||||||
|
using GarmentFactoryContracts.BindingModels;
|
||||||
|
using GarmentFactoryContracts.SearchModels;
|
||||||
|
using GarmentFactoryContracts.StoragesContracts;
|
||||||
|
using GarmentFactoryContracts.ViewModels;
|
||||||
|
using GarmentFactoryDatabaseImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace GarmentFactoryDatabaseImplement.Implements
|
||||||
|
{
|
||||||
|
public class ClientStorage : IClientStorage
|
||||||
|
{
|
||||||
|
public List<ClientViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
using var context = new GarmentFactoryDatabase();
|
||||||
|
return context.Clients
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.Email))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new GarmentFactoryDatabase();
|
||||||
|
return context.Clients
|
||||||
|
.Where(x => x.Email.Contains(model.Email))
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.Email) && string.IsNullOrEmpty(model.Password) && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new GarmentFactoryDatabase();
|
||||||
|
return context.Clients.FirstOrDefault(x =>
|
||||||
|
(!string.IsNullOrEmpty(model.Email) && x.Email == model.Email && !string.IsNullOrEmpty(model.Password) && x.Password == model.Password)
|
||||||
|
|| (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel? Insert(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
var newClient = Client.Create(model);
|
||||||
|
if (newClient == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
using var context = new GarmentFactoryDatabase();
|
||||||
|
context.Clients.Add(newClient);
|
||||||
|
context.SaveChanges();
|
||||||
|
return newClient.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel? Update(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new GarmentFactoryDatabase();
|
||||||
|
var client = context.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (client == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
client.Update(model);
|
||||||
|
context.SaveChanges();
|
||||||
|
return client.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel? Delete(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
using var context = new GarmentFactoryDatabase();
|
||||||
|
var element = context.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
context.Clients.Remove(element);
|
||||||
|
context.SaveChanges();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -14,30 +14,42 @@ namespace GarmentFactoryDatabaseImplement.Implements
|
|||||||
using var context = new GarmentFactoryDatabase();
|
using var context = new GarmentFactoryDatabase();
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Textile)
|
.Include(x => x.Textile)
|
||||||
|
.Include(x => x.Client)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.Id.HasValue && !model.DateFrom.HasValue)
|
|
||||||
{
|
|
||||||
return new();
|
|
||||||
}
|
|
||||||
using var context = new GarmentFactoryDatabase();
|
using var context = new GarmentFactoryDatabase();
|
||||||
if (model.DateFrom.HasValue)
|
if (model.Id.HasValue)
|
||||||
{
|
{
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Textile)
|
.Include(x => x.Textile)
|
||||||
|
.Include(x => x.Client)
|
||||||
|
.Where(x => x.Id == model.Id)
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
else if (model.DateFrom != null && model.DateTo != null)
|
||||||
|
{
|
||||||
|
return context.Orders
|
||||||
|
.Include(x => x.Textile)
|
||||||
|
.Include(x => x.Client)
|
||||||
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
|
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
return context.Orders
|
else if (model.ClientId.HasValue)
|
||||||
|
{
|
||||||
|
return context.Orders
|
||||||
.Include(x => x.Textile)
|
.Include(x => x.Textile)
|
||||||
.Where(x => x.Id == model.Id)
|
.Include(x => x.Client)
|
||||||
|
.Where(x => x.ClientId == model.ClientId)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
}
|
||||||
|
return new();
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||||
@ -49,6 +61,7 @@ namespace GarmentFactoryDatabaseImplement.Implements
|
|||||||
using var context = new GarmentFactoryDatabase();
|
using var context = new GarmentFactoryDatabase();
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Textile)
|
.Include(x => x.Textile)
|
||||||
|
.Include(x => x.Client)
|
||||||
.FirstOrDefault(x => x.Id == model.Id)
|
.FirstOrDefault(x => x.Id == model.Id)
|
||||||
?.GetViewModel;
|
?.GetViewModel;
|
||||||
}
|
}
|
||||||
@ -65,6 +78,7 @@ namespace GarmentFactoryDatabaseImplement.Implements
|
|||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Textile)
|
.Include(x => x.Textile)
|
||||||
|
.Include(x => x.Client)
|
||||||
.FirstOrDefault(x => x.Id == newOrder.Id)
|
.FirstOrDefault(x => x.Id == newOrder.Id)
|
||||||
?.GetViewModel;
|
?.GetViewModel;
|
||||||
}
|
}
|
||||||
@ -81,6 +95,7 @@ namespace GarmentFactoryDatabaseImplement.Implements
|
|||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Textile)
|
.Include(x => x.Textile)
|
||||||
|
.Include(x => x.Client)
|
||||||
.FirstOrDefault(x => x.Id == model.Id)
|
.FirstOrDefault(x => x.Id == model.Id)
|
||||||
?.GetViewModel;
|
?.GetViewModel;
|
||||||
}
|
}
|
||||||
@ -93,6 +108,7 @@ namespace GarmentFactoryDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
var deletedElement = context.Orders
|
var deletedElement = context.Orders
|
||||||
.Include(x => x.Textile)
|
.Include(x => x.Textile)
|
||||||
|
.Include(x => x.Client)
|
||||||
.FirstOrDefault(x => x.Id == model.Id)
|
.FirstOrDefault(x => x.Id == model.Id)
|
||||||
?.GetViewModel;
|
?.GetViewModel;
|
||||||
context.Orders.Remove(element);
|
context.Orders.Remove(element);
|
||||||
|
@ -0,0 +1,64 @@
|
|||||||
|
using GarmentFactoryContracts.BindingModels;
|
||||||
|
using GarmentFactoryContracts.ViewModels;
|
||||||
|
using GarmentFactoryDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace GarmentFactoryDatabaseImplement.Models
|
||||||
|
{
|
||||||
|
public class Client : IClientModel
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string ClientFIO { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string Email { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string Password { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
[ForeignKey("ClientId")]
|
||||||
|
public virtual List<Order> Orders { get; set; } = new();
|
||||||
|
|
||||||
|
public static Client? Create(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ClientFIO = model.ClientFIO,
|
||||||
|
Email = model.Email,
|
||||||
|
Password = model.Password
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ClientFIO = model.ClientFIO;
|
||||||
|
Email = model.Email;
|
||||||
|
Password = model.Password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ClientFIO = ClientFIO,
|
||||||
|
Email = Email,
|
||||||
|
Password = Password
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -18,6 +18,9 @@ namespace GarmentFactoryDatabaseImplement.Models
|
|||||||
[Required]
|
[Required]
|
||||||
public int TextileId { get; set; }
|
public int TextileId { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public int ClientId { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
|
||||||
@ -34,6 +37,8 @@ namespace GarmentFactoryDatabaseImplement.Models
|
|||||||
|
|
||||||
public virtual Textile Textile { get; set; }
|
public virtual Textile Textile { get; set; }
|
||||||
|
|
||||||
|
public virtual Client Client { get; set; }
|
||||||
|
|
||||||
public static Order? Create(OrderBindingModel? model)
|
public static Order? Create(OrderBindingModel? model)
|
||||||
{
|
{
|
||||||
if (model == null)
|
if (model == null)
|
||||||
@ -44,6 +49,7 @@ namespace GarmentFactoryDatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
TextileId = model.TextileId,
|
TextileId = model.TextileId,
|
||||||
|
ClientId = model.ClientId,
|
||||||
Count = model.Count,
|
Count = model.Count,
|
||||||
Sum = model.Sum,
|
Sum = model.Sum,
|
||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
@ -66,12 +72,14 @@ namespace GarmentFactoryDatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
TextileId = TextileId,
|
TextileId = TextileId,
|
||||||
|
ClientId = ClientId,
|
||||||
Count = Count,
|
Count = Count,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
DateCreate = DateCreate,
|
DateCreate = DateCreate,
|
||||||
DateImplement = DateImplement,
|
DateImplement = DateImplement,
|
||||||
TextileName = Textile.TextileName
|
TextileName = Textile.TextileName,
|
||||||
|
ClientFIO = Client.ClientFIO
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,11 @@ namespace GarmentFactoryFileImplement
|
|||||||
private readonly string ComponentFileName = "Component.xml";
|
private readonly string ComponentFileName = "Component.xml";
|
||||||
private readonly string OrderFileName = "Order.xml";
|
private readonly string OrderFileName = "Order.xml";
|
||||||
private readonly string TextileFileName = "Textile.xml";
|
private readonly string TextileFileName = "Textile.xml";
|
||||||
|
private readonly string ClientFileName = "Client.xml";
|
||||||
public List<Component> Components { get; private set; }
|
public List<Component> Components { get; private set; }
|
||||||
public List<Order> Orders { get; private set; }
|
public List<Order> Orders { get; private set; }
|
||||||
public List<Textile> Textils { get; private set; }
|
public List<Textile> Textils { get; private set; }
|
||||||
|
public List<Client> Clients { get; private set; }
|
||||||
public static DataFileSingleton GetInstance()
|
public static DataFileSingleton GetInstance()
|
||||||
{
|
{
|
||||||
if (instance == null)
|
if (instance == null)
|
||||||
@ -28,11 +30,13 @@ namespace GarmentFactoryFileImplement
|
|||||||
public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
|
public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
|
||||||
public void SaveTextils() => SaveData(Textils, TextileFileName, "Textils", x => x.GetXElement);
|
public void SaveTextils() => SaveData(Textils, TextileFileName, "Textils", x => x.GetXElement);
|
||||||
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
|
||||||
|
public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement);
|
||||||
private DataFileSingleton()
|
private DataFileSingleton()
|
||||||
{
|
{
|
||||||
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
|
||||||
Textils = LoadData(TextileFileName, "Textile", x => Textile.Create(x)!)!;
|
Textils = LoadData(TextileFileName, "Textile", x => Textile.Create(x)!)!;
|
||||||
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
|
||||||
|
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
|
||||||
}
|
}
|
||||||
private static List<T>? LoadData<T>(string filename, string xmlNodeName,
|
private static List<T>? LoadData<T>(string filename, string xmlNodeName,
|
||||||
Func<XElement, T> selectFunction)
|
Func<XElement, T> selectFunction)
|
||||||
|
@ -0,0 +1,91 @@
|
|||||||
|
using GarmentFactoryContracts.BindingModels;
|
||||||
|
using GarmentFactoryContracts.SearchModels;
|
||||||
|
using GarmentFactoryContracts.StoragesContracts;
|
||||||
|
using GarmentFactoryContracts.ViewModels;
|
||||||
|
using GarmentFactoryFileImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace GarmentFactoryFileImplement.Implements
|
||||||
|
{
|
||||||
|
public class ClientStorage : IClientStorage
|
||||||
|
{
|
||||||
|
private readonly DataFileSingleton source;
|
||||||
|
|
||||||
|
public ClientStorage()
|
||||||
|
{
|
||||||
|
source = DataFileSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ClientViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
return source.Clients
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.Email))
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
return source.Clients
|
||||||
|
.Where(x => x.Email.Contains(model.Email))
|
||||||
|
.Select(x => x.GetViewModel)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.Email) && string.IsNullOrEmpty(model.Password) && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return source.Clients
|
||||||
|
.FirstOrDefault(x =>
|
||||||
|
(!string.IsNullOrEmpty(model.Email) && x.Email == model.Email && !string.IsNullOrEmpty(model.Password) && x.Password == model.Password)
|
||||||
|
|| (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel? Insert(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
model.Id = source.Clients.Count > 0 ? source.Clients.Max(x => x.Id) + 1 : 1;
|
||||||
|
var newClient = Client.Create(model);
|
||||||
|
if (newClient == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
source.Clients.Add(newClient);
|
||||||
|
source.SaveClients();
|
||||||
|
return newClient.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel? Update(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
var client = source.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (client == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
client.Update(model);
|
||||||
|
source.SaveClients();
|
||||||
|
return client.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel? Delete(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
var element = source.Clients.FirstOrDefault(x => x.Id == model.Id);
|
||||||
|
if (element != null)
|
||||||
|
{
|
||||||
|
source.Clients.Remove(element);
|
||||||
|
source.SaveClients();
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -23,29 +23,35 @@ namespace GarmentFactoryFileImplement.Implements
|
|||||||
public List<OrderViewModel> GetFullList()
|
public List<OrderViewModel> GetFullList()
|
||||||
{
|
{
|
||||||
return source.Orders
|
return source.Orders
|
||||||
.Select(x => AddTextileName(x.GetViewModel))
|
.Select(x => AddIntelligence(x.GetViewModel))
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.Id.HasValue)
|
if (model.Id.HasValue)
|
||||||
{
|
{
|
||||||
return new();
|
return source.Orders
|
||||||
|
.Where(x => x.Id == model.Id)
|
||||||
|
.Select(x => AddIntelligence(x.GetViewModel))
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
if (model.DateFrom.HasValue)
|
else if (model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||||
{
|
{
|
||||||
return source.Orders
|
return source.Orders
|
||||||
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
|
.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
|
||||||
.Select(x => AddTextileName(x.GetViewModel))
|
.Select(x => AddIntelligence(x.GetViewModel))
|
||||||
.ToList();
|
.ToList();
|
||||||
}
|
}
|
||||||
return source.Orders
|
else if (model.ClientId.HasValue)
|
||||||
.Where(x => x.Id == model.Id)
|
{
|
||||||
.Select(x => AddTextileName(x.GetViewModel))
|
return source.Orders
|
||||||
.ToList();
|
.Where(x => x.ClientId == model.ClientId)
|
||||||
|
.Select(x => AddIntelligence(x.GetViewModel))
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
return new();
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? GetElement(OrderSearchModel model)
|
public OrderViewModel? GetElement(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
if (!model.Id.HasValue)
|
if (!model.Id.HasValue)
|
||||||
@ -57,7 +63,7 @@ namespace GarmentFactoryFileImplement.Implements
|
|||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return AddTextileName(order.GetViewModel);
|
return AddIntelligence(order.GetViewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? Insert(OrderBindingModel model)
|
public OrderViewModel? Insert(OrderBindingModel model)
|
||||||
@ -70,7 +76,7 @@ namespace GarmentFactoryFileImplement.Implements
|
|||||||
}
|
}
|
||||||
source.Orders.Add(newOrder);
|
source.Orders.Add(newOrder);
|
||||||
source.SaveOrders();
|
source.SaveOrders();
|
||||||
return AddTextileName(newOrder.GetViewModel);
|
return AddIntelligence(newOrder.GetViewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? Update(OrderBindingModel model)
|
public OrderViewModel? Update(OrderBindingModel model)
|
||||||
@ -82,7 +88,7 @@ namespace GarmentFactoryFileImplement.Implements
|
|||||||
}
|
}
|
||||||
order.Update(model);
|
order.Update(model);
|
||||||
source.SaveOrders();
|
source.SaveOrders();
|
||||||
return AddTextileName(order.GetViewModel);
|
return AddIntelligence(order.GetViewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? Delete(OrderBindingModel model)
|
public OrderViewModel? Delete(OrderBindingModel model)
|
||||||
@ -92,15 +98,17 @@ namespace GarmentFactoryFileImplement.Implements
|
|||||||
{
|
{
|
||||||
source.Orders.Remove(element);
|
source.Orders.Remove(element);
|
||||||
source.SaveOrders();
|
source.SaveOrders();
|
||||||
return AddTextileName(element.GetViewModel);
|
return AddIntelligence(element.GetViewModel);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private OrderViewModel AddTextileName(OrderViewModel model)
|
private OrderViewModel AddIntelligence(OrderViewModel model)
|
||||||
{
|
{
|
||||||
var selectedTextile = source.Textils.FirstOrDefault(x => x.Id == model.TextileId);
|
var selectedTextile = source.Textils.FirstOrDefault(x => x.Id == model.TextileId);
|
||||||
model.TextileName = selectedTextile?.TextileName;
|
model.TextileName = selectedTextile?.TextileName ?? string.Empty;
|
||||||
|
var selectedClient = source.Clients.FirstOrDefault(x => x.Id == model.ClientId);
|
||||||
|
model.ClientFIO = selectedClient?.ClientFIO ?? string.Empty;
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
79
GarmentFactory/GarmentFactoryFileImplement/Models/Client.cs
Normal file
79
GarmentFactory/GarmentFactoryFileImplement/Models/Client.cs
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
using GarmentFactoryContracts.BindingModels;
|
||||||
|
using GarmentFactoryContracts.ViewModels;
|
||||||
|
using GarmentFactoryDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
|
||||||
|
namespace GarmentFactoryFileImplement.Models
|
||||||
|
{
|
||||||
|
public class Client : IClientModel
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public string ClientFIO { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Email { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Password { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public static Client? Create(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ClientFIO = model.ClientFIO,
|
||||||
|
Email = model.Email,
|
||||||
|
Password = model.Password
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Client? Create(XElement element)
|
||||||
|
{
|
||||||
|
if (element == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
|
ClientFIO = element.Element("FIO")!.Value,
|
||||||
|
Email = element.Element("Email")!.Value,
|
||||||
|
Password = element.Element("Password")!.Value
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ClientFIO = model.ClientFIO;
|
||||||
|
Email = model.Email;
|
||||||
|
Password = model.Password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ClientFIO = ClientFIO,
|
||||||
|
Email = Email,
|
||||||
|
Password = Password,
|
||||||
|
};
|
||||||
|
|
||||||
|
public XElement GetXElement => new("Client",
|
||||||
|
new XAttribute("Id", Id),
|
||||||
|
new XElement("FIO", ClientFIO),
|
||||||
|
new XElement("Email", Email),
|
||||||
|
new XElement("Password", Password)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -16,6 +16,7 @@ namespace GarmentFactoryFileImplement.Models
|
|||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
public int TextileId { get; private set; }
|
public int TextileId { get; private set; }
|
||||||
|
public int ClientId { get; private set; }
|
||||||
|
|
||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
|
|
||||||
@ -37,6 +38,7 @@ namespace GarmentFactoryFileImplement.Models
|
|||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
TextileId = model.TextileId,
|
TextileId = model.TextileId,
|
||||||
|
ClientId = model.ClientId,
|
||||||
Count = model.Count,
|
Count = model.Count,
|
||||||
Sum = model.Sum,
|
Sum = model.Sum,
|
||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
@ -55,6 +57,7 @@ namespace GarmentFactoryFileImplement.Models
|
|||||||
{
|
{
|
||||||
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
Id = Convert.ToInt32(element.Attribute("Id")!.Value),
|
||||||
TextileId = Convert.ToInt32(element.Element("TextileId")!.Value),
|
TextileId = Convert.ToInt32(element.Element("TextileId")!.Value),
|
||||||
|
ClientId = Convert.ToInt32(element.Element("ClientId")!.Value),
|
||||||
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
Count = Convert.ToInt32(element.Element("Count")!.Value),
|
||||||
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
Sum = Convert.ToDouble(element.Element("Sum")!.Value),
|
||||||
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
|
Status = (OrderStatus)Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value),
|
||||||
@ -78,6 +81,7 @@ namespace GarmentFactoryFileImplement.Models
|
|||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
TextileId = TextileId,
|
TextileId = TextileId,
|
||||||
|
ClientId = ClientId,
|
||||||
Count = Count,
|
Count = Count,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
@ -88,6 +92,7 @@ namespace GarmentFactoryFileImplement.Models
|
|||||||
public XElement GetXElement => new("Order",
|
public XElement GetXElement => new("Order",
|
||||||
new XAttribute("Id", Id),
|
new XAttribute("Id", Id),
|
||||||
new XElement("TextileId", TextileId),
|
new XElement("TextileId", TextileId),
|
||||||
|
new XElement("ClientId", ClientId),
|
||||||
new XElement("Count", Count.ToString()),
|
new XElement("Count", Count.ToString()),
|
||||||
new XElement("Sum", Sum.ToString()),
|
new XElement("Sum", Sum.ToString()),
|
||||||
new XElement("Status", Status.ToString()),
|
new XElement("Status", Status.ToString()),
|
||||||
|
@ -13,11 +13,13 @@ namespace GarmentFactoryListImplement
|
|||||||
public List<Component> Components { get; set; }
|
public List<Component> Components { get; set; }
|
||||||
public List<Order> Orders { get; set; }
|
public List<Order> Orders { get; set; }
|
||||||
public List<Textile> Textiles { get; set; }
|
public List<Textile> Textiles { get; set; }
|
||||||
|
public List<Client> Clients { get; set; }
|
||||||
private DataListSingleton()
|
private DataListSingleton()
|
||||||
{
|
{
|
||||||
Components = new List<Component>();
|
Components = new List<Component>();
|
||||||
Orders = new List<Order>();
|
Orders = new List<Order>();
|
||||||
Textiles = new List<Textile>();
|
Textiles = new List<Textile>();
|
||||||
|
Clients = new List<Client>();
|
||||||
}
|
}
|
||||||
public static DataListSingleton GetInstance()
|
public static DataListSingleton GetInstance()
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,114 @@
|
|||||||
|
using GarmentFactoryContracts.BindingModels;
|
||||||
|
using GarmentFactoryContracts.SearchModels;
|
||||||
|
using GarmentFactoryContracts.StoragesContracts;
|
||||||
|
using GarmentFactoryContracts.ViewModels;
|
||||||
|
using GarmentFactoryListImplement.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace GarmentFactoryListImplement.Implements
|
||||||
|
{
|
||||||
|
public class ClientStorage : IClientStorage
|
||||||
|
{
|
||||||
|
private readonly DataListSingleton _source;
|
||||||
|
|
||||||
|
public ClientStorage()
|
||||||
|
{
|
||||||
|
_source = DataListSingleton.GetInstance();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ClientViewModel> GetFullList()
|
||||||
|
{
|
||||||
|
var result = new List<ClientViewModel>();
|
||||||
|
foreach (var client in _source.Clients)
|
||||||
|
{
|
||||||
|
result.Add(client.GetViewModel);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
|
||||||
|
{
|
||||||
|
var result = new List<ClientViewModel>();
|
||||||
|
if (string.IsNullOrEmpty(model.Email))
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
foreach (var client in _source.Clients)
|
||||||
|
{
|
||||||
|
if (client.Email.Contains(model.Email))
|
||||||
|
{
|
||||||
|
result.Add(client.GetViewModel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel? GetElement(ClientSearchModel model)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(model.Email) && string.IsNullOrEmpty(model.Password) && !model.Id.HasValue)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
foreach (var client in _source.Clients)
|
||||||
|
{
|
||||||
|
if ((!string.IsNullOrEmpty(model.Email) && client.Email == model.Email
|
||||||
|
&& !string.IsNullOrEmpty(model.Password) && client.Password == model.Password)
|
||||||
|
|| (model.Id.HasValue && client.Id == model.Id))
|
||||||
|
{
|
||||||
|
return client.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel? Insert(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
model.Id = 1;
|
||||||
|
foreach (var client in _source.Clients)
|
||||||
|
{
|
||||||
|
if (model.Id <= client.Id)
|
||||||
|
{
|
||||||
|
model.Id = client.Id + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
var newClient = Client.Create(model);
|
||||||
|
if (newClient == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
_source.Clients.Add(newClient);
|
||||||
|
return newClient.GetViewModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel? Update(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
foreach (var client in _source.Clients)
|
||||||
|
{
|
||||||
|
if (client.Id == model.Id)
|
||||||
|
{
|
||||||
|
client.Update(model);
|
||||||
|
return client.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel? Delete(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < _source.Clients.Count; ++i)
|
||||||
|
{
|
||||||
|
if (_source.Clients[i].Id == model.Id)
|
||||||
|
{
|
||||||
|
var element = _source.Clients[i];
|
||||||
|
_source.Clients.RemoveAt(i);
|
||||||
|
return element.GetViewModel;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -25,7 +25,7 @@ namespace GarmentFactoryListImplement.Implements
|
|||||||
var result = new List<OrderViewModel>();
|
var result = new List<OrderViewModel>();
|
||||||
foreach (var order in _source.Orders)
|
foreach (var order in _source.Orders)
|
||||||
{
|
{
|
||||||
result.Add(AddTextileName(order.GetViewModel));
|
result.Add(AddIntelligence(order.GetViewModel));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -33,26 +33,34 @@ namespace GarmentFactoryListImplement.Implements
|
|||||||
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
|
||||||
{
|
{
|
||||||
var result = new List<OrderViewModel>();
|
var result = new List<OrderViewModel>();
|
||||||
if (!model.Id.HasValue && !model.DateFrom.HasValue)
|
if (model.Id.HasValue)
|
||||||
{
|
{
|
||||||
return result;
|
foreach (var order in _source.Orders)
|
||||||
|
{
|
||||||
|
if (order.Id == model.Id)
|
||||||
|
{
|
||||||
|
result.Add(AddIntelligence(order.GetViewModel));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (model.DateFrom.HasValue)
|
else if(model.DateFrom.HasValue && model.DateTo.HasValue)
|
||||||
{
|
{
|
||||||
foreach (var order in _source.Orders)
|
foreach (var order in _source.Orders)
|
||||||
{
|
{
|
||||||
if (order.DateCreate >= model.DateFrom && order.DateCreate <= model.DateTo)
|
if (order.DateCreate >= model.DateFrom && order.DateCreate <= model.DateTo)
|
||||||
{
|
{
|
||||||
result.Add(AddTextileName(order.GetViewModel));
|
result.Add(AddIntelligence(order.GetViewModel));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
foreach (var order in _source.Orders)
|
else if (model.ClientId.HasValue)
|
||||||
{
|
{
|
||||||
if (order.Id == model.Id)
|
foreach (var order in _source.Orders)
|
||||||
{
|
{
|
||||||
result.Add(AddTextileName(order.GetViewModel));
|
if (order.ClientId == model.ClientId)
|
||||||
|
{
|
||||||
|
result.Add(AddIntelligence(order.GetViewModel));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@ -68,7 +76,7 @@ namespace GarmentFactoryListImplement.Implements
|
|||||||
{
|
{
|
||||||
if (order.Id == model.Id)
|
if (order.Id == model.Id)
|
||||||
{
|
{
|
||||||
return AddTextileName(order.GetViewModel);
|
return AddIntelligence(order.GetViewModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -90,7 +98,7 @@ namespace GarmentFactoryListImplement.Implements
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
_source.Orders.Add(newOrder);
|
_source.Orders.Add(newOrder);
|
||||||
return AddTextileName(newOrder.GetViewModel);
|
return AddIntelligence(newOrder.GetViewModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public OrderViewModel? Update(OrderBindingModel model)
|
public OrderViewModel? Update(OrderBindingModel model)
|
||||||
@ -100,7 +108,7 @@ namespace GarmentFactoryListImplement.Implements
|
|||||||
if (order.Id == model.Id)
|
if (order.Id == model.Id)
|
||||||
{
|
{
|
||||||
order.Update(model);
|
order.Update(model);
|
||||||
return AddTextileName(order.GetViewModel);
|
return AddIntelligence(order.GetViewModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -114,19 +122,27 @@ namespace GarmentFactoryListImplement.Implements
|
|||||||
{
|
{
|
||||||
var element = _source.Orders[i];
|
var element = _source.Orders[i];
|
||||||
_source.Orders.RemoveAt(i);
|
_source.Orders.RemoveAt(i);
|
||||||
return AddTextileName(element.GetViewModel);
|
return AddIntelligence(element.GetViewModel);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private OrderViewModel AddTextileName(OrderViewModel model)
|
private OrderViewModel AddIntelligence(OrderViewModel model)
|
||||||
{
|
{
|
||||||
var selectedTextile = _source.Textiles.Find(textile => textile.Id == model.TextileId);
|
var selectedTextile = _source.Textiles.Find(textile => textile.Id == model.TextileId);
|
||||||
if (selectedTextile != null)
|
if (selectedTextile != null)
|
||||||
{
|
{
|
||||||
model.TextileName = selectedTextile.TextileName;
|
model.TextileName = selectedTextile.TextileName;
|
||||||
}
|
}
|
||||||
|
foreach (var client in _source.Clients)
|
||||||
|
{
|
||||||
|
if (client.Id == model.ClientId)
|
||||||
|
{
|
||||||
|
model.ClientFIO = client.ClientFIO;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
return model;
|
return model;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
56
GarmentFactory/GarmentFactoryListImplement/Models/Client.cs
Normal file
56
GarmentFactory/GarmentFactoryListImplement/Models/Client.cs
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
using GarmentFactoryContracts.BindingModels;
|
||||||
|
using GarmentFactoryContracts.ViewModels;
|
||||||
|
using GarmentFactoryDataModels.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace GarmentFactoryListImplement.Models
|
||||||
|
{
|
||||||
|
public class Client : IClientModel
|
||||||
|
{
|
||||||
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
public string ClientFIO { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Email { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Password { get; private set; } = string.Empty;
|
||||||
|
|
||||||
|
public static Client? Create(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new()
|
||||||
|
{
|
||||||
|
Id = model.Id,
|
||||||
|
ClientFIO = model.ClientFIO,
|
||||||
|
Email = model.Email,
|
||||||
|
Password = model.Password
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(ClientBindingModel model)
|
||||||
|
{
|
||||||
|
if (model == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ClientFIO = model.ClientFIO;
|
||||||
|
Email = model.Email;
|
||||||
|
Password = model.Password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientViewModel GetViewModel => new()
|
||||||
|
{
|
||||||
|
Id = Id,
|
||||||
|
ClientFIO = ClientFIO,
|
||||||
|
Email = Email,
|
||||||
|
Password = Password,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -16,6 +16,8 @@ namespace GarmentFactoryListImplement.Models
|
|||||||
|
|
||||||
public int TextileId { get; private set; }
|
public int TextileId { get; private set; }
|
||||||
|
|
||||||
|
public int ClientId { get; private set; }
|
||||||
|
|
||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
|
|
||||||
public double Sum { get; private set; }
|
public double Sum { get; private set; }
|
||||||
@ -36,6 +38,7 @@ namespace GarmentFactoryListImplement.Models
|
|||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
TextileId = model.TextileId,
|
TextileId = model.TextileId,
|
||||||
|
ClientId = model.ClientId,
|
||||||
Count = model.Count,
|
Count = model.Count,
|
||||||
Sum = model.Sum,
|
Sum = model.Sum,
|
||||||
Status = model.Status,
|
Status = model.Status,
|
||||||
@ -58,6 +61,7 @@ namespace GarmentFactoryListImplement.Models
|
|||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
TextileId = TextileId,
|
TextileId = TextileId,
|
||||||
|
ClientId = ClientId,
|
||||||
Count = Count,
|
Count = Count,
|
||||||
Sum = Sum,
|
Sum = Sum,
|
||||||
Status = Status,
|
Status = Status,
|
||||||
|
98
GarmentFactory/GarmentFactoryView/FormClients.Designer.cs
generated
Normal file
98
GarmentFactory/GarmentFactoryView/FormClients.Designer.cs
generated
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
namespace GarmentFactoryView
|
||||||
|
{
|
||||||
|
partial class FormClients
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
dataGridView = new DataGridView();
|
||||||
|
buttonUpd = new Button();
|
||||||
|
buttonDel = new Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
dataGridView.AllowUserToAddRows = false;
|
||||||
|
dataGridView.AllowUserToDeleteRows = false;
|
||||||
|
dataGridView.BackgroundColor = SystemColors.ControlLightLight;
|
||||||
|
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
dataGridView.Dock = DockStyle.Left;
|
||||||
|
dataGridView.Location = new Point(0, 0);
|
||||||
|
dataGridView.Margin = new Padding(4, 3, 4, 3);
|
||||||
|
dataGridView.MultiSelect = false;
|
||||||
|
dataGridView.Name = "dataGridView";
|
||||||
|
dataGridView.ReadOnly = true;
|
||||||
|
dataGridView.RowHeadersVisible = false;
|
||||||
|
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||||
|
dataGridView.Size = new Size(408, 360);
|
||||||
|
dataGridView.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// buttonUpd
|
||||||
|
//
|
||||||
|
buttonUpd.Location = new Point(430, 59);
|
||||||
|
buttonUpd.Margin = new Padding(4, 3, 4, 3);
|
||||||
|
buttonUpd.Name = "buttonUpd";
|
||||||
|
buttonUpd.Size = new Size(88, 27);
|
||||||
|
buttonUpd.TabIndex = 8;
|
||||||
|
buttonUpd.Text = "Обновить";
|
||||||
|
buttonUpd.UseVisualStyleBackColor = true;
|
||||||
|
buttonUpd.Click += ButtonUpd_Click;
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
buttonDel.Location = new Point(430, 12);
|
||||||
|
buttonDel.Margin = new Padding(4, 3, 4, 3);
|
||||||
|
buttonDel.Name = "buttonDel";
|
||||||
|
buttonDel.Size = new Size(88, 27);
|
||||||
|
buttonDel.TabIndex = 7;
|
||||||
|
buttonDel.Text = "Удалить";
|
||||||
|
buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
buttonDel.Click += ButtonDel_Click;
|
||||||
|
//
|
||||||
|
// FormClients
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(541, 360);
|
||||||
|
Controls.Add(buttonUpd);
|
||||||
|
Controls.Add(buttonDel);
|
||||||
|
Controls.Add(dataGridView);
|
||||||
|
Name = "FormClients";
|
||||||
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
|
Text = "Клиенты";
|
||||||
|
Load += FormClients_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private Button buttonUpd;
|
||||||
|
private Button buttonDel;
|
||||||
|
}
|
||||||
|
}
|
75
GarmentFactory/GarmentFactoryView/FormClients.cs
Normal file
75
GarmentFactory/GarmentFactoryView/FormClients.cs
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
using GarmentFactoryContracts.BindingModels;
|
||||||
|
using GarmentFactoryContracts.BusinessLogicsContracts;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace GarmentFactoryView
|
||||||
|
{
|
||||||
|
public partial class FormClients : Form
|
||||||
|
{
|
||||||
|
private readonly ILogger _logger;
|
||||||
|
|
||||||
|
private readonly IClientLogic _logic;
|
||||||
|
|
||||||
|
public FormClients(ILogger<FormClients> logger, IClientLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logger = logger;
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormClients_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["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Clients loading");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Clients loading error");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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("Deletion of client");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_logic.Delete(new ClientBindingModel { Id = id }))
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Client deletion error");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
GarmentFactory/GarmentFactoryView/FormClients.resx
Normal file
120
GarmentFactory/GarmentFactoryView/FormClients.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>
|
@ -36,12 +36,14 @@
|
|||||||
comboBoxTextile = new ComboBox();
|
comboBoxTextile = new ComboBox();
|
||||||
buttonSave = new Button();
|
buttonSave = new Button();
|
||||||
buttonCancel = new Button();
|
buttonCancel = new Button();
|
||||||
|
labelClient = new Label();
|
||||||
|
comboBoxClient = new ComboBox();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// labelTextile
|
// labelTextile
|
||||||
//
|
//
|
||||||
labelTextile.AutoSize = true;
|
labelTextile.AutoSize = true;
|
||||||
labelTextile.Location = new Point(15, 9);
|
labelTextile.Location = new Point(11, 58);
|
||||||
labelTextile.Name = "labelTextile";
|
labelTextile.Name = "labelTextile";
|
||||||
labelTextile.Size = new Size(75, 20);
|
labelTextile.Size = new Size(75, 20);
|
||||||
labelTextile.TabIndex = 0;
|
labelTextile.TabIndex = 0;
|
||||||
@ -50,7 +52,7 @@
|
|||||||
// labelCount
|
// labelCount
|
||||||
//
|
//
|
||||||
labelCount.AutoSize = true;
|
labelCount.AutoSize = true;
|
||||||
labelCount.Location = new Point(15, 51);
|
labelCount.Location = new Point(11, 100);
|
||||||
labelCount.Name = "labelCount";
|
labelCount.Name = "labelCount";
|
||||||
labelCount.Size = new Size(97, 20);
|
labelCount.Size = new Size(97, 20);
|
||||||
labelCount.TabIndex = 1;
|
labelCount.TabIndex = 1;
|
||||||
@ -59,7 +61,7 @@
|
|||||||
// labelSum
|
// labelSum
|
||||||
//
|
//
|
||||||
labelSum.AutoSize = true;
|
labelSum.AutoSize = true;
|
||||||
labelSum.Location = new Point(15, 92);
|
labelSum.Location = new Point(11, 141);
|
||||||
labelSum.Name = "labelSum";
|
labelSum.Name = "labelSum";
|
||||||
labelSum.Size = new Size(62, 20);
|
labelSum.Size = new Size(62, 20);
|
||||||
labelSum.TabIndex = 2;
|
labelSum.TabIndex = 2;
|
||||||
@ -67,7 +69,7 @@
|
|||||||
//
|
//
|
||||||
// textBoxCount
|
// textBoxCount
|
||||||
//
|
//
|
||||||
textBoxCount.Location = new Point(112, 51);
|
textBoxCount.Location = new Point(108, 100);
|
||||||
textBoxCount.Name = "textBoxCount";
|
textBoxCount.Name = "textBoxCount";
|
||||||
textBoxCount.Size = new Size(293, 27);
|
textBoxCount.Size = new Size(293, 27);
|
||||||
textBoxCount.TabIndex = 4;
|
textBoxCount.TabIndex = 4;
|
||||||
@ -76,7 +78,7 @@
|
|||||||
// textBoxSum
|
// textBoxSum
|
||||||
//
|
//
|
||||||
textBoxSum.BackColor = SystemColors.Control;
|
textBoxSum.BackColor = SystemColors.Control;
|
||||||
textBoxSum.Location = new Point(112, 92);
|
textBoxSum.Location = new Point(108, 141);
|
||||||
textBoxSum.Name = "textBoxSum";
|
textBoxSum.Name = "textBoxSum";
|
||||||
textBoxSum.ReadOnly = true;
|
textBoxSum.ReadOnly = true;
|
||||||
textBoxSum.Size = new Size(293, 27);
|
textBoxSum.Size = new Size(293, 27);
|
||||||
@ -86,7 +88,7 @@
|
|||||||
//
|
//
|
||||||
comboBoxTextile.DropDownStyle = ComboBoxStyle.DropDownList;
|
comboBoxTextile.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
comboBoxTextile.FormattingEnabled = true;
|
comboBoxTextile.FormattingEnabled = true;
|
||||||
comboBoxTextile.Location = new Point(112, 9);
|
comboBoxTextile.Location = new Point(108, 58);
|
||||||
comboBoxTextile.Name = "comboBoxTextile";
|
comboBoxTextile.Name = "comboBoxTextile";
|
||||||
comboBoxTextile.Size = new Size(293, 28);
|
comboBoxTextile.Size = new Size(293, 28);
|
||||||
comboBoxTextile.TabIndex = 6;
|
comboBoxTextile.TabIndex = 6;
|
||||||
@ -94,7 +96,7 @@
|
|||||||
//
|
//
|
||||||
// buttonSave
|
// buttonSave
|
||||||
//
|
//
|
||||||
buttonSave.Location = new Point(184, 131);
|
buttonSave.Location = new Point(180, 180);
|
||||||
buttonSave.Name = "buttonSave";
|
buttonSave.Name = "buttonSave";
|
||||||
buttonSave.Size = new Size(101, 36);
|
buttonSave.Size = new Size(101, 36);
|
||||||
buttonSave.TabIndex = 7;
|
buttonSave.TabIndex = 7;
|
||||||
@ -104,7 +106,7 @@
|
|||||||
//
|
//
|
||||||
// buttonCancel
|
// buttonCancel
|
||||||
//
|
//
|
||||||
buttonCancel.Location = new Point(291, 131);
|
buttonCancel.Location = new Point(287, 180);
|
||||||
buttonCancel.Name = "buttonCancel";
|
buttonCancel.Name = "buttonCancel";
|
||||||
buttonCancel.Size = new Size(101, 36);
|
buttonCancel.Size = new Size(101, 36);
|
||||||
buttonCancel.TabIndex = 8;
|
buttonCancel.TabIndex = 8;
|
||||||
@ -112,11 +114,31 @@
|
|||||||
buttonCancel.UseVisualStyleBackColor = true;
|
buttonCancel.UseVisualStyleBackColor = true;
|
||||||
buttonCancel.Click += ButtonCancel_Click;
|
buttonCancel.Click += ButtonCancel_Click;
|
||||||
//
|
//
|
||||||
|
// labelClient
|
||||||
|
//
|
||||||
|
labelClient.AutoSize = true;
|
||||||
|
labelClient.Location = new Point(11, 15);
|
||||||
|
labelClient.Name = "labelClient";
|
||||||
|
labelClient.Size = new Size(65, 20);
|
||||||
|
labelClient.TabIndex = 9;
|
||||||
|
labelClient.Text = "Клиент :";
|
||||||
|
//
|
||||||
|
// comboBoxClient
|
||||||
|
//
|
||||||
|
comboBoxClient.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
|
comboBoxClient.FormattingEnabled = true;
|
||||||
|
comboBoxClient.Location = new Point(108, 15);
|
||||||
|
comboBoxClient.Name = "comboBoxClient";
|
||||||
|
comboBoxClient.Size = new Size(293, 28);
|
||||||
|
comboBoxClient.TabIndex = 10;
|
||||||
|
//
|
||||||
// FormCreateOrder
|
// FormCreateOrder
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
ClientSize = new Size(424, 181);
|
ClientSize = new Size(424, 227);
|
||||||
|
Controls.Add(comboBoxClient);
|
||||||
|
Controls.Add(labelClient);
|
||||||
Controls.Add(buttonCancel);
|
Controls.Add(buttonCancel);
|
||||||
Controls.Add(buttonSave);
|
Controls.Add(buttonSave);
|
||||||
Controls.Add(comboBoxTextile);
|
Controls.Add(comboBoxTextile);
|
||||||
@ -143,5 +165,7 @@
|
|||||||
private ComboBox comboBoxTextile;
|
private ComboBox comboBoxTextile;
|
||||||
private Button buttonSave;
|
private Button buttonSave;
|
||||||
private Button buttonCancel;
|
private Button buttonCancel;
|
||||||
|
private Label labelClient;
|
||||||
|
private ComboBox comboBoxClient;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -19,13 +19,15 @@ namespace GarmentFactoryView
|
|||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly ITextileLogic _logicT;
|
private readonly ITextileLogic _logicT;
|
||||||
private readonly IOrderLogic _logicO;
|
private readonly IOrderLogic _logicO;
|
||||||
|
private readonly IClientLogic _logicC;
|
||||||
public FormCreateOrder(ILogger<FormCreateOrder> logger, ITextileLogic
|
public FormCreateOrder(ILogger<FormCreateOrder> logger, ITextileLogic
|
||||||
logicT, IOrderLogic logicO)
|
logicT, IOrderLogic logicO, IClientLogic logicC)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_logicT = logicT;
|
_logicT = logicT;
|
||||||
_logicO = logicO;
|
_logicO = logicO;
|
||||||
|
_logicC = logicC;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FormCreateOrder_Load(object sender, EventArgs e)
|
private void FormCreateOrder_Load(object sender, EventArgs e)
|
||||||
@ -47,6 +49,23 @@ logicT, IOrderLogic logicO)
|
|||||||
_logger.LogError(ex, "Ошибка при загрузке изделия для заказаr");
|
_logger.LogError(ex, "Ошибка при загрузке изделия для заказаr");
|
||||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
|
_logger.LogInformation("Loading clients for order");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var clientList = _logicC.ReadList(null);
|
||||||
|
if (clientList != null)
|
||||||
|
{
|
||||||
|
comboBoxClient.DisplayMember = "ClientFIO";
|
||||||
|
comboBoxClient.ValueMember = "Id";
|
||||||
|
comboBoxClient.DataSource = clientList;
|
||||||
|
comboBoxClient.SelectedItem = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "Error during loading clients for order");
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
private void CalcSum()
|
private void CalcSum()
|
||||||
{
|
{
|
||||||
@ -100,12 +119,19 @@ logicT, IOrderLogic logicO)
|
|||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (comboBoxClient.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите клиента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
_logger.LogInformation("Создание заказа");
|
_logger.LogInformation("Создание заказа");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
var operationResult = _logicO.CreateOrder(new OrderBindingModel
|
||||||
{
|
{
|
||||||
|
|
||||||
TextileId = Convert.ToInt32(comboBoxTextile.SelectedValue),
|
TextileId = Convert.ToInt32(comboBoxTextile.SelectedValue),
|
||||||
|
ClientId = Convert.ToInt32(comboBoxClient.SelectedValue),
|
||||||
Count = Convert.ToInt32(textBoxCount.Text),
|
Count = Convert.ToInt32(textBoxCount.Text),
|
||||||
Sum = Convert.ToDouble(textBoxSum.Text)
|
Sum = Convert.ToDouble(textBoxSum.Text)
|
||||||
});
|
});
|
||||||
|
@ -34,14 +34,15 @@
|
|||||||
изделиеToolStripMenuItem = new ToolStripMenuItem();
|
изделиеToolStripMenuItem = new ToolStripMenuItem();
|
||||||
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
отчетыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
списокПродуктаToolStripMenuItem = new ToolStripMenuItem();
|
списокПродуктаToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
компонентыПоИзделиямToolStripMenuItem = new ToolStripMenuItem();
|
||||||
|
списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
|
||||||
dataGridView = new DataGridView();
|
dataGridView = new DataGridView();
|
||||||
buttonCreateOrder = new Button();
|
buttonCreateOrder = new Button();
|
||||||
buttonTakeOrderInWork = new Button();
|
buttonTakeOrderInWork = new Button();
|
||||||
buttonOrderReady = new Button();
|
buttonOrderReady = new Button();
|
||||||
buttonIssuedOrder = new Button();
|
buttonIssuedOrder = new Button();
|
||||||
buttonUpd = new Button();
|
buttonUpd = new Button();
|
||||||
компонентыПоИзделиямToolStripMenuItem = new ToolStripMenuItem();
|
клиентыToolStripMenuItem = new ToolStripMenuItem();
|
||||||
списокЗаказовToolStripMenuItem = new ToolStripMenuItem();
|
|
||||||
menuStrip.SuspendLayout();
|
menuStrip.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
@ -58,7 +59,7 @@
|
|||||||
//
|
//
|
||||||
// справочникиToolStripMenuItem
|
// справочникиToolStripMenuItem
|
||||||
//
|
//
|
||||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, изделиеToolStripMenuItem });
|
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, изделиеToolStripMenuItem, клиентыToolStripMenuItem });
|
||||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||||
справочникиToolStripMenuItem.Size = new Size(117, 24);
|
справочникиToolStripMenuItem.Size = new Size(117, 24);
|
||||||
справочникиToolStripMenuItem.Text = "Справочники";
|
справочникиToolStripMenuItem.Text = "Справочники";
|
||||||
@ -66,14 +67,14 @@
|
|||||||
// компонентыToolStripMenuItem
|
// компонентыToolStripMenuItem
|
||||||
//
|
//
|
||||||
компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
||||||
компонентыToolStripMenuItem.Size = new Size(182, 26);
|
компонентыToolStripMenuItem.Size = new Size(224, 26);
|
||||||
компонентыToolStripMenuItem.Text = "Компоненты";
|
компонентыToolStripMenuItem.Text = "Компоненты";
|
||||||
компонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click;
|
компонентыToolStripMenuItem.Click += КомпонентыToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
// изделиеToolStripMenuItem
|
// изделиеToolStripMenuItem
|
||||||
//
|
//
|
||||||
изделиеToolStripMenuItem.Name = "изделиеToolStripMenuItem";
|
изделиеToolStripMenuItem.Name = "изделиеToolStripMenuItem";
|
||||||
изделиеToolStripMenuItem.Size = new Size(182, 26);
|
изделиеToolStripMenuItem.Size = new Size(224, 26);
|
||||||
изделиеToolStripMenuItem.Text = "Изделие";
|
изделиеToolStripMenuItem.Text = "Изделие";
|
||||||
изделиеToolStripMenuItem.Click += ИзделиеToolStripMenuItem_Click;
|
изделиеToolStripMenuItem.Click += ИзделиеToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
@ -91,6 +92,20 @@
|
|||||||
списокПродуктаToolStripMenuItem.Text = "Список изделия";
|
списокПродуктаToolStripMenuItem.Text = "Список изделия";
|
||||||
списокПродуктаToolStripMenuItem.Click += СписокИзделияToolStripMenuItem_Click;
|
списокПродуктаToolStripMenuItem.Click += СписокИзделияToolStripMenuItem_Click;
|
||||||
//
|
//
|
||||||
|
// компонентыПоИзделиямToolStripMenuItem
|
||||||
|
//
|
||||||
|
компонентыПоИзделиямToolStripMenuItem.Name = "компонентыПоИзделиямToolStripMenuItem";
|
||||||
|
компонентыПоИзделиямToolStripMenuItem.Size = new Size(276, 26);
|
||||||
|
компонентыПоИзделиямToolStripMenuItem.Text = "Компоненты по изделиям";
|
||||||
|
компонентыПоИзделиямToolStripMenuItem.Click += КомпонентыПоИзделиямToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
|
// списокЗаказовToolStripMenuItem
|
||||||
|
//
|
||||||
|
списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
|
||||||
|
списокЗаказовToolStripMenuItem.Size = new Size(276, 26);
|
||||||
|
списокЗаказовToolStripMenuItem.Text = "Список заказов";
|
||||||
|
списокЗаказовToolStripMenuItem.Click += СписокЗаказовToolStripMenuItem_Click;
|
||||||
|
//
|
||||||
// dataGridView
|
// dataGridView
|
||||||
//
|
//
|
||||||
dataGridView.AllowUserToAddRows = false;
|
dataGridView.AllowUserToAddRows = false;
|
||||||
@ -158,19 +173,12 @@
|
|||||||
buttonUpd.UseVisualStyleBackColor = true;
|
buttonUpd.UseVisualStyleBackColor = true;
|
||||||
buttonUpd.Click += ButtonUpd_Click;
|
buttonUpd.Click += ButtonUpd_Click;
|
||||||
//
|
//
|
||||||
// компонентыПоИзделиямToolStripMenuItem
|
// клиентыToolStripMenuItem
|
||||||
//
|
//
|
||||||
компонентыПоИзделиямToolStripMenuItem.Name = "компонентыПоИзделиямToolStripMenuItem";
|
клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
|
||||||
компонентыПоИзделиямToolStripMenuItem.Size = new Size(276, 26);
|
клиентыToolStripMenuItem.Size = new Size(224, 26);
|
||||||
компонентыПоИзделиямToolStripMenuItem.Text = "Компоненты по изделиям";
|
клиентыToolStripMenuItem.Text = "Клиенты";
|
||||||
компонентыПоИзделиямToolStripMenuItem.Click += КомпонентыПоИзделиямToolStripMenuItem_Click;
|
клиентыToolStripMenuItem.Click += КлиентыToolStripMenuItem_Click;
|
||||||
//
|
|
||||||
// списокЗаказовToolStripMenuItem
|
|
||||||
//
|
|
||||||
списокЗаказовToolStripMenuItem.Name = "списокЗаказовToolStripMenuItem";
|
|
||||||
списокЗаказовToolStripMenuItem.Size = new Size(276, 26);
|
|
||||||
списокЗаказовToolStripMenuItem.Text = "Список заказов";
|
|
||||||
списокЗаказовToolStripMenuItem.Click += СписокЗаказовToolStripMenuItem_Click;
|
|
||||||
//
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
@ -212,5 +220,6 @@
|
|||||||
private ToolStripMenuItem списокПродуктаToolStripMenuItem;
|
private ToolStripMenuItem списокПродуктаToolStripMenuItem;
|
||||||
private ToolStripMenuItem компонентыПоИзделиямToolStripMenuItem;
|
private ToolStripMenuItem компонентыПоИзделиямToolStripMenuItem;
|
||||||
private ToolStripMenuItem списокЗаказовToolStripMenuItem;
|
private ToolStripMenuItem списокЗаказовToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem клиентыToolStripMenuItem;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -41,6 +41,8 @@ namespace GarmentFactoryView
|
|||||||
dataGridView.DataSource = list;
|
dataGridView.DataSource = list;
|
||||||
dataGridView.Columns["TextileId"].Visible = false;
|
dataGridView.Columns["TextileId"].Visible = false;
|
||||||
dataGridView.Columns["TextileName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
dataGridView.Columns["TextileName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["ClientId"].Visible = false;
|
||||||
|
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Загрузка заказов");
|
_logger.LogInformation("Загрузка заказов");
|
||||||
}
|
}
|
||||||
@ -185,5 +187,14 @@ namespace GarmentFactoryView
|
|||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void КлиентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
|
||||||
|
if (service is FormClients form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,10 +34,14 @@ namespace GarmentFactoryView
|
|||||||
services.AddTransient<IComponentStorage, ComponentStorage>();
|
services.AddTransient<IComponentStorage, ComponentStorage>();
|
||||||
services.AddTransient<IOrderStorage, OrderStorage>();
|
services.AddTransient<IOrderStorage, OrderStorage>();
|
||||||
services.AddTransient<ITextileStorage, TextileStorage>();
|
services.AddTransient<ITextileStorage, TextileStorage>();
|
||||||
|
services.AddTransient<IClientStorage, ClientStorage>();
|
||||||
|
|
||||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||||
services.AddTransient<ITextileLogic, TextileLogic>();
|
services.AddTransient<ITextileLogic, TextileLogic>();
|
||||||
services.AddTransient<IReportLogic, ReportLogic>();
|
services.AddTransient<IReportLogic, ReportLogic>();
|
||||||
|
services.AddTransient<IClientLogic, ClientLogic>();
|
||||||
|
|
||||||
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
services.AddTransient<AbstractSaveToWord, SaveToWord>();
|
||||||
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
services.AddTransient<AbstractSaveToExcel, SaveToExcel>();
|
||||||
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
services.AddTransient<AbstractSaveToPdf, SaveToPdf>();
|
||||||
@ -50,6 +54,7 @@ namespace GarmentFactoryView
|
|||||||
services.AddTransient<FormTextiles>();
|
services.AddTransient<FormTextiles>();
|
||||||
services.AddTransient<FormReportTextileComponents>();
|
services.AddTransient<FormReportTextileComponents>();
|
||||||
services.AddTransient<FormReportOrders>();
|
services.AddTransient<FormReportOrders>();
|
||||||
|
services.AddTransient<FormClients>();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user