ISEbd-21.Fedotov.I.A.LabWork06 #6

Closed
Ilfedotov.01 wants to merge 3 commits from ISEbd-21.Fedotov.I.A.LabWork06 into ISEbd-21.Fedotov.I.A.LabWork05
23 changed files with 1282 additions and 209 deletions
Showing only changes of commit f60f660bb2 - Show all commits

View File

@ -14,7 +14,7 @@ namespace DinerContracts.BindingModels
public int ClientID { get; set; } public int ClientID { get; set; }
public int ImplementerID { get; set; } public int? ImplementerID { get; set; }
public int Count { get; set; } public int Count { get; set; }

View File

@ -13,7 +13,7 @@ namespace DinerContracts.ViewModels
public int ClientID { get; set; } public int ClientID { get; set; }
public int SnackID { get; set; } public int SnackID { get; set; }
public int ImplementerID { get; set; } public int? ImplementerID { get; set; }
[DisplayName("Количество")] [DisplayName("Количество")]
public int Count { get; set; } public int Count { get; set; }
@ -41,6 +41,6 @@ namespace DinerContracts.ViewModels
public string ClientFIO { get; set; } = string.Empty; public string ClientFIO { get; set; } = string.Empty;
[DisplayName("Исполнитель")] [DisplayName("Исполнитель")]
public string ImplementerFIO { get; set; } = string.Empty; public string? ImplementerFIO { get; set; } = string.Empty;
} }
} }

View File

@ -71,6 +71,15 @@ namespace DinerDataBaseImplement.Implements
.Select(x => x.GetViewModel) .Select(x => x.GetViewModel)
.ToList(); .ToList();
} }
else if ((int)model.Status >= 0) {
return context.Orders
.Include(x => x.Snack)
.Include(x => x.Client)
.Include(x => x.Implementer)
.Where(x => x.Status >= 0)
.Select(x => x.GetViewModel)
.ToList();
}
return new(); return new();
} }
@ -89,10 +98,7 @@ namespace DinerDataBaseImplement.Implements
} }
context.Orders.Add(newOrder); context.Orders.Add(newOrder);
context.SaveChanges(); context.SaveChanges();
return context.Orders.Include(x => x.Snack) return newOrder.GetViewModel;
.Include(x => x.Client)
.Include(x => x.Implementer)
.FirstOrDefault(x => x.ID == newOrder.ID)?.GetViewModel;
} }
public OrderViewModel? Update(OrderBindingModel model) { public OrderViewModel? Update(OrderBindingModel model) {
using var context = new DinerDatabaseBy6Work(); using var context = new DinerDatabaseBy6Work();

View File

@ -12,7 +12,7 @@ using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
namespace DinerDataBaseImplement.Migrations namespace DinerDataBaseImplement.Migrations
{ {
[DbContext(typeof(DinerDatabaseBy6Work))] [DbContext(typeof(DinerDatabaseBy6Work))]
[Migration("20240513124832_InitMigration")] [Migration("20240513154945_InitMigration")]
partial class InitMigration partial class InitMigration
{ {
/// <inheritdoc /> /// <inheritdoc />
@ -117,7 +117,8 @@ namespace DinerDataBaseImplement.Migrations
b.Property<DateTime?>("DateImplement") b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<int>("ImplementerID") b.Property<int?>("ImplementerID")
.IsRequired()
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("SnackID") b.Property<int>("SnackID")

View File

@ -0,0 +1,257 @@
// <auto-generated />
using System;
using DinerDataBaseImplement;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace DinerDataBaseImplement.Migrations
{
[DbContext(typeof(DinerDatabaseBy6Work))]
[Migration("20240513162929_Migration01")]
partial class Migration01
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("ProductVersion", "8.0.3")
.HasAnnotation("Relational:MaxIdentifierLength", 128);
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
modelBuilder.Entity("DinerDataBaseImplement.Models.Client", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<string>("ClientFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.ToTable("Clients");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.Food", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<string>("ComponentName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<double>("Price")
.HasColumnType("float");
b.HasKey("ID");
b.ToTable("Components");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.Implementer", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<string>("ImplementerFIO")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<string>("Password")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.Property<int>("Qualification")
.HasColumnType("int");
b.Property<int>("WorkExperience")
.HasColumnType("int");
b.HasKey("ID");
b.ToTable("Implementers");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.Order", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("ClientID")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<DateTime>("DateCreate")
.HasColumnType("datetime2");
b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2");
b.Property<int?>("ImplementerID")
.HasColumnType("int");
b.Property<int>("SnackID")
.HasColumnType("int");
b.Property<int>("Status")
.HasColumnType("int");
b.Property<double>("Sum")
.HasColumnType("float");
b.HasKey("ID");
b.HasIndex("ClientID");
b.HasIndex("ImplementerID");
b.HasIndex("SnackID");
b.ToTable("Orders");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.Snack", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<double>("Price")
.HasColumnType("float");
b.Property<string>("ProductName")
.IsRequired()
.HasColumnType("nvarchar(max)");
b.HasKey("ID");
b.ToTable("Snacks");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.SnackFood", b =>
{
b.Property<int>("ID")
.ValueGeneratedOnAdd()
.HasColumnType("int");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("ID"));
b.Property<int>("ComponentID")
.HasColumnType("int");
b.Property<int>("Count")
.HasColumnType("int");
b.Property<int>("SnackID")
.HasColumnType("int");
b.HasKey("ID");
b.HasIndex("ComponentID");
b.HasIndex("SnackID");
b.ToTable("ProductComponents");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.Order", b =>
{
b.HasOne("DinerDataBaseImplement.Models.Client", "Client")
.WithMany("Orders")
.HasForeignKey("ClientID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DinerDataBaseImplement.Models.Implementer", "Implementer")
.WithMany("Orders")
.HasForeignKey("ImplementerID");
b.HasOne("DinerDataBaseImplement.Models.Snack", "Snack")
.WithMany("Orders")
.HasForeignKey("SnackID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Client");
b.Navigation("Implementer");
b.Navigation("Snack");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.SnackFood", b =>
{
b.HasOne("DinerDataBaseImplement.Models.Food", "Component")
.WithMany("SnackFood")
.HasForeignKey("ComponentID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DinerDataBaseImplement.Models.Snack", "Product")
.WithMany("Components")
.HasForeignKey("SnackID")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Component");
b.Navigation("Product");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.Client", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.Food", b =>
{
b.Navigation("SnackFood");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.Implementer", b =>
{
b.Navigation("Orders");
});
modelBuilder.Entity("DinerDataBaseImplement.Models.Snack", b =>
{
b.Navigation("Components");
b.Navigation("Orders");
});
#pragma warning restore 612, 618
}
}
}

View File

@ -0,0 +1,59 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace DinerDataBaseImplement.Migrations
{
/// <inheritdoc />
public partial class Migration01 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Orders_Implementers_ImplementerID",
table: "Orders");
migrationBuilder.AlterColumn<int>(
name: "ImplementerID",
table: "Orders",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "int");
migrationBuilder.AddForeignKey(
name: "FK_Orders_Implementers_ImplementerID",
table: "Orders",
column: "ImplementerID",
principalTable: "Implementers",
principalColumn: "ID");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Orders_Implementers_ImplementerID",
table: "Orders");
migrationBuilder.AlterColumn<int>(
name: "ImplementerID",
table: "Orders",
type: "int",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AddForeignKey(
name: "FK_Orders_Implementers_ImplementerID",
table: "Orders",
column: "ImplementerID",
principalTable: "Implementers",
principalColumn: "ID",
onDelete: ReferentialAction.Cascade);
}
}
}

View File

@ -114,7 +114,7 @@ namespace DinerDataBaseImplement.Migrations
b.Property<DateTime?>("DateImplement") b.Property<DateTime?>("DateImplement")
.HasColumnType("datetime2"); .HasColumnType("datetime2");
b.Property<int>("ImplementerID") b.Property<int?>("ImplementerID")
.HasColumnType("int"); .HasColumnType("int");
b.Property<int>("SnackID") b.Property<int>("SnackID")
@ -193,9 +193,7 @@ namespace DinerDataBaseImplement.Migrations
b.HasOne("DinerDataBaseImplement.Models.Implementer", "Implementer") b.HasOne("DinerDataBaseImplement.Models.Implementer", "Implementer")
.WithMany("Orders") .WithMany("Orders")
.HasForeignKey("ImplementerID") .HasForeignKey("ImplementerID");
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("DinerDataBaseImplement.Models.Snack", "Snack") b.HasOne("DinerDataBaseImplement.Models.Snack", "Snack")
.WithMany("Orders") .WithMany("Orders")

View File

@ -42,16 +42,6 @@ namespace DinerDataBaseImplement.Models {
}; };
} }
public static Implementer Create(ImplementerViewModel model) {
return new Implementer() {
ImplementerFIO = model.ImplementerFIO,
Password = model.Password,
WorkExperience = model.WorkExperience,
Qualification = model.Qualification,
ID = model.ID
};
}
public void Update(ImplementerBindingModel? model) { public void Update(ImplementerBindingModel? model) {
if (model == null) { if (model == null) {
return; return;

View File

@ -1,23 +1,25 @@
using DinerContracts.BindingModels; using DinerContracts.BindingModels;
using DinerContracts.ViewModels; using DinerContracts.ViewModels;
using DinerDataBaseImplement.Implements; using DinerDataBaseImplement.Implements;
using DinerDataBaseImplement.Migrations;
using DinerDataModels.Enums; using DinerDataModels.Enums;
using DinerDataModels.Models; using DinerDataModels.Models;
using System.ComponentModel.DataAnnotations; using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Net.Http.Headers;
using System.Xml.Linq; using System.Xml.Linq;
namespace DinerDataBaseImplement.Models namespace DinerDataBaseImplement.Models
{ {
public class Order : IOrderModel public class Order : IOrderModel
{ {
[Required] [ForeignKey("SnackID")]
public int SnackID { get; set; } public int SnackID { get; set; }
[Required] [Required]
public int ClientID { get; set; } public int ClientID { get; set; }
[Required] public int? ImplementerID { get; set; }
public int ImplementerID { get; set; }
[Required] [Required]
public int Count { get; set; } public int Count { get; set; }
@ -36,9 +38,9 @@ namespace DinerDataBaseImplement.Models
public virtual Snack Snack { get; set; } public virtual Snack Snack { get; set; }
public virtual Client Client { get; set; } public virtual Client Client { get; set; }
public virtual Implementer Implementer { get; set; } public virtual Implementer? Implementer { get; set; }
public static Order? Create(OrderBindingModel? model) public static Order? Create(OrderBindingModel model)
{ {
if (model == null) return null; if (model == null) return null;
return new Order() return new Order()
@ -61,8 +63,11 @@ namespace DinerDataBaseImplement.Models
Status = model.Status; Status = model.Status;
DateImplement = model?.DateImplement; DateImplement = model?.DateImplement;
} }
public OrderViewModel GetViewModel => new() public OrderViewModel GetViewModel {
get
{ {
using var context = new DinerDatabaseBy6Work();
return new OrderViewModel {
ID = ID, ID = ID,
SnackID = SnackID, SnackID = SnackID,
Count = Count, Count = Count,
@ -70,11 +75,13 @@ namespace DinerDataBaseImplement.Models
Status = Status, Status = Status,
DateCreate = DateCreate, DateCreate = DateCreate,
DateImplement = DateImplement, DateImplement = DateImplement,
ProductName = Snack.ProductName, ProductName = context.Snacks.FirstOrDefault(x => x.ID == SnackID)?.ProductName ?? string.Empty,
ClientID = ClientID, ClientID = ClientID,
ClientFIO = Client.ClientFIO, ClientFIO = context.Clients.FirstOrDefault(x => x.ID == ClientID)?.ClientFIO ?? string.Empty,
ImplementerID = ImplementerID, ImplementerID = ImplementerID,
ImplementerFIO = Implementer.ImplementerFIO ImplementerFIO = Implementer?.ImplementerFIO ?? string.Empty,
}; };
} }
} }
}
}

View File

@ -16,7 +16,7 @@ namespace DinerListImplement.Models
public int ClientID { get; private set; } public int ClientID { get; private set; }
public int ImplementerID { get; private set; } public int? ImplementerID { get; private set; }
public int Count { get; set; } public int Count { get; set; }

View File

@ -17,7 +17,7 @@ namespace DinerFileImplement.Models
public int ClientID { get; private set; } public int ClientID { get; private set; }
public int ImplementerID { get; set; } public int? ImplementerID { get; set; }
public int Count { get; set; } public int Count { get; set; }

View File

@ -26,8 +26,7 @@
/// Required method for Designer support - do not modify /// Required method for Designer support - do not modify
/// the contents of this method with the code editor. /// the contents of this method with the code editor.
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent() {
{
labelProduct = new Label(); labelProduct = new Label();
comboBoxProduct = new ComboBox(); comboBoxProduct = new ComboBox();
labelCount = new Label(); labelCount = new Label();
@ -36,12 +35,14 @@
textBoxSum = new TextBox(); textBoxSum = new TextBox();
buttonCancel = new Button(); buttonCancel = new Button();
buttonSave = new Button(); buttonSave = new Button();
labelClient = new Label();
comboBoxClient = new ComboBox();
SuspendLayout(); SuspendLayout();
// //
// labelProduct // labelProduct
// //
labelProduct.AutoSize = true; labelProduct.AutoSize = true;
labelProduct.Location = new Point(12, 9); labelProduct.Location = new Point(12, 39);
labelProduct.Name = "labelProduct"; labelProduct.Name = "labelProduct";
labelProduct.Size = new Size(37, 15); labelProduct.Size = new Size(37, 15);
labelProduct.TabIndex = 0; labelProduct.TabIndex = 0;
@ -52,7 +53,7 @@
comboBoxProduct.BackColor = SystemColors.ButtonShadow; comboBoxProduct.BackColor = SystemColors.ButtonShadow;
comboBoxProduct.DropDownStyle = ComboBoxStyle.DropDownList; comboBoxProduct.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxProduct.FormattingEnabled = true; comboBoxProduct.FormattingEnabled = true;
comboBoxProduct.Location = new Point(93, 6); comboBoxProduct.Location = new Point(93, 36);
comboBoxProduct.Name = "comboBoxProduct"; comboBoxProduct.Name = "comboBoxProduct";
comboBoxProduct.Size = new Size(289, 23); comboBoxProduct.Size = new Size(289, 23);
comboBoxProduct.TabIndex = 3; comboBoxProduct.TabIndex = 3;
@ -61,7 +62,7 @@
// labelCount // labelCount
// //
labelCount.AutoSize = true; labelCount.AutoSize = true;
labelCount.Location = new Point(12, 37); labelCount.Location = new Point(12, 67);
labelCount.Name = "labelCount"; labelCount.Name = "labelCount";
labelCount.Size = new Size(75, 15); labelCount.Size = new Size(75, 15);
labelCount.TabIndex = 4; labelCount.TabIndex = 4;
@ -69,7 +70,7 @@
// //
// textBoxCount // textBoxCount
// //
textBoxCount.Location = new Point(93, 34); textBoxCount.Location = new Point(93, 64);
textBoxCount.Name = "textBoxCount"; textBoxCount.Name = "textBoxCount";
textBoxCount.Size = new Size(289, 23); textBoxCount.Size = new Size(289, 23);
textBoxCount.TabIndex = 5; textBoxCount.TabIndex = 5;
@ -78,7 +79,7 @@
// label1 // label1
// //
label1.AutoSize = true; label1.AutoSize = true;
label1.Location = new Point(12, 66); label1.Location = new Point(12, 96);
label1.Name = "label1"; label1.Name = "label1";
label1.Size = new Size(48, 15); label1.Size = new Size(48, 15);
label1.TabIndex = 6; label1.TabIndex = 6;
@ -86,7 +87,7 @@
// //
// textBoxSum // textBoxSum
// //
textBoxSum.Location = new Point(93, 63); textBoxSum.Location = new Point(93, 93);
textBoxSum.Name = "textBoxSum"; textBoxSum.Name = "textBoxSum";
textBoxSum.ReadOnly = true; textBoxSum.ReadOnly = true;
textBoxSum.Size = new Size(289, 23); textBoxSum.Size = new Size(289, 23);
@ -94,7 +95,7 @@
// //
// buttonCancel // buttonCancel
// //
buttonCancel.Location = new Point(307, 92); buttonCancel.Location = new Point(307, 122);
buttonCancel.Name = "buttonCancel"; buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(75, 23); buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 8; buttonCancel.TabIndex = 8;
@ -104,7 +105,7 @@
// //
// buttonSave // buttonSave
// //
buttonSave.Location = new Point(226, 92); buttonSave.Location = new Point(226, 122);
buttonSave.Name = "buttonSave"; buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(75, 23); buttonSave.Size = new Size(75, 23);
buttonSave.TabIndex = 9; buttonSave.TabIndex = 9;
@ -112,11 +113,32 @@
buttonSave.UseVisualStyleBackColor = true; buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click; buttonSave.Click += buttonSave_Click;
// //
// labelClient
//
labelClient.AutoSize = true;
labelClient.Location = new Point(12, 9);
labelClient.Name = "labelClient";
labelClient.Size = new Size(49, 15);
labelClient.TabIndex = 10;
labelClient.Text = "Клиент:";
//
// comboBoxClient
//
comboBoxClient.BackColor = SystemColors.ButtonShadow;
comboBoxClient.DropDownStyle = ComboBoxStyle.DropDownList;
comboBoxClient.FormattingEnabled = true;
comboBoxClient.Location = new Point(93, 7);
comboBoxClient.Name = "comboBoxClient";
comboBoxClient.Size = new Size(289, 23);
comboBoxClient.TabIndex = 11;
//
// FormCreateOrder // FormCreateOrder
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(394, 122); ClientSize = new Size(394, 156);
Controls.Add(comboBoxClient);
Controls.Add(labelClient);
Controls.Add(buttonSave); Controls.Add(buttonSave);
Controls.Add(buttonCancel); Controls.Add(buttonCancel);
Controls.Add(textBoxSum); Controls.Add(textBoxSum);
@ -142,5 +164,7 @@
private TextBox textBoxSum; private TextBox textBoxSum;
private Button buttonCancel; private Button buttonCancel;
private Button buttonSave; private Button buttonSave;
private Label labelClient;
private ComboBox comboBoxClient;
} }
} }

View File

@ -1,5 +1,6 @@
using DinerContracts.BindingModels; using DinerContracts.BindingModels;
using DinerContracts.BusinessLogicsContacts; using DinerContracts.BusinessLogicsContacts;
using DinerContracts.BusinessLogicsContracts;
using DinerContracts.SearchModels; using DinerContracts.SearchModels;
using DinerDataModels.Enums; using DinerDataModels.Enums;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@ -20,13 +21,15 @@ namespace DinerView
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly ISnackLogic _logicSnack; private readonly ISnackLogic _logicSnack;
private readonly IOrderLogic _logicOrder; private readonly IOrderLogic _logicOrder;
private readonly IClientLogic _clientLogic;
public FormCreateOrder(ILogger<FormCreateOrder> logger, ISnackLogic logicSnack, IOrderLogic logicOrder) public FormCreateOrder(ILogger<FormCreateOrder> logger, ISnackLogic logicSnack, IOrderLogic logicOrder, IClientLogic clientLogic)
{ {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_logicSnack = logicSnack; _logicSnack = logicSnack;
_logicOrder = logicOrder; _logicOrder = logicOrder;
_clientLogic = clientLogic;
} }
private void CalcSum() private void CalcSum()
@ -71,6 +74,10 @@ namespace DinerView
{ {
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return; return;
}
if (comboBoxClient.SelectedValue == null) {
MessageBox.Show("Выбирите клиента", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
} }
_logger.LogInformation("Создание заказа"); _logger.LogInformation("Создание заказа");
try try
@ -80,6 +87,7 @@ namespace DinerView
SnackID = Convert.ToInt32(comboBoxProduct.SelectedValue), SnackID = Convert.ToInt32(comboBoxProduct.SelectedValue),
Count = Convert.ToInt32(textBoxCount.Text), Count = Convert.ToInt32(textBoxCount.Text),
Sum = Convert.ToDouble(textBoxSum.Text), Sum = Convert.ToDouble(textBoxSum.Text),
ClientID = Convert.ToInt32(comboBoxClient.SelectedValue)
}); });
if (!operationResult) throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах."); if (!operationResult) throw new Exception("Ошибка при создании заказа. Дополнительная информация в логах.");
@ -113,9 +121,17 @@ namespace DinerView
comboBoxProduct.DataSource = list; comboBoxProduct.DataSource = list;
comboBoxProduct.SelectedItem = null; comboBoxProduct.SelectedItem = null;
} }
var listClient = _clientLogic.ReadList(null);
if (listClient != null) {
comboBoxClient.DisplayMember = "ClientFIO";
comboBoxClient.ValueMember = "ID";
comboBoxClient.DataSource = listClient;
comboBoxClient.SelectedItem = null;
}
} }
catch (Exception ex) { catch (Exception ex) {
_logger.LogError(ex, "Ошибка загрузки списка снэков"); _logger.LogError(ex, "Ошибка загрузки списка снэков или клиентов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
} }
} }

View File

@ -0,0 +1,157 @@
namespace DinerView {
partial class FormImplementer {
/// <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() {
labelFIO = new Label();
labelPassword = new Label();
labelWorkExperience = new Label();
labelQualification = new Label();
textBoxFIO = new TextBox();
textBoxPaassword = new TextBox();
textBoxWorkExperience = new TextBox();
textBoxQualification = new TextBox();
buttonSave = new Button();
buttonCancel = new Button();
SuspendLayout();
//
// labelFIO
//
labelFIO.AutoSize = true;
labelFIO.Location = new Point(12, 19);
labelFIO.Name = "labelFIO";
labelFIO.Size = new Size(37, 15);
labelFIO.TabIndex = 1;
labelFIO.Text = "ФИО:";
//
// labelPassword
//
labelPassword.AutoSize = true;
labelPassword.Location = new Point(12, 50);
labelPassword.Name = "labelPassword";
labelPassword.Size = new Size(49, 15);
labelPassword.TabIndex = 2;
labelPassword.Text = "Пароль";
//
// labelWorkExperience
//
labelWorkExperience.AutoSize = true;
labelWorkExperience.Location = new Point(12, 88);
labelWorkExperience.Name = "labelWorkExperience";
labelWorkExperience.Size = new Size(82, 15);
labelWorkExperience.TabIndex = 3;
labelWorkExperience.Text = "Стаж работы:";
//
// labelQualification
//
labelQualification.AutoSize = true;
labelQualification.Location = new Point(180, 88);
labelQualification.Name = "labelQualification";
labelQualification.Size = new Size(88, 15);
labelQualification.TabIndex = 4;
labelQualification.Text = "Квалификация";
//
// textBoxFIO
//
textBoxFIO.Location = new Point(67, 16);
textBoxFIO.Name = "textBoxFIO";
textBoxFIO.Size = new Size(305, 23);
textBoxFIO.TabIndex = 5;
//
// textBoxPaassword
//
textBoxPaassword.Location = new Point(67, 47);
textBoxPaassword.Name = "textBoxPaassword";
textBoxPaassword.Size = new Size(305, 23);
textBoxPaassword.TabIndex = 6;
//
// textBoxWorkExperience
//
textBoxWorkExperience.Location = new Point(100, 85);
textBoxWorkExperience.Name = "textBoxWorkExperience";
textBoxWorkExperience.Size = new Size(69, 23);
textBoxWorkExperience.TabIndex = 7;
//
// textBoxQualification
//
textBoxQualification.Location = new Point(274, 85);
textBoxQualification.Name = "textBoxQualification";
textBoxQualification.Size = new Size(98, 23);
textBoxQualification.TabIndex = 8;
//
// buttonSave
//
buttonSave.Location = new Point(216, 124);
buttonSave.Name = "buttonSave";
buttonSave.Size = new Size(75, 23);
buttonSave.TabIndex = 10;
buttonSave.Text = "Сохранить";
buttonSave.UseVisualStyleBackColor = true;
buttonSave.Click += buttonSave_Click;
//
// buttonCancel
//
buttonCancel.Location = new Point(297, 124);
buttonCancel.Name = "buttonCancel";
buttonCancel.Size = new Size(75, 23);
buttonCancel.TabIndex = 9;
buttonCancel.Text = "Отмена";
buttonCancel.UseVisualStyleBackColor = true;
buttonCancel.Click += buttonCancel_Click;
//
// FormImplementer
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(394, 159);
Controls.Add(buttonSave);
Controls.Add(buttonCancel);
Controls.Add(textBoxQualification);
Controls.Add(textBoxWorkExperience);
Controls.Add(textBoxPaassword);
Controls.Add(textBoxFIO);
Controls.Add(labelQualification);
Controls.Add(labelWorkExperience);
Controls.Add(labelPassword);
Controls.Add(labelFIO);
Name = "FormImplementer";
Text = "Implementer";
Load += FormImplementer_Load;
ResumeLayout(false);
PerformLayout();
}
#endregion
private Label labelFIO;
private Label labelPassword;
private Label labelWorkExperience;
private Label labelQualification;
private TextBox textBoxFIO;
private TextBox textBoxPaassword;
private TextBox textBoxWorkExperience;
private TextBox textBoxQualification;
private Button buttonSave;
private Button buttonCancel;
}
}

View File

@ -0,0 +1,100 @@
using DinerContracts.BindingModels;
using DinerContracts.BusinessLogicsContracts;
using DinerContracts.SearchModels;
using Microsoft.CodeAnalysis.CSharp.Syntax;
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 DinerView {
public partial class FormImplementer : Form {
private readonly ILogger _logger;
private readonly IImplementerLogic _logic;
private int? _ID;
public int ID {
set { _ID = value; }
}
public FormImplementer(ILogger<FormImplementer> logger, IImplementerLogic logic) {
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void FormImplementer_Load(object sender, EventArgs e) {
if (_ID.HasValue) {
try {
_logger.LogInformation("Получение исполнителя");
var view = _logic.ReadElement(new ImplementerSearchModel {
ID = _ID.Value
});
if (view != null) {
textBoxFIO.Text = view.ImplementerFIO;
textBoxPaassword.Text = view.Password;
textBoxQualification.Text = view.Qualification.ToString();
textBoxWorkExperience.Text = view.WorkExperience.ToString();
}
}
catch (Exception ex) {
_logger.LogError(ex, "Ошибка получения исполнителя");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void buttonSave_Click(object sender, EventArgs e) {
if (string.IsNullOrEmpty(textBoxFIO.Text)) {
MessageBox.Show("Заполните ФИО", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxPaassword.Text)) {
MessageBox.Show("Придумайте пароль", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxQualification.Text)) {
MessageBox.Show("Укажите квалификацию", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
if (string.IsNullOrEmpty(textBoxWorkExperience.Text)) {
MessageBox.Show("Укажите стаж работы", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
_logger.LogInformation("Сохранение исполнителя");
try {
var model = new ImplementerBindingModel {
ID = _ID ?? 0,
ImplementerFIO = textBoxFIO.Text,
Password = textBoxPaassword.Text,
Qualification = Convert.ToInt32(textBoxQualification.Text),
WorkExperience = Convert.ToInt32(textBoxWorkExperience.Text),
};
var operationResult = _ID.HasValue ? _logic.Update(model) : _logic.Create(model);
if (!operationResult) {
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
}
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
DialogResult = DialogResult.OK;
Close();
}
catch (Exception ex) {
_logger.LogError(ex, "Ошибка сохранения исполнителя");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonCancel_Click(object sender, EventArgs e) {
DialogResult = DialogResult.Cancel;
Close();
}
}
}

View File

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

View File

@ -0,0 +1,115 @@
namespace DinerView {
partial class FormImplementers {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing) {
if (disposing && (components != null)) {
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
dataGridView = new DataGridView();
buttonAdd = new Button();
buttonCange = new Button();
buttonDelete = new Button();
buttonUpdate = new Button();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout();
//
// dataGridView
//
dataGridView.AllowUserToAddRows = false;
dataGridView.AllowUserToDeleteRows = false;
dataGridView.BackgroundColor = SystemColors.ButtonHighlight;
dataGridView.BorderStyle = BorderStyle.None;
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
dataGridView.Dock = DockStyle.Left;
dataGridView.Location = new Point(0, 0);
dataGridView.Name = "dataGridView";
dataGridView.RowHeadersVisible = false;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(468, 450);
dataGridView.TabIndex = 1;
//
// buttonAdd
//
buttonAdd.Location = new Point(509, 12);
buttonAdd.Name = "buttonAdd";
buttonAdd.Size = new Size(95, 35);
buttonAdd.TabIndex = 2;
buttonAdd.Text = "Добавить";
buttonAdd.UseVisualStyleBackColor = true;
buttonAdd.Click += buttonAdd_Click;
//
// buttonCange
//
buttonCange.Location = new Point(509, 53);
buttonCange.Name = "buttonCange";
buttonCange.Size = new Size(95, 35);
buttonCange.TabIndex = 3;
buttonCange.Text = "Изменить";
buttonCange.UseVisualStyleBackColor = true;
buttonCange.Click += buttonCange_Click;
//
// buttonDelete
//
buttonDelete.Location = new Point(509, 94);
buttonDelete.Name = "buttonDelete";
buttonDelete.Size = new Size(95, 35);
buttonDelete.TabIndex = 4;
buttonDelete.Text = "Удалить";
buttonDelete.UseVisualStyleBackColor = true;
buttonDelete.Click += buttonDelete_Click;
//
// buttonUpdate
//
buttonUpdate.Location = new Point(509, 135);
buttonUpdate.Name = "buttonUpdate";
buttonUpdate.Size = new Size(95, 35);
buttonUpdate.TabIndex = 5;
buttonUpdate.Text = "Обновить";
buttonUpdate.UseVisualStyleBackColor = true;
buttonUpdate.Click += buttonUpdate_Click;
//
// FormImplementers
//
AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font;
BackColor = SystemColors.ActiveBorder;
ClientSize = new Size(635, 450);
Controls.Add(buttonUpdate);
Controls.Add(buttonDelete);
Controls.Add(buttonCange);
Controls.Add(buttonAdd);
Controls.Add(dataGridView);
Name = "FormImplementers";
Text = "Исполнители";
Load += FormImplementers_Load;
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
ResumeLayout(false);
}
#endregion
private DataGridView dataGridView;
private Button buttonAdd;
private Button buttonCange;
private Button buttonDelete;
private Button buttonUpdate;
}
}

View File

@ -0,0 +1,91 @@
using DinerContracts.BindingModels;
using DinerContracts.BusinessLogicsContracts;
using Microsoft.EntityFrameworkCore.Diagnostics;
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 DinerView {
public partial class FormImplementers : Form {
private readonly ILogger _logger;
private readonly IImplementerLogic _logic;
public FormImplementers(ILogger<FormImplementers> logger, IImplementerLogic logic) {
InitializeComponent();
_logger = logger;
_logic = logic;
}
private void FormImplementers_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["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
}
_logger.LogInformation("Загрузка клиентов");
}
catch (Exception ex) {
_logger.LogError(ex, "Ошибка загрузки клиентов");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
private void buttonUpdate_Click(object sender, EventArgs e) {
LoadData();
}
private void buttonAdd_Click(object sender, EventArgs e) {
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
if (service is FormImplementer form) {
if (form.ShowDialog() == DialogResult.OK) {
LoadData();
}
}
}
private void buttonCange_Click(object sender, EventArgs e) {
if (dataGridView.SelectedRows.Count == 1) {
var service = Program.ServiceProvider?.GetService(typeof(FormImplementer));
if (service is FormImplementer form) {
form.ID = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ID"].Value);
if (form.ShowDialog() == DialogResult.OK) {
LoadData();
}
}
}
}
private void buttonDelete_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 ImplementerBindingModel { ID = id})) {
throw new Exception("Ошибка при удалении. Дополнительная информация в логах");
}
LoadData();
}
catch (Exception ex) {
_logger.LogError(ex, "Ошибка удаления компонента");
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
}
}

View File

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

View File

@ -31,17 +31,17 @@
toolStripMenuItemMenu = new ToolStripMenuItem(); toolStripMenuItemMenu = new ToolStripMenuItem();
toolStripMenuItemFoods = new ToolStripMenuItem(); toolStripMenuItemFoods = new ToolStripMenuItem();
toolStripMenuItemSnacks = new ToolStripMenuItem(); toolStripMenuItemSnacks = new ToolStripMenuItem();
toolStripMenuItemClient = new ToolStripMenuItem();
toolStripMenuItemImplementer = new ToolStripMenuItem();
toolStripMenuItemReport = new ToolStripMenuItem(); toolStripMenuItemReport = new ToolStripMenuItem();
FoodsToolStripMenuItem = new ToolStripMenuItem(); FoodsToolStripMenuItem = new ToolStripMenuItem();
FoodSnacksToolStripMenuItem = new ToolStripMenuItem(); FoodSnacksToolStripMenuItem = new ToolStripMenuItem();
ordersToolStripMenuItem = new ToolStripMenuItem(); ordersToolStripMenuItem = new ToolStripMenuItem();
toolStripMenuItemStartOfWork = new ToolStripMenuItem();
dataGridView = new DataGridView(); dataGridView = new DataGridView();
buttonCreateOrder = new Button(); buttonCreateOrder = new Button();
buttonInWork = new Button();
buttonIsReady = new Button();
buttonIsDelivery = new Button(); buttonIsDelivery = new Button();
buttonUpdateList = new Button(); buttonUpdateList = new Button();
toolStripMenuItemClient = new ToolStripMenuItem();
menuStrip.SuspendLayout(); menuStrip.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit(); ((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
SuspendLayout(); SuspendLayout();
@ -49,16 +49,16 @@
// menuStrip // menuStrip
// //
menuStrip.BackColor = SystemColors.Control; menuStrip.BackColor = SystemColors.Control;
menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItemMenu, toolStripMenuItemReport }); menuStrip.Items.AddRange(new ToolStripItem[] { toolStripMenuItemMenu, toolStripMenuItemReport, toolStripMenuItemStartOfWork });
menuStrip.Location = new Point(0, 0); menuStrip.Location = new Point(0, 0);
menuStrip.Name = "menuStrip"; menuStrip.Name = "menuStrip";
menuStrip.Size = new Size(951, 24); menuStrip.Size = new Size(1114, 24);
menuStrip.TabIndex = 0; menuStrip.TabIndex = 0;
menuStrip.Text = "Справочник"; menuStrip.Text = "Справочник";
// //
// toolStripMenuItemMenu // toolStripMenuItemMenu
// //
toolStripMenuItemMenu.DropDownItems.AddRange(new ToolStripItem[] { toolStripMenuItemFoods, toolStripMenuItemSnacks, toolStripMenuItemClient }); toolStripMenuItemMenu.DropDownItems.AddRange(new ToolStripItem[] { toolStripMenuItemFoods, toolStripMenuItemSnacks, toolStripMenuItemClient, toolStripMenuItemImplementer });
toolStripMenuItemMenu.Name = "toolStripMenuItemMenu"; toolStripMenuItemMenu.Name = "toolStripMenuItemMenu";
toolStripMenuItemMenu.Size = new Size(94, 20); toolStripMenuItemMenu.Size = new Size(94, 20);
toolStripMenuItemMenu.Text = "Справочники"; toolStripMenuItemMenu.Text = "Справочники";
@ -66,17 +66,31 @@
// toolStripMenuItemFoods // toolStripMenuItemFoods
// //
toolStripMenuItemFoods.Name = "toolStripMenuItemFoods"; toolStripMenuItemFoods.Name = "toolStripMenuItemFoods";
toolStripMenuItemFoods.Size = new Size(180, 22); toolStripMenuItemFoods.Size = new Size(149, 22);
toolStripMenuItemFoods.Text = "Продукты"; toolStripMenuItemFoods.Text = "Продукты";
toolStripMenuItemFoods.Click += toolStripMenuItemFoods_Click; toolStripMenuItemFoods.Click += toolStripMenuItemFoods_Click;
// //
// toolStripMenuItemSnacks // toolStripMenuItemSnacks
// //
toolStripMenuItemSnacks.Name = "toolStripMenuItemSnacks"; toolStripMenuItemSnacks.Name = "toolStripMenuItemSnacks";
toolStripMenuItemSnacks.Size = new Size(180, 22); toolStripMenuItemSnacks.Size = new Size(149, 22);
toolStripMenuItemSnacks.Text = "Снэки"; toolStripMenuItemSnacks.Text = "Снэки";
toolStripMenuItemSnacks.Click += toolStripMenuItemSnacks_Click; toolStripMenuItemSnacks.Click += toolStripMenuItemSnacks_Click;
// //
// toolStripMenuItemClient
//
toolStripMenuItemClient.Name = "toolStripMenuItemClient";
toolStripMenuItemClient.Size = new Size(149, 22);
toolStripMenuItemClient.Text = "Клиенты";
toolStripMenuItemClient.Click += toolStripMenuItemClient_Click;
//
// toolStripMenuItemImplementer
//
toolStripMenuItemImplementer.Name = "toolStripMenuItemImplementer";
toolStripMenuItemImplementer.Size = new Size(149, 22);
toolStripMenuItemImplementer.Text = "Исполнители";
toolStripMenuItemImplementer.Click += toolStripMenuItemImplementer_Click;
//
// toolStripMenuItemReport // toolStripMenuItemReport
// //
toolStripMenuItemReport.DropDownItems.AddRange(new ToolStripItem[] { FoodsToolStripMenuItem, FoodSnacksToolStripMenuItem, ordersToolStripMenuItem }); toolStripMenuItemReport.DropDownItems.AddRange(new ToolStripItem[] { FoodsToolStripMenuItem, FoodSnacksToolStripMenuItem, ordersToolStripMenuItem });
@ -105,6 +119,13 @@
ordersToolStripMenuItem.Text = "Список заказов"; ordersToolStripMenuItem.Text = "Список заказов";
ordersToolStripMenuItem.Click += ordersToolStripMenuItem_Click; ordersToolStripMenuItem.Click += ordersToolStripMenuItem_Click;
// //
// toolStripMenuItemStartOfWork
//
toolStripMenuItemStartOfWork.Name = "toolStripMenuItemStartOfWork";
toolStripMenuItemStartOfWork.Size = new Size(92, 20);
toolStripMenuItemStartOfWork.Text = "Запуск работ";
toolStripMenuItemStartOfWork.Click += toolStripMenuItemStartOfWork_Click;
//
// dataGridView // dataGridView
// //
dataGridView.AllowUserToAddRows = false; dataGridView.AllowUserToAddRows = false;
@ -119,12 +140,12 @@
dataGridView.ReadOnly = true; dataGridView.ReadOnly = true;
dataGridView.RowHeadersVisible = false; dataGridView.RowHeadersVisible = false;
dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect; dataGridView.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dataGridView.Size = new Size(726, 426); dataGridView.Size = new Size(889, 426);
dataGridView.TabIndex = 0; dataGridView.TabIndex = 0;
// //
// buttonCreateOrder // buttonCreateOrder
// //
buttonCreateOrder.Location = new Point(732, 36); buttonCreateOrder.Location = new Point(895, 40);
buttonCreateOrder.Name = "buttonCreateOrder"; buttonCreateOrder.Name = "buttonCreateOrder";
buttonCreateOrder.Size = new Size(212, 39); buttonCreateOrder.Size = new Size(212, 39);
buttonCreateOrder.TabIndex = 2; buttonCreateOrder.TabIndex = 2;
@ -132,29 +153,9 @@
buttonCreateOrder.UseVisualStyleBackColor = true; buttonCreateOrder.UseVisualStyleBackColor = true;
buttonCreateOrder.Click += buttonCreateOrder_Click; buttonCreateOrder.Click += buttonCreateOrder_Click;
// //
// buttonInWork
//
buttonInWork.Location = new Point(732, 81);
buttonInWork.Name = "buttonInWork";
buttonInWork.Size = new Size(212, 39);
buttonInWork.TabIndex = 3;
buttonInWork.Text = "Отдать на выполнение";
buttonInWork.UseVisualStyleBackColor = true;
buttonInWork.Click += buttonInWork_Click;
//
// buttonIsReady
//
buttonIsReady.Location = new Point(732, 126);
buttonIsReady.Name = "buttonIsReady";
buttonIsReady.Size = new Size(212, 39);
buttonIsReady.TabIndex = 4;
buttonIsReady.Text = "Заказ готов";
buttonIsReady.UseVisualStyleBackColor = true;
buttonIsReady.Click += buttonIsReady_Click;
//
// buttonIsDelivery // buttonIsDelivery
// //
buttonIsDelivery.Location = new Point(732, 171); buttonIsDelivery.Location = new Point(895, 100);
buttonIsDelivery.Name = "buttonIsDelivery"; buttonIsDelivery.Name = "buttonIsDelivery";
buttonIsDelivery.Size = new Size(212, 39); buttonIsDelivery.Size = new Size(212, 39);
buttonIsDelivery.TabIndex = 5; buttonIsDelivery.TabIndex = 5;
@ -164,7 +165,7 @@
// //
// buttonUpdateList // buttonUpdateList
// //
buttonUpdateList.Location = new Point(732, 216); buttonUpdateList.Location = new Point(895, 159);
buttonUpdateList.Name = "buttonUpdateList"; buttonUpdateList.Name = "buttonUpdateList";
buttonUpdateList.Size = new Size(212, 39); buttonUpdateList.Size = new Size(212, 39);
buttonUpdateList.TabIndex = 6; buttonUpdateList.TabIndex = 6;
@ -172,23 +173,14 @@
buttonUpdateList.UseVisualStyleBackColor = true; buttonUpdateList.UseVisualStyleBackColor = true;
buttonUpdateList.Click += buttonUpdateList_Click; buttonUpdateList.Click += buttonUpdateList_Click;
// //
// toolStripMenuItemClient
//
toolStripMenuItemClient.Name = "toolStripMenuItemClient";
toolStripMenuItemClient.Size = new Size(180, 22);
toolStripMenuItemClient.Text = "Клиенты";
toolStripMenuItemClient.Click += toolStripMenuItemClient_Click;
//
// FormMain // FormMain
// //
AutoScaleDimensions = new SizeF(7F, 15F); AutoScaleDimensions = new SizeF(7F, 15F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
BackColor = SystemColors.ScrollBar; BackColor = SystemColors.ScrollBar;
ClientSize = new Size(951, 450); ClientSize = new Size(1114, 450);
Controls.Add(buttonUpdateList); Controls.Add(buttonUpdateList);
Controls.Add(buttonIsDelivery); Controls.Add(buttonIsDelivery);
Controls.Add(buttonIsReady);
Controls.Add(buttonInWork);
Controls.Add(buttonCreateOrder); Controls.Add(buttonCreateOrder);
Controls.Add(dataGridView); Controls.Add(dataGridView);
Controls.Add(menuStrip); Controls.Add(menuStrip);
@ -211,8 +203,6 @@
private ToolStripMenuItem toolStripMenuItemFoods; private ToolStripMenuItem toolStripMenuItemFoods;
private ToolStripMenuItem toolStripMenuItemSnacks; private ToolStripMenuItem toolStripMenuItemSnacks;
private Button buttonCreateOrder; private Button buttonCreateOrder;
private Button buttonInWork;
private Button buttonIsReady;
private Button buttonIsDelivery; private Button buttonIsDelivery;
private Button buttonUpdateList; private Button buttonUpdateList;
private ToolStripMenuItem toolStripMenuItemReport; private ToolStripMenuItem toolStripMenuItemReport;
@ -220,5 +210,7 @@
private ToolStripMenuItem FoodSnacksToolStripMenuItem; private ToolStripMenuItem FoodSnacksToolStripMenuItem;
private ToolStripMenuItem ordersToolStripMenuItem; private ToolStripMenuItem ordersToolStripMenuItem;
private ToolStripMenuItem toolStripMenuItemClient; private ToolStripMenuItem toolStripMenuItemClient;
private ToolStripMenuItem toolStripMenuItemStartOfWork;
private ToolStripMenuItem toolStripMenuItemImplementer;
} }
} }

View File

@ -1,6 +1,7 @@
using DinerContracts.BindingModels; using DinerContracts.BindingModels;
using DinerContracts.BusinessLogicsContacts; using DinerContracts.BusinessLogicsContacts;
using DinerContracts.BusinessLogicsContracts; using DinerContracts.BusinessLogicsContracts;
using DinerDataBaseImplement.Models;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -19,11 +20,13 @@ namespace DinerView
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IOrderLogic _orderLogic; private readonly IOrderLogic _orderLogic;
private readonly IReportLogic _reportLogic; private readonly IReportLogic _reportLogic;
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic) { private readonly IWorkProcess _workProcess;
public FormMain(ILogger<FormMain> logger, IOrderLogic orderLogic, IReportLogic reportLogic, IWorkProcess workProcess) {
InitializeComponent(); InitializeComponent();
_logger = logger; _logger = logger;
_orderLogic = orderLogic; _orderLogic = orderLogic;
_reportLogic = reportLogic; _reportLogic = reportLogic;
_workProcess = workProcess;
} }
private void FormMain_Load(object sender, EventArgs e) { private void FormMain_Load(object sender, EventArgs e) {
@ -38,8 +41,10 @@ namespace DinerView
dataGridView.DataSource = list; dataGridView.DataSource = list;
dataGridView.Columns["SnackID"].Visible = false; dataGridView.Columns["SnackID"].Visible = false;
dataGridView.Columns["ClientID"].Visible = false; dataGridView.Columns["ClientID"].Visible = false;
dataGridView.Columns["ID"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill; dataGridView.Columns["ImplementerID"].Visible = false;
dataGridView.Columns["ID"].AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
dataGridView.Columns["Sum"].AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader; dataGridView.Columns["Sum"].AutoSizeMode = DataGridViewAutoSizeColumnMode.ColumnHeader;
dataGridView.Columns["ImplementerFIO"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
} }
_logger.LogInformation("Загрузка заказов"); _logger.LogInformation("Загрузка заказов");
} }
@ -160,5 +165,18 @@ namespace DinerView
form.ShowDialog(); form.ShowDialog();
} }
} }
private void toolStripMenuItemImplementer_Click(object sender, EventArgs e) {
var service = Program.ServiceProvider?.GetService(typeof(FormImplementers));
if (service is FormImplementers form) {
form.ShowDialog();
}
}
private void toolStripMenuItemStartOfWork_Click(object sender, EventArgs e) {
_workProcess.Work((Program.ServiceProvider?.GetService(typeof(IImplementerLogic)) as IImplementerLogic)!, _orderLogic);
MessageBox.Show("Процесс обработки запущен", "Сообщение",
MessageBoxButtons.OK, MessageBoxIcon.Information);
}
} }
} }

View File

@ -65,6 +65,8 @@ namespace DinerView
services.AddTransient<FormReportSnackFoods>(); services.AddTransient<FormReportSnackFoods>();
services.AddTransient<FormReportOrders>(); services.AddTransient<FormReportOrders>();
services.AddTransient<FormClient>(); services.AddTransient<FormClient>();
services.AddTransient<FormImplementers>();
services.AddTransient<FormImplementer>();
} }
} }
} }