лр1 коммит2

This commit is contained in:
Катя Ихонкина 2023-03-18 13:35:02 +04:00
parent f1a5244eef
commit 023ecce88f
6 changed files with 34 additions and 63 deletions

View File

@ -108,7 +108,6 @@ namespace PrecastConcretePlantView
var operationResult = _logicO.CreateOrder(new OrderBindingModel var operationResult = _logicO.CreateOrder(new OrderBindingModel
{ {
ReinforcedId = Convert.ToInt32(ReinforcedComboBox.SelectedValue), ReinforcedId = Convert.ToInt32(ReinforcedComboBox.SelectedValue),
ReinforcedName = ReinforcedComboBox.Text,
Count = Convert.ToInt32(CountTextBox.Text), Count = Convert.ToInt32(CountTextBox.Text),
Sum = Convert.ToDouble(SumTextBox.Text) Sum = Convert.ToDouble(SumTextBox.Text)
}); });

View File

@ -98,13 +98,7 @@ namespace PrecastConcretePlantView
{ {
var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel var operationResult = _orderLogic.TakeOrderInWork(new OrderBindingModel
{ {
Id = id, Id = id
ReinforcedId = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["ReinforcedId"].Value),
ReinforcedName = DataGridView.SelectedRows[0].Cells["ReinforcedName"].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) if (!operationResult)
@ -127,61 +121,19 @@ namespace PrecastConcretePlantView
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); _logger.LogInformation("Заказ №{id}. Меняется статус на 'Выдан'", id);
try try
{ {
var operationResult = _orderLogic.FinishOrder(new OrderBindingModel var operationResult = _orderLogic.FinishOrder(new OrderBindingModel
{ {
Id = id, Id = id
ReinforcedId = Convert.ToInt32(DataGridView.SelectedRows[0].Cells["ReinforcedId"].Value),
ReinforcedName = DataGridView.SelectedRows[0].Cells["ReinforcedName"].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) if (!operationResult)
{ {
throw new Exception("Ошибка при сохранении. Дополнительная информация в логах."); 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<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); _logger.LogInformation("Заказ №{id} выдан", id);
LoadData(); 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) private void UpdateListButton_Click(object sender, EventArgs e)
{ {
LoadData(); LoadData();

View File

@ -12,7 +12,6 @@ namespace PrecastConcretePlantContracts.BindingModels
{ {
public int Id { get; set; } public int Id { get; set; }
public int ReinforcedId { get; set; } public int ReinforcedId { get; set; }
public string ReinforcedName { get; set; } = string.Empty;
public int Count { get; set; } public int Count { get; set; }
public double Sum { get; set; } public double Sum { get; set; }
public OrderStatus Status { get; set; } = OrderStatus.Неизвестен; public OrderStatus Status { get; set; } = OrderStatus.Неизвестен;

View File

@ -11,9 +11,9 @@ namespace PrecastConcretePlantContracts.ViewModels
{ {
public class OrderViewModel : IOrderModel public class OrderViewModel : IOrderModel
{ {
public int ReinforcedId { get; set; }
[DisplayName("Номер")] [DisplayName("Номер")]
public int Id { get; set; } public int Id { get; set; }
public int ReinforcedId { get; set; }
[DisplayName("Изделие")] [DisplayName("Изделие")]
public string ReinforcedName { get; set; } = string.Empty; public string ReinforcedName { get; set; } = string.Empty;
[DisplayName("Количество")] [DisplayName("Количество")]

View File

@ -10,7 +10,6 @@ namespace PrecastConcretePlantDataModels.Models
public interface IOrderModel : IId public interface IOrderModel : IId
{ {
int ReinforcedId { get; } int ReinforcedId { get; }
string ReinforcedName { get; }
int Count { get; } int Count { get; }
double Sum { get; } double Sum { get; }
OrderStatus Status { get; } OrderStatus Status { get; }

View File

@ -13,7 +13,6 @@ namespace PrecastConcretePlantListImplement.Models
public class Order : IOrderModel public class Order : IOrderModel
{ {
public int ReinforcedId { get; private set; } public int ReinforcedId { get; private set; }
public string ReinforcedName { get; private set; }
public int Count { get; private set; } public int Count { get; private set; }
public double Sum { get; private set; } public double Sum { get; private set; }
@ -36,7 +35,6 @@ namespace PrecastConcretePlantListImplement.Models
{ {
Id = model.Id, Id = model.Id,
ReinforcedId = model.ReinforcedId, ReinforcedId = model.ReinforcedId,
ReinforcedName = model.ReinforcedName,
Count = model.Count, Count = model.Count,
Sum = model.Sum, Sum = model.Sum,
Status = model.Status, Status = model.Status,
@ -51,12 +49,7 @@ namespace PrecastConcretePlantListImplement.Models
{ {
return; return;
} }
ReinforcedId = model.ReinforcedId;
ReinforcedName = model.ReinforcedName;
Count = model.Count;
Sum = model.Sum;
Status = model.Status; Status = model.Status;
DateCreate = model.DateCreate;
DateImplement = model.DateImplement; DateImplement = model.DateImplement;
} }
@ -64,7 +57,6 @@ namespace PrecastConcretePlantListImplement.Models
{ {
Id = Id, Id = Id,
ReinforcedId = ReinforcedId, ReinforcedId = ReinforcedId,
ReinforcedName = ReinforcedName,
Count = Count, Count = Count,
Sum = Sum, Sum = Sum,
Status = Status, Status = Status,