private bool Invalidata()
        {
            string BarCode = globalVariables.SysDate.Year + globalVariables.SysDate.Month.ToString() +
                             globalVariables.SysDate.Date + txtBarcode.Text;

            Utility.ResetMessageError(errorProvider1);
            if (!string.IsNullOrEmpty(txtBarcode.Text))
            {
                if (Utility.Int32Dbnull(txtBarcode.Text, 0) < SystemParaBarcode.ParaBacode)
                {
                    Utility.SetMessageError(errorProvider1, txtBarcode,
                                            "Số thứ tự của barcode không nhỏ hơn " +
                                            SystemParaBarcode.ParaBacode);
                    txtBarcode.Focus();
                    return(false);
                }
                TTestInfoCollection testInfoCollection =
                    new TTestInfoController().FetchByQuery(TTestInfo.CreateQuery().AddWhere(TTestInfo.Columns.Barcode,
                                                                                            Comparison.Equals,
                                                                                            txtBarcode.Text.Trim()));
                if (testInfoCollection.Count > 0)
                {
                    Utility.SetMessageError(errorProvider1, txtBarcode,
                                            "Tồn tại  " + SystemParaBarcode.ParaBacode);
                    txtBarcode.Focus();
                    return(false);
                }
            }
            return(true);
        }
        private bool InValiData()
        {
            v_patientId = Utility.Int32Dbnull(grdPatients.CurrentRow.Cells["colPatient_ID"].Value, -1);

            TTestInfoCollection testInfoCollection =
                new TTestInfoController().FetchByQuery(TTestInfo.CreateQuery().AND(TTestInfo.Columns.TestTypeId,
                                                                                   Comparison.Equals, v_TestTypeInfo).AND(
                                                           TTestInfo.Columns.PatientId,
                                                           Comparison.Equals, v_patientId));

            if (testInfoCollection.Count > 0)
            {
                return(true);
            }
            return(false);
        }
        public static string InsertTestInfo(TTestInfo pitems)
        {
            try
            {
                using (var scope = new TransactionScope())
                {
                    using (var sp = new SharedDbConnectionScope())
                    {
                        if (pitems.TestDate == null)
                        {
                            pitems.TestDate = DateTime.Now;
                        }
                        if (pitems.RequireDate == null)
                        {
                            pitems.RequireDate = DateTime.Now;
                        }
                        if (pitems.TestStatus == null)
                        {
                            pitems.TestStatus = 0;
                        }


                        int   i        = 0;
                        Query _QueryRS = TTestInfo.CreateQuery();
                        TTestInfoCollection testInfoCollection =
                            new TTestInfoController().FetchByQuery(
                                TTestInfo.CreateQuery().AddWhere(TTestInfo.Columns.PatientId, Comparison.Equals,
                                                                 pitems.PatientId));
                        if (testInfoCollection.Count > 0)
                        {
                            pitems.ParaId = testInfoCollection[0].ParaId;
                        }
                        pitems.IsNew = true;
                        pitems.Save(i);
                        scope.Complete();
                        return(_QueryRS.GetMax(TTestInfo.Columns.TestId).ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public static string BarCodeTestInfo(int vPatient_ID, int testTyeId, int Para_ID)
        {
            var    dataTable = new DataTable();
            string sBarcode  = "";
            TTestInfoCollection testInfoController =
                new TTestInfoController().FetchByQuery(TTestInfo.CreateQuery().AddWhere(TTestInfo.Columns.PatientId,
                                                                                        Comparison.Equals, vPatient_ID));

            if (testInfoController.Count > 0)
            {
                sBarcode = testInfoController[0].Barcode;
            }
            else
            {
                dataTable = SPs.SpGetNewTestSID(globalVariables.SysDate, testTyeId, Para_ID).GetDataSet().Tables[0];
                if (dataTable.Rows.Count > 0)
                {
                    sBarcode = dataTable.Rows[0][0].ToString();
                }
            }
            return(sBarcode);
        }