PIbd-21 Lab1-Hard KozyrevSS SewingDresses Hard #2
@ -0,0 +1,156 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SewingDressesContracts.BindingModels;
|
||||
using SewingDressesContracts.BusinessLogicsContracts;
|
||||
using SewingDressesContracts.SearchModels;
|
||||
using SewingDressesContracts.StoragesContracts;
|
||||
using SewingDressesContracts.ViewModels;
|
||||
using SewingDressesDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SewingDressesBusinessLogic.BusinessLogic
|
||||
{
|
||||
public class ShopLogic : IShopLogic
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IShopStorage _shopStorage;
|
||||
public ShopLogic(ILogger<ShopLogic> logger, IShopStorage shopStorage)
|
||||
{
|
||||
_logger = logger;
|
||||
_shopStorage = shopStorage;
|
||||
}
|
||||
public List<ShopViewModel> ReadList(ShopSearchModel model)
|
||||
{
|
||||
_logger.LogInformation("ReadList. ShopName:{Name}. Id:{ Id}", model?.Name, model?.Id);
|
||||
var list = model == null ? _shopStorage.GetFullList() : _shopStorage.GetFilteredList(model);
|
||||
if (list == null)
|
||||
{
|
||||
_logger.LogWarning("ReadList return null list");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadList. Count:{Count}", list.Count);
|
||||
return list;
|
||||
}
|
||||
public ShopViewModel ReadElement(ShopSearchModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
_logger.LogInformation("ReadElement. ShopName:{ShopName}.Id:{ Id}", model.Name, model.Id);
|
||||
var element = _shopStorage.GetElement(model);
|
||||
if (element == null)
|
||||
{
|
||||
_logger.LogWarning("ReadElement element not found");
|
||||
return null;
|
||||
}
|
||||
_logger.LogInformation("ReadElement find. Id:{Id}", element.Id);
|
||||
return element;
|
||||
}
|
||||
|
||||
public bool Create(ShopBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_shopStorage.Insert(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Insert operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool Update(ShopBindingModel model)
|
||||
{
|
||||
CheckModel(model);
|
||||
if (_shopStorage.Update(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Update operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
public bool Delete(ShopBindingModel model)
|
||||
{
|
||||
CheckModel(model, false);
|
||||
_logger.LogInformation("Delete. Id:{Id}", model.Id);
|
||||
if (_shopStorage.Delete(model) == null)
|
||||
{
|
||||
_logger.LogWarning("Delete operation failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void CheckModel(ShopBindingModel model, bool withParams = true)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
}
|
||||
if (!withParams)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.ShopName))
|
||||
{
|
||||
throw new ArgumentNullException("Нет названия магазина",
|
||||
nameof(model.ShopName));
|
||||
}
|
||||
if (string.IsNullOrEmpty(model.Adress))
|
||||
{
|
||||
throw new ArgumentNullException("Нет адресса магазина",
|
||||
nameof(model.ShopName));
|
||||
}
|
||||
if (model.DateOpen == null)
|
||||
{
|
||||
throw new ArgumentNullException("Нет даты открытия магазина",
|
||||
nameof(model.ShopName));
|
||||
}
|
||||
_logger.LogInformation("Shop. ShopName:{ShopName}.Address:{Address}. DateOpen:{DateOpen}. Id: { Id}", model.ShopName, model.Adress, model.DateOpen, model.Id);
|
||||
var element = _shopStorage.GetElement(new ShopSearchModel
|
||||
{
|
||||
Name = model.ShopName
|
||||
});
|
||||
if (element != null && element.Id != model.Id)
|
||||
{
|
||||
throw new InvalidOperationException("Магазин с таким названием уже есть");
|
||||
}
|
||||
}
|
||||
public bool MakeSupply(ShopSearchModel model, IDressModel dress, int count)
|
||||
{
|
||||
if (model == null)
|
||||
throw new ArgumentNullException(nameof(model));
|
||||
if (dress == null)
|
||||
throw new ArgumentNullException(nameof(dress));
|
||||
if (count <= 0)
|
||||
throw new ArgumentNullException("Количество должно быть положительным числом");
|
||||
|
||||
ShopViewModel? curModel = _shopStorage.GetElement(model);
|
||||
_logger.LogInformation("Make Supply. Id: {Id}. ShopName: {Name}",model.Id, model.Name);
|
||||
if (curModel == null)
|
||||
throw new ArgumentNullException(nameof(curModel));
|
||||
if (curModel.ShopDresses.TryGetValue(dress.Id, out var pair))
|
||||
{
|
||||
curModel.ShopDresses[dress.Id] = (pair.Item1, pair.Item2 + count);
|
||||
_logger.LogInformation("Make Supply. Add Dress. DressName: {Name}. Count: {Count}", pair.Item1, count + pair.Item2);
|
||||
}
|
||||
else
|
||||
{
|
||||
curModel.ShopDresses.Add(dress.Id, (dress, count));
|
||||
_logger.LogInformation("Make Supply. Add new Dress. DressName: {Name}. Count: {Count}", pair.Item1, count);
|
||||
}
|
||||
|
||||
return Update(new()
|
||||
{
|
||||
Id = curModel.Id,
|
||||
ShopName = curModel.ShopName,
|
||||
DateOpen = curModel.DateOpen,
|
||||
Adress = curModel.Adress,
|
||||
ShopDresses = curModel.ShopDresses,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
using SewingDressesDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SewingDressesContracts.BindingModels
|
||||
{
|
||||
public class ShopBindingModel : IShopModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string ShopName { get; set; }
|
||||
public string Adress { get; set; }
|
||||
public DateTime DateOpen { get; set; }
|
||||
public Dictionary<int, (IDressModel, int)> ShopDresses { get; set; } = new();
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using SewingDressesContracts.BindingModels;
|
||||
using SewingDressesContracts.SearchModels;
|
||||
using SewingDressesContracts.ViewModels;
|
||||
using SewingDressesDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SewingDressesContracts.BusinessLogicsContracts
|
||||
{
|
||||
public interface IShopLogic
|
||||
{
|
||||
List<ShopViewModel>? ReadList(ShopSearchModel? model);
|
||||
ShopViewModel? ReadElement(ShopSearchModel? model);
|
||||
bool Create (ShopBindingModel? model);
|
||||
bool Update (ShopBindingModel? model);
|
||||
bool Delete (ShopBindingModel? model);
|
||||
bool MakeSupply(ShopSearchModel model, IDressModel dress, int count);
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SewingDressesContracts.SearchModels
|
||||
{
|
||||
public class ShopSearchModel
|
||||
{
|
||||
public int? Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using SewingDressesContracts.BindingModels;
|
||||
using SewingDressesContracts.SearchModels;
|
||||
using SewingDressesContracts.ViewModels;
|
||||
using SewingDressesDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SewingDressesContracts.StoragesContracts
|
||||
{
|
||||
public interface IShopStorage
|
||||
{
|
||||
List<ShopViewModel> GetFullList();
|
||||
List<ShopViewModel> GetFilteredList(ShopSearchModel model);
|
||||
ShopViewModel? GetElement(ShopSearchModel model);
|
||||
ShopViewModel? Insert(ShopBindingModel model);
|
||||
ShopViewModel? Update(ShopBindingModel model);
|
||||
ShopViewModel? Delete(ShopBindingModel model);
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
using SewingDressesDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SewingDressesContracts.ViewModels
|
||||
{
|
||||
public class ShopViewModel : IShopModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[DisplayName("Название магазина")]
|
||||
public string ShopName { get; set; } = string.Empty;
|
||||
[DisplayName("Адрес")]
|
||||
public string Adress { get; set; } = string.Empty;
|
||||
[DisplayName("Дата открытия")]
|
||||
public DateTime DateOpen { get; set; }
|
||||
public Dictionary<int, (IDressModel, int)> ShopDresses { get; set; } = new();
|
||||
}
|
||||
}
|
15
SewingDresses/SewingDressesDataModels/Models/IShopModel.cs
Normal file
15
SewingDresses/SewingDressesDataModels/Models/IShopModel.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SewingDressesDataModels.Models
|
||||
{
|
||||
public interface IShopModel : IId
|
||||
{
|
||||
string ShopName { get; }
|
||||
string Adress { get; }
|
||||
DateTime DateOpen { get; }
|
||||
}
|
||||
}
|
@ -8,11 +8,13 @@ namespace SewingDressesListImplement
|
||||
public List<Component> Components { get; set; }
|
||||
public List<Order> Orders { get; set; }
|
||||
public List<Dress> Dresses { get; set; }
|
||||
public List<Shop> Shops { get; set; }
|
||||
private DataListSingleton()
|
||||
{
|
||||
Components = new List<Component>();
|
||||
Orders = new List<Order>();
|
||||
Dresses = new List<Dress>();
|
||||
Shops = new List<Shop>();
|
||||
}
|
||||
public static DataListSingleton GetInstance()
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ namespace SewingDressesListImplement.Implements
|
||||
var result = new List<OrderViewModel>();
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
result.Add(order.GetViewModel);
|
||||
result.Add(AcessDressesStorage(order.GetViewModel));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -31,7 +31,7 @@ namespace SewingDressesListImplement.Implements
|
||||
{
|
||||
if (order.Id == model.Id)
|
||||
{
|
||||
result.Add(order.GetViewModel);
|
||||
result.Add(AcessDressesStorage(order.GetViewModel));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@ -94,5 +94,17 @@ namespace SewingDressesListImplement.Implements
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public OrderViewModel AcessDressesStorage(OrderViewModel model)
|
||||
{
|
||||
foreach (var dress in _source.Dresses)
|
||||
{
|
||||
if (dress.Id == model.DressId)
|
||||
{
|
||||
model.DressName = dress.DressName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return model;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,108 @@
|
||||
using SewingDressesContracts.BindingModels;
|
||||
using SewingDressesContracts.SearchModels;
|
||||
using SewingDressesContracts.StoragesContracts;
|
||||
using SewingDressesContracts.ViewModels;
|
||||
using SewingDressesDataModels.Models;
|
||||
using SewingDressesListImplement.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace SewingDressesListImplement.Implements
|
||||
{
|
||||
public class ShopStorage : IShopStorage
|
||||
{
|
||||
private readonly DataListSingleton _source;
|
||||
public ShopStorage()
|
||||
{
|
||||
_source = DataListSingleton.GetInstance();
|
||||
}
|
||||
public List<ShopViewModel> GetFullList()
|
||||
{
|
||||
var result = new List<ShopViewModel>();
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
result.Add(shop.GetViewModel);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public List<ShopViewModel> GetFilteredList(ShopSearchModel model)
|
||||
{
|
||||
var result = new List<ShopViewModel>();
|
||||
if (string.IsNullOrEmpty(model.Name))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if (shop.ShopName.Contains(model.Name))
|
||||
{
|
||||
result.Add(shop.GetViewModel);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public ShopViewModel? GetElement(ShopSearchModel model)
|
||||
{
|
||||
if (string.IsNullOrEmpty(model.Name) && !model.Id.HasValue)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if ((!string.IsNullOrEmpty(model.Name) &&
|
||||
shop.ShopName == model.Name) ||
|
||||
(model.Id.HasValue && shop.Id == model.Id))
|
||||
{
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public ShopViewModel? Insert(ShopBindingModel model)
|
||||
{
|
||||
model.Id = 1;
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if (model.Id <= shop.Id)
|
||||
{
|
||||
model.Id = shop.Id + 1;
|
||||
}
|
||||
}
|
||||
var newShop = Shop.Create(model);
|
||||
if (newShop == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
_source.Shops.Add(newShop);
|
||||
return newShop.GetViewModel;
|
||||
}
|
||||
public ShopViewModel? Update(ShopBindingModel model)
|
||||
{
|
||||
foreach (var shop in _source.Shops)
|
||||
{
|
||||
if (shop.Id == model.Id)
|
||||
{
|
||||
shop.Update(model);
|
||||
return shop.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public ShopViewModel? Delete(ShopBindingModel model)
|
||||
{
|
||||
for (int i = 0; i < _source.Shops.Count; ++i)
|
||||
{
|
||||
if (_source.Shops[i].Id == model.Id)
|
||||
{
|
||||
var element = _source.Shops[i];
|
||||
_source.Shops.RemoveAt(i);
|
||||
return element.GetViewModel;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
@ -39,9 +39,6 @@ namespace SewingDressesListImplement.Models
|
||||
{
|
||||
return;
|
||||
}
|
||||
DressId = model.DressId == 0 ? DressId : model.DressId;
|
||||
Count = model.Count == 0 ? Count : model.Count;
|
||||
Sum = model.Sum == 0 ? Sum : model.Sum;
|
||||
Status = model.Status;
|
||||
DateImplement = model.DateImplement;
|
||||
}
|
||||
|
54
SewingDresses/SewingDressesListImplement/Models/Shop.cs
Normal file
54
SewingDresses/SewingDressesListImplement/Models/Shop.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using SewingDressesContracts.ViewModels;
|
||||
using SewingDressesDataModels.Models;
|
||||
using SewingDressesContracts.BindingModels;
|
||||
|
||||
namespace SewingDressesListImplement.Models
|
||||
{
|
||||
public class Shop : IShopModel
|
||||
{
|
||||
public int Id { get; private set; }
|
||||
public string ShopName { get; private set; }
|
||||
public string Adress { get; private set; }
|
||||
public DateTime DateOpen { get; private set; }
|
||||
public Dictionary<int, (IDressModel, int)> ShopDresses { get; private set; } = new();
|
||||
public static Shop? Create (ShopBindingModel model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Shop()
|
||||
{
|
||||
Id = model.Id,
|
||||
ShopName = model.ShopName,
|
||||
Adress = model.Adress,
|
||||
DateOpen = model.DateOpen,
|
||||
ShopDresses = new()
|
||||
};
|
||||
}
|
||||
public void Update(ShopBindingModel? model)
|
||||
{
|
||||
if (model == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
ShopName = model.ShopName;
|
||||
Adress = model.Adress;
|
||||
DateOpen = model.DateOpen;
|
||||
ShopDresses = model.ShopDresses;
|
||||
}
|
||||
public ShopViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ShopName = ShopName,
|
||||
Adress = Adress,
|
||||
DateOpen = DateOpen,
|
||||
ShopDresses = ShopDresses
|
||||
};
|
||||
}
|
||||
}
|
@ -97,7 +97,7 @@
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "ComponentsForm";
|
||||
Text = "ComponentsForm";
|
||||
Text = "Форма компонентов";
|
||||
Load += ComponentsForm_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
|
@ -97,7 +97,7 @@
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "DressesForm";
|
||||
Text = "DressesForm";
|
||||
Text = "Форма с платьем";
|
||||
Load += DressesForm_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
|
@ -99,6 +99,7 @@ namespace SewingDressesView
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["DressComponents"].Visible = false;
|
||||
dataGridView.Columns["DressName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
_logger.LogInformation("Load components");
|
||||
|
24
SewingDresses/SewingDressesView/MainForm.Designer.cs
generated
24
SewingDresses/SewingDressesView/MainForm.Designer.cs
generated
@ -38,6 +38,8 @@
|
||||
справочникиToolStripMenuItem = new ToolStripMenuItem();
|
||||
компонентыToolStripMenuItem = new ToolStripMenuItem();
|
||||
платьяToolStripMenuItem = new ToolStripMenuItem();
|
||||
магазиныToolStripMenuItem = new ToolStripMenuItem();
|
||||
поставкиToolStripMenuItem = new ToolStripMenuItem();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
menuStrip1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
@ -114,7 +116,7 @@
|
||||
//
|
||||
// справочникиToolStripMenuItem
|
||||
//
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, платьяToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem[] { компонентыToolStripMenuItem, платьяToolStripMenuItem, магазиныToolStripMenuItem, поставкиToolStripMenuItem });
|
||||
справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||
справочникиToolStripMenuItem.Size = new Size(117, 24);
|
||||
справочникиToolStripMenuItem.Text = "Справочники";
|
||||
@ -122,17 +124,31 @@
|
||||
// компонентыToolStripMenuItem
|
||||
//
|
||||
компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
||||
компонентыToolStripMenuItem.Size = new Size(182, 26);
|
||||
компонентыToolStripMenuItem.Size = new Size(224, 26);
|
||||
компонентыToolStripMenuItem.Text = "Компоненты";
|
||||
компонентыToolStripMenuItem.Click += ComponentsToolStripMenuItem_Click;
|
||||
//
|
||||
// платьяToolStripMenuItem
|
||||
//
|
||||
платьяToolStripMenuItem.Name = "платьяToolStripMenuItem";
|
||||
платьяToolStripMenuItem.Size = new Size(182, 26);
|
||||
платьяToolStripMenuItem.Size = new Size(224, 26);
|
||||
платьяToolStripMenuItem.Text = "Платья";
|
||||
платьяToolStripMenuItem.Click += DressesToolStripMenuItem_Click;
|
||||
//
|
||||
// магазиныToolStripMenuItem
|
||||
//
|
||||
магазиныToolStripMenuItem.Name = "магазиныToolStripMenuItem";
|
||||
магазиныToolStripMenuItem.Size = new Size(224, 26);
|
||||
магазиныToolStripMenuItem.Text = "Магазины";
|
||||
магазиныToolStripMenuItem.Click += ShopsToolStripMenuItem_Click;
|
||||
//
|
||||
// поставкиToolStripMenuItem
|
||||
//
|
||||
поставкиToolStripMenuItem.Name = "поставкиToolStripMenuItem";
|
||||
поставкиToolStripMenuItem.Size = new Size(224, 26);
|
||||
поставкиToolStripMenuItem.Text = "Поставки";
|
||||
поставкиToolStripMenuItem.Click += SupplyToolStripMenuItem_Click;
|
||||
//
|
||||
// MainForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
@ -167,5 +183,7 @@
|
||||
private ToolStripMenuItem справочникиToolStripMenuItem;
|
||||
private ToolStripMenuItem компонентыToolStripMenuItem;
|
||||
private ToolStripMenuItem платьяToolStripMenuItem;
|
||||
private ToolStripMenuItem магазиныToolStripMenuItem;
|
||||
private ToolStripMenuItem поставкиToolStripMenuItem;
|
||||
}
|
||||
}
|
@ -45,8 +45,8 @@ namespace SewingDressesView
|
||||
|
||||
private void DressesToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(DressForm));
|
||||
if (service is DressForm form)
|
||||
var service = Program.ServiceProvider?.GetService(typeof(DressesForm));
|
||||
if (service is DressesForm form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
@ -142,5 +142,23 @@ namespace SewingDressesView
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void ShopsToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(ShopsForm));
|
||||
if (service is ShopsForm form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void SupplyToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(SupplyForm));
|
||||
if (service is SupplyForm form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +123,7 @@
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Name = "OrderForm";
|
||||
Text = "OrderForm";
|
||||
Text = "Форма заказа";
|
||||
Load += OrderForm_Load;
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
|
@ -99,7 +99,7 @@ namespace SewingDressesView
|
||||
try
|
||||
{
|
||||
var list = _logicD.ReadList(null);
|
||||
if (list != null)
|
||||
if (list != null)
|
||||
{
|
||||
comboBoxDress.DisplayMember = "DressName";
|
||||
comboBoxDress.ValueMember = "Id";
|
||||
|
@ -35,6 +35,8 @@ namespace SewingDressesView
|
||||
services.AddTransient<IComponentLogic, ComponentLogic>();
|
||||
services.AddTransient<IOrderLogic, OrderLogic>();
|
||||
services.AddTransient<IDressLogic, DressLogic>();
|
||||
services.AddTransient<IShopStorage, ShopStorage>();
|
||||
services.AddTransient<IShopLogic, ShopLogic>();
|
||||
services.AddTransient<MainForm>();
|
||||
services.AddTransient<ComponentForm>();
|
||||
services.AddTransient<ComponentsForm>();
|
||||
@ -42,6 +44,9 @@ namespace SewingDressesView
|
||||
services.AddTransient<DressForm>();
|
||||
services.AddTransient<DressComponentForm>();
|
||||
services.AddTransient<DressesForm>();
|
||||
services.AddTransient<ShopForm>();
|
||||
services.AddTransient<ShopsForm>();
|
||||
services.AddTransient<SupplyForm>();
|
||||
}
|
||||
}
|
||||
}
|
193
SewingDresses/SewingDressesView/ShopForm.Designer.cs
generated
Normal file
193
SewingDresses/SewingDressesView/ShopForm.Designer.cs
generated
Normal file
@ -0,0 +1,193 @@
|
||||
namespace SewingDressesView
|
||||
{
|
||||
partial class ShopForm
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
dateTimePicker = new DateTimePicker();
|
||||
textBoxName = new TextBox();
|
||||
textBoxAdress = new TextBox();
|
||||
dataGridView = new DataGridView();
|
||||
IdColumn = new DataGridViewTextBoxColumn();
|
||||
Title = new DataGridViewTextBoxColumn();
|
||||
Cost = new DataGridViewTextBoxColumn();
|
||||
Count = new DataGridViewTextBoxColumn();
|
||||
buttonSave = new Button();
|
||||
buttonCancel = new Button();
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
label3 = new Label();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dateTimePicker
|
||||
//
|
||||
dateTimePicker.Location = new Point(714, 34);
|
||||
dateTimePicker.Name = "dateTimePicker";
|
||||
dateTimePicker.Size = new Size(250, 27);
|
||||
dateTimePicker.TabIndex = 0;
|
||||
//
|
||||
// textBoxName
|
||||
//
|
||||
textBoxName.Location = new Point(714, 85);
|
||||
textBoxName.Name = "textBoxName";
|
||||
textBoxName.Size = new Size(250, 27);
|
||||
textBoxName.TabIndex = 1;
|
||||
//
|
||||
// textBoxAdress
|
||||
//
|
||||
textBoxAdress.Location = new Point(714, 139);
|
||||
textBoxAdress.Name = "textBoxAdress";
|
||||
textBoxAdress.Size = new Size(250, 27);
|
||||
textBoxAdress.TabIndex = 2;
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Columns.AddRange(new DataGridViewColumn[] { IdColumn, Title, Cost, Count });
|
||||
dataGridView.Location = new Point(10, 32);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.RowTemplate.Height = 29;
|
||||
dataGridView.Size = new Size(554, 380);
|
||||
dataGridView.TabIndex = 3;
|
||||
//
|
||||
// IdColumn
|
||||
//
|
||||
IdColumn.HeaderText = "Номер платья";
|
||||
IdColumn.MinimumWidth = 6;
|
||||
IdColumn.Name = "IdColumn";
|
||||
IdColumn.Visible = false;
|
||||
IdColumn.Width = 125;
|
||||
//
|
||||
// Title
|
||||
//
|
||||
Title.HeaderText = "Название";
|
||||
Title.MinimumWidth = 6;
|
||||
Title.Name = "Title";
|
||||
Title.Width = 125;
|
||||
//
|
||||
// Cost
|
||||
//
|
||||
Cost.HeaderText = "Цена";
|
||||
Cost.MinimumWidth = 6;
|
||||
Cost.Name = "Cost";
|
||||
Cost.Width = 125;
|
||||
//
|
||||
// Count
|
||||
//
|
||||
Count.HeaderText = "Количество";
|
||||
Count.MinimumWidth = 6;
|
||||
Count.Name = "Count";
|
||||
Count.Width = 125;
|
||||
//
|
||||
// buttonSave
|
||||
//
|
||||
buttonSave.Location = new Point(714, 219);
|
||||
buttonSave.Name = "buttonSave";
|
||||
buttonSave.Size = new Size(94, 29);
|
||||
buttonSave.TabIndex = 4;
|
||||
buttonSave.Text = "Сохранить";
|
||||
buttonSave.UseVisualStyleBackColor = true;
|
||||
buttonSave.Click += buttonSave_Click;
|
||||
//
|
||||
// buttonCancel
|
||||
//
|
||||
buttonCancel.Location = new Point(870, 219);
|
||||
buttonCancel.Name = "buttonCancel";
|
||||
buttonCancel.Size = new Size(94, 29);
|
||||
buttonCancel.TabIndex = 5;
|
||||
buttonCancel.Text = "Отмена";
|
||||
buttonCancel.UseVisualStyleBackColor = true;
|
||||
buttonCancel.Click += buttonCancel_Click;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(592, 39);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(110, 20);
|
||||
label1.TabIndex = 6;
|
||||
label1.Text = "Дата создания";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(592, 88);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(77, 20);
|
||||
label2.TabIndex = 7;
|
||||
label2.Text = "Название";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(592, 142);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(51, 20);
|
||||
label3.TabIndex = 8;
|
||||
label3.Text = "Адрес";
|
||||
//
|
||||
// ShopForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(976, 450);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(buttonCancel);
|
||||
Controls.Add(buttonSave);
|
||||
Controls.Add(dataGridView);
|
||||
Controls.Add(textBoxAdress);
|
||||
Controls.Add(textBoxName);
|
||||
Controls.Add(dateTimePicker);
|
||||
Name = "ShopForm";
|
||||
Text = "Форма магазина";
|
||||
Load += ShopForm_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DateTimePicker dateTimePicker;
|
||||
private TextBox textBoxName;
|
||||
private TextBox textBoxAdress;
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonSave;
|
||||
private Button buttonCancel;
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Label label3;
|
||||
private DataGridViewTextBoxColumn IdColumn;
|
||||
private DataGridViewTextBoxColumn Title;
|
||||
private DataGridViewTextBoxColumn Cost;
|
||||
private DataGridViewTextBoxColumn Count;
|
||||
}
|
||||
}
|
122
SewingDresses/SewingDressesView/ShopForm.cs
Normal file
122
SewingDresses/SewingDressesView/ShopForm.cs
Normal file
@ -0,0 +1,122 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SewingDressesContracts.BindingModels;
|
||||
using SewingDressesContracts.BusinessLogicsContracts;
|
||||
using SewingDressesContracts.SearchModels;
|
||||
using SewingDressesDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace SewingDressesView
|
||||
{
|
||||
public partial class ShopForm : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IShopLogic _logic;
|
||||
public int? _id;
|
||||
private Dictionary<int, (IDressModel, int)> _dresses;
|
||||
public ShopForm(ILogger<ShopForm> logger, IShopLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private void ShopForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (_id.HasValue)
|
||||
{
|
||||
_logger.LogInformation("Shop load");
|
||||
try
|
||||
{
|
||||
var shop = _logic.ReadElement(new ShopSearchModel { Id = _id });
|
||||
if (shop != null)
|
||||
{
|
||||
textBoxName.Text = shop.ShopName;
|
||||
textBoxAdress.Text = shop.Adress;
|
||||
dateTimePicker.Text = shop.DateOpen.ToString();
|
||||
_dresses = shop.ShopDresses;
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Load shop error");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Load dresses");
|
||||
try
|
||||
{
|
||||
if (_dresses != null)
|
||||
{
|
||||
foreach (var dress in _dresses)
|
||||
{
|
||||
dataGridView.Rows.Add(new object[] { dress.Key, dress.Value.Item1.DressName, dress.Value.Item1.Price, dress.Value.Item2 });
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Load dresses into shop error");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
private void buttonSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(textBoxName.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (string.IsNullOrEmpty(textBoxAdress.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
_logger.LogInformation("Save shop");
|
||||
try
|
||||
{
|
||||
var model = new ShopBindingModel
|
||||
{
|
||||
Id = _id ?? 0,
|
||||
ShopName = textBoxName.Text,
|
||||
Adress = textBoxAdress.Text,
|
||||
DateOpen = dateTimePicker.Value.Date,
|
||||
ShopDresses = _dresses
|
||||
};
|
||||
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, "Save shop error");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
129
SewingDresses/SewingDressesView/ShopForm.resx
Normal file
129
SewingDresses/SewingDressesView/ShopForm.resx
Normal file
@ -0,0 +1,129 @@
|
||||
<?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>
|
||||
<metadata name="IdColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Cost.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>
|
114
SewingDresses/SewingDressesView/ShopsForm.Designer.cs
generated
Normal file
114
SewingDresses/SewingDressesView/ShopsForm.Designer.cs
generated
Normal file
@ -0,0 +1,114 @@
|
||||
namespace SewingDressesView
|
||||
{
|
||||
partial class ShopsForm
|
||||
{
|
||||
/// <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();
|
||||
buttonUpdate = new Button();
|
||||
buttonReset = new Button();
|
||||
buttonDelete = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// dataGridView
|
||||
//
|
||||
dataGridView.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dataGridView.Location = new Point(14, 17);
|
||||
dataGridView.Name = "dataGridView";
|
||||
dataGridView.RowHeadersWidth = 51;
|
||||
dataGridView.RowTemplate.Height = 29;
|
||||
dataGridView.Size = new Size(646, 415);
|
||||
dataGridView.TabIndex = 0;
|
||||
//
|
||||
// buttonAdd
|
||||
//
|
||||
buttonAdd.Location = new Point(797, 49);
|
||||
buttonAdd.Name = "buttonAdd";
|
||||
buttonAdd.Size = new Size(94, 29);
|
||||
buttonAdd.TabIndex = 1;
|
||||
buttonAdd.Text = "Добавить";
|
||||
buttonAdd.UseVisualStyleBackColor = true;
|
||||
buttonAdd.Click += buttonAdd_Click;
|
||||
//
|
||||
// buttonUpdate
|
||||
//
|
||||
buttonUpdate.Location = new Point(797, 114);
|
||||
buttonUpdate.Name = "buttonUpdate";
|
||||
buttonUpdate.Size = new Size(94, 29);
|
||||
buttonUpdate.TabIndex = 2;
|
||||
buttonUpdate.Text = "Изменить";
|
||||
buttonUpdate.UseVisualStyleBackColor = true;
|
||||
buttonUpdate.Click += buttonUpdate_Click;
|
||||
//
|
||||
// buttonReset
|
||||
//
|
||||
buttonReset.Location = new Point(797, 184);
|
||||
buttonReset.Name = "buttonReset";
|
||||
buttonReset.Size = new Size(94, 29);
|
||||
buttonReset.TabIndex = 3;
|
||||
buttonReset.Text = "Обновить";
|
||||
buttonReset.UseVisualStyleBackColor = true;
|
||||
buttonReset.Click += buttonReset_Click;
|
||||
//
|
||||
// buttonDelete
|
||||
//
|
||||
buttonDelete.Location = new Point(797, 263);
|
||||
buttonDelete.Name = "buttonDelete";
|
||||
buttonDelete.Size = new Size(94, 29);
|
||||
buttonDelete.TabIndex = 4;
|
||||
buttonDelete.Text = "Удалить";
|
||||
buttonDelete.UseVisualStyleBackColor = true;
|
||||
buttonDelete.Click += buttonDelete_Click;
|
||||
//
|
||||
// ShopsForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(942, 450);
|
||||
Controls.Add(buttonDelete);
|
||||
Controls.Add(buttonReset);
|
||||
Controls.Add(buttonUpdate);
|
||||
Controls.Add(buttonAdd);
|
||||
Controls.Add(dataGridView);
|
||||
Name = "ShopsForm";
|
||||
Text = "Магазины";
|
||||
Load += ShopsForm_Load;
|
||||
((System.ComponentModel.ISupportInitialize)dataGridView).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonAdd;
|
||||
private Button buttonUpdate;
|
||||
private Button buttonReset;
|
||||
private Button buttonDelete;
|
||||
}
|
||||
}
|
118
SewingDresses/SewingDressesView/ShopsForm.cs
Normal file
118
SewingDresses/SewingDressesView/ShopsForm.cs
Normal file
@ -0,0 +1,118 @@
|
||||
using Microsoft.Extensions.Logging;
|
||||
using SewingDressesContracts.BindingModels;
|
||||
using SewingDressesContracts.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 SewingDressesView
|
||||
{
|
||||
public partial class ShopsForm : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IShopLogic _logic;
|
||||
public ShopsForm(ILogger<ShopsForm> logger, IShopLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
try
|
||||
{
|
||||
var list = _logic.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ShopName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["Adress"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["DateOpen"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["ShopDresses"].Visible = false;
|
||||
}
|
||||
_logger.LogInformation("Load shops");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Load shop error");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ShopsForm_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void buttonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(ShopForm));
|
||||
if (service is ShopForm form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(ShopForm));
|
||||
if (service is ShopForm form)
|
||||
{
|
||||
var tmp = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
form._id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonReset_Click(object sender, EventArgs e)
|
||||
{
|
||||
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 ShopBindingModel
|
||||
{
|
||||
Id = id
|
||||
}))
|
||||
{
|
||||
throw new Exception("Ошибка при удалении. Дополнительная информация в логах.");
|
||||
}
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка удаления магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
120
SewingDresses/SewingDressesView/ShopsForm.resx
Normal file
120
SewingDresses/SewingDressesView/ShopsForm.resx
Normal 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>
|
141
SewingDresses/SewingDressesView/SupplyForm.Designer.cs
generated
Normal file
141
SewingDresses/SewingDressesView/SupplyForm.Designer.cs
generated
Normal file
@ -0,0 +1,141 @@
|
||||
namespace SewingDressesView
|
||||
{
|
||||
partial class SupplyForm
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
ShopComboBox = new ComboBox();
|
||||
DressComboBox = new ComboBox();
|
||||
CountTextBox = new TextBox();
|
||||
SaveButton = new Button();
|
||||
Cancel = new Button();
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
label3 = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// ShopComboBox
|
||||
//
|
||||
ShopComboBox.FormattingEnabled = true;
|
||||
ShopComboBox.Location = new Point(155, 34);
|
||||
ShopComboBox.Name = "ShopComboBox";
|
||||
ShopComboBox.Size = new Size(318, 28);
|
||||
ShopComboBox.TabIndex = 0;
|
||||
//
|
||||
// DressComboBox
|
||||
//
|
||||
DressComboBox.FormattingEnabled = true;
|
||||
DressComboBox.Location = new Point(155, 79);
|
||||
DressComboBox.Name = "DressComboBox";
|
||||
DressComboBox.Size = new Size(318, 28);
|
||||
DressComboBox.TabIndex = 1;
|
||||
//
|
||||
// CountTextBox
|
||||
//
|
||||
CountTextBox.Location = new Point(155, 128);
|
||||
CountTextBox.Name = "CountTextBox";
|
||||
CountTextBox.Size = new Size(318, 27);
|
||||
CountTextBox.TabIndex = 2;
|
||||
//
|
||||
// SaveButton
|
||||
//
|
||||
SaveButton.Location = new Point(252, 200);
|
||||
SaveButton.Name = "SaveButton";
|
||||
SaveButton.Size = new Size(107, 36);
|
||||
SaveButton.TabIndex = 3;
|
||||
SaveButton.Text = "Сохранить";
|
||||
SaveButton.UseVisualStyleBackColor = true;
|
||||
SaveButton.Click += SaveButton_Click;
|
||||
//
|
||||
// Cancel
|
||||
//
|
||||
Cancel.Location = new Point(365, 200);
|
||||
Cancel.Name = "Cancel";
|
||||
Cancel.Size = new Size(108, 36);
|
||||
Cancel.TabIndex = 4;
|
||||
Cancel.Text = "Отмена";
|
||||
Cancel.UseVisualStyleBackColor = true;
|
||||
Cancel.Click += CancelButton_Click;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(40, 37);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(69, 20);
|
||||
label1.TabIndex = 5;
|
||||
label1.Text = "Магазин";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(40, 82);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(58, 20);
|
||||
label2.TabIndex = 6;
|
||||
label2.Text = "Платье";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(40, 131);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(90, 20);
|
||||
label3.TabIndex = 7;
|
||||
label3.Text = "Количество";
|
||||
//
|
||||
// SupplyForm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(8F, 20F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(506, 260);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Controls.Add(Cancel);
|
||||
Controls.Add(SaveButton);
|
||||
Controls.Add(CountTextBox);
|
||||
Controls.Add(DressComboBox);
|
||||
Controls.Add(ShopComboBox);
|
||||
Name = "SupplyForm";
|
||||
Text = "Форма поставки";
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private ComboBox ShopComboBox;
|
||||
private ComboBox DressComboBox;
|
||||
private TextBox CountTextBox;
|
||||
private Button SaveButton;
|
||||
private Button Cancel;
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Label label3;
|
||||
}
|
||||
}
|
149
SewingDresses/SewingDressesView/SupplyForm.cs
Normal file
149
SewingDresses/SewingDressesView/SupplyForm.cs
Normal file
@ -0,0 +1,149 @@
|
||||
using SewingDressesContracts.BusinessLogicsContracts;
|
||||
using SewingDressesContracts.SearchModels;
|
||||
using SewingDressesContracts.ViewModels;
|
||||
using SewingDressesDataModels.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace SewingDressesView
|
||||
{
|
||||
public partial class SupplyForm : Form
|
||||
{
|
||||
private readonly List<DressViewModel>? _dressList;
|
||||
private readonly List<ShopViewModel>? _shopsList;
|
||||
IShopLogic _shopLogic;
|
||||
IDressLogic _dressLogic;
|
||||
public int ShopId
|
||||
{
|
||||
get
|
||||
{
|
||||
return Convert.ToInt32(ShopComboBox.SelectedValue);
|
||||
}
|
||||
set
|
||||
{
|
||||
ShopComboBox.SelectedValue = value;
|
||||
}
|
||||
}
|
||||
public int DressId
|
||||
{
|
||||
get
|
||||
{
|
||||
return Convert.ToInt32(DressComboBox.SelectedValue);
|
||||
}
|
||||
set
|
||||
{
|
||||
DressComboBox.SelectedValue = value;
|
||||
}
|
||||
}
|
||||
|
||||
public IDressModel? DressModel
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_dressList == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var elem in _dressList)
|
||||
{
|
||||
if (elem.Id == DressId)
|
||||
{
|
||||
return elem;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int Count
|
||||
{
|
||||
get { return Convert.ToInt32(CountTextBox.Text); }
|
||||
set
|
||||
{ CountTextBox.Text = value.ToString(); }
|
||||
}
|
||||
public SupplyForm(IDressLogic dressLogic, IShopLogic shopLogic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_shopLogic = shopLogic;
|
||||
_dressLogic = dressLogic;
|
||||
_dressList = dressLogic.ReadList(null);
|
||||
_shopsList = shopLogic.ReadList(null);
|
||||
if (_dressList != null)
|
||||
{
|
||||
DressComboBox.DisplayMember = "DressName";
|
||||
DressComboBox.ValueMember = "Id";
|
||||
DressComboBox.DataSource = _dressList;
|
||||
DressComboBox.SelectedItem = null;
|
||||
}
|
||||
if (_shopsList != null)
|
||||
{
|
||||
ShopComboBox.DisplayMember = "ShopName";
|
||||
ShopComboBox.ValueMember = "Id";
|
||||
ShopComboBox.DataSource = _shopsList;
|
||||
ShopComboBox.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(CountTextBox.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните поле Количество", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (DressComboBox.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите платье", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
if (ShopComboBox.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите магазин", "Ошибка",
|
||||
MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
int count = Convert.ToInt32(CountTextBox.Text);
|
||||
|
||||
bool res = _shopLogic.MakeSupply(
|
||||
new ShopSearchModel() { Id = Convert.ToInt32(ShopComboBox.SelectedValue) },
|
||||
_dressLogic.ReadElement(new() { Id = Convert.ToInt32(DressComboBox.SelectedValue) }),
|
||||
count
|
||||
);
|
||||
|
||||
if (!res)
|
||||
{
|
||||
throw new Exception("Ошибка при пополнении. Дополнительная информация в логах");
|
||||
}
|
||||
|
||||
MessageBox.Show("Пополнение прошло успешно");
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
|
||||
}
|
||||
catch (Exception er)
|
||||
{
|
||||
MessageBox.Show("Ошибка пополнения");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void CancelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
SewingDresses/SewingDressesView/SupplyForm.resx
Normal file
120
SewingDresses/SewingDressesView/SupplyForm.resx
Normal 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>
|
Loading…
Reference in New Issue
Block a user