From a9eafdd5857972e71339b9bb101865302e437bfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D1=8F=D1=87=D0=B5=D1=81=D0=BB=D0=B0=D0=B2=20=D0=98?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=BE=D0=B2?= Date: Thu, 7 Mar 2024 08:36:19 +0400 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BF=D1=80=D0=BE=D0=B2=D0=B5=D1=80=D0=BA?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FormCreateTransportation.cs | 13 +++++++++++++ .../TransportCompanyView/FormMain.Designer.cs | 6 +++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/TransportCompany/TransportCompanyView/FormCreateTransportation.cs b/TransportCompany/TransportCompanyView/FormCreateTransportation.cs index 62efe2a..1847a4f 100644 --- a/TransportCompany/TransportCompanyView/FormCreateTransportation.cs +++ b/TransportCompany/TransportCompanyView/FormCreateTransportation.cs @@ -124,6 +124,19 @@ namespace TransportCompanyView _logger.LogInformation("Создание транспортировки"); try { + var selectedCargo = _cargoList?.FirstOrDefault(c => c.Id == Convert.ToInt32(comboBoxCargo.SelectedValue)); + var selectedTransport = _transportList?.FirstOrDefault(t => t.Id == Convert.ToInt32(comboBoxTransport.SelectedValue)); + + var cargoWeight = selectedCargo?.Weight ?? 0; + var totalCount = Convert.ToInt32(textBoxCount.Text); + var totalWeight = cargoWeight * totalCount; + + if (totalWeight > selectedTransport?.LoadCapacity) + { + MessageBox.Show("Вес груза превышает вместимость выбранной машины", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error); + return; + } + var operationResult = _logicTt.CreateTransportation(new TransportationBindingModel { DriverId = Convert.ToInt32(comboBoxDriver.SelectedValue), diff --git a/TransportCompany/TransportCompanyView/FormMain.Designer.cs b/TransportCompany/TransportCompanyView/FormMain.Designer.cs index 84890f3..fab20c3 100644 --- a/TransportCompany/TransportCompanyView/FormMain.Designer.cs +++ b/TransportCompany/TransportCompanyView/FormMain.Designer.cs @@ -100,7 +100,7 @@ dataGridView.ReadOnly = true; dataGridView.RowHeadersWidth = 51; dataGridView.RowTemplate.Height = 29; - dataGridView.Size = new Size(1305, 381); + dataGridView.Size = new Size(1305, 628); dataGridView.TabIndex = 1; // // buttonCreateOrder @@ -109,7 +109,7 @@ buttonCreateOrder.Name = "buttonCreateOrder"; buttonCreateOrder.Size = new Size(247, 29); buttonCreateOrder.TabIndex = 2; - buttonCreateOrder.Text = "Создать транспортировку"; + buttonCreateOrder.Text = "Создать накладную"; buttonCreateOrder.UseVisualStyleBackColor = true; buttonCreateOrder.Click += ButtonFormCreateTransportation_Click; // @@ -157,7 +157,7 @@ // AutoScaleDimensions = new SizeF(8F, 20F); AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(1594, 425); + ClientSize = new Size(1594, 671); Controls.Add(buttonRef); Controls.Add(buttonIssuedOrder); Controls.Add(buttonOrderReady);