2 усложненная
This commit is contained in:
parent
7e33506003
commit
e23105958f
282
JewelryStore/FormMain.Designer.cs
generated
282
JewelryStore/FormMain.Designer.cs
generated
@ -1,5 +1,6 @@
|
||||
namespace JewelryStore
|
||||
{
|
||||
|
||||
partial class FormMain
|
||||
{
|
||||
/// <summary>
|
||||
@ -28,154 +29,163 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.buttonReady = new System.Windows.Forms.Button();
|
||||
this.dataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.buttonCreate = new System.Windows.Forms.Button();
|
||||
this.buttonToWork = new System.Windows.Forms.Button();
|
||||
this.buttonPut = new System.Windows.Forms.Button();
|
||||
this.buttonRefresh = new System.Windows.Forms.Button();
|
||||
this.StoreReplenishment = new System.Windows.Forms.Button();
|
||||
this.menuStrip = new System.Windows.Forms.MenuStrip();
|
||||
this.справочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.компонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.изделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.MenuStrip = new System.Windows.Forms.MenuStrip();
|
||||
this.СправочникиToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ИзделияToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.КомпонентыToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.StoreToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit();
|
||||
this.menuStrip.SuspendLayout();
|
||||
this.DataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.CreateOrderButton = new System.Windows.Forms.Button();
|
||||
this.TakeOrderInWorkButton = new System.Windows.Forms.Button();
|
||||
this.OrderReadyButton = new System.Windows.Forms.Button();
|
||||
this.IssuedOrderButton = new System.Windows.Forms.Button();
|
||||
this.UpdateListButton = new System.Windows.Forms.Button();
|
||||
this.StoreReplenishment = new System.Windows.Forms.Button();
|
||||
this.SellJewelButton = new System.Windows.Forms.Button();
|
||||
this.MenuStrip.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// buttonReady
|
||||
// MenuStrip
|
||||
//
|
||||
this.buttonReady.Location = new System.Drawing.Point(1273, 225);
|
||||
this.buttonReady.Name = "buttonReady";
|
||||
this.buttonReady.Size = new System.Drawing.Size(215, 34);
|
||||
this.buttonReady.TabIndex = 3;
|
||||
this.buttonReady.Text = "Заказ готов";
|
||||
this.buttonReady.UseVisualStyleBackColor = true;
|
||||
this.buttonReady.Click += new System.EventHandler(this.buttonReady_Click);
|
||||
this.MenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.СправочникиToolStripMenuItem});
|
||||
this.MenuStrip.Location = new System.Drawing.Point(0, 0);
|
||||
this.MenuStrip.Name = "MenuStrip";
|
||||
this.MenuStrip.Size = new System.Drawing.Size(865, 24);
|
||||
this.MenuStrip.TabIndex = 0;
|
||||
this.MenuStrip.Text = "menuStrip1";
|
||||
//
|
||||
// dataGridView
|
||||
// СправочникиToolStripMenuItem
|
||||
//
|
||||
this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dataGridView.Location = new System.Drawing.Point(9, 52);
|
||||
this.dataGridView.Name = "dataGridView";
|
||||
this.dataGridView.RowHeadersWidth = 62;
|
||||
this.dataGridView.RowTemplate.Height = 33;
|
||||
this.dataGridView.Size = new System.Drawing.Size(1227, 386);
|
||||
this.dataGridView.TabIndex = 0;
|
||||
//
|
||||
// buttonCreate
|
||||
//
|
||||
this.buttonCreate.Location = new System.Drawing.Point(1273, 52);
|
||||
this.buttonCreate.Name = "buttonCreate";
|
||||
this.buttonCreate.Size = new System.Drawing.Size(215, 34);
|
||||
this.buttonCreate.TabIndex = 1;
|
||||
this.buttonCreate.Text = "Создать заказ";
|
||||
this.buttonCreate.UseVisualStyleBackColor = true;
|
||||
this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
|
||||
//
|
||||
// buttonToWork
|
||||
//
|
||||
this.buttonToWork.Location = new System.Drawing.Point(1273, 137);
|
||||
this.buttonToWork.Name = "buttonToWork";
|
||||
this.buttonToWork.Size = new System.Drawing.Size(215, 34);
|
||||
this.buttonToWork.TabIndex = 2;
|
||||
this.buttonToWork.Text = "Отдать на выполнение";
|
||||
this.buttonToWork.UseVisualStyleBackColor = true;
|
||||
this.buttonToWork.Click += new System.EventHandler(this.buttonToWork_Click);
|
||||
//
|
||||
// buttonPut
|
||||
//
|
||||
this.buttonPut.Location = new System.Drawing.Point(1273, 308);
|
||||
this.buttonPut.Name = "buttonPut";
|
||||
this.buttonPut.Size = new System.Drawing.Size(215, 34);
|
||||
this.buttonPut.TabIndex = 4;
|
||||
this.buttonPut.Text = "Заказ выдан";
|
||||
this.buttonPut.UseVisualStyleBackColor = true;
|
||||
this.buttonPut.Click += new System.EventHandler(this.buttonPut_Click);
|
||||
//
|
||||
// buttonRefresh
|
||||
//
|
||||
this.buttonRefresh.Location = new System.Drawing.Point(1273, 395);
|
||||
this.buttonRefresh.Name = "buttonRefresh";
|
||||
this.buttonRefresh.Size = new System.Drawing.Size(215, 34);
|
||||
this.buttonRefresh.TabIndex = 5;
|
||||
this.buttonRefresh.Text = "Обновить список";
|
||||
this.buttonRefresh.UseVisualStyleBackColor = true;
|
||||
this.buttonRefresh.Click += new System.EventHandler(this.buttonRefresh_Click);
|
||||
//
|
||||
// StoreReplenishment
|
||||
//
|
||||
this.StoreReplenishment.Location = new System.Drawing.Point(1273, 469);
|
||||
this.StoreReplenishment.Name = "StoreReplenishment";
|
||||
this.StoreReplenishment.Size = new System.Drawing.Size(215, 31);
|
||||
this.StoreReplenishment.TabIndex = 6;
|
||||
this.StoreReplenishment.Text = "Пополнение магазина";
|
||||
this.StoreReplenishment.UseVisualStyleBackColor = true;
|
||||
this.StoreReplenishment.Click += new System.EventHandler(this.StoreReplenishment_Click);
|
||||
//
|
||||
// menuStrip
|
||||
//
|
||||
this.menuStrip.ImageScalingSize = new System.Drawing.Size(24, 24);
|
||||
this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.справочникиToolStripMenuItem});
|
||||
this.menuStrip.Location = new System.Drawing.Point(0, 0);
|
||||
this.menuStrip.Name = "menuStrip";
|
||||
this.menuStrip.Size = new System.Drawing.Size(1530, 33);
|
||||
this.menuStrip.TabIndex = 6;
|
||||
this.menuStrip.Text = "menuStrip1";
|
||||
//
|
||||
// справочникиToolStripMenuItem
|
||||
//
|
||||
this.справочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.компонентыToolStripMenuItem,
|
||||
this.изделияToolStripMenuItem,
|
||||
this.СправочникиToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.ИзделияToolStripMenuItem,
|
||||
this.КомпонентыToolStripMenuItem,
|
||||
this.StoreToolStripMenuItem});
|
||||
this.справочникиToolStripMenuItem.Name = "справочникиToolStripMenuItem";
|
||||
this.справочникиToolStripMenuItem.Size = new System.Drawing.Size(139, 29);
|
||||
this.справочникиToolStripMenuItem.Text = "Справочники";
|
||||
this.СправочникиToolStripMenuItem.Name = "СправочникиToolStripMenuItem";
|
||||
this.СправочникиToolStripMenuItem.Size = new System.Drawing.Size(94, 20);
|
||||
this.СправочникиToolStripMenuItem.Text = "Cправочники";
|
||||
//
|
||||
// компонентыToolStripMenuItem
|
||||
// ИзделияToolStripMenuItem
|
||||
//
|
||||
this.компонентыToolStripMenuItem.Name = "компонентыToolStripMenuItem";
|
||||
this.компонентыToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
|
||||
this.компонентыToolStripMenuItem.Text = "Компоненты";
|
||||
this.компонентыToolStripMenuItem.Click += new System.EventHandler(this.компонентыToolStripMenuItem_Click);
|
||||
this.ИзделияToolStripMenuItem.Name = "ИзделияToolStripMenuItem";
|
||||
this.ИзделияToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.ИзделияToolStripMenuItem.Text = "Изделия";
|
||||
this.ИзделияToolStripMenuItem.Click += new System.EventHandler(this.ИзделияToolStripMenuItem_Click);
|
||||
//
|
||||
// изделияToolStripMenuItem
|
||||
// КомпонентыToolStripMenuItem
|
||||
//
|
||||
this.изделияToolStripMenuItem.Name = "изделияToolStripMenuItem";
|
||||
this.изделияToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
|
||||
this.изделияToolStripMenuItem.Text = "Драгоценности";
|
||||
this.изделияToolStripMenuItem.Click += new System.EventHandler(this.драгоценностиToolStripMenuItem_Click);
|
||||
this.КомпонентыToolStripMenuItem.Name = "КомпонентыToolStripMenuItem";
|
||||
this.КомпонентыToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.КомпонентыToolStripMenuItem.Text = "Компоненты";
|
||||
this.КомпонентыToolStripMenuItem.Click += new System.EventHandler(this.КомпонентыToolStripMenuItem_Click);
|
||||
//
|
||||
// StoreToolStripMenuItem
|
||||
//
|
||||
this.StoreToolStripMenuItem.Name = "StoreToolStripMenuItem";
|
||||
this.StoreToolStripMenuItem.Size = new System.Drawing.Size(270, 34);
|
||||
this.StoreToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
||||
this.StoreToolStripMenuItem.Text = "Магазины";
|
||||
this.StoreToolStripMenuItem.Click += new System.EventHandler(this.StoreToolStripMenuItem_Click);
|
||||
//
|
||||
// DataGridView
|
||||
//
|
||||
this.DataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.DataGridView.Location = new System.Drawing.Point(0, 27);
|
||||
this.DataGridView.Name = "DataGridView";
|
||||
this.DataGridView.RowTemplate.Height = 25;
|
||||
this.DataGridView.Size = new System.Drawing.Size(722, 421);
|
||||
this.DataGridView.TabIndex = 1;
|
||||
//
|
||||
// CreateOrderButton
|
||||
//
|
||||
this.CreateOrderButton.Location = new System.Drawing.Point(728, 28);
|
||||
this.CreateOrderButton.Name = "CreateOrderButton";
|
||||
this.CreateOrderButton.Size = new System.Drawing.Size(125, 33);
|
||||
this.CreateOrderButton.TabIndex = 2;
|
||||
this.CreateOrderButton.Text = "Создать заказ";
|
||||
this.CreateOrderButton.UseVisualStyleBackColor = true;
|
||||
this.CreateOrderButton.Click += new System.EventHandler(this.CreateOrderButton_Click);
|
||||
//
|
||||
// TakeOrderInWorkButton
|
||||
//
|
||||
this.TakeOrderInWorkButton.Location = new System.Drawing.Point(728, 83);
|
||||
this.TakeOrderInWorkButton.Name = "TakeOrderInWorkButton";
|
||||
this.TakeOrderInWorkButton.Size = new System.Drawing.Size(125, 39);
|
||||
this.TakeOrderInWorkButton.TabIndex = 3;
|
||||
this.TakeOrderInWorkButton.Text = "Отдать на выполнение";
|
||||
this.TakeOrderInWorkButton.UseVisualStyleBackColor = true;
|
||||
this.TakeOrderInWorkButton.Click += new System.EventHandler(this.TakeOrderInWorkButton_Click);
|
||||
//
|
||||
// OrderReadyButton
|
||||
//
|
||||
this.OrderReadyButton.Location = new System.Drawing.Point(728, 146);
|
||||
this.OrderReadyButton.Name = "OrderReadyButton";
|
||||
this.OrderReadyButton.Size = new System.Drawing.Size(125, 33);
|
||||
this.OrderReadyButton.TabIndex = 4;
|
||||
this.OrderReadyButton.Text = "Заказ готов";
|
||||
this.OrderReadyButton.UseVisualStyleBackColor = true;
|
||||
this.OrderReadyButton.Click += new System.EventHandler(this.OrderReadyButton_Click);
|
||||
//
|
||||
// IssuedOrderButton
|
||||
//
|
||||
this.IssuedOrderButton.Location = new System.Drawing.Point(728, 204);
|
||||
this.IssuedOrderButton.Name = "IssuedOrderButton";
|
||||
this.IssuedOrderButton.Size = new System.Drawing.Size(125, 33);
|
||||
this.IssuedOrderButton.TabIndex = 5;
|
||||
this.IssuedOrderButton.Text = "Заказ выдан";
|
||||
this.IssuedOrderButton.UseVisualStyleBackColor = true;
|
||||
this.IssuedOrderButton.Click += new System.EventHandler(this.IssuedOrderButton_Click);
|
||||
//
|
||||
// UpdateListButton
|
||||
//
|
||||
this.UpdateListButton.Location = new System.Drawing.Point(728, 262);
|
||||
this.UpdateListButton.Name = "UpdateListButton";
|
||||
this.UpdateListButton.Size = new System.Drawing.Size(125, 33);
|
||||
this.UpdateListButton.TabIndex = 6;
|
||||
this.UpdateListButton.Text = "Обновить список";
|
||||
this.UpdateListButton.UseVisualStyleBackColor = true;
|
||||
this.UpdateListButton.Click += new System.EventHandler(this.UpdateListButton_Click);
|
||||
//
|
||||
// StoreReplenishment
|
||||
//
|
||||
this.StoreReplenishment.Location = new System.Drawing.Point(728, 317);
|
||||
this.StoreReplenishment.Name = "StoreReplenishment";
|
||||
this.StoreReplenishment.Size = new System.Drawing.Size(125, 50);
|
||||
this.StoreReplenishment.TabIndex = 7;
|
||||
this.StoreReplenishment.Text = "Пополнение магазина";
|
||||
this.StoreReplenishment.UseVisualStyleBackColor = true;
|
||||
this.StoreReplenishment.Click += new System.EventHandler(this.StoreReplenishment_Click);
|
||||
//
|
||||
// SellJewelButton
|
||||
//
|
||||
this.SellJewelButton.Location = new System.Drawing.Point(728, 385);
|
||||
this.SellJewelButton.Name = "SellJewelButton";
|
||||
this.SellJewelButton.Size = new System.Drawing.Size(125, 31);
|
||||
this.SellJewelButton.TabIndex = 8;
|
||||
this.SellJewelButton.Text = "Продать изделие";
|
||||
this.SellJewelButton.UseVisualStyleBackColor = true;
|
||||
this.SellJewelButton.Click += new System.EventHandler(this.SellJewelButton_Click);
|
||||
//
|
||||
// FormMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1530, 599);
|
||||
this.ClientSize = new System.Drawing.Size(865, 450);
|
||||
this.Controls.Add(this.SellJewelButton);
|
||||
this.Controls.Add(this.StoreReplenishment);
|
||||
this.Controls.Add(this.buttonRefresh);
|
||||
this.Controls.Add(this.buttonPut);
|
||||
this.Controls.Add(this.buttonReady);
|
||||
this.Controls.Add(this.buttonToWork);
|
||||
this.Controls.Add(this.buttonCreate);
|
||||
this.Controls.Add(this.dataGridView);
|
||||
this.Controls.Add(this.menuStrip);
|
||||
this.MainMenuStrip = this.menuStrip;
|
||||
this.Controls.Add(this.UpdateListButton);
|
||||
this.Controls.Add(this.IssuedOrderButton);
|
||||
this.Controls.Add(this.OrderReadyButton);
|
||||
this.Controls.Add(this.TakeOrderInWorkButton);
|
||||
this.Controls.Add(this.CreateOrderButton);
|
||||
this.Controls.Add(this.DataGridView);
|
||||
this.Controls.Add(this.MenuStrip);
|
||||
this.MainMenuStrip = this.MenuStrip;
|
||||
this.Name = "FormMain";
|
||||
this.Text = "Изготовление Драгоценностей";
|
||||
this.Load += new System.EventHandler(this.FormMain_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.menuStrip.ResumeLayout(false);
|
||||
this.menuStrip.PerformLayout();
|
||||
this.Text = "Установка ПО";
|
||||
this.MenuStrip.ResumeLayout(false);
|
||||
this.MenuStrip.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@ -183,17 +193,19 @@
|
||||
|
||||
#endregion
|
||||
|
||||
private DataGridView dataGridView;
|
||||
private Button buttonCreate;
|
||||
private Button buttonToWork;
|
||||
private Button buttonPut;
|
||||
private Button buttonRefresh;
|
||||
private MenuStrip menuStrip;
|
||||
private ToolStripMenuItem справочникиToolStripMenuItem;
|
||||
private ToolStripMenuItem компонентыToolStripMenuItem;
|
||||
private ToolStripMenuItem изделияToolStripMenuItem;
|
||||
private MenuStrip MenuStrip;
|
||||
private ToolStripMenuItem СправочникиToolStripMenuItem;
|
||||
private ToolStripMenuItem ИзделияToolStripMenuItem;
|
||||
private ToolStripMenuItem КомпонентыToolStripMenuItem;
|
||||
private DataGridView DataGridView;
|
||||
private Button CreateOrderButton;
|
||||
private Button TakeOrderInWorkButton;
|
||||
private Button OrderReadyButton;
|
||||
private Button IssuedOrderButton;
|
||||
private Button UpdateListButton;
|
||||
private ToolStripMenuItem StoreToolStripMenuItem;
|
||||
private Button buttonReady;
|
||||
private Button StoreReplenishment;
|
||||
private Button SellJewelButton;
|
||||
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ namespace JewelryStore
|
||||
{
|
||||
public partial class FormMain : Form
|
||||
{
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderLogic _orderLogic;
|
||||
|
||||
@ -24,24 +25,26 @@ namespace JewelryStore
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_orderLogic = orderLogic;
|
||||
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void FormMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
|
||||
try
|
||||
{
|
||||
var list = _orderLogic.ReadList(null);
|
||||
|
||||
if (list != null)
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["JewelId"].Visible = false;
|
||||
DataGridView.DataSource = list;
|
||||
DataGridView.Columns["JewelId"].Visible = false;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка заказов");
|
||||
@ -53,16 +56,17 @@ namespace JewelryStore
|
||||
}
|
||||
}
|
||||
|
||||
private void компонентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
private void КомпонентыToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormComponents));
|
||||
|
||||
if (service is FormComponents form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void драгоценностиToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
private void ИзделияToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormJewels));
|
||||
|
||||
@ -72,9 +76,10 @@ namespace JewelryStore
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonCreate_Click(object sender, EventArgs e)
|
||||
private void CreateOrderButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormCreateOrder));
|
||||
|
||||
if (service is FormCreateOrder form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
@ -82,62 +87,66 @@ namespace JewelryStore
|
||||
}
|
||||
}
|
||||
|
||||
private void buttonToWork_Click(object sender, EventArgs e)
|
||||
private void TakeOrderInWorkButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
if (DataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'В работе'", id);
|
||||
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
|
||||
{
|
||||
Id = id,
|
||||
JewelId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["JewelId"].Value),
|
||||
JewelName = dataGridView.SelectedRows[0].Cells["JewelName"].Value.ToString(),
|
||||
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
||||
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
||||
JewelId = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["JewelId"].Value),
|
||||
JewelName = DataGridView.SelectedRows[0].Cells["JewelName"].Value.ToString(),
|
||||
Status = Enum.Parse<OrderStatus>(DataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||
Count = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||
Sum = double.Parse(DataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
||||
DateCreate = DateTime.Parse(DataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
||||
});
|
||||
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка передачи заказа в работу");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void buttonReady_Click(object sender, EventArgs e)
|
||||
private void IssuedOrderButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
if (DataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id);
|
||||
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
|
||||
{
|
||||
Id = id,
|
||||
JewelId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["JewelId"].Value),
|
||||
JewelName = dataGridView.SelectedRows[0].Cells["JewelName"].Value.ToString(),
|
||||
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
||||
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
||||
JewelId = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["JewelId"].Value),
|
||||
JewelName = DataGridView.SelectedRows[0].Cells["JewelName"].Value.ToString(),
|
||||
Status = Enum.Parse<OrderStatus>(DataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||
Count = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||
Sum = double.Parse(DataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
||||
DateCreate = DateTime.Parse(DataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
||||
});
|
||||
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -146,58 +155,49 @@ namespace JewelryStore
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void buttonPut_Click(object sender, EventArgs e)
|
||||
private void OrderReadyButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (dataGridView.SelectedRows.Count == 1)
|
||||
if (DataGridView.SelectedRows.Count == 1)
|
||||
{
|
||||
int id = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value);
|
||||
_logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
|
||||
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.DeliveryOrder(new
|
||||
OrderBindingModel
|
||||
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel
|
||||
{
|
||||
Id = id,
|
||||
JewelId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["JewelId"].Value),
|
||||
JewelName = dataGridView.SelectedRows[0].Cells["JewelName"].Value.ToString(),
|
||||
Status = Enum.Parse<OrderStatus>(dataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||
Count = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||
Sum = double.Parse(dataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
||||
DateCreate = DateTime.Parse(dataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
||||
JewelId = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["JewelId"].Value),
|
||||
JewelName = DataGridView.SelectedRows[0].Cells["JewelName"].Value.ToString(),
|
||||
Status = Enum.Parse<OrderStatus>(DataGridView.SelectedRows[0].Cells["Status"].Value.ToString()),
|
||||
Count = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Count"].Value),
|
||||
Sum = double.Parse(DataGridView.SelectedRows[0].Cells["Sum"].Value.ToString()),
|
||||
DateCreate = DateTime.Parse(DataGridView.SelectedRows[0].Cells["DateCreate"].Value.ToString()),
|
||||
});
|
||||
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
_logger.LogInformation("Заказ №{id} выдан", id);
|
||||
LoadData();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка отметки о выдачи заказа");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void buttonRefresh_Click(object sender, EventArgs e)
|
||||
private void UpdateListButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void StoreToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormStores));
|
||||
|
||||
if (service is FormStores form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
private void StoreReplenishment_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormStoreReplenishment));
|
||||
@ -207,5 +207,25 @@ namespace JewelryStore
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void StoreToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormStores));
|
||||
|
||||
if (service is FormStores form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
|
||||
private void SellJewelButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormSellJewel));
|
||||
|
||||
if (service is FormSellJewel form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
120
JewelryStore/FormSellJewel.Designer.cs
generated
Normal file
120
JewelryStore/FormSellJewel.Designer.cs
generated
Normal file
@ -0,0 +1,120 @@
|
||||
namespace JewelryStore
|
||||
{
|
||||
partial class FormSellJewel
|
||||
{
|
||||
|
||||
/// <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.JewelLabel = new System.Windows.Forms.Label();
|
||||
this.QuantityLabel = new System.Windows.Forms.Label();
|
||||
this.JewelСomboBox = new System.Windows.Forms.ComboBox();
|
||||
this.QuantityTextBox = new System.Windows.Forms.TextBox();
|
||||
this.SaveButton = new System.Windows.Forms.Button();
|
||||
this.ButtonCancel = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// JewelLabel
|
||||
//
|
||||
this.JewelLabel.AutoSize = true;
|
||||
this.JewelLabel.Location = new System.Drawing.Point(12, 18);
|
||||
this.JewelLabel.Name = "JewelLabel";
|
||||
this.JewelLabel.Size = new System.Drawing.Size(56, 15);
|
||||
this.JewelLabel.TabIndex = 0;
|
||||
this.JewelLabel.Text = "Изделие:";
|
||||
//
|
||||
// QuantityLabel
|
||||
//
|
||||
this.QuantityLabel.AutoSize = true;
|
||||
this.QuantityLabel.Location = new System.Drawing.Point(12, 51);
|
||||
this.QuantityLabel.Name = "QuantityLabel";
|
||||
this.QuantityLabel.Size = new System.Drawing.Size(75, 15);
|
||||
this.QuantityLabel.TabIndex = 1;
|
||||
this.QuantityLabel.Text = "Количество:";
|
||||
//
|
||||
// JewelСomboBox
|
||||
//
|
||||
this.JewelСomboBox.FormattingEnabled = true;
|
||||
this.JewelСomboBox.Location = new System.Drawing.Point(88, 15);
|
||||
this.JewelСomboBox.Name = "JewelСomboBox";
|
||||
this.JewelСomboBox.Size = new System.Drawing.Size(184, 23);
|
||||
this.JewelСomboBox.TabIndex = 2;
|
||||
//
|
||||
// QuantityTextBox
|
||||
//
|
||||
this.QuantityTextBox.Location = new System.Drawing.Point(88, 48);
|
||||
this.QuantityTextBox.Name = "QuantityTextBox";
|
||||
this.QuantityTextBox.Size = new System.Drawing.Size(184, 23);
|
||||
this.QuantityTextBox.TabIndex = 3;
|
||||
//
|
||||
// SaveButton
|
||||
//
|
||||
this.SaveButton.Location = new System.Drawing.Point(72, 100);
|
||||
this.SaveButton.Name = "SaveButton";
|
||||
this.SaveButton.Size = new System.Drawing.Size(97, 29);
|
||||
this.SaveButton.TabIndex = 4;
|
||||
this.SaveButton.Text = "Сохранить";
|
||||
this.SaveButton.UseVisualStyleBackColor = true;
|
||||
this.SaveButton.Click += new System.EventHandler(this.SaveButton_Click);
|
||||
//
|
||||
// ButtonCancel
|
||||
//
|
||||
this.ButtonCancel.Location = new System.Drawing.Point(175, 100);
|
||||
this.ButtonCancel.Name = "ButtonCancel";
|
||||
this.ButtonCancel.Size = new System.Drawing.Size(97, 29);
|
||||
this.ButtonCancel.TabIndex = 5;
|
||||
this.ButtonCancel.Text = "Отмена";
|
||||
this.ButtonCancel.UseVisualStyleBackColor = true;
|
||||
this.ButtonCancel.Click += new System.EventHandler(this.ButtonCancel_Click);
|
||||
//
|
||||
// FromSellJewel
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(284, 141);
|
||||
this.Controls.Add(this.ButtonCancel);
|
||||
this.Controls.Add(this.SaveButton);
|
||||
this.Controls.Add(this.QuantityTextBox);
|
||||
this.Controls.Add(this.JewelСomboBox);
|
||||
this.Controls.Add(this.QuantityLabel);
|
||||
this.Controls.Add(this.JewelLabel);
|
||||
this.Name = "FromSellJewel";
|
||||
this.Text = "Продать Изделие";
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label JewelLabel;
|
||||
private Label QuantityLabel;
|
||||
private ComboBox JewelСomboBox;
|
||||
private TextBox QuantityTextBox;
|
||||
private Button SaveButton;
|
||||
private Button ButtonCancel;
|
||||
}
|
||||
}
|
103
JewelryStore/FormSellJewel.cs
Normal file
103
JewelryStore/FormSellJewel.cs
Normal file
@ -0,0 +1,103 @@
|
||||
using JewelryStoreContracts.BusinessLogicsContracts;
|
||||
using JewelryStoreContracts.SearchModels;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace JewelryStore
|
||||
{
|
||||
public partial class FormSellJewel : Form
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IJewelLogic _logicJewel;
|
||||
private readonly IStoreLogic _logicStore;
|
||||
public FormSellJewel(ILogger<FormSellJewel> logger, IJewelLogic logicJewel, IStoreLogic logicStore)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_logicJewel = logicJewel;
|
||||
_logicStore = logicStore;
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void FormSellJewel_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
|
||||
private void LoadData()
|
||||
{
|
||||
_logger.LogInformation("Loading jewels for sale.");
|
||||
|
||||
try
|
||||
{
|
||||
var list = _logicJewel.ReadList(null);
|
||||
if (list != null)
|
||||
{
|
||||
JewelСomboBox.DisplayMember = "JewelName";
|
||||
JewelСomboBox.ValueMember = "Id";
|
||||
JewelСomboBox.DataSource = list;
|
||||
JewelСomboBox.SelectedItem = null;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "List loading error.");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(QuantityTextBox.Text))
|
||||
{
|
||||
MessageBox.Show("Укажите количество", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (JewelСomboBox.SelectedValue == null)
|
||||
{
|
||||
MessageBox.Show("Выберите изделие", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Jewel sale.");
|
||||
|
||||
try
|
||||
{
|
||||
var operationResult = _logicStore.SellJewel(_logicJewel.ReadElement(new JewelSearchModel()
|
||||
{
|
||||
Id = Convert.ToInt32(JewelСomboBox.SelectedValue)
|
||||
})!, Convert.ToInt32(QuantityTextBox.Text));
|
||||
|
||||
if (!operationResult)
|
||||
{
|
||||
throw new Exception("Ошибка при продаже изделия. Дополнительная информация в логах.");
|
||||
}
|
||||
|
||||
MessageBox.Show("Сохранение прошло успешно", "Сообщение", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
DialogResult = DialogResult.OK;
|
||||
|
||||
Close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Jewel sale error.");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
JewelryStore/FormSellJewel.resx
Normal file
120
JewelryStore/FormSellJewel.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>
|
93
JewelryStore/FormStore.Designer.cs
generated
93
JewelryStore/FormStore.Designer.cs
generated
@ -31,7 +31,7 @@
|
||||
this.StoreNameLabel = new System.Windows.Forms.Label();
|
||||
this.StoreAdressLabel = new System.Windows.Forms.Label();
|
||||
this.OpeningDateLabel = new System.Windows.Forms.Label();
|
||||
this.NameTextBox = new System.Windows.Forms.TextBox();
|
||||
this.NameComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.AdressTextBox = new System.Windows.Forms.TextBox();
|
||||
this.DataGridView = new System.Windows.Forms.DataGridView();
|
||||
this.JewelName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
@ -40,53 +40,52 @@
|
||||
this.SaveButton = new System.Windows.Forms.Button();
|
||||
this.ButtonCancel = new System.Windows.Forms.Button();
|
||||
this.OpeningDatePicker = new System.Windows.Forms.DateTimePicker();
|
||||
this.VolumeNumericUpDown = new System.Windows.Forms.NumericUpDown();
|
||||
this.JewelMaxCountLable = new System.Windows.Forms.Label();
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.VolumeNumericUpDown)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// StoreNameLabel
|
||||
//
|
||||
this.StoreNameLabel.AutoSize = true;
|
||||
this.StoreNameLabel.Location = new System.Drawing.Point(17, 15);
|
||||
this.StoreNameLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.StoreNameLabel.Location = new System.Drawing.Point(12, 9);
|
||||
this.StoreNameLabel.Name = "StoreNameLabel";
|
||||
this.StoreNameLabel.Size = new System.Drawing.Size(179, 25);
|
||||
this.StoreNameLabel.Size = new System.Drawing.Size(119, 15);
|
||||
this.StoreNameLabel.TabIndex = 0;
|
||||
this.StoreNameLabel.Text = "Название магазина: ";
|
||||
//
|
||||
// StoreAdressLabel
|
||||
//
|
||||
this.StoreAdressLabel.AutoSize = true;
|
||||
this.StoreAdressLabel.Location = new System.Drawing.Point(17, 67);
|
||||
this.StoreAdressLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.StoreAdressLabel.Location = new System.Drawing.Point(12, 40);
|
||||
this.StoreAdressLabel.Name = "StoreAdressLabel";
|
||||
this.StoreAdressLabel.Size = new System.Drawing.Size(151, 25);
|
||||
this.StoreAdressLabel.Size = new System.Drawing.Size(100, 15);
|
||||
this.StoreAdressLabel.TabIndex = 1;
|
||||
this.StoreAdressLabel.Text = "Адрес магазина: ";
|
||||
//
|
||||
// OpeningDateLabel
|
||||
//
|
||||
this.OpeningDateLabel.AutoSize = true;
|
||||
this.OpeningDateLabel.Location = new System.Drawing.Point(17, 120);
|
||||
this.OpeningDateLabel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
|
||||
this.OpeningDateLabel.Location = new System.Drawing.Point(12, 72);
|
||||
this.OpeningDateLabel.Name = "OpeningDateLabel";
|
||||
this.OpeningDateLabel.Size = new System.Drawing.Size(140, 25);
|
||||
this.OpeningDateLabel.Size = new System.Drawing.Size(93, 15);
|
||||
this.OpeningDateLabel.TabIndex = 2;
|
||||
this.OpeningDateLabel.Text = "Дата открытия: ";
|
||||
//
|
||||
// NameTextBox
|
||||
// NameComboBox
|
||||
//
|
||||
this.NameTextBox.Location = new System.Drawing.Point(196, 10);
|
||||
this.NameTextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.NameTextBox.Name = "NameTextBox";
|
||||
this.NameTextBox.Size = new System.Drawing.Size(247, 31);
|
||||
this.NameTextBox.TabIndex = 3;
|
||||
this.NameComboBox.FormattingEnabled = true;
|
||||
this.NameComboBox.Location = new System.Drawing.Point(137, 6);
|
||||
this.NameComboBox.Name = "NameComboBox";
|
||||
this.NameComboBox.Size = new System.Drawing.Size(174, 23);
|
||||
this.NameComboBox.TabIndex = 3;
|
||||
//
|
||||
// AdressTextBox
|
||||
//
|
||||
this.AdressTextBox.Location = new System.Drawing.Point(196, 62);
|
||||
this.AdressTextBox.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.AdressTextBox.Location = new System.Drawing.Point(137, 37);
|
||||
this.AdressTextBox.Name = "AdressTextBox";
|
||||
this.AdressTextBox.Size = new System.Drawing.Size(247, 31);
|
||||
this.AdressTextBox.Size = new System.Drawing.Size(174, 23);
|
||||
this.AdressTextBox.TabIndex = 4;
|
||||
//
|
||||
// DataGridView
|
||||
@ -96,41 +95,33 @@
|
||||
this.JewelName,
|
||||
this.JewelPrice,
|
||||
this.JewelCount});
|
||||
this.DataGridView.Location = new System.Drawing.Point(17, 182);
|
||||
this.DataGridView.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.DataGridView.Location = new System.Drawing.Point(12, 109);
|
||||
this.DataGridView.Name = "DataGridView";
|
||||
this.DataGridView.RowHeadersWidth = 62;
|
||||
this.DataGridView.RowTemplate.Height = 25;
|
||||
this.DataGridView.Size = new System.Drawing.Size(1109, 480);
|
||||
this.DataGridView.Size = new System.Drawing.Size(776, 288);
|
||||
this.DataGridView.TabIndex = 6;
|
||||
//
|
||||
// JewelName
|
||||
//
|
||||
this.JewelName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.JewelName.HeaderText = "Название изделия";
|
||||
this.JewelName.MinimumWidth = 8;
|
||||
this.JewelName.Name = "JewelName";
|
||||
//
|
||||
// JewelPrice
|
||||
//
|
||||
this.JewelPrice.HeaderText = "Цена";
|
||||
this.JewelPrice.MinimumWidth = 8;
|
||||
this.JewelPrice.Name = "JewelPrice";
|
||||
this.JewelPrice.Width = 150;
|
||||
//
|
||||
// JewelCount
|
||||
//
|
||||
this.JewelCount.HeaderText = "Количество";
|
||||
this.JewelCount.MinimumWidth = 8;
|
||||
this.JewelCount.Name = "JewelCount";
|
||||
this.JewelCount.Width = 150;
|
||||
//
|
||||
// SaveButton
|
||||
//
|
||||
this.SaveButton.Location = new System.Drawing.Point(789, 672);
|
||||
this.SaveButton.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.SaveButton.Location = new System.Drawing.Point(552, 403);
|
||||
this.SaveButton.Name = "SaveButton";
|
||||
this.SaveButton.Size = new System.Drawing.Size(164, 58);
|
||||
this.SaveButton.Size = new System.Drawing.Size(115, 35);
|
||||
this.SaveButton.TabIndex = 7;
|
||||
this.SaveButton.Text = "Сохранить";
|
||||
this.SaveButton.UseVisualStyleBackColor = true;
|
||||
@ -138,10 +129,9 @@
|
||||
//
|
||||
// ButtonCancel
|
||||
//
|
||||
this.ButtonCancel.Location = new System.Drawing.Point(961, 672);
|
||||
this.ButtonCancel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.ButtonCancel.Location = new System.Drawing.Point(673, 403);
|
||||
this.ButtonCancel.Name = "ButtonCancel";
|
||||
this.ButtonCancel.Size = new System.Drawing.Size(164, 58);
|
||||
this.ButtonCancel.Size = new System.Drawing.Size(115, 35);
|
||||
this.ButtonCancel.TabIndex = 8;
|
||||
this.ButtonCancel.Text = "Отменить";
|
||||
this.ButtonCancel.UseVisualStyleBackColor = true;
|
||||
@ -149,31 +139,48 @@
|
||||
//
|
||||
// OpeningDatePicker
|
||||
//
|
||||
this.OpeningDatePicker.Location = new System.Drawing.Point(196, 110);
|
||||
this.OpeningDatePicker.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.OpeningDatePicker.Location = new System.Drawing.Point(137, 66);
|
||||
this.OpeningDatePicker.Name = "OpeningDatePicker";
|
||||
this.OpeningDatePicker.Size = new System.Drawing.Size(247, 31);
|
||||
this.OpeningDatePicker.Size = new System.Drawing.Size(174, 23);
|
||||
this.OpeningDatePicker.TabIndex = 9;
|
||||
//
|
||||
// VolumeNumericUpDown
|
||||
//
|
||||
this.VolumeNumericUpDown.Location = new System.Drawing.Point(486, 7);
|
||||
this.VolumeNumericUpDown.Name = "VolumeNumericUpDown";
|
||||
this.VolumeNumericUpDown.Size = new System.Drawing.Size(168, 23);
|
||||
this.VolumeNumericUpDown.TabIndex = 10;
|
||||
//
|
||||
// JewelMaxCountLable
|
||||
//
|
||||
this.JewelMaxCountLable.AutoSize = true;
|
||||
this.JewelMaxCountLable.Location = new System.Drawing.Point(340, 9);
|
||||
this.JewelMaxCountLable.Name = "JewelMaxCountLable";
|
||||
this.JewelMaxCountLable.Size = new System.Drawing.Size(140, 15);
|
||||
this.JewelMaxCountLable.TabIndex = 11;
|
||||
this.JewelMaxCountLable.Text = "Вместимость магазина: ";
|
||||
//
|
||||
// FormStore
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(10F, 25F);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(1143, 750);
|
||||
this.ClientSize = new System.Drawing.Size(800, 450);
|
||||
this.Controls.Add(this.JewelMaxCountLable);
|
||||
this.Controls.Add(this.VolumeNumericUpDown);
|
||||
this.Controls.Add(this.OpeningDatePicker);
|
||||
this.Controls.Add(this.ButtonCancel);
|
||||
this.Controls.Add(this.SaveButton);
|
||||
this.Controls.Add(this.DataGridView);
|
||||
this.Controls.Add(this.AdressTextBox);
|
||||
this.Controls.Add(this.NameTextBox);
|
||||
this.Controls.Add(this.NameComboBox);
|
||||
this.Controls.Add(this.OpeningDateLabel);
|
||||
this.Controls.Add(this.StoreAdressLabel);
|
||||
this.Controls.Add(this.StoreNameLabel);
|
||||
this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.Name = "FormStore";
|
||||
this.Text = "Изделия магазина";
|
||||
this.Load += new System.EventHandler(this.FormStore_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.DataGridView)).EndInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.VolumeNumericUpDown)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
@ -184,7 +191,7 @@
|
||||
private Label StoreNameLabel;
|
||||
private Label StoreAdressLabel;
|
||||
private Label OpeningDateLabel;
|
||||
private TextBox NameTextBox;
|
||||
private ComboBox NameComboBox;
|
||||
private TextBox AdressTextBox;
|
||||
private DataGridView DataGridView;
|
||||
private Button SaveButton;
|
||||
@ -193,5 +200,7 @@
|
||||
private DataGridViewTextBoxColumn JewelPrice;
|
||||
private DataGridViewTextBoxColumn JewelCount;
|
||||
private DateTimePicker OpeningDatePicker;
|
||||
private NumericUpDown VolumeNumericUpDown;
|
||||
private Label JewelMaxCountLable;
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
using JewelryStoreContracts.BindingModels;
|
||||
using JewelryStoreContracts.BusinessLogicsContracts;
|
||||
using JewelryStoreContracts.SearchModels;
|
||||
using JewelryStoreContracts.ViewModels;
|
||||
using JewelryStoreDataModels.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@ -17,78 +18,48 @@ namespace JewelryStore
|
||||
{
|
||||
public partial class FormStore : Form
|
||||
{
|
||||
private readonly List<StoreViewModel>? _listStores;
|
||||
private readonly IStoreLogic _logic;
|
||||
private readonly ILogger _logger;
|
||||
public int Id { get; set; }
|
||||
private int? _id;
|
||||
private Dictionary<int, (IJewelModel, int)> _listStores;
|
||||
public int Id { set { _id = value; } }
|
||||
|
||||
public FormStore(ILogger<FormStore> logger, IStoreLogic logic)
|
||||
{
|
||||
InitializeComponent();
|
||||
_logger = logger;
|
||||
_listStores = logic.ReadList(null);
|
||||
_listStores = new();
|
||||
_logic = logic;
|
||||
}
|
||||
|
||||
private IStoreModel? GetStore(int id)
|
||||
{
|
||||
if (_listStores == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
foreach (var elem in _listStores)
|
||||
{
|
||||
if (elem.Id == id)
|
||||
{
|
||||
return elem;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void SaveButton_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (string.IsNullOrEmpty(NameTextBox.Text))
|
||||
if (string.IsNullOrEmpty(NameComboBox.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните название", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(AdressTextBox.Text))
|
||||
{
|
||||
MessageBox.Show("Заполните адрес", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Сохранение магазина");
|
||||
|
||||
try
|
||||
{
|
||||
DateTime.TryParse(OpeningDatePicker.Text, out var dateTime);
|
||||
StoreBindingModel model = new()
|
||||
var model = new StoreBindingModel
|
||||
{
|
||||
StoreName = NameTextBox.Text,
|
||||
Id = _id ?? 0,
|
||||
StoreName = NameComboBox.Text,
|
||||
StoreAdress = AdressTextBox.Text,
|
||||
OpeningDate = dateTime
|
||||
OpeningDate = OpeningDatePicker.Value.Date,
|
||||
JewelMaxCount = (int)VolumeNumericUpDown.Value
|
||||
};
|
||||
var vmodel = GetStore(Id);
|
||||
bool operationResult = false;
|
||||
|
||||
if (vmodel != null)
|
||||
{
|
||||
model.Id = vmodel.Id;
|
||||
operationResult = _logic.Update(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
operationResult = _logic.Create(model);
|
||||
}
|
||||
|
||||
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();
|
||||
@ -108,34 +79,52 @@ namespace JewelryStore
|
||||
|
||||
private void FormStore_Load(object sender, EventArgs e)
|
||||
{
|
||||
LoadData();
|
||||
}
|
||||
private void LoadData(bool extendDate = true)
|
||||
if (_id.HasValue)
|
||||
{
|
||||
_logger.LogInformation("Загрузка магазина");
|
||||
try
|
||||
{
|
||||
var model = GetStore(extendDate ? Id : Convert.ToInt32(NameTextBox.Text));
|
||||
if (model != null)
|
||||
var view = _logic.ReadElement(new StoreSearchModel
|
||||
{
|
||||
NameTextBox.Text = model.StoreName;
|
||||
AdressTextBox.Text = model.StoreAdress;
|
||||
OpeningDatePicker.Text = Convert.ToString(model.OpeningDate);
|
||||
DataGridView.Rows.Clear();
|
||||
foreach (var el in model.StoreJewels.Values)
|
||||
Id = _id.Value
|
||||
});
|
||||
if (view != null)
|
||||
{
|
||||
DataGridView.Rows.Add(new object[] { el.Item1.JewelName, el.Item1.Price, el.Item2 });
|
||||
NameComboBox.Text = view.StoreName;
|
||||
AdressTextBox.Text = view.StoreAdress;
|
||||
OpeningDatePicker.Text = view.OpeningDate.ToString();
|
||||
VolumeNumericUpDown.Value = view.JewelMaxCount;
|
||||
_listStores = view.StoreJewels ?? new Dictionary<int, (IJewelModel, int)>();
|
||||
LoadData();
|
||||
}
|
||||
}
|
||||
_logger.LogInformation("Загрузка магазинов");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки магазинов");
|
||||
_logger.LogError(ex, "Ошибка загрузки магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
private void LoadData(bool extendDate = true)
|
||||
{
|
||||
_logger.LogInformation("Загрузка изделий магазина");
|
||||
try
|
||||
{
|
||||
if (_listStores != null)
|
||||
{
|
||||
DataGridView.Rows.Clear();
|
||||
foreach (var elem in _listStores)
|
||||
{
|
||||
DataGridView.Rows.Add(new object[] { elem.Key, elem.Value.Item1.JewelName, elem.Value.Item2 });
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка загрузки изделий магазина");
|
||||
MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ namespace JewelryStore
|
||||
DataGridView.DataSource = list;
|
||||
DataGridView.Columns["Id"].Visible = false;
|
||||
DataGridView.Columns["StoreName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
DataGridView.Columns["Jewels"].Visible = false;
|
||||
DataGridView.Columns["StoreJewels"].Visible = false;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка магазинов");
|
||||
|
@ -15,21 +15,17 @@ namespace JewelryStore
|
||||
{
|
||||
private static ServiceProvider? _serviceProvider;
|
||||
public static ServiceProvider? ServiceProvider => _serviceProvider;
|
||||
/// <summary>
|
||||
/// The main entry point for the application.
|
||||
/// </summary>
|
||||
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
// To customize application configuration such as set high DPI
|
||||
//settings or default font,
|
||||
// see https://aka.ms/applicationconfiguration.
|
||||
ApplicationConfiguration.Initialize();
|
||||
var services = new ServiceCollection();
|
||||
ConfigureServices(services);
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
Application.Run(_serviceProvider.GetRequiredService<FormMain>());
|
||||
}
|
||||
|
||||
private static void ConfigureServices(ServiceCollection services)
|
||||
{
|
||||
services.AddLogging(option =>
|
||||
@ -55,7 +51,7 @@ namespace JewelryStore
|
||||
services.AddTransient<FormStores>();
|
||||
services.AddTransient<FormStore>();
|
||||
services.AddTransient<FormStoreReplenishment>();
|
||||
services.AddTransient<FormSellJewel>();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user