Вроде финальные правки.

This commit is contained in:
Programmist73 2023-02-13 23:06:34 +04:00
parent 52e276b9bd
commit 3cd62dec9e
5 changed files with 56 additions and 23 deletions

View File

@ -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);

View File

@ -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)

View File

@ -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)

View File

@ -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);
}
}

View File

@ -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,