Exemplo n.º 1
0
        /************************************************************
         * Doctor
         ***********************************************************/

        private void buttonAdminDAdd_Click(object sender, EventArgs e)
        {
            int id   = 0;
            int pass = 0;

            try
            {
                id = Convert.ToInt32(textBoxAdminDID.Text);
            }
            catch (Exception)
            {
            }

            try
            {
                pass = Convert.ToInt32(textBoxAdminDPassword.Text);
            }
            catch (Exception)
            {
            }

            try
            {
                _controller.AddDoctor(id, textBoxAdminDName.Text, textBoxAdminDAddress.Text, textBoxAdminDUsername.Text, pass);
                UpdateDoctorList();
                textBoxAdminDName.Text     = "";
                textBoxAdminDID.Text       = "";
                textBoxAdminDUsername.Text = "";
                textBoxAdminDAddress.Text  = "";
                textBoxAdminDPassword.Text = "";
            }
            catch (DoctorIDAlreadyExsistsException)
            {
                MessageBox.Show("Doctor ID already exists!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (InvalidNameException)
            {
                MessageBox.Show("Wrong name!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (InvalidAddressException)
            {
                MessageBox.Show("Wrong address!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (InvalidIDException)
            {
                MessageBox.Show("Wrong ID!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (InvalidUsernameException)
            {
                MessageBox.Show("Wrong username!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (InvalidPasswordException)
            {
                MessageBox.Show("Wrong password!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }