예제 #1
0
        private void editpatientsavebutton_Click(object sender, EventArgs e)
        {
            int     patientid = Convert.ToInt32(editpatientidlabel.Text);
            Patient patient   = new Patient();

            patient = ada.getPatientbyId(patientid);
            string gender = "";

            if (editpatientnametextBox.Text == patient.Name && editpatientaddresscomboBox.SelectedItem.ToString() == patient.Address && editpatientcontacttextBox.Text == patient.Contactno.ToString() && Convert.ToDateTime(editpatientdobdateTimePicker.Text) == patient.DOB && (editpatientmaleradioButton.Text == patient.Gender || editpatientfemaleradioButton.Text == patient.Gender))
            {
                MessageBox.Show("No New Changes.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            else
            {
                if (string.IsNullOrEmpty(editpatientnametextBox.Text))
                {
                    MessageBox.Show("Name Can Not Be Empty.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    editpatientnametextBox.Focus();
                    return;
                }
                else if (string.IsNullOrEmpty(editpatientcontacttextBox.Text))
                {
                    MessageBox.Show("Contact Number Can Not Be Empty.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    editpatientcontacttextBox.Focus();
                    return;
                }
                else if (editpatientaddresscomboBox.SelectedItem == null)
                {
                    MessageBox.Show("Address Can Not Be Empty.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    editpatientaddresscomboBox.Focus();
                    return;
                }
                else if (editpatientmaleradioButton.Checked == false && editpatientfemaleradioButton.Checked == false)
                {
                    MessageBox.Show("Select gender.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    editpatientmaleradioButton.Focus();
                    editpatientfemaleradioButton.Focus();
                    return;
                }
                else
                {
                    if (editpatientmaleradioButton.Checked == true)
                    {
                        gender = "Male";
                    }
                    else if (editpatientfemaleradioButton.Checked == true)
                    {
                        gender = "Female";
                    }
                    if (editpatientcontacttextBox.Text.Length > 11)
                    {
                        MessageBox.Show("Invalid Contactno");
                    }
                    else
                    {
                        ada.editPatient(patientid, editpatientnametextBox.Text, editpatientcontacttextBox.Text, editpatientaddresscomboBox.SelectedItem.ToString(), gender, editpatientdobdateTimePicker.Text);
                        MessageBox.Show("Patient Updated Successfully.");
                    }
                }
            }
        }