Exemple #1
0
        //Add new medical staff button
        private void button7_Click(object sender, EventArgs e)
        {
            DbConnector dbConn = new DbConnector();

            dbConn.connect();

            MedicalStaff        mStaff    = new MedicalStaff();
            MedicalStaffHandler mStaffHnd = new MedicalStaffHandler();

            bool verifyCareer = false;

            if (textBox14.Text != "" && textBox15.Text != "" && textBox16.Text != "" &&
                (comboBox6.SelectedItem).ToString() != "- SELECT CAREER -")
            {
                if ((comboBox6.SelectedItem).ToString() == "Consultant")
                {
                    if (textBox17.Text != "")
                    {
                        verifyCareer = true;
                    }
                    else
                    {
                        MessageBox.Show("Invalid format for Email !");
                    }
                }
                else if ((comboBox6.SelectedItem).ToString() == "Doctor" || (comboBox6.SelectedItem).ToString() == "Nurse")
                {
                    if (int.TryParse(textBox18.Text, out int theContact))
                    {
                        if (int.TryParse(textBox19.Text, out int thePager))
                        {
                            verifyCareer = true;
                        }
                        else
                        {
                            MessageBox.Show("Invalid format for Pager Number !");
                        }
                    }
                    else
                    {
                        MessageBox.Show("Invalid format for Contact Number!");
                    }
                }
                else
                {
                    MessageBox.Show("Please select a type of career.");
                }

                if (verifyCareer == true)
                {
                    mStaff.Staffid  = textBox14.Text;
                    mStaff.Name     = textBox15.Text;
                    mStaff.Password = textBox16.Text;
                    mStaff.Email    = textBox17.Text;
                    mStaff.Contact  = textBox18.Text;
                    mStaff.Pager    = textBox19.Text;
                    mStaff.Career   = (comboBox6.SelectedItem).ToString();

                    int recordCnt = mStaffHnd.addNewMedicalStaff(dbConn.getConn(), mStaff);
                    MessageBox.Show(recordCnt + " Medical Staff Registered Successfully !");

                    textBox14.Text = "";
                    textBox15.Text = "";
                    textBox16.Text = "";
                    textBox17.Text = "";
                    textBox18.Text = "";
                    textBox19.Text = "";

                    comboBox6.SelectedIndex = 0;

                    medicalStaffDBtable(1);
                }
            }
            else
            {
                MessageBox.Show("Please fill up all fields to register.");
            }
        }