示例#1
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;
                    }
                }
            }
        }
示例#2
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;
                    }
                }
            }
        }
示例#3
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.");
            }
        }