void Add() { //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 == "") { //get the data entered by the user 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); //add the record Roomtype.Add(); //all done so redirect to the main pahgge Response.Redirect("Default.aspx"); } else { //report Error lblError.Text = "There were problems with the data entered" + Error; } }
public void DeleteMethodOK() { //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.RoomtypeID = 81; 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; //find the record AllRooms.ThisRoomtype.Find(PrimaryKey); //delete the record AllRooms.Delete(); //now find the record Boolean Found = AllRooms.ThisRoomtype.Find(PrimaryKey); //test to see that the record was not found Assert.IsFalse(Found); }
public void AddMethodOK() { //create instance of the class we want to create clsRoomtypeCollection AllRooms = new clsRoomtypeCollection(); //createthe item of the test data clsRoomType TestItem = new clsRoomType(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.Active = true; TestItem.RoomFloorNo = 1; TestItem.RoomtypeSize = "4 guests"; TestItem.Roomtype = "Standard"; TestItem.DateTime = DateTime.Now.Date; //Set ThisRoom to test the data AllRooms.ThisRoomtype = TestItem; //add the record PrimaryKey = AllRooms.Add(); //set the primary key of the test data TestItem.RoomtypeID = PrimaryKey;//find the record //find the record AllRooms.ThisRoomtype.Find(PrimaryKey); //test to see that the two values are the same Assert.AreEqual(AllRooms.ThisRoomtype, TestItem); }
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); }