Ejemplo n.º 1
0
        private void buttonAddPacient_Click(object sender, EventArgs e)
        {
            int    id         = 0;
            string doctorName = "";

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

            if (!String.IsNullOrEmpty(textBoxMNDoctorName.Text))
            {
                try
                {
                    string name = textBoxMNName.Text;
                    string add  = textBoxMNAdd.Text;

                    _controller.AddPacient(id, textBoxMNName.Text, textBoxMNAdd.Text, doctorName, _doctor.ID);
                    _doctor.PacientList.Add(new Patient(Convert.ToInt32(textBoxMNID.Text), textBoxMNName.Text, textBoxMNAdd.Text, _doctor.Name, _doctor.ID));

                    UpdatePacientsList();

                    textBoxMNName.Text    = "";
                    textBoxMNID.Text      = "";
                    textBoxMNAdd.Text     = "";
                    comboBoxMNDoctor.Text = "";

                    textBoxMNDoctorName.Text = "";
                    textBoxMNDoctorID.Text   = "";
                    textBoxMNDoctorAdd.Text  = "";
                    comboBoxMNDoctorPat.Text = "";
                }
                catch (PatientDAlreadyExsistsException)
                {
                    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);
                }
            }
            else
            {
                MessageBox.Show("Wrong doctor name!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }