protected void btnFind_Click(object sender, EventArgs e)
    {
        //create an instance of the trainers class
        clsTrainers ATrainer = new clsTrainers();
        //variable to store the primary key
        Int32 TrainerID;
        //variable to store the result of the find operation
        Boolean Found = false;

        //get the primary key entered by the user
        TrainerID = Convert.ToInt32(txtTrainerID.Text);
        //find the record
        Found = ATrainer.Find(TrainerID);
        //if found
        if (Found == true)
        {
            //display the values of the properties in the form
            txtBrand.Text     = ATrainer.Brand;
            txtName.Text      = ATrainer.Name;
            ddlColour.Text    = ATrainer.Colour;
            txtSize.Text      = ATrainer.Size.ToString();
            txtPrice.Text     = ATrainer.Price.ToString();
            txtDateAdded.Text = ATrainer.DateAdded.ToString();
        }
        else
        {
            lblError.Text = "Trainer not found";
        }
    }
Example #2
0
        public void FoundOK()
        {
            //create an instance of the class clsTrainers
            clsTrainers ATrainer = new clsTrainers();
            //test data to store the result of the search
            Boolean Found = false;
            //create some test data to use with the method
            Int32 TrainerID = 2;

            //invoke the method
            Found = ATrainer.Find(TrainerID);
            Assert.IsTrue(Found);
        }
Example #3
0
        public void TestInStockFound()
        {
            //create an instance of the class clsTrainers
            clsTrainers ATrainer = new clsTrainers();
            //test data to store the result of the search
            Boolean Found = false;
            //boolean variable to record if data is OK
            Boolean OK = true;
            //create some test data to use with the method
            Int32 TrainerID = 2;

            //invoke the method
            Found = ATrainer.Find(TrainerID);
            //check the property
            if (ATrainer.InStock != true)
            {
                OK = false;
            }
            //test to see that the result is correct
            Assert.IsTrue(OK);
        }