private void button1_submit_Click(object sender, EventArgs e)
        {
            patient       = new Patient();
            businessLayer = new HospitalBusinessLayer();
            if (btnSubmit.Text == "Submit")
            {
                patient.Name        = txtPatientName.Text;
                patient.Address     = txtAddress.Text;
                patient.DateOfBirth = Convert.ToDateTime(txtDOB.Text);
                if (rbtn_Male.Checked)
                {
                    patient.Gender = Gender.M;
                }
                else
                {
                    patient.Gender = Gender.F;
                }

                patient.ContactNumber = txtContact.Text;
                patient.Emergency     = txtEmergrncy.Text;
                int    patientId = businessLayer.AddPatient(patient);
                string Message   = string.Empty;
                if (patientId > 0)
                {
                    Message = "Patient ID " + patientId;
                }
                else
                {
                    Message = "Patient Not Added";
                }

                MessageBox.Show(Message);
            }
            else
            {
                int  patientID = Convert.ToInt32(txtPatientID.Text);
                bool exist     = businessLayer.GetPatientDetailByPatientID(patientID, out patient);
                if (exist)
                {
                    txtPatientName.Text = patient.Name;
                    txtAddress.Text     = patient.Address;
                    txtContact.Text     = patient.ContactNumber;
                    txtDOB.Text         = patient.DateOfBirth.ToString();
                    if (patient.Gender == Gender.M)
                    {
                        rbtn_Male.Checked = true;
                    }
                    else
                    {
                        rbtn_Female.Checked = true;
                    }
                }
                else
                {
                    MessageBox.Show("Patient Not found");
                }
            }
        }
Ejemplo n.º 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {
         string userName = txt1_userName.Text;
         string password = txt2_password.Text;
         HospitalBusinessLayer business = new HospitalBusinessLayer();
         User user = null;
         user = business.validateCredential(userName, password);
         if (user != null)
         {
             WelcomeForm welcomeForm = new WelcomeForm(user);
             welcomeForm.Show();
             this.Hide();
         }
     }
     catch (HospitalExceptionLayer.HospitalException ex)
     {
         lblError.Text = ex.Message;
     }
 }