//function for adding new records void Add() { //create an instance of the cars clsCarCollection CarBook = new clsCarCollection(); //validate the data on the web form String Error = CarBook.ThisCar.Valid(txtCarName.Text, txtCarModel.Text, txtCarReg.Text, txtColour.Text, txtEngineSize.Text, txtPrice.Text); //if data is ok add to object if (Error == "") { //get the data entrted by user CarBook.ThisCar.RegPlate = txtCarReg.Text; CarBook.ThisCar.CarName = txtCarName.Text; CarBook.ThisCar.CarModel = txtCarModel.Text; CarBook.ThisCar.CarColour = txtColour.Text; CarBook.ThisCar.EngineSize = txtEngineSize.Text; CarBook.ThisCar.Price = Convert.ToInt32(txtPrice.Text); //add the records CarBook.Add(); lblError.Text = "Success"; } else { //report an error lblError.Text = "There were problems with the enterd data" + Error; } }
void Add() { //create an instance of the address book clsCarCollection CarBook = new clsCarCollection(); //validate the data on the web form String Error = CarBook.ThisCar.Valid(ddlCarNo.Text, txtCarMake.Text, txtCarModel.Text, txtAge.Text, txtMileage.Text, txtBodyType.Text); //if the data is OK then add it to the object if (Error == "") { //get the data entered by the user CarBook.ThisCar.CarNo = Convert.ToInt32(ddlCarNo.Text); CarBook.ThisCar.CarMake = txtCarMake.Text; CarBook.ThisCar.CarModel = txtCarModel.Text; CarBook.ThisCar.Age = Convert.ToInt32(txtAge.Text); CarBook.ThisCar.Mileage = Convert.ToInt32(txtMileage.Text); CarBook.ThisCar.Active = chkActive.Checked; //add the record CarBook.Add(); //all done so redirect back to the main page Response.Redirect("Default.aspx"); } else { //report an error lblError.Text = "There were problems with the data entered " + Error; } }
public void DeleteMethodOk() { //create an instance of the class we want to create clsCarCollection AllMainteance = new clsCarCollection(); //create the item of test data clsMaintenance TestItem = new clsMaintenance(); //var to store the primary key int PrimaryKey = 0; //set its properties TestItem.Active = true; TestItem.MaintenanceID = 1; TestItem.Cost = 1; TestItem.Date = DateTime.Now.Date; TestItem.Description = "something"; TestItem.Repair = true; //add the item //set ThisCar to the test data AllMainteance.ThisMaitenance = TestItem; //add the record PrimaryKey = AllMainteance.Add(); //set the primary key of the test data AllMainteance.ThisCar.Find(PrimaryKey); //Delete AllMainteance.Delete(); //now find the record Boolean Found = AllMainteance.ThisMaitenance.Find(PrimaryKey); //test to see that the two values are the same Assert.IsFalse(Found); }
public void AddMethodOk() { //create an instance of the class we want to create clsCarCollection AllCars = new clsCarCollection(); //create the item of test data clsCar TestItem = new clsCar(); //var to store the primary key int PrimaryKey = 0; //set its properties TestItem.CarNo = 1; TestItem.CarMake = "Honda"; TestItem.CarModel = "Civic"; TestItem.Colour = "red"; TestItem.BodyType = "Sedan"; TestItem.Age = 5; TestItem.Active = true; TestItem.Mileage = 100000; //set ThisCar to the test data AllCars.ThisCar = TestItem; //add the record PrimaryKey = AllCars.Add(); //set the primary key of the test data TestItem.CarNo = PrimaryKey; //find the record AllCars.ThisCar.Find(PrimaryKey); //test to see that the two values are the same Assert.AreEqual(AllCars.ThisCar, TestItem); }
public void AddMethodOk() { //create an instance of the class we want to create clsCarCollection AllCars = new clsCarCollection(); //create the item of test data clsCar TestItem = new clsCar(); //var to store the prim key Int32 PrimaryKey = 0; //set its proprties TestItem.RegPlate = "dy20abc"; TestItem.CarName = "Audi"; TestItem.CarModel = "S5"; TestItem.CarColour = "Blue"; TestItem.EngineSize = "2949"; TestItem.Price = 150; //set this cars to the test data AllCars.ThisCar = TestItem; //add record PrimaryKey = AllCars.Add(); //set the prim key of the test data TestItem.CarID = PrimaryKey; //find the record AllCars.ThisCar.Find(PrimaryKey); //test to see that the 2 values are the same Assert.AreEqual(AllCars.ThisCar, TestItem); }
public void DeleteMethodOk() { //create an instance of the class we want to create clsCarCollection AllCars = new clsCarCollection(); //create the item of test data clsCar TestItem = new clsCar(); //var to store the prim key Int32 PrimaryKey = 0; //set its proprties TestItem.RegPlate = "dy20abc"; TestItem.CarName = "Audi"; TestItem.CarModel = "S5"; TestItem.CarColour = "Blue"; TestItem.EngineSize = "2949cc"; TestItem.Price = 150; //set this cars to the test data AllCars.ThisCar = TestItem; //add record PrimaryKey = AllCars.Add(); //set the prim key of the test data TestItem.CarID = PrimaryKey; //find the record AllCars.ThisCar.Find(PrimaryKey); //delte record AllCars.Delete(); //find record Boolean Found = AllCars.ThisCar.Find(PrimaryKey); //test to see recrod not found Assert.IsFalse(Found); }
public void AddMethodOK() { //create an instance of the class we want to create clsCarCollection AllCars = new clsCarCollection(); //create the item of test data clsCar TestItem = new clsCar(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.Fuel = true; TestItem.CarID = 3; TestItem.ColourNo = 4; TestItem.CarName = "Audi"; TestItem.Model = "A6 Sedan C8"; TestItem.BodyType = "SUV"; TestItem.Price = 47739.99m; TestItem.Stock = 3; TestItem.YearMade = DateTime.Now.Date; //set ThisCar to the test data AllCars.ThisCar = TestItem; //add the record PrimaryKey = AllCars.Add(); //set the primary key of the test data TestItem.CarID = PrimaryKey; //find the record AllCars.ThisCar.Find(PrimaryKey); //test to see that the two values are the same Assert.AreEqual(AllCars.ThisCar, TestItem); }
public void UpdateMethodOk() { //create an instance of the class we want to create clsCarCollection AllMainteance = new clsCarCollection(); //create the item of test data clsMaintenance TestItem = new clsMaintenance(); //var to store the primary key int PrimaryKey = 0; //set its properties TestItem.Active = true; TestItem.MaintenanceID = 1; TestItem.Cost = 1; TestItem.Date = DateTime.Now.Date; TestItem.Description = "something"; TestItem.Repair = true; //add the item //set ThisCar to the test data AllMainteance.ThisMaitenance = TestItem; //add record PrimaryKey = AllMainteance.Add(); //set the pirmary key TestItem.MaintenanceID = PrimaryKey; //modify the test data TestItem.Active = true; TestItem.MaintenanceID = 1; TestItem.Cost = 1; TestItem.Date = DateTime.Now.Date; TestItem.Description = "something"; TestItem.Repair = true; //set the reocrd AllMainteance.ThisMaitenance = TestItem; //find the record AllMainteance.Update(); //find the reocrd AllMainteance.ThisMaitenance.Find(PrimaryKey); //test to see thismainatenace the test data Assert.AreEqual(AllMainteance.ThisMaitenance, TestItem); }