//function for adding new records
        void Add()
        {
            //create an instance of the booking list
            clsBookingsCollection BookingsList = new clsBookingsCollection();
            //validate the data on the web form
            String Error = BookingsList.ThisBookings.Valid(txtAmount.Text, txtDateBo.Text, txtPayType.Text);

            //if the data is OK then add it to the object
            if (Error == "")
            {
                //get the data entered by the user
                BookingsList.ThisBookings.Ammount     = Convert.ToDecimal(txtAmount.Text);
                BookingsList.ThisBookings.DateBooked  = Convert.ToDateTime(txtDateBo.Text);
                BookingsList.ThisBookings.PaymentType = txtPayType.Text;
                //add the record
                BookingsList.Add();
                //all done so redirect back to the main page
                lblError.Text = "Sucessfully Booked";
            }
            else
            {
                //report an error
                lblError.Text = "There were problems with the data entered " + Error;
            }
        }
Exemple #2
0
        public void FilterbyDateBookedTestDataFoundMax()
        {
            //create an instance of the filtered data
            clsBookingsCollection FilteredBookings = new clsBookingsCollection(" ");
            //var to store outcome
            Boolean OK = true;

            //apply a filter string (should return some records)
            FilteredBookings.FilterbyDateBooked("03/12/2017", "23/02/2018");
            //check the correct number of records are found
            if (FilteredBookings.Count == 7)
            {
                //check the first record is ID 25
                if (FilteredBookings.BookingsList[0].BookRef != 25)
                {
                    OK = false;
                }
                //check that the first record is ID 31
                if (FilteredBookings.BookingsList[6].BookRef != 31)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }

            //test to see there are records
            Assert.IsTrue(OK);
        }
Exemple #3
0
        public void FilterbyReferenceTestDataFound()
        {
            //create an instance of the filtered data
            clsBookingsCollection FilteredBookings = new clsBookingsCollection();
            //var to store outcome
            Boolean OK = true;

            //apply a primary key value
            FilteredBookings.FilterbyBookRef("2");
            //check the correct number of records are found
            if (FilteredBookings.Count == 1)
            {
                //check the first record is ID 2
                if (FilteredBookings.BookingsList[0].BookRef != 2)
                {
                    OK = false;
                }
            }
            else
            {
                OK = false;
            }

            //test to see there are records
            Assert.IsTrue(OK);
        }
Exemple #4
0
        public void DeleteMethodOK()
        {
            //create an instance of the class we want to create
            clsBookingsCollection AllBookings = new clsBookingsCollection();
            //create an instance of test data
            clsBookings TestItem = new clsBookings();
            //var to store primary key
            Int32 PK = 0;

            //set the properties
            //TestItem.BookRef = 3;
            TestItem.Ammount     = Convert.ToInt32(9756.24);
            TestItem.DateBooked  = DateTime.Now.Date;
            TestItem.PaymentType = "Debit";
            TestItem.CustID      = '2';
            //set ThisBooking 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);
        }
Exemple #5
0
        public void AddMethodOK()
        {
            //create an instance of the class we want to create
            clsBookingsCollection AllBookings = new clsBookingsCollection();
            //create an instance of test data
            clsBookings TestItem = new clsBookings();
            //var to store primary key
            Int32 PK = 0;

            //set the properties
            //TestItem.BookRef = 3;
            TestItem.Ammount     = Convert.ToInt32(8000.50);
            TestItem.DateBooked  = DateTime.Now.Date;
            TestItem.PaymentType = "Debit";
            TestItem.CustID      = 1;
            //set ThisBooking 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);
            //test to see that it exists
            Assert.AreEqual(AllBookings.ThisBookings, TestItem);
        }
Exemple #6
0
    //function for updating records
    void Update()
    {
        //create an instance of the booking list
        clsBookingsCollection BookingsList = new clsBookingsCollection();
        //validate the data on the web form
        String Error = BookingsList.ThisBookings.Valid(txtAmmount.Text, txtDateBooked.Text, txtPaymentType.Text);

        //if the data is OK then add it to the object
        if (Error == "")
        {
            //find the record to update
            BookingsList.ThisBookings.Find(BookRef);
            //get the data entered by the user
            BookingsList.ThisBookings.Ammount     = Convert.ToDecimal(txtAmmount.Text);
            BookingsList.ThisBookings.DateBooked  = Convert.ToDateTime(txtDateBooked.Text);
            BookingsList.ThisBookings.PaymentType = txtPaymentType.Text;
            BookingsList.ThisBookings.CustID      = Convert.ToInt32(lstCust.SelectedValue);
            //update the record
            BookingsList.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 data entered " + Error;
        }
    }
        public void UpdateMethodOK()
        {
            //create an instance of the class we want to create
            clsBookingsCollection AllBookings = new clsBookingsCollection();
            //create an instance of test data
            clsBookings TestItem = new clsBookings();
            //var to store primary key
            Int32 PK = 0;

            //set the properties
            //TestItem.BookRef = 3;
            TestItem.Ammount     = 80;
            TestItem.DateBooked  = DateTime.Now.Date;
            TestItem.PaymentType = "Debit";
            //set ThisBooking 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.BookRef = 3;
            TestItem.Ammount     = 40;
            TestItem.DateBooked  = DateTime.Now.Date;
            TestItem.PaymentType = "Credit";
            //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);
        }
Exemple #8
0
        public void InstanceOK()
        {
            //create an instance of the class we want to create
            clsBookingsCollection AllBookings = new clsBookingsCollection();

            //test to see that it exists
            Assert.IsNotNull(AllBookings);
        }
Exemple #9
0
        public void FilterbyReferenceNotFound()
        {
            //create an instance of the filtered data
            clsBookingsCollection FilteredBookings = new clsBookingsCollection();

            //apply a blank string (should return no records)
            FilteredBookings.FilterbyBookRef("1000000");
            //test to see the two values are the same
            Assert.AreEqual(0, FilteredBookings.Count);
        }
Exemple #10
0
        public void FilterbyDateBookedNotFound()
        {
            //create an instance of the filtered data
            clsBookingsCollection FilteredBookings = new clsBookingsCollection(" ");

            //apply a filter (should return no records)
            FilteredBookings.FilterbyDateBooked(DateTime.Now.Date.ToString(), DateTime.Now.Date.AddYears(-50).ToString());
            //test to see the two values are the same
            Assert.AreEqual(0, FilteredBookings.Count);
        }
Exemple #11
0
    void DisplayBookings()
    {
        //create an instance of the booking list
        clsBookingsCollection BookingsList = new clsBookingsCollection();

        //find the record to update
        BookingsList.ThisBookings.Find(BookRef);
        //display the data for this record
        txtAmmount.Text     = BookingsList.ThisBookings.Ammount.ToString();
        txtDateBooked.Text  = BookingsList.ThisBookings.DateBooked.ToString();
        txtPaymentType.Text = BookingsList.ThisBookings.PaymentType;
    }
Exemple #12
0
        Int32 DeleteBooking()
        {
            //function to delete the selected record
            //create a new instance of the bookings collection
            clsBookingsCollection Bookings = new clsBookingsCollection();

            //find the record to delete
            Bookings.ThisBookings.Find(BookRef);
            //delete the record
            Bookings.Delete();
            return(BookRef);
        }
Exemple #13
0
        public void FilterbyDateOK()
        {
            clsBookings TestItem = new clsBookings();
            //create an instance of the class we want to create
            clsBookingsCollection AllBookings = new clsBookingsCollection();
            //create an instance of the filtered data
            clsBookingsCollection FilteredBookings = new clsBookingsCollection(" ");

            //apply a blank string (should return all records)
            FilteredBookings.FilterbyDateBooked(DateTime.Now.Date.AddYears(-50).ToString(), DateTime.Now.Date.ToString());
            //test to see the two values are the same
            Assert.AreEqual(AllBookings.Count, FilteredBookings.Count);
        }
Exemple #14
0
        public void FilterbySurnameNotFound()
        {
            clsBookings TestItem = new clsBookings();
            //create an instance of the class we want to create
            clsBookingsCollection AllBookings = new clsBookingsCollection();
            //create an instance of the filtered data
            clsBookingsCollection FilteredBookings = new clsBookingsCollection();

            //apply a blank string (should return all records)
            FilteredBookings.FilterSurname("!");
            //test to see the two values are the same
            Assert.AreEqual(0, FilteredBookings.Count);
        }
        Int32 DisplayBookings()
        {
            //create an instance of the booking collection
            clsBookingsCollection Bookings = new clsBookingsCollection();

            //set the data source to the list of bookings in the collection
            lstBookings.DataSource = Bookings.BookingsList;
            //set the name of the primary key
            lstBookings.ValueMember = "BookRef";
            //set the data field to display
            lstBookings.DisplayMember = "AllDetails";
            //return the count of records in the list
            return(Bookings.Count);
        }
        void DisplayBookings()
        {
            //create an instance of the booking list
            clsBookingsCollection BookingsList = new clsBookingsCollection();

            //find the record to update
            BookingsList.ThisBookings.Find(BookingRef);
            //display the data for this record
            txtBookRef.Text       = BookingsList.ThisBookings.BookRef.ToString();
            txtAmount.Text        = BookingsList.ThisBookings.Ammount.ToString();
            txtDateBo.Text        = BookingsList.ThisBookings.DateBooked.ToString("dd/MM/yyyy");
            txtPayType.Text       = BookingsList.ThisBookings.PaymentType;
            lstCust.SelectedValue = BookingsList.ThisBookings.CustID;
        }
    void DisplayBookings()
    {
        //create an instance of the booking collection
        clsBookingsCollection Bookings = new clsBookingsCollection();

        //set the data source to the list of bookings in the collection
        lstBookings.DataSource = Bookings.BookingsList;
        //set the name of the primary key
        lstBookings.DataValueField = "BookRef";
        //set the data field to display
        lstBookings.DataTextField = "AllDetails";
        //bind the data to the list
        lstBookings.DataBind();
    }
    void FilterBookingsDateRange(string StartDate, string EndDate)
    {
        //create an instance of the booking collection
        clsBookingsCollection Bookings = new clsBookingsCollection(User.Identity.Name);

        Bookings.FilterbyDateBooked(StartDate, EndDate);
        //set the data source to the list of bookings in the collection
        lstBookings.DataSource = Bookings.BookingsList;
        //set the name of the primary key
        lstBookings.DataValueField = "BookRef";
        //set the data field to display
        lstBookings.DataTextField = "AllDetails";
        //bind the data to the list
        lstBookings.DataBind();
    }
        Int32 FilterSurnane(string Surnane)
        {
            //create an instance of the booking collection
            clsBookingsCollection Bookings = new clsBookingsCollection();

            Bookings.FilterSurname(Surnane);
            //set the data source to the list of bookings in the collection
            lstBookings.DataSource = Bookings.BookingsList;
            //set the name of the primary key
            lstBookings.ValueMember = "BookRef";
            //set the data field to display
            lstBookings.DisplayMember = "AllCDetails";
            //bind the data to the list
            return(Bookings.Count);
        }
        Int32 FilterBookingsDateRange(string StartDate, string EndDate)
        {
            //create an instance of the booking collection
            clsBookingsCollection Bookings = new clsBookingsCollection(" ");

            Bookings.FilterbyDateBooked(StartDate, EndDate);
            //set the data source to the list of bookings in the collection
            lstBookings.DataSource = Bookings.BookingsList;
            //set the name of the primary key
            lstBookings.ValueMember = "BookRef";
            //set the data field to display
            lstBookings.DisplayMember = "AllDetails";
            //bind the data to the list
            return(Bookings.Count);
        }
    void FilterBookingsRef(string BookRef)
    {
        //create an instance of the booking collection
        clsBookingsCollection Bookings = new clsBookingsCollection();

        Bookings.FilterbyBookRef(BookRef);
        //set the data source to the list of bookings in the collection
        lstBookings.DataSource = Bookings.BookingsList;
        //set the name of the primary key
        lstBookings.DataValueField = "BookRef";
        //set the data field to display
        lstBookings.DataTextField = "BookRef";
        //bind the data to the list
        lstBookings.DataBind();
    }
Exemple #22
0
        public void ThisBookingPropertyOK()
        {
            //create an instance of the class we want to create
            clsBookingsCollection AllBookings = new clsBookingsCollection();
            //create some test data to assign to the property
            //add an item to the list
            clsBookings TestBooking = new clsBookings();

            //set its properties
            TestBooking.BookRef     = 1;
            TestBooking.Ammount     = 50;
            TestBooking.DateBooked  = DateTime.Now.Date;
            TestBooking.PaymentType = "Credit";
            //assign the data to the property
            AllBookings.ThisBookings = TestBooking;//test to see that it exists
            Assert.AreEqual(AllBookings.ThisBookings, TestBooking);
        }
        private void btnDFilter_Click(object sender, EventArgs e)
        {
            //create an instance of the booking list
            clsBookingsCollection BookingsList = new clsBookingsCollection(" ");
            //validate the data on the web form
            String Error = BookingsList.ThisBookings.ValidDateFilter(txtStartDate.Text, txtEndDate.Text);

            //if the data is OK then add it to the object
            if (Error == "")
            {
                //display the number of record found after filtering has been applied
                lblError.Text = FilterBookingsDateRange(txtStartDate.Text, txtEndDate.Text) + " Found";
            }
            else
            {
                //report an error
                lblError.Text = "There were problems with the data entered " + Error;
            }
        }
Exemple #24
0
        public void CountBookingsList()
        {
            //create an instance of the class we want to create
            clsBookingsCollection AllBookings = new clsBookingsCollection();
            //create some test data to assign to the property
            //in this sceanario it needs to be a lists of objects
            List <clsBookings> TestList = new List <clsBookings>();
            //add an item to the list
            //create the item of test data
            clsBookings TestItem = new clsBookings();

            //set its properties
            TestItem.BookRef     = 1;
            TestItem.Ammount     = 50;
            TestItem.DateBooked  = DateTime.Now.Date;
            TestItem.PaymentType = "Credit";
            //add the item to the test list
            TestList.Add(TestItem);
            //assign the data to the property
            AllBookings.BookingsList = TestList;//test to see that it exists
            Assert.AreEqual(AllBookings.Count, TestList.Count);
        }
    protected void btnFDate_Click(object sender, EventArgs e)
    {
        //create an instance of the booking list
        clsBookingsCollection BookingsList = new clsBookingsCollection(User.Identity.Name);
        //validate the data on the web form
        String Error = BookingsList.ThisBookings.ValidDateFilter(txtStartDate.Text, txtEndDate.Text);

        //if the data is OK then add it to the object
        if (Error == "")
        {
            //display the number of record found after filtering has been applied
            FilterBookingsDateRange(txtStartDate.Text, txtEndDate.Text);
            //clear the label
            lblError.Text = "";
        }
        else
        {
            //report an error
            lblError.Text = "There were problems with the data entered " + Error;
            //display all bookings
            //DisplayBookings();
        }
    }