Exemplo n.º 1
0
        public LabTestGroup GetGroupLabTest(int mainTestId)
        {
            LabTest   mainLabTest = this.GetLabTestById(mainTestId);
            ClsObject obj         = new ClsObject();

            ClsUtility.Init_Hashtable();
            ClsUtility.AddExtendedParameters("@MainTestId", SqlDbType.Int, mainTestId);
            DataTable    dt       = (DataTable)obj.ReturnObject(ClsUtility.theParams, "Laboratory_GroupGetLabTest", ClsUtility.ObjectEnum.DataTable);
            LabTestGroup groupLab = new LabTestGroup()
            {
                GroupTest = mainLabTest
            };
            TestDepartment department = null;
            var            component  = (from row in dt.AsEnumerable()
                                         select new LabTest()
            {
                Id = Convert.ToInt32(row["Id"]),
                Name = row["Name"].ToString(),
                IsGroup = Convert.ToBoolean(row["IsGroup"]),
                ReferenceId = row["ReferenceId"].ToString(),
                ParameterCount = Convert.ToInt32(row["ParameterCount"]),
                Department = row["DepartmentId"] == DBNull.Value ? department : new TestDepartment()
                {
                    Id = Convert.ToInt32(row["DepartmentId"]), Name = row["Department"].ToString()
                },
                DeleteFlag = Convert.ToBoolean(row["DeleteFlag"]),
                Active = Convert.ToBoolean(row["Active"]),
                TestParameter = null
            }
                                         ).ToList <LabTest>();

            groupLab.ComponentTest = component;
            obj = null;
            return(groupLab);
        }
        protected void AddLabRecord(object sender, EventArgs e)
        {
            if (null == this.SelectedTest)
            {
                hdCustID.Value   = textSelectLab.Text = "";
                this.isDataEntry = false;
                return;
            }
            LabTestGroup testGroup = this.SelectedGroup;
            LabTest      candidate = this.SelectedTest;
            bool         proceed   = false;

            proceed = (null == testGroup.ComponentTest || testGroup.ComponentTest.Count == 0 || !testGroup.ComponentTest.Exists(o => o.Id == candidate.Id));
            if (!proceed || candidate.IsGroup)
            {
                hdCustID.Value   = textSelectLab.Text = "";
                this.isDataEntry = false;
                return;
            }
            try
            {
                mGr.SaveGroupLabTest(candidate.Id, this.MainLabTestId);
                this.PopulateLabTest();
                IQCareMsgBox.NotifyAction(string.Format("{0} has been added to this group", candidate.Name), "Success", false, this, "");
                this.SelectedTest = null;
                hdCustID.Value    = textSelectLab.Text = "";
                this.isDataEntry  = false;
                return;
            }
            catch (Exception ex)
            {
                this.ShowErrorMessage(ref ex);
            }
        }
        protected void LabNameChanged(object sender, EventArgs e)
        {
            LabTestGroup testGroup = this.SelectedGroup;
            int          _testId;
            string       _testname         = "";
            string       _refId            = "";
            string       _testDepartmentId = "";
            string       _testDepartment   = "";
            bool         isGroup           = true;
            int          _paramCount;

            if (!(hdCustID.Value != null && String.IsNullOrEmpty(hdCustID.Value)))
            {
                String[] itemCodes = hdCustID.Value.Split(';');
                if (itemCodes.Length == 7)
                {
                    _testId           = Convert.ToInt32(itemCodes[0]);
                    _testname         = itemCodes[1].ToString();
                    _refId            = itemCodes[2].ToString();
                    _paramCount       = Convert.ToInt32(itemCodes[3]);
                    isGroup           = bool.Parse(itemCodes[4].ToString());
                    _testDepartmentId = itemCodes[5].ToString();
                    _testDepartment   = itemCodes[6].ToString();

                    bool proceed = false;
                    proceed = (null == testGroup.ComponentTest || testGroup.ComponentTest.Count == 0 || !testGroup.ComponentTest.Exists(o => o.Id == _testId));

                    if (!proceed || isGroup)
                    {
                        ((TextBox)sender).Text = "";
                        hdCustID.Value         = "";
                        this.isDataEntry       = false;
                        return;
                    }
                    this.SelectedTest = new LabTest()
                    {
                        Id         = _testId,
                        Name       = _testname,
                        Department = new TestDepartment()
                        {
                            Id = Convert.ToInt32(_testDepartmentId), Name = _testDepartment, DeleteFlag = false
                        },
                        ReferenceId    = _refId,
                        ParameterCount = _paramCount,
                        IsGroup        = isGroup
                    };

                    this.isDataEntry = true;
                }
            }
        }
 private void PopulateLabTest()
 {
     try
     {
         LabTest selectedLab = (LabTest)Session[SessionKey.SelectedLab];
         this.MainLabTestId = selectedLab.Id;
         labelTestName.Text = selectedLab.Name;
         LabTestGroup group = mGr.GetGroupLabTest(this.MainLabTestId);
         this.SelectedGroup = group;
         if (null != group && null != group.ComponentTest)
         {
             gridlabMaster.DataSource = group.ComponentTest;
             gridlabMaster.DataBind();
         }
     }
     catch (Exception ex)
     {
         this.ShowErrorMessage(ref ex);
     }
 }