예제 #1
0
        public void AddMethodOk()
        {
            // create an instance of the class we want to create
            clsDestinationCollection AllDestinations = new clsDestinationCollection();
            // create the item of test data
            clsDestination TestItem = new clsDestination();
            // primary key variable
            Int32 PrimaryKey = 0;

            // set its properties
            TestItem.DestinationID  = 1;
            TestItem.Destination    = "Rome";
            TestItem.PricePerPerson = 99;
            TestItem.DayOfFlight    = DateTime.Now.Date;
            TestItem.ReturnDate     = DateTime.Now.Date.AddDays(1);
            // set ThisDestination to the test data
            AllDestinations.ThisDestination = TestItem;
            // add the record
            PrimaryKey = AllDestinations.Add();
            // set the primary key of the test data
            TestItem.DestinationID = PrimaryKey;
            // find the record
            AllDestinations.ThisDestination.Find(PrimaryKey);
            // test to see that the two values are the same
            Assert.AreEqual(AllDestinations.ThisDestination, TestItem);
        }
예제 #2
0
        public void AddMethodOK()
        {
            //create an instance of the class we want to creat
            clsDestinationCollection AllDestinations = new clsDestinationCollection();
            //create the item of test data
            clsDestination TestItem = new clsDestination();
            //var to store the primary key
            Int32 Primarykey = 0;

            //set its properties
            TestItem.DestinationID    = 1;
            TestItem.EndPointHouseNo  = "1";
            TestItem.EndPointPostCode = "LE2 2WX";
            TestItem.EndPointStreet   = "God Street";
            TestItem.EndPointTown     = "Leicester";
            TestItem.PickupTime       = DateTime.Now.Date;
            TestItem.DropoffTime      = DateTime.Now.Date;
            //set ThisDestination to the test data
            AllDestinations.ThisDestination = TestItem;
            //add the record
            Primarykey = AllDestinations.Add();
            //find the record
            AllDestinations.ThisDestination.Find(Primarykey);
            //test to see that the two valyes are the same
            Assert.AreEqual(AllDestinations.ThisDestination, TestItem);
        }
예제 #3
0
        void Add()
        {
            clsDestinationCollection DestinationBook = new clsDestinationCollection();
            //validate the data on the web form
            String Error = DestinationBook.ThisDestination.Valid(txtHouseNo.Text, txtPostCode.Text, txtStreet.Text, txtTown.Text, txtPickUp.Text);

            //if the datas is OK the add it to the object
            if (Error == "")
            {
                //get the data entered by the user
                DestinationBook.ThisDestination.EndPointHouseNo  = txtHouseNo.Text;
                DestinationBook.ThisDestination.EndPointPostCode = txtPostCode.Text;
                DestinationBook.ThisDestination.EndPointStreet   = txtStreet.Text;
                DestinationBook.ThisDestination.EndPointTown     = txtTown.Text;
                DestinationBook.ThisDestination.PickupTime       = Convert.ToDateTime(txtPickUp.Text);
                DestinationBook.ThisDestination.DropoffTime      = Convert.ToDateTime(txtPickUp.Text);
                //add the record
                DestinationBook.Add();
                Response.Redirect("DestinationPage.aspx");
            }
            else
            {
                //report an error
                lblError.Text = "There is issue with information entered " + Error;
            }
        }
예제 #4
0
        public void UpdateMethodOK()
        {
            //create an instance of the class we want to creat
            clsDestinationCollection AllDestinations = new clsDestinationCollection();
            //create the item of test data
            clsDestination TestItem = new clsDestination();
            //var to store the primary key
            Int32 Primarykey = 0;

            //set its properties
            TestItem.EndPointHouseNo  = "1";
            TestItem.EndPointPostCode = "LE2 2WX";
            TestItem.EndPointStreet   = "God Street";
            TestItem.EndPointTown     = "Leicester";
            TestItem.PickupTime       = DateTime.Now.Date;
            TestItem.DropoffTime      = DateTime.Now.Date;
            //set ThisDestination to the test data
            AllDestinations.ThisDestination = TestItem;
            //add the record
            Primarykey = AllDestinations.Add();
            //set the primary key of the test data
            TestItem.DestinationID = Primarykey;
            //modify the test data
            TestItem.EndPointHouseNo  = "132";
            TestItem.EndPointPostCode = "GH2 2WX";
            TestItem.EndPointStreet   = "God's Son Street";
            TestItem.EndPointTown     = "Ash Town";
            TestItem.PickupTime       = DateTime.Now.Date;
            TestItem.DropoffTime      = DateTime.Now.Date;
            //set the record based on the new test data
            AllDestinations.ThisDestination = TestItem;
            //update the record
            AllDestinations.Update();
            //find the record
            AllDestinations.ThisDestination.Find(Primarykey);
            //test to see ThisDestionation match the test date
            Assert.AreEqual(AllDestinations.ThisDestination, TestItem);
        }
예제 #5
0
    // function for adding new destinations
    void Add()
    {
        // create an instance of the destination collection class
        clsDestinationCollection Destinations = new clsDestinationCollection();
        // validate the data
        Boolean OK = Destinations.ThisDestination.Valid(txtDestinationName.Text, Convert.ToDecimal(txtPrice.Text), txtDayofFlight.Text, txtReturnDate.Text);

        // if the data is OK then add it to the object
        if (OK == true)
        {
            // get the data entered by the user
            Destinations.ThisDestination.Destination    = txtDestinationName.Text;
            Destinations.ThisDestination.PricePerPerson = Convert.ToDecimal(txtPrice.Text);
            Destinations.ThisDestination.DayOfFlight    = Convert.ToDateTime(txtDayofFlight.Text);
            Destinations.ThisDestination.ReturnDate     = Convert.ToDateTime(txtReturnDate.Text);
            // add the record
            Destinations.Add();
        }
        else
        {
            // error
            lblError.Text = "There is a problem with the data entered";
        }
    }