//function for updating new records void Update() { //create an instance of the booking Book clsBookingCollection BookingBook = new clsBookingCollection(); //validate the data on the web form string Error = BookingBook.ThisBooking.Valid(txtBookingName.Text, txtBookingDate.Text, txtBookingValidity.Text); //if the data is ok then add it to the object if (Error == "") { //find the record to update BookingBook.ThisBooking.Find(BookingID); //get the data entered by the user BookingBook.ThisBooking.BookingName = txtBookingName.Text; BookingBook.ThisBooking.BookingDate = Convert.ToDateTime(txtBookingDate.Text); BookingBook.ThisBooking.BookingValidity = Convert.ToInt32(txtBookingValidity.Text); //update the record BookingBook.Update(); //all done so redirect back to the main page Response.Redirect("BookingList.aspx"); } else { //report an error lblError.Text = "There are problems with the data entered " + Error; } }
public void InstanceOk() {//create an instance of the class clsBookingCollection TheBookings = new clsBookingCollection(); // test the result Assert.IsNotNull(TheBookings); }
void Update() { //create an instance of the booking list clsBookingCollection Bookings = new clsBookingCollection(); //validate the data on the web form //string foreName, string surname, string dateOfBirth, string gender, string contactNumber, string eMail, string flatNo, string houseNo, string postCode String Error = Bookings.ThisBookings.Valid(txtuseremail.Text, txtDateBooked.Text, txtTimeBooked.Text, txtGuestsBooked.Text, txtDiningBooked.Text); //if the data is OK then add it to the object if (Error == "") { //find the record to update Bookings.ThisBookings.Find(bookRef); //get the data entered by the user Bookings.ThisBookings.useremail = Convert.ToString(txtuseremail.Text); Bookings.ThisBookings.DateBooked = Convert.ToDateTime(txtDateBooked.Text); Bookings.ThisBookings.TimeBooked = Convert.ToString(txtTimeBooked.Text); Bookings.ThisBookings.GuestsBooked = Convert.ToString(txtGuestsBooked.Text); Bookings.ThisBookings.DiningBooked = Convert.ToString(txtDiningBooked.Text); //CList.ThisCustomer.UserName = User.Identity.Name; //update the record Bookings.Update(); //all done so redirect back to the main page // Response.Redirect("AdminHomepage.aspx"); lblError.Text = "update"; } else { //report an error lblError.Text = "There were problems with the data entered " + Error; } }
Int32 DisplayBooking(string BookingNameFilter) { //var to store the BookingName string BookingName; //create an instance of the Orderline collection class clsBookingCollection Booking = new clsBookingCollection(); Booking.ReportByBookingName(BookingNameFilter); //var to store the count of records Int32 RecordCount; //var to store the index for the loop Int32 Index = 0; //get the count of records RecordCount = Booking.Count; //clear the list box lstBooking.Items.Clear(); //while there are records while (Index < RecordCount) { //get the BookingName BookingName = Booking.BookingList[Index].BookingName; //create a new entry for the list box ListItem NewEntry = new ListItem(BookingName + " ".ToString()); //add the staff to the list lstBooking.Items.Add(NewEntry); //move the index to the next record Index++; } //return to the count of records found return(RecordCount); }
public void ReportByBookingNameTestDataFound() { //create an instance of the filtered data clsBookingCollection FilteredBooking = new clsBookingCollection(); //var to store outcome Boolean OK = true; //apply a name that does not exist FilteredBooking.ReportByBookingName("Gabriela"); //check that the correct number of records are found if (FilteredBooking.Count == 2) { //Check that the first record is ID 23 if (FilteredBooking.BookingList[0].BookingID != 23) { OK = false; } //Check that the first record is ID 24 if (FilteredBooking.BookingList[1].BookingID != 24) { OK = false; } } else { OK = false; } //test to see that there are no record Assert.IsTrue(OK); }
public void AddBookingMethodOK() { // create an instance of the booking collection class clsBookingCollection Bookings = new clsBookingCollection(); // create item of test data clsBooking TestItem = new clsBooking(); // var to store primary key Int32 PrimaryKey = 0; // set the properties TestItem.BookingID = 3; TestItem.TotalPrice = 200; TestItem.BookingApproved = false; TestItem.DestinationID = 2; TestItem.BookingDate = DateTime.Now.Date; TestItem.CarParkID = 151; TestItem.CustomerNo = 1; // set ThisBooking to the test data Bookings.ThisBooking = TestItem; // add the record PrimaryKey = Bookings.Add(); // set the primary key TestItem.BookingID = PrimaryKey; // find the record Bookings.ThisBooking.Find(PrimaryKey); // test to see that the two values are the same Assert.AreEqual(Bookings.ThisBooking, TestItem); }
public void FilterbyuseremailTestDataFound() { //create an instance of the filtered data clsBookingCollection FilteredBookings = new clsBookingCollection(" "); //var to store outcome Boolean OK = true; //apply a primary key value FilteredBookings.Filterbyemail("*****@*****.**"); //check the correct number of records are found if (FilteredBookings.Count == 20) { //check the first record is ID 2 if (FilteredBookings.BookingsList[0].BookRef != 2000) { OK = true; } // check that the first record is ID if (FilteredBookings.BookingsList[1].BookRef != 2002) { OK = false; } } else { OK = false; } //test to see there are records Assert.IsTrue(OK); }
public void BookingListOk() { //create an instans of the class we wants to create clsBookingCollection AllBookings = new clsBookingCollection(); //create some test data to asig to the propertiy List <clsBooking> TestList = new List <clsBooking>; //add an item to the list //create an item of the test data clsBooking TestItem = new clsBooking(); //set the properties TestItem.BookingID = 1; TestItem.CustomerID = 1; TestItem.HotelID = 1; TestItem.RoomNo = 1; TestItem.BookingDate = DateTime.Now.Date; TestItem.CheckInDate = DateTime.Now.Date.AddDays(2); TestItem.CheckOutDate = DateTime.Now.Date.AddDays(4); TestItem.NumOfNights = 2; //add the item to the test list TestList.Add(TestItem); //asign the data to the property AllBookings.BookingList = TestList; //test to see that the two values are the same Assert.AreEqual(AllBookings.BookingList, TestList); }
public void AddMethodOK() { //instance of collection class clsBookingCollection AllBookings = new clsBookingCollection(); //test data clsBookings TestItem = new clsBookings(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.BookingNo = 1; TestItem.CustomerNo = 1; TestItem.TourNo = 1; TestItem.DateandTime = DateTime.Now.Date; TestItem.PassengerCount = 1; //set thisBooking to the test data AllBookings.ThisBooking = TestItem; //add recprd PrimaryKey = AllBookings.Add; //set the primary key of the test data TestItem.BookingNo = PrimaryKey; //find the record AllBookings.ThisBooking.Find(PrimaryKey); //test to see that th //e two values are the same Assert.AreEqual(AllBookings.ThisBooking, TestItem); }
public void AddMethod() { //create an instance of a class clsBookingCollection AllBooking = new clsBookingCollection(); //create the item of test data clsBooking TestItem = new clsBooking(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.BookingID = 1; TestItem.CustomerID = 2; TestItem.StaffID = 2; TestItem.FlightID = 2; TestItem.BookingName = "Tom"; TestItem.BookingDate = DateTime.Now.Date; TestItem.BookingValidity = 30; //set thisBooking to the test data AllBooking.ThisBooking = TestItem; //add the record PrimaryKey = AllBooking.Add(); //set the primary key of the test data TestItem.BookingID = PrimaryKey; //find the record AllBooking.ThisBooking.Find(PrimaryKey); //test to see that the two values are the same Assert.AreEqual(AllBooking.ThisBooking, TestItem); }
public void ListAndCount() { //create an instance of a class clsBookingCollection AllBooking = new clsBookingCollection(); //create some test data to assign to the property //in this case the data needs to be a list of objects List <clsBooking> TestList = new List <clsBooking>(); //add an item to the list //create the item of test data clsBooking TestItem = new clsBooking(); //set its properties TestItem.BookingID = 1; TestItem.CustomerID = 2; TestItem.StaffID = 2; TestItem.FlightID = 2; TestItem.BookingName = "Tom"; TestItem.BookingDate = DateTime.Now.Date; TestItem.BookingValidity = 30; //add the item to the test list TestList.Add(TestItem); //assign the data to the property AllBooking.BookingList = TestList; //test to see that the two values are the same Assert.AreEqual(AllBooking.Count, TestList.Count); }
public void DeleteMethodOK() { //create an instance of the class we want to create clsBookingCollection AllBookings = new clsBookingCollection("Fbloggs"); //create an instance of test data clsBooking TestItem = new clsBooking(); //var to store primary key Int32 PK = 0; //set the properties //TestItem.CustomerID = 3; TestItem.useremail = "*****@*****.**"; TestItem.DateBooked = DateTime.Now.Date; TestItem.TimeBooked = DateTime.Now.Date.ToString(); TestItem.GuestsBooked = "10"; TestItem.DiningBooked = "Dinner"; //set ThisCustomer to validate test data AllBookings.ThisBookings = TestItem; //add the record PK = AllBookings.Add(); //set primary key of test data TestItem.BookRef = PK; //find the record AllBookings.ThisBookings.Find(PK); //delete the record AllBookings.Delete(); //now find the record Boolean Found = AllBookings.ThisBookings.Find(PK); //test to see that it exists Assert.IsFalse(Found); }
public void DeleteMethod() { //create an instance of a class clsBookingCollection AllBooking = new clsBookingCollection(); //create the item of test data clsBooking TestItem = new clsBooking(); //var to store the primary key Int32 PrimaryKey = 0; //set its properties TestItem.BookingID = 1; TestItem.CustomerID = 2; TestItem.StaffID = 2; TestItem.FlightID = 2; TestItem.BookingName = "Tom"; TestItem.BookingDate = DateTime.Now.Date; TestItem.BookingValidity = 30; //set thisBooking to the test data AllBooking.ThisBooking = TestItem; //add the record PrimaryKey = AllBooking.Add(); //set the primary key of the test data TestItem.BookingID = PrimaryKey; //find the record AllBooking.ThisBooking.Find(PrimaryKey); //delete this record AllBooking.Delete(); //now find the record Boolean Found = AllBooking.ThisBooking.Find(PrimaryKey); //test to see that the record was not found Assert.IsFalse(Found); }
public void InstantOk() { //create an instans of the class we wants to create clsBookingCollection AllBookings = new clsBookingCollection(); //test to see that it exists Assert.IsNotNull(AllBookings); }
private void DisplayRecords() { string Username = Session["user"].ToString(); clsBookingCollection Record = new clsBookingCollection(Username); GVBookings.DataSource = Record.BookingList; GVBookings.DataBind(); }
public void InstanceOK() { // create an instance of the BookingCollection class clsBookingCollection AllBookings = new clsBookingCollection(); // test to see that it exists Assert.IsNotNull(AllBookings); }
public void ReportByBookingNameNoneFound() { //create an instance of the class containing unfiltered results clsBookingCollection FilteredBooking = new clsBookingCollection(); //apply a booking that does not exist FilteredBooking.ReportByBookingName("XXXXX"); //test to see that there are no records Assert.AreEqual(0, FilteredBooking.Count); }
public void FilterbyuseremailNoneFound() { //create an instance of the filtered data clsBookingCollection AllBookings = new clsBookingCollection(" "); //apply a blank string (should return all records) AllBookings.Filterbyemail("xxx xxx"); //test to see the two values are the same Assert.AreEqual(0, AllBookings.Count); }
public void CountPropertyOK() { //instance of collection class clsBookingCollection AllBookings = new clsBookingCollection(); //test data to assign to the property Int32 SomeCount = 2; //assign the data to the property AllBookings.Count = SomeCount; //test to see that the two are the same Assert.AreEqual(AllBookings.Count, SomeCount); }
void DeleteBooking() { //function to delete the selected record //create a new instance of the Booking book clsBookingCollection BookingBook = new clsBookingCollection(); //find the record to delete BookingBook.ThisBooking.Find(BookingID); //delete the record BookingBook.Delete(); }
void DisplayBooking() { //create an instance of the booking Book clsBookingCollection BookingBook = new clsBookingCollection(); //find the record to update BookingBook.ThisBooking.Find(BookingID); //display the data for this record txtBookingName.Text = BookingBook.ThisBooking.BookingName; txtBookingDate.Text = BookingBook.ThisBooking.BookingDate.ToString(); txtBookingValidity.Text = BookingBook.ThisBooking.BookingValidity.ToString(); }
public void ReportByBookingName() { //create an instance of the class containing unfiltered results clsBookingCollection AllBooking = new clsBookingCollection(); //create an instance of the filtered data clsBookingCollection FilteredBooking = new clsBookingCollection(); //apply a blank string (should return all records) FilteredBooking.ReportByBookingName(""); //test to see that the two values are the same Assert.AreEqual(AllBooking.Count, FilteredBooking.Count); }
public void FilterbyuseremailOK() { clsBooking TestItem = new clsBooking(); //create an instance of the class we want to create clsBookingCollection AllBookings = new clsBookingCollection(); //create an instance of the filtered data clsBookingCollection FilteredBookings = new clsBookingCollection(" "); //apply a blank string (should return all records) FilteredBookings.Filterbyemail(""); //test to see the two values are the same Assert.AreEqual(AllBookings.Count, FilteredBookings.Count); }
void Delete() { ////function to delete the selected record //create a new instance of the Customer collection clsBookingCollection BookingList = new clsBookingCollection(User.Identity.Name); //find the record to delete BookingList.ThisBookings.Find(bookRef); //delete the record BookingList.Delete(); }
private void DeleteRecord() { string username = Session["user"].ToString(); //new instance clsBookingCollection Record = new clsBookingCollection(username); //get the number of the booking to be deleted from the session object BookingID = Convert.ToInt32(Session["BookingID"]); //find the record Record.ThisBooking.Find(BookingID); //delete the record Record.Delete(); }
void DisplayBookings() { //create an instancew of the Customer Collection clsBookingCollection Booking = new clsBookingCollection(); // set the data source to the list of countries in the collection lstBooking.DataSource = Booking.BookingsList; // set the name of the primary key lstBooking.DataValueField = "bookRef"; // set the data field to display lstBooking.DataTextField = "AllDetails"; //bind the data to the list lstBooking.DataBind(); }
void DisplayBooking() { //create an instance of the booking list clsBookingCollection Bookings = new clsBookingCollection(); //find the record to update Bookings.ThisBookings.Find(bookRef); //display the data for this record txtuseremail.Text = Bookings.ThisBookings.useremail; txtDateBooked.Text = Bookings.ThisBookings.DateBooked.ToString("dd/MM/yyyy"); txtTimeBooked.Text = Bookings.ThisBookings.TimeBooked; txtGuestsBooked.Text = Bookings.ThisBookings.GuestsBooked; txtDiningBooked.Text = Bookings.ThisBookings.DiningBooked; }
void DisplayBooking() { //create an instance of the booking collection clsBookingCollection Booking = new clsBookingCollection(); //set the data source to the list of bookings in the collection lstBooking.DataSource = Booking.BookingList; //set the name of the primary key lstBooking.DataValueField = "BookingID"; //set the data field to display lstBooking.DataTextField = "BookingName"; //bind the data source to the list lstBooking.DataBind(); }
void Filteremail(string useremail) { //create an instance of the booking collection clsBookingCollection Booking = new clsBookingCollection(); Booking.Filterbyemail(useremail); //set the data source to the list of bookings in the collection lstBooking.DataSource = Booking.BookingsList; //set the name of the primary key lstBooking.DataValueField = "bookRef"; //set the data field to display lstBooking.DataTextField = "useremail"; //bind the data to the list lstBooking.DataBind(); }
void DisplayBooking() { // create an instance of the booking collection clsBookingCollection Booking = new clsBookingCollection(); // find the record to update Booking.ThisBooking.Find(BookingID); // display the data for the record txtDestinationID.Text = Booking.ThisBooking.DestinationID.ToString(); txtTotalPrice.Text = Booking.ThisBooking.TotalPrice.ToString(); txtBookingDate.Text = Booking.ThisBooking.BookingDate.ToString(); txtBookingApproved.Text = Booking.ThisBooking.BookingApproved.ToString(); txtCarParkID.Text = Booking.ThisBooking.CarParkID.ToString(); txtCustomerID.Text = Booking.ThisBooking.CustomerNo.ToString(); }