Exemple #1
0
        /// <summary>
        ///   Adds the patient to the database. First all extra charaters are removed, the form is validated. The record is saved and if the save is successful then a new <see cref = "OpticianDB.Forms.PatientInfo" /> form is opened with the data. If the saving fails another record exists with the same data and the user is informed
        /// </summary>
        /// <param name = "sender">The sender.</param>
        /// <param name = "e">The <see cref = "System.EventArgs" /> instance containing the event data.</param>
        private void AddPatient(object sender, EventArgs e)
        {
            telephone_Text.Text = telephone_Text.Text.Replace(" ", "");
            telephone_Text.Text = telephone_Text.Text.Replace("-", "");
            nhsNumber_Text.Text = nhsNumber_Text.Text.Replace(" ", "");
            nhsNumber_Text.Text = nhsNumber_Text.Text.Replace("-", "");
            if (!CanSave())
            {
                return;
            }
            int result = dbb.AddPatient(name_Text.Text, address_Text.Text, telephone_Text.Text,
                                        dateOfBirth_DateTimePicker.Value, nhsNumber_Text.Text, email_Text.Text,
                                        (RecallMethods)
                                        Enum.Parse(typeof(RecallMethods), recallMethod_ComboBox.SelectedItem.ToString()));

            if (result == -1)
            {
                MessageBox.Show("Record already exists", "Record Addition Failed", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
            else
            {
                PatientInfo pi = new PatientInfo(result);
                pi.Show();
                pi.Focus();
                Close();
            }
        }