Beispiel #1
0
        private void GetID()
        {
            //Call the getBookingID method from the Bookings class and save the ID as the variable newBookingsID.
            int newBookingID = Bookings.getBookingID();

            //Convert the BookingID to a string and display the new ID in lblDisplayBookingID along with the letters "BKG" before it.
            lblDisplayBookingID.Text = "BKG" + Convert.ToString(newBookingID);
        }
Beispiel #2
0
        private void SearchClass()
        {
            //Call the getClassName method from the Class class and pass the text in txtClassID.
            List <string> names = Bookings.getClassName(cbClassID.Text);
            {
                //If the amount of names is greater than 0...
                if (names.Count > 0)
                {
                    //Create a new instance of the stringbuilder class.
                    StringBuilder sb = new StringBuilder();

                    foreach (string name in names)
                    {
                        sb.AppendLine(name);
                        //Display the class name in lblDisplayName.
                        lblDisplayName.Text = name;
                    }
                }
            }

            //Call the getClassDay method from the Class class and pass the text in txtClassID
            List <string> days = Bookings.getClassDay(cbClassID.Text);
            {
                //If the amount of days is greater than 0...
                if (days.Count > 0)
                {
                    //Create a new instance of the stringbuilder class.
                    StringBuilder _stringB = new StringBuilder();

                    foreach (string day in days)
                    {
                        _stringB.AppendLine(day);
                        //Display the day in lblDisplayDay.
                        lblDisplayDay.Text = day;
                    }
                }
            }

            //Call the getClassTime method from the Class class and pass the text in txtClassID
            List <string> times = Class.getClassTime(cbClassID.Text);
            {
                //If the amount of times is greater than 0...
                if (times.Count > 0)
                {
                    //Create a new instance of the stringbuilder class.
                    StringBuilder _stringBuilder = new StringBuilder();

                    foreach (string time in times)
                    {
                        _stringBuilder.AppendLine(time);
                        //Display the time in lblDisplayTime.
                        lblDisplayTime.Text = time;
                    }
                }
            }
        }
Beispiel #3
0
        private void cbClassID_SelectedIndexChanged(object sender, EventArgs e)
        {
            //Call the getClassName method from the Bookings Class and pass across the data.
            List <string> classNames = Bookings.getClassName(cbClassID.Text);
            {
                //If the amount of names is greater than 0...
                if (classNames.Count > 0)
                {
                    //Create an instance of the stringbuilder class.
                    StringBuilder string_b = new StringBuilder();
                    foreach (string name in classNames)
                    {
                        string_b.AppendLine(name);
                        //Display the name in lblDisplayClassName.
                        lblDisplayClassName.Text = name;
                    }
                }
            }

            //Call the getClassDay method from the Bookings Class and pass across the data.
            List <string> classDays = Bookings.getClassDay(cbClassID.Text);
            {
                //If the amount of days is greater than 0...
                if (classDays.Count > 0)
                {
                    //Create an instance of the stringbuilder class.
                    StringBuilder string_build = new StringBuilder();
                    foreach (string day in classDays)
                    {
                        string_build.AppendLine(day);
                        //Display the day in lblDisplayDay.
                        lblDisplayDay.Text = day;
                    }
                }
            }

            //Call the getClassTime method from the Bookings Class and pass across the data.
            List <string> classTimes = Bookings.getClassTime(cbClassID.Text);
            {
                //If the amount of times is greater than 0...
                if (classTimes.Count > 0)
                {
                    //Create an instance of the stringbuilder class.
                    StringBuilder s_builder = new StringBuilder();
                    foreach (string time in classTimes)
                    {
                        s_builder.AppendLine(time);
                        //Display the time in lblDisplayTime.
                        lblDisplayTime.Text = time;
                    }
                }
            }
        }
Beispiel #4
0
 public void ClassIDs()
 {
     //Call the getClassIDs method from the BookingsClass and save into a list.
     List <string> IDs = Bookings.getClassIDs();
     {
         foreach (string id in IDs)
         {
             //Add each ID into cbClassID.
             cbClassID.Items.Add(id);
         }
     }
 }
Beispiel #5
0
 public void ClassIDs()
 {
     //Call the getClassID method from the Bookings form and save it in a list.
     List <string> ids = Bookings.getClassID();
     {
         foreach (string id in ids)
         {
             //Add each ID to the combobox.
             cbClassID.Items.Add(id);
         }
     }
 }
Beispiel #6
0
        private void changeDataGridView()
        {
            //If the date picked is greater than one month in advance...
            if (dateTimePickerClass.Value >= DateTime.Now.AddMonths(1))
            {
                //Display the message below.
                MessageBox.Show("You cannot book more than a month in advance.");
                //Reset the date to the current date.
                dateTimePickerClass.Value = DateTime.Now;
                //Call the Reset method.
                Reset();
            }
            else
            {
                //Call the CheckMember method from the Bookings class and pass across the data.
                List <int> members = Bookings.CheckMember(cbClassID.Text, dateTimePickerClass.Value);
                //Convert the list to a Data Table.
                DataTable memberData = ConvertListToDataTable(members);

                dataGridViewBooking.DataSource            = memberData;
                dataGridViewBooking.Columns[0].HeaderText = "Member ID";
                //Count the amount of spaces left in the class.
                int count      = dataGridViewBooking.RowCount - 1;
                int amountLeft = 15 - count;
                //If there are spaces left in the class...
                if (amountLeft > 0)
                {
                    //Display the number of spaces along with a message.
                    lblDisplayNumber.Text = "Number of spaces left: " + Convert.ToString(amountLeft);
                }
                //Otherwise...
                else
                {
                    //Display the message below.
                    lblDisplayNumber.Text = "There are no spaces left in this class.";
                    //Call the Blink method.
                    Blink();
                    //The save button will disappear.
                    btnSave.Visible = false;
                }
            }
        }
Beispiel #7
0
        private void DeleteBooking()
        {
            //Try to...
            try
            {
                //Call the DeleteBooking method from the Bookings Class and pass across the data.
                int rowsAffected = Bookings.DeleteBooking(txtBookingID.Text);

                if (rowsAffected > 0)
                {
                    //If the Booking has been deleted successfully, displaythe message below.
                    MessageBox.Show("Booking deleted successfully.");
                    //Call the reset method.
                    Reset();
                }
            }
            //Catch any exception which may occur and display an error message.
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #8
0
        private void EditBooking()
        {
            //Try to...
            try
            {
                //Call the EditBooking method from the Bookings Class and pass across the data.
                int rowsAffected = Bookings.EditBooking(Convert.ToInt32(txtBookingID.Text), cbClassID.Text);

                if (rowsAffected > 0)
                {
                    //If the Booking has been edited successfully display the message below.
                    MessageBox.Show("Booking edited successfully.");
                    //Call the Reset button.
                    Reset();
                }
            }
            //Catch any exception which may occur and display an error message.
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #9
0
        //When a cell in the data grid view is clicked on, this method finds the forenames and surnames of all the members who are booked for that class
        //and returns the as a list. Then, when a cell is clicked on, the MemberForename and MemberSurname appear in a Message Box.
        private void dataGridViewBooking_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.RowIndex == -1)
            {
                return;
            }
            if (dataGridViewBooking.CurrentCell.ColumnIndex.Equals(0))
            {
                if (dataGridViewBooking.CurrentCell != null && dataGridViewBooking.CurrentCell.Value != null)
                {
                    int           cell      = Convert.ToInt32(dataGridViewBooking.CurrentCell.Value);
                    List <string> mSurnames = Bookings.getMemberSurname(Convert.ToString(cell));
                    if (mSurnames.Count > 0)
                    {
                        StringBuilder sb = new StringBuilder();
                        foreach (string surname in mSurnames)
                        {
                            sb.AppendLine(Convert.ToString(mSurnames));
                        }
                        ;

                        List <string> mForenames = Bookings.getMemberForename(Convert.ToString(cell));
                        {
                            if (mForenames.Count > 0)
                            {
                                StringBuilder sb1 = new StringBuilder();
                                foreach (string fornames in mForenames)
                                {
                                    sb.AppendLine(Convert.ToString(mForenames));
                                }
                                string membername = mForenames[0] + " " + mSurnames[0];
                                MessageBox.Show(membername);
                            }
                        }
                    }
                }
            }
        }
Beispiel #10
0
        private void Search()
        {
            //If txtBookingID is not empty.
            if (txtBookingID.Text != "")
            {
                //This method will check if the BookingID is valid.
                using (SqlConnection connection = new SqlConnection(_connectionString))
                {
                    using (SqlCommand sqlCommand = new SqlCommand("SELECT COUNT(*) FROM Booking WHERE (BookingID = @BookingID)", connection))
                    {
                        connection.Open();
                        sqlCommand.Parameters.AddWithValue("@BookingID", txtBookingID.Text);
                        int  booking      = (int)sqlCommand.ExecuteScalar();
                        bool bookingExist = false;
                        if (booking > 0)
                        {
                            bookingExist = true;
                            //If bookingExist is true.
                            if (bookingExist)
                            {
                                //Call the getBookingDate method from the Bookings Class and pass across the data.
                                List <DateTime> bDates = Bookings.getBookingDate(txtBookingID.Text);
                                {
                                    //If the amount of bookingsDates is greater than 0...
                                    if (bDates.Count > 0)
                                    {
                                        //Create an instance of the stringbuilder class.
                                        StringBuilder string_Builder = new StringBuilder();

                                        foreach (DateTime date in bDates)
                                        {
                                            string_Builder.AppendLine(Convert.ToString(date));
                                            //Display and convert the BookingDate in lblDisplayBookingDate.
                                            lblDisplayBookingDate.Text = Convert.ToString(date.ToString("yyyy-MM-dd"));
                                        }
                                    }
                                }

                                //Call the getMemberID method from the Bookings Class and pass across the data.
                                List <int> ids = Bookings.getMemberID(txtBookingID.Text);
                                {
                                    //If the amount of IDs is greater than 0...
                                    if (ids.Count > 0)
                                    {
                                        //Create an instance of the stringbuilder class.
                                        StringBuilder _sb = new StringBuilder();
                                        foreach (int id in ids)
                                        {
                                            _sb.AppendLine(Convert.ToString(id));
                                            //Display the ID in lblMemberID.
                                            txtMemberID.Text = Convert.ToString(id);
                                        }
                                    }
                                }

                                //Call the getMemberForename method from the Bookings Class and pass across the data.
                                List <string> fnames = Bookings.getMemberForename(txtMemberID.Text);
                                {
                                    //If the amount of names is greater than 0...
                                    if (fnames.Count > 0)
                                    {
                                        //Create an instance of the stringbuilder class.
                                        StringBuilder stringBuilder = new StringBuilder();
                                        foreach (string fname in fnames)
                                        {
                                            stringBuilder.AppendLine(fname);
                                            //Display the name in lblDisplayName.
                                            lblDisplayName.Text = fname;
                                            //Save the name into the variable _fname.
                                            _fname = lblDisplayName.Text;
                                        }
                                    }
                                }

                                //Call the getBookingSurname method from the Bookings Class and pass across the data.
                                List <string> snames = Bookings.getMemberSurname(txtMemberID.Text);
                                {
                                    //If the amount of names is greater than 0...
                                    if (snames.Count > 0)
                                    {
                                        //Create an instance of the stringbuilder class.
                                        StringBuilder string_Builder = new StringBuilder();
                                        foreach (string sname in snames)
                                        {
                                            string_Builder.AppendLine(sname);
                                            //Display the forname and surname in lblDisplayName.
                                            lblDisplayName.Text = _fname + " " + sname;
                                        }
                                    }
                                }

                                //Call the getMemberPostCode method from the Bookings Class and pass across the data.
                                List <string> postCodes = Bookings.getMemberPostCode(txtMemberID.Text);
                                {
                                    //If the amount of postcodes is greater than 0...
                                    if (postCodes.Count > 0)
                                    {
                                        //Create an instance of the stringbuilder class.
                                        StringBuilder string_Builder = new StringBuilder();
                                        foreach (string pc in postCodes)
                                        {
                                            string_Builder.AppendLine(pc);
                                            //Display the postcode in lblDisplayPostCode.
                                            lblDisplayPostCode.Text = pc;
                                        }
                                    }
                                }

                                //Call the getClassID method from the Bookings Class and pass across the data.
                                List <string> classIDs = Bookings.getClassID(txtBookingID.Text);
                                {
                                    //If the amount of IDs is greater than 0...
                                    if (classIDs.Count > 0)
                                    {
                                        //Create an instance of the stringbuilder class.
                                        StringBuilder s_b = new StringBuilder();
                                        foreach (string id in classIDs)
                                        {
                                            s_b.AppendLine(id);
                                            //Display the ClassID in lblClassID.
                                            cbClassID.Text = id;
                                        }
                                    }
                                }

                                //Call the getClassName method from the Bookings Class and pass across the data.
                                List <string> classNames = Bookings.getClassName(cbClassID.Text);
                                {
                                    //If the amount of names is greater than 0...
                                    if (classNames.Count > 0)
                                    {
                                        //Create an instance of the stringbuilder class.
                                        StringBuilder string_b = new StringBuilder();
                                        foreach (string name in classNames)
                                        {
                                            string_b.AppendLine(name);
                                            //Display the name in lblDisplayClassName.
                                            lblDisplayClassName.Text = name;
                                        }
                                    }
                                }

                                //Call the getClassDay method from the Bookings Class and pass across the data.
                                List <string> classDays = Bookings.getClassDay(cbClassID.Text);
                                {
                                    //If the amount of days is greater than 0...
                                    if (classDays.Count > 0)
                                    {
                                        //Create an instance of the stringbuilder class.
                                        StringBuilder string_build = new StringBuilder();
                                        foreach (string day in classDays)
                                        {
                                            string_build.AppendLine(day);
                                            //Display the day in lblDisplayDay.
                                            lblDisplayDay.Text = day;
                                        }
                                    }
                                }

                                //Call the getClassTime method from the Bookings Class and pass across the data.
                                List <string> classTimes = Bookings.getClassTime(cbClassID.Text);
                                {
                                    //If the amount of times is greater than 0...
                                    if (classTimes.Count > 0)
                                    {
                                        //Create an instance of the stringbuilder class.
                                        StringBuilder s_builder = new StringBuilder();
                                        foreach (string time in classTimes)
                                        {
                                            s_builder.AppendLine(time);
                                            //Display the time in lblDisplayTime.
                                            lblDisplayTime.Text = time;
                                        }
                                    }
                                }

                                //Call the getClassDate method from the Bookings Class and pass across the data.
                                List <DateTime> classDates = Bookings.getClassDate(txtBookingID.Text);
                                {
                                    //If the amount of dates is greater than 0...
                                    if (classDates.Count > 0)
                                    {
                                        //Create an instance of the stringbuilder class.
                                        StringBuilder string_builder = new StringBuilder();

                                        foreach (DateTime c_date in classDates)
                                        {
                                            string_builder.AppendLine(Convert.ToString(c_date));
                                            //Display the ClassDate in dateTimePickerClass.
                                            dateTimePickerClass.Value = c_date;
                                        }
                                    }
                                }
                            }
                            //Otherwise display the message below.
                            else
                            {
                                MessageBox.Show("This booking does not exist.");
                            }
                        }
                        //Otherwise display the message below.
                        else
                        {
                            MessageBox.Show("This booking does not exist.");
                        }
                    }
                }
            }
            //Otherwise display the message below.
            else
            {
                MessageBox.Show("Please enter a BookingID.");
            }
        }
Beispiel #11
0
        private void SearchMember()
        {
            //Call the getMemberForename method from the Bookings Class and pass across the data.
            List <string> fnames = Bookings.getMemberForename(txtMemberID.Text);
            {
                //If the amount of names is greater than 0...
                if (fnames.Count > 0)
                {
                    //Create an instance of the stringbuilder class.
                    StringBuilder stringb = new StringBuilder();

                    foreach (string fname in fnames)
                    {
                        stringb.AppendLine(fname);
                        //Display the name in lblDisplayForename.
                        lblDisplayForename.Text = fname;
                    }
                }
            }

            //Call the getBookingSurname method from the Bookings Class and pass across the data.
            List <string> snames = Bookings.getMemberSurname(txtMemberID.Text);
            {
                //If the amount of names is greater than 0...
                if (snames.Count > 0)
                {
                    //Create an instance of the stringbuilder class.
                    StringBuilder string_b = new StringBuilder();

                    foreach (string sname in snames)
                    {
                        string_b.AppendLine(sname);
                        //Display the forname and surname in lblDisplaySurname.
                        lblDisplaySurname.Text = sname;
                    }
                }
            }

            //Call the getMemberStreet method from the Bookings Class and pass across the data.
            List <string> streets = Bookings.getMemberStreet(txtMemberID.Text);
            {
                //If the amount of streets is greater than 0...
                if (streets.Count > 0)
                {
                    //Create an instance of the stringbuilder class.
                    StringBuilder s_b = new StringBuilder();

                    foreach (string street in streets)
                    {
                        s_b.AppendLine(street);
                        //Display the postcode in lblDisplayStreet.
                        lblDisplayStreet.Text = street;
                    }
                }
            }

            //Call the getMemberTown method from the Bookings Class and pass across the data.
            List <string> towns = Bookings.getMemberTown(txtMemberID.Text);
            {
                //If the amount of towns is greater than 0...
                if (towns.Count > 0)
                {
                    //Create an instance of the stringbuilder class.
                    StringBuilder stringbuild = new StringBuilder();

                    foreach (string town in towns)
                    {
                        stringbuild.AppendLine(town);
                        //Display the postcode in lblDisplayTown.
                        lblDisplayTown.Text = town;
                    }
                }
            }

            //Call the getMemberCounty method from the Bookings Class and pass across the data.
            List <string> counties = Bookings.getMemberCounty(txtMemberID.Text);
            {
                //If the amount of counties is greater than 0...
                if (counties.Count > 0)
                {
                    //Create an instance of the stringbuilder class.
                    StringBuilder sbuild = new StringBuilder();

                    foreach (string county in counties)
                    {
                        sbuild.AppendLine(county);
                        //Display the postcode in lblDisplayCounty.
                        lblDisplayCounty.Text = county;
                    }
                }
            }

            //Call the getMemberPostCode method from the Bookings Class and pass across the data.
            List <string> pcs = Bookings.getMemberPostCode(txtMemberID.Text);
            {
                //If the amount of postcodes is greater than 0...
                if (pcs.Count > 0)
                {
                    //Create an instance of the stringbuilder class.
                    StringBuilder stbuilder = new StringBuilder();

                    foreach (string pc in pcs)
                    {
                        stbuilder.AppendLine(pc);
                        //Display the postcode in lblDisplayPostCode.
                        lblDisplayPostCode.Text = pc;
                    }
                }
            }
        }