Exemplo n.º 1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(txtFirstName.Text) && !String.IsNullOrEmpty(txtMiddleName.Text) &&
                !String.IsNullOrEmpty(txtLastName.Text) && !String.IsNullOrEmpty(txtAddress.Text) &&
                !String.IsNullOrEmpty(txtContactNo.Text) && !String.IsNullOrEmpty(txtEmailAddress.Text) &&
                (rbnMale.Checked || rbnFemale.Checked) && cmbEvents.SelectedIndex != -1 &&
                (rbnStudent.Checked && !String.IsNullOrEmpty(txtSchoolName.Text) && !String.IsNullOrEmpty(txtCourse.Text) &&
                 !String.IsNullOrEmpty(txtYear.Text)) ||
                (rbnWorking.Checked && !String.IsNullOrEmpty(txtWorksAt.Text) && !String.IsNullOrEmpty(txtPosition.Text)))
            {
                setGuest();
                guestPresenter.addGuest();
                if (btnAdd.Text == "Add")
                {
                    guestPresenter.registerGuest();
                    MessageBox.Show("Guest successfully registered to " + cmbEvents.Text, "Guests", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Your registration to " + cmbEvents.Text + " is successful and is pending for approval",
                                    "Guests", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    MessageBox.Show("Your registration code is " + guestPresenter.getCode() + ". Use this code to check your " +
                                    "status of registration later on. Thank you!", "Guest Registration", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }

                this.Close();
            }
            else
            {
                MessageBox.Show("Please fill up the form correctly", "Guests", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }

            /*if (btnAdd.Text == "Add")
             * {
             *  if (!String.IsNullOrEmpty(txtFirstName.Text) && !String.IsNullOrEmpty(txtMiddleName.Text) &&
             *      !String.IsNullOrEmpty(txtLastName.Text) && !String.IsNullOrEmpty(txtAddress.Text) &&
             *      !String.IsNullOrEmpty(txtContactNo.Text) && !String.IsNullOrEmpty(txtEmailAddress.Text) &&
             *      (rbnMale.Checked || rbnFemale.Checked) && cmbEvents.SelectedIndex != -1)
             *  {
             *      if (rbnStudent.Checked)
             *      {
             *          if (!String.IsNullOrEmpty(txtSchoolName.Text) && !String.IsNullOrEmpty(txtCourse.Text) &&
             *              !String.IsNullOrEmpty(txtYear.Text))
             *          {
             *              setGuest();
             *              guestPresenter.addGuest();
             *              guestPresenter.registerGuest();
             *
             *              MessageBox.Show("Guest successfully registered to " + cmbEvents.Text, "Guests", MessageBoxButtons.OK,
             *                  MessageBoxIcon.Information);
             *              this.Close();
             *          }
             *          else
             *          {
             *              MessageBox.Show("Please fill up the form correctly", "Guests", MessageBoxButtons.OK,
             *                      MessageBoxIcon.Error);
             *          }
             *      }
             *      else if (rbnWorking.Checked)
             *      {
             *          if (!String.IsNullOrEmpty(txtWorksAt.Text) && !String.IsNullOrEmpty(txtPosition.Text))
             *          {
             *              setGuest();
             *              guestPresenter.addGuest();
             *              guestPresenter.registerGuest();
             *
             *              MessageBox.Show("Guest successfully registered to " + cmbEvents.Text, "Guests", MessageBoxButtons.OK,
             *                  MessageBoxIcon.Information);
             *              this.Close();
             *          }
             *          else
             *          {
             *              MessageBox.Show("Please fill up the form correctly", "Guests", MessageBoxButtons.OK,
             *                      MessageBoxIcon.Error);
             *          }
             *      }
             *      else
             *      {
             *          MessageBox.Show("Please fill up the form correctly", "Guests", MessageBoxButtons.OK,
             *                          MessageBoxIcon.Error);
             *      }
             *  }
             *  else
             *  {
             *      MessageBox.Show("Please fill up the form correctly", "Guests", MessageBoxButtons.OK,
             *                          MessageBoxIcon.Error);
             *  }
             * }
             * else if (btnAdd.Text == "Register")
             * {
             *  if (!String.IsNullOrEmpty(txtFirstName.Text) && !String.IsNullOrEmpty(txtMiddleName.Text) &&
             *      !String.IsNullOrEmpty(txtLastName.Text) && !String.IsNullOrEmpty(txtAddress.Text) &&
             *      !String.IsNullOrEmpty(txtContactNo.Text) && !String.IsNullOrEmpty(txtEmailAddress.Text) &&
             *      (rbnMale.Checked || rbnFemale.Checked) && cmbEvents.SelectedIndex != -1)
             *  {
             *      if (rbnStudent.Checked)
             *      {
             *          if (!String.IsNullOrEmpty(txtSchoolName.Text) && !String.IsNullOrEmpty(txtCourse.Text) &&
             *              !String.IsNullOrEmpty(txtYear.Text))
             *          {
             *              setGuest();
             *              guestPresenter.addGuest();
             *
             *              MessageBox.Show("Your registration to " + cmbEvents.Text + " is successful and is pending for approval",
             *                  "Guests", MessageBoxButtons.OK, MessageBoxIcon.Information);
             *              MessageBox.Show("Your registration code is " + guestPresenter.getCode() + ". Use this code to check your " +
             *                  "status of registration later on. Thank you!", "Guest Registration", MessageBoxButtons.OK,
             *                  MessageBoxIcon.Information);
             *              this.Close();
             *          }
             *          else
             *          {
             *              MessageBox.Show("Please fill up the form correctly", "Guest Registration", MessageBoxButtons.OK,
             *                      MessageBoxIcon.Error);
             *          }
             *      }
             *      else if (rbnWorking.Checked)
             *      {
             *          if (!String.IsNullOrEmpty(txtWorksAt.Text) && !String.IsNullOrEmpty(txtPosition.Text))
             *          {
             *              setGuest();
             *              guestPresenter.addGuest();
             *
             *              MessageBox.Show("Your registration to " + cmbEvents.Text + " is successful and is pending for approval",
             *                  "Guests", MessageBoxButtons.OK, MessageBoxIcon.Information);
             *              MessageBox.Show("Your registration code is " + guestPresenter.getCode() + ". Use this code to check your " +
             *                  "status of registration later on. Thank you!", "Guest Registration", MessageBoxButtons.OK,
             *                  MessageBoxIcon.Information);
             *              this.Close();
             *          }
             *          else
             *          {
             *              MessageBox.Show("Please fill up the form correctly", "Guest Registration", MessageBoxButtons.OK,
             *                      MessageBoxIcon.Error);
             *          }
             *      }
             *      else
             *      {
             *          MessageBox.Show("Please fill up the form correctly", "Guest Registration", MessageBoxButtons.OK,
             *                          MessageBoxIcon.Error);
             *      }
             *  }
             *  else
             *  {
             *      MessageBox.Show("Please fill up the form correctly", "Guest Registration", MessageBoxButtons.OK,
             *                          MessageBoxIcon.Error);
             *  }
             * }
             * else
             * {
             *  clearFields();
             * }*/
        }
Exemplo n.º 2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (btnAdd.Text == "Add")
            {
                if (!String.IsNullOrEmpty(txtFirstName.Text) && !String.IsNullOrEmpty(txtMiddleName.Text) &&
                    !String.IsNullOrEmpty(txtLastName.Text) && !String.IsNullOrEmpty(txtAddress.Text) &&
                    !String.IsNullOrEmpty(txtContactNo.Text) && !String.IsNullOrEmpty(txtEmailAddress.Text) &&
                    (rbnMale.Checked || rbnFemale.Checked) && cmbEvents.SelectedIndex != -1)
                {
                    if (rbnStudent.Checked)
                    {
                        if (!String.IsNullOrEmpty(txtSchoolName.Text) && !String.IsNullOrEmpty(txtCourse.Text) &&
                            !String.IsNullOrEmpty(txtYear.Text))
                        {
                            setGuest();
                            guestPresenter.addGuest();
                            guestPresenter.registerGuest();
                            MessageBox.Show("Guest successfully registered to " + cmbEvents.Text, "Guests", MessageBoxButtons.OK,
                                            MessageBoxIcon.Information);

                            clearFields();
                            guestPresenter.loadGuests(dataGuests);
                        }
                        else
                        {
                            MessageBox.Show("Please fill up the form correctly", "Guests", MessageBoxButtons.OK,
                                            MessageBoxIcon.Error);
                        }
                    }
                    else if (rbnWorking.Checked)
                    {
                        if (!String.IsNullOrEmpty(txtWorksAt.Text) && !String.IsNullOrEmpty(txtPosition.Text))
                        {
                            setGuest();
                            guestPresenter.addGuest();
                            guestPresenter.registerGuest();
                            MessageBox.Show("Guest successfully registered to " + cmbEvents.Text, "Guests", MessageBoxButtons.OK,
                                            MessageBoxIcon.Information);
                        }
                        else
                        {
                            MessageBox.Show("Please fill up the form correctly", "Guests", MessageBoxButtons.OK,
                                            MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Please fill up the form correctly", "Events", MessageBoxButtons.OK,
                                        MessageBoxIcon.Error);
                    }
                }
                else
                {
                    MessageBox.Show("Please fill up the form correctly", "Events", MessageBoxButtons.OK,
                                    MessageBoxIcon.Error);
                }
            }
            else
            {
                clearFields();
            }
        }