コード例 #1
0
        public void UpdateMethodOk()
        {
            // 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.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;
            // modify the test data
            TestItem.Destination    = "Paris";
            TestItem.PricePerPerson = 50;
            // 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 ThisDestination matches the test data
            Assert.AreEqual(AllDestinations.ThisDestination, TestItem);
        }
コード例 #2
0
        void Update()
        {
            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 == "")
            {
                //find the record to update
                DestinationBook.ThisDestination.Find(DestinationID);
                //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.Update();
                Response.Redirect("DestinationPage.aspx");
            }
            else
            {
                //report an error
                lblError.Text = "There were problem with the data enetered " + Error;
            }
        }
コード例 #3
0
    // function for updating destinations
    void Update()
    {
        // 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)
        {
            // find the record to update
            Destinations.ThisDestination.Find(DestinationID);
            // 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);
            // update the record
            Destinations.Update();
        }
        else
        {
            // error
            lblError.Text = "There is a problem with the data entered";
        }
    }
コード例 #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);
        }