protected void OnShipmentKeyComboBoxSelectionChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e) { var index = RadComboShipmentKey.SelectedIndex; if (index < 0) { return; } var selectedModel = ShipmentKeys[index]; if (selectedModel == null) { return; } var selectedItem = RadComboShipmentKey.SelectedItem; if (selectedItem == null) { return; } EnableOrDisableInvoiceInformationControls(true); LoadBillToAndShipTo(); LoadBanks(); LoadShipmentModes(); LoadStatus(); LoadPorts(); var weeklyCapacityId = int.Parse(WeekComboBox.SelectedItem.Value); var obj = new WeeklyProductionCapacityBO { ID = weeklyCapacityId }; obj.GetObject(); int invoiceId; var invoices = DB.Invoice(weeklyCapacityId, selectedModel.ShipToID, selectedModel.ShipmentDate.GetSQLDateString()); if (invoices.Count == 0) { invoiceId = DB.CreateInvoice(weeklyCapacityId, selectedModel.ShipToID, selectedModel.PortID, obj.WeekendDate.Year + obj.WeekendDate.Month.ToString().PadLeft(2, '0') + obj.WeekendDate.Day.ToString().PadLeft(2, '0'), selectedModel.ShipmentDate.GetSQLDateString(), selectedModel.PriceTermID, selectedModel.ShipmentModeID, LoggedUser.ID); } else { invoiceId = invoices[0].ID; } if (invoiceId != 0) { btnCreateInvoice.Visible = true; dvNewContent.Visible = true; CostSheetButton.Visible = true; ItemsPanel.Visible = true; LoadInvoiceItems(invoiceId); } }