diff --git a/PrecastConcretePlant/FormCreateOrder.cs b/PrecastConcretePlant/FormCreateOrder.cs index f64035c..b3a89b2 100644 --- a/PrecastConcretePlant/FormCreateOrder.cs +++ b/PrecastConcretePlant/FormCreateOrder.cs @@ -108,7 +108,6 @@ namespace PrecastConcretePlantView var operationResult = _logicO.CreateOrder(new OrderBindingModel { ReinforcedId = Convert.ToInt32(ReinforcedComboBox.SelectedValue), - ReinforcedName = ReinforcedComboBox.Text, Count = Convert.ToInt32(CountTextBox.Text), Sum = Convert.ToDouble(SumTextBox.Text) }); diff --git a/PrecastConcretePlant/FormMain.cs b/PrecastConcretePlant/FormMain.cs index 7fa1cd9..2721deb 100644 --- a/PrecastConcretePlant/FormMain.cs +++ b/PrecastConcretePlant/FormMain.cs @@ -98,13 +98,7 @@ namespace PrecastConcretePlantView { var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel { - Id = id, - ReinforcedId = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["ReinforcedId"].Value), - ReinforcedName = DataGridView.SelectedRows[0].Cells["ReinforcedName"].Value.ToString(), - Status = Enum.Parse(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()), + Id = id }); if (!operationResult) @@ -127,61 +121,19 @@ namespace PrecastConcretePlantView if (DataGridView.SelectedRows.Count == 1) { int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); try { var operationResult = _orderLogic.FinishOrder(new OrderBindingModel { - Id = id, - ReinforcedId = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["ReinforcedId"].Value), - ReinforcedName = DataGridView.SelectedRows[0].Cells["ReinforcedName"].Value.ToString(), - Status = Enum.Parse(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()), + Id = id }); if (!operationResult) { throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); } - - LoadData(); - } - catch (Exception ex) - { - _logger.LogError(ex, "Ошибка отметки о готовности заказа"); - MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - } - - private void OrderReadyButton_Click(object sender, EventArgs e) - { - if (DataGridView.SelectedRows.Count == 1) - { - int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); - _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id); - - try - { - var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel - { - Id = id, - ReinforcedId = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["ReinforcedId"].Value), - ReinforcedName = DataGridView.SelectedRows[0].Cells["ReinforcedName"].Value.ToString(), - Status = Enum.Parse(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(); } @@ -193,6 +145,36 @@ namespace PrecastConcretePlantView } } + private void OrderReadyButton_Click(object sender, EventArgs e) + { + if (DataGridView.SelectedRows.Count == 1) + { + int id = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["Id"].Value); + _logger.LogInformation("Заказ №{id}. Меняется статус на 'Готов'", id); + + try + { + var operationResult = _orderLogic.DeliveryOrder(new OrderBindingModel + { + Id = id + }); + + if (!operationResult) + { + throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); + } + + _logger.LogInformation("Заказ №{id} готов", id); + LoadData(); + } + catch (Exception ex) + { + _logger.LogError(ex, "Ошибка отметки о готовности заказа"); + MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + } + } + private void UpdateListButton_Click(object sender, EventArgs e) { LoadData(); diff --git a/PrecastConcretePlantContracts/BindingModels/OrderBindingModel.cs b/PrecastConcretePlantContracts/BindingModels/OrderBindingModel.cs index e8e0bff..ec3ad91 100644 --- a/PrecastConcretePlantContracts/BindingModels/OrderBindingModel.cs +++ b/PrecastConcretePlantContracts/BindingModels/OrderBindingModel.cs @@ -12,7 +12,6 @@ namespace PrecastConcretePlantContracts.BindingModels { public int Id { get; set; } public int ReinforcedId { get; set; } - public string ReinforcedName { get; set; } = string.Empty; public int Count { get; set; } public double Sum { get; set; } public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; diff --git a/PrecastConcretePlantContracts/ViewModels/OrderViewModel.cs b/PrecastConcretePlantContracts/ViewModels/OrderViewModel.cs index 48ddb46..27f9501 100644 --- a/PrecastConcretePlantContracts/ViewModels/OrderViewModel.cs +++ b/PrecastConcretePlantContracts/ViewModels/OrderViewModel.cs @@ -11,9 +11,9 @@ namespace PrecastConcretePlantContracts.ViewModels { public class OrderViewModel : IOrderModel { - public int ReinforcedId { get; set; } [DisplayName("Номер")] public int Id { get; set; } + public int ReinforcedId { get; set; } [DisplayName("Изделие")] public string ReinforcedName { get; set; } = string.Empty; [DisplayName("Количество")] diff --git a/PrecastConcretePlantDataModels/Models/IOrderModel.cs b/PrecastConcretePlantDataModels/Models/IOrderModel.cs index 50d8b16..db89e4e 100644 --- a/PrecastConcretePlantDataModels/Models/IOrderModel.cs +++ b/PrecastConcretePlantDataModels/Models/IOrderModel.cs @@ -10,7 +10,6 @@ namespace PrecastConcretePlantDataModels.Models public interface IOrderModel : IId { int ReinforcedId { get; } - string ReinforcedName { get; } int Count { get; } double Sum { get; } OrderStatus Status { get; } diff --git a/PrecastConcretePlantListImplement/Models/Order.cs b/PrecastConcretePlantListImplement/Models/Order.cs index 46c7dd0..004364e 100644 --- a/PrecastConcretePlantListImplement/Models/Order.cs +++ b/PrecastConcretePlantListImplement/Models/Order.cs @@ -13,7 +13,6 @@ namespace PrecastConcretePlantListImplement.Models public class Order : IOrderModel { public int ReinforcedId { get; private set; } - public string ReinforcedName { get; private set; } public int Count { get; private set; } public double Sum { get; private set; } @@ -36,7 +35,6 @@ namespace PrecastConcretePlantListImplement.Models { Id = model.Id, ReinforcedId = model.ReinforcedId, - ReinforcedName = model.ReinforcedName, Count = model.Count, Sum = model.Sum, Status = model.Status, @@ -51,12 +49,7 @@ namespace PrecastConcretePlantListImplement.Models { return; } - ReinforcedId = model.ReinforcedId; - ReinforcedName = model.ReinforcedName; - Count = model.Count; - Sum = model.Sum; Status = model.Status; - DateCreate = model.DateCreate; DateImplement = model.DateImplement; } @@ -64,7 +57,6 @@ namespace PrecastConcretePlantListImplement.Models { Id = Id, ReinforcedId = ReinforcedId, - ReinforcedName = ReinforcedName, Count = Count, Sum = Sum, Status = Status,