private void tsmAddDetail_Click(object sender, EventArgs e)
 {
     try
     {
         if (grdTestInfo.CurrentRow == null | tabTestInfo.SelectedTab.Name != "tabResult") return;
         var obj = new frmTiepDonDangKy();
         obj.LoadType = "ForResultDetail";
         obj.currentTest_ID = Utility.Int32Dbnull(grdTestInfo.GetValue("Test_ID"));
         obj.currentTestType_ID = Utility.Int32Dbnull(grdTestInfo.GetValue("TestType_ID"));
         if (Utility.Int32Dbnull(grdPatients.GetValue("Patient_ID")) <= 0)
         {
             Utility.ShowMsg("Mã loại xét nghiệm không đúng !");
             obj.Dispose();
             return;
         }
         obj.patientId = Utility.Int32Dbnull(grdPatients.GetValue("Patient_ID"));
         obj.dtResultDetail = m_dtResultDetail;
         obj.ShowDialog();
         FocusColumnResult();
     }
     catch (Exception ex)
     {
         Utility.ShowMsg(ex.Message);
     }
     //btnParaEntry.PerformClick();
 }
        private void LoadFormPatientInfo(action vAction)
        {
            try
            {
                if (vAction == action.Update)
                {
                    if (grdPatients.CurrentRow == null) return;
                    if (grdPatients.CurrentRow.RowType != RowType.Record) return;
                }

                if (vAction == action.Insert | mv_DTPatientInfor.Rows.Count > 0)
                {
                    //if (SysPara.BarcodeType.ToUpper().Equals("VIETDUC"))
                    //{
                    //    var oForm = new frmNewPatientReg_VietDuc();
                    //    oForm.m_iAction = vAction;
                    //    if (vAction != action.Insert)
                    //        oForm.mv_DR = mv_DTPatientInfor.Rows[grdPatients.CurrentRow.RowIndex];
                    //    oForm.mv_ParentTable = mv_DTPatientInfor;
                    //    oForm.grdList = grdPatients;
                    //    oForm.dtDepartment = dtDepartment;
                    //    oForm.dtObjectType = dtObjectType;
                    //    oForm.ShowDialog();
                    //    if (oForm.AutoLoadRegForm) cmdTestTypeReg.PerformClick();
                    //    ModifyCommand();
                    //}
                    //else
                    //{
                    //var oForm = new frmNewPatientReg_VietDuc();
                    //oForm.m_iAction = vAction;
                    //if (vAction != action.Insert)
                    //    oForm.mv_DR = mv_DTPatientInfor.Rows[grdPatients.CurrentRow.RowIndex];
                    //oForm.mv_ParentTable = mv_DTPatientInfor;
                    //oForm.grdList = grdPatients;
                    //oForm.dtDepartment = dtDepartment;
                    //oForm.dtObjectType = dtObjectType;
                    //oForm.ShowDialog();
                    //if (oForm.AutoLoadRegForm) LoadTestTypeRegForm(Utility.Int32Dbnull(oForm.txtPatient_ID.Text));//cmdTestTypeReg.PerformClick();
                    //ModifyCommand();
                    //}

                    //var oForm = new frmInsertUpdatePatient();
                    //oForm.m_iAction = vAction;
                    //if (vAction != action.Insert)
                    //{
                    //    var tempPatientId = grdPatients.GetValue("Patient_ID");
                    //    var tempPatient = (from dr in mv_DTPatientInfor.AsEnumerable()
                    //                       where dr["Patient_ID"].Equals(tempPatientId)
                    //                       select dr).FirstOrDefault();
                    //    oForm.mv_DR = tempPatient;
                    //}
                    //oForm.mv_ParentTable = mv_DTPatientInfor;
                    //oForm.grdList = grdPatients;
                    //oForm.dtDepartment = dtDepartment;
                    //oForm.dtObjectType = dtObjectType;
                    //oForm.ShowDialog();
                    //if (oForm.AutoLoadRegForm && !string.IsNullOrEmpty(oForm.txtPatient_ID.Text))
                    //    LoadTestTypeRegForm(Utility.Int32Dbnull(oForm.txtPatient_ID.Text));
                    ////cmdTestTypeReg.PerformClick();
                    //ModifyCommand();

                    var oForm = new frmTiepDonDangKy();
                    oForm.m_iAction = vAction;
                    if (vAction != action.Insert)
                    {
                        var tempPatientId = grdPatients.GetValue("Patient_ID");
                        var tempPatient = (from dr in mv_DTPatientInfor.AsEnumerable()
                                           where dr["Patient_ID"].Equals(tempPatientId)
                                           select dr).FirstOrDefault();
                        oForm.mv_DR = tempPatient;
                        oForm.patientId = Utility.Int32Dbnull(tempPatientId);
                        oForm.AutoLoadRegForm = true;
                        oForm.Ok = true;
                    }
                    else if (vAction == action.Normal)
                    {
                        var tempPatientId = grdPatients.GetValue("Patient_ID");
                        var tempPatient = (from dr in mv_DTPatientInfor.AsEnumerable()
                                           where dr["Patient_ID"].Equals(tempPatientId)
                                           select dr).FirstOrDefault();
                        oForm.mv_DR = tempPatient;
                        oForm.patientId = Utility.Int32Dbnull(tempPatientId);
                        oForm.AutoLoadRegForm = true;
                        oForm.Ok = true;
                    }
                    oForm.mv_ParentTable = mv_DTPatientInfor;
                    oForm.grdList = grdPatients;

                    oForm.dtDepartment = dtDepartment;
                    oForm.dtObjectType = dtObjectType;

                    oForm.ShowDialog();
                    //if (oForm.AutoLoadRegForm && !string.IsNullOrEmpty(oForm.txtPatient_ID.Text))
                    //    LoadTestTypeRegForm(Utility.Int32Dbnull(oForm.txtPatient_ID.Text));
                    //cmdTestTypeReg.PerformClick();
                    ModifyCommand();
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
        private void LoadTestTypeRegForm(int patient_ID)
        {
            try
            {
                if (grdPatients.CurrentRow == null) return;
                var obj = new frmTiepDonDangKy();
                if (grdTestTypeRegList.GetValue("Test_ID") != null)
                {
                    obj.currentTest_ID = Utility.Int32Dbnull(grdTestTypeRegList.GetValue("Test_ID"));
                }

                obj.patientId = patient_ID;
                obj.dtTestTypeList = dtTestType;
                obj.grdPatients = grdPatients;
                obj.dtDepartment = dtDepartment;
                obj.AutoLoadRegForm = false;
                obj.m_iAction = action.Normal;
               var tempPatientId = grdPatients.GetValue("Patient_ID");
               var tempPatient = (from dr in mv_DTPatientInfor.AsEnumerable()
                                       where dr["Patient_ID"].Equals(tempPatientId)
                                       select dr).FirstOrDefault();
                    obj.mv_DR = tempPatient;
                    obj.patientId = Utility.Int32Dbnull(tempPatientId);
                    obj.AutoLoadRegForm = true;
               //obj.PrintbarcodeInstance = PrintBarcode;
                obj.ShowDialog();

                tsmRefresh.PerformClick();
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }
        private void LoadTestTypeRegForm(int patient_ID)
        {
            try
            {
                if (grdPatients.CurrentRow == null) return;
                var obj = new frmTiepDonDangKy();
                if (grdTestTypeRegList.GetValue("Test_ID") != null)
                {
                    obj.currentTest_ID = Utility.Int32Dbnull(grdTestTypeRegList.GetValue("Test_ID"));
                }

                obj.patientId = patient_ID;
                obj.dtTestTypeList = dtTestType;
                obj.grdPatients = grdPatients;
               // obj.PrintbarcodeInstance = PrintBarcode;
                obj.ShowDialog();
                tsmRefresh.PerformClick();
            }
            catch (Exception ex)
            {
                Utility.ShowMsg(ex.Message);
            }
        }