рабочее десктопное приложение, добавление клиента везде

This commit is contained in:
ValAnn 2024-04-08 13:43:32 +04:00
parent 64ba14b302
commit e4b8afb8da
29 changed files with 1011 additions and 226 deletions

View File

@ -12,6 +12,7 @@ namespace SushiBarContracts.BindingModels
{ {
public int Id { get; set; } public int Id { get; set; }
public int SushiId { get; set; } public int SushiId { get; set; }
public int ClientId { get; set; }
public int Count { get; set; } public int Count { get; set; }
public double Sum { get; set; } public double Sum { get; set; }
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;

View File

@ -9,6 +9,7 @@ namespace SushiBarContracts.SearchModels
public class OrderSearchModel public class OrderSearchModel
{ {
public int? Id { get; set; } public int? Id { get; set; }
public int? ClientId { get; set; }
public DateTime? DateFrom { get; set; } public DateTime? DateFrom { get; set; }
public DateTime? DateTo { get; set; } public DateTime? DateTo { get; set; }
} }

View File

@ -15,7 +15,11 @@ namespace SushiBarContracts.ViewModels
public int Id { get; set; } public int Id { get; set; }
public int SushiId { get; set; } public int SushiId { get; set; }
public int ClientId { get; set; }
[DisplayName("ФИО клиента")]
public string ClientFIO { get; set; } = string.Empty;
[DisplayName("Изделие")] [DisplayName("Изделие")]
public string SushiName { get; set; } = string.Empty; public string SushiName { get; set; } = string.Empty;

View File

@ -10,6 +10,7 @@ namespace SushiBarDataModels.Models
public interface IOrderModel : IId public interface IOrderModel : IId
{ {
int SushiId { get; } int SushiId { get; }
int ClientId { get; }
int Count { get; } int Count { get; }
double Sum { get; } double Sum { get; }
OrderStatus Status { get; } OrderStatus Status { get; }

View File

@ -0,0 +1,86 @@
using SushiBar.BindingModels;
using SushiBar.SearchModels;
using SushiBar.StoragesContracts;
using SushiBar.ViewModels;
using SushiBarDatabaseImplement.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SushiBarDatabaseImplement.Implements
{
public class ClientStorage : IClientStorage
{
public List<ClientViewModel> GetFullList()
{
using var context = new SushiBarDatabase();
return context.Clients.Select(x => x.GetViewModel).ToList();
}
public List<ClientViewModel> GetFilteredList(ClientSearchModel model)
{
if (string.IsNullOrEmpty(model.ClientFIO))
{
return new();
}
using var context = new SushiBarDatabase();
return context.Clients.Where(x => x.ClientFIO.Contains(model.ClientFIO)).Select(x => x.GetViewModel).ToList();
}
public ClientViewModel? GetElement(ClientSearchModel model)
{
if (string.IsNullOrEmpty(model.Email) && string.IsNullOrEmpty(model.Password) && !model.Id.HasValue)
{
return null;
}
using var context = new SushiBarDatabase();
return context.Clients.FirstOrDefault(x =>
(!string.IsNullOrEmpty(model.Email) && x.Email == model.Email && !string.IsNullOrEmpty(model.Password) && x.Password == model.Password) ||
(model.Id.HasValue && x.Id == model.Id))
?.GetViewModel;
}
public ClientViewModel? Insert(ClientBindingModel model)
{
var newComponent = Client.Create(model);
if (newComponent == null)
{
return null;
}
using var context = new SushiBarDatabase();
context.Clients.Add(newComponent);
context.SaveChanges();
return newComponent.GetViewModel;
}
public ClientViewModel? Update(ClientBindingModel model)
{
using var context = new SushiBarDatabase();
var component = context.Clients.FirstOrDefault(x => x.Id == model.Id);
if (component == null)
{
return null;
}
component.Update(model);
context.SaveChanges();
return component.GetViewModel;
}
public ClientViewModel? Delete(ClientBindingModel model)
{
using var context = new SushiBarDatabase();
var element = context.Clients.FirstOrDefault(rec => rec.Id == model.Id);
if (element != null)
{
context.Clients.Remove(element);
context.SaveChanges();
return element.GetViewModel;
}
return null;
}
}
}

View File

@ -17,7 +17,7 @@ namespace SushiBarDatabaseImplement.Implements
public List<OrderViewModel> GetFullList() public List<OrderViewModel> GetFullList()
{ {
using var context = new SushiBarDatabase(); using var context = new SushiBarDatabase();
return context.Orders.Include(x => x.Sushi).Select(x => x.GetViewModel).ToList(); return context.Orders.Include(x => x.Sushi).Include(x => x.Client).Select(x => x.GetViewModel).ToList();
} }
public List<OrderViewModel> GetFilteredList(OrderSearchModel model) public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
@ -31,6 +31,10 @@ namespace SushiBarDatabaseImplement.Implements
{ {
return context.Orders.Include(x => x.Sushi).Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo).Select(x => x.GetViewModel).ToList(); return context.Orders.Include(x => x.Sushi).Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo).Select(x => x.GetViewModel).ToList();
} }
if (model.ClientId.HasValue)
{
return context.Orders.Include(x => x.Sushi).Where(x => x.ClientId == model.ClientId).Select(x => x.GetViewModel).ToList();
}
return context.Orders.Include(x => x.Sushi).Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList(); return context.Orders.Include(x => x.Sushi).Where(x => x.Id == model.Id).Select(x => x.GetViewModel).ToList();
} }

View File

@ -12,7 +12,7 @@ using SushiBarDatabaseImplement;
namespace SushiBarDatabaseImplement.Migrations namespace SushiBarDatabaseImplement.Migrations
{ {
[DbContext(typeof(SushiBarDatabase))] [DbContext(typeof(SushiBarDatabase))]
[Migration("20240313082356_InitialCreate")] [Migration("20240408093304_InitialCreate")]
partial class InitialCreate partial class InitialCreate
{ {
/// <inheritdoc /> /// <inheritdoc />
@ -25,6 +25,31 @@ namespace SushiBarDatabaseImplement.Migrations
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClientFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Component", b => modelBuilder.Entity("SushiBarDatabaseImplement.Models.Component", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@ -53,6 +78,9 @@ namespace SushiBarDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<int>("Count") b.Property<int>("Count")
.HasColumnType("int"); .HasColumnType("int");
@ -73,6 +101,8 @@ namespace SushiBarDatabaseImplement.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("ClientId");
b.HasIndex("SushiId"); b.HasIndex("SushiId");
b.ToTable("Orders"); b.ToTable("Orders");
@ -126,12 +156,20 @@ namespace SushiBarDatabaseImplement.Migrations
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Order", b => modelBuilder.Entity("SushiBarDatabaseImplement.Models.Order", b =>
{ {
b.HasOne("SushiBarDatabaseImplement.Models.Client", "Client")
.WithMany("Orders")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SushiBarDatabaseImplement.Models.Sushi", "Sushi") b.HasOne("SushiBarDatabaseImplement.Models.Sushi", "Sushi")
.WithMany("Orders") .WithMany("Orders")
.HasForeignKey("SushiId") .HasForeignKey("SushiId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("Client");
b.Navigation("Sushi"); b.Navigation("Sushi");
}); });
@ -154,6 +192,11 @@ namespace SushiBarDatabaseImplement.Migrations
b.Navigation("Sushi"); b.Navigation("Sushi");
}); });
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Client", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Component", b => modelBuilder.Entity("SushiBarDatabaseImplement.Models.Component", b =>
{ {
b.Navigation("SushiComponents"); b.Navigation("SushiComponents");

View File

@ -11,6 +11,21 @@ namespace SushiBarDatabaseImplement.Migrations
/// <inheritdoc /> /// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder) protected override void Up(MigrationBuilder migrationBuilder)
{ {
migrationBuilder.CreateTable(
name: "Clients",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ClientFIO = table.Column<string>(type: "nvarchar(max)", nullable: false),
Email = table.Column<string>(type: "nvarchar(max)", nullable: false),
Password = table.Column<string>(type: "nvarchar(max)", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Clients", x => x.Id);
});
migrationBuilder.CreateTable( migrationBuilder.CreateTable(
name: "Components", name: "Components",
columns: table => new columns: table => new
@ -45,6 +60,7 @@ namespace SushiBarDatabaseImplement.Migrations
{ {
Id = table.Column<int>(type: "int", nullable: false) Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"), .Annotation("SqlServer:Identity", "1, 1"),
ClientId = table.Column<int>(type: "int", nullable: false),
SushiId = table.Column<int>(type: "int", nullable: false), SushiId = table.Column<int>(type: "int", nullable: false),
Count = table.Column<int>(type: "int", nullable: false), Count = table.Column<int>(type: "int", nullable: false),
Sum = table.Column<double>(type: "float", nullable: false), Sum = table.Column<double>(type: "float", nullable: false),
@ -55,6 +71,12 @@ namespace SushiBarDatabaseImplement.Migrations
constraints: table => constraints: table =>
{ {
table.PrimaryKey("PK_Orders", x => x.Id); table.PrimaryKey("PK_Orders", x => x.Id);
table.ForeignKey(
name: "FK_Orders_Clients_ClientId",
column: x => x.ClientId,
principalTable: "Clients",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey( table.ForeignKey(
name: "FK_Orders_Sushis_SushiId", name: "FK_Orders_Sushis_SushiId",
column: x => x.SushiId, column: x => x.SushiId,
@ -90,6 +112,11 @@ namespace SushiBarDatabaseImplement.Migrations
onDelete: ReferentialAction.Cascade); onDelete: ReferentialAction.Cascade);
}); });
migrationBuilder.CreateIndex(
name: "IX_Orders_ClientId",
table: "Orders",
column: "ClientId");
migrationBuilder.CreateIndex( migrationBuilder.CreateIndex(
name: "IX_Orders_SushiId", name: "IX_Orders_SushiId",
table: "Orders", table: "Orders",
@ -115,6 +142,9 @@ namespace SushiBarDatabaseImplement.Migrations
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "SushiComponents"); name: "SushiComponents");
migrationBuilder.DropTable(
name: "Clients");
migrationBuilder.DropTable( migrationBuilder.DropTable(
name: "Components"); name: "Components");

View File

@ -22,6 +22,31 @@ namespace SushiBarDatabaseImplement.Migrations
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Client", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<string>("ClientFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Clients");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Component", b => modelBuilder.Entity("SushiBarDatabaseImplement.Models.Component", b =>
{ {
b.Property<int>("Id") b.Property<int>("Id")
@ -50,6 +75,9 @@ namespace SushiBarDatabaseImplement.Migrations
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id")); SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
b.Property<int>("ClientId")
.HasColumnType("int");
b.Property<int>("Count") b.Property<int>("Count")
.HasColumnType("int"); .HasColumnType("int");
@ -70,6 +98,8 @@ namespace SushiBarDatabaseImplement.Migrations
b.HasKey("Id"); b.HasKey("Id");
b.HasIndex("ClientId");
b.HasIndex("SushiId"); b.HasIndex("SushiId");
b.ToTable("Orders"); b.ToTable("Orders");
@ -123,12 +153,20 @@ namespace SushiBarDatabaseImplement.Migrations
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Order", b => modelBuilder.Entity("SushiBarDatabaseImplement.Models.Order", b =>
{ {
b.HasOne("SushiBarDatabaseImplement.Models.Client", "Client")
.WithMany("Orders")
.HasForeignKey("ClientId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("SushiBarDatabaseImplement.Models.Sushi", "Sushi") b.HasOne("SushiBarDatabaseImplement.Models.Sushi", "Sushi")
.WithMany("Orders") .WithMany("Orders")
.HasForeignKey("SushiId") .HasForeignKey("SushiId")
.OnDelete(DeleteBehavior.Cascade) .OnDelete(DeleteBehavior.Cascade)
.IsRequired(); .IsRequired();
b.Navigation("Client");
b.Navigation("Sushi"); b.Navigation("Sushi");
}); });
@ -151,6 +189,11 @@ namespace SushiBarDatabaseImplement.Migrations
b.Navigation("Sushi"); b.Navigation("Sushi");
}); });
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Client", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("SushiBarDatabaseImplement.Models.Component", b => modelBuilder.Entity("SushiBarDatabaseImplement.Models.Component", b =>
{ {
b.Navigation("SushiComponents"); b.Navigation("SushiComponents");

View File

@ -12,7 +12,7 @@ using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace PizzeriaDatabaseImplement.Models namespace SushiBarDatabaseImplement.Models
{ {
public class Client : IClientModel public class Client : IClientModel
{ {

View File

@ -15,6 +15,9 @@ namespace SushiBarDatabaseImplement.Models
{ {
public int Id { get; private set; } public int Id { get; private set; }
[Required]
public int ClientId { get; private set; }
public virtual Client Client { get; private set; } = new();
[Required] [Required]
public int SushiId { get; private set; } public int SushiId { get; private set; }
@ -39,6 +42,8 @@ namespace SushiBarDatabaseImplement.Models
return new Order() return new Order()
{ {
Id = model.Id, Id = model.Id,
ClientId = model.ClientId,
Client = context.Clients.First(x => x.Id == model.ClientId),
SushiId = model.SushiId, SushiId = model.SushiId,
Sushi = context.Sushis.First(x => x.Id == model.SushiId), Sushi = context.Sushis.First(x => x.Id == model.SushiId),
Count = model.Count, Count = model.Count,

View File

@ -22,5 +22,6 @@ namespace SushiBarDatabaseImplement
public virtual DbSet<Sushi> Sushis { set; get; } public virtual DbSet<Sushi> Sushis { set; get; }
public virtual DbSet<SushiComponent> SushiComponents { set; get; } public virtual DbSet<SushiComponent> SushiComponents { set; get; }
public virtual DbSet<Order> Orders { set; get; } public virtual DbSet<Order> Orders { set; get; }
public virtual DbSet<Client> Clients { set; get; }
} }
} }

View File

@ -1,4 +1,5 @@
using SushiBarFileImplement.Models; using PizzeriaFileImplement.Models;
using SushiBarFileImplement.Models;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -14,9 +15,11 @@ namespace SushiBarFileImplement
private readonly string ComponentFileName = "Component.xml"; private readonly string ComponentFileName = "Component.xml";
private readonly string OrderFileName = "Order.xml"; private readonly string OrderFileName = "Order.xml";
private readonly string SushiFileName = "Sushi.xml"; private readonly string SushiFileName = "Sushi.xml";
private readonly string ClientFileName = "Client.xml";
public List<Component> Components { get; private set; } public List<Component> Components { get; private set; }
public List<Order> Orders { get; private set; } public List<Order> Orders { get; private set; }
public List<Sushi> Sushis { get; private set; } public List<Sushi> Sushis { get; private set; }
public List<Client> Clients { get; private set; }
public static DataFileSingleton GetInstance() public static DataFileSingleton GetInstance()
{ {
@ -30,12 +33,14 @@ namespace SushiBarFileImplement
public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement); public void SaveComponents() => SaveData(Components, ComponentFileName, "Components", x => x.GetXElement);
public void SaveSushis() => SaveData(Sushis, SushiFileName, "Sushis", x => x.GetXElement); public void SaveSushis() => SaveData(Sushis, SushiFileName, "Sushis", x => x.GetXElement);
public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement); public void SaveOrders() => SaveData(Orders, OrderFileName, "Orders", x => x.GetXElement);
public void SaveClients() => SaveData(Clients, ClientFileName, "Clients", x => x.GetXElement);
private DataFileSingleton() private DataFileSingleton()
{ {
Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!; Components = LoadData(ComponentFileName, "Component", x => Component.Create(x)!)!;
Sushis = LoadData(SushiFileName, "Sushi", x => Sushi.Create(x)!)!; Sushis = LoadData(SushiFileName, "Sushi", x => Sushi.Create(x)!)!;
Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!; Orders = LoadData(OrderFileName, "Order", x => Order.Create(x)!)!;
Clients = LoadData(ClientFileName, "Client", x => Client.Create(x)!)!;
} }
private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction) private static List<T>? LoadData<T>(string filename, string xmlNodeName, Func<XElement, T> selectFunction)

View File

@ -24,11 +24,21 @@ namespace SushiBarFileImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model) public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{ {
if (!model.DateFrom.HasValue || !model.DateTo.HasValue) if (model.DateFrom.HasValue)
{ {
return new(); return source.Orders.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo)
.Select(x => GetViewModel(x)).ToList();
} }
return source.Orders.Where(x => x.DateCreate >= model.DateFrom && x.DateCreate <= model.DateTo).Select(x => AttachSushiName(x.GetViewModel)).ToList(); if (model.ClientId.HasValue && !model.Id.HasValue)
{
return source.Orders.Where(x => x.ClientId == model.ClientId).Select(x => x.GetViewModel).ToList();
}
if (model.Id.HasValue)
{
return source.Orders.Where(x => x.Id.Equals(model.Id)).Select(x => GetViewModel(x)).ToList();
}
return new();
} }
public OrderViewModel? GetElement(OrderSearchModel model) public OrderViewModel? GetElement(OrderSearchModel model)
@ -90,5 +100,23 @@ namespace SushiBarFileImplement.Implements
} }
return model; return model;
} }
private OrderViewModel GetViewModel(Order order)
{
var viewModel = order.GetViewModel;
var pizza = source.Sushis.FirstOrDefault(x => x.Id == order.SushiId);
var client = source.Clients.FirstOrDefault(x => x.Id == order.ClientId);
if (pizza != null)
{
viewModel.SushiName = pizza.SushiName;
}
if (client != null)
{
viewModel.ClientFIO = client.ClientFIO;
}
return viewModel;
}
} }
} }

View File

@ -14,6 +14,7 @@ namespace SushiBarFileImplement.Models
internal class Order : IOrderModel internal class Order : IOrderModel
{ {
public int Id { get; private set; } public int Id { get; private set; }
public int ClientId { get; private set; }
public int SushiId { get; private set; } public int SushiId { get; private set; }
public int Count { get; private set; } public int Count { get; private set; }
public double Sum { get; private set; } public double Sum { get; private set; }
@ -31,6 +32,7 @@ namespace SushiBarFileImplement.Models
{ {
Id = model.Id, Id = model.Id,
SushiId = model.SushiId, SushiId = model.SushiId,
ClientId = model.ClientId,
Count = model.Count, Count = model.Count,
Sum = model.Sum, Sum = model.Sum,
Status = model.Status, Status = model.Status,
@ -50,6 +52,7 @@ namespace SushiBarFileImplement.Models
{ {
Id = Convert.ToInt32(element.Attribute("Id")!.Value), Id = Convert.ToInt32(element.Attribute("Id")!.Value),
SushiId = Convert.ToInt32(element.Element("SushiId")!.Value), SushiId = Convert.ToInt32(element.Element("SushiId")!.Value),
ClientId = Convert.ToInt32(element.Element("ClientId")!.Value),
Count = Convert.ToInt32(element.Element("Count")!.Value), Count = Convert.ToInt32(element.Element("Count")!.Value),
Sum = Convert.ToDouble(element.Element("Sum")!.Value), Sum = Convert.ToDouble(element.Element("Sum")!.Value),
Status = (OrderStatus)(Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value)), Status = (OrderStatus)(Enum.Parse(typeof(OrderStatus), element.Element("Status")!.Value)),
@ -73,6 +76,7 @@ namespace SushiBarFileImplement.Models
{ {
Id = Id, Id = Id,
SushiId = SushiId, SushiId = SushiId,
ClientId = ClientId,
Count = Count, Count = Count,
Sum = Sum, Sum = Sum,
Status = Status, Status = Status,
@ -83,6 +87,7 @@ namespace SushiBarFileImplement.Models
public XElement GetXElement => new("Order", public XElement GetXElement => new("Order",
new XAttribute("Id", Id), new XAttribute("Id", Id),
new XElement("SushiId", SushiId.ToString()), new XElement("SushiId", SushiId.ToString()),
new XElement("ClientId", ClientId.ToString()),
new XElement("Count", Count.ToString()), new XElement("Count", Count.ToString()),
new XElement("Sum", Sum.ToString()), new XElement("Sum", Sum.ToString()),
new XElement("Status", Status.ToString()), new XElement("Status", Status.ToString()),

View File

@ -13,11 +13,13 @@ namespace SushiBarListImplement
public List<Component> Components { get; set; } public List<Component> Components { get; set; }
public List<Order> Orders { get; set; } public List<Order> Orders { get; set; }
public List<Sushi> Sushis { get; set; } public List<Sushi> Sushis { get; set; }
public List<Client> Clients { get; set; }
private DataListSingleton() private DataListSingleton()
{ {
Components = new List<Component>(); Components = new List<Component>();
Orders = new List<Order>(); Orders = new List<Order>();
Sushis = new List<Sushi>(); Sushis = new List<Sushi>();
Clients = new List<Client>();
} }
public static DataListSingleton GetInstance() public static DataListSingleton GetInstance()
{ {

View File

@ -33,18 +33,37 @@ namespace SushiBarListImplement.Implements
public List<OrderViewModel> GetFilteredList(OrderSearchModel model) public List<OrderViewModel> GetFilteredList(OrderSearchModel model)
{ {
var result = new List<OrderViewModel>(); var result = new List<OrderViewModel>();
if (model == null || !model.DateFrom.HasValue || !model.DateFrom.HasValue) if (model.DateFrom.HasValue)
{ {
return result;
}
foreach (var order in _source.Orders) foreach (var order in _source.Orders)
{ {
if (order.DateCreate >= model.DateFrom && order.DateCreate <= model.DateTo) if (order.DateCreate >= model.DateFrom && order.DateCreate <= model.DateTo)
{ {
result.Add(AttachSushiName(order.GetViewModel)); result.Add(GetViewModel(order));
} }
} }
}
else if (model.ClientId.HasValue && !model.Id.HasValue)
{
foreach (var order in _source.Orders)
{
if (order.ClientId == model.ClientId)
{
result.Add(GetViewModel(order));
}
}
}
else if (model.Id.HasValue)
{
foreach (var order in _source.Orders)
{
if (order.Id == model.Id)
{
result.Add(GetViewModel(order));
}
}
}
return result; return result;
} }
@ -122,5 +141,27 @@ namespace SushiBarListImplement.Implements
} }
return model; return model;
} }
private OrderViewModel GetViewModel(Order order)
{
var viewModel = order.GetViewModel;
foreach (var package in _source.Sushis)
{
if (package.Id == order.SushiId)
{
viewModel.SushiName = package.SushiName;
break;
}
}
foreach (var client in _source.Clients)
{
if (client.Id == order.ClientId)
{
viewModel.ClientFIO = client.ClientFIO;
break;
}
}
return viewModel;
}
} }
} }

View File

@ -4,7 +4,7 @@ using SushiBarContracts.BindingModels;
using SushiBarContracts.ViewModels; using SushiBarContracts.ViewModels;
using SushiBarDataModels.Models; using SushiBarDataModels.Models;
namespace PizzeriaListImplement.Models namespace SushiBarListImplement.Models
{ {
public class Client : IClientModel public class Client : IClientModel
{ {

View File

@ -14,6 +14,7 @@ namespace SushiBarListImplement.Models
{ {
public int Id { get; private set; } public int Id { get; private set; }
public int SushiId { get; private set; } public int SushiId { get; private set; }
public int ClientId { get; private set; }
public int Count { get; private set; } public int Count { get; private set; }
public double Sum { get; private set; } public double Sum { get; private set; }
public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен; public OrderStatus Status { get; private set; } = OrderStatus.Неизвестен;
@ -30,6 +31,7 @@ namespace SushiBarListImplement.Models
{ {
Id = model.Id, Id = model.Id,
SushiId = model.SushiId, SushiId = model.SushiId,
ClientId = model.ClientId,
Count = model.Count, Count = model.Count,
Sum = model.Sum, Sum = model.Sum,
Status = model.Status, Status = model.Status,
@ -52,6 +54,7 @@ namespace SushiBarListImplement.Models
{ {
Id = Id, Id = Id,
SushiId = SushiId, SushiId = SushiId,
ClientId = ClientId,
Count = Count, Count = Count,
Sum = Sum, Sum = Sum,
Status = Status, Status = Status,

View File

@ -0,0 +1,95 @@

namespace SushiBarView
{
partial class FormClients
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.dataGridView = new System.Windows.Forms.DataGridView();
this.buttonDel = new System.Windows.Forms.Button();
this.buttonRef = new System.Windows.Forms.Button();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
this.SuspendLayout();
//
// dataGridView
//
this.dataGridView.AllowUserToAddRows = false;
this.dataGridView.AllowUserToDeleteRows = false;
this.dataGridView.BackgroundColor = System.Drawing.SystemColors.ControlLightLight;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Dock = System.Windows.Forms.DockStyle.Left;
this.dataGridView.Location = new System.Drawing.Point(0, 0);
this.dataGridView.Name = "dataGridView";
this.dataGridView.ReadOnly = true;
this.dataGridView.RowHeadersVisible = false;
this.dataGridView.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dataGridView.Size = new System.Drawing.Size(350, 312);
this.dataGridView.TabIndex = 0;
//
// buttonDel
//
this.buttonDel.Location = new System.Drawing.Point(368, 12);
this.buttonDel.Name = "buttonDel";
this.buttonDel.Size = new System.Drawing.Size(75, 23);
this.buttonDel.TabIndex = 3;
this.buttonDel.Text = "Удалить";
this.buttonDel.UseVisualStyleBackColor = true;
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
//
// buttonRef
//
this.buttonRef.Location = new System.Drawing.Point(368, 53);
this.buttonRef.Name = "buttonRef";
this.buttonRef.Size = new System.Drawing.Size(75, 23);
this.buttonRef.TabIndex = 4;
this.buttonRef.Text = "Обновить";
this.buttonRef.UseVisualStyleBackColor = true;
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
//
// FormClients
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(464, 312);
this.Controls.Add(this.buttonRef);
this.Controls.Add(this.buttonDel);
this.Controls.Add(this.dataGridView);
this.Name = "FormClients";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Клиенты";
this.Load += new System.EventHandler(this.FormClients_Load);
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.DataGridView dataGridView;
private System.Windows.Forms.Button buttonDel;
private System.Windows.Forms.Button buttonRef;
}
}

View File

@ -0,0 +1,86 @@
using Microsoft.Extensions.Logging;
using SushiBar.BindingModels;
using SushiBar.BusinessLogicsContracts;
using SushiBarContracts.BindingModels;
using SushiBarContracts.BusinessLogicsContracts;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace SushiBarView
{
public partial class FormClients : Form
{
private readonly ILogger _logger;
private readonly IClientLogic _logic;
public FormClients(ILogger<FormClients> logger, IClientLogic logic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void FormClients_Load(object sender, EventArgs e)
{
LoadData();
}
private void LoadData()
{
try
{
var list = _logic.ReadList(null);
if (list != null)
{
dataGridView.DataSource = list;
dataGridView.Columns["Id"].Visible = false;
dataGridView.Columns["ClientFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка клиентов");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка загрузки клиентов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void ButtonDel_Click(object sender, EventArgs e)
{
if (dataGridView.SelectedRows.Count == 1)
{
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
{
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
try
{
if (!_logic.Delete(new ClientBindingModel { Id = id }))
{
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
}
_logger.LogInformation("Удаление клиента");
}
catch (Exception ex)
{
_logger.LogError(ex, "Ошибка удаления клиента");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
LoadData();
}
}
}
private void ButtonRef_Click(object sender, EventArgs e)
{
LoadData();
}
}
}

View File

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

View File

@ -28,107 +28,127 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.textBoxCount = new System.Windows.Forms.TextBox(); textBoxCount = new TextBox();
this.labelCost = new System.Windows.Forms.Label(); labelCost = new Label();
this.labelName = new System.Windows.Forms.Label(); labelName = new Label();
this.textBoxSum = new System.Windows.Forms.TextBox(); textBoxSum = new TextBox();
this.label1 = new System.Windows.Forms.Label(); label1 = new Label();
this.ButtonCancel = new System.Windows.Forms.Button(); ButtonCancel = new Button();
this.ButtonSave = new System.Windows.Forms.Button(); ButtonSave = new Button();
this.comboBoxSushi = new System.Windows.Forms.ComboBox(); comboBoxSushi = new ComboBox();
this.SuspendLayout(); comboBoxUser = new ComboBox();
labelUser = new Label();
SuspendLayout();
// //
// textBoxCount // textBoxCount
// //
this.textBoxCount.Location = new System.Drawing.Point(83, 42); textBoxCount.Location = new Point(83, 42);
this.textBoxCount.Name = "textBoxCount"; textBoxCount.Name = "textBoxCount";
this.textBoxCount.Size = new System.Drawing.Size(262, 23); textBoxCount.Size = new Size(262, 23);
this.textBoxCount.TabIndex = 9; textBoxCount.TabIndex = 9;
this.textBoxCount.TextChanged += new System.EventHandler(this.textBoxCost_TextChanged); textBoxCount.TextChanged += textBoxCost_TextChanged;
// //
// labelCost // labelCost
// //
this.labelCost.AutoSize = true; labelCost.AutoSize = true;
this.labelCost.Location = new System.Drawing.Point(5, 45); labelCost.Location = new Point(5, 45);
this.labelCost.Name = "labelCost"; labelCost.Name = "labelCost";
this.labelCost.Size = new System.Drawing.Size(72, 15); labelCost.Size = new Size(72, 15);
this.labelCost.TabIndex = 7; labelCost.TabIndex = 7;
this.labelCost.Text = "Количество"; labelCost.Text = "Количество";
this.labelCost.Click += new System.EventHandler(this.labelCost_Click); labelCost.Click += labelCost_Click;
// //
// labelName // labelName
// //
this.labelName.AutoSize = true; labelName.AutoSize = true;
this.labelName.Location = new System.Drawing.Point(5, 12); labelName.Location = new Point(5, 12);
this.labelName.Name = "labelName"; labelName.Name = "labelName";
this.labelName.Size = new System.Drawing.Size(53, 15); labelName.Size = new Size(53, 15);
this.labelName.TabIndex = 6; labelName.TabIndex = 6;
this.labelName.Text = "Изделие"; labelName.Text = "Изделие";
// //
// textBoxSum // textBoxSum
// //
this.textBoxSum.Location = new System.Drawing.Point(83, 80); textBoxSum.Location = new Point(83, 75);
this.textBoxSum.Name = "textBoxSum"; textBoxSum.Name = "textBoxSum";
this.textBoxSum.Size = new System.Drawing.Size(262, 23); textBoxSum.Size = new Size(262, 23);
this.textBoxSum.TabIndex = 11; textBoxSum.TabIndex = 11;
// //
// label1 // label1
// //
this.label1.AutoSize = true; label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(5, 83); label1.Location = new Point(5, 83);
this.label1.Name = "label1"; label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(45, 15); label1.Size = new Size(45, 15);
this.label1.TabIndex = 10; label1.TabIndex = 10;
this.label1.Text = "Сумма"; label1.Text = "Сумма";
// //
// ButtonCancel // ButtonCancel
// //
this.ButtonCancel.Location = new System.Drawing.Point(258, 120); ButtonCancel.Location = new Point(258, 166);
this.ButtonCancel.Name = "ButtonCancel"; ButtonCancel.Name = "ButtonCancel";
this.ButtonCancel.Size = new System.Drawing.Size(87, 26); ButtonCancel.Size = new Size(87, 26);
this.ButtonCancel.TabIndex = 13; ButtonCancel.TabIndex = 13;
this.ButtonCancel.Text = "Отмена"; ButtonCancel.Text = "Отмена";
this.ButtonCancel.UseVisualStyleBackColor = true; ButtonCancel.UseVisualStyleBackColor = true;
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click); ButtonCancel.Click += ButtonCancel_Click;
// //
// ButtonSave // ButtonSave
// //
this.ButtonSave.Location = new System.Drawing.Point(165, 120); ButtonSave.Location = new Point(165, 166);
this.ButtonSave.Name = "ButtonSave"; ButtonSave.Name = "ButtonSave";
this.ButtonSave.Size = new System.Drawing.Size(87, 26); ButtonSave.Size = new Size(87, 26);
this.ButtonSave.TabIndex = 12; ButtonSave.TabIndex = 12;
this.ButtonSave.Text = "Сохранить"; ButtonSave.Text = "Сохранить";
this.ButtonSave.UseVisualStyleBackColor = true; ButtonSave.UseVisualStyleBackColor = true;
this.ButtonSave.Click += new System.EventHandler(this.ButtonSave_Click); ButtonSave.Click += ButtonSave_Click;
// //
// comboBoxSushi // comboBoxSushi
// //
this.comboBoxSushi.FormattingEnabled = true; comboBoxSushi.FormattingEnabled = true;
this.comboBoxSushi.Location = new System.Drawing.Point(83, 9); comboBoxSushi.Location = new Point(83, 9);
this.comboBoxSushi.Name = "comboBoxSushi"; comboBoxSushi.Name = "comboBoxSushi";
this.comboBoxSushi.Size = new System.Drawing.Size(262, 23); comboBoxSushi.Size = new Size(262, 23);
this.comboBoxSushi.TabIndex = 14; comboBoxSushi.TabIndex = 14;
this.comboBoxSushi.SelectedIndexChanged += new System.EventHandler(this.comboBox1_SelectedIndexChanged); comboBoxSushi.SelectedIndexChanged += comboBox1_SelectedIndexChanged;
//
// comboBoxUser
//
comboBoxUser.FormattingEnabled = true;
comboBoxUser.Location = new Point(95, 110);
comboBoxUser.Name = "comboBoxUser";
comboBoxUser.Size = new Size(250, 23);
comboBoxUser.TabIndex = 15;
//
// labelUser
//
labelUser.AutoSize = true;
labelUser.Location = new Point(5, 113);
labelUser.Name = "labelUser";
labelUser.Size = new Size(84, 15);
labelUser.TabIndex = 16;
labelUser.Text = "Пользователь";
// //
// FormCreateOrder // FormCreateOrder
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(354, 158); ClientSize = new Size(354, 204);
this.Controls.Add(this.comboBoxSushi); Controls.Add(labelUser);
this.Controls.Add(this.ButtonCancel); Controls.Add(comboBoxUser);
this.Controls.Add(this.ButtonSave); Controls.Add(comboBoxSushi);
this.Controls.Add(this.textBoxSum); Controls.Add(ButtonCancel);
this.Controls.Add(this.label1); Controls.Add(ButtonSave);
this.Controls.Add(this.textBoxCount); Controls.Add(textBoxSum);
this.Controls.Add(this.labelCost); Controls.Add(label1);
this.Controls.Add(this.labelName); Controls.Add(textBoxCount);
this.Name = "FormCreateOrder"; Controls.Add(labelCost);
this.Text = "FormCreateOrder"; Controls.Add(labelName);
this.Load += new System.EventHandler(this.FormCreateOrder_Load); Name = "FormCreateOrder";
this.ResumeLayout(false); Text = "FormCreateOrder";
this.PerformLayout(); Load += FormCreateOrder_Load;
ResumeLayout(false);
PerformLayout();
} }
#endregion #endregion
@ -141,5 +161,7 @@
private Button ButtonCancel; private Button ButtonCancel;
private Button ButtonSave; private Button ButtonSave;
private ComboBox comboBoxSushi; private ComboBox comboBoxSushi;
private ComboBox comboBoxUser;
private Label labelUser;
} }
} }

View File

@ -1,4 +1,6 @@
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using SushiBar.BusinessLogicsContracts;
using SushiBar.ViewModels;
using SushiBarContracts.BindingModels; using SushiBarContracts.BindingModels;
using SushiBarContracts.BusinessLogicsContracts; using SushiBarContracts.BusinessLogicsContracts;
using SushiBarContracts.SearchModels; using SushiBarContracts.SearchModels;
@ -21,30 +23,42 @@ namespace SushiBarView
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly ISushiLogic _logicP; private readonly ISushiLogic _logicP;
private readonly IOrderLogic _logicO; private readonly IOrderLogic _logicO;
private List<SushiViewModel>? _list; private readonly IClientLogic _logicC;
private List<SushiViewModel>? _listSushis;
private List<ClientViewModel>? _listClients;
public FormCreateOrder() public FormCreateOrder()
{ {
InitializeComponent(); InitializeComponent();
} }
public FormCreateOrder(ILogger<FormCreateOrder> logger, ISushiLogic logicP, IOrderLogic logicO) public FormCreateOrder(ILogger<FormCreateOrder> logger, ISushiLogic logicP, IOrderLogic logicO, IClientLogic logicC)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_logicP = logicP; _logicP = logicP;
_logicO = logicO; _logicO = logicO;
_logicC = logicC;
} }
private void FormCreateOrder_Load(object sender, EventArgs e) private void FormCreateOrder_Load(object sender, EventArgs e)
{ {
_logger.LogInformation("Загрузка изделий для заказа"); _logger.LogInformation("Загрузка изделий для заказа");
_list = _logicP.ReadList(null); _listSushis = _logicP.ReadList(null);
if (_list != null) if (_listSushis != null)
{ {
comboBoxSushi.DisplayMember = "SushiName"; comboBoxSushi.DisplayMember = "SushiName";
comboBoxSushi.ValueMember = "Id"; comboBoxSushi.ValueMember = "Id";
comboBoxSushi.DataSource = _list; comboBoxSushi.DataSource = _listSushis;
comboBoxSushi.SelectedItem = null; comboBoxSushi.SelectedItem = null;
_logger.LogInformation("Загрузка суши для заказа"); _logger.LogInformation("Загрузка суши для заказа");
} }
_listClients = _logicC.ReadList(null);
if (_listClients != null)
{
comboBoxUser.DisplayMember = "ClientFIO";
comboBoxUser.ValueMember = "Id";
comboBoxUser.DataSource = _listClients;
comboBoxUser.SelectedItem = null;
_logger.LogInformation("Загрузка клиентов для заказа");
}
} }
private void labelCost_Click(object sender, EventArgs e) private void labelCost_Click(object sender, EventArgs e)
{ {
@ -65,11 +79,17 @@ namespace SushiBarView
MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
} }
if (comboBoxUser.SelectedValue == null)
{
MessageBox.Show("Выберите клиента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Создание заказа"); _logger.LogInformation("Создание заказа");
try try
{ {
var operationResult = _logicO.CreateOrder(new OrderBindingModel var operationResult = _logicO.CreateOrder(new OrderBindingModel
{ {
ClientId = Convert.ToInt32(comboBoxUser.SelectedValue),
SushiId = Convert.ToInt32(comboBoxSushi.SelectedValue), SushiId = Convert.ToInt32(comboBoxSushi.SelectedValue),
Count = Convert.ToInt32(textBoxCount.Text), Count = Convert.ToInt32(textBoxCount.Text),
Sum = Convert.ToDouble(textBoxSum.Text) Sum = Convert.ToDouble(textBoxSum.Text)
@ -92,16 +112,15 @@ namespace SushiBarView
} }
private void CalcSum() private void CalcSum()
{ {
if (comboBoxSushi.SelectedValue != null && if (comboBoxSushi.SelectedValue != null && comboBoxUser.SelectedValue != null &&
!string.IsNullOrEmpty(textBoxCount.Text)) !string.IsNullOrEmpty(textBoxCount.Text))
{ {
try try
{ {
int id = Convert.ToInt32(comboBoxSushi.SelectedValue); int idSushi = Convert.ToInt32(comboBoxSushi.SelectedValue);
var sushi = _logicP.ReadElement(new SushiSearchModel var sushi = _logicP.ReadElement(new SushiSearchModel
{ {
Id Id = idSushi
= id
}); });
int count = Convert.ToInt32(textBoxCount.Text); int count = Convert.ToInt32(textBoxCount.Text);
textBoxSum.Text = Math.Round(count * (sushi?.Price ?? 0), textBoxSum.Text = Math.Round(count * (sushi?.Price ?? 0),

View File

@ -1,4 +1,64 @@
<root> <?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: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:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">

View File

@ -28,170 +28,171 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
this.ButtonCreateOrder = new System.Windows.Forms.Button(); ButtonCreateOrder = new Button();
this.ButtonOrderReady = new System.Windows.Forms.Button(); ButtonOrderReady = new Button();
this.ButtonRef = new System.Windows.Forms.Button(); ButtonRef = new Button();
this.ButtonIssuedOrder = new System.Windows.Forms.Button(); ButtonIssuedOrder = new Button();
this.ButtonTakeOrderInWork = new System.Windows.Forms.Button(); ButtonTakeOrderInWork = new Button();
this.menuStrip = new System.Windows.Forms.MenuStrip(); menuStrip = new MenuStrip();
this.toolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); toolStripMenuItem1 = new ToolStripMenuItem();
this.componentsToolStripMenuItemToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); componentsToolStripMenuItemToolStripMenuItem = new ToolStripMenuItem();
this.sushiToolStripMenuItemToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); sushiToolStripMenuItemToolStripMenuItem = new ToolStripMenuItem();
this.dataGridView = new System.Windows.Forms.DataGridView(); отчётыToolStripMenuItem = new ToolStripMenuItem();
this.отчётыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); componentsToolStripMenuItem1 = new ToolStripMenuItem();
this.componentsToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); componentSushiToolStripMenuItem1 = new ToolStripMenuItem();
this.componentSushiToolStripMenuItem1 = new System.Windows.Forms.ToolStripMenuItem(); ordersToolStripMenuItem = new ToolStripMenuItem();
this.ordersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); dataGridView = new DataGridView();
this.menuStrip.SuspendLayout(); ClientToolStripMenuItem = new ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); menuStrip.SuspendLayout();
this.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
// //
// ButtonCreateOrder // ButtonCreateOrder
// //
this.ButtonCreateOrder.Location = new System.Drawing.Point(676, 37); ButtonCreateOrder.Location = new Point(676, 37);
this.ButtonCreateOrder.Name = "ButtonCreateOrder"; ButtonCreateOrder.Name = "ButtonCreateOrder";
this.ButtonCreateOrder.Size = new System.Drawing.Size(217, 29); ButtonCreateOrder.Size = new Size(217, 29);
this.ButtonCreateOrder.TabIndex = 0; ButtonCreateOrder.TabIndex = 0;
this.ButtonCreateOrder.Text = "Создать заказ"; ButtonCreateOrder.Text = "Создать заказ";
this.ButtonCreateOrder.UseVisualStyleBackColor = true; ButtonCreateOrder.UseVisualStyleBackColor = true;
this.ButtonCreateOrder.Click += new System.EventHandler(this.ButtonCreateOrder_Click); ButtonCreateOrder.Click += ButtonCreateOrder_Click;
// //
// ButtonOrderReady // ButtonOrderReady
// //
this.ButtonOrderReady.Location = new System.Drawing.Point(676, 180); ButtonOrderReady.Location = new Point(676, 180);
this.ButtonOrderReady.Name = "ButtonOrderReady"; ButtonOrderReady.Name = "ButtonOrderReady";
this.ButtonOrderReady.Size = new System.Drawing.Size(217, 29); ButtonOrderReady.Size = new Size(217, 29);
this.ButtonOrderReady.TabIndex = 1; ButtonOrderReady.TabIndex = 1;
this.ButtonOrderReady.Text = "Заказ готов"; ButtonOrderReady.Text = "Заказ готов";
this.ButtonOrderReady.UseVisualStyleBackColor = true; ButtonOrderReady.UseVisualStyleBackColor = true;
this.ButtonOrderReady.Click += new System.EventHandler(this.ButtonOrderReady_Click); ButtonOrderReady.Click += ButtonOrderReady_Click;
// //
// ButtonRef // ButtonRef
// //
this.ButtonRef.Location = new System.Drawing.Point(676, 323); ButtonRef.Location = new Point(676, 323);
this.ButtonRef.Name = "ButtonRef"; ButtonRef.Name = "ButtonRef";
this.ButtonRef.Size = new System.Drawing.Size(217, 29); ButtonRef.Size = new Size(217, 29);
this.ButtonRef.TabIndex = 2; ButtonRef.TabIndex = 2;
this.ButtonRef.Text = "Обновить список"; ButtonRef.Text = "Обновить список";
this.ButtonRef.UseVisualStyleBackColor = true; ButtonRef.UseVisualStyleBackColor = true;
this.ButtonRef.Click += new System.EventHandler(this.ButtonRef_Click); ButtonRef.Click += ButtonRef_Click;
// //
// ButtonIssuedOrder // ButtonIssuedOrder
// //
this.ButtonIssuedOrder.Location = new System.Drawing.Point(676, 256); ButtonIssuedOrder.Location = new Point(676, 256);
this.ButtonIssuedOrder.Name = "ButtonIssuedOrder"; ButtonIssuedOrder.Name = "ButtonIssuedOrder";
this.ButtonIssuedOrder.Size = new System.Drawing.Size(217, 29); ButtonIssuedOrder.Size = new Size(217, 29);
this.ButtonIssuedOrder.TabIndex = 3; ButtonIssuedOrder.TabIndex = 3;
this.ButtonIssuedOrder.Text = "Заказ выполнен"; ButtonIssuedOrder.Text = "Заказ выполнен";
this.ButtonIssuedOrder.UseVisualStyleBackColor = true; ButtonIssuedOrder.UseVisualStyleBackColor = true;
this.ButtonIssuedOrder.Click += new System.EventHandler(this.ButtonIssuedOrder_Click); ButtonIssuedOrder.Click += ButtonIssuedOrder_Click;
// //
// ButtonTakeOrderInWork // ButtonTakeOrderInWork
// //
this.ButtonTakeOrderInWork.Location = new System.Drawing.Point(676, 109); ButtonTakeOrderInWork.Location = new Point(676, 109);
this.ButtonTakeOrderInWork.Name = "ButtonTakeOrderInWork"; ButtonTakeOrderInWork.Name = "ButtonTakeOrderInWork";
this.ButtonTakeOrderInWork.Size = new System.Drawing.Size(217, 29); ButtonTakeOrderInWork.Size = new Size(217, 29);
this.ButtonTakeOrderInWork.TabIndex = 4; ButtonTakeOrderInWork.TabIndex = 4;
this.ButtonTakeOrderInWork.Text = "Отдать на выполнение"; ButtonTakeOrderInWork.Text = "Отдать на выполнение";
this.ButtonTakeOrderInWork.UseVisualStyleBackColor = true; ButtonTakeOrderInWork.UseVisualStyleBackColor = true;
this.ButtonTakeOrderInWork.Click += new System.EventHandler(this.ButtonTakeOrderInWork_Click); ButtonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
// //
// menuStrip // menuStrip
// //
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItem1, отчётыToolStripMenuItem });
this.toolStripMenuItem1, this.отчётыToolStripMenuItem}); menuStrip.Location = new Point(0, 0);
this.menuStrip.Location = new System.Drawing.Point(0, 0); menuStrip.Name = "menuStrip";
this.menuStrip.Name = "menuStrip"; menuStrip.Size = new Size(922, 24);
this.menuStrip.Size = new System.Drawing.Size(922, 24); menuStrip.TabIndex = 5;
this.menuStrip.TabIndex = 5; menuStrip.Text = "menuStrip1";
this.menuStrip.Text = "menuStrip1";
// //
// toolStripMenuItem1 // toolStripMenuItem1
// //
this.toolStripMenuItem1.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { toolStripMenuItem1.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItemToolStripMenuItem, sushiToolStripMenuItemToolStripMenuItem, ClientToolStripMenuItem });
this.componentsToolStripMenuItemToolStripMenuItem, toolStripMenuItem1.Name = "toolStripMenuItem1";
this.sushiToolStripMenuItemToolStripMenuItem}); toolStripMenuItem1.Size = new Size(94, 20);
this.toolStripMenuItem1.Name = "toolStripMenuItem1"; toolStripMenuItem1.Text = "Справочники";
this.toolStripMenuItem1.Size = new System.Drawing.Size(94, 20);
this.toolStripMenuItem1.Text = "Справочники";
// //
// componentsToolStripMenuItemToolStripMenuItem // componentsToolStripMenuItemToolStripMenuItem
// //
this.componentsToolStripMenuItemToolStripMenuItem.Name = "componentsToolStripMenuItemToolStripMenuItem"; componentsToolStripMenuItemToolStripMenuItem.Name = "componentsToolStripMenuItemToolStripMenuItem";
this.componentsToolStripMenuItemToolStripMenuItem.Size = new System.Drawing.Size(180, 22); componentsToolStripMenuItemToolStripMenuItem.Size = new Size(180, 22);
this.componentsToolStripMenuItemToolStripMenuItem.Text = "Компоненты"; componentsToolStripMenuItemToolStripMenuItem.Text = "Компоненты";
this.componentsToolStripMenuItemToolStripMenuItem.Click += new System.EventHandler(this.componentsToolStripMenuItem_Click); componentsToolStripMenuItemToolStripMenuItem.Click += componentsToolStripMenuItem_Click;
// //
// sushiToolStripMenuItemToolStripMenuItem // sushiToolStripMenuItemToolStripMenuItem
// //
this.sushiToolStripMenuItemToolStripMenuItem.Name = "sushiToolStripMenuItemToolStripMenuItem"; sushiToolStripMenuItemToolStripMenuItem.Name = "sushiToolStripMenuItemToolStripMenuItem";
this.sushiToolStripMenuItemToolStripMenuItem.Size = new System.Drawing.Size(180, 22); sushiToolStripMenuItemToolStripMenuItem.Size = new Size(180, 22);
this.sushiToolStripMenuItemToolStripMenuItem.Text = "Суши"; sushiToolStripMenuItemToolStripMenuItem.Text = "Суши";
this.sushiToolStripMenuItemToolStripMenuItem.Click += new System.EventHandler(this.sushiToolStripMenuItem_Click); sushiToolStripMenuItemToolStripMenuItem.Click += sushiToolStripMenuItem_Click;
//
// dataGridView
//
this.dataGridView.BackgroundColor = System.Drawing.Color.White;
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView.Location = new System.Drawing.Point(12, 27);
this.dataGridView.Name = "dataGridView";
this.dataGridView.RowTemplate.Height = 25;
this.dataGridView.Size = new System.Drawing.Size(647, 344);
this.dataGridView.TabIndex = 6;
// //
// отчётыToolStripMenuItem // отчётыToolStripMenuItem
// //
this.отчётыToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { отчётыToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { componentsToolStripMenuItem1, componentSushiToolStripMenuItem1, ordersToolStripMenuItem });
this.componentsToolStripMenuItem1, отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
this.componentSushiToolStripMenuItem1, отчётыToolStripMenuItem.Size = new Size(60, 20);
this.ordersToolStripMenuItem}); отчётыToolStripMenuItem.Text = "Отчёты";
this.отчётыToolStripMenuItem.Name = "отчётыToolStripMenuItem";
this.отчётыToolStripMenuItem.Size = new System.Drawing.Size(60, 20);
this.отчётыToolStripMenuItem.Text = "Отчёты";
// //
// componentsToolStripMenuItem1 // componentsToolStripMenuItem1
// //
this.componentsToolStripMenuItem1.Name = "componentsToolStripMenuItem1"; componentsToolStripMenuItem1.Name = "componentsToolStripMenuItem1";
this.componentsToolStripMenuItem1.Size = new System.Drawing.Size(205, 22); componentsToolStripMenuItem1.Size = new Size(201, 22);
this.componentsToolStripMenuItem1.Text = "Суши"; componentsToolStripMenuItem1.Text = "Суши";
this.componentsToolStripMenuItem1.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click); componentsToolStripMenuItem1.Click += ComponentsToolStripMenuItem_Click;
// //
// componentSushiToolStripMenuItem1 // componentSushiToolStripMenuItem1
// //
this.componentSushiToolStripMenuItem1.Name = "componentSushiToolStripMenuItem1"; componentSushiToolStripMenuItem1.Name = "componentSushiToolStripMenuItem1";
this.componentSushiToolStripMenuItem1.Size = new System.Drawing.Size(205, 22); componentSushiToolStripMenuItem1.Size = new Size(201, 22);
this.componentSushiToolStripMenuItem1.Text = "Суши с компонентами"; componentSushiToolStripMenuItem1.Text = "Суши с компонентами";
this.componentSushiToolStripMenuItem1.Click += new System.EventHandler(this.ComponentSushiToolStripMenuItem_Click); componentSushiToolStripMenuItem1.Click += ComponentSushiToolStripMenuItem_Click;
// //
// ordersToolStripMenuItem // ordersToolStripMenuItem
// //
this.ordersToolStripMenuItem.Name = "ordersToolStripMenuItem"; ordersToolStripMenuItem.Name = "ordersToolStripMenuItem";
this.ordersToolStripMenuItem.Size = new System.Drawing.Size(205, 22); ordersToolStripMenuItem.Size = new Size(201, 22);
this.ordersToolStripMenuItem.Text = "Заказы"; ordersToolStripMenuItem.Text = "Заказы";
this.ordersToolStripMenuItem.Click += new System.EventHandler(this.OrdersToolStripMenuItem_Click); ordersToolStripMenuItem.Click += OrdersToolStripMenuItem_Click;
//
// dataGridView
//
dataGridView.BackgroundColor = Color.White;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Location = new Point(12, 27);
dataGridView.Name = "dataGridView";
dataGridView.RowTemplate.Height = 25;
dataGridView.Size = new Size(647, 344);
dataGridView.TabIndex = 6;
//
// ClientToolStripMenuItem
//
ClientToolStripMenuItem.Name = "ClientToolStripMenuItem";
ClientToolStripMenuItem.Size = new Size(180, 22);
ClientToolStripMenuItem.Text = "Клиенты";
ClientToolStripMenuItem.Click += ClientToolStripMenuItem_Click;
// //
// FormMain // FormMain
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(922, 383); ClientSize = new Size(922, 383);
this.Controls.Add(this.dataGridView); Controls.Add(dataGridView);
this.Controls.Add(this.ButtonTakeOrderInWork); Controls.Add(ButtonTakeOrderInWork);
this.Controls.Add(this.ButtonIssuedOrder); Controls.Add(ButtonIssuedOrder);
this.Controls.Add(this.ButtonRef); Controls.Add(ButtonRef);
this.Controls.Add(this.ButtonOrderReady); Controls.Add(ButtonOrderReady);
this.Controls.Add(this.ButtonCreateOrder); Controls.Add(ButtonCreateOrder);
this.Controls.Add(this.menuStrip); Controls.Add(menuStrip);
this.MainMenuStrip = this.menuStrip; MainMenuStrip = menuStrip;
this.Name = "FormMain"; Name = "FormMain";
this.Text = "FormMain"; Text = "FormMain";
this.Load += new System.EventHandler(this.FormMain_Load); Load += FormMain_Load;
this.menuStrip.ResumeLayout(false); menuStrip.ResumeLayout(false);
this.menuStrip.PerformLayout(); menuStrip.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
this.ResumeLayout(false); ResumeLayout(false);
this.PerformLayout(); PerformLayout();
} }
#endregion #endregion
@ -210,5 +211,6 @@
private ToolStripMenuItem componentsToolStripMenuItem1; private ToolStripMenuItem componentsToolStripMenuItem1;
private ToolStripMenuItem componentSushiToolStripMenuItem1; private ToolStripMenuItem componentSushiToolStripMenuItem1;
private ToolStripMenuItem ordersToolStripMenuItem; private ToolStripMenuItem ordersToolStripMenuItem;
private ToolStripMenuItem ClientToolStripMenuItem;
} }
} }

View File

@ -57,7 +57,8 @@ namespace SushiBarView
{ {
dataGridView.DataSource = list; dataGridView.DataSource = list;
dataGridView.Columns["SushiId"].Visible = false; dataGridView.Columns["SushiId"].Visible = false;
dataGridView.Columns["ClientId"].Visible = false;
} }
_logger.LogInformation("Загрузка заказов"); _logger.LogInformation("Загрузка заказов");
} }
@ -91,7 +92,7 @@ namespace SushiBarView
int id = int id =
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value); Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id); _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
try try
{ {
var operationResult = _orderLogic.TakeOrderInWork(new var operationResult = _orderLogic.TakeOrderInWork(new
OrderBindingModel OrderBindingModel
@ -132,8 +133,8 @@ namespace SushiBarView
catch (Exception ex) catch (Exception ex)
{ {
_logger.LogError(ex, "Ошибка отметки о готовности заказа"); _logger.LogError(ex, "Ошибка отметки о готовности заказа");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
MessageBoxIcon.Error); MessageBoxIcon.Error);
} }
} }
} }
@ -200,5 +201,13 @@ MessageBoxIcon.Error);
} }
} }
private void ClientToolStripMenuItem_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormClients));
if (service is FormClients form)
{
form.ShowDialog();
}
}
} }
} }

View File

@ -1,4 +1,64 @@
<root> <?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: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:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true"> <xsd:element name="root" msdata:IsDataSet="true">

View File

@ -11,6 +11,9 @@ using SushiBarBusinessLogic.OfficePackage.Implements;
using SushiBarBusinessLogic.OfficePackage; using SushiBarBusinessLogic.OfficePackage;
using SushiBarBusinessLogic; using SushiBarBusinessLogic;
using SushiBarView.Reports; using SushiBarView.Reports;
using SushiBar.StoragesContracts;
using Microsoft.EntityFrameworkCore.Design;
using SushiBar.BusinessLogicsContracts;
namespace SushiBarView namespace SushiBarView
{ {
@ -40,9 +43,13 @@ namespace SushiBarView
services.AddTransient<IComponentStorage, ComponentStorage>(); services.AddTransient<IComponentStorage, ComponentStorage>();
services.AddTransient<IOrderStorage, OrderStorage>(); services.AddTransient<IOrderStorage, OrderStorage>();
services.AddTransient<ISushiStorage, SushiStorage>(); services.AddTransient<ISushiStorage, SushiStorage>();
services.AddTransient<IClientStorage, ClientStorage>();
services.AddTransient<IComponentLogic, ComponentLogic>(); services.AddTransient<IComponentLogic, ComponentLogic>();
services.AddTransient<IOrderLogic, OrderLogic>(); services.AddTransient<IOrderLogic, OrderLogic>();
services.AddTransient<ISushiLogic, SushiLogic>(); services.AddTransient<ISushiLogic, SushiLogic>();
services.AddTransient<IClientLogic, ClientLogic>();
services.AddTransient<FormMain>(); services.AddTransient<FormMain>();
services.AddTransient<FormComponent>(); services.AddTransient<FormComponent>();
services.AddTransient<FormComponents>(); services.AddTransient<FormComponents>();
@ -53,6 +60,8 @@ namespace SushiBarView
services.AddTransient<FormReportOrders>(); services.AddTransient<FormReportOrders>();
services.AddTransient<FormReportSushiComponents>(); services.AddTransient<FormReportSushiComponents>();
services.AddTransient<IReportLogic, ReportLogic>(); services.AddTransient<IReportLogic, ReportLogic>();
services.AddTransient<FormClients>();
services.AddTransient<EntityFrameworkDesignServicesBuilder>();
services.AddTransient<AbstractSaveToWord, SaveToWord>(); services.AddTransient<AbstractSaveToWord, SaveToWord>();
services.AddTransient<AbstractSaveToExcel, SaveToExcel>(); services.AddTransient<AbstractSaveToExcel, SaveToExcel>();