Beispiel #1
0
        /// <summary>
        /// Sets required key fields and helper data sources
        /// </summary>
        private void InitParamaters()
        {
            _diseaseName            = !string.IsNullOrEmpty(QueryDiseaseName) ? QueryDiseaseName : string.Empty;
            _diseaseAttributeLookup = new Dictionary <int, int>();
            _lkpDiseaseAttributeId  = null;

            // set data sources
            LookupCodeDa da = new LookupCodeDa();

            if (QueryDiseaseId.HasValue)
            {
                var lkpAttributes = BOL.BusinessObject.GetByFields <LookupAttribute>(new Dictionary <string, object> {
                    { LookupAttribute.AttributeName, "Disease" }
                });
                if (lkpAttributes.Count() > 0)
                {
                    _lkpDiseaseAttributeId = (int)lkpAttributes.First()[LookupAttribute.AttributeId];
                    // get lookup codes for current disease
                    var diseaseLkpCode = BOL.BusinessObject.GetByFields <LookupCodeAttribute>(new Dictionary <string, object>
                    {
                        { LookupCodeAttribute.AttributeId, _lkpDiseaseAttributeId.Value },
                        { LookupCodeAttribute.AttributeValue, QueryDiseaseName }
                    });
                    // create lookup to get lookup attribute id by lookup code id
                    _diseaseAttributeLookup = diseaseLkpCode.ToDictionary(b => (int)b[LookupCodeAttribute.LookupCodeId], b => (int)b[LookupCodeAttribute.LookupCodeAttributeId]);
                }
            }
            // set main lookup data source
            _lkpCodesTable = da.GetLookupFieldNames().Tables[0];
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BindLookupAttributeValues(object sender, EventArgs e)
        {
            string lkFieldName    = LookupCodesList.Value;
            string lkpAttributeId = LookupAttributesList.Value;

            // determine if using textbox(default) to build value or dropdown list
            string lkpAttributeValue = string.Empty;

            if (!string.IsNullOrEmpty(LookupAttributeValue.Value))
            {
                lkpAttributeValue = LookupAttributeValue.Value;
            }
            else if (!string.IsNullOrEmpty(ExistingAttributeValues.Value))
            {
                lkpAttributeValue = ExistingAttributeValues.Value;
            }

            if (!string.IsNullOrEmpty(lkFieldName) && !string.IsNullOrEmpty(lkpAttributeId) && !string.IsNullOrEmpty(lkpAttributeValue))
            {
                selectedAttributeValue = lkpAttributeValue;

                LookupCodeDa da = new LookupCodeDa();
                DataView     dv = da.GetLookupCodeAttributesByLkpFieldAndAttribute(lkFieldName, int.Parse(lkpAttributeId), lkpAttributeValue).DefaultView;
                LookupAttributesGrid.DataSource = dv;
                LookupAttributesGrid.DataBind();
                GridPanel.Visible = true;
                UpdateBtn.Visible = true;
            }
            else
            {
                GridPanel.Visible = false;
                UpdateBtn.Visible = false;
            }
            dirtyRows = new List <int>();
        }
Beispiel #3
0
 /// <summary>
 /// Get mapping of chron items to color
 /// </summary>
 /// <param name="lkpFieldName">The lkp field assocaited to colors by attribute</param>
 private IDictionary <string, Color> GetDefaultColors(string lkpFieldName)
 {
     if (!string.IsNullOrEmpty(lkpFieldName))
     {
         // build simple lookup for var name > color
         DataTable colorsDt = new LookupCodeDa().GetLookupCodesAttributeValues(lkpFieldName, "Color");
         var       lookup   = from row in colorsDt.AsEnumerable()
                              let lkpCode = row[LookupCode.LkpCode].ToString()
                                            let lkpAttributeValue = row[LookupCodeAttribute.AttributeValue].ToString()
                                                                    group lkpAttributeValue by lkpCode into g
                                                                    let lkpCode                         = g.First()
                                                                                              let color = !string.IsNullOrEmpty(lkpCode) ? (lkpCode.StartsWith("#") ? System.Drawing.ColorTranslator.FromHtml(lkpCode) : System.Drawing.Color.FromName(lkpCode)) : DEFAULT_CHRON_COLOR
                                                                                                          select new
         {
             Code  = g.Key,
             Color = color
         };
         // convert mapping to lookup of var to Color
         return(lookup.ToDictionary(k => k.Code, k => k.Color));
     }
     else
     {
         return(new Dictionary <string, Color>());
     }
 }
Beispiel #4
0
        /// <summary>
        /// Builds a grid populated with the current LkpFieldName
        /// </summary>
        /// <param name="lkpField"></param>
        private bool BuildLookupCodeList(string lkpField)
        {
            InitParamaters();

            LookupCodeDa da       = new LookupCodeDa();
            var          lkpCodes = LookupCode.GetByFieldsAsDataView <LookupCode>(new Dictionary <string, object>
            {
                { LookupCode.LkpFieldName, lkpField }
            });
            // sort by, then alpha numeric
            DataColumn sortCol  = new DataColumn("_Sort", typeof(int), "ISNULL(LkpOrder," + int.MaxValue + ")");
            DataColumn sortCol2 = new DataColumn("_Sort2", typeof(int), "ISNULL(LookupCodeId," + int.MaxValue + ") - ISNULL(LookupCodeId," + int.MaxValue + " - 1)");

            lkpCodes.Table.Columns.Add(sortCol);
            lkpCodes.Table.Columns.Add(sortCol2);
            lkpCodes.Sort = "_Sort ASC, _Sort2 ASC, " + LookupCode.LkpCode + " ASC";
            // build main lookup code list

            LookupCodeGrid.DataSource = lkpCodes;
            LookupCodeGrid.DataBind();

            DataSet   ds = da.GetLookupCodeStats(lkpField, _diseaseName);
            DataTable lookupByMetadata   = ds.Tables[0];
            int       lookupCodeCount    = (int)ds.Tables[1].Rows[0][0];
            int       lookupDiseaseCount = (int)ds.Tables[2].Rows[0][0];

            BuildLkpStats(lookupByMetadata, lookupDiseaseCount, lookupCodeCount);

            return(lookupCodeCount > 0);
        }
Beispiel #5
0
    protected void SetSiteItems()
    {
        DataView view = LookupCodeDa.GetLookupData("SpecimenSites", "SiteId", "SiteName", "", "");

        RptSite.DataSource = view;
        RptSite.DataBind();
    }
Beispiel #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void HandleLookupDeleteClick(object sender, CommandEventArgs e)
        {
            int          lkpCodeId = int.Parse(e.CommandArgument.ToString());
            LookupCodeDa da        = new LookupCodeDa();

            da.DeleteLookupCode(lkpCodeId);
            BuildStageStageEventsAndAttributes();
        }
Beispiel #7
0
        protected void GetCodes()
        {
            string       lkpField = Request.Form[LookupCodeFieldName];
            LookupCodeDa da       = new LookupCodeDa();
            DataTable    dt       = da.GetLookupsByFieldName(lkpField).Tables[0];
            string       codes    = "{ \"codes\": " + GetOutputArray(dt) + " }";

            Response.Write(codes);
        }
Beispiel #8
0
        protected void BindLookupCodeDropDowns()
        {
            LookupCodeDa da = new LookupCodeDa();
            DataTable    lookupDataSource = da.GetLookupFieldNames().Tables[0];

            LookupCodes.DataSource = lookupDataSource;
            LookupCodes.DataBind();
            ChildLookupCodeField.DataSource = lookupDataSource;
            ChildLookupCodeField.DataBind();
        }
Beispiel #9
0
        /// <summary>
        /// Helper function used to create child records for projects based on lookup codes
        /// </summary>
        /// <param name="parentBizo"></param>
        /// <param name="childBizo"></param>
        /// <param name="parentBizoNameField"></param>
        /// <param name="childBizoNameField"></param>
        /// <param name="PARENT_LKP_FIELD_TYPE"></param>
        /// <param name="CHILD_LKP_FIELD_TYPE"></param>
        /// <param name="validate">Whether to check if parent has child records before inserting</param>
        /// <param name="doSave">true if to save populated biz objects before returning </param>
        /// <returns></returns>
        private static List <BusinessObject> CreateChildRecordByBizLkpCodes(BusinessObject parentBizo, BusinessObject childBizo, string parentBizoNameField, string childBizoNameField, string PARENT_LKP_FIELD_TYPE, string CHILD_LKP_FIELD_TYPE, bool validate, bool doSave)
        {
            List <BusinessObject> childBizList = new List <BusinessObject>();
            int    bizPriKey    = int.Parse(parentBizo[parentBizo.PrimaryKeyName].ToString());
            string bizNameField = parentBizo[parentBizoNameField].ToString();

            // Check child Bizo to ensure no records have been created

            //BusinessObject checker = BusinessObjectFactory.BuildBusinessObject(childBizo.TableName);
            //checker.GetByParent(bizPriKey);
            //if (checker.RecordCount > 0 && validate)
            //{
            //    return childBizList;
            //}

            if (validate)
            {
                string tablename     = childBizo.TableName;
                string parentKeyName = BusinessObject.GetParentKeyName(tablename);
                var    criteria      = new Dictionary <string, object>()
                {
                    { parentKeyName, bizPriKey }
                };

                if (BusinessObject.Exists(tablename, criteria))
                {
                    return(childBizList);
                }
            }

            LookupCodeDa da = new LookupCodeDa();

            DataRow[] lkpRecords = da.GetLookupsByFieldName(PARENT_LKP_FIELD_TYPE).Tables[0].Select("", LKP_SORT_ORDER);

            foreach (DataRow lkpRecord in lkpRecords)
            {
                string lkpCode = lkpRecord[LookupCode.LkpCode].ToString();
                if (lkpCode == bizNameField)
                {
                    int       lkpCodeId       = int.Parse(lkpRecord[LookupCode.LookupCodeId].ToString());
                    DataRow[] childLkpRecords = da.GetChildCodesByLookupIdAndChildLookupName(lkpCodeId, CHILD_LKP_FIELD_TYPE).Select("", LKP_SORT_ORDER);
                    foreach (DataRow childLkpRecord in childLkpRecords)
                    {
                        string         childLkpCode = childLkpRecord[LookupCode.LkpCode].ToString();
                        BusinessObject childBiz     = BusinessObjectFactory.BuildBusinessObject(childBizo.TableName);
                        childBiz[childBiz.ParentKeyName] = bizPriKey;
                        childBiz[childBizoNameField]     = childLkpCode;
                        childBiz.Save();

                        childBizList.Add(childBiz);
                    }
                }
            }
            return(childBizList);
        }
Beispiel #10
0
        protected override void Page_Load(object sender, EventArgs e)
        {
            bool requestFromMetaDataPage = false;

            // if page is launched from meta data page populate with lookup code values based on query string
            if (Request.QueryString["lookupCodeValue"] != null)
            {
                requestFromMetaDataPage = true;
                PopulateLookupFieldDropDown();
                fieldName.SelectedValue = Request.QueryString["lookupCodeValue"].ToString();
            }

            lkpName.Disabled = true;

            if (Page.IsPostBack || requestFromMetaDataPage)
            {
                //get look up codes for posted field name
                if (fieldName.SelectedValue != null && fieldName.SelectedValue.Length > 0)
                {
                    lkpName.Value = fieldName.SelectedValue;

                    LookupCodeDa lkpDa = new LookupCodeDa();
                    DataSet      lkpDs = lkpDa.GetLookupsByFieldName(fieldName.SelectedValue);

                    if (lkpDs.Tables[0].Rows.Count > 0)
                    {
                        //show repeater table
                        repeaterDiv.Visible = true;
                        //hide table
                        tableDiv.Visible = false;
                        addBtn.Visible   = true;

                        if (!Page.IsPostBack)
                        {
                            BindLookupCodesGrid();
                        }
                    }
                }
                else
                {
                    repeaterDiv.Visible = false;
                    tableDiv.Visible    = false;
                    addBtn.Visible      = false;
                }
            }
            else
            {
                //hide
                repeaterDiv.Visible = false;
                tableDiv.Visible    = false;

                //populate the lookup field name drop down
                PopulateLookupFieldDropDown();
            }
        }
Beispiel #11
0
        protected void BuildCommonProblems()
        {
            LookupCodeDa lDa = new LookupCodeDa();
            DataTable    lDt = lDa.GetLookupCodes("Problem");

            if (lDt.Rows.Count > 0)
            {
                CommonProblems.DataSource = lDt.DefaultView;
                CommonProblems.DataBind();
            }
        }
Beispiel #12
0
        protected void GetCodesByParentIdAndChildFieldName()
        {
            int          parentLkpId    = int.Parse(Request.Form[ParentLookupId]);
            string       childFieldName = Request.Form[ChildLookupFieldName];
            LookupCodeDa da             = new LookupCodeDa();
            DataTable    lookupCodes    = da.GetLookupCodesExcludingCodesByParentLookupId(parentLkpId, childFieldName);
            DataTable    childNodes     = da.GetChildCodesByLookupIdAndChildLookupName(parentLkpId, childFieldName);
            string       codes          = "{ \"codes\": " + GetOutputArray(lookupCodes) + ", \"childCodes\": " + GetOutputArray(childNodes) + " }";

            Response.Write(codes);
        }
        protected void BuildCommonPlans()
        {
            LookupCodeDa lDa = new LookupCodeDa();
            DataTable    lDt = lDa.GetLookupCodes("ProblemPlan,Disease,Osteoporosis");

            if (lDt.Rows.Count > 0)
            {
                CommonPlans.DataSource = lDt.DefaultView;
                CommonPlans.DataBind();
            }
        }
Beispiel #14
0
        protected void BuildFilterByParent(object sender, EventArgs e)
        {
            string filterLkpCodeId = FilterByParentLkpCodes.Value;

            if (!string.IsNullOrEmpty(filterLkpCodeId))
            {
                LookupCodeDa da = new LookupCodeDa();
                var          currentChildCodes = da.GetChildCodesByLookupIdAndChildLookupName(int.Parse(filterLkpCodeId), CurrentLkpFieldName.Value);
                SetLookupCodeGridFilter(currentChildCodes, "ApplyToParent", LookupParentChildCode.ParentChildCodeId);
            }
        }
Beispiel #15
0
        protected void BuildLookupCodeByAttribute(object sender, EventArgs e)
        {
            string lkpAttributeId    = FilterByAttributeNames.Value;
            string lkpAttributeValue = FilterByAttributeValues.Value;

            if (!string.IsNullOrEmpty(lkpAttributeValue))
            {
                LookupCodeDa da = new LookupCodeDa();
                var          codeByAttribute = da.GetLookupCodeAttributesByLkpFieldAndAttribute(CurrentLkpFieldName.Value, int.Parse(lkpAttributeId), lkpAttributeValue);
                SetLookupCodeGridFilter(codeByAttribute, "ApplyToAttribute", LookupCodeAttribute.LookupCodeAttributeId);
            }
        }
        /// <summary>
        ///
        /// </summary>
        private void BuildDropDownLists()
        {
            LookupCodeDa da             = new LookupCodeDa();
            DataTable    lookupCodeList = da.GetLookupFieldNames().Tables[0];

            LookupCodesList.DataSource = lookupCodeList;
            LookupCodesList.DataBind();

            // Bind dropdown list
            LookupAttributesList.DataSource = LookupAttributesDataView;
            LookupAttributesList.DataBind();
        }
Beispiel #17
0
        protected void PopulateLookupFieldDropDown()
        {
            LookupCodeDa da = new LookupCodeDa();
            DataSet      ds = da.GetLookupFieldNames();

            if (ds.Tables.Count > 0)
            {
                fieldName.DataSource     = ds.Tables[0].DefaultView;
                fieldName.DataTextField  = "LkpFieldName";
                fieldName.DataValueField = "LkpFieldName";
                fieldName.DataBind();
            }
        }
Beispiel #18
0
        protected void BuildFilterByParentLkpCodes(object sender, EventArgs e)
        {
            FilterByParentLkpCodes.Items.Clear();

            string lkpField = FilterByParentLkpFieldNames.Value;

            if (!string.IsNullOrEmpty(lkpField))
            {
                LookupCodeDa da       = new LookupCodeDa();
                var          lkpCodes = da.GetLookupsByFieldName(lkpField).Tables[0].DefaultView;
                FilterByParentLkpCodes.DataSource = lkpCodes;
                FilterByParentLkpCodes.DataBind();
            }
        }
Beispiel #19
0
        protected void BuildPhysicianJSRepeater(string PhysicianType, Repeater PhysicianRepeater)
        {
            string LkpString = "OpSurgeon,PhysicianType," + PhysicianType;


            LookupCodeDa lDa = new LookupCodeDa();
            DataTable    lDt = lDa.GetLookupCodes(LkpString);

            if (lDt.Rows.Count > 0)
            {
                PhysicianRepeater.DataSource = lDt.DefaultView;
                PhysicianRepeater.DataBind();
            }
        }
Beispiel #20
0
        protected void RemoveAssociations()
        {
            LookupCodeDa da          = new LookupCodeDa();
            string       parentLkpId = Request.Form[ParentLookupId];
            string       keyList     = Request.Form[ChildLookupCodeIdList];

            if (!string.IsNullOrEmpty(parentLkpId) && !string.IsNullOrEmpty(keyList))
            {
                int      parentKey = int.Parse(parentLkpId);
                string[] childKeys = keyList.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                da.RemoveChildCodes(parentKey, childKeys);
            }
            GetCodesByParentIdAndChildFieldName();
        }
        protected override void Page_Load(object sender, System.EventArgs e)
        {
            base.Page_Load(sender, e);
            BuildChemoTx(this._patientId, "", "Dynamic");
            base.SetTitle(ComponentTitle);

            LookupCodeDa lpcDa  = new LookupCodeDa();
            DataTable    lpcDt  = lpcDa.GetLookupCodes("MedTxAgent");
            DataTable    lpcDt2 = lpcDa.GetLookupCodes("MedTxType");

            SetNewAgentLookupCode(MedTxAgent_6, lpcDt, MedTxType_6, lpcDt2);
            SetNewAgentLookupCode(MedTxAgent_7, lpcDt, MedTxType_7, lpcDt2);
            SetNewAgentLookupCode(MedTxAgent_8, lpcDt, MedTxType_8, lpcDt2);
            SetNewAgentLookupCode(MedTxAgent_9, lpcDt, MedTxType_9, lpcDt2);
            SetNewAgentLookupCode(MedTxAgent_10, lpcDt, MedTxType_10, lpcDt2);
        }
Beispiel #22
0
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            LookupCodeDa da           = new LookupCodeDa();
            DataView     procNameView = da.GetLookupCodesByAttributeByNameAndValue("ProcName", "Baseline Form Prostate", "PCCTC").DefaultView;

            if (procNameView.Count == 0)
            {
                procNameView = CacheManager.GetLookupCodeList("ProcName").DefaultView;
            }
            if (procNameView.Count > 0)
            {
                procNameView.Sort    = LookupCode.LkpCode + " ASC";
                procedureLookupNames = procNameView.ToTable();
            }
        }
Beispiel #23
0
        protected void BindLookupCodesGrid()
        {
            string selectedFieldName = fieldName.SelectedValue;

            if (!string.IsNullOrEmpty(selectedFieldName))
            {
                LookupCodeDa lkpDa = new LookupCodeDa();
                DataSet      lkpDs = lkpDa.GetLookupsByFieldName(selectedFieldName);
                DataView     view  = lkpDs.Tables[0].DefaultView;
                // Add empty rows
                for (int i = 0; i < BLANK_LOOKUPCODE_ROWS; i++)
                {
                    view.AddNew();
                }
                LookupCodeGrid.DataSource = view;
                LookupCodeGrid.DataBind();
            }
        }
Beispiel #24
0
        /// <summary>
        /// Builds a list of default idenfitiers used for default search parameters
        /// as well as identifier on various forms.
        /// </summary>
        private void BuildDefaultIdentifiers()
        {
            // determine if list should be Shown
            string showIdentifierOnLogin = CaisisConfiguration.GetWebConfigValue("ShowIdentifiersOnLogin");

            // only build and show list if web config key explicity set to true
            if (!string.IsNullOrEmpty(showIdentifierOnLogin) && bool.Parse(showIdentifierOnLogin))
            {
                LookupCodeDa lkpDa         = new LookupCodeDa();
                DataView     defaultIdList = lkpDa.GetLookupCodesAttributeValues("IdType", "UseAsDefault").DefaultView;
                DefaultIdentifiersRadioList.DataSource = defaultIdList;
                DefaultIdentifiersRadioList.DataBind();

                // only show identifiers radio when values exist
                if (defaultIdList.Count > 0)
                {
                    // show list
                    IdentifiersPanel.Visible = true;
                    // select value in list if in cookie
                    HttpCookie defaultIdTypeCookie = GetDefaultIdTypeCookie();
                    if (defaultIdTypeCookie != null)
                    {
                        string defaultIdType = defaultIdTypeCookie.Value;
                        // if a value exists in cookie, check default radio
                        if (!string.IsNullOrEmpty(defaultIdType))
                        {
                            foreach (ListItem item in DefaultIdentifiersRadioList.Items)
                            {
                                if (item.Value == defaultIdType)
                                {
                                    item.Selected = true;
                                    break;
                                }
                            }
                        }
                    }
                }
                else
                {
                    IdentifiersPanel.Visible = false;
                }
            }
        }
Beispiel #25
0
        /// <summary>
        /// Builds checkbox matrix to allow selecting organizations and stages
        /// </summary>
        private void BuildCheckBoxMatrix()
        {
            LookupCodeDa lookupDa = new LookupCodeDa();

            // Set Global Organization List (controls columns)
            organizationListDataView = da.GetAllOrganizationsByProjectId(projectId).DefaultView;
            allProjectStageEvents    = da.GetStageEventsByProject(projectId).DefaultView;

            // Determine if we need to filter organization
            if (!string.IsNullOrEmpty(OrganizationId))
            {
                organizationListDataView.RowFilter = ProjectOrganization.OrganizationId + " = " + OrganizationId;
            }

            // Gets all Stage names based on Lookup Codes
            DataTable stagesLkpCodes = lookupDa.GetLookupsByFieldName("ProjectStages").Tables[0];

            // Bind Organization Header Items
            OrgListRptr.DataSource = organizationListDataView;
            OrgListRptr.DataBind();

            // Bind Stages
            //ProjectStage projectStages = new ProjectStage();
            //projectStages.GetByParent(projectId);
            //orgStageRecords = projectStages.DataSourceView;

            orgStageRecords = BusinessObject.GetByParentAsDataView <ProjectStage>(projectId);

            if (orgStageRecords.Count == 0)
            {
                ProjectMgmtUtil.CreateProjectChildRecords(projectId);
                //projectStages.GetByParent(projectId);
                //orgStageRecords = projectStages.DataSourceView;

                orgStageRecords = BusinessObject.GetByParentAsDataView <ProjectStage>(projectId);
            }

            orgStageRecords.RowFilter = ProjectStage.OrganizationId + " IS NULL";

            //StagesRptr.DataSource = stagesLkpCodes;
            StagesRptr.DataSource = orgStageRecords;
            StagesRptr.DataBind();
        }
Beispiel #26
0
 /// <summary>
 /// Sets the color AttributeId used for updating attributes for setting colors with stages
 /// </summary>
 private void SetColorAttributeId()
 {
     if (!Page.IsPostBack)
     {
         LookupCodeDa da             = new LookupCodeDa();
         DataView     colorAttibutes = da.GetLookupAttributeByName("Color").DefaultView;
         if (colorAttibutes.Count > 0)
         {
             int attId = int.Parse(colorAttibutes[0][LookupAttribute.AttributeId].ToString());
             ColorAttributeId.Value = attId.ToString();
             int attributeId = int.Parse(ColorAttributeId.Value);
             stageColorCodeAttributes = da.GetLookupCodeAttributesByAttributeId(attributeId);
         }
     }
     else
     {
         int attributeId = int.Parse(ColorAttributeId.Value);
         stageColorCodeAttributes = da.GetLookupCodeAttributesByAttributeId(attributeId);
     }
 }
Beispiel #27
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string output      = "";
            string methodName  = Request.Form["methodName"];
            string lookupField = Request.Form["field"];
            string searchTerm  = Request.Form["search"];
            bool   isDistinct  = string.IsNullOrEmpty(Request.Form["isDistinct"]) ? false : bool.Parse(Request.Form["isDistinct"]);

            switch (methodName)
            {
            case ("GetParentCodeByChildCode"):
                string       childLkpField  = Request.Form["childLkpField"];
                string       childLkpCode   = Request.Form["childLkpCode"];
                string       parentLkpField = Request.Form["parentLkpField"];
                LookupCodeDa da             = new LookupCodeDa();
                DataTable    dt             = da.GetParentLookupCodeByChildCode(parentLkpField, childLkpField, childLkpCode);
                // 0 || > 1 results, return empty value (prevent ambiguity)
                output = dt.Rows.Count == 1 ? dt.Rows[0][LookupCode.LkpCode].ToString() : "";
                break;

            default:
                if (!string.IsNullOrEmpty(lookupField))
                {
                    DataTable lkpTable = GetLookupCodes(lookupField, isDistinct);
                    if (lkpTable.Columns.Contains(LookupCode.LkpCode))
                    {
                        string[] lkpFields = new string[] { LookupCode.LkpCode, LookupCode.LkpDescription };
                        output = PageUtil.DataTableToJSArray(lkpTable, lkpFields, false);
                    }
                    else
                    {
                        string[] lkpFields = new string[] { "DropDownValue", "DropDownText" };
                        output = PageUtil.DataTableToJSArray(lkpTable, lkpFields, false);
                    }
                }
                break;
            }


            Response.Write(output);
        }
        /// <summary>
        /// Returns true if the selected ProjectType needs an approval record, else false.
        /// </summary>
        /// <param name="projectType"></param>
        /// <returns></returns>
        private bool FormNeedsApprovalStep(string projectType)
        {
            LookupCodeDa da = new LookupCodeDa();
            // LookupCode ProjectApprovalType should contain a single lookup value
            // used to link child codes as needing approval step.
            DataTable dt = da.GetLookupsByFieldName("ProjectApprovalType").Tables[0];

            DataRow[] singleType = dt.Select("LkpCode = 'ProjectApprovalType'");
            if (singleType.Length > 0)
            {
                int parentCodeId = int.Parse(singleType[0]["LookupCodeId"].ToString());
                // Get all the ProjectTypes which need approval
                DataTable childCodes = da.GetChildCodesByLookupIdAndChildLookupName(parentCodeId, "ProjectType");
                // If projectType is in this list, we need an approval step
                if (childCodes.Select("LkpCode = '" + PageUtil.EscapeSingleQuotesForSql(projectType) + "'").Length > 0)
                {
                    return(true);
                }
            }
            return(false);
        }
Beispiel #29
0
        protected void GetAllCodesByParentId()
        {
            int          parentLkpId  = int.Parse(Request.Form[ParentLookupId]);
            LookupCodeDa da           = new LookupCodeDa();
            DataTable    results      = da.GetChildsCodeByLookupId(parentLkpId);
            string       outputBuffer = "[";
            string       s            = "";

            foreach (DataRow row in results.Rows)
            {
                string lkpFieldName = row[LookupCode.LkpFieldName].ToString();
                if (lkpFieldName != s)
                {
                    outputBuffer += "{ \"field\" : '" + lkpFieldName + "', \"codes\": " + GetOutputArray(results.Select("LkpFieldName = '" + lkpFieldName + "'")) + " } ,";
                    s             = lkpFieldName;
                }
            }
            outputBuffer  = outputBuffer.TrimEnd(",".ToCharArray());
            outputBuffer += "]";
            Response.Write(outputBuffer);
        }
Beispiel #30
0
        protected void EditButtonClick(object sender, CommandEventArgs e)
        {
            tableDiv.Visible = true;

            //sally added
            //this.repeaterDiv.Visible = false;

            tblAddBtn.Visible = false;
            updateBtn.Visible = true;

            int          lkpId = int.Parse(e.CommandName);
            LookupCodeDa da    = new LookupCodeDa();
            DataSet      ds    = da.GetLookupCodesRecord(lkpId);
            DataRow      dr    = ds.Tables[0].Rows[0];

            lkpOrder.Value       = dr[LookupCode.LkpOrder].ToString();
            lkpCodeId.Value      = dr["LookupCodeId"].ToString();
            lkpFieldName.Value   = dr["LkpFieldName"].ToString();
            lkpValue.Value       = dr["LkpCode"].ToString();
            lkpDescription.Value = dr["LkpDescription"].ToString();
            lkpSuppress.Checked  = bool.Parse(dr["LkpSuppress"].ToString());
        }