This commit is contained in:
a.puchkina 2024-05-14 00:16:03 +04:00
parent a6ecc6b25f
commit 7a9aea4a30
49 changed files with 4185 additions and 88 deletions

View File

@ -33,6 +33,20 @@ namespace TransportLogisticBusinessLogic
return list;
}
public OrderViewModel? ReadElement(OrderSearchModel model)
{
if (model == null)
{
throw new ArgumentNullException(nameof(model));
}
var element = _orderStorage.GetElement(model);
if (element == null)
{
return null;
}
return element;
}
public bool CreateOrder(OrderBindingModel model)
{
CheckModel(model);
@ -75,6 +89,10 @@ namespace TransportLogisticBusinessLogic
{
return ChangeStatus(model, OrderStatus.Доставлен);
}
public bool DeliveryOrder(OrderBindingModel model)
{
return ChangeStatus(model, OrderStatus.Выдан);
}
private void CheckModel(OrderBindingModel model, bool withParams = true)
{
if (model == null)
@ -87,6 +105,6 @@ namespace TransportLogisticBusinessLogic
}
_logger.LogInformation("Order. Id: { Id}", model.Id);
}
}
}

View File

@ -6,7 +6,7 @@ namespace TransportLogisticContracts.BindingModels
{
public int Id { get; set; }
public string Name { get; set; } = string.Empty;
public double Weght { get; set; }
public double Weight { get; set; }
public string Size{ get; set; } = string.Empty;
}
}

View File

@ -12,7 +12,7 @@ namespace TransportLogisticContracts.BindingModels
public int StartStorageId { get; set; }
public int FinishStorageId { get; set; }
public int CustomerId { get; set; }
public Dictionary<int, (ITransportModel, int)> Transports { get; set; } = new();
public Dictionary<int, (IGoodModel, int)> Goods { get; set; } = new();
public Dictionary<int, (ITransportModel, int)> OrderTransports { get; set; } = new();
public Dictionary<int, (IGoodModel, int)> OrderGoods { get; set; } = new();
}
}

View File

@ -7,6 +7,7 @@ namespace TransportLogisticContracts.BusinessLogicsContracts
public interface IOrderLogic
{
List<OrderViewModel>? ReadList(OrderSearchModel? model);
OrderViewModel? ReadElement(OrderSearchModel model);
bool CreateOrder(OrderBindingModel model);
bool TakeOrderInWork(OrderBindingModel model);
bool FinishOrder(OrderBindingModel model);

View File

@ -3,6 +3,6 @@
public class OrderSearchModel
{
public int? Id { get; set; }
public string? CustomerId { get; set; }
public int? CustomerId { get; set; }
}
}

View File

@ -1,5 +1,6 @@
using TransportLogisticDataModels;
using System.ComponentModel;
using TransportLogisticDataModels.Enums;
namespace TransportLogisticContracts.ViewModels
{
@ -22,7 +23,7 @@ namespace TransportLogisticContracts.ViewModels
public int CustomerId { get; set; }
[DisplayName("Имя заказчика")]
public string CustomerName { get; set; } = string.Empty;
public Dictionary<int, (ITransportModel, int)> Transports { get; set; } = new();
public Dictionary<int, (IGoodModel, int)> Goods { get; set; } = new();
public Dictionary<int, (ITransportModel, int)> OrderTransports { get; set; } = new();
public Dictionary<int, (IGoodModel, int)> OrderGoods { get; set; } = new();
}
}

View File

@ -5,7 +5,7 @@
Неизвестен = -1,
Принят = 0,
В_пути = 1,
Готов_к_выдаче = 2,
Доставлен = 3
Доставлен = 2,
Выдан = 3
}
}

View File

@ -9,69 +9,76 @@ namespace TransportLogisticDatabaseImplement.Implements
{
public class CustomerStorage : ICustomerStorage
{
public List<CustomerViewModel> GetFullList()
{
using var context = new TransportLogisticDatabase();
return context.Customers.Select(x => x.GetViewModel).ToList();
}
public List<CustomerViewModel> GetFullList()
{
using var context = new TransportLogisticDatabase();
return context.Customers
.Select(x => x.GetViewModel)
.ToList();
}
public List<CustomerViewModel> GetFilteredList(CustomerSearchModel model)
{
if (string.IsNullOrEmpty(model.Name))
{
return new();
}
using var context = new TransportLogisticDatabase();
return context.Customers.Where(x => x.Name.Contains(model.Name)).Select(x => x.GetViewModel).ToList();
}
public List<CustomerViewModel> GetFilteredList(CustomerSearchModel model)
{
if (string.IsNullOrEmpty(model.Email))
{
return new();
}
using var context = new TransportLogisticDatabase();
return context.Customers
.Where(x => x.Email.Contains(model.Email))
.Select(x => x.GetViewModel)
.ToList();
}
public CustomerViewModel? GetElement(CustomerSearchModel model)
{
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
{
return null;
}
using var context = new TransportLogisticDatabase();
return context.Customers.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Name) && x.Name == model.Name) || (model.Id.HasValue && x.Id == model.Id)) ?.GetViewModel;
}
public CustomerViewModel? GetElement(CustomerSearchModel model)
{
if (string.IsNullOrEmpty(model.Email) && !model.Id.HasValue)
{
return null;
}
using var context = new TransportLogisticDatabase();
return context.Customers.FirstOrDefault(x =>
(!string.IsNullOrEmpty(model.Email) && x.Email == model.Email)
|| (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
public CustomerViewModel? Insert(CustomerBindingModel model)
{
var newCustomer = Customer.Create(model);
if (newCustomer == null)
{
return null;
}
using var context = new TransportLogisticDatabase();
context.Customers.Add(newCustomer);
context.SaveChanges();
return newCustomer.GetViewModel;
}
public CustomerViewModel? Insert(CustomerBindingModel model)
{
var newCustomer = Customer.Create(model);
if (newCustomer == null)
{
return null;
}
using var context = new TransportLogisticDatabase();
context.Customers.Add(newCustomer);
context.SaveChanges();
return newCustomer.GetViewModel;
}
public CustomerViewModel? Update(CustomerBindingModel model)
{
using var context = new TransportLogisticDatabase();
var Customer = context.Customers.FirstOrDefault(x => x.Id == model.Id);
if (Customer == null)
{
return null;
}
Customer.Update(model);
context.SaveChanges();
return Customer.GetViewModel;
}
public CustomerViewModel? Update(CustomerBindingModel model)
{
using var context = new TransportLogisticDatabase();
var Customer = context.Customers.FirstOrDefault(x => x.Id == model.Id);
if (Customer == null)
{
return null;
}
Customer.Update(model);
context.SaveChanges();
return Customer.GetViewModel;
}
public CustomerViewModel? Delete(CustomerBindingModel model)
{
using var context = new TransportLogisticDatabase();
var element = context.Customers.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Customers.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
public CustomerViewModel? Delete(CustomerBindingModel model)
{
using var context = new TransportLogisticDatabase();
var element = context.Customers.FirstOrDefault(x => x.Id == model.Id);
if (element != null)
{
context.Customers.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,79 @@
using TransportLogisticContracts.BindingModels;
using TransportLogisticContracts.SearchModels;
using TransportLogisticContracts.StorageContracts;
using TransportLogisticContracts.ViewModels;
using TransportLogisticDatabaseImplement.Models;
namespace TransportLogisticDatabaseImplement.Implement
{
public class GoodStorage : IGoodStorage
{
public List<GoodViewModel> GetFullList()
{
using var context = new TransportLogisticDatabase();
return context.Goods
.Select(x => x.GetViewModel)
.ToList();
}
public List<GoodViewModel> GetFilteredList(GoodSearchModel model)
{
if (string.IsNullOrEmpty(model.Name))
{
return new();
}
using var context = new TransportLogisticDatabase();
return context.Goods
.Where(x => x.Name.Contains(model.Name))
.Select(x => x.GetViewModel)
.ToList();
}
public GoodViewModel? GetElement(GoodSearchModel model)
{
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
{
return null;
}
using var context = new TransportLogisticDatabase();
return context.Goods
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Name) && x.Name ==
model.Name) || (model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public GoodViewModel? Insert(GoodBindingModel model)
{
var newGood = Good.Create(model);
if (newGood == null)
{
return null;
}
using var context = new TransportLogisticDatabase();
context.Goods.Add(newGood);
context.SaveChanges();
return newGood.GetViewModel;
}
public GoodViewModel? Update(GoodBindingModel model)
{
using var context = new TransportLogisticDatabase();
var Good = context.Goods.FirstOrDefault(x => x.Id == model.Id);
if (Good == null)
{
return null;
}
Good.Update(model);
context.SaveChanges();
return Good.GetViewModel;
}
public GoodViewModel? Delete(GoodBindingModel model)
{
using var context = new TransportLogisticDatabase();
var element = context.Goods.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Goods.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,139 @@
using TransportLogisticContracts.BindingModels;
using TransportLogisticContracts.SearchModels;
using TransportLogisticContracts.StorageContracts;
using TransportLogisticContracts.ViewModels;
using TransportLogisticDatabaseImplement.Models;
using Order = TransportLogisticDatabaseImplement.Models.Order;
using Microsoft.EntityFrameworkCore;
namespace TransportLogisticDatabaseImplement.Implement
{
public class OrderStorage : IOrderStorage
{
public List<OrderViewModel> GetFullList()
{
using var context = new TransportLogisticDatabase();
return context.Orders
.Include(x => x.Storage)
.Include(x => x.Customer)
.Include(x => x.Transports)
.ThenInclude(x => x.Transport)
.Include(x => x.Goods)
.ThenInclude(x => x.Good)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{
using var context = new TransportLogisticDatabase();
if (model.Id.HasValue)
{
return context.Orders
.Include(x => x.Storage)
.Include(x => x.Customer)
.Include(x => x.Transports)
.ThenInclude(x => x.Transport)
.Include(x => x.Goods)
.ThenInclude(x => x.Good)
.Where(x => x.Id == model.Id)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
else if (model.CustomerId.HasValue)
{
return context.Orders
.Include(x => x.Storage)
.Include(x => x.Customer)
.Include(x => x.Transports)
.ThenInclude(x => x.Transport)
.Include(x => x.Goods)
.ThenInclude(x => x.Good)
.Where(x => x.CustomerId == model.CustomerId)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
return new();
}
public OrderViewModel? GetElement(OrderSearchModel model)
{
if (!model.Id.HasValue)
{
return null;
}
using var context = new TransportLogisticDatabase();
return context.Orders
.Include(x => x.Storage)
.Include(x => x.Customer)
.Include(x => x.Transports)
.ThenInclude(x => x.Transport)
.Include(x => x.Goods)
.ThenInclude(x => x.Good)
.FirstOrDefault(x => model.Id.HasValue && x.Id == model.Id)
?.GetViewModel;
}
public OrderViewModel? Insert(OrderBindingModel model)
{
using var context = new TransportLogisticDatabase();
var newOrder = Order.Create(context, model);
if (newOrder == null)
{
return null;
}
context.Orders.Add(newOrder);
context.SaveChanges();
return newOrder.GetViewModel;
}
public OrderViewModel? Update(OrderBindingModel model)
{
using var context = new TransportLogisticDatabase();
using var transaction = context.Database.BeginTransaction();
try
{
var order = context.Orders.FirstOrDefault(rec => rec.Id == model.Id);
if (order == null)
{
return null;
}
order.Update(model);
context.SaveChanges();
order.UpdateTransports(context, model);
order.UpdateGoods(context, model);
transaction.Commit();
return order.GetViewModel;
}
catch
{
transaction.Rollback();
throw;
}
}
public OrderViewModel? Delete(OrderBindingModel model)
{
using var context = new TransportLogisticDatabase();
var element = context.Orders
.Include(x => x.Transports)
.Include(x => x.Goods)
.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
var deletedElement = context.Orders
.Include(x => x.Storage)
.Include(x => x.Customer)
.FirstOrDefault(x => x.Id == model.Id)
?.GetViewModel;
context.Orders.Remove(element);
context.SaveChanges();
return deletedElement;
}
return null;
}
}
}

View File

@ -0,0 +1,83 @@
using TransportLogisticContracts.BindingModels;
using TransportLogisticContracts.SearchModels;
using TransportLogisticContracts.StorageContracts;
using TransportLogisticContracts.ViewModels;
using TransportLogisticDatabaseImplement.Models;
namespace TransportLogisticDatabaseImplement.Implement
{
public class StorageStorage : IStorageStorage
{
public List<StorageViewModel> GetFullList()
{
using var context = new TransportLogisticDatabase();
return context.Storages
.Select(x => x.GetViewModel)
.ToList();
}
public List<StorageViewModel> GetFilteredList(StorageSearchModel model)
{
if (string.IsNullOrEmpty(model.Name))
{
return new();
}
using var context = new TransportLogisticDatabase();
return context.Storages
.Where(x => x.Name.Contains(model.Name))
.Select(x => x.GetViewModel)
.ToList();
}
public StorageViewModel? GetElement(StorageSearchModel model)
{
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
{
return null;
}
using var context = new TransportLogisticDatabase();
return context.Storages.FirstOrDefault(x =>
(!string.IsNullOrEmpty(model.Name) && x.Name == model.Name)
|| (model.Id.HasValue && x.Id == model.Id))?.GetViewModel;
}
public StorageViewModel? Insert(StorageBindingModel model)
{
var newStorage = Storage.Create(model);
if (newStorage == null)
{
return null;
}
using var context = new TransportLogisticDatabase();
context.Storages.Add(newStorage);
context.SaveChanges();
return newStorage.GetViewModel;
}
public StorageViewModel? Update(StorageBindingModel model)
{
using var context = new TransportLogisticDatabase();
var Storage = context.Storages.FirstOrDefault(x => x.Id == model.Id);
if (Storage == null)
{
return null;
}
Storage.Update(model);
context.SaveChanges();
return Storage.GetViewModel;
}
public StorageViewModel? Delete(StorageBindingModel model)
{
using var context = new TransportLogisticDatabase();
var element = context.Storages.FirstOrDefault(x => x.Id == model.Id);
if (element != null)
{
context.Storages.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -0,0 +1,79 @@
using TransportLogisticContracts.BindingModels;
using TransportLogisticContracts.SearchModels;
using TransportLogisticContracts.StorageContracts;
using TransportLogisticContracts.ViewModels;
using TransportLogisticDatabaseImplement.Models;
namespace TransportLogisticDatabaseImplement.Implement
{
public class TransportStorage : ITransportStorage
{
public List<TransportViewModel> GetFullList()
{
using var context = new TransportLogisticDatabase();
return context.Transports
.Select(x => x.GetViewModel)
.ToList();
}
public List<TransportViewModel> GetFilteredList(TransportSearchModel model)
{
if (string.IsNullOrEmpty(model.Type))
{
return new();
}
using var context = new TransportLogisticDatabase();
return context.Transports
.Where(x => x.Type.Contains(model.Type))
.Select(x => x.GetViewModel)
.ToList();
}
public TransportViewModel? GetElement(TransportSearchModel model)
{
if (string.IsNullOrEmpty(model.Type) && !model.Id.HasValue)
{
return null;
}
using var context = new TransportLogisticDatabase();
return context.Transports
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.Type) && x.Type ==
model.Type) || (model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public TransportViewModel? Insert(TransportBindingModel model)
{
var newTransport = Transport.Create(model);
if (newTransport == null)
{
return null;
}
using var context = new TransportLogisticDatabase();
context.Transports.Add(newTransport);
context.SaveChanges();
return newTransport.GetViewModel;
}
public TransportViewModel? Update(TransportBindingModel model)
{
using var context = new TransportLogisticDatabase();
var Transport = context.Transports.FirstOrDefault(x => x.Id == model.Id);
if (Transport == null)
{
return null;
}
Transport.Update(model);
context.SaveChanges();
return Transport.GetViewModel;
}
public TransportViewModel? Delete(TransportBindingModel model)
{
using var context = new TransportLogisticDatabase();
var element = context.Transports.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Transports.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -12,6 +12,10 @@ namespace TransportLogisticDatabaseImplement.Models
public int Id { get; private set; }
[Required]
public string Name { get; private set; } = string.Empty;
[Required]
public string Lastname { get; private set; } = string.Empty;
[Required]
public string Email { get; private set; } = string.Empty;
[ForeignKey("CustomerId")]
public virtual List<Order> Order { get; set; } = new();
@ -26,6 +30,8 @@ namespace TransportLogisticDatabaseImplement.Models
{
Id = model.Id,
Name = model.Name,
Lastname = model.Lastname,
Email = model.Email,
};
}
@ -35,6 +41,8 @@ namespace TransportLogisticDatabaseImplement.Models
{
Id = model.Id,
Name = model.Name,
Lastname = model.Lastname,
Email = model.Email,
};
}
@ -45,12 +53,16 @@ namespace TransportLogisticDatabaseImplement.Models
return;
}
Name = model.Name;
Lastname = model.Lastname;
Email = model.Email;
}
public CustomerViewModel GetViewModel => new()
{
Id = Id,
Name = Name
Name = Name,
Lastname = Lastname,
Email = Email,
};
}
}

View File

@ -0,0 +1,61 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using TransportLogisticDataModels;
using TransportLogisticContracts.BindingModels;
using TransportLogisticContracts.ViewModels;
namespace TransportLogisticDatabaseImplement.Models
{
public class Good : IGoodModel
{
public int Id { get; private set; }
[Required]
public string Name { get; private set; } = string.Empty;
public double Weight { get; private set; }
public string Size { get; private set; } = string.Empty;
[ForeignKey("GoodId")]
public virtual List<OrderGood> OrderGoods{ get; set; } = new();
public static Good? Create(GoodBindingModel model)
{
if (model == null)
{
return null;
}
return new Good()
{
Id = model.Id,
Name = model.Name,
Weight = model.Weight,
Size = model.Size
};
}
public static Good Create(GoodViewModel model)
{
return new Good
{
Id = model.Id,
Name = model.Name,
Weight = model.Weight,
Size = model.Size
};
}
public void Update(GoodBindingModel model)
{
if (model == null)
{
return;
}
Name = model.Name;
Weight = model.Weight;
Size = model.Size;
}
public GoodViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
Weight = Weight,
Size = Size
};
}
}

View File

@ -0,0 +1,179 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using TransportLogisticContracts.BindingModels;
using TransportLogisticContracts.ViewModels;
using TransportLogisticDataModels;
using TransportLogisticDataModels.Enums;
namespace TransportLogisticDatabaseImplement.Models
{
public class Order : IOrderModel
{
public int Id { get; set; }
[Required]
public OrderStatus Status { get; set; }
[Required]
public DateTime DateCreate { get; set; }
public DateTime? DateDelivered { get; set; }
public int StartStorageId { get; set; }
[Required]
public int FinishStorageId { get; set; }
[Required]
public int CustomerId { get; set; }
[Required]
private Dictionary<int, (ITransportModel, int)>? _orderTransports = null;
[NotMapped]
public Dictionary<int, (ITransportModel, int)> OrderTransports
{
get
{
if (_orderTransports == null)
{
_orderTransports = Transports
.ToDictionary(recPC => recPC.TransportId, recPC =>
(recPC.Transport as ITransportModel, recPC.TransportsCount));
}
return _orderTransports;
}
}
[ForeignKey("OrderId")]
public virtual List<OrderTransport> Transports{ get; set; } = new();
private Dictionary<int, (IGoodModel, int)>? _orderGoods = null;
[NotMapped]
public Dictionary<int, (IGoodModel, int)> OrderGoods
{
get
{
if (_orderGoods == null)
{
_orderGoods = Goods
.ToDictionary(recPC => recPC.GoodId, recPC =>
(recPC.Good as IGoodModel, recPC.GoodsCount));
}
return _orderGoods;
}
}
[ForeignKey("OrderId")]
public virtual List<OrderGood> Goods { get; set; } = new();
public virtual Transport Transport{ get; set; }
public virtual Good Good { get; set; }
public virtual Customer Customer { get; set; }
public virtual Storage Storage { get; set; }
public static Order? Create(TransportLogisticDatabase context, OrderBindingModel? model)
{
if (model == null)
{
return null;
}
return new Order()
{
Id = model.Id,
Status = model.Status,
DateCreate = model.DateCreate,
DateDelivered = model.DateDelivered,
StartStorageId = model.StartStorageId,
FinishStorageId = model.FinishStorageId,
CustomerId = model.CustomerId,
Transports = model.OrderTransports.Select(x => new OrderTransport
{
Transport = context.Transports.First(y => y.Id == x.Key),
TransportsCount = x.Value.Item2
}).ToList(),
Goods = model.OrderGoods.Select(q => new OrderGood
{
Good = context.Goods.First(z => z.Id == q.Key),
GoodsCount = q.Value.Item2
}).ToList()
};
}
public void Update(OrderBindingModel? model)
{
if (model == null)
{
return;
}
Status = model.Status;
DateDelivered = model.DateDelivered;
}
public OrderViewModel GetViewModel => new()
{
Id = Id,
Status = Status,
DateCreate = DateCreate,
DateDelivered = DateDelivered,
StartStorageId = StartStorageId,
FinishStorageId = FinishStorageId,
CustomerId = CustomerId,
OrderTransports = OrderTransports,
OrderGoods = OrderGoods
};
public void UpdateTransports(TransportLogisticDatabase context, OrderBindingModel model)
{
var orderTransports = context.OrderTransports.Where(rec => rec.OrderId == model.Id).ToList();
if (orderTransports != null && orderTransports.Count > 0)
{ // удалили те, которых нет в модели
context.OrderTransports.RemoveRange(orderTransports.Where(rec => !model.OrderTransports.ContainsKey(rec.TransportId)));
context.SaveChanges();
// обновили количество у существующих записей
foreach (var updateTransport in orderTransports)
{
updateTransport.TransportsCount = model.OrderTransports[updateTransport.TransportId].Item2;
model.OrderTransports.Remove(updateTransport.TransportId);
}
context.SaveChanges();
}
var reinforced = context.Orders.First(x => x.Id == Id);
foreach (var rp in model.OrderTransports)
{
context.OrderTransports.Add(new OrderTransport
{
Order = reinforced,
Transport = context.Transports.First(x => x.Id == rp.Key),
TransportsCount = rp.Value.Item2
});
context.SaveChanges();
}
_orderTransports = null;
}
public void UpdateGoods(TransportLogisticDatabase context, OrderBindingModel model)
{
var orderGoods = context.OrderGoods.Where(rec => rec.OrderId == model.Id).ToList();
if (orderGoods != null && orderGoods.Count > 0)
{ // удалили те, которых нет в модели
context.OrderGoods.RemoveRange(orderGoods.Where(rec => !model.OrderGoods.ContainsKey(rec.GoodId)));
context.SaveChanges();
// обновили количество у существующих записей
foreach (var updateGood in orderGoods)
{
updateGood.GoodsCount = model.OrderGoods[updateGood.GoodId].Item2;
model.OrderGoods.Remove(updateGood.GoodId);
}
context.SaveChanges();
}
var reinforced = context.Orders.First(x => x.Id == Id);
foreach (var rp in model.OrderGoods)
{
context.OrderGoods.Add(new OrderGood
{
Order = reinforced,
Good = context.Goods.First(x => x.Id == rp.Key),
GoodsCount = rp.Value.Item2
});
context.SaveChanges();
}
_orderTransports = null;
}
}
}

View File

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TransportLogisticDatabaseImplement.Models
{
public class OrderGood
{
public int Id { get; set; }
[Required]
public int OrderId { get; set; }
[Required]
public int GoodId { get; set; }
[Required]
public int GoodsCount { get; set; }
[Required]
public virtual Order Order{ get; set; } = new();
public virtual Good Good { get; set; } = new();
}
}

View File

@ -0,0 +1,20 @@
using System.ComponentModel.DataAnnotations;
namespace TransportLogisticDatabaseImplement.Models
{
public class OrderTransport
{
public int Id { get; set; }
[Required]
public int OrderId { get; set; }
[Required]
public int TransportId { get; set; }
[Required]
public int TransportsCount { get; set; }
[Required]
public virtual Order Order{ get; set; } = new();
public virtual Transport Transport{ get; set; } = new();
}
}

View File

@ -0,0 +1,53 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using TransportLogisticDataModels;
using TransportLogisticContracts.BindingModels;
using TransportLogisticContracts.ViewModels;
namespace TransportLogisticDatabaseImplement.Models
{
public class Storage : IStorageModel
{
public int Id { get; private set; }
[Required]
public string Name { get; private set; } = string.Empty;
[Required]
public string Address { get; private set; } = string.Empty;
[ForeignKey("StorageId")]
public virtual List<Order> Orders{ get; set; } = new();
public static Storage? Create(StorageBindingModel model)
{
if (model == null)
{
return null;
}
return new()
{
Id = model.Id,
Name = model.Name,
Address = model.Address
};
}
public void Update(StorageBindingModel model)
{
if (model == null)
{
return;
}
Name = model.Name;
Address = model.Address;
}
public StorageViewModel GetViewModel => new()
{
Id = Id,
Name = Name,
Address = Address
};
}
}

View File

@ -0,0 +1,56 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
using TransportLogisticDataModels;
using TransportLogisticContracts.ViewModels;
using TransportLogisticContracts.BindingModels;
namespace TransportLogisticDatabaseImplement.Models
{
public class Transport : ITransportModel
{
public int Id { get; set; }
[Required]
public string Type { get; set; } = string.Empty;
public double LoadCapacity { get; set; }
[ForeignKey("TransportId")]
public virtual List<OrderTransport> OrderTransports { get; set; } = new();
public static Transport? Create(TransportBindingModel model)
{
if (model == null)
{
return null;
}
return new Transport()
{
Id = model.Id,
Type = model.Type,
LoadCapacity = model.LoadCapacity
};
}
public static Transport Create(TransportViewModel model)
{
return new Transport
{
Id = model.Id,
Type = model.Type,
LoadCapacity = model.LoadCapacity
};
}
public void Update(TransportBindingModel model)
{
if (model == null)
{
return;
}
Type = model.Type;
LoadCapacity = model.LoadCapacity;
}
public TransportViewModel GetViewModel => new()
{
Id = Id,
Type = Type,
LoadCapacity = LoadCapacity
};
}
}

View File

@ -1,7 +1,5 @@
using System.Collections.Generic;
using System.ComponentModel;
using Microsoft.EntityFrameworkCore;
using TransportLogisticDatabaseImplement.Models;
using Microsoft.EntityFrameworkCore;
namespace TransportLogisticDatabaseImplement
{
@ -19,7 +17,9 @@ namespace TransportLogisticDatabaseImplement
public virtual DbSet<Customer> Customers { get; set; }
public virtual DbSet<Storage> Storages { get; set; }
public virtual DbSet<Transport> Transports { set; get; }
public virtual DbSet<OrderTransport> OrderTransports { set; get; }
public virtual DbSet<Order> Orders { set; get; }
public virtual DbSet<Good> Goods{ set; get; }
public virtual DbSet<OrderGood> OrderGoods{ set; get; }
}
}

View File

@ -0,0 +1,383 @@
namespace TransportLogisticForm
{
partial class FormCreateOrder
{
/// <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()
{
label1 = new Label();
label2 = new Label();
label3 = new Label();
comboBoxStart = new ComboBox();
comboBoxFinish = new ComboBox();
comboBoxCustomer = new ComboBox();
buttonSave = new Button();
buttonCancel = new Button();
groupBoxTransports = new GroupBox();
buttonUpd = new Button();
buttonDel = new Button();
buttonEdit = new Button();
buttonAdd = new Button();
dataGridView = new DataGridView();
ColumnId = new DataGridViewTextBoxColumn();
ColumnName = new DataGridViewTextBoxColumn();
ColumnCount = new DataGridViewTextBoxColumn();
groupBoxGoods = new GroupBox();
button1 = new Button();
button2 = new Button();
button3 = new Button();
button4 = new Button();
dataGridView1 = new DataGridView();
dataGridViewTextBoxColumn1 = new DataGridViewTextBoxColumn();
dataGridViewTextBoxColumn2 = new DataGridViewTextBoxColumn();
dataGridViewTextBoxColumn3 = new DataGridViewTextBoxColumn();
groupBoxTransports.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
groupBoxGoods.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
SuspendLayout();
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(25, 21);
label1.Name = "label1";
label1.Size = new Size(133, 20);
label1.TabIndex = 0;
label1.Text = "Точка отбывания:";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(25, 64);
label2.Name = "label2";
label2.Size = new Size(145, 20);
label2.TabIndex = 1;
label2.Text = "Точка прибывания:";
//
// label3
//
label3.AutoSize = true;
label3.Location = new Point(25, 107);
label3.Name = "label3";
label3.Size = new Size(74, 20);
label3.TabIndex = 2;
label3.Text = "Заказчик:";
//
// comboBoxStart
//
comboBoxStart.FormattingEnabled = true;
comboBoxStart.Location = new Point(193, 18);
comboBoxStart.Name = "comboBoxStart";
comboBoxStart.Size = new Size(271, 28);
comboBoxStart.TabIndex = 3;
//
// comboBoxFinish
//
comboBoxFinish.FormattingEnabled = true;
comboBoxFinish.Location = new Point(193, 61);
comboBoxFinish.Name = "comboBoxFinish";
comboBoxFinish.Size = new Size(271, 28);
comboBoxFinish.TabIndex = 4;
//
// comboBoxCustomer
//
comboBoxCustomer.FormattingEnabled = true;
comboBoxCustomer.Location = new Point(193, 104);
comboBoxCustomer.Name = "comboBoxCustomer";
comboBoxCustomer.Size = new Size(271, 28);
comboBoxCustomer.TabIndex = 5;
//
// buttonSave
//
buttonSave.Location = new Point(267, 444);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(152, 51);
buttonSave.TabIndex = 6;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(448, 444);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(152, 51);
buttonCancel.TabIndex = 7;
buttonCancel.Text = " Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// groupBoxTransports
//
groupBoxTransports.Controls.Add(buttonUpd);
groupBoxTransports.Controls.Add(buttonDel);
groupBoxTransports.Controls.Add(buttonEdit);
groupBoxTransports.Controls.Add(buttonAdd);
groupBoxTransports.Controls.Add(dataGridView);
groupBoxTransports.Location = new Point(12, 148);
groupBoxTransports.Name = "groupBoxTransports";
groupBoxTransports.Size = new Size(407, 290);
groupBoxTransports.TabIndex = 8;
groupBoxTransports.TabStop = false;
groupBoxTransports.Text = "Транспорт";
//
// buttonUpd
//
buttonUpd.Location = new Point(308, 214);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(93, 32);
buttonUpd.TabIndex = 4;
buttonUpd.Text = "Обновить";
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += buttonUpd_Click;
//
// buttonDel
//
buttonDel.Location = new Point(308, 155);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(93, 32);
buttonDel.TabIndex = 3;
buttonDel.Text = "Удалить";
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += buttonDel_Click;
//
// buttonEdit
//
buttonEdit.Location = new Point(308, 96);
buttonEdit.Name = "buttonEdit";
buttonEdit.Size = new Size(93, 32);
buttonEdit.TabIndex = 2;
buttonEdit.Text = "Изменить";
buttonEdit.UseVisualStyleBackColor = true;
buttonEdit.Click += buttonEdit_Click;
//
// buttonAdd
//
buttonAdd.Location = new Point(308, 38);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(93, 32);
buttonAdd.TabIndex = 1;
buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.BackgroundColor = SystemColors.ControlLightLight;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ColumnId, ColumnName, ColumnCount });
dataGridView.Location = new Point(6, 27);
dataGridView.Name = "dataGridView";
dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false;
dataGridView.RowHeadersWidth = 51;
dataGridView.RowTemplate.Height = 29;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(296, 229);
dataGridView.TabIndex = 0;
//
// ColumnId
//
ColumnId.HeaderText = "Id";
ColumnId.MinimumWidth = 6;
ColumnId.Name = "ColumnId";
ColumnId.ReadOnly = true;
ColumnId.Visible = false;
ColumnId.Width = 125;
//
// ColumnName
//
ColumnName.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
ColumnName.FillWeight = 100.53476F;
ColumnName.HeaderText = "Транспорт";
ColumnName.MinimumWidth = 6;
ColumnName.Name = "ColumnName";
ColumnName.ReadOnly = true;
//
// ColumnCount
//
ColumnCount.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
ColumnCount.HeaderText = "Количество транспорта";
ColumnCount.MinimumWidth = 6;
ColumnCount.Name = "ColumnCount";
ColumnCount.ReadOnly = true;
//
// groupBoxGoods
//
groupBoxGoods.Controls.Add(button1);
groupBoxGoods.Controls.Add(button2);
groupBoxGoods.Controls.Add(button3);
groupBoxGoods.Controls.Add(button4);
groupBoxGoods.Controls.Add(dataGridView1);
groupBoxGoods.Location = new Point(448, 148);
groupBoxGoods.Name = "groupBoxGoods";
groupBoxGoods.Size = new Size(407, 290);
groupBoxGoods.TabIndex = 9;
groupBoxGoods.TabStop = false;
groupBoxGoods.Text = "Товары";
//
// button1
//
button1.Location = new Point(308, 214);
button1.Name = "button1";
button1.Size = new Size(93, 32);
button1.TabIndex = 4;
button1.Text = "Обновить";
button1.UseVisualStyleBackColor = true;
button1.Click += button1_Click;
//
// button2
//
button2.Location = new Point(308, 155);
button2.Name = "button2";
button2.Size = new Size(93, 32);
button2.TabIndex = 3;
button2.Text = "Удалить";
button2.UseVisualStyleBackColor = true;
button2.Click += button2_Click;
//
// button3
//
button3.Location = new Point(308, 96);
button3.Name = "button3";
button3.Size = new Size(93, 32);
button3.TabIndex = 2;
button3.Text = "Изменить";
button3.UseVisualStyleBackColor = true;
button3.Click += button3_Click;
//
// button4
//
button4.Location = new Point(308, 38);
button4.Name = "button4";
button4.Size = new Size(93, 32);
button4.TabIndex = 1;
button4.Text = "Добавить";
button4.UseVisualStyleBackColor = true;
button4.Click += button4_Click;
//
// dataGridView1
//
dataGridView1.AllowUserToAddRows = false;
dataGridView1.AllowUserToDeleteRows = false;
dataGridView1.BackgroundColor = SystemColors.ControlLightLight;
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Columns.AddRange(new DataGridViewColumn[] { dataGridViewTextBoxColumn1, dataGridViewTextBoxColumn2, dataGridViewTextBoxColumn3 });
dataGridView1.Location = new Point(6, 27);
dataGridView1.Name = "dataGridView1";
dataGridView1.ReadOnly = true;
dataGridView1.RowHeadersVisible = false;
dataGridView1.RowHeadersWidth = 51;
dataGridView1.RowTemplate.Height = 29;
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView1.Size = new Size(296, 229);
dataGridView1.TabIndex = 0;
//
// dataGridViewTextBoxColumn1
//
dataGridViewTextBoxColumn1.HeaderText = "Id";
dataGridViewTextBoxColumn1.MinimumWidth = 6;
dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
dataGridViewTextBoxColumn1.ReadOnly = true;
dataGridViewTextBoxColumn1.Visible = false;
dataGridViewTextBoxColumn1.Width = 125;
//
// dataGridViewTextBoxColumn2
//
dataGridViewTextBoxColumn2.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridViewTextBoxColumn2.FillWeight = 100.53476F;
dataGridViewTextBoxColumn2.HeaderText = "Товар";
dataGridViewTextBoxColumn2.MinimumWidth = 6;
dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
dataGridViewTextBoxColumn2.ReadOnly = true;
//
// dataGridViewTextBoxColumn3
//
dataGridViewTextBoxColumn3.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridViewTextBoxColumn3.HeaderText = "Количество товаров";
dataGridViewTextBoxColumn3.MinimumWidth = 6;
dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
dataGridViewTextBoxColumn3.ReadOnly = true;
//
// FormCreateOrder
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(867, 507);
Controls.Add(groupBoxGoods);
Controls.Add(groupBoxTransports);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(comboBoxCustomer);
Controls.Add(comboBoxFinish);
Controls.Add(comboBoxStart);
Controls.Add(label3);
Controls.Add(label2);
Controls.Add(label1);
Name = "FormCreateOrder";
Text = "Создание заказа";
Load += FormCreateOrder_Load;
groupBoxTransports.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
groupBoxGoods.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label label1;
private Label label2;
private Label label3;
private ComboBox comboBoxStart;
private ComboBox comboBoxFinish;
private ComboBox comboBoxCustomer;
private Button buttonSave;
private Button buttonCancel;
private GroupBox groupBoxTransports;
private Button buttonUpd;
private Button buttonDel;
private Button buttonEdit;
private Button buttonAdd;
private DataGridView dataGridView;
private DataGridViewTextBoxColumn ColumnId;
private DataGridViewTextBoxColumn ColumnName;
private DataGridViewTextBoxColumn ColumnCount;
private GroupBox groupBoxGoods;
private Button button1;
private Button button2;
private Button button3;
private Button button4;
private DataGridView dataGridView1;
private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
private DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
}
}

View File

@ -0,0 +1,315 @@
using System.Windows.Forms;
using TransportLogisticContracts.BindingModels;
using TransportLogisticContracts.BusinessLogicsContracts;
using TransportLogisticContracts.SearchModels;
using TransportLogisticDataModels;
namespace TransportLogisticForm
{
public partial class FormCreateOrder : Form
{
private readonly IStorageLogic _logicS;
private readonly IOrderLogic _logicO;
private readonly ICustomerLogic _logicC;
private int? _id;
private Dictionary<int, (ITransportModel, int)> _orderTransports;
private Dictionary<int, (IGoodModel, int)> _orderGoods;
public int Id { set { _id = value; } }
public FormCreateOrder(IStorageLogic logicS, IOrderLogic logicO,
ICustomerLogic logicC)
{
_logicS = logicS;
_logicO = logicO;
_logicC = logicC;
_orderTransports = new Dictionary<int, (ITransportModel, int)>();
_orderGoods = new Dictionary<int, (IGoodModel, int)>();
InitializeComponent();
}
private void FormCreateOrder_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
var view = _logicO.ReadElement(new OrderSearchModel { Id = _id.Value });
if (view != null)
{
_orderTransports = view.OrderTransports ?? new Dictionary<int, (ITransportModel, int)>();
_orderGoods = view.OrderGoods ?? new Dictionary<int, (IGoodModel, int)>();
LoadData();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
try
{
var startList = _logicS.ReadList(null);
if (startList != null)
{
comboBoxStart.DisplayMember = "Name";
comboBoxStart.DisplayMember = "Address";
comboBoxStart.ValueMember = "Id";
comboBoxStart.DataSource = startList;
comboBoxStart.SelectedItem = null;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
var finishList = _logicS.ReadList(null);
if (finishList != null)
{
comboBoxFinish.DisplayMember = "Name";
comboBoxFinish.DisplayMember = "Address";
comboBoxFinish.ValueMember = "Id";
comboBoxFinish.DataSource = finishList;
comboBoxFinish.SelectedItem = null;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
var customerList = _logicC.ReadList(null);
if (customerList != null)
{
comboBoxFinish.DisplayMember = "Name";
comboBoxFinish.DisplayMember = "Lastname";
comboBoxFinish.DisplayMember = "Email";
comboBoxFinish.ValueMember = "Id";
comboBoxFinish.DataSource = customerList;
comboBoxFinish.SelectedItem = null;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void LoadData()
{
try
{
if (_orderGoods != null && _orderTransports != null)
{
dataGridView.Rows.Clear();
foreach (var pc in _orderGoods)
{
dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.Name, pc.Value.Item2 });
}
foreach (var pc in _orderTransports)
{
dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.Type, pc.Value.Item2 });
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonSave_Click(object sender, EventArgs e)
{
if (comboBoxStart.SelectedValue == null)
{
MessageBox.Show("Выберите склад", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxFinish.SelectedValue == null)
{
MessageBox.Show("Выберите склад", "Ошибка",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBoxCustomer.SelectedValue == null)
{
MessageBox.Show("Выберите заказчика", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
var operationResult = _logicO.CreateOrder(new OrderBindingModel
{
StartStorageId = Convert.ToInt32(comboBoxStart.SelectedValue),
FinishStorageId = Convert.ToInt32(comboBoxFinish.SelectedValue),
CustomerId = Convert.ToInt32(comboBoxCustomer.SelectedValue)
});
if (!operationResult)
{
throw new Exception("Ошибка при создании заказа.Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
private void buttonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormOrderTransports));
if (service is FormOrderTransports form)
{
if (form.ShowDialog() == DialogResult.OK)
{
if (form.TransportModel == null)
{
return;
}
if (_orderTransports.ContainsKey(form.Id))
{
_orderTransports[form.Id] = (form.TransportModel, form.TransportsCount);
}
else
{
_orderTransports.Add(form.Id, (form.TransportModel, form.TransportsCount));
}
LoadData();
}
}
}
private void buttonEdit_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormOrderTransports));
if (service is FormOrderTransports form)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
form.Id = id;
form.TransportsCount = _orderTransports[id].Item2;
if (form.ShowDialog() == DialogResult.OK)
{
if (form.TransportModel == null)
{
return;
}
_orderTransports[form.Id] = (form.TransportModel, form.TransportsCount);
LoadData();
}
}
}
}
private void buttonDel_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
try
{
_orderTransports?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
LoadData();
}
}
}
private void buttonUpd_Click(object sender, EventArgs e)
{
LoadData();
}
private void button4_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormOrderGoods));
if (service is FormOrderGoods form)
{
if (form.ShowDialog() == DialogResult.OK)
{
if (form.GoodModel == null)
{
return;
}
if (_orderGoods.ContainsKey(form.Id))
{
_orderGoods[form.Id] = (form.GoodModel, form.GoodsCount);
}
else
{
_orderGoods.Add(form.Id, (form.GoodModel, form.GoodsCount));
}
LoadData();
}
}
}
private void button3_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormOrderGoods));
if (service is FormOrderGoods form)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
form.Id = id;
form.GoodsCount = _orderGoods[id].Item2;
if (form.ShowDialog() == DialogResult.OK)
{
if (form.GoodModel == null)
{
return;
}
_orderGoods[form.Id] = (form.GoodModel, form.GoodsCount);
LoadData();
}
}
}
}
private void button2_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
try
{
_orderGoods?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
LoadData();
}
}
}
private void button1_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

@ -0,0 +1,138 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="ColumnId.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ColumnCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="dataGridViewTextBoxColumn3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

View File

@ -0,0 +1,117 @@
namespace TransportLogisticForm
{
partial class FormCustomers
{
/// <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()
{
dataGridView1 = new DataGridView();
buttonUpd = new Button();
buttonDel = new Button();
button1 = new Button();
button2 = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
SuspendLayout();
//
// dataGridView1
//
dataGridView1.AllowUserToAddRows = false;
dataGridView1.AllowUserToDeleteRows = false;
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Location = new Point(1, 1);
dataGridView1.MultiSelect = false;
dataGridView1.Name = "dataGridView1";
dataGridView1.ReadOnly = true;
dataGridView1.RowTemplate.Height = 29;
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView1.Size = new Size(529, 498);
dataGridView1.TabIndex = 1;
//
// buttonUpd
//
buttonUpd.Location = new Point(556, 166);
buttonUpd.Margin = new Padding(5, 4, 5, 4);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(113, 53);
buttonUpd.TabIndex = 10;
buttonUpd.Text = "Обновить";
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += buttonUpd_Click;
//
// buttonDel
//
buttonDel.Location = new Point(556, 105);
buttonDel.Margin = new Padding(5, 4, 5, 4);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(113, 53);
buttonDel.TabIndex = 9;
buttonDel.Text = "Удалить";
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += buttonDel_Click;
//
// button1
//
button1.Location = new Point(574, 249);
button1.Name = "button1";
button1.Size = new Size(75, 23);
button1.TabIndex = 11;
button1.Text = "button1";
button1.UseVisualStyleBackColor = true;
//
// button2
//
button2.Location = new Point(579, 316);
button2.Name = "button2";
button2.Size = new Size(75, 23);
button2.TabIndex = 12;
button2.Text = "button2";
button2.UseVisualStyleBackColor = true;
//
// FormCustomers
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(683, 498);
Controls.Add(button2);
Controls.Add(button1);
Controls.Add(buttonUpd);
Controls.Add(buttonDel);
Controls.Add(dataGridView1);
Name = "FormCustomers";
Text = "Заказчики";
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView1;
private Button buttonUpd;
private Button buttonDel;
private Button button1;
private Button button2;
}
}

View File

@ -0,0 +1,68 @@
using System.Windows.Forms;
using TransportLogisticContracts.BindingModels;
using TransportLogisticContracts.BusinessLogicsContracts;
namespace TransportLogisticForm
{
public partial class FormCustomers : Form
{
private readonly ICustomerLogic _logic;
public FormCustomers(ICustomerLogic logic)
{
_logic = logic;
InitializeComponent();
}
private void FormCustomers_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView1.DataSource = list;
dataGridView1.Columns["Id"].Visible = false;
dataGridView1.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView1.Columns["Lastname"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView1.Columns["Email"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonDel_Click(object sender, EventArgs e)
{
if (dataGridView1.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить заказчика?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
try
{
if (!_logic.Delete(new CustomerBindingModel { Id = id }))
{
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void buttonUpd_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View 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>

View File

@ -0,0 +1,96 @@
namespace TransportLogisticForm
{
partial class FormGood
{
/// <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()
{
label1 = new Label();
textBoxName = new TextBox();
buttonCancel = new Button();
buttonSave = new Button();
SuspendLayout();
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(12, 23);
label1.Name = "label1";
label1.Size = new Size(80, 20);
label1.TabIndex = 0;
label1.Text = "Название:";
//
// textBoxName
//
textBoxName.Location = new Point(98, 20);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(269, 27);
textBoxName.TabIndex = 1;
//
// buttonCancel
//
buttonCancel.Location = new Point(272, 68);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(95, 43);
buttonCancel.TabIndex = 3;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(171, 68);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(95, 43);
buttonSave.TabIndex = 4;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// FormGood
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(391, 132);
Controls.Add(buttonSave);
Controls.Add(buttonCancel);
Controls.Add(textBoxName);
Controls.Add(label1);
Name = "FormGood";
Text = "Товар";
Load += FormGood_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label label1;
private TextBox textBoxName;
private Button buttonCancel;
private Button buttonSave;
}
}

View File

@ -0,0 +1,72 @@
using TransportLogisticContracts.BindingModels;
using TransportLogisticContracts.BusinessLogicsContracts;
using TransportLogisticContracts.SearchModels;
namespace TransportLogisticForm
{
public partial class FormGood : Form
{
private readonly IGoodLogic _logic;
private int? _id;
public int Id { set { _id = value; } }
public FormGood(IGoodLogic logic)
{
_logic = logic;
InitializeComponent();
}
private void FormGood_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
var view = _logic.ReadElement(new GoodSearchModel { Id = _id.Value });
if (view != null)
{
textBoxName.Text = view.Name;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void buttonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxName.Text))
{
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
var model = new GoodBindingModel
{
Id = _id ?? 0,
Name = textBoxName.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)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View 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>

View File

@ -0,0 +1,112 @@
namespace TransportLogisticForm
{
partial class FormGoods
{
/// <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();
buttonAdd = new Button();
buttonUpd = new Button();
buttonDel = new Button();
buttonEdit = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// dataGridView
//
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(-1, 0);
dataGridView.Name = "dataGridView";
dataGridView.RowTemplate.Height = 29;
dataGridView.Size = new Size(437, 442);
dataGridView.TabIndex = 0;
//
// buttonAdd
//
buttonAdd.Location = new Point(446, 62);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(128, 53);
buttonAdd.TabIndex = 2;
buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// buttonUpd
//
buttonUpd.Location = new Point(446, 239);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(128, 53);
buttonUpd.TabIndex = 7;
buttonUpd.Text = "Обновить";
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += buttonUpd_Click;
//
// buttonDel
//
buttonDel.Location = new Point(446, 180);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(128, 53);
buttonDel.TabIndex = 6;
buttonDel.Text = "Удалить";
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += buttonDel_Click;
//
// buttonEdit
//
buttonEdit.Location = new Point(446, 121);
buttonEdit.Name = "buttonEdit";
buttonEdit.Size = new Size(128, 53);
buttonEdit.TabIndex = 5;
buttonEdit.Text = "Изменить";
buttonEdit.UseVisualStyleBackColor = true;
buttonEdit.Click += buttonEdit_Click;
//
// FormGoods
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(586, 443);
Controls.Add(buttonUpd);
Controls.Add(buttonDel);
Controls.Add(buttonEdit);
Controls.Add(buttonAdd);
Controls.Add(dataGridView);
Name = "FormGoods";
Text = "Товары";
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button buttonAdd;
private Button buttonUpd;
private Button buttonDel;
private Button buttonEdit;
}
}

View File

@ -0,0 +1,94 @@
using TransportLogisticContracts.BindingModels;
using TransportLogisticContracts.BusinessLogicsContracts;
namespace TransportLogisticForm
{
public partial class FormGoods : Form
{
private readonly IGoodLogic _logic;
public FormGoods(IGoodLogic logic)
{
InitializeComponent();
_logic = logic;
}
private void FormGoods_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["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["Weight"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["Size"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormGood));
if (service is FormGood form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void buttonEdit_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormGood));
if (service is FormGood 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);
try
{
if (!_logic.Delete(new GoodBindingModel { Id = id }))
{
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void buttonUpd_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View 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>

View File

@ -67,28 +67,28 @@ namespace TransportLogisticForm
// ЗаказчикиToolStripMenuItem
//
ЗаказчикиToolStripMenuItem.Name = "ЗаказчикиToolStripMenuItem";
ЗаказчикиToolStripMenuItem.Size = new Size(152, 24);
ЗаказчикиToolStripMenuItem.Size = new Size(180, 24);
ЗаказчикиToolStripMenuItem.Text = "Заказчики";
ЗаказчикиToolStripMenuItem.Click += ЗаказчикиToolStripMenuItem_Click;
//
// ТоварыToolStripMenuItem
//
ТоварыToolStripMenuItem.Name = "ТоварыToolStripMenuItem";
ТоварыToolStripMenuItem.Size = new Size(152, 24);
ТоварыToolStripMenuItem.Size = new Size(180, 24);
ТоварыToolStripMenuItem.Text = "Товары";
ТоварыToolStripMenuItem.Click += ТоварыToolStripMenuItem_Click;
//
// СкладыToolStripMenuItem
//
СкладыToolStripMenuItem.Name = "СкладыToolStripMenuItem";
СкладыToolStripMenuItem.Size = new Size(152, 24);
СкладыToolStripMenuItem.Size = new Size(180, 24);
СкладыToolStripMenuItem.Text = "Склады";
СкладыToolStripMenuItem.Click += СкладыToolStripMenuItem_Click;
//
// ТранспортToolStripMenuItem
//
ТранспортToolStripMenuItem.Name = "ТранспортToolStripMenuItem";
ТранспортToolStripMenuItem.Size = new Size(152, 24);
ТранспортToolStripMenuItem.Size = new Size(180, 24);
ТранспортToolStripMenuItem.Text = "Транспорт";
ТранспортToolStripMenuItem.Click += ТранспортToolStripMenuItem_Click;
//
@ -176,6 +176,7 @@ namespace TransportLogisticForm
Name = "FormMain";
StartPosition = FormStartPosition.CenterScreen;
Text = "Транспортная логистика";
Load += FormMain_Load;
menuStrip.ResumeLayout(false);
menuStrip.PerformLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();

View File

@ -0,0 +1,118 @@
namespace TransportLogisticForm
{
partial class FormOrderGoods
{
/// <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()
{
textBox = new TextBox();
buttonCancel = new Button();
buttonSave = new Button();
comboBox = new ComboBox();
label2 = new Label();
label1 = new Label();
SuspendLayout();
//
// textBox
//
textBox.Location = new Point(188, 71);
textBox.Name = "textBox";
textBox.Size = new Size(216, 27);
textBox.TabIndex = 14;
//
// buttonCancel
//
buttonCancel.Location = new Point(300, 127);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(104, 39);
buttonCancel.TabIndex = 13;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(188, 127);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(104, 39);
buttonSave.TabIndex = 12;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// comboBox
//
comboBox.FormattingEnabled = true;
comboBox.Location = new Point(119, 23);
comboBox.Name = "comboBox";
comboBox.Size = new Size(285, 28);
comboBox.TabIndex = 11;
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(21, 74);
label2.Name = "label2";
label2.Size = new Size(154, 20);
label2.TabIndex = 10;
label2.Text = "Количество товаров:";
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(21, 26);
label1.Name = "label1";
label1.Size = new Size(54, 20);
label1.TabIndex = 9;
label1.Text = "Товар:";
//
// FormOrderGoods
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(428, 188);
Controls.Add(textBox);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(comboBox);
Controls.Add(label2);
Controls.Add(label1);
Name = "FormOrderGoods";
Text = "Товары";
ResumeLayout(false);
PerformLayout();
}
#endregion
private TextBox textBox;
private Button buttonCancel;
private Button buttonSave;
private ComboBox comboBox;
private Label label2;
private Label label1;
}
}

View File

@ -0,0 +1,66 @@
using TransportLogisticContracts.BusinessLogicsContracts;
using TransportLogisticContracts.ViewModels;
using TransportLogisticDataModels;
namespace TransportLogisticForm
{
public partial class FormOrderGoods : Form
{
private readonly List<GoodViewModel>? _list;
public int Id { get { return Convert.ToInt32(comboBox.SelectedValue); } set { comboBox.SelectedValue = value; } }
public IGoodModel? GoodModel
{
get
{
if (_list == null)
{
return null;
}
foreach (var elem in _list)
{
if (elem.Id == Id)
{
return elem;
}
}
return null;
}
}
public int GoodsCount { get { return Convert.ToInt32(textBox.Text); } set { textBox.Text = value.ToString(); } }
public FormOrderGoods(IGoodLogic logic)
{
_list = logic.ReadList(null);
if (_list != null)
{
comboBox.DisplayMember = "Name";
comboBox.ValueMember = "Id";
comboBox.DataSource = _list;
comboBox.SelectedItem = null;
}
InitializeComponent();
}
private void buttonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBox.Text))
{
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBox.SelectedValue == null)
{
MessageBox.Show("Выберите транспорт", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
DialogResult = DialogResult.OK;
Close();
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View 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>

View File

@ -0,0 +1,118 @@
namespace TransportLogisticForm
{
partial class FormOrderTransports
{
/// <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()
{
label1 = new Label();
label2 = new Label();
comboBox = new ComboBox();
buttonCancel = new Button();
buttonSave = new Button();
textBox = new TextBox();
SuspendLayout();
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(22, 24);
label1.Name = "label1";
label1.Size = new Size(86, 20);
label1.TabIndex = 0;
label1.Text = "Транспорт:";
//
// label2
//
label2.AutoSize = true;
label2.Location = new Point(22, 72);
label2.Name = "label2";
label2.Size = new Size(177, 20);
label2.TabIndex = 1;
label2.Text = "Количество транспорта:";
//
// comboBox
//
comboBox.FormattingEnabled = true;
comboBox.Location = new Point(120, 21);
comboBox.Name = "comboBox";
comboBox.Size = new Size(285, 28);
comboBox.TabIndex = 2;
//
// buttonCancel
//
buttonCancel.Location = new Point(301, 125);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(104, 39);
buttonCancel.TabIndex = 7;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// buttonSave
//
buttonSave.Location = new Point(189, 125);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(104, 39);
buttonSave.TabIndex = 6;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// textBox
//
textBox.Location = new Point(205, 69);
textBox.Name = "textBox";
textBox.Size = new Size(200, 27);
textBox.TabIndex = 8;
//
// FormOrderTransports
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(430, 182);
Controls.Add(textBox);
Controls.Add(buttonCancel);
Controls.Add(buttonSave);
Controls.Add(comboBox);
Controls.Add(label2);
Controls.Add(label1);
Name = "FormOrderTransports";
Text = "Транспорт заказа";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label label1;
private Label label2;
private ComboBox comboBox;
private Button buttonCancel;
private Button buttonSave;
private TextBox textBox;
}
}

View File

@ -0,0 +1,66 @@
using TransportLogisticContracts.BusinessLogicsContracts;
using TransportLogisticContracts.ViewModels;
using TransportLogisticDataModels;
namespace TransportLogisticForm
{
public partial class FormOrderTransports : Form
{
private readonly List<TransportViewModel>? _list;
public int Id { get { return Convert.ToInt32(comboBox.SelectedValue); } set { comboBox.SelectedValue = value; } }
public ITransportModel? TransportModel
{
get
{
if (_list == null)
{
return null;
}
foreach (var elem in _list)
{
if (elem.Id == Id)
{
return elem;
}
}
return null;
}
}
public int TransportsCount { get { return Convert.ToInt32(textBox.Text); } set { textBox.Text = value.ToString(); } }
public FormOrderTransports(ITransportLogic logic)
{
_list = logic.ReadList(null);
if (_list != null)
{
comboBox.DisplayMember = "Type";
comboBox.ValueMember = "Id";
comboBox.DataSource = _list;
comboBox.SelectedItem = null;
}
InitializeComponent();
}
private void buttonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBox.Text))
{
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (comboBox.SelectedValue == null)
{
MessageBox.Show("Выберите транспорт", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
DialogResult = DialogResult.OK;
Close();
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View 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>

View File

@ -0,0 +1,117 @@
namespace TransportLogisticForm
{
partial class FormStorages
{
/// <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()
{
button2 = new Button();
button1 = new Button();
buttonUpd = new Button();
buttonDel = new Button();
dataGridView1 = new DataGridView();
((System.ComponentModel.ISupportInitialize)dataGridView1).BeginInit();
SuspendLayout();
//
// button2
//
button2.Location = new Point(576, 315);
button2.Name = "button2";
button2.Size = new Size(75, 23);
button2.TabIndex = 17;
button2.Text = "button2";
button2.UseVisualStyleBackColor = true;
//
// button1
//
button1.Location = new Point(571, 248);
button1.Name = "button1";
button1.Size = new Size(75, 23);
button1.TabIndex = 16;
button1.Text = "button1";
button1.UseVisualStyleBackColor = true;
//
// buttonUpd
//
buttonUpd.Location = new Point(553, 165);
buttonUpd.Margin = new Padding(5, 4, 5, 4);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(113, 53);
buttonUpd.TabIndex = 15;
buttonUpd.Text = "Обновить";
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += buttonUpd_Click;
//
// buttonDel
//
buttonDel.Location = new Point(553, 104);
buttonDel.Margin = new Padding(5, 4, 5, 4);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(113, 53);
buttonDel.TabIndex = 14;
buttonDel.Text = "Удалить";
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += buttonDel_Click;
//
// dataGridView1
//
dataGridView1.AllowUserToAddRows = false;
dataGridView1.AllowUserToDeleteRows = false;
dataGridView1.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView1.Location = new Point(-2, 0);
dataGridView1.MultiSelect = false;
dataGridView1.Name = "dataGridView1";
dataGridView1.ReadOnly = true;
dataGridView1.RowTemplate.Height = 29;
dataGridView1.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView1.Size = new Size(529, 498);
dataGridView1.TabIndex = 13;
//
// FormStorages
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(683, 499);
Controls.Add(button2);
Controls.Add(button1);
Controls.Add(buttonUpd);
Controls.Add(buttonDel);
Controls.Add(dataGridView1);
Name = "FormStorages";
Text = "Склады";
((System.ComponentModel.ISupportInitialize)dataGridView1).EndInit();
ResumeLayout(false);
}
#endregion
private Button button2;
private Button button1;
private Button buttonUpd;
private Button buttonDel;
private DataGridView dataGridView1;
}
}

View File

@ -0,0 +1,66 @@
using TransportLogisticContracts.BindingModels;
using TransportLogisticContracts.BusinessLogicsContracts;
namespace TransportLogisticForm
{
public partial class FormStorages : Form
{
private readonly IStorageLogic _logic;
public FormStorages(IStorageLogic logic)
{
_logic = logic;
InitializeComponent();
}
private void FormStorages_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView1.DataSource = list;
dataGridView1.Columns["Id"].Visible = false;
dataGridView1.Columns["Name"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView1.Columns["Address"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonDel_Click(object sender, EventArgs e)
{
if (dataGridView1.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить заказчика?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
try
{
if (!_logic.Delete(new StorageBindingModel { Id = id }))
{
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void buttonUpd_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View 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>

View File

@ -0,0 +1,95 @@
namespace TransportLogisticForm
{
partial class FormTransport
{
/// <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()
{
buttonSave = new Button();
buttonCancel = new Button();
textBoxName = new TextBox();
label1 = new Label();
SuspendLayout();
//
// buttonSave
//
buttonSave.Location = new Point(171, 66);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(95, 43);
buttonSave.TabIndex = 8;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(272, 66);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(95, 43);
buttonCancel.TabIndex = 7;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// textBoxName
//
textBoxName.Location = new Point(98, 18);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(269, 27);
textBoxName.TabIndex = 6;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(12, 21);
label1.Name = "label1";
label1.Size = new Size(80, 20);
label1.TabIndex = 5;
label1.Text = "Название:";
//
// FormTransport
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(386, 131);
Controls.Add(buttonSave);
Controls.Add(buttonCancel);
Controls.Add(textBoxName);
Controls.Add(label1);
Name = "FormTransport";
Text = "Транспорт";
ResumeLayout(false);
PerformLayout();
}
#endregion
private Button buttonSave;
private Button buttonCancel;
private TextBox textBoxName;
private Label label1;
}
}

View File

@ -0,0 +1,72 @@
using TransportLogisticContracts.BindingModels;
using TransportLogisticContracts.BusinessLogicsContracts;
using TransportLogisticContracts.SearchModels;
namespace TransportLogisticForm
{
public partial class FormTransport : Form
{
private readonly ITransportLogic _logic;
private int? _id;
public int Id { set { _id = value; } }
public FormTransport(ITransportLogic logic)
{
InitializeComponent();
_logic = logic;
}
private void FormTransports_Load(object sender, EventArgs e)
{
if (_id.HasValue)
{
try
{
var view = _logic.ReadElement(new TransportSearchModel { Id = _id.Value });
if (view != null)
{
textBoxName.Text = view.Type;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void buttonSave_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(textBoxName.Text))
{
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
try
{
var model = new TransportBindingModel
{
Id = _id ?? 0,
Type = textBoxName.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)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCancel_Click(object sender, EventArgs e)
{
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View 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>

View File

@ -0,0 +1,113 @@
namespace TransportLogisticForm
{
partial class FormTransports
{
/// <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()
{
buttonUpd = new Button();
buttonDel = new Button();
buttonEdit = new Button();
buttonAdd = new Button();
dataGridView = new DataGridView();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// buttonUpd
//
buttonUpd.Location = new Point(454, 231);
buttonUpd.Name = "buttonUpd";
buttonUpd.Size = new Size(128, 53);
buttonUpd.TabIndex = 17;
buttonUpd.Text = "Обновить";
buttonUpd.UseVisualStyleBackColor = true;
buttonUpd.Click += buttonUpd_Click;
//
// buttonDel
//
buttonDel.Location = new Point(454, 172);
buttonDel.Name = "buttonDel";
buttonDel.Size = new Size(128, 53);
buttonDel.TabIndex = 16;
buttonDel.Text = "Удалить";
buttonDel.UseVisualStyleBackColor = true;
buttonDel.Click += buttonDel_Click;
//
// buttonEdit
//
buttonEdit.Location = new Point(454, 113);
buttonEdit.Name = "buttonEdit";
buttonEdit.Size = new Size(128, 53);
buttonEdit.TabIndex = 15;
buttonEdit.Text = "Изменить";
buttonEdit.UseVisualStyleBackColor = true;
buttonEdit.Click += buttonEdit_Click;
//
// buttonAdd
//
buttonAdd.Location = new Point(454, 54);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(128, 53);
buttonAdd.TabIndex = 14;
buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// dataGridView
//
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(2, -4);
dataGridView.Name = "dataGridView";
dataGridView.RowTemplate.Height = 29;
dataGridView.Size = new Size(437, 442);
dataGridView.TabIndex = 13;
//
// FormTransports
//
AutoScaleDimensions = new SizeF(8F, 20F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(598, 439);
Controls.Add(buttonUpd);
Controls.Add(buttonDel);
Controls.Add(buttonEdit);
Controls.Add(buttonAdd);
Controls.Add(dataGridView);
Name = "FormTransports";
Text = "Транспорты";
Load += FormTransports_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private Button buttonUpd;
private Button buttonDel;
private Button buttonEdit;
private Button buttonAdd;
private DataGridView dataGridView;
}
}

View File

@ -0,0 +1,94 @@
using TransportLogisticContracts.BindingModels;
using TransportLogisticContracts.BusinessLogicsContracts;
namespace TransportLogisticForm
{
public partial class FormTransports : Form
{
private readonly ITransportLogic _logic;
public FormTransports(ITransportLogic logic)
{
InitializeComponent();
_logic = logic;
}
private void FormTransports_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["Type"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
dataGridView.Columns["LoadCapacity"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonAdd_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormGood));
if (service is FormTransport form)
{
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
}
}
}
private void buttonEdit_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormGood));
if (service is FormTransport 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);
try
{
if (!_logic.Delete(new TransportBindingModel { Id = id }))
{
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
}
LoadData();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
private void buttonUpd_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View 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>

View File

@ -2,6 +2,8 @@ using Microsoft.Extensions.DependencyInjection;
using TransportLogisticContracts.StorageContracts;
using TransportLogisticContracts.BusinessLogicsContracts;
using TransportLogisticDatabaseImplement.Implements;
using TransportLogisticDatabaseImplement.Implement;
using TransportLogisticBusinessLogic;
namespace TransportLogisticForm
{
@ -32,19 +34,22 @@ namespace TransportLogisticForm
services.AddTransient<ITransportStorage, TransportStorage>();
services.AddTransient<IGoodStorage, GoodStorage>();
services.AddTransient<IProjectLogic, ProjectLogic>();
services.AddTransient<ITaskLogic, TaskLogic>();
services.AddTransient<IOrganizationLogic, OrganizationLogic>();
services.AddTransient<IUserLogic, UserLogic>();
services.AddTransient<IStorageLogic, StorageLogic>();
services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<ICustomerLogic, CustomerLogic>();
services.AddTransient<ITransportLogic, TransportLogic>();
services.AddTransient<IGoodLogic, GoodLogic>();
services.AddTransient<FormMain>();
services.AddTransient<FormProject>();
services.AddTransient<FormProjects>();
services.AddTransient<FormCreateTask>();
services.AddTransient<FormOrganization>();
services.AddTransient<FormOrganizationProject>();
services.AddTransient<FormOrganizations>();
services.AddTransient<FormUsers>();
services.AddTransient<FormStorages>();
services.AddTransient<FormCreateOrder>();
services.AddTransient<FormGoods>();
services.AddTransient<FormGood>();
services.AddTransient<FormCustomers>();
services.AddTransient<FormTransports>();
services.AddTransient<FormTransport>();
services.AddTransient<FormOrderTransports>();
services.AddTransient<FormOrderGoods>();
}
}
}