private void Window_Loaded(object sender, RoutedEventArgs e) { List <Vehicle> vehlist = VehicleDB.GetVehicles(); foreach (Vehicle v in vehlist) { cboInventoryID.Items.Add(v.InventoryID); } cboInventoryID.SelectedIndex = -1; }
private void btnInsert_Click(object sender, RoutedEventArgs e) { if (IsValidData()) { int inventoryID = Convert.ToInt32(txtInventoryID.Text); string manufacturer = txtManufacturer.Text; string modelname = txtModelName.Text; int year = Convert.ToInt32(txtModelYear.Text); string vehicleid = txtVehicleID.Text; decimal costvalue = Convert.ToDecimal(txtCostValue.Text); Vehicle vehicle = new Vehicle(inventoryID, manufacturer, modelname, year, vehicleid, costvalue); if (VehicleDB.InsertVehicle(vehicle)) { txtMessage.Text = "The above vehicle was added to the database."; } else { txtMessage.Text = "The above vehicle was not added to the database."; } } }