Esempio n. 1
0
    void Update()
    {
        //create an instance of the Roomtype
        clsRoomtypeCollection Roomtype = new clsRoomtypeCollection();
        //validate the data on the web form
        String Error = Roomtype.ThisRoomtype.Valid(txtRoomID.Text, txtRoomFloor.Text, txtRoomType.Text, txtRoomType.Text, txtDateAdded.Text);

        //if the data is OK then add it to the subject
        if (Error == "")
        {
            //find the record to update
            Roomtype.ThisRoomtype.Find(RoomtypeID);
            Roomtype.ThisRoomtype.RoomtypeID   = Convert.ToInt32(txtRoomID.Text);
            Roomtype.ThisRoomtype.RoomFloorNo  = Convert.ToInt32(txtRoomFloor.Text);
            Roomtype.ThisRoomtype.RoomtypeSize = txtRoomSize.Text;
            Roomtype.ThisRoomtype.Roomtype     = txtRoomType.Text;
            Roomtype.ThisRoomtype.DateTime     = Convert.ToDateTime(txtDateAdded.Text);
            //update the record
            Roomtype.Update();
            //all done so redirect back to the main page
            Response.Redirect("Default.aspx");
        }
        else
        {
            //report an error
            lblError.Text = "There were problems with the dat entered" + Error;
        }
    }
Esempio n. 2
0
        public void UpdateMethodOK()
        {
            //Create an isntance of the class we want to create
            clsRoomtypeCollection AllRooms = new clsRoomtypeCollection();
            //create the item of test data
            clsRoomType TestItem = new clsRoomType();
            //var to store the primary key
            Int32 PrimaryKey = 0;

            //set its proeprties
            TestItem.Active       = false;
            TestItem.RoomFloorNo  = 1;
            TestItem.RoomtypeSize = "4 guests";
            TestItem.Roomtype     = "Standard";
            TestItem.DateTime     = DateTime.Now.Date;
            //set ThisRoomtype to the test dat
            AllRooms.ThisRoomtype = TestItem;
            //add the record
            PrimaryKey = AllRooms.Add();
            //set the primary key of the tst data
            TestItem.RoomtypeID = PrimaryKey;
            //modify the test data
            TestItem.Active       = false;
            TestItem.RoomFloorNo  = 1;
            TestItem.RoomtypeSize = "4 guests";
            TestItem.Roomtype     = "Standard";
            TestItem.DateTime     = DateTime.Now.Date;
            //set the record based on the new test data
            AllRooms.ThisRoomtype = TestItem;
            //update the record
            AllRooms.Update();
            //find the record
            AllRooms.ThisRoomtype.Find(PrimaryKey);
            //test to see Thisroomtype matches the test data
            Assert.AreEqual(AllRooms.ThisRoomtype, TestItem);
        }