Merge branch 'Lab1_Base' into Lab1_Hard
This commit is contained in:
commit
48a5b72bbb
@ -39,7 +39,13 @@ namespace ConfectioneryBusinessLogic.BusinessLogics
|
|||||||
|
|
||||||
public bool TakeOrderInWork(OrderBindingModel model) => SetOrderStatus(model, OrderStatus.Выполняется);
|
public bool TakeOrderInWork(OrderBindingModel model) => SetOrderStatus(model, OrderStatus.Выполняется);
|
||||||
public bool DeliveryOrder(OrderBindingModel model) => SetOrderStatus(model, OrderStatus.Выдан);
|
public bool DeliveryOrder(OrderBindingModel model) => SetOrderStatus(model, OrderStatus.Выдан);
|
||||||
public bool FinishOrder(OrderBindingModel model) => SetOrderStatus(model, OrderStatus.Готов);
|
public bool FinishOrder(OrderBindingModel model)
|
||||||
|
{
|
||||||
|
var res = SetOrderStatus(model, OrderStatus.Готов);
|
||||||
|
if (res)
|
||||||
|
model.DateImplement = DateTime.Now;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
public List<OrderViewModel>? ReadList(OrderSearchModel? model)
|
||||||
{
|
{
|
||||||
|
@ -62,7 +62,12 @@ namespace ConfectioneryBusinessLogic
|
|||||||
}
|
}
|
||||||
public bool Update(ShopBindingModel model)
|
public bool Update(ShopBindingModel model)
|
||||||
{
|
{
|
||||||
CheckModel(model);
|
CheckModel(model, false);
|
||||||
|
if (string.IsNullOrEmpty(model.Name))
|
||||||
|
{
|
||||||
|
throw new ArgumentNullException("Нет названия магазина",
|
||||||
|
nameof(model.Name));
|
||||||
|
}
|
||||||
model.Pastries = new();
|
model.Pastries = new();
|
||||||
if (_shopStorage.Update(model) == null)
|
if (_shopStorage.Update(model) == null)
|
||||||
{
|
{
|
||||||
@ -103,7 +108,7 @@ namespace ConfectioneryBusinessLogic
|
|||||||
{
|
{
|
||||||
Name = model.Name
|
Name = model.Name
|
||||||
});
|
});
|
||||||
if (element != null && element.Id != model.Id)
|
if (element != null && element.Id != model.Id && element.Name == model.Name)
|
||||||
{
|
{
|
||||||
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ namespace ConfectioneryListImplement
|
|||||||
{
|
{
|
||||||
if (model.Id.HasValue && order.Id == model.Id)
|
if (model.Id.HasValue && order.Id == model.Id)
|
||||||
{
|
{
|
||||||
return order.GetViewModel;
|
return GetViewModel(order);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -55,7 +55,7 @@ namespace ConfectioneryListImplement
|
|||||||
{
|
{
|
||||||
if (order.Id == model.Id)
|
if (order.Id == model.Id)
|
||||||
{
|
{
|
||||||
return new() { order.GetViewModel };
|
return new() { GetViewModel(order) };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new();
|
return new();
|
||||||
@ -66,7 +66,7 @@ namespace ConfectioneryListImplement
|
|||||||
var result = new List<OrderViewModel>();
|
var result = new List<OrderViewModel>();
|
||||||
foreach (var order in _source.Orders)
|
foreach (var order in _source.Orders)
|
||||||
{
|
{
|
||||||
result.Add(order.GetViewModel);
|
result.Add(GetViewModel(order));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -102,5 +102,19 @@ namespace ConfectioneryListImplement
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private OrderViewModel GetViewModel(Order model)
|
||||||
|
{
|
||||||
|
var res = model.GetViewModel;
|
||||||
|
foreach (var pastry in _source.Pastry)
|
||||||
|
{
|
||||||
|
if (pastry.Id == model.PastryId)
|
||||||
|
{
|
||||||
|
res.PastryName = pastry.PastryName;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
7
Confectionery/FormMain.Designer.cs
generated
7
Confectionery/FormMain.Designer.cs
generated
@ -67,21 +67,21 @@
|
|||||||
// pastryToolStripMenuItem
|
// pastryToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.pastryToolStripMenuItem.Name = "pastryToolStripMenuItem";
|
this.pastryToolStripMenuItem.Name = "pastryToolStripMenuItem";
|
||||||
this.pastryToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
this.pastryToolStripMenuItem.Size = new System.Drawing.Size(145, 22);
|
||||||
this.pastryToolStripMenuItem.Text = "Изделия";
|
this.pastryToolStripMenuItem.Text = "Изделия";
|
||||||
this.pastryToolStripMenuItem.Click += new System.EventHandler(this.PastryToolStripMenuItem_Click);
|
this.pastryToolStripMenuItem.Click += new System.EventHandler(this.PastryToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// componentToolStripMenuItem
|
// componentToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.componentToolStripMenuItem.Name = "componentToolStripMenuItem";
|
this.componentToolStripMenuItem.Name = "componentToolStripMenuItem";
|
||||||
this.componentToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
this.componentToolStripMenuItem.Size = new System.Drawing.Size(145, 22);
|
||||||
this.componentToolStripMenuItem.Text = "Компоненты";
|
this.componentToolStripMenuItem.Text = "Компоненты";
|
||||||
this.componentToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click);
|
this.componentToolStripMenuItem.Click += new System.EventHandler(this.ComponentsToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
// ShopsToolStripMenuItem
|
// ShopsToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.ShopsToolStripMenuItem.Name = "ShopsToolStripMenuItem";
|
this.ShopsToolStripMenuItem.Name = "ShopsToolStripMenuItem";
|
||||||
this.ShopsToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
this.ShopsToolStripMenuItem.Size = new System.Drawing.Size(145, 22);
|
||||||
this.ShopsToolStripMenuItem.Text = "Магазины";
|
this.ShopsToolStripMenuItem.Text = "Магазины";
|
||||||
this.ShopsToolStripMenuItem.Click += new System.EventHandler(this.ShopsToolStripMenuItem_Click);
|
this.ShopsToolStripMenuItem.Click += new System.EventHandler(this.ShopsToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
@ -154,6 +154,7 @@
|
|||||||
//
|
//
|
||||||
// buttonAddPastryInShop
|
// buttonAddPastryInShop
|
||||||
//
|
//
|
||||||
|
this.buttonAddPastryInShop.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.buttonAddPastryInShop.Location = new System.Drawing.Point(624, 326);
|
this.buttonAddPastryInShop.Location = new System.Drawing.Point(624, 326);
|
||||||
this.buttonAddPastryInShop.Name = "buttonAddPastryInShop";
|
this.buttonAddPastryInShop.Name = "buttonAddPastryInShop";
|
||||||
this.buttonAddPastryInShop.Size = new System.Drawing.Size(147, 31);
|
this.buttonAddPastryInShop.Size = new System.Drawing.Size(147, 31);
|
||||||
|
112
Confectionery/FormShop.Designer.cs
generated
112
Confectionery/FormShop.Designer.cs
generated
@ -31,6 +31,15 @@
|
|||||||
this.label1 = new System.Windows.Forms.Label();
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
this.comboBoxShop = new System.Windows.Forms.ComboBox();
|
this.comboBoxShop = new System.Windows.Forms.ComboBox();
|
||||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||||
|
this.PastryName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.Price = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.Count = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
|
this.label3 = new System.Windows.Forms.Label();
|
||||||
|
this.textBoxAddress = new System.Windows.Forms.TextBox();
|
||||||
|
this.textBoxDateOpening = new System.Windows.Forms.TextBox();
|
||||||
|
this.buttonCancel = new System.Windows.Forms.Button();
|
||||||
|
this.buttonSave = new System.Windows.Forms.Button();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
@ -39,16 +48,16 @@
|
|||||||
this.label1.AutoSize = true;
|
this.label1.AutoSize = true;
|
||||||
this.label1.Location = new System.Drawing.Point(12, 9);
|
this.label1.Location = new System.Drawing.Point(12, 9);
|
||||||
this.label1.Name = "label1";
|
this.label1.Name = "label1";
|
||||||
this.label1.Size = new System.Drawing.Size(124, 15);
|
this.label1.Size = new System.Drawing.Size(116, 15);
|
||||||
this.label1.TabIndex = 0;
|
this.label1.TabIndex = 0;
|
||||||
this.label1.Text = "Выбранный магазин:";
|
this.label1.Text = "Название магазина:";
|
||||||
//
|
//
|
||||||
// comboBoxShop
|
// comboBoxShop
|
||||||
//
|
//
|
||||||
this.comboBoxShop.FormattingEnabled = true;
|
this.comboBoxShop.FormattingEnabled = true;
|
||||||
this.comboBoxShop.Location = new System.Drawing.Point(142, 9);
|
this.comboBoxShop.Location = new System.Drawing.Point(12, 27);
|
||||||
this.comboBoxShop.Name = "comboBoxShop";
|
this.comboBoxShop.Name = "comboBoxShop";
|
||||||
this.comboBoxShop.Size = new System.Drawing.Size(121, 23);
|
this.comboBoxShop.Size = new System.Drawing.Size(141, 23);
|
||||||
this.comboBoxShop.TabIndex = 1;
|
this.comboBoxShop.TabIndex = 1;
|
||||||
this.comboBoxShop.SelectedIndexChanged += new System.EventHandler(this.ComboBoxShop_SelectedIndexChanged);
|
this.comboBoxShop.SelectedIndexChanged += new System.EventHandler(this.ComboBoxShop_SelectedIndexChanged);
|
||||||
//
|
//
|
||||||
@ -58,17 +67,97 @@
|
|||||||
| System.Windows.Forms.AnchorStyles.Left)
|
| System.Windows.Forms.AnchorStyles.Left)
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||||
this.dataGridView.Location = new System.Drawing.Point(12, 38);
|
this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||||
|
this.PastryName,
|
||||||
|
this.Price,
|
||||||
|
this.Count});
|
||||||
|
this.dataGridView.Location = new System.Drawing.Point(12, 64);
|
||||||
this.dataGridView.Name = "dataGridView";
|
this.dataGridView.Name = "dataGridView";
|
||||||
this.dataGridView.RowTemplate.Height = 25;
|
this.dataGridView.RowTemplate.Height = 25;
|
||||||
this.dataGridView.Size = new System.Drawing.Size(583, 242);
|
this.dataGridView.Size = new System.Drawing.Size(583, 213);
|
||||||
this.dataGridView.TabIndex = 2;
|
this.dataGridView.TabIndex = 2;
|
||||||
//
|
//
|
||||||
|
// PastryName
|
||||||
|
//
|
||||||
|
this.PastryName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||||
|
this.PastryName.HeaderText = "Имя изделия";
|
||||||
|
this.PastryName.Name = "PastryName";
|
||||||
|
//
|
||||||
|
// Price
|
||||||
|
//
|
||||||
|
this.Price.HeaderText = "Цена";
|
||||||
|
this.Price.Name = "Price";
|
||||||
|
//
|
||||||
|
// Count
|
||||||
|
//
|
||||||
|
this.Count.HeaderText = "Количество";
|
||||||
|
this.Count.Name = "Count";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
this.label2.AutoSize = true;
|
||||||
|
this.label2.Location = new System.Drawing.Point(159, 9);
|
||||||
|
this.label2.Name = "label2";
|
||||||
|
this.label2.Size = new System.Drawing.Size(97, 15);
|
||||||
|
this.label2.TabIndex = 3;
|
||||||
|
this.label2.Text = "Адрес магазина:";
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
this.label3.AutoSize = true;
|
||||||
|
this.label3.Location = new System.Drawing.Point(386, 9);
|
||||||
|
this.label3.Name = "label3";
|
||||||
|
this.label3.Size = new System.Drawing.Size(100, 15);
|
||||||
|
this.label3.TabIndex = 4;
|
||||||
|
this.label3.Text = "Время открытия:";
|
||||||
|
//
|
||||||
|
// textBoxAddress
|
||||||
|
//
|
||||||
|
this.textBoxAddress.Location = new System.Drawing.Point(159, 27);
|
||||||
|
this.textBoxAddress.Name = "textBoxAddress";
|
||||||
|
this.textBoxAddress.Size = new System.Drawing.Size(221, 23);
|
||||||
|
this.textBoxAddress.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// textBoxDateOpening
|
||||||
|
//
|
||||||
|
this.textBoxDateOpening.Location = new System.Drawing.Point(386, 27);
|
||||||
|
this.textBoxDateOpening.Name = "textBoxDateOpening";
|
||||||
|
this.textBoxDateOpening.Size = new System.Drawing.Size(209, 23);
|
||||||
|
this.textBoxDateOpening.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// buttonCancel
|
||||||
|
//
|
||||||
|
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonCancel.Location = new System.Drawing.Point(492, 283);
|
||||||
|
this.buttonCancel.Name = "buttonCancel";
|
||||||
|
this.buttonCancel.Size = new System.Drawing.Size(103, 23);
|
||||||
|
this.buttonCancel.TabIndex = 7;
|
||||||
|
this.buttonCancel.Text = "Отмена";
|
||||||
|
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||||
|
//
|
||||||
|
// buttonSave
|
||||||
|
//
|
||||||
|
this.buttonSave.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.buttonSave.Location = new System.Drawing.Point(366, 284);
|
||||||
|
this.buttonSave.Name = "buttonSave";
|
||||||
|
this.buttonSave.Size = new System.Drawing.Size(120, 22);
|
||||||
|
this.buttonSave.TabIndex = 8;
|
||||||
|
this.buttonSave.Text = "Сохранить";
|
||||||
|
this.buttonSave.UseVisualStyleBackColor = true;
|
||||||
|
this.buttonSave.Click += new System.EventHandler(this.ButtonSave_Click);
|
||||||
|
//
|
||||||
// FormShop
|
// FormShop
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(607, 292);
|
this.ClientSize = new System.Drawing.Size(607, 317);
|
||||||
|
this.Controls.Add(this.buttonSave);
|
||||||
|
this.Controls.Add(this.buttonCancel);
|
||||||
|
this.Controls.Add(this.textBoxDateOpening);
|
||||||
|
this.Controls.Add(this.textBoxAddress);
|
||||||
|
this.Controls.Add(this.label3);
|
||||||
|
this.Controls.Add(this.label2);
|
||||||
this.Controls.Add(this.dataGridView);
|
this.Controls.Add(this.dataGridView);
|
||||||
this.Controls.Add(this.comboBoxShop);
|
this.Controls.Add(this.comboBoxShop);
|
||||||
this.Controls.Add(this.label1);
|
this.Controls.Add(this.label1);
|
||||||
@ -85,5 +174,14 @@
|
|||||||
private Label label1;
|
private Label label1;
|
||||||
private ComboBox comboBoxShop;
|
private ComboBox comboBoxShop;
|
||||||
private DataGridView dataGridView;
|
private DataGridView dataGridView;
|
||||||
|
private Label label2;
|
||||||
|
private Label label3;
|
||||||
|
private TextBox textBoxAddress;
|
||||||
|
private TextBox textBoxDateOpening;
|
||||||
|
private Button buttonCancel;
|
||||||
|
private Button buttonSave;
|
||||||
|
private DataGridViewTextBoxColumn PastryName;
|
||||||
|
private DataGridViewTextBoxColumn Price;
|
||||||
|
private DataGridViewTextBoxColumn Count;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,8 @@
|
|||||||
using ConfectioneryContracts.BusinessLogicsContracts;
|
using ConfectioneryContracts.BindingModels;
|
||||||
|
using ConfectioneryContracts.BusinessLogicsContracts;
|
||||||
using ConfectioneryContracts.ViewModels;
|
using ConfectioneryContracts.ViewModels;
|
||||||
|
using ConfectioneryDataModels;
|
||||||
|
using ConfectioneryDataModels.Models;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
@ -8,6 +11,7 @@ using System.ComponentModel;
|
|||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
@ -16,21 +20,55 @@ namespace ConfectioneryView
|
|||||||
{
|
{
|
||||||
public partial class FormShop : Form
|
public partial class FormShop : Form
|
||||||
{
|
{
|
||||||
private readonly List<ShopViewModel>? _list;
|
private readonly List<ShopViewModel>? _listShops;
|
||||||
private readonly IShopLogic _logic;
|
private readonly IShopLogic _logic;
|
||||||
private readonly ILogger _logger;
|
private readonly ILogger _logger;
|
||||||
|
private IShopModel? _currentShopModel;
|
||||||
|
|
||||||
|
public int Id
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return Convert.ToInt32(comboBoxShop.SelectedValue);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
comboBoxShop.SelectedValue = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public IShopModel? ShopModel
|
||||||
|
{
|
||||||
|
get => _currentShopModel;
|
||||||
|
}
|
||||||
|
|
||||||
|
private IShopModel? GetShop()
|
||||||
|
{
|
||||||
|
var list = _logic.ReadList(null);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
foreach (var elem in list)
|
||||||
|
{
|
||||||
|
if (elem.Id == this.Id)
|
||||||
|
{
|
||||||
|
return elem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public FormShop(ILogger<FormShop> logger, IShopLogic logic)
|
public FormShop(ILogger<FormShop> logger, IShopLogic logic)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
_list = logic.ReadList(null);
|
_listShops = logic.ReadList(null);
|
||||||
_logic = logic;
|
_logic = logic;
|
||||||
if (_list != null)
|
if (_listShops != null)
|
||||||
{
|
{
|
||||||
comboBoxShop.DisplayMember = "Name";
|
comboBoxShop.DisplayMember = "Name";
|
||||||
comboBoxShop.ValueMember = "Id";
|
comboBoxShop.ValueMember = "Id";
|
||||||
comboBoxShop.DataSource = _list;
|
comboBoxShop.DataSource = _listShops;
|
||||||
comboBoxShop.SelectedItem = null;
|
comboBoxShop.SelectedItem = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -39,13 +77,22 @@ namespace ConfectioneryView
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var list = _logic.ReadList(null);
|
var currentShop = _logic.ReadElement(new() { Id = this.Id});
|
||||||
if (list != null)
|
if (currentShop != null)
|
||||||
{
|
{
|
||||||
dataGridView.DataSource = list;
|
var vmodel = GetShop();
|
||||||
dataGridView.Columns["Id"].Visible = false;
|
if (vmodel != null)
|
||||||
dataGridView.Columns["Name"].AutoSizeMode =
|
{
|
||||||
DataGridViewAutoSizeColumnMode.Fill;
|
comboBoxShop.Text = vmodel.Name;
|
||||||
|
textBoxAddress.Text = vmodel.Address;
|
||||||
|
textBoxDateOpening.Text = Convert.ToString(vmodel.DateOpening);
|
||||||
|
}
|
||||||
|
dataGridView.Rows.Clear();
|
||||||
|
foreach (var el in currentShop.Pastries.Values)
|
||||||
|
{
|
||||||
|
dataGridView.Rows.Add(new object[]{el.Item1.PastryName, el.Item1.Price, el.Item2 });
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
_logger.LogInformation("Загрузка магазинов");
|
_logger.LogInformation("Загрузка магазинов");
|
||||||
}
|
}
|
||||||
@ -61,5 +108,60 @@ namespace ConfectioneryView
|
|||||||
{
|
{
|
||||||
LoadData();
|
LoadData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ButtonSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(comboBoxShop.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните название", "Ошибка",
|
||||||
|
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(textBoxAddress.Text))
|
||||||
|
{
|
||||||
|
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK,
|
||||||
|
MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_logger.LogInformation("Сохранение изделия");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var vmodel = GetShop();
|
||||||
|
if (vmodel != null)
|
||||||
|
{
|
||||||
|
_currentShopModel = vmodel;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Создаем новый магазин если не нашли такого
|
||||||
|
DateTime.TryParse(textBoxDateOpening.Text, out var dateTime);
|
||||||
|
ShopBindingModel model = new()
|
||||||
|
{
|
||||||
|
Name = comboBoxShop.Text,
|
||||||
|
Address = textBoxAddress.Text,
|
||||||
|
DateOpening = dateTime
|
||||||
|
};
|
||||||
|
var operationResult = _logic.Create(model);
|
||||||
|
_currentShopModel = 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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,4 +57,13 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<metadata name="PastryName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="Price.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
|
<metadata name="Count.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>True</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
@ -36,6 +36,7 @@ namespace ConfectioneryView
|
|||||||
{
|
{
|
||||||
dataGridView.DataSource = list;
|
dataGridView.DataSource = list;
|
||||||
dataGridView.Columns["Id"].Visible = false;
|
dataGridView.Columns["Id"].Visible = false;
|
||||||
|
dataGridView.Columns["PastryComponents"].Visible = false;
|
||||||
dataGridView.Columns["PastryName"].AutoSizeMode =
|
dataGridView.Columns["PastryName"].AutoSizeMode =
|
||||||
DataGridViewAutoSizeColumnMode.Fill;
|
DataGridViewAutoSizeColumnMode.Fill;
|
||||||
}
|
}
|
||||||
|
@ -41,9 +41,8 @@ namespace ConfectioneryView
|
|||||||
}
|
}
|
||||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
var service =
|
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
|
||||||
Program.ServiceProvider?.GetService(typeof(FormComponent));
|
if (service is FormShop form)
|
||||||
if (service is FormComponent form)
|
|
||||||
{
|
{
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
@ -55,14 +54,23 @@ namespace ConfectioneryView
|
|||||||
{
|
{
|
||||||
if (dataGridView.SelectedRows.Count == 1)
|
if (dataGridView.SelectedRows.Count == 1)
|
||||||
{
|
{
|
||||||
var service =
|
var service = Program.ServiceProvider?.GetService(typeof(FormShop));
|
||||||
Program.ServiceProvider?.GetService(typeof(FormComponent));
|
if (service is FormShop form)
|
||||||
if (service is FormComponent form)
|
|
||||||
{
|
{
|
||||||
form.Id =
|
var id = form.Id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||||
Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
|
||||||
if (form.ShowDialog() == DialogResult.OK)
|
if (form.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
|
var model = form.ShopModel;
|
||||||
|
if (model != null)
|
||||||
|
{
|
||||||
|
_logic.Update(new()
|
||||||
|
{
|
||||||
|
Id = id,
|
||||||
|
Address = model.Address,
|
||||||
|
Name = model.Name,
|
||||||
|
DateOpening= model.DateOpening,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,6 +53,7 @@ namespace ConfectioneryView
|
|||||||
services.AddTransient<FormViewPastry>();
|
services.AddTransient<FormViewPastry>();
|
||||||
services.AddTransient<FormAddPastryInShop>();
|
services.AddTransient<FormAddPastryInShop>();
|
||||||
services.AddTransient<FormViewShops>();
|
services.AddTransient<FormViewShops>();
|
||||||
|
services.AddTransient<FormShop>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user