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

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -0,0 +1,95 @@

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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