Eliseev E.E. LabWork01 #1
@ -125,14 +125,14 @@
|
||||
// workPieceToolStripMenuItem
|
||||
//
|
||||
this.workPieceToolStripMenuItem.Name = "workPieceToolStripMenuItem";
|
||||
this.workPieceToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||
this.workPieceToolStripMenuItem.Size = new System.Drawing.Size(162, 26);
|
||||
this.workPieceToolStripMenuItem.Text = "Заготовки";
|
||||
this.workPieceToolStripMenuItem.Click += new System.EventHandler(this.WorkPieceToolStripMenuItem_Click);
|
||||
//
|
||||
// manufactureToolStripMenuItem
|
||||
//
|
||||
this.manufactureToolStripMenuItem.Name = "manufactureToolStripMenuItem";
|
||||
this.manufactureToolStripMenuItem.Size = new System.Drawing.Size(224, 26);
|
||||
this.manufactureToolStripMenuItem.Size = new System.Drawing.Size(162, 26);
|
||||
this.manufactureToolStripMenuItem.Text = "Изделия";
|
||||
this.manufactureToolStripMenuItem.Click += new System.EventHandler(this.ManufactureToolStripMenuItem_Click);
|
||||
//
|
||||
@ -150,7 +150,7 @@
|
||||
this.Controls.Add(this.menuStrip1);
|
||||
this.MainMenuStrip = this.menuStrip1;
|
||||
this.Name = "FormMain";
|
||||
this.Text = "Абстрактный магазин";
|
||||
this.Text = "Кузнечная мастерская";
|
||||
this.Load += new System.EventHandler(this.FormMain_Load);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
|
||||
this.menuStrip1.ResumeLayout(false);
|
||||
|
@ -1,5 +1,6 @@
|
||||
using BlacksmithWorkshopContracts.BindingModels;
|
||||
using BlacksmithWorkshopContracts.BusinessLogicsContracts;
|
||||
using BlacksmithWorkshopDataModels.Enums;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@ -67,9 +68,9 @@ namespace BlacksmithWorkshop
|
||||
|
||||
private void ManufactureToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormManufacture));
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormManufactures));
|
||||
|
||||
if (service is FormManufacture form)
|
||||
if (service is FormManufactures form)
|
||||
{
|
||||
form.ShowDialog();
|
||||
}
|
||||
@ -97,8 +98,13 @@ namespace BlacksmithWorkshop
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
|
||||
{
|
||||
Id = id
|
||||
{
|
||||
Id = id,
|
||||
ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].Value),
|
||||
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)
|
||||
@ -126,8 +132,13 @@ namespace BlacksmithWorkshop
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
|
||||
{
|
||||
Id = id
|
||||
{
|
||||
Id = id,
|
||||
ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].Value),
|
||||
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)
|
||||
@ -155,8 +166,13 @@ namespace BlacksmithWorkshop
|
||||
try
|
||||
{
|
||||
var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel
|
||||
{
|
||||
Id = id
|
||||
{
|
||||
Id = id,
|
||||
ManufactureId = Convert.ToInt32(dataGridView.SelectedRows[0].Cells["ManufactureId"].Value),
|
||||
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)
|
||||
|
@ -43,7 +43,8 @@ namespace BlacksmithWorkshop
|
||||
{
|
||||
dataGridView.DataSource = list;
|
||||
dataGridView.Columns["Id"].Visible = false;
|
||||
dataGridView.Columns["ColumnName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
dataGridView.Columns["ManufactureWorkPieces"].Visible = false;
|
||||
dataGridView.Columns["ManufactureName"].AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
|
||||
}
|
||||
|
||||
_logger.LogInformation("Загрузка изделий");
|
||||
@ -58,6 +59,7 @@ namespace BlacksmithWorkshop
|
||||
private void ButtonAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
var service = Program.ServiceProvider?.GetService(typeof(FormManufacture));
|
||||
|
||||
if (service is FormManufacture form)
|
||||
{
|
||||
if (form.ShowDialog() == DialogResult.OK)
|
||||
|
@ -30,7 +30,7 @@ namespace BlacksmithWorkshopListImplement.Implements
|
||||
|
||||
foreach (var order in _source.Orders)
|
||||
{
|
||||
result.Add(order.GetViewModel);
|
||||
result.Add(GetViewModel(order));
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -50,7 +50,7 @@ namespace BlacksmithWorkshopListImplement.Implements
|
||||
{
|
||||
if (order.Id == model.Id)
|
||||
{
|
||||
result.Add(order.GetViewModel);
|
||||
result.Add(GetViewModel(order));
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,13 +69,31 @@ namespace BlacksmithWorkshopListImplement.Implements
|
||||
{
|
||||
if (model.Id.HasValue && order.Id == model.Id)
|
||||
{
|
||||
return order.GetViewModel;
|
||||
return GetViewModel(order);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
//метод для записи названия изделия на форме с заказами
|
||||
private OrderViewModel GetViewModel(Order order)
|
||||
{
|
||||
var viewModel = order.GetViewModel;
|
||||
|
||||
foreach (var manufactures in _source.Manufactures)
|
||||
{
|
||||
if (manufactures.Id == order.ManufactureId)
|
||||
{
|
||||
viewModel.ManufactureName = manufactures.ManufactureName;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return viewModel;
|
||||
}
|
||||
|
||||
//при создании заказа определяем для него новый id: ищем max id и прибавляем к нему 1
|
||||
public OrderViewModel? Insert(OrderBindingModel model)
|
||||
{
|
||||
@ -98,7 +116,7 @@ namespace BlacksmithWorkshopListImplement.Implements
|
||||
|
||||
_source.Orders.Add(newOrder);
|
||||
|
||||
return newOrder.GetViewModel;
|
||||
return GetViewModel(newOrder);
|
||||
}
|
||||
|
||||
//обновление заказа
|
||||
@ -110,7 +128,7 @@ namespace BlacksmithWorkshopListImplement.Implements
|
||||
{
|
||||
order.Update(model);
|
||||
|
||||
return order.GetViewModel;
|
||||
return GetViewModel(order);
|
||||
}
|
||||
}
|
||||
|
||||
@ -127,7 +145,7 @@ namespace BlacksmithWorkshopListImplement.Implements
|
||||
var element = _source.Orders[i];
|
||||
_source.Orders.RemoveAt(i);
|
||||
|
||||
return element.GetViewModel;
|
||||
return GetViewModel(element);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ namespace BlacksmithWorkshopListImplement.Models
|
||||
|
||||
return new Order()
|
||||
{
|
||||
Id = model.Id,
|
||||
ManufactureId = model.ManufactureId,
|
||||
Count = model.Count,
|
||||
Sum = model.Sum,
|
||||
@ -54,18 +55,14 @@ namespace BlacksmithWorkshopListImplement.Models
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ManufactureId = model.ManufactureId;
|
||||
Count = model.Count;
|
||||
Sum = model.Sum;
|
||||
Status = model.Status;
|
||||
DateCreate = model.DateCreate;
|
||||
DateImplement = model.DateImplement;
|
||||
}
|
||||
|
||||
//метод для создания объекта класса ViewModel на основе данных объекта класса-компонента
|
||||
public OrderViewModel GetViewModel => new()
|
||||
{
|
||||
Id = Id,
|
||||
ManufactureId = ManufactureId,
|
||||
Count = Count,
|
||||
Sum = Sum,
|
||||
|
Loading…
Reference in New Issue
Block a user