diff --git a/DiningRoom/DiningRoomBusinessLogic/BusinessLogic/OrderLogic.cs b/DiningRoom/DiningRoomBusinessLogic/BusinessLogic/OrderLogic.cs
index d3769fd..5295162 100644
--- a/DiningRoom/DiningRoomBusinessLogic/BusinessLogic/OrderLogic.cs
+++ b/DiningRoom/DiningRoomBusinessLogic/BusinessLogic/OrderLogic.cs
@@ -113,34 +113,40 @@ namespace DiningRoomBusinessLogic.BusinessLogic
return true;
}
-
- private bool ChangeStatus(OrderBindingModel model, OrderStatus newStatus)
- {
- CheckModel(model, false);
- var order = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
- if (order == null)
- {
- throw new ArgumentNullException(nameof(order));
- }
- if (newStatus - model.Status == 1)
- {
- model.Status = newStatus;
-
- if (_orderStorage.Update(model) == null)
- {
- _logger.LogWarning("Update order operation failed");
- return false;
- }
- return true;
- }
- if (order.Status + 1 != newStatus)
- {
- _logger.LogWarning("Change status operation failed. Incorrect new status: {newStatus}. Current status: {currStatus}", newStatus, order.Status);
- return false;
- }
- _logger.LogWarning("Changing status operation faled: current:{Status}: required:{newStatus}.", model.Status, newStatus);
- throw new ArgumentException($"Невозможно присвоить статус {newStatus} заказу с текущим статусом {model.Status}");
- }
+ public bool ChangeStatus(OrderBindingModel model, OrderStatus newStatus)
+ {
+ var vmodel = _orderStorage.GetElement(new() { Id = model.Id });
+
+ if (vmodel == null)
+ {
+ throw new ArgumentNullException(nameof(model));
+ }
+
+ if ((int)vmodel.Status + 1 != (int)newStatus)
+ {
+ throw new InvalidOperationException($"Попытка перевести заказ не в следующий статус: " +
+ $"Текущий статус: {vmodel.Status} \n" +
+ $"Планируемый статус: {newStatus} \n" +
+ $"Доступный статус: {(OrderStatus)((int)vmodel.Status + 1)}");
+ }
+
+ model.Status = newStatus;
+ model.DateCreate = vmodel.DateCreate;
+
+ model.ProductId = vmodel.ProductId;
+ model.Sum = vmodel.Sum;
+ model.Count = vmodel.Count;
+
+ var result = _orderStorage.Update(model);
+
+ if (result == null)
+ {
+ _logger.LogWarning("Update operation failed");
+
+ return false;
+ }
+ return true;
+ }
//Перевод заказа в состояние выполнения
public bool TakeOrderInWork(OrderBindingModel model)
diff --git a/DiningRoom/DiningRoomBusinessLogic/BusinessLogic/ReportLogic.cs b/DiningRoom/DiningRoomBusinessLogic/BusinessLogic/ReportLogic.cs
index 3ed5449..0d14093 100644
--- a/DiningRoom/DiningRoomBusinessLogic/BusinessLogic/ReportLogic.cs
+++ b/DiningRoom/DiningRoomBusinessLogic/BusinessLogic/ReportLogic.cs
@@ -15,17 +15,11 @@ namespace DiningRoomBusinessLogic.BusinessLogic
_componentStorage = ComponentStorage;
}
- ///
- /// Получение отчёта для Word или Excel
- ///
- public List GetReportComponentsWithShipments(List SelectedComponents)
+ public List GetReportComponentsWithOrders(List SelectedComponents)
{
return _componentStorage.GetComponentsOrders(SelectedComponents);
}
- ///
- /// Получение отчёта для отправки на почту
- ///
public List GetReportComponentsByCardDate(ReportBindingModel Report)
{
return _componentStorage.GetComponentsByDate(Report);
diff --git a/DiningRoom/DiningRoomContracts/BindingModels/CardBindingModel.cs b/DiningRoom/DiningRoomContracts/BindingModels/CardBindingModel.cs
index f8182d5..b78fce6 100644
--- a/DiningRoom/DiningRoomContracts/BindingModels/CardBindingModel.cs
+++ b/DiningRoom/DiningRoomContracts/BindingModels/CardBindingModel.cs
@@ -11,7 +11,6 @@ namespace DiningRoomContracts.BindingModels
public class CardBindingModel : ICardModel
{
public int Id { get; set; }
- public int? DrinkId { get; set; }
public string CardName { get; set; } = string.Empty;
public DateTime DateCardCreate { get; set; } = DateTime.Now;
}
diff --git a/DiningRoom/DiningRoomContracts/BindingModels/DrinkBindingModel.cs b/DiningRoom/DiningRoomContracts/BindingModels/DrinkBindingModel.cs
index 4e79556..02df344 100644
--- a/DiningRoom/DiningRoomContracts/BindingModels/DrinkBindingModel.cs
+++ b/DiningRoom/DiningRoomContracts/BindingModels/DrinkBindingModel.cs
@@ -5,6 +5,8 @@ namespace DiningRoomContracts.BindingModels
public class DrinkBindingModel : IDrinkModel
{
public int Id { get; set; }
+ public int CardId { get; set; }
+ public string CardName { get; set; } = string.Empty;
public string DrinkName { get; set; } = string.Empty;
diff --git a/DiningRoom/DiningRoomContracts/BusinessLogicContracts/IReportLogic.cs b/DiningRoom/DiningRoomContracts/BusinessLogicContracts/IReportLogic.cs
index b887d5e..a859cc9 100644
--- a/DiningRoom/DiningRoomContracts/BusinessLogicContracts/IReportLogic.cs
+++ b/DiningRoom/DiningRoomContracts/BusinessLogicContracts/IReportLogic.cs
@@ -9,7 +9,7 @@ namespace DiningRoomContracts.BusinessLogicContracts
///
/// Получение отчёта для Word или Excel
///
- List GetReportComponentsWithShipments(List SelectedComponents);
+ List GetReportComponentsWithOrders(List SelectedComponents);
///
/// Получение отчёта для отправки на почту
diff --git a/DiningRoom/DiningRoomContracts/ViewModels/DrinkViewModel.cs b/DiningRoom/DiningRoomContracts/ViewModels/DrinkViewModel.cs
index 16be0e5..2a2b450 100644
--- a/DiningRoom/DiningRoomContracts/ViewModels/DrinkViewModel.cs
+++ b/DiningRoom/DiningRoomContracts/ViewModels/DrinkViewModel.cs
@@ -6,6 +6,8 @@ namespace DiningRoomContracts.ViewModels
public class DrinkViewModel : IDrinkModel
{
public int Id { get; set; }
+ public int CardId { get; set; }
+ [DisplayName("Алкогольная карта")]
public string CardName { get; set; } = string.Empty;
[DisplayName("Название товара")]
diff --git a/DiningRoom/DiningRoomDataModels/Models/IDrinkModel.cs b/DiningRoom/DiningRoomDataModels/Models/IDrinkModel.cs
index 64e8f7a..53d1adb 100644
--- a/DiningRoom/DiningRoomDataModels/Models/IDrinkModel.cs
+++ b/DiningRoom/DiningRoomDataModels/Models/IDrinkModel.cs
@@ -15,10 +15,11 @@
/// Стоимость товара
///
double Cost { get; }
+ public int CardId { get; set; }
- ///
- /// Список продуктов
- ///
- Dictionary DrinkComponents { get; }
+ ///
+ /// Список продуктов
+ ///
+ Dictionary DrinkComponents { get; }
}
}
diff --git a/DiningRoom/DiningRoomDataModels/Models/IOrderModel.cs b/DiningRoom/DiningRoomDataModels/Models/IOrderModel.cs
index fe84f8e..d5aa8b0 100644
--- a/DiningRoom/DiningRoomDataModels/Models/IOrderModel.cs
+++ b/DiningRoom/DiningRoomDataModels/Models/IOrderModel.cs
@@ -14,7 +14,6 @@ namespace DiningRoomDataModels.Models
///
DateTime DateCreate { get; }
int ProductId { get; }
- string ProductName { get; }
///
/// Статус заказа
///
diff --git a/DiningRoom/DiningRoomDatabaseImplement/Implements/CardStorage.cs b/DiningRoom/DiningRoomDatabaseImplement/Implements/CardStorage.cs
index a3552a3..14f9651 100644
--- a/DiningRoom/DiningRoomDatabaseImplement/Implements/CardStorage.cs
+++ b/DiningRoom/DiningRoomDatabaseImplement/Implements/CardStorage.cs
@@ -14,7 +14,6 @@ namespace DiningRoomDatabaseImplement.Implements
{
public class CardStorage : ICardStorage
{
- //id пользователя учитывается в GetFilteredList
public List GetFullList()
{
using var context = new DiningRoomDatabase();
diff --git a/DiningRoom/DiningRoomDatabaseImplement/Implements/DrinkStorage.cs b/DiningRoom/DiningRoomDatabaseImplement/Implements/DrinkStorage.cs
index 9f95133..2c0202d 100644
--- a/DiningRoom/DiningRoomDatabaseImplement/Implements/DrinkStorage.cs
+++ b/DiningRoom/DiningRoomDatabaseImplement/Implements/DrinkStorage.cs
@@ -13,7 +13,8 @@ namespace DiningRoomDatabaseImplement.Implements
{
using var context = new DiningRoomDatabase();
return context.Drinks
- .Include(x => x.Components)
+ .Include(x => x.Card)
+ .Include(x => x.Components)
.ThenInclude(x => x.Component)
.ToList()
.Select(x => x.GetViewModel)
@@ -28,7 +29,8 @@ namespace DiningRoomDatabaseImplement.Implements
}
using var context = new DiningRoomDatabase();
return context.Drinks
- .Include(x => x.Components)
+ .Include(x => x.Card)
+ .Include(x => x.Components)
.ThenInclude(x => x.Component)
.Where(x => x.DrinkName.Contains(model.DrinkName))
.ToList()
@@ -44,7 +46,8 @@ namespace DiningRoomDatabaseImplement.Implements
}
using var context = new DiningRoomDatabase();
return context.Drinks
- .Include(x => x.Components)
+ .Include(x => x.Card)
+ .Include(x => x.Components)
.ThenInclude(x => x.Component)
.FirstOrDefault(x => (!string.IsNullOrEmpty(model.DrinkName) && x.DrinkName == model.DrinkName) ||
(model.Id.HasValue && x.Id == model.Id))
diff --git a/DiningRoom/DiningRoomDatabaseImplement/Migrations/20240525195148_InitialCreate.Designer.cs b/DiningRoom/DiningRoomDatabaseImplement/Migrations/20240526010428_InitialCreate.Designer.cs
similarity index 93%
rename from DiningRoom/DiningRoomDatabaseImplement/Migrations/20240525195148_InitialCreate.Designer.cs
rename to DiningRoom/DiningRoomDatabaseImplement/Migrations/20240526010428_InitialCreate.Designer.cs
index b9ca7a2..bb8621a 100644
--- a/DiningRoom/DiningRoomDatabaseImplement/Migrations/20240525195148_InitialCreate.Designer.cs
+++ b/DiningRoom/DiningRoomDatabaseImplement/Migrations/20240526010428_InitialCreate.Designer.cs
@@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace DiningRoomDatabaseImplement.Migrations
{
[DbContext(typeof(DiningRoomDatabase))]
- [Migration("20240525195148_InitialCreate")]
+ [Migration("20240526010428_InitialCreate")]
partial class InitialCreate
{
///
@@ -25,21 +25,6 @@ namespace DiningRoomDatabaseImplement.Migrations
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
- modelBuilder.Entity("CardDrink", b =>
- {
- b.Property("CardId")
- .HasColumnType("integer");
-
- b.Property("DrinkId")
- .HasColumnType("integer");
-
- b.HasKey("CardId", "DrinkId");
-
- b.HasIndex("DrinkId");
-
- b.ToTable("CardDrink");
- });
-
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Card", b =>
{
b.Property("Id")
@@ -101,6 +86,9 @@ namespace DiningRoomDatabaseImplement.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+ b.Property("CardId")
+ .HasColumnType("integer");
+
b.Property("Cost")
.HasColumnType("double precision");
@@ -113,6 +101,8 @@ namespace DiningRoomDatabaseImplement.Migrations
b.HasKey("Id");
+ b.HasIndex("CardId");
+
b.HasIndex("UserId");
b.ToTable("Drinks");
@@ -161,10 +151,6 @@ namespace DiningRoomDatabaseImplement.Migrations
b.Property("ProductId")
.HasColumnType("integer");
- b.Property("ProductName")
- .IsRequired()
- .HasColumnType("text");
-
b.Property("Status")
.HasColumnType("integer");
@@ -259,21 +245,6 @@ namespace DiningRoomDatabaseImplement.Migrations
b.ToTable("Users");
});
- modelBuilder.Entity("CardDrink", b =>
- {
- b.HasOne("DiningRoomDatabaseImplement.Models.Card", null)
- .WithMany()
- .HasForeignKey("CardId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("DiningRoomDatabaseImplement.Models.Drink", null)
- .WithMany()
- .HasForeignKey("DrinkId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Card", b =>
{
b.HasOne("DiningRoomDatabaseImplement.Models.User", null)
@@ -290,9 +261,17 @@ namespace DiningRoomDatabaseImplement.Migrations
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Drink", b =>
{
+ b.HasOne("DiningRoomDatabaseImplement.Models.Card", "Card")
+ .WithMany("Drinks")
+ .HasForeignKey("CardId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
b.HasOne("DiningRoomDatabaseImplement.Models.User", null)
.WithMany("Drinks")
.HasForeignKey("UserId");
+
+ b.Navigation("Card");
});
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.DrinkComponent", b =>
@@ -355,6 +334,11 @@ namespace DiningRoomDatabaseImplement.Migrations
b.Navigation("Product");
});
+ modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Card", b =>
+ {
+ b.Navigation("Drinks");
+ });
+
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Component", b =>
{
b.Navigation("DrinkComponents");
diff --git a/DiningRoom/DiningRoomDatabaseImplement/Migrations/20240525195148_InitialCreate.cs b/DiningRoom/DiningRoomDatabaseImplement/Migrations/20240526010428_InitialCreate.cs
similarity index 92%
rename from DiningRoom/DiningRoomDatabaseImplement/Migrations/20240525195148_InitialCreate.cs
rename to DiningRoom/DiningRoomDatabaseImplement/Migrations/20240526010428_InitialCreate.cs
index 302ab4b..e023091 100644
--- a/DiningRoom/DiningRoomDatabaseImplement/Migrations/20240525195148_InitialCreate.cs
+++ b/DiningRoom/DiningRoomDatabaseImplement/Migrations/20240526010428_InitialCreate.cs
@@ -68,26 +68,6 @@ namespace DiningRoomDatabaseImplement.Migrations
principalColumn: "Id");
});
- migrationBuilder.CreateTable(
- name: "Drinks",
- columns: table => new
- {
- Id = table.Column(type: "integer", nullable: false)
- .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
- DrinkName = table.Column(type: "text", nullable: false),
- Cost = table.Column(type: "double precision", nullable: false),
- UserId = table.Column(type: "integer", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Drinks", x => x.Id);
- table.ForeignKey(
- name: "FK_Drinks_Users_UserId",
- column: x => x.UserId,
- principalTable: "Users",
- principalColumn: "Id");
- });
-
migrationBuilder.CreateTable(
name: "Products",
columns: table => new
@@ -109,54 +89,30 @@ namespace DiningRoomDatabaseImplement.Migrations
});
migrationBuilder.CreateTable(
- name: "CardDrink",
+ name: "Drinks",
columns: table => new
{
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ DrinkName = table.Column(type: "text", nullable: false),
CardId = table.Column(type: "integer", nullable: false),
- DrinkId = table.Column(type: "integer", nullable: false)
+ Cost = table.Column(type: "double precision", nullable: false),
+ UserId = table.Column(type: "integer", nullable: true)
},
constraints: table =>
{
- table.PrimaryKey("PK_CardDrink", x => new { x.CardId, x.DrinkId });
+ table.PrimaryKey("PK_Drinks", x => x.Id);
table.ForeignKey(
- name: "FK_CardDrink_Cards_CardId",
+ name: "FK_Drinks_Cards_CardId",
column: x => x.CardId,
principalTable: "Cards",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
- name: "FK_CardDrink_Drinks_DrinkId",
- column: x => x.DrinkId,
- principalTable: "Drinks",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- });
-
- migrationBuilder.CreateTable(
- name: "DrinkComponents",
- columns: table => new
- {
- Id = table.Column(type: "integer", nullable: false)
- .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
- DrinkId = table.Column(type: "integer", nullable: false),
- ComponentId = table.Column(type: "integer", nullable: false),
- Count = table.Column(type: "integer", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_DrinkComponents", x => x.Id);
- table.ForeignKey(
- name: "FK_DrinkComponents_Components_ComponentId",
- column: x => x.ComponentId,
- principalTable: "Components",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
- table.ForeignKey(
- name: "FK_DrinkComponents_Drinks_DrinkId",
- column: x => x.DrinkId,
- principalTable: "Drinks",
- principalColumn: "Id",
- onDelete: ReferentialAction.Cascade);
+ name: "FK_Drinks_Users_UserId",
+ column: x => x.UserId,
+ principalTable: "Users",
+ principalColumn: "Id");
});
migrationBuilder.CreateTable(
@@ -166,7 +122,6 @@ namespace DiningRoomDatabaseImplement.Migrations
Id = table.Column(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
ProductId = table.Column(type: "integer", nullable: false),
- ProductName = table.Column(type: "text", nullable: false),
Count = table.Column(type: "integer", nullable: false),
Sum = table.Column(type: "double precision", nullable: false),
Status = table.Column(type: "integer", nullable: false),
@@ -216,10 +171,32 @@ namespace DiningRoomDatabaseImplement.Migrations
onDelete: ReferentialAction.Cascade);
});
- migrationBuilder.CreateIndex(
- name: "IX_CardDrink_DrinkId",
- table: "CardDrink",
- column: "DrinkId");
+ migrationBuilder.CreateTable(
+ name: "DrinkComponents",
+ columns: table => new
+ {
+ Id = table.Column(type: "integer", nullable: false)
+ .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
+ DrinkId = table.Column(type: "integer", nullable: false),
+ ComponentId = table.Column(type: "integer", nullable: false),
+ Count = table.Column(type: "integer", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_DrinkComponents", x => x.Id);
+ table.ForeignKey(
+ name: "FK_DrinkComponents_Components_ComponentId",
+ column: x => x.ComponentId,
+ principalTable: "Components",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ table.ForeignKey(
+ name: "FK_DrinkComponents_Drinks_DrinkId",
+ column: x => x.DrinkId,
+ principalTable: "Drinks",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
migrationBuilder.CreateIndex(
name: "IX_Cards_UserId",
@@ -241,6 +218,11 @@ namespace DiningRoomDatabaseImplement.Migrations
table: "DrinkComponents",
column: "DrinkId");
+ migrationBuilder.CreateIndex(
+ name: "IX_Drinks_CardId",
+ table: "Drinks",
+ column: "CardId");
+
migrationBuilder.CreateIndex(
name: "IX_Drinks_UserId",
table: "Drinks",
@@ -275,9 +257,6 @@ namespace DiningRoomDatabaseImplement.Migrations
///
protected override void Down(MigrationBuilder migrationBuilder)
{
- migrationBuilder.DropTable(
- name: "CardDrink");
-
migrationBuilder.DropTable(
name: "DrinkComponents");
@@ -287,9 +266,6 @@ namespace DiningRoomDatabaseImplement.Migrations
migrationBuilder.DropTable(
name: "ProductComponents");
- migrationBuilder.DropTable(
- name: "Cards");
-
migrationBuilder.DropTable(
name: "Drinks");
@@ -299,6 +275,9 @@ namespace DiningRoomDatabaseImplement.Migrations
migrationBuilder.DropTable(
name: "Products");
+ migrationBuilder.DropTable(
+ name: "Cards");
+
migrationBuilder.DropTable(
name: "Users");
}
diff --git a/DiningRoom/DiningRoomDatabaseImplement/Migrations/DiningRoomDatabaseModelSnapshot.cs b/DiningRoom/DiningRoomDatabaseImplement/Migrations/DiningRoomDatabaseModelSnapshot.cs
index 5f86f03..a91a24a 100644
--- a/DiningRoom/DiningRoomDatabaseImplement/Migrations/DiningRoomDatabaseModelSnapshot.cs
+++ b/DiningRoom/DiningRoomDatabaseImplement/Migrations/DiningRoomDatabaseModelSnapshot.cs
@@ -22,21 +22,6 @@ namespace DiningRoomDatabaseImplement.Migrations
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
- modelBuilder.Entity("CardDrink", b =>
- {
- b.Property("CardId")
- .HasColumnType("integer");
-
- b.Property("DrinkId")
- .HasColumnType("integer");
-
- b.HasKey("CardId", "DrinkId");
-
- b.HasIndex("DrinkId");
-
- b.ToTable("CardDrink");
- });
-
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Card", b =>
{
b.Property("Id")
@@ -98,6 +83,9 @@ namespace DiningRoomDatabaseImplement.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property("Id"));
+ b.Property("CardId")
+ .HasColumnType("integer");
+
b.Property("Cost")
.HasColumnType("double precision");
@@ -110,6 +98,8 @@ namespace DiningRoomDatabaseImplement.Migrations
b.HasKey("Id");
+ b.HasIndex("CardId");
+
b.HasIndex("UserId");
b.ToTable("Drinks");
@@ -158,10 +148,6 @@ namespace DiningRoomDatabaseImplement.Migrations
b.Property("ProductId")
.HasColumnType("integer");
- b.Property("ProductName")
- .IsRequired()
- .HasColumnType("text");
-
b.Property("Status")
.HasColumnType("integer");
@@ -256,21 +242,6 @@ namespace DiningRoomDatabaseImplement.Migrations
b.ToTable("Users");
});
- modelBuilder.Entity("CardDrink", b =>
- {
- b.HasOne("DiningRoomDatabaseImplement.Models.Card", null)
- .WithMany()
- .HasForeignKey("CardId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
-
- b.HasOne("DiningRoomDatabaseImplement.Models.Drink", null)
- .WithMany()
- .HasForeignKey("DrinkId")
- .OnDelete(DeleteBehavior.Cascade)
- .IsRequired();
- });
-
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Card", b =>
{
b.HasOne("DiningRoomDatabaseImplement.Models.User", null)
@@ -287,9 +258,17 @@ namespace DiningRoomDatabaseImplement.Migrations
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Drink", b =>
{
+ b.HasOne("DiningRoomDatabaseImplement.Models.Card", "Card")
+ .WithMany("Drinks")
+ .HasForeignKey("CardId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
b.HasOne("DiningRoomDatabaseImplement.Models.User", null)
.WithMany("Drinks")
.HasForeignKey("UserId");
+
+ b.Navigation("Card");
});
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.DrinkComponent", b =>
@@ -352,6 +331,11 @@ namespace DiningRoomDatabaseImplement.Migrations
b.Navigation("Product");
});
+ modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Card", b =>
+ {
+ b.Navigation("Drinks");
+ });
+
modelBuilder.Entity("DiningRoomDatabaseImplement.Models.Component", b =>
{
b.Navigation("DrinkComponents");
diff --git a/DiningRoom/DiningRoomDatabaseImplement/Models/Drink.cs b/DiningRoom/DiningRoomDatabaseImplement/Models/Drink.cs
index 7dd7227..a9e8525 100644
--- a/DiningRoom/DiningRoomDatabaseImplement/Models/Drink.cs
+++ b/DiningRoom/DiningRoomDatabaseImplement/Models/Drink.cs
@@ -14,11 +14,11 @@ namespace DiningRoomDatabaseImplement.Models
[Required]
public string DrinkName { get; private set; } = string.Empty;
+ public int CardId { get; set; }
- [Required]
+ [Required]
public double Cost { get; private set; }
- [ForeignKey("DrinkId")]
- public virtual List Card { get; set; } = new();
+ public virtual Card Card { get; set; }
[ForeignKey("DrinkId")]
public virtual List Components { get; set; } = new();
@@ -48,7 +48,8 @@ namespace DiningRoomDatabaseImplement.Models
{
Id = Model.Id,
DrinkName = Model.DrinkName,
- Cost = Model.Cost,
+ CardId = Model.CardId,
+ Cost = Model.Cost,
Components = Model.DrinkComponents.Select(x => new DrinkComponent
{
Component = Context.Components.First(y => y.Id == x.Key),
@@ -60,6 +61,7 @@ namespace DiningRoomDatabaseImplement.Models
{
DrinkName = model.DrinkName;
Cost = model.Cost;
+ CardId = model.CardId;
}
public DrinkViewModel GetViewModel
{
@@ -72,7 +74,9 @@ namespace DiningRoomDatabaseImplement.Models
Id = Id,
DrinkName = DrinkName,
Cost = Cost,
- DrinkComponents = DrinkComponents
+ CardId = CardId,
+ CardName = context.Cards.FirstOrDefault(x => x.Id == CardId)?.CardName ?? string.Empty,
+ DrinkComponents = DrinkComponents
};
}
}
diff --git a/DiningRoom/DiningRoomDatabaseImplement/Models/Order.cs b/DiningRoom/DiningRoomDatabaseImplement/Models/Order.cs
index f4a439b..001ae78 100644
--- a/DiningRoom/DiningRoomDatabaseImplement/Models/Order.cs
+++ b/DiningRoom/DiningRoomDatabaseImplement/Models/Order.cs
@@ -18,8 +18,6 @@ namespace DiningRoomDatabaseImplement.Models
[Required]
public int ProductId { get; set; }
[Required]
- public string ProductName { get; set; } = string.Empty;
- [Required]
public int Count { get; set; }
[Required]
public double Sum { get; set; }
@@ -27,6 +25,7 @@ namespace DiningRoomDatabaseImplement.Models
public OrderStatus Status { get; set; }
[Required]
public DateTime DateCreate { get; set; }
+
public virtual Product Product { get; set; }
@@ -40,7 +39,6 @@ namespace DiningRoomDatabaseImplement.Models
{
Id = model.Id,
ProductId = model.ProductId,
- ProductName = model.ProductName,
DateCreate = model.DateCreate,
Status = model.Status,
Count = model.Count,
diff --git a/DiningRoom/DiningRoomView/FormCards.Designer.cs b/DiningRoom/DiningRoomView/FormCards.Designer.cs
new file mode 100644
index 0000000..732f245
--- /dev/null
+++ b/DiningRoom/DiningRoomView/FormCards.Designer.cs
@@ -0,0 +1,125 @@
+namespace DiningRoomView
+{
+ partial class FormCards
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ dataGridView = new DataGridView();
+ ButtonAdd = new Button();
+ ButtonUpd = new Button();
+ ButtonDel = new Button();
+ ButtonRef = new Button();
+ textBoxName = new TextBox();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.BackgroundColor = SystemColors.ButtonHighlight;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.Location = new Point(0, 0);
+ dataGridView.Name = "dataGridView";
+ dataGridView.RowTemplate.Height = 25;
+ dataGridView.Size = new Size(433, 448);
+ dataGridView.TabIndex = 0;
+ //
+ // ButtonAdd
+ //
+ ButtonAdd.Location = new Point(439, 116);
+ ButtonAdd.Name = "ButtonAdd";
+ ButtonAdd.Size = new Size(225, 23);
+ ButtonAdd.TabIndex = 1;
+ ButtonAdd.Text = "Добавить";
+ ButtonAdd.UseVisualStyleBackColor = true;
+ ButtonAdd.Click += ButtonAdd_Click;
+ //
+ // ButtonUpd
+ //
+ ButtonUpd.Location = new Point(439, 145);
+ ButtonUpd.Name = "ButtonUpd";
+ ButtonUpd.Size = new Size(225, 23);
+ ButtonUpd.TabIndex = 2;
+ ButtonUpd.Text = "Изменить";
+ ButtonUpd.UseVisualStyleBackColor = true;
+ ButtonUpd.Click += ButtonUpd_Click;
+ //
+ // ButtonDel
+ //
+ ButtonDel.Location = new Point(439, 174);
+ ButtonDel.Name = "ButtonDel";
+ ButtonDel.Size = new Size(225, 23);
+ ButtonDel.TabIndex = 3;
+ ButtonDel.Text = "Удалить";
+ ButtonDel.UseVisualStyleBackColor = true;
+ ButtonDel.Click += ButtonDel_Click;
+ //
+ // ButtonRef
+ //
+ ButtonRef.Location = new Point(439, 203);
+ ButtonRef.Name = "ButtonRef";
+ ButtonRef.Size = new Size(225, 23);
+ ButtonRef.TabIndex = 4;
+ ButtonRef.Text = "Обновить";
+ ButtonRef.UseVisualStyleBackColor = true;
+ ButtonRef.Click += ButtonRef_Click;
+ //
+ // textBoxName
+ //
+ textBoxName.Location = new Point(439, 30);
+ textBoxName.Name = "textBoxName";
+ textBoxName.Size = new Size(225, 23);
+ textBoxName.TabIndex = 5;
+ //
+ // FormCards
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(668, 450);
+ Controls.Add(textBoxName);
+ Controls.Add(ButtonRef);
+ Controls.Add(ButtonDel);
+ Controls.Add(ButtonUpd);
+ Controls.Add(ButtonAdd);
+ Controls.Add(dataGridView);
+ Name = "FormCards";
+ Text = "Изделия";
+ Load += FormWoods_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private System.Windows.Forms.DataGridView dataGridView;
+ private System.Windows.Forms.Button ButtonAdd;
+ private System.Windows.Forms.Button ButtonUpd;
+ private System.Windows.Forms.Button ButtonDel;
+ private System.Windows.Forms.Button ButtonRef;
+ private TextBox textBoxName;
+ }
+}
\ No newline at end of file
diff --git a/DiningRoom/DiningRoomView/FormCards.cs b/DiningRoom/DiningRoomView/FormCards.cs
new file mode 100644
index 0000000..a9dec13
--- /dev/null
+++ b/DiningRoom/DiningRoomView/FormCards.cs
@@ -0,0 +1,141 @@
+using DiningRoomContracts.BindingModels;
+using DiningRoomContracts.BusinessLogicContracts;
+using DiningRoomContracts.SearchModels;
+using DiningRoomDataModels.Models;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using static System.Windows.Forms.DataFormats;
+
+namespace DiningRoomView
+{
+ public partial class FormCards : Form
+ {
+ private readonly ILogger _logger;
+ private readonly ICardLogic _logic;
+ public FormCards(ILogger logger, ICardLogic logic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logic = logic;
+ }
+ private void FormWoods_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["CardName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
+
+ }
+ _logger.LogInformation("Загрузка карт");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки карт");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonAdd_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxName.Text))
+ {
+ MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Сохранение карты");
+ try
+ {
+ var model = new CardBindingModel
+ {
+ Id = 0,
+ CardName = textBoxName.Text,
+ };
+ var operationResult =_logic.Create(model);
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка сохранения карты");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonUpd_Click(object sender, EventArgs e)
+ {
+ if (string.IsNullOrEmpty(textBoxName.Text))
+ {
+ MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ return;
+ }
+ _logger.LogInformation("Сохранение карты");
+ try
+ {
+ int _id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ var model = new CardBindingModel
+ {
+ Id = _id,
+ CardName = textBoxName.Text,
+ };
+ var operationResult = _logic.Update(model);
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка сохранения карты");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonDel_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ if (MessageBox.Show("Удалить запись?", "Вопрос", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Удаление карты");
+ try
+ {
+ if (!_logic.Delete(new CardBindingModel { Id = id }))
+ {
+ throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка удаления продукта");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ }
+ private void ButtonRef_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/DiningRoom/DiningRoomView/FormCards.resx b/DiningRoom/DiningRoomView/FormCards.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/DiningRoom/DiningRoomView/FormCards.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/DiningRoom/DiningRoomView/FormCreateOrder.Designer.cs b/DiningRoom/DiningRoomView/FormCreateOrder.Designer.cs
new file mode 100644
index 0000000..1cfbb41
--- /dev/null
+++ b/DiningRoom/DiningRoomView/FormCreateOrder.Designer.cs
@@ -0,0 +1,143 @@
+namespace DiningRoomView
+{
+ partial class FormCreateOrder
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ labelProduct = new Label();
+ labelCount = new Label();
+ labelSum = new Label();
+ comboBoxProduct = new ComboBox();
+ textBoxCount = new TextBox();
+ textBoxSum = new TextBox();
+ ButtonSave = new Button();
+ ButtonCancel = new Button();
+ SuspendLayout();
+ //
+ // labelProduct
+ //
+ labelProduct.AutoSize = true;
+ labelProduct.Location = new Point(12, 8);
+ labelProduct.Name = "labelProduct";
+ labelProduct.Size = new Size(53, 15);
+ labelProduct.TabIndex = 0;
+ labelProduct.Text = "Изделие";
+ //
+ // labelCount
+ //
+ labelCount.AutoSize = true;
+ labelCount.Location = new Point(12, 37);
+ labelCount.Name = "labelCount";
+ labelCount.Size = new Size(72, 15);
+ labelCount.TabIndex = 1;
+ labelCount.Text = "Количество";
+ //
+ // labelSum
+ //
+ labelSum.AutoSize = true;
+ labelSum.Location = new Point(12, 66);
+ labelSum.Name = "labelSum";
+ labelSum.Size = new Size(45, 15);
+ labelSum.TabIndex = 2;
+ labelSum.Text = "Сумма";
+ //
+ // comboBoxProduct
+ //
+ comboBoxProduct.FormattingEnabled = true;
+ comboBoxProduct.Location = new Point(121, 5);
+ comboBoxProduct.Name = "comboBoxProduct";
+ comboBoxProduct.Size = new Size(292, 23);
+ comboBoxProduct.TabIndex = 3;
+ comboBoxProduct.SelectedIndexChanged += comboBoxProduct_SelectedIndexChanged;
+ //
+ // textBoxCount
+ //
+ textBoxCount.Location = new Point(121, 34);
+ textBoxCount.Name = "textBoxCount";
+ textBoxCount.Size = new Size(292, 23);
+ textBoxCount.TabIndex = 4;
+ textBoxCount.TextChanged += textBoxCount_TextChanged;
+ //
+ // textBoxSum
+ //
+ textBoxSum.Location = new Point(121, 63);
+ textBoxSum.Name = "textBoxSum";
+ textBoxSum.Size = new Size(292, 23);
+ textBoxSum.TabIndex = 5;
+ //
+ // ButtonSave
+ //
+ ButtonSave.Location = new Point(257, 92);
+ ButtonSave.Name = "ButtonSave";
+ ButtonSave.Size = new Size(75, 23);
+ ButtonSave.TabIndex = 6;
+ ButtonSave.Text = "Сохранить";
+ ButtonSave.UseVisualStyleBackColor = true;
+ ButtonSave.Click += ButtonSave_Click;
+ //
+ // ButtonCancel
+ //
+ ButtonCancel.Location = new Point(338, 92);
+ ButtonCancel.Name = "ButtonCancel";
+ ButtonCancel.Size = new Size(75, 23);
+ ButtonCancel.TabIndex = 7;
+ ButtonCancel.Text = "Отмена";
+ ButtonCancel.UseVisualStyleBackColor = true;
+ ButtonCancel.Click += ButtonCancel_Click;
+ //
+ // FormCreateOrder
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(425, 127);
+ Controls.Add(ButtonCancel);
+ Controls.Add(ButtonSave);
+ Controls.Add(textBoxSum);
+ Controls.Add(textBoxCount);
+ Controls.Add(comboBoxProduct);
+ Controls.Add(labelSum);
+ Controls.Add(labelCount);
+ Controls.Add(labelProduct);
+ Name = "FormCreateOrder";
+ Text = "Заказ";
+ Load += FormCreateOrder_Load;
+ ResumeLayout(false);
+ PerformLayout();
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Label labelProduct;
+ private System.Windows.Forms.Label labelCount;
+ private System.Windows.Forms.Label labelSum;
+ private System.Windows.Forms.ComboBox comboBoxProduct;
+ private System.Windows.Forms.TextBox textBoxCount;
+ private System.Windows.Forms.TextBox textBoxSum;
+ private System.Windows.Forms.Button ButtonSave;
+ private System.Windows.Forms.Button ButtonCancel;
+ }
+}
\ No newline at end of file
diff --git a/DiningRoom/DiningRoomView/FormCreateOrder.cs b/DiningRoom/DiningRoomView/FormCreateOrder.cs
new file mode 100644
index 0000000..1ae867c
--- /dev/null
+++ b/DiningRoom/DiningRoomView/FormCreateOrder.cs
@@ -0,0 +1,117 @@
+using DiningRoomBusinessLogic.BusinessLogic;
+using DiningRoomContracts.BindingModels;
+using DiningRoomContracts.BusinessLogicContracts;
+using DiningRoomContracts.SearchModels;
+using DiningRoomContracts.ViewModels;
+using DiningRoomDataModels.Enums;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace DiningRoomView
+{
+ public partial class FormCreateOrder : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IProductLogic _logicP;
+ private readonly IOrderLogic _logicO;
+
+ public FormCreateOrder(ILogger logger, IProductLogic logicP, IOrderLogic logicO)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _logicP = logicP;
+ _logicO = logicO;
+
+ }
+ private void FormCreateOrder_Load(object sender, EventArgs e)
+ {
+ _logger.LogInformation("Загрузка изделий для заказа");
+ // прописать логику
+ List list = _logicP.ReadList(null);
+ if (list != null)
+ {
+ comboBoxProduct.DisplayMember = "ProductName";
+ comboBoxProduct.ValueMember = "Id";
+ comboBoxProduct.DataSource = list;
+ comboBoxProduct.SelectedItem = null;
+ }
+ }
+ private void CalcSum()
+ {
+ if (comboBoxProduct.SelectedValue != null && !string.IsNullOrEmpty(textBoxCount.Text))
+ {
+ try
+ {
+ int id = Convert.ToInt32(comboBoxProduct.SelectedValue);
+ var product = _logicP.ReadElement(new ProductSearchModel { Id = id });
+ int count = Convert.ToInt32(textBoxCount.Text);
+ textBoxSum.Text = Math.Round(count * (product?.Cost ?? 0), 2).ToString();
+ _logger.LogInformation("Расчет суммы заказа");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка расчета суммы заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void textBoxCount_TextChanged(object sender, EventArgs e)
+ {
+ CalcSum();
+ }
+ private void comboBoxProduct_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ CalcSum();
+ }
+ 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;
+ }
+ _logger.LogInformation("Создание заказа");
+ try
+ {
+ var operationResult = _logicO.Create(new OrderBindingModel
+ {
+ ProductId = Convert.ToInt32(comboBoxProduct.SelectedValue),
+ ProductName = comboBoxProduct.Text,
+ Count = Convert.ToInt32(textBoxCount.Text),
+ Sum = Convert.ToDouble(textBoxSum.Text),
+ Status = OrderStatus.Принят
+ });
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах.");
+ }
+ MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
+ DialogResult = DialogResult.OK;
+ Close();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка создания заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonCancel_Click(object sender, EventArgs e)
+ {
+ DialogResult = DialogResult.Cancel;
+ Close();
+ }
+ }
+}
diff --git a/DiningRoom/DiningRoomView/FormCreateOrder.resx b/DiningRoom/DiningRoomView/FormCreateOrder.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/DiningRoom/DiningRoomView/FormCreateOrder.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/DiningRoom/DiningRoomView/FormDrink.Designer.cs b/DiningRoom/DiningRoomView/FormDrink.Designer.cs
index 9b605c0..bd30d8d 100644
--- a/DiningRoom/DiningRoomView/FormDrink.Designer.cs
+++ b/DiningRoom/DiningRoomView/FormDrink.Designer.cs
@@ -37,12 +37,14 @@
ID = new DataGridViewTextBoxColumn();
ComponentName = new DataGridViewTextBoxColumn();
Count = new DataGridViewTextBoxColumn();
+ ButtonSave = new Button();
+ ButtonCancel = new Button();
ButtonRef = new Button();
ButtonDel = new Button();
ButtonUpd = new Button();
ButtonAdd = new Button();
- ButtonSave = new Button();
- ButtonCancel = new Button();
+ comboBoxCards = new ComboBox();
+ label1 = new Label();
groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
@@ -67,14 +69,14 @@
//
// textBoxName
//
- textBoxName.Location = new Point(94, 6);
+ textBoxName.Location = new Point(133, 6);
textBoxName.Name = "textBoxName";
textBoxName.Size = new Size(247, 23);
textBoxName.TabIndex = 2;
//
// textBoxPrice
//
- textBoxPrice.Location = new Point(94, 38);
+ textBoxPrice.Location = new Point(133, 38);
textBoxPrice.Name = "textBoxPrice";
textBoxPrice.Size = new Size(100, 23);
textBoxPrice.TabIndex = 3;
@@ -82,13 +84,15 @@
// groupBox1
//
groupBox1.Controls.Add(dataGridView);
+ groupBox1.Controls.Add(ButtonSave);
+ groupBox1.Controls.Add(ButtonCancel);
groupBox1.Controls.Add(ButtonRef);
groupBox1.Controls.Add(ButtonDel);
groupBox1.Controls.Add(ButtonUpd);
groupBox1.Controls.Add(ButtonAdd);
- groupBox1.Location = new Point(12, 67);
+ groupBox1.Location = new Point(12, 122);
groupBox1.Name = "groupBox1";
- groupBox1.Size = new Size(510, 338);
+ groupBox1.Size = new Size(510, 389);
groupBox1.TabIndex = 4;
groupBox1.TabStop = false;
groupBox1.Text = "Компонент";
@@ -98,7 +102,7 @@
dataGridView.BackgroundColor = SystemColors.ButtonHighlight;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Columns.AddRange(new DataGridViewColumn[] { ID, ComponentName, Count });
- dataGridView.Location = new Point(0, 21);
+ dataGridView.Location = new Point(6, 35);
dataGridView.Name = "dataGridView";
dataGridView.RowTemplate.Height = 25;
dataGridView.Size = new Size(394, 311);
@@ -122,49 +126,9 @@
Count.HeaderText = "Количество";
Count.Name = "Count";
//
- // ButtonRef
- //
- ButtonRef.Location = new Point(400, 169);
- ButtonRef.Name = "ButtonRef";
- ButtonRef.Size = new Size(106, 28);
- ButtonRef.TabIndex = 4;
- ButtonRef.Text = "Обновить";
- ButtonRef.UseVisualStyleBackColor = true;
- ButtonRef.Click += ButtonRef_Click;
- //
- // ButtonDel
- //
- ButtonDel.Location = new Point(400, 135);
- ButtonDel.Name = "ButtonDel";
- ButtonDel.Size = new Size(106, 28);
- ButtonDel.TabIndex = 3;
- ButtonDel.Text = "Удалить";
- ButtonDel.UseVisualStyleBackColor = true;
- ButtonDel.Click += ButtonDel_Click;
- //
- // ButtonUpd
- //
- ButtonUpd.Location = new Point(400, 101);
- ButtonUpd.Name = "ButtonUpd";
- ButtonUpd.Size = new Size(106, 28);
- ButtonUpd.TabIndex = 2;
- ButtonUpd.Text = "Изменить";
- ButtonUpd.UseVisualStyleBackColor = true;
- ButtonUpd.Click += ButtonUpd_Click;
- //
- // ButtonAdd
- //
- ButtonAdd.Location = new Point(400, 67);
- ButtonAdd.Name = "ButtonAdd";
- ButtonAdd.Size = new Size(106, 28);
- ButtonAdd.TabIndex = 1;
- ButtonAdd.Text = "Добавить";
- ButtonAdd.UseVisualStyleBackColor = true;
- ButtonAdd.Click += ButtonAdd_Click;
- //
// ButtonSave
//
- ButtonSave.Location = new Point(354, 415);
+ ButtonSave.Location = new Point(354, 352);
ButtonSave.Name = "ButtonSave";
ButtonSave.Size = new Size(75, 23);
ButtonSave.TabIndex = 5;
@@ -174,7 +138,7 @@
//
// ButtonCancel
//
- ButtonCancel.Location = new Point(435, 415);
+ ButtonCancel.Location = new Point(435, 352);
ButtonCancel.Name = "ButtonCancel";
ButtonCancel.Size = new Size(75, 23);
ButtonCancel.TabIndex = 6;
@@ -182,13 +146,71 @@
ButtonCancel.UseVisualStyleBackColor = true;
ButtonCancel.Click += ButtonCancel_Click;
//
+ // ButtonRef
+ //
+ ButtonRef.Location = new Point(404, 137);
+ ButtonRef.Name = "ButtonRef";
+ ButtonRef.Size = new Size(106, 28);
+ ButtonRef.TabIndex = 4;
+ ButtonRef.Text = "Обновить";
+ ButtonRef.UseVisualStyleBackColor = true;
+ ButtonRef.Click += ButtonRef_Click;
+ //
+ // ButtonDel
+ //
+ ButtonDel.Location = new Point(404, 103);
+ ButtonDel.Name = "ButtonDel";
+ ButtonDel.Size = new Size(106, 28);
+ ButtonDel.TabIndex = 3;
+ ButtonDel.Text = "Удалить";
+ ButtonDel.UseVisualStyleBackColor = true;
+ ButtonDel.Click += ButtonDel_Click;
+ //
+ // ButtonUpd
+ //
+ ButtonUpd.Location = new Point(404, 69);
+ ButtonUpd.Name = "ButtonUpd";
+ ButtonUpd.Size = new Size(106, 28);
+ ButtonUpd.TabIndex = 2;
+ ButtonUpd.Text = "Изменить";
+ ButtonUpd.UseVisualStyleBackColor = true;
+ ButtonUpd.Click += ButtonUpd_Click;
+ //
+ // ButtonAdd
+ //
+ ButtonAdd.Location = new Point(404, 35);
+ ButtonAdd.Name = "ButtonAdd";
+ ButtonAdd.Size = new Size(106, 28);
+ ButtonAdd.TabIndex = 1;
+ ButtonAdd.Text = "Добавить";
+ ButtonAdd.UseVisualStyleBackColor = true;
+ ButtonAdd.Click += ButtonAdd_Click;
+ //
+ // comboBoxCards
+ //
+ comboBoxCards.BackColor = SystemColors.Window;
+ comboBoxCards.FormattingEnabled = true;
+ comboBoxCards.Location = new Point(133, 75);
+ comboBoxCards.Name = "comboBoxCards";
+ comboBoxCards.Size = new Size(247, 23);
+ comboBoxCards.TabIndex = 7;
+ //
+ // label1
+ //
+ label1.AutoSize = true;
+ label1.Location = new Point(12, 78);
+ label1.Name = "label1";
+ label1.Size = new Size(115, 15);
+ label1.TabIndex = 8;
+ label1.Text = "Алкогольная карта:";
+ //
// FormDrink
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
- ClientSize = new Size(536, 450);
- Controls.Add(ButtonCancel);
- Controls.Add(ButtonSave);
+ ClientSize = new Size(536, 505);
+ Controls.Add(label1);
+ Controls.Add(comboBoxCards);
Controls.Add(groupBox1);
Controls.Add(textBoxPrice);
Controls.Add(textBoxName);
@@ -220,5 +242,7 @@
private System.Windows.Forms.DataGridViewTextBoxColumn ID;
private System.Windows.Forms.DataGridViewTextBoxColumn ComponentName;
private System.Windows.Forms.DataGridViewTextBoxColumn Count;
+ private ComboBox comboBoxCards;
+ private Label label1;
}
}
\ No newline at end of file
diff --git a/DiningRoom/DiningRoomView/FormDrink.cs b/DiningRoom/DiningRoomView/FormDrink.cs
index b6b524e..cf69c87 100644
--- a/DiningRoom/DiningRoomView/FormDrink.cs
+++ b/DiningRoom/DiningRoomView/FormDrink.cs
@@ -1,9 +1,11 @@
using DiningRoomContracts.BindingModels;
using DiningRoomContracts.BusinessLogicContracts;
using DiningRoomContracts.SearchModels;
+using DiningRoomContracts.ViewModels;
using DiningRoomDataModels.Models;
using Microsoft.Extensions.Logging;
using System;
+using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
@@ -19,15 +21,46 @@ namespace DiningRoomView
{
private readonly ILogger _logger;
private readonly IDrinkLogic _logic;
+ private readonly ICardLogic _cardLogic;
private int? _id;
+
private Dictionary _drinkComponents;
- public int Id { set { _id = value; } }
- public FormDrink(ILogger logger, IDrinkLogic logic)
+ public int Id { get { return Convert.ToInt32(comboBoxCards.SelectedValue); } set { comboBoxCards.SelectedValue = value; _id = value; } }
+
+ private readonly List? _list;
+ public ICardModel? CardModel
+ {
+ get
+ {
+ if (_list == null)
+ {
+ return null;
+ }
+ foreach (var elem in _list)
+ {
+ if (elem.Id == Id)
+ {
+ return elem;
+ }
+ }
+ return null;
+ }
+ }
+ public FormDrink(ILogger logger, IDrinkLogic logic, ICardLogic cardLogic)
{
InitializeComponent();
_logger = logger;
_logic = logic;
+ _cardLogic = cardLogic;
_drinkComponents = new Dictionary();
+ _list = _cardLogic.ReadList(null);
+ if (_list != null)
+ {
+ comboBoxCards.DisplayMember = "CardName";
+ comboBoxCards.ValueMember = "Id";
+ comboBoxCards.DataSource = _list;
+ comboBoxCards.SelectedItem = null;
+ }
}
private void FormDrink_Load(object sender, EventArgs e)
{
@@ -167,6 +200,7 @@ namespace DiningRoomView
Id = _id ?? 0,
DrinkName = textBoxName.Text,
Cost = Convert.ToDouble(textBoxPrice.Text),
+ CardId = Convert.ToInt32(comboBoxCards.SelectedValue),
DrinkComponents = _drinkComponents
};
var operationResult = _id.HasValue ? _logic.Update(model) : _logic.Create(model);
diff --git a/DiningRoom/DiningRoomView/FormMain.Designer.cs b/DiningRoom/DiningRoomView/FormMain.Designer.cs
index a0c4956..225feb1 100644
--- a/DiningRoom/DiningRoomView/FormMain.Designer.cs
+++ b/DiningRoom/DiningRoomView/FormMain.Designer.cs
@@ -32,8 +32,8 @@
dataGridView2 = new DataGridView();
menuStrip1 = new MenuStrip();
продуктыToolStripMenuItem = new ToolStripMenuItem();
- клиентыToolStripMenuItem = new ToolStripMenuItem();
- поставщикиToolStripMenuItem = new ToolStripMenuItem();
+ заказыToolStripMenuItem = new ToolStripMenuItem();
+ алкогольныеКартыToolStripMenuItem = new ToolStripMenuItem();
button1 = new Button();
label1 = new Label();
label2 = new Label();
@@ -68,7 +68,7 @@
//
// menuStrip1
//
- menuStrip1.Items.AddRange(new ToolStripItem[] { продуктыToolStripMenuItem, клиентыToolStripMenuItem, поставщикиToolStripMenuItem });
+ menuStrip1.Items.AddRange(new ToolStripItem[] { продуктыToolStripMenuItem, заказыToolStripMenuItem, алкогольныеКартыToolStripMenuItem });
menuStrip1.Location = new Point(0, 0);
menuStrip1.Name = "menuStrip1";
menuStrip1.Size = new Size(666, 24);
@@ -82,15 +82,19 @@
продуктыToolStripMenuItem.Text = "Продукты";
продуктыToolStripMenuItem.Click += ПродуктыToolStripMenuItem_Click;
//
- // клиентыToolStripMenuItem
+ // заказыToolStripMenuItem
//
- клиентыToolStripMenuItem.Name = "клиентыToolStripMenuItem";
- клиентыToolStripMenuItem.Size = new Size(12, 20);
+ заказыToolStripMenuItem.Name = "заказыToolStripMenuItem";
+ заказыToolStripMenuItem.Size = new Size(58, 20);
+ заказыToolStripMenuItem.Text = "Заказы";
+ заказыToolStripMenuItem.Click += ЗаказыToolStripMenuItem_Click;
//
- // поставщикиToolStripMenuItem
+ // алкогольныеКартыToolStripMenuItem
//
- поставщикиToolStripMenuItem.Name = "поставщикиToolStripMenuItem";
- поставщикиToolStripMenuItem.Size = new Size(12, 20);
+ алкогольныеКартыToolStripMenuItem.Name = "алкогольныеКартыToolStripMenuItem";
+ алкогольныеКартыToolStripMenuItem.Size = new Size(130, 20);
+ алкогольныеКартыToolStripMenuItem.Text = "Алкогольные карты";
+ алкогольныеКартыToolStripMenuItem.Click += КартыToolStripMenuItem_Click;
//
// button1
//
@@ -216,8 +220,6 @@
private DataGridView dataGridView2;
private MenuStrip menuStrip1;
private ToolStripMenuItem продуктыToolStripMenuItem;
- private ToolStripMenuItem клиентыToolStripMenuItem;
- private ToolStripMenuItem поставщикиToolStripMenuItem;
private Button button1;
private Label label1;
private Label label2;
@@ -227,5 +229,7 @@
private Button button5;
private Button button6;
private Button button7;
+ private ToolStripMenuItem заказыToolStripMenuItem;
+ private ToolStripMenuItem алкогольныеКартыToolStripMenuItem;
}
}
\ No newline at end of file
diff --git a/DiningRoom/DiningRoomView/FormMain.cs b/DiningRoom/DiningRoomView/FormMain.cs
index edd637e..7f3df3a 100644
--- a/DiningRoom/DiningRoomView/FormMain.cs
+++ b/DiningRoom/DiningRoomView/FormMain.cs
@@ -79,6 +79,22 @@ namespace DiningRoomView
form.ShowDialog();
}
}
+ private void ЗаказыToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormOrders));
+ if (service is FormOrders form)
+ {
+ form.ShowDialog();
+ }
+ }
+ private void КартыToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormCards));
+ if (service is FormCards form)
+ {
+ form.ShowDialog();
+ }
+ }
private void ButtonAddProduct_Click(object sender, EventArgs e)
{
var service = Program.ServiceProvider?.GetService(typeof(FormProduct));
@@ -142,12 +158,12 @@ namespace DiningRoomView
}
private void ButtonUpdDrink_Click(object sender, EventArgs e)
{
- if (dataGridView1.SelectedRows.Count == 1)
+ if (dataGridView2.SelectedRows.Count == 1)
{
var service = Program.ServiceProvider?.GetService(typeof(FormDrink));
if (service is FormDrink form)
{
- form.Id = Convert.ToInt32(dataGridView1.SelectedRows[0].Cells["Id"].Value);
+ form.Id = Convert.ToInt32(dataGridView2.SelectedRows[0].Cells["Id"].Value);
if (form.ShowDialog() == DialogResult.OK)
{
LoadData();
diff --git a/DiningRoom/DiningRoomView/FormOrders.Designer.cs b/DiningRoom/DiningRoomView/FormOrders.Designer.cs
new file mode 100644
index 0000000..3c8d8f2
--- /dev/null
+++ b/DiningRoom/DiningRoomView/FormOrders.Designer.cs
@@ -0,0 +1,127 @@
+namespace DiningRoomView
+{
+ partial class FormOrders
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Windows Form Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ dataGridView = new DataGridView();
+ ButtonCreateOrder = new Button();
+ ButtonRef = new Button();
+ ButtonIssuedOrder = new Button();
+ ButtonOrderReady = new Button();
+ ButtonTakeOrderInWork = new Button();
+ ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
+ SuspendLayout();
+ //
+ // dataGridView
+ //
+ dataGridView.BackgroundColor = SystemColors.ButtonHighlight;
+ dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
+ dataGridView.EnableHeadersVisualStyles = false;
+ dataGridView.Location = new Point(12, 12);
+ dataGridView.MultiSelect = false;
+ dataGridView.Name = "dataGridView";
+ dataGridView.Size = new Size(600, 371);
+ dataGridView.TabIndex = 1;
+ //
+ // ButtonCreateOrder
+ //
+ ButtonCreateOrder.Location = new Point(618, 12);
+ ButtonCreateOrder.Name = "ButtonCreateOrder";
+ ButtonCreateOrder.Size = new Size(122, 23);
+ ButtonCreateOrder.TabIndex = 2;
+ ButtonCreateOrder.Text = "Создать заказ";
+ ButtonCreateOrder.UseVisualStyleBackColor = true;
+ ButtonCreateOrder.Click += ButtonCreateOrder_Click;
+ //
+ // ButtonRef
+ //
+ ButtonRef.Location = new Point(618, 147);
+ ButtonRef.Name = "ButtonRef";
+ ButtonRef.Size = new Size(122, 23);
+ ButtonRef.TabIndex = 6;
+ ButtonRef.Text = "Обновить список";
+ ButtonRef.UseVisualStyleBackColor = true;
+ ButtonRef.Click += ButtonRef_Click;
+ //
+ // ButtonIssuedOrder
+ //
+ ButtonIssuedOrder.Location = new Point(618, 118);
+ ButtonIssuedOrder.Name = "ButtonIssuedOrder";
+ ButtonIssuedOrder.Size = new Size(122, 23);
+ ButtonIssuedOrder.TabIndex = 5;
+ ButtonIssuedOrder.Text = "Заказ выдан";
+ ButtonIssuedOrder.UseVisualStyleBackColor = true;
+ ButtonIssuedOrder.Click += ButtonIssuedOrder_Click;
+ //
+ // ButtonOrderReady
+ //
+ ButtonOrderReady.Location = new Point(618, 89);
+ ButtonOrderReady.Name = "ButtonOrderReady";
+ ButtonOrderReady.Size = new Size(122, 23);
+ ButtonOrderReady.TabIndex = 4;
+ ButtonOrderReady.Text = "Заказ готов";
+ ButtonOrderReady.UseVisualStyleBackColor = true;
+ ButtonOrderReady.Click += ButtonOrderReady_Click;
+ //
+ // ButtonTakeOrderInWork
+ //
+ ButtonTakeOrderInWork.Location = new Point(618, 41);
+ ButtonTakeOrderInWork.Name = "ButtonTakeOrderInWork";
+ ButtonTakeOrderInWork.Size = new Size(122, 42);
+ ButtonTakeOrderInWork.TabIndex = 3;
+ ButtonTakeOrderInWork.Text = "Отдать на выполнение";
+ ButtonTakeOrderInWork.UseVisualStyleBackColor = true;
+ ButtonTakeOrderInWork.Click += ButtonTakeOrderInWork_Click;
+ //
+ // FormOrders
+ //
+ AutoScaleDimensions = new SizeF(7F, 15F);
+ AutoScaleMode = AutoScaleMode.Font;
+ ClientSize = new Size(752, 391);
+ Controls.Add(ButtonRef);
+ Controls.Add(ButtonIssuedOrder);
+ Controls.Add(ButtonOrderReady);
+ Controls.Add(ButtonTakeOrderInWork);
+ Controls.Add(ButtonCreateOrder);
+ Controls.Add(dataGridView);
+ Name = "FormOrders";
+ Text = "Заказы";
+ Load += FormMain_Load;
+ ((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
+ ResumeLayout(false);
+ }
+
+ #endregion
+ private System.Windows.Forms.DataGridView dataGridView;
+ private System.Windows.Forms.Button ButtonCreateOrder;
+ private System.Windows.Forms.Button ButtonRef;
+ private Button ButtonIssuedOrder;
+ private Button ButtonOrderReady;
+ private Button ButtonTakeOrderInWork;
+ }
+}
\ No newline at end of file
diff --git a/DiningRoom/DiningRoomView/FormOrders.cs b/DiningRoom/DiningRoomView/FormOrders.cs
new file mode 100644
index 0000000..2a4d9da
--- /dev/null
+++ b/DiningRoom/DiningRoomView/FormOrders.cs
@@ -0,0 +1,131 @@
+using DiningRoomBusinessLogic.BusinessLogic;
+using DiningRoomContracts.BindingModels;
+using DiningRoomContracts.BusinessLogicContracts;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace DiningRoomView
+{
+ public partial class FormOrders : Form
+ {
+ private readonly ILogger _logger;
+ private readonly IOrderLogic _orderLogic;
+ public FormOrders(ILogger logger, IOrderLogic orderLogic)
+ {
+ InitializeComponent();
+ _logger = logger;
+ _orderLogic = orderLogic;
+ }
+ private void FormMain_Load(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ private void LoadData()
+ {
+ _logger.LogInformation("Загрузка заказов");
+ // прописать логику
+ try
+ {
+ var list = _orderLogic.ReadList(null);
+ if (list != null)
+ {
+ dataGridView.DataSource = list;
+ dataGridView.Columns["ProductId"].Visible = false;
+ }
+ _logger.LogInformation("Загрузка продуктов");
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка загрузки продуктов");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ private void ButtonCreateOrder_Click(object sender, EventArgs e)
+ {
+ var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
+ if (service is FormCreateOrder form)
+ {
+ form.ShowDialog();
+ LoadData();
+ }
+ }
+ private void ButtonTakeOrderInWork_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
+ try
+ {
+ var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { Id = id });
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка передачи заказа в работу");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void ButtonOrderReady_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
+ try
+ {
+ var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { Id = id });
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка отметки о готовности заказа"); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void ButtonIssuedOrder_Click(object sender, EventArgs e)
+ {
+ if (dataGridView.SelectedRows.Count == 1)
+ {
+ int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
+ _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
+ try
+ {
+ var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel { Id = id });
+ if (!operationResult)
+ {
+ throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
+ }
+ _logger.LogInformation("Заказ №{id} выдан", id);
+ LoadData();
+ }
+ catch (Exception ex)
+ {
+ _logger.LogError(ex, "Ошибка отметки о выдачи заказа");
+ MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+ private void ButtonRef_Click(object sender, EventArgs e)
+ {
+ LoadData();
+ }
+ }
+}
diff --git a/DiningRoom/DiningRoomView/FormOrders.resx b/DiningRoom/DiningRoomView/FormOrders.resx
new file mode 100644
index 0000000..af32865
--- /dev/null
+++ b/DiningRoom/DiningRoomView/FormOrders.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/DiningRoom/DiningRoomView/Program.cs b/DiningRoom/DiningRoomView/Program.cs
index 4c8beda..743e4f7 100644
--- a/DiningRoom/DiningRoomView/Program.cs
+++ b/DiningRoom/DiningRoomView/Program.cs
@@ -54,6 +54,9 @@ namespace DiningRoomView
services.AddTransient();
services.AddTransient();
services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();
+ services.AddTransient();