void CarRegExists() //funtion to test if the car registration exists. { //create instance of class. clsCarsCollection Cars = new clsCarsCollection(); //get the car registration plate entered by the user. Cars.ThisCar.CarRegistrationPlate = txtReceptionistCarRegistrationPlate.Text; //check the registration. Cars.CarRegistrationExists(); }
void Add() { //function to add a car. //create an instance clsCarsCollection Cars = new clsCarsCollection(); //validate the data on the web form Boolean OK = Cars.ThisCar.Valid(txtReceptionistCarManufacturer.Text, txtReceptionistCarModel.Text, txtReceptionistCarRegistrationPlate.Text, txtReceptionistCarColour.Text, txtReceptionistCarNumberOfDoors.Text, txtReceptionistCarNumberOfSeats.Text, txtReceptionistSupplierID.Text); //if the data is OK then add it to the object. if (OK == true) { //get the data entered by the user. Cars.ThisCar.CarManufacturer = txtReceptionistCarManufacturer.Text; Cars.ThisCar.CarModel = txtReceptionistCarModel.Text; Cars.ThisCar.CarRegistrationPlate = txtReceptionistCarRegistrationPlate.Text; Cars.ThisCar.CarColour = txtReceptionistCarColour.Text; Cars.ThisCar.CarNumberOfDoors = Convert.ToInt32(txtReceptionistCarNumberOfDoors.Text); Cars.ThisCar.CarNumberOfSeats = Convert.ToInt32(txtReceptionistCarNumberOfSeats.Text); Cars.ThisCar.CarNeedsRepair = Convert.ToBoolean(ChkBoxReceptionistNeedsRepair.Checked); Cars.ThisCar.CarSold = Convert.ToBoolean(ChkBoxReceptionistSold.Checked); Cars.ThisCar.SupplierID = Convert.ToInt32(txtReceptionistSupplierID.Text); //test to see if the registration exists. if (Convert.ToInt32(Cars.CarRegistrationExists()) == 0) { lblError.Text = "Car Reg already exists"; } else { //add the record. Cars.Add(); //set lbl to empty lblError.Text = ""; //reload/refresh the page. Response.Redirect("ReceptionistHomepage.aspx"); } } else { //report the error lblError.Text = "There were problems with the data entered"; } }