2 лаба лала

This commit is contained in:
a.puchkina 2024-05-21 21:24:17 +04:00
parent 4716a60227
commit 8a96f638b3
2 changed files with 41 additions and 43 deletions

View File

@ -37,12 +37,12 @@
магазиныToolStripMenuItem = new ToolStripMenuItem();
toolStripDropDownButtonOperations = new ToolStripDropDownButton();
поставкаToolStripMenuItem = new ToolStripMenuItem();
продажаToolStripMenuItem = new ToolStripMenuItem();
buttonCreateeOrder = new Button();
buttonTakeOrderInWork = new Button();
buttonOrderReady = new Button();
buttonIssuedOrder = new Button();
buttonRefresh = new Button();
продажаToolStripMenuItem = new ToolStripMenuItem();
((System.ComponentModel.ISupportInitialize)dataGridView).BeginInit();
toolStrip1.SuspendLayout();
SuspendLayout();
@ -113,10 +113,17 @@
// поставкаToolStripMenuItem
//
поставкаToolStripMenuItem.Name = "поставкаToolStripMenuItem";
поставкаToolStripMenuItem.Size = new Size(180, 24);
поставкаToolStripMenuItem.Size = new Size(142, 24);
поставкаToolStripMenuItem.Text = "Поставка";
поставкаToolStripMenuItem.Click += поставкаToolStripMenuItem_Click;
//
// продажаToolStripMenuItem
//
продажаToolStripMenuItem.Name = "продажаToolStripMenuItem";
продажаToolStripMenuItem.Size = new Size(142, 24);
продажаToolStripMenuItem.Text = "Продажа";
продажаToolStripMenuItem.Click += продажаToolStripMenuItem_Click;
//
// buttonCreateeOrder
//
buttonCreateeOrder.Location = new Point(993, 91);
@ -167,13 +174,6 @@
buttonRefresh.UseVisualStyleBackColor = true;
buttonRefresh.Click += buttonRefresh_Click;
//
// продажаToolStripMenuItem
//
продажаToolStripMenuItem.Name = "продажаToolStripMenuItem";
продажаToolStripMenuItem.Size = new Size(180, 24);
продажаToolStripMenuItem.Text = "Продажа";
продажаToolStripMenuItem.Click += продажаToolStripMenuItem_Click;
//
// FormMain
//
AutoScaleDimensions = new SizeF(8F, 20F);

View File

@ -83,51 +83,49 @@ namespace TravelCompanyBusinessLogic.BusinessLogic
public bool ToNextStatus(OrderBindingModel model, OrderStatus orderStatus)
{
CheckModel(model, false);
var element = _orderStorage.GetElement(new OrderSearchModel()
{
Id = model.Id
});
if (element == null)
{
throw new ArgumentNullException(nameof(element));
}
CheckModel(model, false);
var order = _orderStorage.GetElement(new OrderSearchModel { Id = model.Id });
if (order == null)
{
_logger.LogWarning("Change status operation failed. Order not found");
return false;
}
if (order.Status + 1 != orderStatus)
{
_logger.LogWarning("Change status operation failed. Incorrect new status: {orderStatus}. Current status: {currStatus}",
orderStatus, order.Status);
return false;
}
if (orderStatus == OrderStatus.Выдан)
{
var travel = _travelStorage.GetElement(new TravelSearchModel() { Id = element.TravelId });
if (travel == null)
var iceCream = _travelStorage.GetElement(new TravelSearchModel() { Id = order.TravelId });
if (iceCream == null)
{
_logger.LogWarning("Change status operation failed. Travel not found");
return false;
}
if (!DeliverTravels(travel, element.Count))
if (!DeliverTravels(iceCream, order.Count))
{
_logger.LogWarning("Change status operation failed. Travels delivery operation failed");
return false;
}
}
if (model.Status != orderStatus - 1)
{
_logger.LogWarning("Status update to " + orderStatus + " operation failed");
return false;
}
model.Status = orderStatus;
if (model.Status == OrderStatus.Выдан)
{
model.DateImplement = DateTime.Now;
}
if (_orderStorage.Update(model) == null)
{
model.Status--;
_logger.LogWarning("Changing status operation faled");
return false;
}
return true;
}
model.Status = orderStatus;
if (model.Status == OrderStatus.Готов)
{
model.DateImplement = DateTime.Now;
}
else
{
model.DateImplement = order.DateImplement;
}
if (_orderStorage.Update(model) == null)
{
_logger.LogWarning("Change status operation failed");
return false;
}
return true;
}
private bool DeliverTravels(ITravelModel travel, int count)
{