protected void VehicleDDL_SelectedIndexChanged(object sender, EventArgs e) { usernumber = Convert.ToInt32(Application["UserNumber"]); DBConnection db = new DBConnection(); db.LoadClientVehicles(usernumber); foreach (ClientVehicle cv in ClientVehicleBindingList.ClientVehicleList) { try { if (cv.ClientVehicleNumber == Convert.ToInt32(VehicleDDL.SelectedItem.Value)) { clientVehicleNumber = cv.ClientVehicleNumber; break; } } catch(Exception) { Lbl.Text = "Please select a vehicle"; } } }
protected void Unnamed_Click(object sender, EventArgs e) { //Still need to remove white space and capitalise reg number string manufacturer = autoComplete.Text; string model = ModelDDL.Text; string year = YearDDL.Text; string engineSize = EngineSizeDDL.Text; //Fuel Type string fuelType = FuelTypeDDL.Text; if (fuelType == "Diesel") fuelType = "D"; else if (fuelType == "Petrol") fuelType = "P"; //Model Number string modelNumber = string.Concat(manufacturer, model, year, fuelType, engineSize); //Usernumber is retrieved from the initiating of the form string regNumber = License.Text; //Unregistered Client THEREFORE Usernumber = 1 ClientVehicle newCV = new ClientVehicle(modelNumber, manufacturer, model, Convert.ToInt32(year), Convert.ToChar(fuelType), Convert.ToInt32(engineSize), true, 0, 1, regNumber, "", ""); Label lblMasterStatus = (Label)Master.FindControl("message"); lblMasterStatus.Visible = true; lblMasterStatus.Text = newCV.InsertNewClientVehicle(newCV); DBConnection db = new DBConnection(); db.LoadClientVehicles(1); int clientVehicleNum = 0; foreach (ClientVehicle cv in ClientVehicleBindingList.ClientVehicleList) { if (cv.ModelNumber == modelNumber) { clientVehicleNum = cv.ClientVehicleNumber; } } Application.Contents.Remove("ClientUN"); Application.Contents.Remove("ProjectRequest"); Application.Contents.Remove("ClientVehicleNum"); Application.Contents.Remove("FName"); Application.Contents.Remove("SName"); Application.Contents.Remove("ContactNum"); Application["ClientUN"] = "1"; Application["ProjectRequest"] = "0"; Application["ClientVehicleNum"] = clientVehicleNum; Application["FName"] = txtName.Text; Application["SName"] = txtSurname.Text; Application["ContactNum"] = txtContactNumber.Text; Response.Redirect("./ConfirmDate"); }