Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
    //function for Adding records
    void Add()
    {
        //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
            //Customer.ThisCustomer.Find(Id);
            //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.Add();
            //all done so redirect back to the main page
            // Response.Redirect("AdminHomepage.aspx"); page does not exist
            lblError.Text = "add";
        }
        else
        {
            //report an error
            lblError.Text = "There were problems with the data entered " + Error;
        }
    }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
    //function for adding new records
    void Add()
    {
        //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 == "")
        {
            //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);
            //add the record
            BookingBook.Add();
            //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;
        }
    }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
    void Add()
    {
        // create an instance of the class file
        clsBookingCollection Booking = new clsBookingCollection();

        // get the data
        Booking.ThisBooking.DestinationID   = Convert.ToInt32(txtID.Text);
        Booking.ThisBooking.TotalPrice      = Convert.ToDecimal(txtTotalPrice.Text);
        Booking.ThisBooking.BookingApproved = Convert.ToBoolean(txtBookingApproved.Text);
        Booking.ThisBooking.BookingDate     = Convert.ToDateTime(txtBookingDate.Text);
        Booking.ThisBooking.CustomerNo      = Convert.ToInt32(txtCustomerID.Text);
        Booking.ThisBooking.CarParkID       = Convert.ToInt32(txtCarParkID.Text);
        // add the record
        Booking.Add();
    }
Ejemplo n.º 8
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        //instance of cls booking
        clsBookings ThisBooking = new clsBookings();
        //variable to store error msg
        string ErrorMessage;

        //test data entered
        ErrorMessage = ThisBooking.BookingValid(txtCustomerNo.Text,
                                                txtTourNo.Text,
                                                txtPassengerCount.Text,
                                                txtDateandTime.Text);
        //if no errors
        if (ErrorMessage == "")
        {
            //instance of booking collection class
            clsBookingCollection BookingList = new clsBookingCollection();
            //insert new data
            if (BookingNo == -1)
            {
                //copy data from the interface to the object
                BookingList.ThisBooking.CustomerNo     = Convert.ToInt32(txtCustomerNo.Text);
                BookingList.ThisBooking.TourNo         = Convert.ToInt32(txtTourNo.Text);
                BookingList.ThisBooking.PassengerCount = Convert.ToInt32(txtPassengerCount.Text);
                BookingList.ThisBooking.DateandTime    = Convert.ToDateTime(txtDateandTime);
                //add the new record
                BookingList.Add();
            }
            else//update existing data
            {
                BookingList.ThisBooking.CustomerNo     = Convert.ToInt32(txtCustomerNo.Text);
                BookingList.ThisBooking.TourNo         = Convert.ToInt32(txtTourNo.Text);
                BookingList.ThisBooking.PassengerCount = Convert.ToInt32(txtPassengerCount.Text);
                BookingList.ThisBooking.DateandTime    = Convert.ToDateTime(txtDateandTime);
                //add the new record
                BookingList.Update();
            }
            //Redirect back to the bookings list
            Response.Redirect("StaffBooking.aspx");
        }
        else
        {
            //display error message
            lblError.Text = ErrorMessage;
        }
    }
Ejemplo n.º 9
0
        public void UpdateBookingMethodOK()
        {
            // 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.TotalPrice      = 198;
            TestItem.BookingApproved = false;
            TestItem.DestinationID   = 1;
            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 of the test data
            TestItem.BookingID = PrimaryKey;
            // modify the test data
            TestItem.TotalPrice      = 1500;
            TestItem.BookingApproved = true;
            TestItem.DestinationID   = 12;
            TestItem.BookingDate     = DateTime.Now.Date;
            TestItem.CarParkID       = 154;
            TestItem.CustomerNo      = 5;
            // set the record based on the new test data
            Bookings.ThisBooking = TestItem;
            // update the record
            Bookings.Update();
            // find the record
            Bookings.ThisBooking.Find(PrimaryKey);
            // test to see ThisBooking matches the test data
            Assert.AreEqual(Bookings.ThisBooking, TestItem);
        }
Ejemplo n.º 10
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            string Username = Session["user"].ToString();
            clsBookingCollection Booking = new clsBookingCollection(Username);
            //validation here
            Boolean OK = Booking.ThisBooking.Valid(Station_origin.Text, Station_destination.Text, ddlType.Text, ddlDate.Text, ddlMonth.Text, ddlDeparture.Text);
            //set some vars for the txt elements
            string Station_Origin      = Station_origin.Text;
            string Station_Destination = Station_destination.Text;
            string Type      = ddlType.Text;
            string Date      = ddlDate.Text;
            string Month     = ddlMonth.Text;
            string Departure = ddlDeparture.Text;
            // string Arrival = ddlArrival.Text;
            string UserName = Username;

            //if the data is OK add it to the object
            if (OK == true)
            {
                Booking.ThisBooking.Station_Origin      = Station_Origin;
                Booking.ThisBooking.Station_Destination = Station_Destination;
                Booking.ThisBooking.Type      = Type;
                Booking.ThisBooking.Date      = Date;
                Booking.ThisBooking.Month     = Month;
                Booking.ThisBooking.Departure = Departure;
                //      Booking.ThisBooking.Arrival = Arrival;
                Booking.ThisBooking.Username = UserName;
                Booking.Add();
                //Response.Redirect("Cart.aspx");
                lblError.Text = "Success";
            }
            else
            {
                //report an error
                lblError.Text = "Please try again";
            }
        }
Ejemplo n.º 11
0
        public void UpdateMethodOK()
        {
            //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.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;
            //modify the record
            TestItem.useremail    = "*****@*****.**";
            TestItem.DateBooked   = DateTime.Now.Date;
            TestItem.TimeBooked   = DateTime.Now.Date.ToString();
            TestItem.GuestsBooked = "10";
            TestItem.DiningBooked = "Dinner";
            //set the record based on the new record
            AllBookings.ThisBookings = TestItem;
            //update the record
            AllBookings.Update();
            //find the record
            AllBookings.ThisBookings.Find(PK);
            //test to see that it exists
            Assert.AreEqual(AllBookings.ThisBookings, TestItem);
        }