Сделал основую часть.
This commit is contained in:
parent
16e907326c
commit
bf57e05c9a
@ -88,7 +88,7 @@ namespace RestaurantBusinessLogic.BusinessLogics
|
|||||||
{
|
{
|
||||||
throw new ArgumentNullException("Нет цены у заказа", nameof(model.Price));
|
throw new ArgumentNullException("Нет цены у заказа", nameof(model.Price));
|
||||||
}
|
}
|
||||||
if (model.Date != null)
|
if (model.Date == null)
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException("Нет даты у заказа", nameof(model.Date));
|
throw new ArgumentNullException("Нет даты у заказа", nameof(model.Date));
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ namespace RestaurantContracts.BindingModels
|
|||||||
|
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
|
||||||
public Dictionary<int, (IProviderModel, int, DateTime)> ComponentProviders { get; set; } = new();
|
public List<(IProviderModel, int, DateTime)> ComponentProviders { get; set; } = new();
|
||||||
|
|
||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ namespace RestaurantContracts.BindingModels
|
|||||||
{
|
{
|
||||||
public int ClientId { get; set; } = new();
|
public int ClientId { get; set; } = new();
|
||||||
|
|
||||||
public int Price { get; set; }
|
public double Price { get; set; }
|
||||||
|
|
||||||
public DateTime Date { get; set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
public DateTime Date { get; set; } = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc);
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ namespace RestaurantContracts.BindingModels
|
|||||||
{
|
{
|
||||||
public string Type { get; set; } = string.Empty;
|
public string Type { get; set; } = string.Empty;
|
||||||
|
|
||||||
public int Price { get; set; }
|
public double Price { get; set; }
|
||||||
|
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
|
||||||
|
@ -21,6 +21,6 @@ namespace RestaurantContracts.ViewModels
|
|||||||
[DisplayName("Количество")]
|
[DisplayName("Количество")]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
|
||||||
public Dictionary<int, (IProviderModel, int, DateTime)> ComponentProviders { get; set; } = new();
|
public List<(IProviderModel, int, DateTime)> ComponentProviders { get; set; } = new();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,7 @@ namespace RestaurantContracts.ViewModels
|
|||||||
public string ClientLastName { get; set; } = string.Empty;
|
public string ClientLastName { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Цена")]
|
[DisplayName("Цена")]
|
||||||
public int Price { get; set; }
|
public double Price { get; set; }
|
||||||
|
|
||||||
[DisplayName("Дата")]
|
[DisplayName("Дата")]
|
||||||
public DateTime Date { get; set; }
|
public DateTime Date { get; set; }
|
||||||
|
@ -16,7 +16,7 @@ namespace RestaurantContracts.ViewModels
|
|||||||
public string Type { get; set; } = string.Empty;
|
public string Type { get; set; } = string.Empty;
|
||||||
|
|
||||||
[DisplayName("Цена")]
|
[DisplayName("Цена")]
|
||||||
public int Price { get; set; }
|
public double Price { get; set; }
|
||||||
|
|
||||||
[DisplayName("Количество продуктов")]
|
[DisplayName("Количество продуктов")]
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
@ -14,6 +14,6 @@ namespace RestaurantDataModels.Models
|
|||||||
|
|
||||||
int Count { get; }
|
int Count { get; }
|
||||||
|
|
||||||
Dictionary<int, (IProviderModel, int, DateTime)> ComponentProviders { get; }
|
List<(IProviderModel, int, DateTime)> ComponentProviders { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ namespace RestaurantDataModels.Models
|
|||||||
{
|
{
|
||||||
int ClientId { get; }
|
int ClientId { get; }
|
||||||
|
|
||||||
int Price { get; }
|
double Price { get; }
|
||||||
|
|
||||||
DateTime Date { get; }
|
DateTime Date { get; }
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ namespace RestaurantDataModels.Models
|
|||||||
{
|
{
|
||||||
string Type { get; }
|
string Type { get; }
|
||||||
|
|
||||||
int Price { get; }
|
double Price { get; }
|
||||||
|
|
||||||
int Count { get; }
|
int Count { get; }
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ namespace RestaurantDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Products)
|
.Include(x => x.Products)
|
||||||
.ThenInclude(x => x.ProductId)
|
.ThenInclude(x => x.Product)
|
||||||
.Include(x => x.Client)
|
.Include(x => x.Client)
|
||||||
.Where(x => x.Id == model.Id)
|
.Where(x => x.Id == model.Id)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
@ -42,7 +42,7 @@ namespace RestaurantDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Products)
|
.Include(x => x.Products)
|
||||||
.ThenInclude(x => x.ProductId)
|
.ThenInclude(x => x.Product)
|
||||||
.Include(x => x.Client)
|
.Include(x => x.Client)
|
||||||
.Where(x => x.ClientId == model.ClientId)
|
.Where(x => x.ClientId == model.ClientId)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
@ -52,7 +52,7 @@ namespace RestaurantDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
return context.Orders
|
return context.Orders
|
||||||
.Include(x => x.Products)
|
.Include(x => x.Products)
|
||||||
.ThenInclude(x => x.ProductId)
|
.ThenInclude(x => x.Product)
|
||||||
.Include(x => x.Client)
|
.Include(x => x.Client)
|
||||||
.Where(x => x.Date == model.Date)
|
.Where(x => x.Date == model.Date)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
@ -95,7 +95,7 @@ namespace RestaurantDatabaseImplement.Implements
|
|||||||
var element = context.Orders
|
var element = context.Orders
|
||||||
.Include(x => x.Client)
|
.Include(x => x.Client)
|
||||||
.Include(x => x.Products)
|
.Include(x => x.Products)
|
||||||
.ThenInclude(x => x.ProductId)
|
.ThenInclude(x => x.Product)
|
||||||
.FirstOrDefault(x => x.Id == model.Id);
|
.FirstOrDefault(x => x.Id == model.Id);
|
||||||
if (element == null)
|
if (element == null)
|
||||||
{
|
{
|
||||||
@ -111,7 +111,7 @@ namespace RestaurantDatabaseImplement.Implements
|
|||||||
var element = context.Orders
|
var element = context.Orders
|
||||||
.Include(x => x.Client)
|
.Include(x => x.Client)
|
||||||
.Include(x => x.Products)
|
.Include(x => x.Products)
|
||||||
.ThenInclude(x => x.ProductId)
|
.ThenInclude(x => x.Product)
|
||||||
.FirstOrDefault(rec => rec.Id == model.Id);
|
.FirstOrDefault(rec => rec.Id == model.Id);
|
||||||
if (element != null)
|
if (element != null)
|
||||||
{
|
{
|
||||||
|
@ -19,7 +19,7 @@ namespace RestaurantDatabaseImplement.Implements
|
|||||||
using var context = new RestaurantDatabase();
|
using var context = new RestaurantDatabase();
|
||||||
return context.Products
|
return context.Products
|
||||||
.Include(x => x.Components)
|
.Include(x => x.Components)
|
||||||
.ThenInclude(x => x.ComponentId)
|
.ThenInclude(x => x.Component)
|
||||||
.ToList()
|
.ToList()
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
@ -31,7 +31,7 @@ namespace RestaurantDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
return context.Products
|
return context.Products
|
||||||
.Include(x => x.Components)
|
.Include(x => x.Components)
|
||||||
.ThenInclude(x => x.ComponentId)
|
.ThenInclude(x => x.Component)
|
||||||
.Where(x => x.Id == model.Id)
|
.Where(x => x.Id == model.Id)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
@ -40,7 +40,7 @@ namespace RestaurantDatabaseImplement.Implements
|
|||||||
{
|
{
|
||||||
return context.Products
|
return context.Products
|
||||||
.Include(x => x.Components)
|
.Include(x => x.Components)
|
||||||
.ThenInclude(x => x.ComponentId)
|
.ThenInclude(x => x.Component)
|
||||||
.Where(x => x.Type == model.Type)
|
.Where(x => x.Type == model.Type)
|
||||||
.Select(x => x.GetViewModel)
|
.Select(x => x.GetViewModel)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
319
Restaurant/RestaurantDatabaseImplement/Migrations/20230516191214_migr2.Designer.cs
generated
Normal file
319
Restaurant/RestaurantDatabaseImplement/Migrations/20230516191214_migr2.Designer.cs
generated
Normal file
@ -0,0 +1,319 @@
|
|||||||
|
// <auto-generated />
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
|
using RestaurantDatabaseImplement;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace RestaurantDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
[DbContext(typeof(RestaurantDatabase))]
|
||||||
|
[Migration("20230516191214_migr2")]
|
||||||
|
partial class migr2
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||||
|
{
|
||||||
|
#pragma warning disable 612, 618
|
||||||
|
modelBuilder
|
||||||
|
.HasAnnotation("ProductVersion", "7.0.5")
|
||||||
|
.HasAnnotation("Relational:MaxIdentifierLength", 63);
|
||||||
|
|
||||||
|
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
||||||
|
|
||||||
|
modelBuilder.Entity("RestaurantDatabaseImplement.Models.Client", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("FirstName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("LastName")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Number")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Clients");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RestaurantDatabaseImplement.Models.Component", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<int>("Price")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Components");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RestaurantDatabaseImplement.Models.ComponentProvider", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("ComponentId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime>("Date")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<int>("ProviderId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ComponentId");
|
||||||
|
|
||||||
|
b.HasIndex("ProviderId");
|
||||||
|
|
||||||
|
b.ToTable("ComponentProviders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RestaurantDatabaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("ClientId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<DateTime>("Date")
|
||||||
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
|
b.Property<double>("Price")
|
||||||
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ClientId");
|
||||||
|
|
||||||
|
b.ToTable("Orders");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RestaurantDatabaseImplement.Models.OrderProduct", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("OrderId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("ProductId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("OrderId");
|
||||||
|
|
||||||
|
b.HasIndex("ProductId");
|
||||||
|
|
||||||
|
b.ToTable("OrderProducts");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RestaurantDatabaseImplement.Models.Product", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<double>("Price")
|
||||||
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
|
b.Property<string>("Type")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Products");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RestaurantDatabaseImplement.Models.ProductComponent", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<int>("ComponentId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("Count")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.Property<int>("ProductId")
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("ComponentId");
|
||||||
|
|
||||||
|
b.HasIndex("ProductId");
|
||||||
|
|
||||||
|
b.ToTable("ProductComponents");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RestaurantDatabaseImplement.Models.Provider", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("integer");
|
||||||
|
|
||||||
|
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
|
||||||
|
|
||||||
|
b.Property<string>("Address")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("text");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("Providers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RestaurantDatabaseImplement.Models.ComponentProvider", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("RestaurantDatabaseImplement.Models.Component", "Component")
|
||||||
|
.WithMany("Providers")
|
||||||
|
.HasForeignKey("ComponentId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("RestaurantDatabaseImplement.Models.Provider", "Provider")
|
||||||
|
.WithMany("ComponentProviders")
|
||||||
|
.HasForeignKey("ProviderId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Component");
|
||||||
|
|
||||||
|
b.Navigation("Provider");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RestaurantDatabaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("RestaurantDatabaseImplement.Models.Client", "Client")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("ClientId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Client");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RestaurantDatabaseImplement.Models.OrderProduct", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("RestaurantDatabaseImplement.Models.Order", "Order")
|
||||||
|
.WithMany("Products")
|
||||||
|
.HasForeignKey("OrderId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("RestaurantDatabaseImplement.Models.Product", "Product")
|
||||||
|
.WithMany("OrderProducts")
|
||||||
|
.HasForeignKey("ProductId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Order");
|
||||||
|
|
||||||
|
b.Navigation("Product");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RestaurantDatabaseImplement.Models.ProductComponent", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("RestaurantDatabaseImplement.Models.Component", "Component")
|
||||||
|
.WithMany("ProductComponents")
|
||||||
|
.HasForeignKey("ComponentId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("RestaurantDatabaseImplement.Models.Product", "Product")
|
||||||
|
.WithMany("Components")
|
||||||
|
.HasForeignKey("ProductId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
|
b.Navigation("Component");
|
||||||
|
|
||||||
|
b.Navigation("Product");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RestaurantDatabaseImplement.Models.Component", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("ProductComponents");
|
||||||
|
|
||||||
|
b.Navigation("Providers");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RestaurantDatabaseImplement.Models.Order", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Products");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RestaurantDatabaseImplement.Models.Product", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("Components");
|
||||||
|
|
||||||
|
b.Navigation("OrderProducts");
|
||||||
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("RestaurantDatabaseImplement.Models.Provider", b =>
|
||||||
|
{
|
||||||
|
b.Navigation("ComponentProviders");
|
||||||
|
});
|
||||||
|
#pragma warning restore 612, 618
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace RestaurantDatabaseImplement.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class migr2 : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<double>(
|
||||||
|
name: "Price",
|
||||||
|
table: "Products",
|
||||||
|
type: "double precision",
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(int),
|
||||||
|
oldType: "integer");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<double>(
|
||||||
|
name: "Price",
|
||||||
|
table: "Orders",
|
||||||
|
type: "double precision",
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(int),
|
||||||
|
oldType: "integer");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<int>(
|
||||||
|
name: "Price",
|
||||||
|
table: "Products",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(double),
|
||||||
|
oldType: "double precision");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<int>(
|
||||||
|
name: "Price",
|
||||||
|
table: "Orders",
|
||||||
|
type: "integer",
|
||||||
|
nullable: false,
|
||||||
|
oldClrType: typeof(double),
|
||||||
|
oldType: "double precision");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -113,8 +113,8 @@ namespace RestaurantDatabaseImplement.Migrations
|
|||||||
b.Property<DateTime>("Date")
|
b.Property<DateTime>("Date")
|
||||||
.HasColumnType("timestamp with time zone");
|
.HasColumnType("timestamp with time zone");
|
||||||
|
|
||||||
b.Property<int>("Price")
|
b.Property<double>("Price")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
@ -160,8 +160,8 @@ namespace RestaurantDatabaseImplement.Migrations
|
|||||||
b.Property<int>("Count")
|
b.Property<int>("Count")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("integer");
|
||||||
|
|
||||||
b.Property<int>("Price")
|
b.Property<double>("Price")
|
||||||
.HasColumnType("integer");
|
.HasColumnType("double precision");
|
||||||
|
|
||||||
b.Property<string>("Type")
|
b.Property<string>("Type")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
|
@ -22,17 +22,16 @@ namespace RestaurantDatabaseImplement.Models
|
|||||||
[Required]
|
[Required]
|
||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
|
|
||||||
private Dictionary<int, (IProviderModel, int, DateTime)>? _componentProviders = null;
|
private List<(IProviderModel, int, DateTime)>? _componentProviders = null;
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public Dictionary<int, (IProviderModel, int, DateTime)> ComponentProviders
|
public List<(IProviderModel, int, DateTime)> ComponentProviders
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
if (_componentProviders == null)
|
if (_componentProviders == null)
|
||||||
{
|
{
|
||||||
_componentProviders = Providers.ToDictionary(recPC => recPC.ProviderId, recPC =>
|
_componentProviders = Providers.Select(recPC => (recPC.Provider as IProviderModel, recPC.Count, recPC.Date)).ToList();
|
||||||
(recPC.Provider as IProviderModel, recPC.Count, recPC.Date));
|
|
||||||
}
|
}
|
||||||
return _componentProviders;
|
return _componentProviders;
|
||||||
}
|
}
|
||||||
@ -60,9 +59,9 @@ namespace RestaurantDatabaseImplement.Models
|
|||||||
Count = model.Count,
|
Count = model.Count,
|
||||||
Providers = model.ComponentProviders.Select(x => new ComponentProvider
|
Providers = model.ComponentProviders.Select(x => new ComponentProvider
|
||||||
{
|
{
|
||||||
Provider = context.Providers.First(y => y.Id == x.Key),
|
Provider = context.Providers.First(y => y.ComponentProviders == x.Item1),
|
||||||
Count = x.Value.Item2,
|
Count = x.Item2,
|
||||||
Date = x.Value.Item3
|
Date = x.Item3
|
||||||
}).ToList()
|
}).ToList()
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -88,13 +87,13 @@ namespace RestaurantDatabaseImplement.Models
|
|||||||
var ComponentProviders = context.ComponentProviders.Where(rec => rec.ComponentId == model.Id).ToList();
|
var ComponentProviders = context.ComponentProviders.Where(rec => rec.ComponentId == model.Id).ToList();
|
||||||
if (ComponentProviders != null && ComponentProviders.Count > 0)
|
if (ComponentProviders != null && ComponentProviders.Count > 0)
|
||||||
{ // удалили те, которых нет в модели
|
{ // удалили те, которых нет в модели
|
||||||
context.ComponentProviders.RemoveRange(ComponentProviders.Where(rec => !model.ComponentProviders.ContainsKey(rec.ProviderId)));
|
context.ComponentProviders.RemoveRange(ComponentProviders.Where(rec => !model.ComponentProviders.Select(x => x.Item1.Id).Contains(rec.ProviderId)));
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
// обновили количество у существующих записей
|
// обновили количество у существующих записей
|
||||||
foreach (var updateComponent in ComponentProviders)
|
foreach (var updateComponent in ComponentProviders)
|
||||||
{
|
{
|
||||||
updateComponent.Count = model.ComponentProviders[updateComponent.ProviderId].Item2;
|
updateComponent.Count = model.ComponentProviders.Find(x => x.Item1.Id == updateComponent.ProviderId).Item2;
|
||||||
model.ComponentProviders.Remove(updateComponent.ProviderId);
|
model.ComponentProviders.Remove(model.ComponentProviders.Find(x => x.Item1.Id == updateComponent.ProviderId));
|
||||||
}
|
}
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
@ -104,9 +103,9 @@ namespace RestaurantDatabaseImplement.Models
|
|||||||
context.ComponentProviders.Add(new ComponentProvider
|
context.ComponentProviders.Add(new ComponentProvider
|
||||||
{
|
{
|
||||||
Component = Component,
|
Component = Component,
|
||||||
Provider = context.Providers.First(x => x.Id == pc.Key),
|
Provider = context.Providers.First(x => x.ComponentProviders == pc.Item1),
|
||||||
Count = pc.Value.Item2,
|
Count = pc.Item2,
|
||||||
Date = pc.Value.Item3 // ??????
|
Date = pc.Item3 // ??????
|
||||||
});
|
});
|
||||||
context.SaveChanges();
|
context.SaveChanges();
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ namespace RestaurantDatabaseImplement.Models
|
|||||||
public virtual Client Client { get; set; } = new();
|
public virtual Client Client { get; set; } = new();
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public int Price { get; set; }
|
public double Price { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public DateTime Date { get; set; }
|
public DateTime Date { get; set; }
|
||||||
@ -54,6 +54,7 @@ namespace RestaurantDatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
Id = model.Id,
|
Id = model.Id,
|
||||||
ClientId = model.ClientId,
|
ClientId = model.ClientId,
|
||||||
|
Client = context.Clients.FirstOrDefault(x => x.Id == model.ClientId),
|
||||||
Price = model.Price,
|
Price = model.Price,
|
||||||
Date = model.Date,
|
Date = model.Date,
|
||||||
Products = model.OrderProducts.Select(x => new OrderProduct
|
Products = model.OrderProducts.Select(x => new OrderProduct
|
||||||
@ -74,6 +75,8 @@ namespace RestaurantDatabaseImplement.Models
|
|||||||
{
|
{
|
||||||
Id = Id,
|
Id = Id,
|
||||||
ClientId = ClientId,
|
ClientId = ClientId,
|
||||||
|
ClientFirstName = Client.FirstName,
|
||||||
|
ClientLastName = Client.LastName,
|
||||||
Price = Price,
|
Price = Price,
|
||||||
Date = Date,
|
Date = Date,
|
||||||
};
|
};
|
||||||
|
@ -17,7 +17,7 @@ namespace RestaurantDatabaseImplement.Models
|
|||||||
public string Type { get; private set; } = string.Empty;
|
public string Type { get; private set; } = string.Empty;
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public int Price { get; private set; }
|
public double Price { get; private set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
|
113
Restaurant/RestaurantView/FormComponent.Designer.cs
generated
113
Restaurant/RestaurantView/FormComponent.Designer.cs
generated
@ -37,14 +37,14 @@
|
|||||||
this.textBoxPrice = new System.Windows.Forms.TextBox();
|
this.textBoxPrice = new System.Windows.Forms.TextBox();
|
||||||
this.textBoxCount = new System.Windows.Forms.TextBox();
|
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||||
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
|
||||||
this.buttonAdd = new System.Windows.Forms.Button();
|
|
||||||
this.buttonDel = new System.Windows.Forms.Button();
|
|
||||||
this.buttonUpd = new System.Windows.Forms.Button();
|
|
||||||
this.buttonRef = new System.Windows.Forms.Button();
|
this.buttonRef = new System.Windows.Forms.Button();
|
||||||
this.Id = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
this.buttonUpd = new System.Windows.Forms.Button();
|
||||||
this.Provider = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
this.buttonDel = new System.Windows.Forms.Button();
|
||||||
|
this.buttonAdd = new System.Windows.Forms.Button();
|
||||||
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
this.Identificator = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.Provider = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
this.groupBox1.SuspendLayout();
|
this.groupBox1.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
@ -104,7 +104,6 @@
|
|||||||
//
|
//
|
||||||
// textBoxPrice
|
// textBoxPrice
|
||||||
//
|
//
|
||||||
this.textBoxPrice.Enabled = false;
|
|
||||||
this.textBoxPrice.Location = new System.Drawing.Point(98, 65);
|
this.textBoxPrice.Location = new System.Drawing.Point(98, 65);
|
||||||
this.textBoxPrice.Name = "textBoxPrice";
|
this.textBoxPrice.Name = "textBoxPrice";
|
||||||
this.textBoxPrice.Size = new System.Drawing.Size(295, 23);
|
this.textBoxPrice.Size = new System.Drawing.Size(295, 23);
|
||||||
@ -112,6 +111,7 @@
|
|||||||
//
|
//
|
||||||
// textBoxCount
|
// textBoxCount
|
||||||
//
|
//
|
||||||
|
this.textBoxCount.Enabled = false;
|
||||||
this.textBoxCount.Location = new System.Drawing.Point(98, 110);
|
this.textBoxCount.Location = new System.Drawing.Point(98, 110);
|
||||||
this.textBoxCount.Name = "textBoxCount";
|
this.textBoxCount.Name = "textBoxCount";
|
||||||
this.textBoxCount.Size = new System.Drawing.Size(295, 23);
|
this.textBoxCount.Size = new System.Drawing.Size(295, 23);
|
||||||
@ -131,18 +131,35 @@
|
|||||||
this.groupBox1.TabStop = false;
|
this.groupBox1.TabStop = false;
|
||||||
this.groupBox1.Text = "Поставщики";
|
this.groupBox1.Text = "Поставщики";
|
||||||
//
|
//
|
||||||
// dataGridView1
|
// buttonRef
|
||||||
//
|
//
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
this.buttonRef.Location = new System.Drawing.Point(512, 194);
|
||||||
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
this.buttonRef.Name = "buttonRef";
|
||||||
this.Id,
|
this.buttonRef.Size = new System.Drawing.Size(75, 23);
|
||||||
this.Provider,
|
this.buttonRef.TabIndex = 4;
|
||||||
this.Count});
|
this.buttonRef.Text = "Обновить";
|
||||||
this.dataGridView.Location = new System.Drawing.Point(6, 22);
|
this.buttonRef.UseVisualStyleBackColor = true;
|
||||||
this.dataGridView.Name = "dataGridView1";
|
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||||
this.dataGridView.RowTemplate.Height = 25;
|
//
|
||||||
this.dataGridView.Size = new System.Drawing.Size(466, 251);
|
// buttonUpd
|
||||||
this.dataGridView.TabIndex = 0;
|
//
|
||||||
|
this.buttonUpd.Location = new System.Drawing.Point(512, 136);
|
||||||
|
this.buttonUpd.Name = "buttonUpd";
|
||||||
|
this.buttonUpd.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonUpd.TabIndex = 3;
|
||||||
|
this.buttonUpd.Text = "Изменить";
|
||||||
|
this.buttonUpd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
this.buttonDel.Location = new System.Drawing.Point(512, 79);
|
||||||
|
this.buttonDel.Name = "buttonDel";
|
||||||
|
this.buttonDel.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonDel.TabIndex = 2;
|
||||||
|
this.buttonDel.Text = "Удалить";
|
||||||
|
this.buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
|
||||||
//
|
//
|
||||||
// buttonAdd
|
// buttonAdd
|
||||||
//
|
//
|
||||||
@ -154,44 +171,24 @@
|
|||||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
||||||
//
|
//
|
||||||
// buttonDel
|
// dataGridView
|
||||||
//
|
//
|
||||||
this.buttonDel.Location = new System.Drawing.Point(512, 79);
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
this.buttonDel.Name = "buttonDel";
|
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||||
this.buttonDel.Size = new System.Drawing.Size(75, 23);
|
this.Identificator,
|
||||||
this.buttonDel.TabIndex = 2;
|
this.Count,
|
||||||
this.buttonDel.Text = "Удалить";
|
this.Provider});
|
||||||
this.buttonDel.UseVisualStyleBackColor = true;
|
this.dataGridView.Location = new System.Drawing.Point(6, 22);
|
||||||
|
this.dataGridView.Name = "dataGridView";
|
||||||
|
this.dataGridView.RowTemplate.Height = 25;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(466, 251);
|
||||||
|
this.dataGridView.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// buttonUpd
|
// Identificator
|
||||||
//
|
//
|
||||||
this.buttonUpd.Location = new System.Drawing.Point(512, 136);
|
this.Identificator.HeaderText = "Identificator";
|
||||||
this.buttonUpd.Name = "buttonUpd";
|
this.Identificator.Name = "Identificator";
|
||||||
this.buttonUpd.Size = new System.Drawing.Size(75, 23);
|
this.Identificator.Visible = false;
|
||||||
this.buttonUpd.TabIndex = 3;
|
|
||||||
this.buttonUpd.Text = "Изменить";
|
|
||||||
this.buttonUpd.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// buttonRef
|
|
||||||
//
|
|
||||||
this.buttonRef.Location = new System.Drawing.Point(512, 194);
|
|
||||||
this.buttonRef.Name = "buttonRef";
|
|
||||||
this.buttonRef.Size = new System.Drawing.Size(75, 23);
|
|
||||||
this.buttonRef.TabIndex = 4;
|
|
||||||
this.buttonRef.Text = "Обновить";
|
|
||||||
this.buttonRef.UseVisualStyleBackColor = true;
|
|
||||||
//
|
|
||||||
// Id
|
|
||||||
//
|
|
||||||
this.Id.HeaderText = "Id";
|
|
||||||
this.Id.Name = "Id";
|
|
||||||
this.Id.Visible = false;
|
|
||||||
//
|
|
||||||
// Provider
|
|
||||||
//
|
|
||||||
this.Provider.HeaderText = "Поставщик";
|
|
||||||
this.Provider.Name = "Provider";
|
|
||||||
this.Provider.Width = 200;
|
|
||||||
//
|
//
|
||||||
// Count
|
// Count
|
||||||
//
|
//
|
||||||
@ -199,6 +196,12 @@
|
|||||||
this.Count.Name = "Count";
|
this.Count.Name = "Count";
|
||||||
this.Count.Width = 200;
|
this.Count.Width = 200;
|
||||||
//
|
//
|
||||||
|
// Provider
|
||||||
|
//
|
||||||
|
this.Provider.HeaderText = "Поставщик";
|
||||||
|
this.Provider.Name = "Provider";
|
||||||
|
this.Provider.Width = 200;
|
||||||
|
//
|
||||||
// FormComponent
|
// FormComponent
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
@ -239,8 +242,8 @@
|
|||||||
private Button buttonDel;
|
private Button buttonDel;
|
||||||
private Button buttonAdd;
|
private Button buttonAdd;
|
||||||
private DataGridView dataGridView;
|
private DataGridView dataGridView;
|
||||||
private DataGridViewTextBoxColumn Id;
|
private DataGridViewTextBoxColumn Identificator;
|
||||||
private DataGridViewTextBoxColumn Provider;
|
|
||||||
private DataGridViewTextBoxColumn Count;
|
private DataGridViewTextBoxColumn Count;
|
||||||
|
private DataGridViewTextBoxColumn Provider;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -18,14 +18,14 @@ namespace RestaurantView
|
|||||||
public partial class FormComponent : Form
|
public partial class FormComponent : Form
|
||||||
{
|
{
|
||||||
private readonly IComponentLogic _componentLogic;
|
private readonly IComponentLogic _componentLogic;
|
||||||
private Dictionary<int, (IProviderModel, int, DateTime)> _componentProviders;
|
private List<(IProviderModel, int, DateTime)> _componentProviders;
|
||||||
private int? _id;
|
private int? _id;
|
||||||
public int Id { set { _id = value; } }
|
public int Id { set { _id = value; } }
|
||||||
public FormComponent(IComponentLogic componentLogic)
|
public FormComponent(IComponentLogic componentLogic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_componentLogic = componentLogic;
|
_componentLogic = componentLogic;
|
||||||
_componentProviders = new Dictionary<int, (IProviderModel, int, DateTime)>();
|
_componentProviders = new List<(IProviderModel, int, DateTime)>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FormComponent_Load(object sender, EventArgs e)
|
private void FormComponent_Load(object sender, EventArgs e)
|
||||||
@ -43,7 +43,7 @@ namespace RestaurantView
|
|||||||
textBoxName.Text = view.Name;
|
textBoxName.Text = view.Name;
|
||||||
textBoxPrice.Text = view.Price.ToString();
|
textBoxPrice.Text = view.Price.ToString();
|
||||||
textBoxCount.Text = view.Count.ToString();
|
textBoxCount.Text = view.Count.ToString();
|
||||||
_componentProviders = view.ComponentProviders ?? new Dictionary<int, (IProviderModel, int, DateTime)>();
|
_componentProviders = view.ComponentProviders ?? new List<(IProviderModel, int, DateTime)>();
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -88,7 +88,71 @@ namespace RestaurantView
|
|||||||
|
|
||||||
private void buttonAdd_Click(object sender, EventArgs e)
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormComponentProvider));
|
||||||
|
if (service is FormComponentProvider form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (form.ProviderModel == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_componentProviders.Add((form.ProviderModel, form.Count, form.Date));
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service =
|
||||||
|
Program.ServiceProvider?.GetService(typeof(FormComponentProvider));
|
||||||
|
if (service is FormComponentProvider form)
|
||||||
|
{
|
||||||
|
int id =
|
||||||
|
Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||||
|
form.Id = id;
|
||||||
|
form.Count = _componentProviders[id].Item2;
|
||||||
|
form.Date = _componentProviders[id].Item3;
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (form.ProviderModel == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_componentProviders[form.Id] = (form.ProviderModel, form.Count, form.Date);
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonDel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос",
|
||||||
|
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_componentProviders?.Remove(((IProviderModel, int, DateTime))dataGridView.SelectedRows[0].Cells[0].Value);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonRef_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LoadData()
|
private void LoadData()
|
||||||
@ -100,8 +164,9 @@ namespace RestaurantView
|
|||||||
dataGridView.Rows.Clear();
|
dataGridView.Rows.Clear();
|
||||||
foreach (var pc in _componentProviders)
|
foreach (var pc in _componentProviders)
|
||||||
{
|
{
|
||||||
dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.Name, pc.Value.Item2, pc.Value.Item3 });
|
dataGridView.Rows.Add(new object[] { pc.Item1.Name, pc.Item2, pc.Item3 });
|
||||||
}
|
}
|
||||||
|
textBoxCount.Text = CalcCount().ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -110,5 +175,15 @@ namespace RestaurantView
|
|||||||
MessageBoxIcon.Error);
|
MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private double CalcCount()
|
||||||
|
{
|
||||||
|
double count = 0;
|
||||||
|
foreach (var elem in _componentProviders)
|
||||||
|
{
|
||||||
|
count += elem.Item2;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,22 +57,13 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<metadata name="Id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="Identificator.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="Provider.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="Count.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="Count.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="Id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
<metadata name="Provider.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
<metadata name="Provider.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
<value>True</value>
|
<value>True</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<metadata name="Count.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
|
||||||
<value>True</value>
|
|
||||||
</metadata>
|
|
||||||
</root>
|
</root>
|
@ -28,12 +28,114 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private void InitializeComponent()
|
private void InitializeComponent()
|
||||||
{
|
{
|
||||||
this.components = new System.ComponentModel.Container();
|
this.comboBoxProviders = new System.Windows.Forms.ComboBox();
|
||||||
|
this.labelProviders = new System.Windows.Forms.Label();
|
||||||
|
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||||
|
this.labelCount = new System.Windows.Forms.Label();
|
||||||
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.dateTimePicker = new System.Windows.Forms.DateTimePicker();
|
||||||
|
this.labelDate = new System.Windows.Forms.Label();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// comboBoxProviders
|
||||||
|
//
|
||||||
|
this.comboBoxProviders.FormattingEnabled = true;
|
||||||
|
this.comboBoxProviders.Location = new System.Drawing.Point(91, 33);
|
||||||
|
this.comboBoxProviders.Name = "comboBoxProviders";
|
||||||
|
this.comboBoxProviders.Size = new System.Drawing.Size(219, 23);
|
||||||
|
this.comboBoxProviders.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// labelProviders
|
||||||
|
//
|
||||||
|
this.labelProviders.AutoSize = true;
|
||||||
|
this.labelProviders.Location = new System.Drawing.Point(12, 36);
|
||||||
|
this.labelProviders.Name = "labelProviders";
|
||||||
|
this.labelProviders.Size = new System.Drawing.Size(73, 15);
|
||||||
|
this.labelProviders.TabIndex = 1;
|
||||||
|
this.labelProviders.Text = "Поставщик:";
|
||||||
|
//
|
||||||
|
// textBoxCount
|
||||||
|
//
|
||||||
|
this.textBoxCount.Location = new System.Drawing.Point(91, 75);
|
||||||
|
this.textBoxCount.Name = "textBoxCount";
|
||||||
|
this.textBoxCount.Size = new System.Drawing.Size(219, 23);
|
||||||
|
this.textBoxCount.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// labelCount
|
||||||
|
//
|
||||||
|
this.labelCount.AutoSize = true;
|
||||||
|
this.labelCount.Location = new System.Drawing.Point(10, 78);
|
||||||
|
this.labelCount.Name = "labelCount";
|
||||||
|
this.labelCount.Size = new System.Drawing.Size(75, 15);
|
||||||
|
this.labelCount.TabIndex = 3;
|
||||||
|
this.labelCount.Text = "Количество:";
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
this.buttonSave.Location = new System.Drawing.Point(65, 157);
|
||||||
|
this.buttonSave.Name = "buttonSave";
|
||||||
|
this.buttonSave.Size = new System.Drawing.Size(75, 23);
|
||||||
|
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(176, 157);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonCancel.TabIndex = 5;
|
||||||
|
this.buttonCancel.Text = "Отменить";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||||
|
//
|
||||||
|
// dateTimePicker
|
||||||
|
//
|
||||||
|
this.dateTimePicker.Location = new System.Drawing.Point(91, 115);
|
||||||
|
this.dateTimePicker.Name = "dateTimePicker";
|
||||||
|
this.dateTimePicker.Size = new System.Drawing.Size(219, 23);
|
||||||
|
this.dateTimePicker.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// labelDate
|
||||||
|
//
|
||||||
|
this.labelDate.AutoSize = true;
|
||||||
|
this.labelDate.Location = new System.Drawing.Point(50, 115);
|
||||||
|
this.labelDate.Name = "labelDate";
|
||||||
|
this.labelDate.Size = new System.Drawing.Size(35, 15);
|
||||||
|
this.labelDate.TabIndex = 7;
|
||||||
|
this.labelDate.Text = "Дата:";
|
||||||
|
//
|
||||||
|
// FormComponentProvider
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
this.ClientSize = new System.Drawing.Size(322, 206);
|
||||||
|
this.Controls.Add(this.labelDate);
|
||||||
|
this.Controls.Add(this.dateTimePicker);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.buttonSave);
|
||||||
|
this.Controls.Add(this.labelCount);
|
||||||
|
this.Controls.Add(this.textBoxCount);
|
||||||
|
this.Controls.Add(this.labelProviders);
|
||||||
|
this.Controls.Add(this.comboBoxProviders);
|
||||||
|
this.Name = "FormComponentProvider";
|
||||||
this.Text = "FormComponentProvider";
|
this.Text = "FormComponentProvider";
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
private ComboBox comboBoxProviders;
|
||||||
|
private Label labelProviders;
|
||||||
|
private TextBox textBoxCount;
|
||||||
|
private Label labelCount;
|
||||||
|
private Button buttonSave;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private DateTimePicker dateTimePicker;
|
||||||
|
private Label labelDate;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -21,11 +21,11 @@ namespace RestaurantView
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return Convert.ToInt32(comboBoxComponent.SelectedValue);
|
return Convert.ToInt32(comboBoxProviders.SelectedValue);
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
comboBoxComponent.SelectedValue = value;
|
comboBoxProviders.SelectedValue = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -52,16 +52,23 @@ namespace RestaurantView
|
|||||||
get { return Convert.ToInt32(textBoxCount.Text); }
|
get { return Convert.ToInt32(textBoxCount.Text); }
|
||||||
set { textBoxCount.Text = value.ToString(); }
|
set { textBoxCount.Text = value.ToString(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DateTime Date
|
||||||
|
{
|
||||||
|
get { return DateTime.Now; }
|
||||||
|
set { dateTimePicker.Value = value; }
|
||||||
|
}
|
||||||
|
|
||||||
public FormComponentProvider(IProviderLogic logic)
|
public FormComponentProvider(IProviderLogic logic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_list = logic.ReadList(null);
|
_list = logic.ReadList(null);
|
||||||
if (_list != null)
|
if (_list != null)
|
||||||
{
|
{
|
||||||
comboBoxProvider.DisplayMember = "ComponentName";
|
comboBoxProviders.DisplayMember = "Name";
|
||||||
comboBoxProvider.ValueMember = "Id";
|
comboBoxProviders.ValueMember = "Id";
|
||||||
comboBoxProvider.DataSource = _list;
|
comboBoxProviders.DataSource = _list;
|
||||||
comboBoxProvider.SelectedItem = null;
|
comboBoxProviders.SelectedItem = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +80,7 @@ namespace RestaurantView
|
|||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (comboBoxComponent.SelectedValue == null)
|
if (comboBoxProviders.SelectedValue == null)
|
||||||
{
|
{
|
||||||
MessageBox.Show("Выберите компонент", "Ошибка",
|
MessageBox.Show("Выберите компонент", "Ошибка",
|
||||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
@ -1,64 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<root>
|
||||||
<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">
|
||||||
|
226
Restaurant/RestaurantView/FormCreateOrder.Designer.cs
generated
Normal file
226
Restaurant/RestaurantView/FormCreateOrder.Designer.cs
generated
Normal file
@ -0,0 +1,226 @@
|
|||||||
|
namespace RestaurantView
|
||||||
|
{
|
||||||
|
partial class FormCreateOrder
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.labelPrice = new System.Windows.Forms.Label();
|
||||||
|
this.labelClient = new System.Windows.Forms.Label();
|
||||||
|
this.comboBoxClients = new System.Windows.Forms.ComboBox();
|
||||||
|
this.textBoxPrice = new System.Windows.Forms.TextBox();
|
||||||
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||||
|
this.buttonRef = new System.Windows.Forms.Button();
|
||||||
|
this.buttonDel = new System.Windows.Forms.Button();
|
||||||
|
this.buttonUpd = new System.Windows.Forms.Button();
|
||||||
|
this.buttonAdd = new System.Windows.Forms.Button();
|
||||||
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
this.Identificator = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.Product = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.groupBox1.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelPrice
|
||||||
|
//
|
||||||
|
this.labelPrice.AutoSize = true;
|
||||||
|
this.labelPrice.Location = new System.Drawing.Point(44, 21);
|
||||||
|
this.labelPrice.Name = "labelPrice";
|
||||||
|
this.labelPrice.Size = new System.Drawing.Size(38, 15);
|
||||||
|
this.labelPrice.TabIndex = 2;
|
||||||
|
this.labelPrice.Text = "Цена:";
|
||||||
|
//
|
||||||
|
// labelClient
|
||||||
|
//
|
||||||
|
this.labelClient.AutoSize = true;
|
||||||
|
this.labelClient.Location = new System.Drawing.Point(33, 55);
|
||||||
|
this.labelClient.Name = "labelClient";
|
||||||
|
this.labelClient.Size = new System.Drawing.Size(49, 15);
|
||||||
|
this.labelClient.TabIndex = 3;
|
||||||
|
this.labelClient.Text = "Клиент:";
|
||||||
|
//
|
||||||
|
// comboBoxClients
|
||||||
|
//
|
||||||
|
this.comboBoxClients.FormattingEnabled = true;
|
||||||
|
this.comboBoxClients.Location = new System.Drawing.Point(88, 52);
|
||||||
|
this.comboBoxClients.Name = "comboBoxClients";
|
||||||
|
this.comboBoxClients.Size = new System.Drawing.Size(254, 23);
|
||||||
|
this.comboBoxClients.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// textBoxPrice
|
||||||
|
//
|
||||||
|
this.textBoxPrice.Enabled = false;
|
||||||
|
this.textBoxPrice.Location = new System.Drawing.Point(88, 18);
|
||||||
|
this.textBoxPrice.Name = "textBoxPrice";
|
||||||
|
this.textBoxPrice.Size = new System.Drawing.Size(254, 23);
|
||||||
|
this.textBoxPrice.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
this.buttonSave.Location = new System.Drawing.Point(195, 345);
|
||||||
|
this.buttonSave.Name = "buttonSave";
|
||||||
|
this.buttonSave.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonSave.TabIndex = 8;
|
||||||
|
this.buttonSave.Text = "Сохранить";
|
||||||
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(308, 345);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonCancel.TabIndex = 9;
|
||||||
|
this.buttonCancel.Text = "Отменить";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
this.groupBox1.Controls.Add(this.buttonRef);
|
||||||
|
this.groupBox1.Controls.Add(this.buttonDel);
|
||||||
|
this.groupBox1.Controls.Add(this.buttonUpd);
|
||||||
|
this.groupBox1.Controls.Add(this.buttonAdd);
|
||||||
|
this.groupBox1.Controls.Add(this.dataGridView);
|
||||||
|
this.groupBox1.Location = new System.Drawing.Point(12, 94);
|
||||||
|
this.groupBox1.Name = "groupBox1";
|
||||||
|
this.groupBox1.Size = new System.Drawing.Size(555, 234);
|
||||||
|
this.groupBox1.TabIndex = 10;
|
||||||
|
this.groupBox1.TabStop = false;
|
||||||
|
this.groupBox1.Text = "Продукты";
|
||||||
|
//
|
||||||
|
// buttonRef
|
||||||
|
//
|
||||||
|
this.buttonRef.Location = new System.Drawing.Point(464, 168);
|
||||||
|
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);
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
this.buttonDel.Location = new System.Drawing.Point(464, 122);
|
||||||
|
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);
|
||||||
|
//
|
||||||
|
// buttonUpd
|
||||||
|
//
|
||||||
|
this.buttonUpd.Location = new System.Drawing.Point(464, 76);
|
||||||
|
this.buttonUpd.Name = "buttonUpd";
|
||||||
|
this.buttonUpd.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonUpd.TabIndex = 2;
|
||||||
|
this.buttonUpd.Text = "Изменить";
|
||||||
|
this.buttonUpd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
this.buttonAdd.Location = new System.Drawing.Point(464, 33);
|
||||||
|
this.buttonAdd.Name = "buttonAdd";
|
||||||
|
this.buttonAdd.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonAdd.TabIndex = 1;
|
||||||
|
this.buttonAdd.Text = "Добавить";
|
||||||
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||||
|
this.Identificator,
|
||||||
|
this.Product,
|
||||||
|
this.Count});
|
||||||
|
this.dataGridView.Location = new System.Drawing.Point(6, 22);
|
||||||
|
this.dataGridView.Name = "dataGridView";
|
||||||
|
this.dataGridView.RowTemplate.Height = 25;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(447, 206);
|
||||||
|
this.dataGridView.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// Identificator
|
||||||
|
//
|
||||||
|
this.Identificator.HeaderText = "Id";
|
||||||
|
this.Identificator.Name = "Identificator";
|
||||||
|
this.Identificator.Visible = false;
|
||||||
|
//
|
||||||
|
// Product
|
||||||
|
//
|
||||||
|
this.Product.HeaderText = "Продукт";
|
||||||
|
this.Product.Name = "Product";
|
||||||
|
//
|
||||||
|
// Count
|
||||||
|
//
|
||||||
|
this.Count.HeaderText = "Количество";
|
||||||
|
this.Count.Name = "Count";
|
||||||
|
//
|
||||||
|
// FormCreateOrder
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(579, 382);
|
||||||
|
this.Controls.Add(this.groupBox1);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.buttonSave);
|
||||||
|
this.Controls.Add(this.textBoxPrice);
|
||||||
|
this.Controls.Add(this.comboBoxClients);
|
||||||
|
this.Controls.Add(this.labelClient);
|
||||||
|
this.Controls.Add(this.labelPrice);
|
||||||
|
this.Name = "FormCreateOrder";
|
||||||
|
this.Text = "Заказ";
|
||||||
|
this.Load += new System.EventHandler(this.FormCreateOrder_Load);
|
||||||
|
this.groupBox1.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
private Label labelPrice;
|
||||||
|
private Label labelClient;
|
||||||
|
private ComboBox comboBoxClients;
|
||||||
|
private TextBox textBoxPrice;
|
||||||
|
private Button buttonSave;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private GroupBox groupBox1;
|
||||||
|
private Button buttonRef;
|
||||||
|
private Button buttonDel;
|
||||||
|
private Button buttonUpd;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private DataGridViewTextBoxColumn Identificator;
|
||||||
|
private DataGridViewTextBoxColumn Product;
|
||||||
|
private DataGridViewTextBoxColumn Count;
|
||||||
|
}
|
||||||
|
}
|
212
Restaurant/RestaurantView/FormCreateOrder.cs
Normal file
212
Restaurant/RestaurantView/FormCreateOrder.cs
Normal file
@ -0,0 +1,212 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using RestaurantContracts.BindingModels;
|
||||||
|
using RestaurantContracts.BusinessLogicsContracts;
|
||||||
|
using RestaurantContracts.SearchModels;
|
||||||
|
using RestaurantDatabaseImplement.Models;
|
||||||
|
using RestaurantDataModels.Models;
|
||||||
|
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 RestaurantView
|
||||||
|
{
|
||||||
|
public partial class FormCreateOrder : Form
|
||||||
|
{
|
||||||
|
private readonly IProductLogic _logicP;
|
||||||
|
private readonly IOrderLogic _logicO;
|
||||||
|
private readonly IClientLogic _logicC;
|
||||||
|
private int? _id;
|
||||||
|
private Dictionary<int, (IProductModel, int)> _orderProducts;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
|
||||||
|
public FormCreateOrder(IProductLogic logicP, IOrderLogic logicO, IClientLogic logicC)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logicP = logicP;
|
||||||
|
_logicO = logicO;
|
||||||
|
_logicC = logicC;
|
||||||
|
_orderProducts = new Dictionary<int, (IProductModel, int)>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormCreateOrder_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var clients = _logicC.ReadList(null);
|
||||||
|
if (clients != null)
|
||||||
|
{
|
||||||
|
comboBoxClients.DisplayMember = "FirstName";
|
||||||
|
comboBoxClients.ValueMember = "Id";
|
||||||
|
comboBoxClients.DataSource = clients;
|
||||||
|
comboBoxClients.SelectedItem = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private double CalcPrice()
|
||||||
|
{
|
||||||
|
double price = 0;
|
||||||
|
foreach (var elem in _orderProducts)
|
||||||
|
{
|
||||||
|
price += elem.Value.Item1.Price * elem.Value.Item2;
|
||||||
|
}
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxPrice.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_orderProducts == null || _orderProducts.Count == 0)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните компоненты", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = new OrderBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
Price = Convert.ToDouble(textBoxPrice.Text),
|
||||||
|
ClientId = Convert.ToInt32(comboBoxClients.SelectedValue),
|
||||||
|
Date = DateTime.SpecifyKind(DateTime.Now, DateTimeKind.Utc),
|
||||||
|
OrderProducts = _orderProducts
|
||||||
|
};
|
||||||
|
var operationResult = _id.HasValue ? _logicO.Update(model) :
|
||||||
|
_logicO.Create(model);
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_orderProducts != null)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Clear();
|
||||||
|
foreach (var pc in _orderProducts)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.Type, pc.Value.Item2 });
|
||||||
|
}
|
||||||
|
textBoxPrice.Text = CalcPrice().ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormOrderProduct));
|
||||||
|
if (service is FormOrderProduct form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (form.ProductModel == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_orderProducts.ContainsKey(form.Id))
|
||||||
|
{
|
||||||
|
_orderProducts[form.Id] = (form.ProductModel, form.Count);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_orderProducts.Add(form.Id, (form.ProductModel, form.Count));
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service =
|
||||||
|
Program.ServiceProvider?.GetService(typeof(FormOrderProduct));
|
||||||
|
if (service is FormOrderProduct form)
|
||||||
|
{
|
||||||
|
int id =
|
||||||
|
Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||||
|
form.Id = id;
|
||||||
|
form.Count = _orderProducts[id].Item2;
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (form.ProductModel == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_orderProducts[form.Id] = (form.ProductModel, form.Count);
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonDel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос",
|
||||||
|
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_orderProducts?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonRef_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
69
Restaurant/RestaurantView/FormCreateOrder.resx
Normal file
69
Restaurant/RestaurantView/FormCreateOrder.resx
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="Identificator.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="Product.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="Count.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
26
Restaurant/RestaurantView/FormMain.Designer.cs
generated
26
Restaurant/RestaurantView/FormMain.Designer.cs
generated
@ -34,6 +34,8 @@
|
|||||||
this.ClientsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.ClientsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.ProvidersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.ProvidersToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
this.ComponentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
this.ComponentsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.ProductsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||||
|
this.buttonUpd = new System.Windows.Forms.Button();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
this.menuStrip1.SuspendLayout();
|
this.menuStrip1.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
@ -55,13 +57,15 @@
|
|||||||
this.buttonAdd.TabIndex = 1;
|
this.buttonAdd.TabIndex = 1;
|
||||||
this.buttonAdd.Text = "Создать заказ";
|
this.buttonAdd.Text = "Создать заказ";
|
||||||
this.buttonAdd.UseVisualStyleBackColor = true;
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAdd.Click += new System.EventHandler(this.buttonAdd_Click);
|
||||||
//
|
//
|
||||||
// menuStrip1
|
// menuStrip1
|
||||||
//
|
//
|
||||||
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
this.menuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||||
this.ClientsToolStripMenuItem,
|
this.ClientsToolStripMenuItem,
|
||||||
this.ProvidersToolStripMenuItem,
|
this.ProvidersToolStripMenuItem,
|
||||||
this.ComponentsToolStripMenuItem});
|
this.ComponentsToolStripMenuItem,
|
||||||
|
this.ProductsToolStripMenuItem});
|
||||||
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
this.menuStrip1.Location = new System.Drawing.Point(0, 0);
|
||||||
this.menuStrip1.Name = "menuStrip1";
|
this.menuStrip1.Name = "menuStrip1";
|
||||||
this.menuStrip1.Size = new System.Drawing.Size(1163, 24);
|
this.menuStrip1.Size = new System.Drawing.Size(1163, 24);
|
||||||
@ -89,11 +93,29 @@
|
|||||||
this.ComponentsToolStripMenuItem.Text = "Компоненты";
|
this.ComponentsToolStripMenuItem.Text = "Компоненты";
|
||||||
this.ComponentsToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click);
|
this.ComponentsToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
|
// ProductsToolStripMenuItem
|
||||||
|
//
|
||||||
|
this.ProductsToolStripMenuItem.Name = "ProductsToolStripMenuItem";
|
||||||
|
this.ProductsToolStripMenuItem.Size = new System.Drawing.Size(74, 20);
|
||||||
|
this.ProductsToolStripMenuItem.Text = "Продукты";
|
||||||
|
this.ProductsToolStripMenuItem.Click += new System.EventHandler(this.ProductsToolStripMenuItem_Click);
|
||||||
|
//
|
||||||
|
// buttonUpd
|
||||||
|
//
|
||||||
|
this.buttonUpd.Location = new System.Drawing.Point(785, 12);
|
||||||
|
this.buttonUpd.Name = "buttonUpd";
|
||||||
|
this.buttonUpd.Size = new System.Drawing.Size(152, 45);
|
||||||
|
this.buttonUpd.TabIndex = 3;
|
||||||
|
this.buttonUpd.Text = "Обновить";
|
||||||
|
this.buttonUpd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUpd.Click += new System.EventHandler(this.buttonUpd_Click);
|
||||||
|
//
|
||||||
// FormMain
|
// FormMain
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(1163, 634);
|
this.ClientSize = new System.Drawing.Size(1163, 634);
|
||||||
|
this.Controls.Add(this.buttonUpd);
|
||||||
this.Controls.Add(this.buttonAdd);
|
this.Controls.Add(this.buttonAdd);
|
||||||
this.Controls.Add(this.dataGridView);
|
this.Controls.Add(this.dataGridView);
|
||||||
this.Controls.Add(this.menuStrip1);
|
this.Controls.Add(this.menuStrip1);
|
||||||
@ -117,5 +139,7 @@
|
|||||||
private ToolStripMenuItem ClientsToolStripMenuItem;
|
private ToolStripMenuItem ClientsToolStripMenuItem;
|
||||||
private ToolStripMenuItem ProvidersToolStripMenuItem;
|
private ToolStripMenuItem ProvidersToolStripMenuItem;
|
||||||
private ToolStripMenuItem ComponentsToolStripMenuItem;
|
private ToolStripMenuItem ComponentsToolStripMenuItem;
|
||||||
|
private ToolStripMenuItem ProductsToolStripMenuItem;
|
||||||
|
private Button buttonUpd;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -30,6 +30,7 @@ namespace RestaurantView
|
|||||||
{
|
{
|
||||||
dataGridView.DataSource = list;
|
dataGridView.DataSource = list;
|
||||||
dataGridView.Columns["ClientId"].Visible = false;
|
dataGridView.Columns["ClientId"].Visible = false;
|
||||||
|
dataGridView.Columns["OrderProducts"].Visible = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -69,5 +70,29 @@ namespace RestaurantView
|
|||||||
form.ShowDialog();
|
form.ShowDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ProductsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormProducts));
|
||||||
|
if (service is FormProducts form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
||||||
|
if (service is FormCreateOrder form)
|
||||||
|
{
|
||||||
|
form.ShowDialog();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buttonUpd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
119
Restaurant/RestaurantView/FormOrderProduct.Designer.cs
generated
Normal file
119
Restaurant/RestaurantView/FormOrderProduct.Designer.cs
generated
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
namespace RestaurantView
|
||||||
|
{
|
||||||
|
partial class FormOrderProduct
|
||||||
|
{
|
||||||
|
/// <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.buttonSave = new System.Windows.Forms.Button();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.labelProduct = new System.Windows.Forms.Label();
|
||||||
|
this.labelCount = new System.Windows.Forms.Label();
|
||||||
|
this.comboBoxProduct = new System.Windows.Forms.ComboBox();
|
||||||
|
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
this.buttonSave.Location = new System.Drawing.Point(96, 107);
|
||||||
|
this.buttonSave.Name = "buttonSave";
|
||||||
|
this.buttonSave.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonSave.TabIndex = 0;
|
||||||
|
this.buttonSave.Text = "Сохранитьъ";
|
||||||
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(220, 107);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonCancel.TabIndex = 1;
|
||||||
|
this.buttonCancel.Text = "Отменить";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||||
|
//
|
||||||
|
// labelProduct
|
||||||
|
//
|
||||||
|
this.labelProduct.AutoSize = true;
|
||||||
|
this.labelProduct.Location = new System.Drawing.Point(31, 24);
|
||||||
|
this.labelProduct.Name = "labelProduct";
|
||||||
|
this.labelProduct.Size = new System.Drawing.Size(56, 15);
|
||||||
|
this.labelProduct.TabIndex = 2;
|
||||||
|
this.labelProduct.Text = "Продукт:";
|
||||||
|
//
|
||||||
|
// labelCount
|
||||||
|
//
|
||||||
|
this.labelCount.AutoSize = true;
|
||||||
|
this.labelCount.Location = new System.Drawing.Point(12, 65);
|
||||||
|
this.labelCount.Name = "labelCount";
|
||||||
|
this.labelCount.Size = new System.Drawing.Size(75, 15);
|
||||||
|
this.labelCount.TabIndex = 3;
|
||||||
|
this.labelCount.Text = "Количество:";
|
||||||
|
//
|
||||||
|
// comboBoxProduct
|
||||||
|
//
|
||||||
|
this.comboBoxProduct.FormattingEnabled = true;
|
||||||
|
this.comboBoxProduct.Location = new System.Drawing.Point(93, 21);
|
||||||
|
this.comboBoxProduct.Name = "comboBoxProduct";
|
||||||
|
this.comboBoxProduct.Size = new System.Drawing.Size(245, 23);
|
||||||
|
this.comboBoxProduct.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// textBoxCount
|
||||||
|
//
|
||||||
|
this.textBoxCount.Location = new System.Drawing.Point(92, 62);
|
||||||
|
this.textBoxCount.Name = "textBoxCount";
|
||||||
|
this.textBoxCount.Size = new System.Drawing.Size(246, 23);
|
||||||
|
this.textBoxCount.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// FormOrderProduct
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(391, 147);
|
||||||
|
this.Controls.Add(this.textBoxCount);
|
||||||
|
this.Controls.Add(this.comboBoxProduct);
|
||||||
|
this.Controls.Add(this.labelCount);
|
||||||
|
this.Controls.Add(this.labelProduct);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.buttonSave);
|
||||||
|
this.Name = "FormOrderProduct";
|
||||||
|
this.Text = "FormOrderProduct";
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonSave;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Label labelProduct;
|
||||||
|
private Label labelCount;
|
||||||
|
private ComboBox comboBoxProduct;
|
||||||
|
private TextBox textBoxCount;
|
||||||
|
}
|
||||||
|
}
|
90
Restaurant/RestaurantView/FormOrderProduct.cs
Normal file
90
Restaurant/RestaurantView/FormOrderProduct.cs
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
using RestaurantContracts.BusinessLogicsContracts;
|
||||||
|
using RestaurantContracts.ViewModels;
|
||||||
|
using RestaurantDataModels.Models;
|
||||||
|
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 RestaurantView
|
||||||
|
{
|
||||||
|
public partial class FormOrderProduct : Form
|
||||||
|
{
|
||||||
|
private readonly List<ProductViewModel>? _list;
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Convert.ToInt32(comboBoxProduct.SelectedValue);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
comboBoxProduct.SelectedValue = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public IProductModel? ProductModel
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_list == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
foreach (var elem in _list)
|
||||||
|
{
|
||||||
|
if (elem.Id == Id)
|
||||||
|
{
|
||||||
|
return elem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int Count
|
||||||
|
{
|
||||||
|
get { return Convert.ToInt32(textBoxCount.Text); }
|
||||||
|
set { textBoxCount.Text = value.ToString(); }
|
||||||
|
}
|
||||||
|
public FormOrderProduct(IProductLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_list = logic.ReadList(null);
|
||||||
|
if (_list != null)
|
||||||
|
{
|
||||||
|
comboBoxProduct.DisplayMember = "Type";
|
||||||
|
comboBoxProduct.ValueMember = "Id";
|
||||||
|
comboBoxProduct.DataSource = _list;
|
||||||
|
comboBoxProduct.SelectedItem = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните поле Количество", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (comboBoxProduct.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите продукт", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
Restaurant/RestaurantView/FormOrderProduct.resx
Normal file
60
Restaurant/RestaurantView/FormOrderProduct.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
226
Restaurant/RestaurantView/FormProduct.Designer.cs
generated
Normal file
226
Restaurant/RestaurantView/FormProduct.Designer.cs
generated
Normal file
@ -0,0 +1,226 @@
|
|||||||
|
namespace RestaurantView
|
||||||
|
{
|
||||||
|
partial class FormProduct
|
||||||
|
{
|
||||||
|
/// <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.labelPrice = new System.Windows.Forms.Label();
|
||||||
|
this.textBoxType = new System.Windows.Forms.TextBox();
|
||||||
|
this.textBoxPrice = new System.Windows.Forms.TextBox();
|
||||||
|
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||||
|
this.buttonRef = new System.Windows.Forms.Button();
|
||||||
|
this.buttonUpd = new System.Windows.Forms.Button();
|
||||||
|
this.buttonDel = new System.Windows.Forms.Button();
|
||||||
|
this.buttonAdd = new System.Windows.Forms.Button();
|
||||||
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.Identificator = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.Component = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.groupBox1.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// labelName
|
||||||
|
//
|
||||||
|
this.labelName.AutoSize = true;
|
||||||
|
this.labelName.Location = new System.Drawing.Point(20, 29);
|
||||||
|
this.labelName.Name = "labelName";
|
||||||
|
this.labelName.Size = new System.Drawing.Size(62, 15);
|
||||||
|
this.labelName.TabIndex = 0;
|
||||||
|
this.labelName.Text = "Название:";
|
||||||
|
//
|
||||||
|
// labelPrice
|
||||||
|
//
|
||||||
|
this.labelPrice.AutoSize = true;
|
||||||
|
this.labelPrice.Location = new System.Drawing.Point(44, 70);
|
||||||
|
this.labelPrice.Name = "labelPrice";
|
||||||
|
this.labelPrice.Size = new System.Drawing.Size(38, 15);
|
||||||
|
this.labelPrice.TabIndex = 1;
|
||||||
|
this.labelPrice.Text = "Цена:";
|
||||||
|
//
|
||||||
|
// textBoxType
|
||||||
|
//
|
||||||
|
this.textBoxType.Location = new System.Drawing.Point(88, 26);
|
||||||
|
this.textBoxType.Name = "textBoxType";
|
||||||
|
this.textBoxType.Size = new System.Drawing.Size(429, 23);
|
||||||
|
this.textBoxType.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// textBoxPrice
|
||||||
|
//
|
||||||
|
this.textBoxPrice.Enabled = false;
|
||||||
|
this.textBoxPrice.Location = new System.Drawing.Point(88, 67);
|
||||||
|
this.textBoxPrice.Name = "textBoxPrice";
|
||||||
|
this.textBoxPrice.Size = new System.Drawing.Size(429, 23);
|
||||||
|
this.textBoxPrice.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
this.groupBox1.Controls.Add(this.buttonRef);
|
||||||
|
this.groupBox1.Controls.Add(this.buttonUpd);
|
||||||
|
this.groupBox1.Controls.Add(this.buttonDel);
|
||||||
|
this.groupBox1.Controls.Add(this.buttonAdd);
|
||||||
|
this.groupBox1.Controls.Add(this.dataGridView);
|
||||||
|
this.groupBox1.Location = new System.Drawing.Point(20, 124);
|
||||||
|
this.groupBox1.Name = "groupBox1";
|
||||||
|
this.groupBox1.Size = new System.Drawing.Size(643, 281);
|
||||||
|
this.groupBox1.TabIndex = 4;
|
||||||
|
this.groupBox1.TabStop = false;
|
||||||
|
this.groupBox1.Text = "Поставщики";
|
||||||
|
//
|
||||||
|
// buttonRef
|
||||||
|
//
|
||||||
|
this.buttonRef.Location = new System.Drawing.Point(531, 184);
|
||||||
|
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);
|
||||||
|
//
|
||||||
|
// buttonUpd
|
||||||
|
//
|
||||||
|
this.buttonUpd.Location = new System.Drawing.Point(531, 84);
|
||||||
|
this.buttonUpd.Name = "buttonUpd";
|
||||||
|
this.buttonUpd.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonUpd.TabIndex = 3;
|
||||||
|
this.buttonUpd.Text = "Изменить";
|
||||||
|
this.buttonUpd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
this.buttonDel.Location = new System.Drawing.Point(531, 132);
|
||||||
|
this.buttonDel.Name = "buttonDel";
|
||||||
|
this.buttonDel.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonDel.TabIndex = 2;
|
||||||
|
this.buttonDel.Text = "Удалить";
|
||||||
|
this.buttonDel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonDel.Click += new System.EventHandler(this.ButtonDel_Click);
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
this.buttonAdd.Location = new System.Drawing.Point(531, 36);
|
||||||
|
this.buttonAdd.Name = "buttonAdd";
|
||||||
|
this.buttonAdd.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonAdd.TabIndex = 1;
|
||||||
|
this.buttonAdd.Text = "Добавить";
|
||||||
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||||
|
//
|
||||||
|
// dataGridView
|
||||||
|
//
|
||||||
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||||
|
this.Identificator,
|
||||||
|
this.Component,
|
||||||
|
this.Count});
|
||||||
|
this.dataGridView.Location = new System.Drawing.Point(6, 22);
|
||||||
|
this.dataGridView.Name = "dataGridView";
|
||||||
|
this.dataGridView.RowTemplate.Height = 25;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(491, 253);
|
||||||
|
this.dataGridView.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
this.buttonSave.Location = new System.Drawing.Point(217, 423);
|
||||||
|
this.buttonSave.Name = "buttonSave";
|
||||||
|
this.buttonSave.Size = new System.Drawing.Size(87, 32);
|
||||||
|
this.buttonSave.TabIndex = 5;
|
||||||
|
this.buttonSave.Text = "Сохранить";
|
||||||
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(376, 423);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(77, 32);
|
||||||
|
this.buttonCancel.TabIndex = 6;
|
||||||
|
this.buttonCancel.Text = "Отменить";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||||
|
//
|
||||||
|
// Identificator
|
||||||
|
//
|
||||||
|
this.Identificator.HeaderText = "Id";
|
||||||
|
this.Identificator.Name = "Identificator";
|
||||||
|
this.Identificator.Visible = false;
|
||||||
|
//
|
||||||
|
// Component
|
||||||
|
//
|
||||||
|
this.Component.HeaderText = "Компонент";
|
||||||
|
this.Component.Name = "Component";
|
||||||
|
//
|
||||||
|
// Count
|
||||||
|
//
|
||||||
|
this.Count.HeaderText = "Количество";
|
||||||
|
this.Count.Name = "Count";
|
||||||
|
//
|
||||||
|
// FormProduct
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(692, 472);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.buttonSave);
|
||||||
|
this.Controls.Add(this.groupBox1);
|
||||||
|
this.Controls.Add(this.textBoxPrice);
|
||||||
|
this.Controls.Add(this.textBoxType);
|
||||||
|
this.Controls.Add(this.labelPrice);
|
||||||
|
this.Controls.Add(this.labelName);
|
||||||
|
this.Name = "FormProduct";
|
||||||
|
this.Text = "Продукт";
|
||||||
|
this.Load += new System.EventHandler(this.FormProduct_Load);
|
||||||
|
this.groupBox1.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label labelName;
|
||||||
|
private Label labelPrice;
|
||||||
|
private TextBox textBoxType;
|
||||||
|
private TextBox textBoxPrice;
|
||||||
|
private GroupBox groupBox1;
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private Button buttonRef;
|
||||||
|
private Button buttonUpd;
|
||||||
|
private Button buttonDel;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Button buttonSave;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private DataGridViewTextBoxColumn Identificator;
|
||||||
|
private DataGridViewTextBoxColumn Component;
|
||||||
|
private DataGridViewTextBoxColumn Count;
|
||||||
|
}
|
||||||
|
}
|
221
Restaurant/RestaurantView/FormProduct.cs
Normal file
221
Restaurant/RestaurantView/FormProduct.cs
Normal file
@ -0,0 +1,221 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using RestaurantContracts.BindingModels;
|
||||||
|
using RestaurantContracts.BusinessLogicsContracts;
|
||||||
|
using RestaurantContracts.SearchModels;
|
||||||
|
using RestaurantContracts.ViewModels;
|
||||||
|
using RestaurantDataModels.Models;
|
||||||
|
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 RestaurantView
|
||||||
|
{
|
||||||
|
public partial class FormProduct : Form
|
||||||
|
{
|
||||||
|
private readonly IProductLogic _logic;
|
||||||
|
private int? _id;
|
||||||
|
private Dictionary<int, (IComponentModel, int)> _productComponents;
|
||||||
|
public int Id { set { _id = value; } }
|
||||||
|
|
||||||
|
public FormProduct(IProductLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logic = logic;
|
||||||
|
_productComponents = new Dictionary<int, (IComponentModel, int)>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormProduct_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_id.HasValue)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var view = _logic.ReadElement(new ProductSearchModel
|
||||||
|
{
|
||||||
|
Id = _id.Value
|
||||||
|
});
|
||||||
|
if (view != null)
|
||||||
|
{
|
||||||
|
textBoxType.Text = view.Type;
|
||||||
|
textBoxPrice.Text = view.Price.ToString();
|
||||||
|
_productComponents = view.ProductComponents ?? new Dictionary<int, (IComponentModel, int)>();
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (_productComponents != null)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Clear();
|
||||||
|
foreach (var pc in _productComponents)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Add(new object[] { pc.Key, pc.Value.Item1.Name, pc.Value.Item2 });
|
||||||
|
}
|
||||||
|
textBoxPrice.Text = CalcPrice().ToString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormProductComponent));
|
||||||
|
if (service is FormProductComponent form)
|
||||||
|
{
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (form.ComponentModel == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_productComponents.ContainsKey(form.Id))
|
||||||
|
{
|
||||||
|
_productComponents[form.Id] = (form.ComponentModel, form.Count);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_productComponents.Add(form.Id, (form.ComponentModel, form.Count));
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonUpd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
var service =
|
||||||
|
Program.ServiceProvider?.GetService(typeof(FormProductComponent));
|
||||||
|
if (service is FormProductComponent form)
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value);
|
||||||
|
form.Id = id;
|
||||||
|
form.Count = _productComponents[id].Item2;
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (form.ComponentModel == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_productComponents[form.Id] = (form.ComponentModel, form.Count);
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonDel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос",
|
||||||
|
MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_productComponents?.Remove(Convert.ToInt32(dataGridView.SelectedRows[0].Cells[0].Value));
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonRef_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxType.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните название", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(textBoxPrice.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните цену", "Ошибка", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (_productComponents == null || _productComponents.Count == 0)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните компоненты", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var model = new ProductBindingModel
|
||||||
|
{
|
||||||
|
Id = _id ?? 0,
|
||||||
|
Type = textBoxType.Text,
|
||||||
|
Price = Convert.ToDouble(textBoxPrice.Text),
|
||||||
|
Count = 1,
|
||||||
|
ProductComponents = _productComponents
|
||||||
|
};
|
||||||
|
var operationResult = _id.HasValue ? _logic.Update(model) :
|
||||||
|
_logic.Create(model);
|
||||||
|
if (!operationResult)
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
MessageBox.Show("Сохранение прошло успешно", "Сообщение",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private double CalcPrice()
|
||||||
|
{
|
||||||
|
double price = 0;
|
||||||
|
foreach (var elem in _productComponents)
|
||||||
|
{
|
||||||
|
price += ((elem.Value.Item1?.Price ?? 0) * elem.Value.Item2);
|
||||||
|
}
|
||||||
|
return Math.Round(price * 1.1, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
69
Restaurant/RestaurantView/FormProduct.resx
Normal file
69
Restaurant/RestaurantView/FormProduct.resx
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="Identificator.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="Component.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="Count.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
119
Restaurant/RestaurantView/FormProductComponent.Designer.cs
generated
Normal file
119
Restaurant/RestaurantView/FormProductComponent.Designer.cs
generated
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
namespace RestaurantView
|
||||||
|
{
|
||||||
|
partial class FormProductComponent
|
||||||
|
{
|
||||||
|
/// <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.buttonSave = new System.Windows.Forms.Button();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.comboBoxComponent = new System.Windows.Forms.ComboBox();
|
||||||
|
this.labelComponent = new System.Windows.Forms.Label();
|
||||||
|
this.labelCount = new System.Windows.Forms.Label();
|
||||||
|
this.textBoxCount = new System.Windows.Forms.TextBox();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
this.buttonSave.Location = new System.Drawing.Point(98, 119);
|
||||||
|
this.buttonSave.Name = "buttonSave";
|
||||||
|
this.buttonSave.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonSave.TabIndex = 0;
|
||||||
|
this.buttonSave.Text = "Сохранить";
|
||||||
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(209, 119);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.buttonCancel.TabIndex = 1;
|
||||||
|
this.buttonCancel.Text = "Отменить";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||||
|
//
|
||||||
|
// comboBoxComponent
|
||||||
|
//
|
||||||
|
this.comboBoxComponent.FormattingEnabled = true;
|
||||||
|
this.comboBoxComponent.Location = new System.Drawing.Point(98, 24);
|
||||||
|
this.comboBoxComponent.Name = "comboBoxComponent";
|
||||||
|
this.comboBoxComponent.Size = new System.Drawing.Size(242, 23);
|
||||||
|
this.comboBoxComponent.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// labelComponent
|
||||||
|
//
|
||||||
|
this.labelComponent.AutoSize = true;
|
||||||
|
this.labelComponent.Location = new System.Drawing.Point(20, 27);
|
||||||
|
this.labelComponent.Name = "labelComponent";
|
||||||
|
this.labelComponent.Size = new System.Drawing.Size(72, 15);
|
||||||
|
this.labelComponent.TabIndex = 3;
|
||||||
|
this.labelComponent.Text = "Компонент:";
|
||||||
|
//
|
||||||
|
// labelCount
|
||||||
|
//
|
||||||
|
this.labelCount.AutoSize = true;
|
||||||
|
this.labelCount.Location = new System.Drawing.Point(12, 68);
|
||||||
|
this.labelCount.Name = "labelCount";
|
||||||
|
this.labelCount.Size = new System.Drawing.Size(75, 15);
|
||||||
|
this.labelCount.TabIndex = 4;
|
||||||
|
this.labelCount.Text = "Количество:";
|
||||||
|
//
|
||||||
|
// textBoxCount
|
||||||
|
//
|
||||||
|
this.textBoxCount.Location = new System.Drawing.Point(98, 65);
|
||||||
|
this.textBoxCount.Name = "textBoxCount";
|
||||||
|
this.textBoxCount.Size = new System.Drawing.Size(242, 23);
|
||||||
|
this.textBoxCount.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// FormProductComponent
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(365, 157);
|
||||||
|
this.Controls.Add(this.textBoxCount);
|
||||||
|
this.Controls.Add(this.labelCount);
|
||||||
|
this.Controls.Add(this.labelComponent);
|
||||||
|
this.Controls.Add(this.comboBoxComponent);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.buttonSave);
|
||||||
|
this.Name = "FormProductComponent";
|
||||||
|
this.Text = "FormProductComponent";
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
this.PerformLayout();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Button buttonSave;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private ComboBox comboBoxComponent;
|
||||||
|
private Label labelComponent;
|
||||||
|
private Label labelCount;
|
||||||
|
private TextBox textBoxCount;
|
||||||
|
}
|
||||||
|
}
|
90
Restaurant/RestaurantView/FormProductComponent.cs
Normal file
90
Restaurant/RestaurantView/FormProductComponent.cs
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
using RestaurantContracts.BusinessLogicsContracts;
|
||||||
|
using RestaurantContracts.ViewModels;
|
||||||
|
using RestaurantDataModels.Models;
|
||||||
|
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 RestaurantView
|
||||||
|
{
|
||||||
|
public partial class FormProductComponent : Form
|
||||||
|
{
|
||||||
|
private readonly List<ComponentViewModel>? _list;
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Convert.ToInt32(comboBoxComponent.SelectedValue);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
comboBoxComponent.SelectedValue = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public IComponentModel? ComponentModel
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_list == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
foreach (var elem in _list)
|
||||||
|
{
|
||||||
|
if (elem.Id == Id)
|
||||||
|
{
|
||||||
|
return elem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int Count
|
||||||
|
{
|
||||||
|
get { return Convert.ToInt32(textBoxCount.Text); }
|
||||||
|
set { textBoxCount.Text = value.ToString(); }
|
||||||
|
}
|
||||||
|
public FormProductComponent(IComponentLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_list = logic.ReadList(null);
|
||||||
|
if (_list != null)
|
||||||
|
{
|
||||||
|
comboBoxComponent.DisplayMember = "Name";
|
||||||
|
comboBoxComponent.ValueMember = "Id";
|
||||||
|
comboBoxComponent.DataSource = _list;
|
||||||
|
comboBoxComponent.SelectedItem = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(textBoxCount.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните поле Количество", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (comboBoxComponent.SelectedValue == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Выберите компонент", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DialogResult = DialogResult.OK;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
DialogResult = DialogResult.Cancel;
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
Restaurant/RestaurantView/FormProductComponent.resx
Normal file
60
Restaurant/RestaurantView/FormProductComponent.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
114
Restaurant/RestaurantView/FormProducts.Designer.cs
generated
Normal file
114
Restaurant/RestaurantView/FormProducts.Designer.cs
generated
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
namespace RestaurantView
|
||||||
|
{
|
||||||
|
partial class FormProducts
|
||||||
|
{
|
||||||
|
/// <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.buttonAdd = new System.Windows.Forms.Button();
|
||||||
|
this.buttonUpd = new System.Windows.Forms.Button();
|
||||||
|
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.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
|
this.dataGridView.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.dataGridView.Name = "dataGridView";
|
||||||
|
this.dataGridView.RowTemplate.Height = 25;
|
||||||
|
this.dataGridView.Size = new System.Drawing.Size(656, 452);
|
||||||
|
this.dataGridView.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// buttonAdd
|
||||||
|
//
|
||||||
|
this.buttonAdd.Location = new System.Drawing.Point(691, 44);
|
||||||
|
this.buttonAdd.Name = "buttonAdd";
|
||||||
|
this.buttonAdd.Size = new System.Drawing.Size(86, 33);
|
||||||
|
this.buttonAdd.TabIndex = 1;
|
||||||
|
this.buttonAdd.Text = "Добавить";
|
||||||
|
this.buttonAdd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonAdd.Click += new System.EventHandler(this.ButtonAdd_Click);
|
||||||
|
//
|
||||||
|
// buttonUpd
|
||||||
|
//
|
||||||
|
this.buttonUpd.Location = new System.Drawing.Point(691, 116);
|
||||||
|
this.buttonUpd.Name = "buttonUpd";
|
||||||
|
this.buttonUpd.Size = new System.Drawing.Size(86, 34);
|
||||||
|
this.buttonUpd.TabIndex = 2;
|
||||||
|
this.buttonUpd.Text = "Изменить";
|
||||||
|
this.buttonUpd.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonUpd.Click += new System.EventHandler(this.ButtonUpd_Click);
|
||||||
|
//
|
||||||
|
// buttonDel
|
||||||
|
//
|
||||||
|
this.buttonDel.Location = new System.Drawing.Point(691, 187);
|
||||||
|
this.buttonDel.Name = "buttonDel";
|
||||||
|
this.buttonDel.Size = new System.Drawing.Size(86, 36);
|
||||||
|
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(691, 260);
|
||||||
|
this.buttonRef.Name = "buttonRef";
|
||||||
|
this.buttonRef.Size = new System.Drawing.Size(86, 41);
|
||||||
|
this.buttonRef.TabIndex = 4;
|
||||||
|
this.buttonRef.Text = "Обновить";
|
||||||
|
this.buttonRef.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonRef.Click += new System.EventHandler(this.ButtonRef_Click);
|
||||||
|
//
|
||||||
|
// FormProducts
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(810, 450);
|
||||||
|
this.Controls.Add(this.buttonRef);
|
||||||
|
this.Controls.Add(this.buttonDel);
|
||||||
|
this.Controls.Add(this.buttonUpd);
|
||||||
|
this.Controls.Add(this.buttonAdd);
|
||||||
|
this.Controls.Add(this.dataGridView);
|
||||||
|
this.Name = "FormProducts";
|
||||||
|
this.Text = "Продукты";
|
||||||
|
this.Load += new System.EventHandler(this.FormProducts_Load);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private DataGridView dataGridView;
|
||||||
|
private Button buttonAdd;
|
||||||
|
private Button buttonUpd;
|
||||||
|
private Button buttonDel;
|
||||||
|
private Button buttonRef;
|
||||||
|
}
|
||||||
|
}
|
109
Restaurant/RestaurantView/FormProducts.cs
Normal file
109
Restaurant/RestaurantView/FormProducts.cs
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using RestaurantContracts.BindingModels;
|
||||||
|
using RestaurantContracts.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 RestaurantView
|
||||||
|
{
|
||||||
|
public partial class FormProducts : Form
|
||||||
|
{
|
||||||
|
private readonly IProductLogic _logic;
|
||||||
|
public FormProducts(IProductLogic logic)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
_logic = logic;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void FormProducts_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadData()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = _logic.ReadList(null);
|
||||||
|
if (list != null)
|
||||||
|
{
|
||||||
|
dataGridView.DataSource = list;
|
||||||
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
dataGridView.Columns["Type"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
dataGridView.Columns["ProductComponents"].Visible = false;
|
||||||
|
dataGridView.Columns["Count"].Visible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
var service = Program.ServiceProvider?.GetService(typeof(FormProduct));
|
||||||
|
if (service is FormProduct 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(FormProduct));
|
||||||
|
if (service is FormProduct form)
|
||||||
|
{
|
||||||
|
form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonDel_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
|
{
|
||||||
|
if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
||||||
|
{
|
||||||
|
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_logic.Delete(new ProductBindingModel
|
||||||
|
{
|
||||||
|
Id = id
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||||
|
}
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ButtonRef_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
LoadData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
Restaurant/RestaurantView/FormProducts.resx
Normal file
60
Restaurant/RestaurantView/FormProducts.resx
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<root>
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
@ -47,6 +47,12 @@ namespace RestaurantView
|
|||||||
services.AddTransient<FormProviders>();
|
services.AddTransient<FormProviders>();
|
||||||
services.AddTransient<FormComponent>();
|
services.AddTransient<FormComponent>();
|
||||||
services.AddTransient<FormComponents>();
|
services.AddTransient<FormComponents>();
|
||||||
|
services.AddTransient<FormComponentProvider>();
|
||||||
|
services.AddTransient<FormProduct>();
|
||||||
|
services.AddTransient<FormProducts>();
|
||||||
|
services.AddTransient<FormProductComponent>();
|
||||||
|
services.AddTransient<FormCreateOrder>();
|
||||||
|
services.AddTransient<FormOrderProduct>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user