void Add()
    {
        //create an instance
        clsCarRepairsCollection CarRepair = new clsCarRepairsCollection();
        //validate the data on webform
        Boolean OK = CarRepair.ThisCarRepair.Valid(txtMechanicDaysInForRepair.Text, txtMechanicDeadlineDate.Text, txtMechanicPartPrice.Text, txtMechanicPartRequired.Text, txtMechanicCarID.Text, txtMechanicStaffID.Text);

        //if data is okay then add to object
        if (OK == true)
        {
            //Fetch data entered by user
            CarRepair.ThisCarRepair.DaysInForRepair = Convert.ToInt32(txtMechanicDaysInForRepair.Text);
            CarRepair.ThisCarRepair.DeadlineDate    = Convert.ToDateTime(txtMechanicDeadlineDate.Text);
            CarRepair.ThisCarRepair.PartPrice       = Convert.ToDecimal(txtMechanicPartPrice.Text);
            CarRepair.ThisCarRepair.PartRequired    = txtMechanicPartRequired.Text;
            CarRepair.ThisCarRepair.CarID           = Convert.ToInt32(txtMechanicCarID.Text);
            CarRepair.ThisCarRepair.StaffID         = Convert.ToInt32(txtMechanicStaffID.Text);
            //add record
            CarRepair.Add();
            Response.Redirect("MechanicHomepage.aspx");
            lblMechanicError.Text = "Repair successfully added";
        }
        else
        {
            //report error
            lblMechanicError.Text = "There were problems with the data you have entered, please try again";
        }
    }
        public void AddMethodOK()
        {
            //Create an instance of the class
            clsCarRepairsCollection AllCarRepairs = new clsCarRepairsCollection();
            //create the item of test data
            clsCarRepairs TestItem = new clsCarRepairs();
            //Var to store the primary key
            Int32 PrimaryKey = 0;

            //Set its properties
            TestItem.CarRepairID     = 2000;
            TestItem.DaysInForRepair = 27;
            TestItem.DeadlineDate    = DateTime.Now.Date.AddDays(60);
            TestItem.PartPrice       = 52.99m;
            TestItem.PartRequired    = "Add test";

            TestItem.CarID   = 2000;
            TestItem.StaffID = 2000;
            //set this repair to the test data
            AllCarRepairs.ThisCarRepair = TestItem;
            //add the record
            PrimaryKey = AllCarRepairs.Add();
            //set the primary key of the test data
            TestItem.CarRepairID = PrimaryKey;
            //find the record
            AllCarRepairs.ThisCarRepair.Find(PrimaryKey);
            //Test to see if the two values are the same
            Assert.AreEqual(AllCarRepairs.ThisCarRepair, TestItem);
        }
        public void DeleteMethodOK()
        {
            //Create an instance of the class
            clsCarRepairsCollection AllCarRepairs = new clsCarRepairsCollection();
            //create the item of test data
            clsCarRepairs TestItem = new clsCarRepairs();
            //Var to store the primary key
            Int32 PrimaryKey = 0;

            //Set its properties
            TestItem.CarRepairID     = 8;
            TestItem.DaysInForRepair = 1;
            TestItem.DeadlineDate    = DateTime.Now.Date.AddDays(9);
            TestItem.PartPrice       = 200.00m;
            TestItem.PartRequired    = "4 new tyres";
            //set this repair to the test data
            AllCarRepairs.ThisCarRepair = TestItem;
            //add the record
            PrimaryKey = AllCarRepairs.Add();
            //set the primary key of the test data
            TestItem.CarRepairID = PrimaryKey;
            //find the record
            AllCarRepairs.ThisCarRepair.Find(PrimaryKey);
            //Delete the record
            AllCarRepairs.Archive();
            //Now find the record
            Boolean Found = AllCarRepairs.ThisCarRepair.Find(PrimaryKey);

            //Test to see if the two values are the same
            Assert.IsFalse(Found);
        }
        public void UpdateMethodOK()
        {
            //Create an instance of the class
            clsCarRepairsCollection AllCarRepairs = new clsCarRepairsCollection();
            //create the item of test data
            clsCarRepairs TestItem = new clsCarRepairs();
            //Var to store the primary key
            Int32 PrimaryKey = 0;

            //Set its properties
            TestItem.DaysInForRepair = 1;
            TestItem.DeadlineDate    = DateTime.Now.Date.AddDays(9);
            TestItem.PartPrice       = 200.00m;
            TestItem.PartRequired    = "4 new tyres";

            //set this repair to the test data
            AllCarRepairs.ThisCarRepair = TestItem;
            //add the record
            PrimaryKey = AllCarRepairs.Add();
            //set the primary key of the test data
            TestItem.CarRepairID = PrimaryKey;
            //Modify the data
            TestItem.DaysInForRepair = 2;
            TestItem.DeadlineDate    = DateTime.Now.Date.AddDays(12);
            TestItem.PartPrice       = 210.00m;
            TestItem.PartRequired    = "7 new tyres";

            //set this repair to the new test data
            AllCarRepairs.ThisCarRepair = TestItem;
            //Update the record
            AllCarRepairs.Update();
            //find the record
            AllCarRepairs.ThisCarRepair.Find(PrimaryKey);
            //Test to see if the two values are the same
            Assert.AreEqual(AllCarRepairs.ThisCarRepair, TestItem);
        }