private void changeDataGridView()
        {
            //Call the CheckMember method from the Bookings class and pass across the data.
            List <int> members = Bookings.CheckMember(txtClassID.Text, Convert.ToDateTime(txtDate.Text));

            //Convert the list to a Data Table.
            DataTable memberData = ConvertListToDataTable(members);

            dataGridViewClass.DataSource            = memberData;
            dataGridViewClass.Columns[0].HeaderText = "Member ID";
            //Count the amount of spaces left in the class.
            int count      = dataGridViewClass.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();
            }
        }
Esempio n. 2
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;
                }
            }
        }