Слой хранения данных в базе данных + слой с представлением пользователя
This commit is contained in:
parent
35f2d60907
commit
34a190211b
@ -5,13 +5,15 @@ VisualStudioVersion = 17.7.34024.191
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransportCompanyView", "TransportCompanyView\TransportCompanyView.csproj", "{6DBE2D7A-A9FD-4FBC-BD54-28FDBB359F7A}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TransportCompanyDataModels", "TransportCompanyDataModels\TransportCompanyDataModels.csproj", "{49B3AF87-E6E5-4B8C-B2B6-EC3BD9509DA2}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransportCompanyDataModels", "TransportCompanyDataModels\TransportCompanyDataModels.csproj", "{49B3AF87-E6E5-4B8C-B2B6-EC3BD9509DA2}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TransportCompanyContracts", "TransportCompanyContracts\TransportCompanyContracts.csproj", "{842017C2-FA27-4317-8C12-5CF64C85F2E0}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransportCompanyContracts", "TransportCompanyContracts\TransportCompanyContracts.csproj", "{842017C2-FA27-4317-8C12-5CF64C85F2E0}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TransportCompanyBusinessLogic", "TransportCompanyBusinessLogic\TransportCompanyBusinessLogic.csproj", "{49A4EC0D-8412-42E4-B4C1-3B5FDDEF0D70}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransportCompanyBusinessLogic", "TransportCompanyBusinessLogic\TransportCompanyBusinessLogic.csproj", "{49A4EC0D-8412-42E4-B4C1-3B5FDDEF0D70}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TransportCompanyListImplement", "TransportCompanyListImplement\TransportCompanyListImplement.csproj", "{0772D7CB-D2B3-4DCD-8135-734AB2F00A04}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TransportCompanyListImplement", "TransportCompanyListImplement\TransportCompanyListImplement.csproj", "{0772D7CB-D2B3-4DCD-8135-734AB2F00A04}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TransportCompanyDatabaseImplement", "TransportCompanyDatabaseImplement\TransportCompanyDatabaseImplement.csproj", "{E88D7676-7B0F-4D65-8C8F-C8EA376EA7B1}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@ -39,6 +41,10 @@ Global
|
||||
{0772D7CB-D2B3-4DCD-8135-734AB2F00A04}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0772D7CB-D2B3-4DCD-8135-734AB2F00A04}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0772D7CB-D2B3-4DCD-8135-734AB2F00A04}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E88D7676-7B0F-4D65-8C8F-C8EA376EA7B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E88D7676-7B0F-4D65-8C8F-C8EA376EA7B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E88D7676-7B0F-4D65-8C8F-C8EA376EA7B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E88D7676-7B0F-4D65-8C8F-C8EA376EA7B1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -95,6 +95,13 @@ namespace TransportCompanyBusinessLogic.BusinessLogics
|
||||
{
|
||||
throw new ArgumentNullException(nameof(element));
|
||||
}
|
||||
model.DriverId = element.DriverId;
|
||||
model.CargoId = element.CargoId;
|
||||
model.TransportId = element.TransportId;
|
||||
model.PointToId = element.PointToId;
|
||||
model.PointFromId = element.PointFromId;
|
||||
model.Count = element.Count;
|
||||
model.ArrivalDate = element.ArrivalDate;
|
||||
model.Status = element.Status;
|
||||
if (requiredStatus - model.Status == 1)
|
||||
{
|
||||
|
@ -27,16 +27,16 @@ namespace TransportCompanyContracts.ViewModels
|
||||
[DisplayName("Количество")]
|
||||
public int Count { get; set; }
|
||||
|
||||
public int PointToId { get; set; }
|
||||
|
||||
[DisplayName("Откуда")]
|
||||
public string PointNameTo { get; set; } = string.Empty;
|
||||
|
||||
public int PointFromId { get; set; }
|
||||
|
||||
[DisplayName("Куда")]
|
||||
[DisplayName("Откуда")]
|
||||
public string PointNameFrom { get; set; } = string.Empty;
|
||||
|
||||
public int PointToId { get; set; }
|
||||
|
||||
[DisplayName("Куда")]
|
||||
public string PointNameTo { get; set; } = string.Empty;
|
||||
|
||||
[DisplayName("Статус")]
|
||||
public TransportationStatus Status { get; set; } = TransportationStatus.Неизвестен;
|
||||
|
||||
|
@ -0,0 +1,79 @@
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
using TransportCompanyContracts.StoragesContracts;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
using TransportCompanyDatabaseImplement.Models;
|
||||
|
||||
namespace TransportCompanyDatabaseImplement.Implements
|
||||
{
|
||||
public class CargoStorage : ICargoStorage
|
||||
{
|
||||
public List<CargoViewModel> GetFullList()
|
||||
{
|
||||
using var context = new TransportCompanyDatabase();
|
||||
return context.Cargos.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<CargoViewModel> GetFilteredList(CargoSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.CargoName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new TransportCompanyDatabase();
|
||||
return context.Cargos.Where(x => x.CargoName.Contains(model.CargoName)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public CargoViewModel? GetElement(CargoSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.CargoName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new TransportCompanyDatabase();
|
||||
return context.Cargos.FirstOrDefault(x =>
|
||||
(!string.IsNullOrEmpty(model.CargoName) && x.CargoName == model.CargoName) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public CargoViewModel? Insert(CargoBindingModel model)
|
||||
{
|
||||
var newComponent = Cargo.Create(model);
|
||||
if (newComponent == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new TransportCompanyDatabase();
|
||||
context.Cargos.Add(newComponent);
|
||||
context.SaveChanges();
|
||||
return newComponent.GetViewModel;
|
||||
}
|
||||
|
||||
public CargoViewModel? Update(CargoBindingModel model)
|
||||
{
|
||||
using var context = new TransportCompanyDatabase();
|
||||
var component = context.Cargos.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (component == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
component.Update(model);
|
||||
context.SaveChanges();
|
||||
return component.GetViewModel;
|
||||
}
|
||||
|
||||
public CargoViewModel? Delete(CargoBindingModel model)
|
||||
{
|
||||
using var context = new TransportCompanyDatabase();
|
||||
var element = context.Cargos.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Cargos.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
using TransportCompanyContracts.StoragesContracts;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
using TransportCompanyDatabaseImplement.Models;
|
||||
|
||||
namespace TransportCompanyDatabaseImplement.Implements
|
||||
{
|
||||
public class DriverStorage : IDriverStorage
|
||||
{
|
||||
public List<DriverViewModel> GetFullList()
|
||||
{
|
||||
using var context = new TransportCompanyDatabase();
|
||||
return context.Drivers.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<DriverViewModel> GetFilteredList(DriverSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.DriverFio))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new TransportCompanyDatabase();
|
||||
return context.Drivers.Where(x => x.DriverFio.Contains(model.DriverFio)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public DriverViewModel? GetElement(DriverSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.DriverFio) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new TransportCompanyDatabase();
|
||||
return context.Drivers.FirstOrDefault(x =>
|
||||
(!string.IsNullOrEmpty(model.DriverFio) && x.DriverFio == model.DriverFio) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public DriverViewModel? Insert(DriverBindingModel model)
|
||||
{
|
||||
var newComponent = Driver.Create(model);
|
||||
if (newComponent == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new TransportCompanyDatabase();
|
||||
context.Drivers.Add(newComponent);
|
||||
context.SaveChanges();
|
||||
return newComponent.GetViewModel;
|
||||
}
|
||||
|
||||
public DriverViewModel? Update(DriverBindingModel model)
|
||||
{
|
||||
using var context = new TransportCompanyDatabase();
|
||||
var component = context.Drivers.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (component == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
component.Update(model);
|
||||
context.SaveChanges();
|
||||
return component.GetViewModel;
|
||||
}
|
||||
|
||||
public DriverViewModel? Delete(DriverBindingModel model)
|
||||
{
|
||||
using var context = new TransportCompanyDatabase();
|
||||
var element = context.Drivers.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Drivers.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
using TransportCompanyContracts.StoragesContracts;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
using TransportCompanyDatabaseImplement.Models;
|
||||
|
||||
namespace TransportCompanyDatabaseImplement.Implements
|
||||
{
|
||||
public class PointStorage : IPointStorage
|
||||
{
|
||||
public List<PointViewModel> GetFullList()
|
||||
{
|
||||
using var context = new TransportCompanyDatabase();
|
||||
return context.Points.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<PointViewModel> GetFilteredList(PointSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.PointName))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new TransportCompanyDatabase();
|
||||
return context.Points.Where(x => x.PointName.Contains(model.PointName)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public PointViewModel? GetElement(PointSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.PointName) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new TransportCompanyDatabase();
|
||||
return context.Points.FirstOrDefault(x =>
|
||||
(!string.IsNullOrEmpty(model.PointName) && x.PointName == model.PointName) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public PointViewModel? Insert(PointBindingModel model)
|
||||
{
|
||||
var newComponent = Point.Create(model);
|
||||
if (newComponent == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new TransportCompanyDatabase();
|
||||
context.Points.Add(newComponent);
|
||||
context.SaveChanges();
|
||||
return newComponent.GetViewModel;
|
||||
}
|
||||
|
||||
public PointViewModel? Update(PointBindingModel model)
|
||||
{
|
||||
using var context = new TransportCompanyDatabase();
|
||||
var component = context.Points.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (component == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
component.Update(model);
|
||||
context.SaveChanges();
|
||||
return component.GetViewModel;
|
||||
}
|
||||
|
||||
public PointViewModel? Delete(PointBindingModel model)
|
||||
{
|
||||
using var context = new TransportCompanyDatabase();
|
||||
var element = context.Points.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Points.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
using TransportCompanyContracts.StoragesContracts;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
using TransportCompanyDatabaseImplement.Models;
|
||||
|
||||
namespace TransportCompanyDatabaseImplement.Implements
|
||||
{
|
||||
public class TransportStorage : ITransportStorage
|
||||
{
|
||||
public List<TransportViewModel> GetFullList()
|
||||
{
|
||||
using var context = new TransportCompanyDatabase();
|
||||
return context.Transports.Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public List<TransportViewModel> GetFilteredList(TransportSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Model))
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new TransportCompanyDatabase();
|
||||
return context.Transports.Where(x => x.Model.Contains(model.Model)).Select(x => x.GetViewModel).ToList();
|
||||
}
|
||||
|
||||
public TransportViewModel? GetElement(TransportSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Model) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new TransportCompanyDatabase();
|
||||
return context.Transports.FirstOrDefault(x =>
|
||||
(!string.IsNullOrEmpty(model.Model) && x.Model == model.Model) ||
|
||||
(model.Id.HasValue && x.Id == model.Id))
|
||||
?.GetViewModel;
|
||||
}
|
||||
|
||||
public TransportViewModel? Insert(TransportBindingModel model)
|
||||
{
|
||||
var newComponent = Transport.Create(model);
|
||||
if (newComponent == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
using var context = new TransportCompanyDatabase();
|
||||
context.Transports.Add(newComponent);
|
||||
context.SaveChanges();
|
||||
return newComponent.GetViewModel;
|
||||
}
|
||||
|
||||
public TransportViewModel? Update(TransportBindingModel model)
|
||||
{
|
||||
using var context = new TransportCompanyDatabase();
|
||||
var component = context.Transports.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (component == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
component.Update(model);
|
||||
context.SaveChanges();
|
||||
return component.GetViewModel;
|
||||
}
|
||||
|
||||
public TransportViewModel? Delete(TransportBindingModel model)
|
||||
{
|
||||
using var context = new TransportCompanyDatabase();
|
||||
var element = context.Transports.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (element != null)
|
||||
{
|
||||
context.Transports.Remove(element);
|
||||
context.SaveChanges();
|
||||
return element.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
using TransportCompanyContracts.StoragesContracts;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
using TransportCompanyDatabaseImplement.Models;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace TransportCompanyDatabaseImplement.Implements
|
||||
{
|
||||
public class TransportationStorage : ITransportationStorage
|
||||
{
|
||||
public List<TransportationViewModel> GetFullList()
|
||||
{
|
||||
using var context = new TransportCompanyDatabase();
|
||||
return context.Transportations
|
||||
.Include(x => x.Cargo)
|
||||
.Include(x => x.Driver)
|
||||
.Include(x => x.PointFrom)
|
||||
.Include(x => x.PointTo)
|
||||
.Include(x => x.Transport)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<TransportationViewModel> GetFilteredList(TransportationSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new TransportCompanyDatabase();
|
||||
return context.Transportations
|
||||
.Include(x => x.Cargo)
|
||||
.Include(x => x.Driver)
|
||||
.Include(x => x.PointFrom)
|
||||
.Include(x => x.PointTo)
|
||||
.Include(x => x.Transport)
|
||||
.Where(x => x.Id == model.Id)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public TransportationViewModel? GetElement(TransportationSearchModel model)
|
||||
{
|
||||
if (!model.Id.HasValue)
|
||||
{
|
||||
return new();
|
||||
}
|
||||
using var context = new TransportCompanyDatabase();
|
||||
return context.Transportations
|
||||
.Include(x => x.Cargo)
|
||||
.Include(x => x.Driver)
|
||||
.Include(x => x.PointFrom)
|
||||
.Include(x => x.PointTo)
|
||||
.Include(x => x.Transport)
|
||||
.FirstOrDefault(x => x.Id == model.Id)?.GetViewModel;
|
||||
}
|
||||
|
||||
public TransportationViewModel? Insert(TransportationBindingModel model)
|
||||
{
|
||||
using var context = new TransportCompanyDatabase();
|
||||
if (model == null)
|
||||
return null;
|
||||
var newOrder = Transportation.Create(context, model);
|
||||
if (newOrder == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
context.Transportations.Add(newOrder);
|
||||
context.SaveChanges();
|
||||
return newOrder.GetViewModel;
|
||||
}
|
||||
|
||||
public TransportationViewModel? Update(TransportationBindingModel model)
|
||||
{
|
||||
using var context = new TransportCompanyDatabase();
|
||||
var order = context.Transportations.FirstOrDefault(x => x.Id == model.Id);
|
||||
if (order == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
order.Update(model);
|
||||
context.SaveChanges();
|
||||
return order.GetViewModel;
|
||||
}
|
||||
|
||||
public TransportationViewModel? Delete(TransportationBindingModel model)
|
||||
{
|
||||
using var context = new TransportCompanyDatabase();
|
||||
var order = context.Transportations.FirstOrDefault(rec => rec.Id == model.Id);
|
||||
if (order != null)
|
||||
{
|
||||
context.Transportations.Remove(order);
|
||||
context.SaveChanges();
|
||||
return order.GetViewModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
231
TransportCompany/TransportCompanyDatabaseImplement/Migrations/20240305163445_InitialCreate.Designer.cs
generated
Normal file
231
TransportCompany/TransportCompanyDatabaseImplement/Migrations/20240305163445_InitialCreate.Designer.cs
generated
Normal file
@ -0,0 +1,231 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using TransportCompanyDatabaseImplement;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace TransportCompanyDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(TransportCompanyDatabase))]
|
||||
[Migration("20240305163445_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.3")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("TransportCompanyDatabaseImplement.Models.Cargo", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("CargoName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Weight")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Cargos");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TransportCompanyDatabaseImplement.Models.Driver", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("DriverFio")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Drivers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TransportCompanyDatabaseImplement.Models.Point", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PointName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Points");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TransportCompanyDatabaseImplement.Models.Transport", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("LoadCapacity")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Model")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("StateNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Transports");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TransportCompanyDatabaseImplement.Models.Transportation", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("ArrivalDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("CargoId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DepartureDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("DriverId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PointFromId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PointToId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("TransportId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CargoId");
|
||||
|
||||
b.HasIndex("DriverId");
|
||||
|
||||
b.HasIndex("PointFromId");
|
||||
|
||||
b.HasIndex("PointToId");
|
||||
|
||||
b.HasIndex("TransportId");
|
||||
|
||||
b.ToTable("Transportations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TransportCompanyDatabaseImplement.Models.Transportation", b =>
|
||||
{
|
||||
b.HasOne("TransportCompanyDatabaseImplement.Models.Cargo", "Cargo")
|
||||
.WithMany("Transportations")
|
||||
.HasForeignKey("CargoId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("TransportCompanyDatabaseImplement.Models.Driver", "Driver")
|
||||
.WithMany("Transportations")
|
||||
.HasForeignKey("DriverId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("TransportCompanyDatabaseImplement.Models.Point", "PointFrom")
|
||||
.WithMany("TransportationsFrom")
|
||||
.HasForeignKey("PointFromId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("TransportCompanyDatabaseImplement.Models.Point", "PointTo")
|
||||
.WithMany("TransportationsTo")
|
||||
.HasForeignKey("PointToId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("TransportCompanyDatabaseImplement.Models.Transport", "Transport")
|
||||
.WithMany("Transportations")
|
||||
.HasForeignKey("TransportId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Cargo");
|
||||
|
||||
b.Navigation("Driver");
|
||||
|
||||
b.Navigation("PointFrom");
|
||||
|
||||
b.Navigation("PointTo");
|
||||
|
||||
b.Navigation("Transport");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TransportCompanyDatabaseImplement.Models.Cargo", b =>
|
||||
{
|
||||
b.Navigation("Transportations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TransportCompanyDatabaseImplement.Models.Driver", b =>
|
||||
{
|
||||
b.Navigation("Transportations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TransportCompanyDatabaseImplement.Models.Point", b =>
|
||||
{
|
||||
b.Navigation("TransportationsFrom");
|
||||
|
||||
b.Navigation("TransportationsTo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TransportCompanyDatabaseImplement.Models.Transport", b =>
|
||||
{
|
||||
b.Navigation("Transportations");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,167 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace TransportCompanyDatabaseImplement.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialCreate : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Cargos",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
CargoName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Weight = table.Column<int>(type: "int", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Cargos", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Drivers",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
DriverFio = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
PhoneNumber = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Drivers", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Points",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
PointName = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
Address = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Points", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Transports",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
Model = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
||||
LoadCapacity = table.Column<int>(type: "int", nullable: false),
|
||||
StateNumber = table.Column<string>(type: "nvarchar(max)", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Transports", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Transportations",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<int>(type: "int", nullable: false)
|
||||
.Annotation("SqlServer:Identity", "1, 1"),
|
||||
DriverId = table.Column<int>(type: "int", nullable: false),
|
||||
TransportId = table.Column<int>(type: "int", nullable: false),
|
||||
CargoId = table.Column<int>(type: "int", nullable: false),
|
||||
Count = table.Column<int>(type: "int", nullable: false),
|
||||
PointToId = table.Column<int>(type: "int", nullable: false),
|
||||
PointFromId = table.Column<int>(type: "int", nullable: false),
|
||||
Status = table.Column<int>(type: "int", nullable: false),
|
||||
DepartureDate = table.Column<DateTime>(type: "datetime2", nullable: false),
|
||||
ArrivalDate = table.Column<DateTime>(type: "datetime2", nullable: true)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Transportations", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Transportations_Cargos_CargoId",
|
||||
column: x => x.CargoId,
|
||||
principalTable: "Cargos",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Transportations_Drivers_DriverId",
|
||||
column: x => x.DriverId,
|
||||
principalTable: "Drivers",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Transportations_Points_PointFromId",
|
||||
column: x => x.PointFromId,
|
||||
principalTable: "Points",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_Transportations_Points_PointToId",
|
||||
column: x => x.PointToId,
|
||||
principalTable: "Points",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_Transportations_Transports_TransportId",
|
||||
column: x => x.TransportId,
|
||||
principalTable: "Transports",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Transportations_CargoId",
|
||||
table: "Transportations",
|
||||
column: "CargoId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Transportations_DriverId",
|
||||
table: "Transportations",
|
||||
column: "DriverId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Transportations_PointFromId",
|
||||
table: "Transportations",
|
||||
column: "PointFromId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Transportations_PointToId",
|
||||
table: "Transportations",
|
||||
column: "PointToId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Transportations_TransportId",
|
||||
table: "Transportations",
|
||||
column: "TransportId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "Transportations");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Cargos");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Drivers");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Points");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Transports");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,228 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using TransportCompanyDatabaseImplement;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace TransportCompanyDatabaseImplement.Migrations
|
||||
{
|
||||
[DbContext(typeof(TransportCompanyDatabase))]
|
||||
partial class TransportCompanyDatabaseModelSnapshot : ModelSnapshot
|
||||
{
|
||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
||||
{
|
||||
#pragma warning disable 612, 618
|
||||
modelBuilder
|
||||
.HasAnnotation("ProductVersion", "7.0.3")
|
||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
||||
|
||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
||||
|
||||
modelBuilder.Entity("TransportCompanyDatabaseImplement.Models.Cargo", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("CargoName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<int>("Weight")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Cargos");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TransportCompanyDatabaseImplement.Models.Driver", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("DriverFio")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Drivers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TransportCompanyDatabaseImplement.Models.Point", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<string>("Address")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("PointName")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Points");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TransportCompanyDatabaseImplement.Models.Transport", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<int>("LoadCapacity")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<string>("Model")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.Property<string>("StateNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("nvarchar(max)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.ToTable("Transports");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TransportCompanyDatabaseImplement.Models.Transportation", b =>
|
||||
{
|
||||
b.Property<int>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("int");
|
||||
|
||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
||||
|
||||
b.Property<DateTime?>("ArrivalDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("CargoId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Count")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<DateTime>("DepartureDate")
|
||||
.HasColumnType("datetime2");
|
||||
|
||||
b.Property<int>("DriverId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PointFromId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("PointToId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("Status")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.Property<int>("TransportId")
|
||||
.HasColumnType("int");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CargoId");
|
||||
|
||||
b.HasIndex("DriverId");
|
||||
|
||||
b.HasIndex("PointFromId");
|
||||
|
||||
b.HasIndex("PointToId");
|
||||
|
||||
b.HasIndex("TransportId");
|
||||
|
||||
b.ToTable("Transportations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TransportCompanyDatabaseImplement.Models.Transportation", b =>
|
||||
{
|
||||
b.HasOne("TransportCompanyDatabaseImplement.Models.Cargo", "Cargo")
|
||||
.WithMany("Transportations")
|
||||
.HasForeignKey("CargoId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("TransportCompanyDatabaseImplement.Models.Driver", "Driver")
|
||||
.WithMany("Transportations")
|
||||
.HasForeignKey("DriverId")
|
||||
.OnDelete(DeleteBehavior.ClientSetNull)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("TransportCompanyDatabaseImplement.Models.Point", "PointFrom")
|
||||
.WithMany("TransportationsFrom")
|
||||
.HasForeignKey("PointFromId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("TransportCompanyDatabaseImplement.Models.Point", "PointTo")
|
||||
.WithMany("TransportationsTo")
|
||||
.HasForeignKey("PointToId")
|
||||
.OnDelete(DeleteBehavior.Restrict)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("TransportCompanyDatabaseImplement.Models.Transport", "Transport")
|
||||
.WithMany("Transportations")
|
||||
.HasForeignKey("TransportId")
|
||||
.OnDelete(DeleteBehavior.ClientSetNull)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Cargo");
|
||||
|
||||
b.Navigation("Driver");
|
||||
|
||||
b.Navigation("PointFrom");
|
||||
|
||||
b.Navigation("PointTo");
|
||||
|
||||
b.Navigation("Transport");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TransportCompanyDatabaseImplement.Models.Cargo", b =>
|
||||
{
|
||||
b.Navigation("Transportations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TransportCompanyDatabaseImplement.Models.Driver", b =>
|
||||
{
|
||||
b.Navigation("Transportations");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TransportCompanyDatabaseImplement.Models.Point", b =>
|
||||
{
|
||||
b.Navigation("TransportationsFrom");
|
||||
|
||||
b.Navigation("TransportationsTo");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("TransportCompanyDatabaseImplement.Models.Transport", b =>
|
||||
{
|
||||
b.Navigation("Transportations");
|
||||
});
|
||||
#pragma warning restore 612, 618
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
using TransportCompanyDataModels.Models;
|
||||
|
||||
namespace TransportCompanyDatabaseImplement.Models
|
||||
{
|
||||
public class Cargo : ICargoModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public string CargoName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public int Weight { get; private set; }
|
||||
|
||||
[ForeignKey("CargoId")]
|
||||
public virtual List<Transportation> Transportations { get; set; } = new();
|
||||
|
||||
public static Cargo? Create(CargoBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Cargo()
|
||||
{
|
||||
Id = model.Id,
|
||||
CargoName = model.CargoName,
|
||||
Weight = model.Weight
|
||||
};
|
||||
}
|
||||
|
||||
public static Cargo Create(CargoViewModel model)
|
||||
{
|
||||
return new Cargo
|
||||
{
|
||||
Id = model.Id,
|
||||
CargoName = model.CargoName,
|
||||
Weight = model.Weight
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(CargoBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
CargoName = model.CargoName;
|
||||
Weight = model.Weight;
|
||||
}
|
||||
|
||||
public CargoViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
CargoName = CargoName,
|
||||
Weight = Weight
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
using TransportCompanyDataModels.Models;
|
||||
|
||||
namespace TransportCompanyDatabaseImplement.Models
|
||||
{
|
||||
public class Driver : IDriverModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public string DriverFio { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string PhoneNumber { get; private set; } = string.Empty;
|
||||
|
||||
[ForeignKey("DriverId")]
|
||||
public virtual List<Transportation> Transportations { get; set; } = new();
|
||||
|
||||
public static Driver? Create(DriverBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Driver()
|
||||
{
|
||||
Id = model.Id,
|
||||
DriverFio = model.DriverFio,
|
||||
PhoneNumber = model.PhoneNumber
|
||||
};
|
||||
}
|
||||
|
||||
public static Driver Create(DriverViewModel model)
|
||||
{
|
||||
return new Driver
|
||||
{
|
||||
Id = model.Id,
|
||||
DriverFio = model.DriverFio,
|
||||
PhoneNumber = model.PhoneNumber
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(DriverBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
DriverFio = model.DriverFio;
|
||||
PhoneNumber = model.PhoneNumber;
|
||||
}
|
||||
|
||||
public DriverViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
DriverFio = DriverFio,
|
||||
PhoneNumber = PhoneNumber
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
using TransportCompanyDataModels.Models;
|
||||
|
||||
namespace TransportCompanyDatabaseImplement.Models
|
||||
{
|
||||
public class Point : IPointModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public string PointName { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public string Address { get; private set; } = string.Empty;
|
||||
|
||||
[ForeignKey("PointToId")]
|
||||
public virtual List<Transportation> TransportationsTo { get; set; } = new();
|
||||
|
||||
[ForeignKey("PointFromId")]
|
||||
public virtual List<Transportation> TransportationsFrom { get; set; } = new();
|
||||
|
||||
|
||||
public static Point? Create(PointBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Point()
|
||||
{
|
||||
Id = model.Id,
|
||||
PointName = model.PointName,
|
||||
Address = model.Address
|
||||
};
|
||||
}
|
||||
|
||||
public static Point Create(PointViewModel model)
|
||||
{
|
||||
return new Point
|
||||
{
|
||||
Id = model.Id,
|
||||
PointName = model.PointName,
|
||||
Address = model.Address
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(PointBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
PointName = model.PointName;
|
||||
Address = model.Address;
|
||||
}
|
||||
|
||||
public PointViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
PointName = PointName,
|
||||
Address = Address
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
using TransportCompanyDataModels.Models;
|
||||
|
||||
namespace TransportCompanyDatabaseImplement.Models
|
||||
{
|
||||
public class Transport : ITransportModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
[Required]
|
||||
public string Model { get; private set; } = string.Empty;
|
||||
[Required]
|
||||
public int LoadCapacity { get; private set; }
|
||||
[Required]
|
||||
public string StateNumber { get; private set; } = string.Empty;
|
||||
|
||||
[ForeignKey("TransportId")]
|
||||
public virtual List<Transportation> Transportations { get; set; } = new();
|
||||
|
||||
public static Transport? Create(TransportBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Transport()
|
||||
{
|
||||
Id = model.Id,
|
||||
Model = model.Model,
|
||||
LoadCapacity = model.LoadCapacity,
|
||||
StateNumber = model.StateNumber
|
||||
};
|
||||
}
|
||||
|
||||
public static Transport Create(TransportViewModel model)
|
||||
{
|
||||
return new Transport()
|
||||
{
|
||||
Id = model.Id,
|
||||
Model = model.Model,
|
||||
LoadCapacity = model.LoadCapacity,
|
||||
StateNumber = model.StateNumber
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(TransportBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Model = model.Model;
|
||||
LoadCapacity = model.LoadCapacity;
|
||||
StateNumber = model.StateNumber;
|
||||
}
|
||||
|
||||
public TransportViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
Model = Model,
|
||||
LoadCapacity = LoadCapacity,
|
||||
StateNumber = StateNumber
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
using TransportCompanyDataModels.Enums;
|
||||
using TransportCompanyDataModels.Models;
|
||||
|
||||
namespace TransportCompanyDatabaseImplement.Models
|
||||
{
|
||||
public class Transportation : ITransportationModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
|
||||
[Required]
|
||||
public int DriverId { get; private set; }
|
||||
public virtual Driver Driver { get; set; } = new();
|
||||
|
||||
[Required]
|
||||
public int TransportId { get; private set; }
|
||||
public virtual Transport Transport { get; set; } = new();
|
||||
|
||||
[Required]
|
||||
public int CargoId { get; private set; }
|
||||
public virtual Cargo Cargo { get; set; } = new();
|
||||
|
||||
[Required]
|
||||
public int Count { get; private set; }
|
||||
|
||||
[Required]
|
||||
public int PointToId { get; private set; }
|
||||
public virtual Point PointTo { get; set; } = new();
|
||||
|
||||
[Required]
|
||||
public int PointFromId { get; private set; }
|
||||
public virtual Point PointFrom { get; set; } = new();
|
||||
|
||||
[Required]
|
||||
public TransportationStatus Status { get; private set; } = TransportationStatus.Неизвестен;
|
||||
|
||||
[Required]
|
||||
public DateTime DepartureDate { get; private set; } = DateTime.Now;
|
||||
|
||||
public DateTime? ArrivalDate { get; private set; }
|
||||
|
||||
public static Transportation? Create(TransportCompanyDatabase context, TransportationBindingModel model)
|
||||
{
|
||||
return new Transportation()
|
||||
{
|
||||
Id = model.Id,
|
||||
DriverId = model.DriverId,
|
||||
Driver = context.Drivers.First(x => x.Id == model.DriverId),
|
||||
TransportId = model.TransportId,
|
||||
Transport = context.Transports.First(x => x.Id == model.TransportId),
|
||||
CargoId = model.CargoId,
|
||||
Cargo = context.Cargos.First(x => x.Id == model.CargoId),
|
||||
Count = model.Count,
|
||||
PointToId = model.PointToId,
|
||||
PointTo = context.Points.First(x => x.Id == model.PointToId),
|
||||
PointFromId = model.PointFromId,
|
||||
PointFrom = context.Points.First(x => x.Id == model.PointFromId),
|
||||
Status = model.Status,
|
||||
DepartureDate = model.DepartureDate,
|
||||
ArrivalDate = model.ArrivalDate,
|
||||
};
|
||||
}
|
||||
|
||||
public void Update(TransportationBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Status = model.Status;
|
||||
ArrivalDate = model.ArrivalDate;
|
||||
}
|
||||
|
||||
public TransportationViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
DriverId = DriverId,
|
||||
DriverFio = Driver.DriverFio,
|
||||
TransportId = TransportId,
|
||||
Model = Transport.Model,
|
||||
CargoId = CargoId,
|
||||
CargoName = Cargo.CargoName,
|
||||
Count = Count,
|
||||
PointToId = PointToId,
|
||||
PointNameTo = PointTo.PointName,
|
||||
PointFromId = PointFromId,
|
||||
PointNameFrom = PointFrom.PointName,
|
||||
Status = Status,
|
||||
DepartureDate = DepartureDate,
|
||||
ArrivalDate = ArrivalDate,
|
||||
};
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Collections.Generic;
|
||||
using TransportCompanyDatabaseImplement.Models;
|
||||
|
||||
namespace TransportCompanyDatabaseImplement
|
||||
{
|
||||
public class TransportCompanyDatabase : DbContext
|
||||
{
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if (!optionsBuilder.IsConfigured)
|
||||
{
|
||||
optionsBuilder.UseSqlServer(@"Data Source=LAPTOP-M2G96S06\SQLEXPRESS;Initial Catalog=TransportCompanyDatabase;Integrated Security=True;MultipleActiveResultSets=True;;TrustServerCertificate=True");
|
||||
}
|
||||
base.OnConfiguring(optionsBuilder);
|
||||
}
|
||||
public virtual DbSet<Cargo> Cargos { set; get; }
|
||||
public virtual DbSet<Driver> Drivers { set; get; }
|
||||
public virtual DbSet<Point> Points { set; get; }
|
||||
public virtual DbSet<Transport> Transports { set; get; }
|
||||
public virtual DbSet<Transportation> Transportations { set; get; }
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.Entity<Transportation>()
|
||||
.HasOne(t => t.PointTo)
|
||||
.WithMany(p => p.TransportationsTo)
|
||||
.HasForeignKey(t => t.PointToId)
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
|
||||
modelBuilder.Entity<Transportation>()
|
||||
.HasOne(t => t.PointFrom)
|
||||
.WithMany(p => p.TransportationsFrom)
|
||||
.HasForeignKey(t => t.PointFromId)
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.3" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TransportCompanyContracts\TransportCompanyContracts.csproj" />
|
||||
<ProjectReference Include="..\TransportCompanyDataModels\TransportCompanyDataModels.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
@ -18,9 +18,9 @@ namespace TransportCompanyListImplement.Implements
|
||||
public List<CargoViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<CargoViewModel>();
|
||||
foreach (var component in _source.Cargos)
|
||||
foreach (var cargo in _source.Cargos)
|
||||
{
|
||||
result.Add(component.GetViewModel);
|
||||
result.Add(cargo.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -32,11 +32,11 @@ namespace TransportCompanyListImplement.Implements
|
||||
{
|
||||
return result;
|
||||
}
|
||||
foreach (var component in _source.Cargos)
|
||||
foreach (var cargo in _source.Cargos)
|
||||
{
|
||||
if (component.CargoName.Contains(model.CargoName))
|
||||
if (cargo.CargoName.Contains(model.CargoName))
|
||||
{
|
||||
result.Add(component.GetViewModel);
|
||||
result.Add(cargo.GetViewModel);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -48,12 +48,12 @@ namespace TransportCompanyListImplement.Implements
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var component in _source.Cargos)
|
||||
foreach (var cargo in _source.Cargos)
|
||||
{
|
||||
if ((!string.IsNullOrEmpty(model.CargoName) && component.CargoName == model.CargoName) ||
|
||||
(model.Id.HasValue && component.Id == model.Id))
|
||||
if ((!string.IsNullOrEmpty(model.CargoName) && cargo.CargoName == model.CargoName) ||
|
||||
(model.Id.HasValue && cargo.Id == model.Id))
|
||||
{
|
||||
return component.GetViewModel;
|
||||
return cargo.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -62,30 +62,30 @@ namespace TransportCompanyListImplement.Implements
|
||||
public CargoViewModel? Insert(CargoBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
foreach (var component in _source.Cargos)
|
||||
foreach (var cargo in _source.Cargos)
|
||||
{
|
||||
if (model.Id <= component.Id)
|
||||
if (model.Id <= cargo.Id)
|
||||
{
|
||||
model.Id = component.Id + 1;
|
||||
model.Id = cargo.Id + 1;
|
||||
}
|
||||
}
|
||||
var newComponent = Cargo.Create(model);
|
||||
if (newComponent == null)
|
||||
var newCargo = Cargo.Create(model);
|
||||
if (newCargo == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.Cargos.Add(newComponent);
|
||||
return newComponent.GetViewModel;
|
||||
_source.Cargos.Add(newCargo);
|
||||
return newCargo.GetViewModel;
|
||||
}
|
||||
|
||||
public CargoViewModel? Update(CargoBindingModel model)
|
||||
{
|
||||
foreach (var component in _source.Cargos)
|
||||
foreach (var cargo in _source.Cargos)
|
||||
{
|
||||
if (component.Id == model.Id)
|
||||
if (cargo.Id == model.Id)
|
||||
{
|
||||
component.Update(model);
|
||||
return component.GetViewModel;
|
||||
cargo.Update(model);
|
||||
return cargo.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -18,9 +18,9 @@ namespace TransportCompanyListImplement.Implements
|
||||
public List<DriverViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<DriverViewModel>();
|
||||
foreach (var pizzas in _source.Drivers)
|
||||
foreach (var driver in _source.Drivers)
|
||||
{
|
||||
result.Add(pizzas.GetViewModel);
|
||||
result.Add(driver.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -32,11 +32,11 @@ namespace TransportCompanyListImplement.Implements
|
||||
{
|
||||
return result;
|
||||
}
|
||||
foreach (var pizzas in _source.Drivers)
|
||||
foreach (var driver in _source.Drivers)
|
||||
{
|
||||
if (pizzas.DriverFio.Contains(model.DriverFio))
|
||||
if (driver.DriverFio.Contains(model.DriverFio))
|
||||
{
|
||||
result.Add(pizzas.GetViewModel);
|
||||
result.Add(driver.GetViewModel);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -48,12 +48,12 @@ namespace TransportCompanyListImplement.Implements
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var pizzas in _source.Drivers)
|
||||
foreach (var driver in _source.Drivers)
|
||||
{
|
||||
if ((!string.IsNullOrEmpty(model.DriverFio) && pizzas.DriverFio == model.DriverFio) ||
|
||||
(model.Id.HasValue && pizzas.Id == model.Id))
|
||||
if ((!string.IsNullOrEmpty(model.DriverFio) && driver.DriverFio == model.DriverFio) ||
|
||||
(model.Id.HasValue && driver.Id == model.Id))
|
||||
{
|
||||
return pizzas.GetViewModel;
|
||||
return driver.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -62,30 +62,30 @@ namespace TransportCompanyListImplement.Implements
|
||||
public DriverViewModel? Insert(DriverBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
foreach (var pizzas in _source.Drivers)
|
||||
foreach (var driver in _source.Drivers)
|
||||
{
|
||||
if (model.Id <= pizzas.Id)
|
||||
if (model.Id <= driver.Id)
|
||||
{
|
||||
model.Id = pizzas.Id + 1;
|
||||
model.Id = driver.Id + 1;
|
||||
}
|
||||
}
|
||||
var newPizzas = Driver.Create(model);
|
||||
if (newPizzas == null)
|
||||
var newDriver = Driver.Create(model);
|
||||
if (newDriver == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.Drivers.Add(newPizzas);
|
||||
return newPizzas.GetViewModel;
|
||||
_source.Drivers.Add(newDriver);
|
||||
return newDriver.GetViewModel;
|
||||
}
|
||||
|
||||
public DriverViewModel? Update(DriverBindingModel model)
|
||||
{
|
||||
foreach (var pizzas in _source.Drivers)
|
||||
foreach (var driver in _source.Drivers)
|
||||
{
|
||||
if (pizzas.Id == model.Id)
|
||||
if (driver.Id == model.Id)
|
||||
{
|
||||
pizzas.Update(model);
|
||||
return pizzas.GetViewModel;
|
||||
driver.Update(model);
|
||||
return driver.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -18,9 +18,9 @@ namespace TransportCompanyListImplement.Implements
|
||||
public List<PointViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<PointViewModel>();
|
||||
foreach (var pizzas in _source.Points)
|
||||
foreach (var point in _source.Points)
|
||||
{
|
||||
result.Add(pizzas.GetViewModel);
|
||||
result.Add(point.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -32,11 +32,11 @@ namespace TransportCompanyListImplement.Implements
|
||||
{
|
||||
return result;
|
||||
}
|
||||
foreach (var pizzas in _source.Points)
|
||||
foreach (var point in _source.Points)
|
||||
{
|
||||
if (pizzas.PointName.Contains(model.PointName))
|
||||
if (point.PointName.Contains(model.PointName))
|
||||
{
|
||||
result.Add(pizzas.GetViewModel);
|
||||
result.Add(point.GetViewModel);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -48,12 +48,12 @@ namespace TransportCompanyListImplement.Implements
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var pizzas in _source.Points)
|
||||
foreach (var point in _source.Points)
|
||||
{
|
||||
if ((!string.IsNullOrEmpty(model.PointName) && pizzas.PointName == model.PointName) ||
|
||||
(model.Id.HasValue && pizzas.Id == model.Id))
|
||||
if ((!string.IsNullOrEmpty(model.PointName) && point.PointName == model.PointName) ||
|
||||
(model.Id.HasValue && point.Id == model.Id))
|
||||
{
|
||||
return pizzas.GetViewModel;
|
||||
return point.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -62,30 +62,30 @@ namespace TransportCompanyListImplement.Implements
|
||||
public PointViewModel? Insert(PointBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
foreach (var pizzas in _source.Points)
|
||||
foreach (var point in _source.Points)
|
||||
{
|
||||
if (model.Id <= pizzas.Id)
|
||||
if (model.Id <= point.Id)
|
||||
{
|
||||
model.Id = pizzas.Id + 1;
|
||||
model.Id = point.Id + 1;
|
||||
}
|
||||
}
|
||||
var newPizzas = Point.Create(model);
|
||||
if (newPizzas == null)
|
||||
var newPoint = Point.Create(model);
|
||||
if (newPoint == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.Points.Add(newPizzas);
|
||||
return newPizzas.GetViewModel;
|
||||
_source.Points.Add(newPoint);
|
||||
return newPoint.GetViewModel;
|
||||
}
|
||||
|
||||
public PointViewModel? Update(PointBindingModel model)
|
||||
{
|
||||
foreach (var pizzas in _source.Points)
|
||||
foreach (var point in _source.Points)
|
||||
{
|
||||
if (pizzas.Id == model.Id)
|
||||
if (point.Id == model.Id)
|
||||
{
|
||||
pizzas.Update(model);
|
||||
return pizzas.GetViewModel;
|
||||
point.Update(model);
|
||||
return point.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -18,9 +18,9 @@ namespace TransportCompanyListImplement.Implements
|
||||
public List<TransportViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<TransportViewModel>();
|
||||
foreach (var pizzas in _source.Transports)
|
||||
foreach (var transport in _source.Transports)
|
||||
{
|
||||
result.Add(pizzas.GetViewModel);
|
||||
result.Add(transport.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -32,11 +32,11 @@ namespace TransportCompanyListImplement.Implements
|
||||
{
|
||||
return result;
|
||||
}
|
||||
foreach (var pizzas in _source.Transports)
|
||||
foreach (var transport in _source.Transports)
|
||||
{
|
||||
if (pizzas.Model.Contains(model.Model))
|
||||
if (transport.Model.Contains(model.Model))
|
||||
{
|
||||
result.Add(pizzas.GetViewModel);
|
||||
result.Add(transport.GetViewModel);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -48,12 +48,12 @@ namespace TransportCompanyListImplement.Implements
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var pizzas in _source.Transports)
|
||||
foreach (var transport in _source.Transports)
|
||||
{
|
||||
if ((!string.IsNullOrEmpty(model.Model) && pizzas.Model == model.Model) ||
|
||||
(model.Id.HasValue && pizzas.Id == model.Id))
|
||||
if ((!string.IsNullOrEmpty(model.Model) && transport.Model == model.Model) ||
|
||||
(model.Id.HasValue && transport.Id == model.Id))
|
||||
{
|
||||
return pizzas.GetViewModel;
|
||||
return transport.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -62,30 +62,30 @@ namespace TransportCompanyListImplement.Implements
|
||||
public TransportViewModel? Insert(TransportBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
foreach (var pizzas in _source.Transports)
|
||||
foreach (var transport in _source.Transports)
|
||||
{
|
||||
if (model.Id <= pizzas.Id)
|
||||
if (model.Id <= transport.Id)
|
||||
{
|
||||
model.Id = pizzas.Id + 1;
|
||||
model.Id = transport.Id + 1;
|
||||
}
|
||||
}
|
||||
var newPizzas = Transport.Create(model);
|
||||
if (newPizzas == null)
|
||||
var newTransport = Transport.Create(model);
|
||||
if (newTransport == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.Transports.Add(newPizzas);
|
||||
return newPizzas.GetViewModel;
|
||||
_source.Transports.Add(newTransport);
|
||||
return newTransport.GetViewModel;
|
||||
}
|
||||
|
||||
public TransportViewModel? Update(TransportBindingModel model)
|
||||
{
|
||||
foreach (var pizzas in _source.Transports)
|
||||
foreach (var transport in _source.Transports)
|
||||
{
|
||||
if (pizzas.Id == model.Id)
|
||||
if (transport.Id == model.Id)
|
||||
{
|
||||
pizzas.Update(model);
|
||||
return pizzas.GetViewModel;
|
||||
transport.Update(model);
|
||||
return transport.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -18,9 +18,9 @@ namespace TransportCompanyListImplement.Implements
|
||||
public List<TransportationViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<TransportationViewModel>();
|
||||
foreach (var order in _source.Transportations)
|
||||
foreach (var transportation in _source.Transportations)
|
||||
{
|
||||
result.Add(AttachDetails(order.GetViewModel));
|
||||
result.Add(AttachDetails(transportation.GetViewModel));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -32,11 +32,11 @@ namespace TransportCompanyListImplement.Implements
|
||||
{
|
||||
return result;
|
||||
}
|
||||
foreach (var order in _source.Transportations)
|
||||
foreach (var transportation in _source.Transportations)
|
||||
{
|
||||
if (order.Id == model.Id)
|
||||
if (transportation.Id == model.Id)
|
||||
{
|
||||
result.Add(AttachDetails(order.GetViewModel));
|
||||
result.Add(AttachDetails(transportation.GetViewModel));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -48,11 +48,11 @@ namespace TransportCompanyListImplement.Implements
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var order in _source.Transportations)
|
||||
foreach (var transportation in _source.Transportations)
|
||||
{
|
||||
if (model.Id.HasValue && order.Id == model.Id)
|
||||
if (model.Id.HasValue && transportation.Id == model.Id)
|
||||
{
|
||||
return AttachDetails(order.GetViewModel);
|
||||
return AttachDetails(transportation.GetViewModel);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -61,30 +61,30 @@ namespace TransportCompanyListImplement.Implements
|
||||
public TransportationViewModel? Insert(TransportationBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
foreach (var order in _source.Transportations)
|
||||
foreach (var transportation in _source.Transportations)
|
||||
{
|
||||
if (model.Id <= order.Id)
|
||||
if (model.Id <= transportation.Id)
|
||||
{
|
||||
model.Id = order.Id + 1;
|
||||
model.Id = transportation.Id + 1;
|
||||
}
|
||||
}
|
||||
var newOrder = Transportation.Create(model);
|
||||
if (newOrder == null)
|
||||
var newTransportation = Transportation.Create(model);
|
||||
if (newTransportation == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.Transportations.Add(newOrder);
|
||||
return AttachDetails(newOrder.GetViewModel);
|
||||
_source.Transportations.Add(newTransportation);
|
||||
return AttachDetails(newTransportation.GetViewModel);
|
||||
}
|
||||
|
||||
public TransportationViewModel? Update(TransportationBindingModel model)
|
||||
{
|
||||
foreach (var order in _source.Transportations)
|
||||
foreach (var transportation in _source.Transportations)
|
||||
{
|
||||
if (order.Id == model.Id)
|
||||
if (transportation.Id == model.Id)
|
||||
{
|
||||
order.Update(model);
|
||||
return AttachDetails(order.GetViewModel);
|
||||
transportation.Update(model);
|
||||
return AttachDetails(transportation.GetViewModel);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
124
TransportCompany/TransportCompanyView/FormCargo.Designer.cs
generated
Normal file
124
TransportCompany/TransportCompanyView/FormCargo.Designer.cs
generated
Normal file
@ -0,0 +1,124 @@
|
||||
namespace TransportCompanyView
|
||||
{
|
||||
partial class FormCargo
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.labelName = new System.Windows.Forms.Label();
|
||||
this.textBoxName = new System.Windows.Forms.TextBox();
|
||||
this.textBoxWeight = new System.Windows.Forms.TextBox();
|
||||
this.labelCost = new System.Windows.Forms.Label();
|
||||
this.buttonSave = new System.Windows.Forms.Button();
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// labelName
|
||||
//
|
||||
this.labelName.AutoSize = true;
|
||||
this.labelName.Location = new System.Drawing.Point(10, 7);
|
||||
this.labelName.Name = "labelName";
|
||||
this.labelName.Size = new System.Drawing.Size(62, 15);
|
||||
this.labelName.TabIndex = 0;
|
||||
this.labelName.Text = "Название:";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
this.textBoxName.Location = new System.Drawing.Point(86, 7);
|
||||
this.textBoxName.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.textBoxName.Name = "textBoxName";
|
||||
this.textBoxName.Size = new System.Drawing.Size(321, 23);
|
||||
this.textBoxName.TabIndex = 1;
|
||||
//
|
||||
// textBoxCost
|
||||
//
|
||||
this.textBoxWeight.Location = new System.Drawing.Point(86, 32);
|
||||
this.textBoxWeight.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.textBoxWeight.Name = "textBoxWeight";
|
||||
this.textBoxWeight.Size = new System.Drawing.Size(117, 23);
|
||||
this.textBoxWeight.TabIndex = 3;
|
||||
//
|
||||
// labelCost
|
||||
//
|
||||
this.labelCost.AutoSize = true;
|
||||
this.labelCost.Location = new System.Drawing.Point(10, 32);
|
||||
this.labelCost.Name = "labelCost";
|
||||
this.labelCost.Size = new System.Drawing.Size(35, 15);
|
||||
this.labelCost.TabIndex = 2;
|
||||
this.labelCost.Text = "Вес";
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
this.buttonSave.Location = new System.Drawing.Point(150, 68);
|
||||
this.buttonSave.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonSave.Name = "buttonSave";
|
||||
this.buttonSave.Size = new System.Drawing.Size(114, 30);
|
||||
this.buttonSave.TabIndex = 4;
|
||||
this.buttonSave.Text = "Сохранить";
|
||||
this.buttonSave.UseVisualStyleBackColor = true;
|
||||
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
this.buttonCancel.Location = new System.Drawing.Point(287, 68);
|
||||
this.buttonCancel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(119, 30);
|
||||
this.buttonCancel.TabIndex = 5;
|
||||
this.buttonCancel.Text = "Отмена";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// FormComponent
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(418, 106);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.buttonSave);
|
||||
this.Controls.Add(this.textBoxWeight);
|
||||
this.Controls.Add(this.labelCost);
|
||||
this.Controls.Add(this.textBoxName);
|
||||
this.Controls.Add(this.labelName);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.Name = "FormCargo";
|
||||
this.Text = "Груз";
|
||||
this.Load += new System.EventHandler(this.FormCargo_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelName;
|
||||
private TextBox textBoxName;
|
||||
private TextBox textBoxWeight;
|
||||
private Label labelCost;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
90
TransportCompany/TransportCompanyView/FormCargo.cs
Normal file
90
TransportCompany/TransportCompanyView/FormCargo.cs
Normal file
@ -0,0 +1,90 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
|
||||
namespace TransportCompanyView
|
||||
{
|
||||
public partial class FormCargo : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICargoLogic _logic;
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormCargo(ILogger<FormCargo> logger, ICargoLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormCargo_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Получение груза");
|
||||
var view = _logic.ReadElement(new CargoSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.CargoName;
|
||||
textBoxWeight.Text = view.Weight.ToString();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(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;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxWeight.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните вес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Сохранение груза");
|
||||
try
|
||||
{
|
||||
var model = new CargoBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
CargoName = textBoxName.Text,
|
||||
Weight = Convert.ToInt32(textBoxWeight.Text)
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения груза");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
TransportCompany/TransportCompanyView/FormCargo.resx
Normal file
120
TransportCompany/TransportCompanyView/FormCargo.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
137
TransportCompany/TransportCompanyView/FormCargos.Designer.cs
generated
Normal file
137
TransportCompany/TransportCompanyView/FormCargos.Designer.cs
generated
Normal file
@ -0,0 +1,137 @@
|
||||
namespace TransportCompanyView
|
||||
{
|
||||
partial class FormCargos
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.ToolsPanel = new System.Windows.Forms.Panel();
|
||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
||||
this.buttonDelete = new System.Windows.Forms.Button();
|
||||
this.buttonEdit = new System.Windows.Forms.Button();
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.ToolsPanel.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.AllowUserToAddRows = false;
|
||||
this.dataGridView.AllowUserToDeleteRows = false;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Location = new System.Drawing.Point(10, 9);
|
||||
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.ReadOnly = true;
|
||||
this.dataGridView.RowHeadersWidth = 51;
|
||||
this.dataGridView.RowTemplate.Height = 29;
|
||||
this.dataGridView.Size = new System.Drawing.Size(516, 320);
|
||||
this.dataGridView.TabIndex = 0;
|
||||
//
|
||||
// ToolsPanel
|
||||
//
|
||||
this.ToolsPanel.Controls.Add(this.buttonUpdate);
|
||||
this.ToolsPanel.Controls.Add(this.buttonDelete);
|
||||
this.ToolsPanel.Controls.Add(this.buttonEdit);
|
||||
this.ToolsPanel.Controls.Add(this.buttonAdd);
|
||||
this.ToolsPanel.Location = new System.Drawing.Point(532, 9);
|
||||
this.ToolsPanel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.ToolsPanel.Name = "ToolsPanel";
|
||||
this.ToolsPanel.Size = new System.Drawing.Size(158, 320);
|
||||
this.ToolsPanel.TabIndex = 1;
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
this.buttonUpdate.Location = new System.Drawing.Point(27, 154);
|
||||
this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonUpdate.Name = "buttonUpdate";
|
||||
this.buttonUpdate.Size = new System.Drawing.Size(110, 27);
|
||||
this.buttonUpdate.TabIndex = 3;
|
||||
this.buttonUpdate.Text = "Обновить";
|
||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
||||
this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
this.buttonDelete.Location = new System.Drawing.Point(27, 106);
|
||||
this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonDelete.Name = "buttonDelete";
|
||||
this.buttonDelete.Size = new System.Drawing.Size(110, 27);
|
||||
this.buttonDelete.TabIndex = 2;
|
||||
this.buttonDelete.Text = "Удалить";
|
||||
this.buttonDelete.UseVisualStyleBackColor = true;
|
||||
this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click);
|
||||
//
|
||||
// buttonEdit
|
||||
//
|
||||
this.buttonEdit.Location = new System.Drawing.Point(27, 57);
|
||||
this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonEdit.Name = "buttonEdit";
|
||||
this.buttonEdit.Size = new System.Drawing.Size(110, 27);
|
||||
this.buttonEdit.TabIndex = 1;
|
||||
this.buttonEdit.Text = "Изменить";
|
||||
this.buttonEdit.UseVisualStyleBackColor = true;
|
||||
this.buttonEdit.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(27, 12);
|
||||
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonAdd.Name = "buttonAdd";
|
||||
this.buttonAdd.Size = new System.Drawing.Size(110, 27);
|
||||
this.buttonAdd.TabIndex = 0;
|
||||
this.buttonAdd.Text = "Добавить";
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||
//
|
||||
// FormComponents
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(700, 338);
|
||||
this.Controls.Add(this.ToolsPanel);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.Name = "FormCargos";
|
||||
this.Text = "Грузы";
|
||||
this.Load += new System.EventHandler(this.FormCargos_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ToolsPanel.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Panel ToolsPanel;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonDelete;
|
||||
private Button buttonEdit;
|
||||
private Button buttonAdd;
|
||||
}
|
||||
}
|
105
TransportCompany/TransportCompanyView/FormCargos.cs
Normal file
105
TransportCompany/TransportCompanyView/FormCargos.cs
Normal file
@ -0,0 +1,105 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace TransportCompanyView
|
||||
{
|
||||
public partial class FormCargos : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICargoLogic _logic;
|
||||
|
||||
public FormCargos(ILogger<FormCargos> logger, ICargoLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormCargos_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["CargoName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка грузов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки грузов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCargo));
|
||||
if (service is FormCargo form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCargo));
|
||||
if (service is FormCargo form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Удаление груза");
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new CargoBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления груза");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonRef_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
120
TransportCompany/TransportCompanyView/FormCargos.resx
Normal file
120
TransportCompany/TransportCompanyView/FormCargos.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
211
TransportCompany/TransportCompanyView/FormCreateTransportation.Designer.cs
generated
Normal file
211
TransportCompany/TransportCompanyView/FormCreateTransportation.Designer.cs
generated
Normal file
@ -0,0 +1,211 @@
|
||||
namespace TransportCompanyView
|
||||
{
|
||||
partial class FormCreateTransportation
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
labelCargo = new Label();
|
||||
comboBoxCargo = new ComboBox();
|
||||
labelCount = new Label();
|
||||
textBoxCount = new TextBox();
|
||||
buttonCancel = new Button();
|
||||
buttonSave = new Button();
|
||||
comboBoxDriver = new ComboBox();
|
||||
labelDriver = new Label();
|
||||
comboBoxTransport = new ComboBox();
|
||||
labelTransport = new Label();
|
||||
comboBoxPointFrom = new ComboBox();
|
||||
labelPointFrom = new Label();
|
||||
comboBoxPointTo = new ComboBox();
|
||||
labelPointTo = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelCargo
|
||||
//
|
||||
labelCargo.AutoSize = true;
|
||||
labelCargo.Location = new Point(11, 15);
|
||||
labelCargo.Name = "labelCargo";
|
||||
labelCargo.Size = new Size(39, 20);
|
||||
labelCargo.TabIndex = 0;
|
||||
labelCargo.Text = "Груз";
|
||||
//
|
||||
// comboBoxCargo
|
||||
//
|
||||
comboBoxCargo.FormattingEnabled = true;
|
||||
comboBoxCargo.Location = new Point(115, 12);
|
||||
comboBoxCargo.Name = "comboBoxCargo";
|
||||
comboBoxCargo.Size = new Size(358, 28);
|
||||
comboBoxCargo.TabIndex = 1;
|
||||
//
|
||||
// labelCount
|
||||
//
|
||||
labelCount.AutoSize = true;
|
||||
labelCount.Location = new Point(11, 49);
|
||||
labelCount.Name = "labelCount";
|
||||
labelCount.Size = new Size(97, 20);
|
||||
labelCount.TabIndex = 2;
|
||||
labelCount.Text = "Количество: ";
|
||||
//
|
||||
// textBoxCount
|
||||
//
|
||||
textBoxCount.Location = new Point(115, 45);
|
||||
textBoxCount.Name = "textBoxCount";
|
||||
textBoxCount.Size = new Size(358, 27);
|
||||
textBoxCount.TabIndex = 3;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(355, 227);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(110, 32);
|
||||
buttonCancel.TabIndex = 6;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(239, 227);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(110, 32);
|
||||
buttonSave.TabIndex = 7;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += ButtonSave_Click;
|
||||
//
|
||||
// comboBoxDriver
|
||||
//
|
||||
comboBoxDriver.FormattingEnabled = true;
|
||||
comboBoxDriver.Location = new Point(115, 78);
|
||||
comboBoxDriver.Name = "comboBoxDriver";
|
||||
comboBoxDriver.Size = new Size(358, 28);
|
||||
comboBoxDriver.TabIndex = 9;
|
||||
//
|
||||
// labelDriver
|
||||
//
|
||||
labelDriver.AutoSize = true;
|
||||
labelDriver.Location = new Point(11, 81);
|
||||
labelDriver.Name = "labelDriver";
|
||||
labelDriver.Size = new Size(74, 20);
|
||||
labelDriver.TabIndex = 8;
|
||||
labelDriver.Text = "Водитель";
|
||||
//
|
||||
// comboBoxTransport
|
||||
//
|
||||
comboBoxTransport.FormattingEnabled = true;
|
||||
comboBoxTransport.Location = new Point(115, 112);
|
||||
comboBoxTransport.Name = "comboBoxTransport";
|
||||
comboBoxTransport.Size = new Size(358, 28);
|
||||
comboBoxTransport.TabIndex = 11;
|
||||
//
|
||||
// labelTransport
|
||||
//
|
||||
labelTransport.AutoSize = true;
|
||||
labelTransport.Location = new Point(11, 115);
|
||||
labelTransport.Name = "labelTransport";
|
||||
labelTransport.Size = new Size(68, 20);
|
||||
labelTransport.TabIndex = 10;
|
||||
labelTransport.Text = "Машина";
|
||||
//
|
||||
// comboBoxPointFrom
|
||||
//
|
||||
comboBoxPointFrom.FormattingEnabled = true;
|
||||
comboBoxPointFrom.Location = new Point(115, 146);
|
||||
comboBoxPointFrom.Name = "comboBoxPointFrom";
|
||||
comboBoxPointFrom.Size = new Size(358, 28);
|
||||
comboBoxPointFrom.TabIndex = 13;
|
||||
//
|
||||
// labelPointFrom
|
||||
//
|
||||
labelPointFrom.AutoSize = true;
|
||||
labelPointFrom.Location = new Point(11, 149);
|
||||
labelPointFrom.Name = "labelPointFrom";
|
||||
labelPointFrom.Size = new Size(56, 20);
|
||||
labelPointFrom.TabIndex = 12;
|
||||
labelPointFrom.Text = "Откуда";
|
||||
//
|
||||
// comboBoxPointTo
|
||||
//
|
||||
comboBoxPointTo.FormattingEnabled = true;
|
||||
comboBoxPointTo.Location = new Point(115, 180);
|
||||
comboBoxPointTo.Name = "comboBoxPointTo";
|
||||
comboBoxPointTo.Size = new Size(358, 28);
|
||||
comboBoxPointTo.TabIndex = 15;
|
||||
//
|
||||
// labelPointTo
|
||||
//
|
||||
labelPointTo.AutoSize = true;
|
||||
labelPointTo.Location = new Point(11, 183);
|
||||
labelPointTo.Name = "labelPointTo";
|
||||
labelPointTo.Size = new Size(41, 20);
|
||||
labelPointTo.TabIndex = 14;
|
||||
labelPointTo.Text = "Куда";
|
||||
//
|
||||
// FormCreateTransportation
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(485, 271);
|
||||
Controls.Add(comboBoxPointTo);
|
||||
Controls.Add(labelPointTo);
|
||||
Controls.Add(comboBoxPointFrom);
|
||||
Controls.Add(labelPointFrom);
|
||||
Controls.Add(comboBoxTransport);
|
||||
Controls.Add(labelTransport);
|
||||
Controls.Add(comboBoxDriver);
|
||||
Controls.Add(labelDriver);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(textBoxCount);
|
||||
Controls.Add(labelCount);
|
||||
Controls.Add(comboBoxCargo);
|
||||
Controls.Add(labelCargo);
|
||||
Name = "FormCreateTransportation";
|
||||
Text = "Транспортировка";
|
||||
Load += new System.EventHandler(FormCreateTransportation_Load);
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelCargo;
|
||||
private ComboBox comboBoxCargo;
|
||||
private Label labelCount;
|
||||
private TextBox textBoxCount;
|
||||
private Button buttonCancel;
|
||||
private Button buttonSave;
|
||||
private ComboBox comboBoxDriver;
|
||||
private Label labelDriver;
|
||||
private ComboBox comboBoxTransport;
|
||||
private Label labelTransport;
|
||||
private ComboBox comboBoxPointFrom;
|
||||
private Label labelPointFrom;
|
||||
private ComboBox comboBoxPointTo;
|
||||
private Label labelPointTo;
|
||||
}
|
||||
}
|
@ -0,0 +1,157 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
using TransportCompanyContracts.ViewModels;
|
||||
|
||||
namespace TransportCompanyView
|
||||
{
|
||||
public partial class FormCreateTransportation : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ICargoLogic _logicC;
|
||||
private readonly IDriverLogic _logicD;
|
||||
private readonly ITransportLogic _logicT;
|
||||
private readonly IPointLogic _logicP;
|
||||
private readonly ITransportationLogic _logicTt;
|
||||
private List<CargoViewModel>? _cargoList;
|
||||
private List<DriverViewModel>? _driverList;
|
||||
private List<TransportViewModel>? _transportList;
|
||||
private List<PointViewModel>? _pointFromList;
|
||||
private List<PointViewModel>? _pointToList;
|
||||
|
||||
public FormCreateTransportation(ILogger<FormCreateTransportation> logger, ICargoLogic logicC, IDriverLogic logicD, ITransportLogic logicT, IPointLogic logicP, ITransportationLogic logicTt)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logicC = logicC;
|
||||
_logicD = logicD;
|
||||
_logicT = logicT;
|
||||
_logicP = logicP;
|
||||
_logicTt = logicTt;
|
||||
}
|
||||
|
||||
private void FormCreateTransportation_Load(object sender, EventArgs e)
|
||||
{
|
||||
_cargoList = _logicC.ReadList(null);
|
||||
_driverList = _logicD.ReadList(null);
|
||||
_transportList = _logicT.ReadList(null);
|
||||
_pointFromList = _logicP.ReadList(null);
|
||||
_pointToList = _logicP.ReadList(null);
|
||||
|
||||
if (_cargoList != null)
|
||||
{
|
||||
comboBoxCargo.DisplayMember = "CargoName";
|
||||
comboBoxCargo.ValueMember = "Id";
|
||||
comboBoxCargo.DataSource = _cargoList;
|
||||
comboBoxCargo.SelectedItem = null;
|
||||
_logger.LogInformation("Загрузка грузов для транспортировки");
|
||||
}
|
||||
|
||||
if (_driverList != null)
|
||||
{
|
||||
comboBoxDriver.DisplayMember = "DriverFio";
|
||||
comboBoxDriver.ValueMember = "Id";
|
||||
comboBoxDriver.DataSource = _driverList;
|
||||
comboBoxDriver.SelectedItem = null;
|
||||
_logger.LogInformation("Загрузка водителей для транспортировки");
|
||||
}
|
||||
|
||||
if (_transportList != null)
|
||||
{
|
||||
comboBoxTransport.DisplayMember = "Model";
|
||||
comboBoxTransport.ValueMember = "Id";
|
||||
comboBoxTransport.DataSource = _transportList;
|
||||
comboBoxTransport.SelectedItem = null;
|
||||
_logger.LogInformation("Загрузка машин для транспортировки");
|
||||
}
|
||||
|
||||
if (_pointFromList != null)
|
||||
{
|
||||
comboBoxPointFrom.DisplayMember = "PointName";
|
||||
comboBoxPointFrom.ValueMember = "Id";
|
||||
comboBoxPointFrom.DataSource = _pointFromList;
|
||||
comboBoxPointFrom.SelectedItem = null;
|
||||
_logger.LogInformation("Загрузка пунктов отправления для транспортировки");
|
||||
}
|
||||
|
||||
if (_pointToList != null)
|
||||
{
|
||||
comboBoxPointTo.DisplayMember = "PointName";
|
||||
comboBoxPointTo.ValueMember = "Id";
|
||||
comboBoxPointTo.DataSource = _pointToList;
|
||||
comboBoxPointTo.SelectedItem = null;
|
||||
_logger.LogInformation("Загрузка пунктов прибытия для транспортировки");
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните поле Количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (comboBoxCargo.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите груз", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните количество груза", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (comboBoxDriver.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите водителя", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (comboBoxTransport.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите машину", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (comboBoxPointFrom.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите пункт отправки", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (comboBoxPointTo.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите пункт прибытия", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Создание транспортировки");
|
||||
try
|
||||
{
|
||||
var operationResult = _logicTt.CreateTransportation(new TransportationBindingModel
|
||||
{
|
||||
DriverId = Convert.ToInt32(comboBoxDriver.SelectedValue),
|
||||
TransportId = Convert.ToInt32(comboBoxTransport.SelectedValue),
|
||||
CargoId = Convert.ToInt32(comboBoxCargo.SelectedValue),
|
||||
Count = Convert.ToInt32(textBoxCount.Text),
|
||||
PointToId = Convert.ToInt32(comboBoxPointTo.SelectedValue),
|
||||
PointFromId = Convert.ToInt32(comboBoxPointFrom.SelectedValue),
|
||||
});
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при создании транспортировки. Дополнительная информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка создания транспортировки");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
@ -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>
|
118
TransportCompany/TransportCompanyView/FormDriver.Designer.cs
generated
Normal file
118
TransportCompany/TransportCompanyView/FormDriver.Designer.cs
generated
Normal file
@ -0,0 +1,118 @@
|
||||
namespace TransportCompanyView
|
||||
{
|
||||
partial class FormDriver
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
labelName = new Label();
|
||||
textBoxFio = new TextBox();
|
||||
textBoxPhoneNumber = new TextBox();
|
||||
labelPhoneNumber = new Label();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelName
|
||||
//
|
||||
labelName.AutoSize = true;
|
||||
labelName.Location = new Point(11, 9);
|
||||
labelName.Name = "labelName";
|
||||
labelName.Size = new Size(45, 20);
|
||||
labelName.TabIndex = 0;
|
||||
labelName.Text = "ФИО:";
|
||||
//
|
||||
// textBoxFio
|
||||
//
|
||||
textBoxFio.Location = new Point(98, 9);
|
||||
textBoxFio.Name = "textBoxFio";
|
||||
textBoxFio.Size = new Size(366, 27);
|
||||
textBoxFio.TabIndex = 1;
|
||||
//
|
||||
// textBoxPhoneNumber
|
||||
//
|
||||
textBoxPhoneNumber.Location = new Point(98, 43);
|
||||
textBoxPhoneNumber.Name = "textBoxPhoneNumber";
|
||||
textBoxPhoneNumber.Size = new Size(366, 27);
|
||||
textBoxPhoneNumber.TabIndex = 3;
|
||||
//
|
||||
// labelPhoneNumber
|
||||
//
|
||||
labelPhoneNumber.AutoSize = true;
|
||||
labelPhoneNumber.Location = new Point(11, 43);
|
||||
labelPhoneNumber.Name = "labelPhoneNumber";
|
||||
labelPhoneNumber.Size = new Size(69, 20);
|
||||
labelPhoneNumber.TabIndex = 2;
|
||||
labelPhoneNumber.Text = "Телефон";
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(171, 91);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(130, 40);
|
||||
buttonSave.TabIndex = 4;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += ButtonSave_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(328, 91);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(136, 40);
|
||||
buttonCancel.TabIndex = 5;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// FormDriver
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(478, 141);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(textBoxPhoneNumber);
|
||||
Controls.Add(labelPhoneNumber);
|
||||
Controls.Add(textBoxFio);
|
||||
Controls.Add(labelName);
|
||||
Name = "FormDriver";
|
||||
Text = "Водитель";
|
||||
Load += FormCargo_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelName;
|
||||
private TextBox textBoxFio;
|
||||
private TextBox textBoxPhoneNumber;
|
||||
private Label labelPhoneNumber;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
99
TransportCompany/TransportCompanyView/FormDriver.cs
Normal file
99
TransportCompany/TransportCompanyView/FormDriver.cs
Normal file
@ -0,0 +1,99 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
|
||||
namespace TransportCompanyView
|
||||
{
|
||||
public partial class FormDriver : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IDriverLogic _logic;
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormDriver(ILogger<FormDriver> logger, IDriverLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormCargo_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Получение водителя");
|
||||
var view = _logic.ReadElement(new DriverSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
if (view != null)
|
||||
{
|
||||
textBoxFio.Text = view.DriverFio;
|
||||
textBoxPhoneNumber.Text = view.PhoneNumber;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения водителя");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxFio.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните ФИО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxPhoneNumber.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните номер телефона", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Сохранение водителя");
|
||||
try
|
||||
{
|
||||
var model = new DriverBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
DriverFio = textBoxFio.Text,
|
||||
PhoneNumber = textBoxPhoneNumber.Text
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения водителя");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
TransportCompany/TransportCompanyView/FormDriver.resx
Normal file
120
TransportCompany/TransportCompanyView/FormDriver.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
137
TransportCompany/TransportCompanyView/FormDrivers.Designer.cs
generated
Normal file
137
TransportCompany/TransportCompanyView/FormDrivers.Designer.cs
generated
Normal file
@ -0,0 +1,137 @@
|
||||
namespace TransportCompanyView
|
||||
{
|
||||
partial class FormDrivers
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.ToolsPanel = new System.Windows.Forms.Panel();
|
||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
||||
this.buttonDelete = new System.Windows.Forms.Button();
|
||||
this.buttonEdit = new System.Windows.Forms.Button();
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.ToolsPanel.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.AllowUserToAddRows = false;
|
||||
this.dataGridView.AllowUserToDeleteRows = false;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Location = new System.Drawing.Point(10, 9);
|
||||
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.ReadOnly = true;
|
||||
this.dataGridView.RowHeadersWidth = 51;
|
||||
this.dataGridView.RowTemplate.Height = 29;
|
||||
this.dataGridView.Size = new System.Drawing.Size(516, 320);
|
||||
this.dataGridView.TabIndex = 0;
|
||||
//
|
||||
// ToolsPanel
|
||||
//
|
||||
this.ToolsPanel.Controls.Add(this.buttonUpdate);
|
||||
this.ToolsPanel.Controls.Add(this.buttonDelete);
|
||||
this.ToolsPanel.Controls.Add(this.buttonEdit);
|
||||
this.ToolsPanel.Controls.Add(this.buttonAdd);
|
||||
this.ToolsPanel.Location = new System.Drawing.Point(532, 9);
|
||||
this.ToolsPanel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.ToolsPanel.Name = "ToolsPanel";
|
||||
this.ToolsPanel.Size = new System.Drawing.Size(158, 320);
|
||||
this.ToolsPanel.TabIndex = 1;
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
this.buttonUpdate.Location = new System.Drawing.Point(27, 154);
|
||||
this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonUpdate.Name = "buttonUpdate";
|
||||
this.buttonUpdate.Size = new System.Drawing.Size(110, 27);
|
||||
this.buttonUpdate.TabIndex = 3;
|
||||
this.buttonUpdate.Text = "Обновить";
|
||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
||||
this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
this.buttonDelete.Location = new System.Drawing.Point(27, 106);
|
||||
this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonDelete.Name = "buttonDelete";
|
||||
this.buttonDelete.Size = new System.Drawing.Size(110, 27);
|
||||
this.buttonDelete.TabIndex = 2;
|
||||
this.buttonDelete.Text = "Удалить";
|
||||
this.buttonDelete.UseVisualStyleBackColor = true;
|
||||
this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click);
|
||||
//
|
||||
// buttonEdit
|
||||
//
|
||||
this.buttonEdit.Location = new System.Drawing.Point(27, 57);
|
||||
this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonEdit.Name = "buttonEdit";
|
||||
this.buttonEdit.Size = new System.Drawing.Size(110, 27);
|
||||
this.buttonEdit.TabIndex = 1;
|
||||
this.buttonEdit.Text = "Изменить";
|
||||
this.buttonEdit.UseVisualStyleBackColor = true;
|
||||
this.buttonEdit.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(27, 12);
|
||||
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonAdd.Name = "buttonAdd";
|
||||
this.buttonAdd.Size = new System.Drawing.Size(110, 27);
|
||||
this.buttonAdd.TabIndex = 0;
|
||||
this.buttonAdd.Text = "Добавить";
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||
//
|
||||
// FormComponents
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(700, 338);
|
||||
this.Controls.Add(this.ToolsPanel);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.Name = "FormCargos";
|
||||
this.Text = "Водители";
|
||||
this.Load += new System.EventHandler(this.FormDrivers_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ToolsPanel.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Panel ToolsPanel;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonDelete;
|
||||
private Button buttonEdit;
|
||||
private Button buttonAdd;
|
||||
}
|
||||
}
|
116
TransportCompany/TransportCompanyView/FormDrivers.cs
Normal file
116
TransportCompany/TransportCompanyView/FormDrivers.cs
Normal file
@ -0,0 +1,116 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace TransportCompanyView
|
||||
{
|
||||
public partial class FormDrivers : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IDriverLogic _logic;
|
||||
|
||||
public FormDrivers(ILogger<FormDrivers> logger, IDriverLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormDrivers_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;
|
||||
var halfWidth = dataGridView.Width / 2;
|
||||
dataGridView.Columns["DriverFio"].Width = halfWidth;
|
||||
dataGridView.Columns["PhoneNumber"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Загрузка водителей");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки водителей");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormDriver));
|
||||
if (service is FormDriver form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormDriver));
|
||||
if (service is FormDriver form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Удаление водителя");
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new DriverBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления водителя");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonRef_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
120
TransportCompany/TransportCompanyView/FormDrivers.resx
Normal file
120
TransportCompany/TransportCompanyView/FormDrivers.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
194
TransportCompany/TransportCompanyView/FormMain.Designer.cs
generated
Normal file
194
TransportCompany/TransportCompanyView/FormMain.Designer.cs
generated
Normal file
@ -0,0 +1,194 @@
|
||||
namespace TransportCompanyView
|
||||
{
|
||||
partial class FormMain
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
menuStrip1 = new MenuStrip();
|
||||
bookToolStripMenuItem = new ToolStripMenuItem();
|
||||
ingridientsToolStripMenuItem = new ToolStripMenuItem();
|
||||
pizzasToolStripMenuItem = new ToolStripMenuItem();
|
||||
машиныToolStripMenuItem = new ToolStripMenuItem();
|
||||
пунктыToolStripMenuItem = new ToolStripMenuItem();
|
||||
dataGridView = new DataGridView();
|
||||
buttonCreateOrder = new Button();
|
||||
buttonTakeOrderInWork = new Button();
|
||||
buttonOrderReady = new Button();
|
||||
buttonIssuedOrder = new Button();
|
||||
buttonRef = new Button();
|
||||
menuStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// menuStrip1
|
||||
//
|
||||
menuStrip1.ImageScalingSize = new Size(20, 20);
|
||||
menuStrip1.Items.AddRange(new ToolStripItem[] { bookToolStripMenuItem });
|
||||
menuStrip1.Location = new Point(0, 0);
|
||||
menuStrip1.Name = "menuStrip1";
|
||||
menuStrip1.Padding = new Padding(6, 3, 0, 3);
|
||||
menuStrip1.Size = new Size(1594, 30);
|
||||
menuStrip1.TabIndex = 0;
|
||||
menuStrip1.Text = "menuStrip1";
|
||||
//
|
||||
// bookToolStripMenuItem
|
||||
//
|
||||
bookToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { ingridientsToolStripMenuItem, pizzasToolStripMenuItem, машиныToolStripMenuItem, пунктыToolStripMenuItem });
|
||||
bookToolStripMenuItem.Name = "bookToolStripMenuItem";
|
||||
bookToolStripMenuItem.Size = new Size(108, 24);
|
||||
bookToolStripMenuItem.Text = "Справочник";
|
||||
//
|
||||
// ingridientsToolStripMenuItem
|
||||
//
|
||||
ingridientsToolStripMenuItem.Name = "ingridientsToolStripMenuItem";
|
||||
ingridientsToolStripMenuItem.Size = new Size(158, 26);
|
||||
ingridientsToolStripMenuItem.Text = "Грузы";
|
||||
ingridientsToolStripMenuItem.Click += CargosToolStripMenuItem_Click;
|
||||
//
|
||||
// pizzasToolStripMenuItem
|
||||
//
|
||||
pizzasToolStripMenuItem.Name = "pizzasToolStripMenuItem";
|
||||
pizzasToolStripMenuItem.Size = new Size(158, 26);
|
||||
pizzasToolStripMenuItem.Text = "Водители";
|
||||
pizzasToolStripMenuItem.Click += DriversToolStripMenuItem_Click;
|
||||
//
|
||||
// машиныToolStripMenuItem
|
||||
//
|
||||
машиныToolStripMenuItem.Name = "машиныToolStripMenuItem";
|
||||
машиныToolStripMenuItem.Size = new Size(158, 26);
|
||||
машиныToolStripMenuItem.Text = "Машины";
|
||||
машиныToolStripMenuItem.Click += TransportsToolStripMenuItem_Click;
|
||||
//
|
||||
// пунктыToolStripMenuItem
|
||||
//
|
||||
пунктыToolStripMenuItem.Name = "пунктыToolStripMenuItem";
|
||||
пунктыToolStripMenuItem.Size = new Size(158, 26);
|
||||
пунктыToolStripMenuItem.Text = "Пункты";
|
||||
пунктыToolStripMenuItem.Click += PointsToolStripMenuItem_Click;
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.AllowUserToAddRows = false;
|
||||
dataGridView.AllowUserToDeleteRows = false;
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(11, 31);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.ReadOnly = true;
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.RowTemplate.Height = 29;
|
||||
dataGridView.Size = new Size(1305, 381);
|
||||
dataGridView.TabIndex = 1;
|
||||
//
|
||||
// buttonCreateOrder
|
||||
//
|
||||
buttonCreateOrder.Location = new Point(1334, 72);
|
||||
buttonCreateOrder.Name = "buttonCreateOrder";
|
||||
buttonCreateOrder.Size = new Size(247, 29);
|
||||
buttonCreateOrder.TabIndex = 2;
|
||||
buttonCreateOrder.Text = "Создать транспортировку";
|
||||
buttonCreateOrder.UseVisualStyleBackColor = true;
|
||||
buttonCreateOrder.Click += ButtonFormCreateTransportation_Click;
|
||||
//
|
||||
// buttonTakeOrderInWork
|
||||
//
|
||||
buttonTakeOrderInWork.Location = new Point(1334, 124);
|
||||
buttonTakeOrderInWork.Name = "buttonTakeOrderInWork";
|
||||
buttonTakeOrderInWork.Size = new Size(247, 29);
|
||||
buttonTakeOrderInWork.TabIndex = 3;
|
||||
buttonTakeOrderInWork.Text = "Отдать на доставку";
|
||||
buttonTakeOrderInWork.UseVisualStyleBackColor = true;
|
||||
buttonTakeOrderInWork.Click += ButtonDeliveredTransportation_Click;
|
||||
//
|
||||
// buttonOrderReady
|
||||
//
|
||||
buttonOrderReady.Location = new Point(1334, 173);
|
||||
buttonOrderReady.Name = "buttonOrderReady";
|
||||
buttonOrderReady.Size = new Size(247, 29);
|
||||
buttonOrderReady.TabIndex = 4;
|
||||
buttonOrderReady.Text = "Груз прибыл";
|
||||
buttonOrderReady.UseVisualStyleBackColor = true;
|
||||
buttonOrderReady.Click += ButtonArrivedTransportation_Click;
|
||||
//
|
||||
// buttonIssuedOrder
|
||||
//
|
||||
buttonIssuedOrder.Location = new Point(1334, 226);
|
||||
buttonIssuedOrder.Name = "buttonIssuedOrder";
|
||||
buttonIssuedOrder.Size = new Size(247, 29);
|
||||
buttonIssuedOrder.TabIndex = 5;
|
||||
buttonIssuedOrder.Text = "Груз отгружен";
|
||||
buttonIssuedOrder.UseVisualStyleBackColor = true;
|
||||
buttonIssuedOrder.Click += ButtonShippedTransportation_Click;
|
||||
//
|
||||
// buttonRef
|
||||
//
|
||||
buttonRef.Location = new Point(1334, 281);
|
||||
buttonRef.Name = "buttonRef";
|
||||
buttonRef.Size = new Size(247, 29);
|
||||
buttonRef.TabIndex = 6;
|
||||
buttonRef.Text = "Обновить список";
|
||||
buttonRef.UseVisualStyleBackColor = true;
|
||||
buttonRef.Click += ButtonRef_Click;
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1594, 425);
|
||||
Controls.Add(buttonRef);
|
||||
Controls.Add(buttonIssuedOrder);
|
||||
Controls.Add(buttonOrderReady);
|
||||
Controls.Add(buttonTakeOrderInWork);
|
||||
Controls.Add(buttonCreateOrder);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(menuStrip1);
|
||||
MainMenuStrip = menuStrip1;
|
||||
Name = "FormMain";
|
||||
Text = "Транспортная компания";
|
||||
Load += FormMain_Load;
|
||||
menuStrip1.ResumeLayout(false);
|
||||
menuStrip1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private MenuStrip menuStrip1;
|
||||
private ToolStripMenuItem bookToolStripMenuItem;
|
||||
private ToolStripMenuItem ingridientsToolStripMenuItem;
|
||||
private ToolStripMenuItem pizzasToolStripMenuItem;
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonCreateOrder;
|
||||
private Button buttonTakeOrderInWork;
|
||||
private Button buttonOrderReady;
|
||||
private Button buttonIssuedOrder;
|
||||
private Button buttonRef;
|
||||
private ToolStripMenuItem машиныToolStripMenuItem;
|
||||
private ToolStripMenuItem пунктыToolStripMenuItem;
|
||||
}
|
||||
}
|
183
TransportCompany/TransportCompanyView/FormMain.cs
Normal file
183
TransportCompany/TransportCompanyView/FormMain.cs
Normal file
@ -0,0 +1,183 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace TransportCompanyView
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ITransportationLogic _transportationLogic;
|
||||
|
||||
public FormMain(ILogger<FormMain> logger, ITransportationLogic transportationLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_transportationLogic = transportationLogic;
|
||||
}
|
||||
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _transportationLogic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["DriverId"].Visible = false;
|
||||
dataGridView.Columns["TransportId"].Visible = false;
|
||||
dataGridView.Columns["PointToId"].Visible = false;
|
||||
dataGridView.Columns["PointFromId"].Visible = false;
|
||||
dataGridView.Columns["CargoId"].Visible = false;
|
||||
dataGridView.Columns["DriverFio"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopLeft;
|
||||
dataGridView.Columns["Model"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopLeft;
|
||||
dataGridView.Columns["CargoName"].DefaultCellStyle.Alignment = DataGridViewContentAlignment.TopLeft;
|
||||
|
||||
dataGridView.DefaultCellStyle.WrapMode = DataGridViewTriState.True;
|
||||
dataGridView.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
|
||||
}
|
||||
_logger.LogInformation("Загрузка транспортировок");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки транспортировок");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void CargosToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCargos));
|
||||
if (service is FormCargos form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void DriversToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormDrivers));
|
||||
if (service is FormDrivers form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void PointsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormPoints));
|
||||
if (service is FormPoints form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void TransportsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormTransports));
|
||||
if (service is FormTransports form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonFormCreateTransportation_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateTransportation));
|
||||
if (service is FormCreateTransportation form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDeliveredTransportation_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ No{id}. Меняется статус на 'В работе'", id);
|
||||
try
|
||||
{
|
||||
var operationResult = _transportationLogic.DeliveredTransportation(new TransportationBindingModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка передачи заказа в работу");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonArrivedTransportation_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ No{id}. Меняется статус на 'Готов'", id);
|
||||
try
|
||||
{
|
||||
var operationResult = _transportationLogic.ArrivedTransportation(new TransportationBindingModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о готовности заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonShippedTransportation_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ No{id}. Меняется статус на 'Выдан'", id);
|
||||
try
|
||||
{
|
||||
var operationResult = _transportationLogic.ShippedTransportation(new TransportationBindingModel
|
||||
{
|
||||
Id = id
|
||||
});
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
_logger.LogInformation("Заказ No{id} выдан", id);
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonRef_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
123
TransportCompany/TransportCompanyView/FormMain.resx
Normal file
123
TransportCompany/TransportCompanyView/FormMain.resx
Normal file
@ -0,0 +1,123 @@
|
||||
<?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="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
118
TransportCompany/TransportCompanyView/FormPoint.Designer.cs
generated
Normal file
118
TransportCompany/TransportCompanyView/FormPoint.Designer.cs
generated
Normal file
@ -0,0 +1,118 @@
|
||||
namespace TransportCompanyView
|
||||
{
|
||||
partial class FormPoint
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
labelName = new Label();
|
||||
textBoxName = new TextBox();
|
||||
textBoxAddress = new TextBox();
|
||||
labelAddress = new Label();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelName
|
||||
//
|
||||
labelName.AutoSize = true;
|
||||
labelName.Location = new Point(11, 9);
|
||||
labelName.Name = "labelName";
|
||||
labelName.Size = new Size(45, 20);
|
||||
labelName.TabIndex = 0;
|
||||
labelName.Text = "Название:";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(98, 9);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(366, 27);
|
||||
textBoxName.TabIndex = 1;
|
||||
//
|
||||
// textBoxPhoneNumber
|
||||
//
|
||||
textBoxAddress.Location = new Point(98, 43);
|
||||
textBoxAddress.Name = "textBoxAddress";
|
||||
textBoxAddress.Size = new Size(366, 27);
|
||||
textBoxAddress.TabIndex = 3;
|
||||
//
|
||||
// labelPhoneNumber
|
||||
//
|
||||
labelAddress.AutoSize = true;
|
||||
labelAddress.Location = new Point(11, 43);
|
||||
labelAddress.Name = "labelPhoneNumber";
|
||||
labelAddress.Size = new Size(69, 20);
|
||||
labelAddress.TabIndex = 2;
|
||||
labelAddress.Text = "Адрес";
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(171, 91);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(130, 40);
|
||||
buttonSave.TabIndex = 4;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += ButtonSave_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(328, 91);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(136, 40);
|
||||
buttonCancel.TabIndex = 5;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// FormDriver
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(478, 141);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(textBoxAddress);
|
||||
Controls.Add(labelAddress);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(labelName);
|
||||
Name = "FormPoint";
|
||||
Text = "Пункт";
|
||||
Load += FormCargo_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelName;
|
||||
private TextBox textBoxName;
|
||||
private TextBox textBoxAddress;
|
||||
private Label labelAddress;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
}
|
||||
}
|
99
TransportCompany/TransportCompanyView/FormPoint.cs
Normal file
99
TransportCompany/TransportCompanyView/FormPoint.cs
Normal file
@ -0,0 +1,99 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
|
||||
namespace TransportCompanyView
|
||||
{
|
||||
public partial class FormPoint : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IPointLogic _logic;
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormPoint(ILogger<FormPoint> logger, IPointLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormCargo_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Получение пункта");
|
||||
var view = _logic.ReadElement(new PointSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.PointName;
|
||||
textBoxAddress.Text = view.Address;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(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;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxAddress.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Сохранение пункта");
|
||||
try
|
||||
{
|
||||
var model = new PointBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
PointName = textBoxName.Text,
|
||||
Address = textBoxAddress.Text
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения пункта");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
TransportCompany/TransportCompanyView/FormPoint.resx
Normal file
120
TransportCompany/TransportCompanyView/FormPoint.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
137
TransportCompany/TransportCompanyView/FormPoints.Designer.cs
generated
Normal file
137
TransportCompany/TransportCompanyView/FormPoints.Designer.cs
generated
Normal file
@ -0,0 +1,137 @@
|
||||
namespace TransportCompanyView
|
||||
{
|
||||
partial class FormPoints
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.ToolsPanel = new System.Windows.Forms.Panel();
|
||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
||||
this.buttonDelete = new System.Windows.Forms.Button();
|
||||
this.buttonEdit = new System.Windows.Forms.Button();
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.ToolsPanel.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.AllowUserToAddRows = false;
|
||||
this.dataGridView.AllowUserToDeleteRows = false;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Location = new System.Drawing.Point(10, 9);
|
||||
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.ReadOnly = true;
|
||||
this.dataGridView.RowHeadersWidth = 51;
|
||||
this.dataGridView.RowTemplate.Height = 29;
|
||||
this.dataGridView.Size = new System.Drawing.Size(516, 320);
|
||||
this.dataGridView.TabIndex = 0;
|
||||
//
|
||||
// ToolsPanel
|
||||
//
|
||||
this.ToolsPanel.Controls.Add(this.buttonUpdate);
|
||||
this.ToolsPanel.Controls.Add(this.buttonDelete);
|
||||
this.ToolsPanel.Controls.Add(this.buttonEdit);
|
||||
this.ToolsPanel.Controls.Add(this.buttonAdd);
|
||||
this.ToolsPanel.Location = new System.Drawing.Point(532, 9);
|
||||
this.ToolsPanel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.ToolsPanel.Name = "ToolsPanel";
|
||||
this.ToolsPanel.Size = new System.Drawing.Size(158, 320);
|
||||
this.ToolsPanel.TabIndex = 1;
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
this.buttonUpdate.Location = new System.Drawing.Point(27, 154);
|
||||
this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonUpdate.Name = "buttonUpdate";
|
||||
this.buttonUpdate.Size = new System.Drawing.Size(110, 27);
|
||||
this.buttonUpdate.TabIndex = 3;
|
||||
this.buttonUpdate.Text = "Обновить";
|
||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
||||
this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
this.buttonDelete.Location = new System.Drawing.Point(27, 106);
|
||||
this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonDelete.Name = "buttonDelete";
|
||||
this.buttonDelete.Size = new System.Drawing.Size(110, 27);
|
||||
this.buttonDelete.TabIndex = 2;
|
||||
this.buttonDelete.Text = "Удалить";
|
||||
this.buttonDelete.UseVisualStyleBackColor = true;
|
||||
this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click);
|
||||
//
|
||||
// buttonEdit
|
||||
//
|
||||
this.buttonEdit.Location = new System.Drawing.Point(27, 57);
|
||||
this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonEdit.Name = "buttonEdit";
|
||||
this.buttonEdit.Size = new System.Drawing.Size(110, 27);
|
||||
this.buttonEdit.TabIndex = 1;
|
||||
this.buttonEdit.Text = "Изменить";
|
||||
this.buttonEdit.UseVisualStyleBackColor = true;
|
||||
this.buttonEdit.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(27, 12);
|
||||
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonAdd.Name = "buttonAdd";
|
||||
this.buttonAdd.Size = new System.Drawing.Size(110, 27);
|
||||
this.buttonAdd.TabIndex = 0;
|
||||
this.buttonAdd.Text = "Добавить";
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||
//
|
||||
// FormComponents
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(700, 338);
|
||||
this.Controls.Add(this.ToolsPanel);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.Name = "FormPoints";
|
||||
this.Text = "Пункты";
|
||||
this.Load += new System.EventHandler(this.FormDrivers_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ToolsPanel.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Panel ToolsPanel;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonDelete;
|
||||
private Button buttonEdit;
|
||||
private Button buttonAdd;
|
||||
}
|
||||
}
|
116
TransportCompany/TransportCompanyView/FormPoints.cs
Normal file
116
TransportCompany/TransportCompanyView/FormPoints.cs
Normal file
@ -0,0 +1,116 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace TransportCompanyView
|
||||
{
|
||||
public partial class FormPoints : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IPointLogic _logic;
|
||||
|
||||
public FormPoints(ILogger<FormPoints> logger, IPointLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormDrivers_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;
|
||||
var halfWidth = dataGridView.Width / 2;
|
||||
dataGridView.Columns["PointName"].Width = halfWidth;
|
||||
dataGridView.Columns["Address"].Width = halfWidth;
|
||||
}
|
||||
_logger.LogInformation("Загрузка пунктов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки пунктов");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormPoint));
|
||||
if (service is FormPoint form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormPoint));
|
||||
if (service is FormPoint form)
|
||||
{
|
||||
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Удаление пункта");
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new PointBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления пункта");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonRef_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
120
TransportCompany/TransportCompanyView/FormPoints.resx
Normal file
120
TransportCompany/TransportCompanyView/FormPoints.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
140
TransportCompany/TransportCompanyView/FormTransport.Designer.cs
generated
Normal file
140
TransportCompany/TransportCompanyView/FormTransport.Designer.cs
generated
Normal file
@ -0,0 +1,140 @@
|
||||
namespace TransportCompanyView
|
||||
{
|
||||
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()
|
||||
{
|
||||
labelName = new Label();
|
||||
textBoxName = new TextBox();
|
||||
textBoxStateNumber = new TextBox();
|
||||
labelAddress = new Label();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
textBoxLoadCapacity = new TextBox();
|
||||
labelLoadCapacity = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// labelName
|
||||
//
|
||||
labelName.AutoSize = true;
|
||||
labelName.Location = new Point(11, 9);
|
||||
labelName.Name = "labelName";
|
||||
labelName.Size = new Size(80, 20);
|
||||
labelName.TabIndex = 0;
|
||||
labelName.Text = "Название:";
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(117, 9);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(347, 27);
|
||||
textBoxName.TabIndex = 1;
|
||||
//
|
||||
// textBoxStateNumber
|
||||
//
|
||||
textBoxStateNumber.Location = new Point(117, 75);
|
||||
textBoxStateNumber.Name = "textBoxStateNumber";
|
||||
textBoxStateNumber.Size = new Size(347, 27);
|
||||
textBoxStateNumber.TabIndex = 3;
|
||||
//
|
||||
// labelAddress
|
||||
//
|
||||
labelAddress.AutoSize = true;
|
||||
labelAddress.Location = new Point(11, 75);
|
||||
labelAddress.Name = "labelAddress";
|
||||
labelAddress.Size = new Size(85, 20);
|
||||
labelAddress.TabIndex = 2;
|
||||
labelAddress.Text = "Гос. номер";
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(172, 118);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(130, 40);
|
||||
buttonSave.TabIndex = 4;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += ButtonSave_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(328, 118);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(136, 40);
|
||||
buttonCancel.TabIndex = 5;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += ButtonCancel_Click;
|
||||
//
|
||||
// textBoxLoadCapacity
|
||||
//
|
||||
textBoxLoadCapacity.Location = new Point(117, 42);
|
||||
textBoxLoadCapacity.Name = "textBoxLoadCapacity";
|
||||
textBoxLoadCapacity.Size = new Size(101, 27);
|
||||
textBoxLoadCapacity.TabIndex = 7;
|
||||
//
|
||||
// labelLoadCapacity
|
||||
//
|
||||
labelLoadCapacity.AutoSize = true;
|
||||
labelLoadCapacity.Location = new Point(11, 42);
|
||||
labelLoadCapacity.Name = "labelLoadCapacity";
|
||||
labelLoadCapacity.Size = new Size(100, 20);
|
||||
labelLoadCapacity.TabIndex = 6;
|
||||
labelLoadCapacity.Text = "Вместимость";
|
||||
//
|
||||
// FormTransport
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(478, 170);
|
||||
Controls.Add(textBoxLoadCapacity);
|
||||
Controls.Add(labelLoadCapacity);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(textBoxStateNumber);
|
||||
Controls.Add(labelAddress);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(labelName);
|
||||
Name = "FormTransport";
|
||||
Text = "Машина";
|
||||
Load += FormTransport_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label labelName;
|
||||
private TextBox textBoxName;
|
||||
private TextBox textBoxStateNumber;
|
||||
private Label labelAddress;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private TextBox textBoxLoadCapacity;
|
||||
private Label labelLoadCapacity;
|
||||
}
|
||||
}
|
106
TransportCompany/TransportCompanyView/FormTransport.cs
Normal file
106
TransportCompany/TransportCompanyView/FormTransport.cs
Normal file
@ -0,0 +1,106 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
using TransportCompanyContracts.SearchModels;
|
||||
|
||||
namespace TransportCompanyView
|
||||
{
|
||||
public partial class FormTransport : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ITransportLogic _logic;
|
||||
private int? _id;
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormTransport(ILogger<FormTransport> logger, ITransportLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void FormTransport_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
try
|
||||
{
|
||||
_logger.LogInformation("Получение пункта");
|
||||
var view = _logic.ReadElement(new TransportSearchModel
|
||||
{
|
||||
Id = _id.Value
|
||||
});
|
||||
if (view != null)
|
||||
{
|
||||
textBoxName.Text = view.Model;
|
||||
textBoxLoadCapacity.Text = view.LoadCapacity.ToString();
|
||||
textBoxStateNumber.Text = view.StateNumber;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(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;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxLoadCapacity.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните вместимость", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxStateNumber.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните автомобильный номер", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Сохранение пункта");
|
||||
try
|
||||
{
|
||||
var model = new TransportBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
Model = textBoxName.Text,
|
||||
LoadCapacity = Convert.ToInt32(textBoxLoadCapacity.Text),
|
||||
StateNumber = textBoxStateNumber.Text
|
||||
};
|
||||
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка сохранения транспорта");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
TransportCompany/TransportCompanyView/FormTransport.resx
Normal file
120
TransportCompany/TransportCompanyView/FormTransport.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
137
TransportCompany/TransportCompanyView/FormTransports.Designer.cs
generated
Normal file
137
TransportCompany/TransportCompanyView/FormTransports.Designer.cs
generated
Normal file
@ -0,0 +1,137 @@
|
||||
namespace TransportCompanyView
|
||||
{
|
||||
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()
|
||||
{
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.ToolsPanel = new System.Windows.Forms.Panel();
|
||||
this.buttonUpdate = new System.Windows.Forms.Button();
|
||||
this.buttonDelete = new System.Windows.Forms.Button();
|
||||
this.buttonEdit = new System.Windows.Forms.Button();
|
||||
this.buttonAdd = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.ToolsPanel.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
this.dataGridView.AllowUserToAddRows = false;
|
||||
this.dataGridView.AllowUserToDeleteRows = false;
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Location = new System.Drawing.Point(10, 9);
|
||||
this.dataGridView.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.ReadOnly = true;
|
||||
this.dataGridView.RowHeadersWidth = 51;
|
||||
this.dataGridView.RowTemplate.Height = 29;
|
||||
this.dataGridView.Size = new System.Drawing.Size(516, 320);
|
||||
this.dataGridView.TabIndex = 0;
|
||||
//
|
||||
// ToolsPanel
|
||||
//
|
||||
this.ToolsPanel.Controls.Add(this.buttonUpdate);
|
||||
this.ToolsPanel.Controls.Add(this.buttonDelete);
|
||||
this.ToolsPanel.Controls.Add(this.buttonEdit);
|
||||
this.ToolsPanel.Controls.Add(this.buttonAdd);
|
||||
this.ToolsPanel.Location = new System.Drawing.Point(532, 9);
|
||||
this.ToolsPanel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.ToolsPanel.Name = "ToolsPanel";
|
||||
this.ToolsPanel.Size = new System.Drawing.Size(158, 320);
|
||||
this.ToolsPanel.TabIndex = 1;
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
this.buttonUpdate.Location = new System.Drawing.Point(27, 154);
|
||||
this.buttonUpdate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonUpdate.Name = "buttonUpdate";
|
||||
this.buttonUpdate.Size = new System.Drawing.Size(110, 27);
|
||||
this.buttonUpdate.TabIndex = 3;
|
||||
this.buttonUpdate.Text = "Обновить";
|
||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
||||
this.buttonUpdate.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
this.buttonDelete.Location = new System.Drawing.Point(27, 106);
|
||||
this.buttonDelete.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonDelete.Name = "buttonDelete";
|
||||
this.buttonDelete.Size = new System.Drawing.Size(110, 27);
|
||||
this.buttonDelete.TabIndex = 2;
|
||||
this.buttonDelete.Text = "Удалить";
|
||||
this.buttonDelete.UseVisualStyleBackColor = true;
|
||||
this.buttonDelete.Click += new System.EventHandler(this.ButtonDel_Click);
|
||||
//
|
||||
// buttonEdit
|
||||
//
|
||||
this.buttonEdit.Location = new System.Drawing.Point(27, 57);
|
||||
this.buttonEdit.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonEdit.Name = "buttonEdit";
|
||||
this.buttonEdit.Size = new System.Drawing.Size(110, 27);
|
||||
this.buttonEdit.TabIndex = 1;
|
||||
this.buttonEdit.Text = "Изменить";
|
||||
this.buttonEdit.UseVisualStyleBackColor = true;
|
||||
this.buttonEdit.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
this.buttonAdd.Location = new System.Drawing.Point(27, 12);
|
||||
this.buttonAdd.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.buttonAdd.Name = "buttonAdd";
|
||||
this.buttonAdd.Size = new System.Drawing.Size(110, 27);
|
||||
this.buttonAdd.TabIndex = 0;
|
||||
this.buttonAdd.Text = "Добавить";
|
||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||
//
|
||||
// FormComponents
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(700, 338);
|
||||
this.Controls.Add(this.ToolsPanel);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
|
||||
this.Name = "FormTransports";
|
||||
this.Text = "Машины";
|
||||
this.Load += new System.EventHandler(this.FormTransports_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.ToolsPanel.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Panel ToolsPanel;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonDelete;
|
||||
private Button buttonEdit;
|
||||
private Button buttonAdd;
|
||||
}
|
||||
}
|
117
TransportCompany/TransportCompanyView/FormTransports.cs
Normal file
117
TransportCompany/TransportCompanyView/FormTransports.cs
Normal file
@ -0,0 +1,117 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using TransportCompanyContracts.BindingModels;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
|
||||
namespace TransportCompanyView
|
||||
{
|
||||
public partial class FormTransports : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly ITransportLogic _logic;
|
||||
|
||||
public FormTransports(ILogger<FormTransports> logger, ITransportLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_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;
|
||||
var halfWidth = dataGridView.Width / 3;
|
||||
dataGridView.Columns["Model"].Width = halfWidth;
|
||||
dataGridView.Columns["LoadCapacity"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["StateNumber"].Width = halfWidth;
|
||||
}
|
||||
_logger.LogInformation("Загрузка машин");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки машин");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormTransport));
|
||||
if (service is FormTransport form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormTransport));
|
||||
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);
|
||||
_logger.LogInformation("Удаление машины");
|
||||
try
|
||||
{
|
||||
if (!_logic.Delete(new TransportBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления машины");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonRef_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
120
TransportCompany/TransportCompanyView/FormTransports.resx
Normal file
120
TransportCompany/TransportCompanyView/FormTransports.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -1,7 +1,18 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NLog.Extensions.Logging;
|
||||
using TransportCompanyBusinessLogic.BusinessLogics;
|
||||
using TransportCompanyContracts.BusinessLogicsContracts;
|
||||
using TransportCompanyContracts.StoragesContracts;
|
||||
using TransportCompanyDatabaseImplement.Implements;
|
||||
using TransportCompanyView;
|
||||
|
||||
namespace TransportCompanyView
|
||||
{
|
||||
internal static class Program
|
||||
{
|
||||
private static ServiceProvider? _serviceProvider;
|
||||
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
@ -11,7 +22,41 @@ namespace TransportCompanyView
|
||||
// To customize application configuration such as set high DPI settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
Application.Run(new Form1());
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||
}
|
||||
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
services.AddLogging(option =>
|
||||
{
|
||||
option.SetMinimumLevel(LogLevel.Information);
|
||||
option.AddNLog("nlog.config");
|
||||
});
|
||||
|
||||
services.AddTransient<ICargoStorage, CargoStorage>();
|
||||
services.AddTransient<IDriverStorage, DriverStorage>();
|
||||
services.AddTransient<IPointStorage, PointStorage>();
|
||||
services.AddTransient<ITransportationStorage, TransportationStorage>();
|
||||
services.AddTransient<ITransportStorage, TransportStorage>();
|
||||
services.AddTransient<ICargoLogic, CargoLogic>();
|
||||
services.AddTransient<IDriverLogic, DriverLogic>();
|
||||
services.AddTransient<IPointLogic, PointLogic>();
|
||||
services.AddTransient<ITransportationLogic, TransportationLogic>();
|
||||
services.AddTransient<ITransportLogic, TransportLogic>();
|
||||
services.AddTransient<FormCargo>();
|
||||
services.AddTransient<FormCargos>();
|
||||
services.AddTransient<FormDriver>();
|
||||
services.AddTransient<FormDrivers>();
|
||||
services.AddTransient<FormPoint>();
|
||||
services.AddTransient<FormPoints>();
|
||||
services.AddTransient<FormTransport>();
|
||||
services.AddTransient<FormTransports>();
|
||||
services.AddTransient<FormCreateTransportation>();
|
||||
services.AddTransient<FormMain>();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -8,4 +8,32 @@
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="nlog.config" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="nlog.config">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.3">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="8.0.0" />
|
||||
<PackageReference Include="NLog.Extensions.Logging" Version="5.3.8" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\TransportCompanyBusinessLogic\TransportCompanyBusinessLogic.csproj" />
|
||||
<ProjectReference Include="..\TransportCompanyContracts\TransportCompanyContracts.csproj" />
|
||||
<ProjectReference Include="..\TransportCompanyDatabaseImplement\TransportCompanyDatabaseImplement.csproj" />
|
||||
<ProjectReference Include="..\TransportCompanyListImplement\TransportCompanyListImplement.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
15
TransportCompany/TransportCompanyView/nlog.config
Normal file
15
TransportCompany/TransportCompanyView/nlog.config
Normal file
@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
autoReload="true" internalLogLevel="Info">
|
||||
|
||||
<targets>
|
||||
<target xsi:type="File" name="tofile" fileName="log-${shortdate}.log" />
|
||||
</targets>
|
||||
|
||||
<rules>
|
||||
<logger name="*" minlevel="Debug" writeTo="tofile" />
|
||||
</rules>
|
||||
</nlog>
|
||||
</configuration>
|
Loading…
Reference in New Issue
Block a user