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