示例#1
0
 private void btnApp_Click(object sender, EventArgs e)
 {
     try
     {
         if (LoggedUser.type_name.ToUpper() == "DOCTOR")
         {
             if (Application.OpenForms.OfType <frmConsultations>().Count() == 1)
             {
                 Application.OpenForms.OfType <frmConsultations>().First().BringToFront();
             }
             else
             {
                 frmConsultations frm = new frmConsultations();
                 frm.MdiParent = this;
                 frm.Show();
                 frm.WindowState = FormWindowState.Maximized;
             }
         }
         else
         {
             if (Application.OpenForms.OfType <frmAppointments>().Count() == 1)
             {
                 Application.OpenForms.OfType <frmAppointments>().First().BringToFront();
             }
             else
             {
                 frmAppointments frm = new frmAppointments();
                 frm.MdiParent = this;
                 frm.Show();
                 frm.WindowState = FormWindowState.Maximized;
             }
         }
     }
     catch (Exception ex)
     {
         CommonLogger.Info(ex.ToString());
     }
 }
示例#2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidateChildren(ValidationConstraints.Enabled))
                {
                    int  logged_in_user = LoggedUser.id;
                    int  rtn            = -1;
                    int  exists         = -1;
                    char gender;
                    if (rbGender1.Checked == true)
                    {
                        gender = 'M';
                    }
                    else
                    {
                        gender = 'F';
                    }
                    if (txtID.Text.Trim() == "") //add data
                    {
                        exists = pat.existPatients(txtFirstName.Text.Trim(), txtLastName.Text.Trim(), gender, Convert.ToDateTime(dtpDob.Text), txtNationality.Text.Trim(), txtPhone.Text.Trim());
                        if (exists <= 0)
                        {
                            rtn = pat.addPatients(txtFirstName.Text, txtLastName.Text, gender, Convert.ToDateTime(dtpDob.Text), txtNationality.Text, txtPathaka.Text, Convert.ToDateTime(dtpPathakaExpiry.Text), txtAddress.Text, txtCity.Text, txtDistrict.Text, txtZip.Text, txtPhone.Text, txtEmail.Text, txtHistory.Text, txtAllergies.Text, logged_in_user);

                            if (rtn >= 1)
                            {
                                ShowStatus(1, "Record succesfully added. ");
                                clearFormFields();
                                if (chkAppointment.Checked == true)
                                {
                                    if (LoggedUser.type_name.ToUpper() == "DOCTOR")
                                    {
                                        if (Application.OpenForms.OfType <frmConsultations>().Count() == 1)
                                        {
                                            Application.OpenForms.OfType <frmConsultations>().First().BringToFront();
                                        }
                                        else
                                        {
                                            frmConsultations frm = new frmConsultations();
                                            frm.MdiParent = this.ParentForm;
                                            frm.Show();
                                        }
                                    }
                                    else
                                    {
                                        if (Application.OpenForms.OfType <frmAppointments>().Count() == 1)
                                        {
                                            Application.OpenForms.OfType <frmAppointments>().First().BringToFront();
                                        }
                                        else
                                        {
                                            frmAppointments app = new frmAppointments(rtn);
                                            app.MdiParent = this.ParentForm;
                                            app.Show();
                                        }
                                    }
                                }
                            }
                            else if (rtn == -1)
                            {
                                ShowStatus(0, "Some error occurred... Record cannot be added.");
                            }
                        }
                        else
                        {
                            ShowStatus(0, "Patient already exists, cannot be added.");
                        }
                    }
                    else //edit record
                    {
                        rtn = pat.editPatients(Int32.Parse(txtID.Text), txtFirstName.Text, txtLastName.Text, gender, Convert.ToDateTime(dtpDob.Text), txtNationality.Text, txtPathaka.Text, Convert.ToDateTime(dtpPathakaExpiry.Text), txtAddress.Text, txtCity.Text, txtDistrict.Text, txtZip.Text, txtPhone.Text, txtEmail.Text, txtHistory.Text, txtAllergies.Text, logged_in_user);

                        if (rtn > -1)
                        {
                            ShowStatus(1, "Record succesfully updated");
                            clearFormFields();
                        }
                        else if (rtn == -1)
                        {
                            ShowStatus(0, "Some error occurred... Record cannot be added.");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                CommonLogger.Info(ex.ToString());
            }
        }