Exemple #1
0
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            if (txtMemID.Text.Trim() == string.Empty)
            {
                MessageBox.Show("MemberID must be entered!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                int     classID  = Int32.Parse(cmbClass.SelectedItem.ToString().Substring(0, 3));
                int     capacity = Databases.GetCapacity(classID);
                Boolean valid    = Databases.CheckIfFull(classID, capacity);
                if (!valid)
                {
                    MessageBox.Show("Class is full!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    int     memID     = Convert.ToInt32(txtMemID.Text);
                    Boolean available = Databases.CheckValidMember(classID, memID);
                    if (!available)
                    {
                        MessageBox.Show("You have already booked class!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        int     mem = Convert.ToInt32(txtMemID.Text);
                        DataSet ds2;
                        ds2 = Databases.ValidUser(mem);
                        int i = ds2.Tables["Members"].Rows.Count;
                        if (i < 1)
                        {
                            MessageBox.Show("MemberID not valid!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            txtMemID.ResetText();
                        }
                        else
                        {
                            Databases newBooking = new Databases();
                            int       bookingID  = Convert.ToInt32(txtBookingID.Text);

                            newBooking.MakeBooking(bookingID, classID, memID);

                            MessageBox.Show("Booking confirmed!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            this.Close();
                            parent.Visible = true;
                        }
                    }
                }
            }
        }