Пример #1
0
    /// <summary>
    /// Fill the branches drop-down list.
    /// </summary>
    private void FillBrachesList()
    {
        PXToolBarContainer cont     = (PXToolBarContainer)tlbPath.Items["branch"];
        PXDropDown         dropDown = this.GetBranchCombo();

        if (ControlHelper.IsReloadPage(dropDown))
        {
            dropDown.CallbackUpdatable = true;
        }

        string currBranchId  = null;
        int?   currentBranch = PXAccess.GetBranchID();

        List <PXAccess.BranchCollection.Info> items = GetBranches().ToList();

        items.Sort((a, b) => string.Compare(a.Cd, b.Cd));

        dropDown.Items.Clear();
        foreach (PXAccess.BranchCollection.Info item in items)
        {
            var current = (currentBranch != null && currentBranch.Equals(item.Id));
            dropDown.Items.Add(new PXListItem(item.Name, item.Id.ToString()));
            if (current)
            {
                currBranchId = item.Id.ToString();
            }
        }

        if (PXAccess.FeatureInstalled("PX.Objects.CS.FeaturesSet+Branch") && dropDown.Items.Count > 0)
        {
            if (ControlHelper.IsReloadPage(tlbPath))
            {
                tlbPath.CallbackUpdatable = true;
            }
            if (currentBranch != null)
            {
                dropDown.Value = currBranchId;
            }
            else
            {
                dropDown.Items.Insert(0, new PXListItem("Select Branch", null));
            }
            dropDown.ItemChanged += Branch_ItemClick;
        }
        else
        {
            cont.Visible = false;
            PXToolBarLabel lbl = tlbPath.Items["branchLabel"] as PXToolBarLabel;
            if (lbl != null)
            {
                lbl.Visible = false;
            }
            lbl = tlbPath.Items["branchSep"] as PXToolBarLabel;
            if (lbl != null)
            {
                lbl.Visible = false;
            }
        }
    }
Пример #2
0
    /// <summary>
    /// Find the braches drop down control.
    /// </summary>
    private PXDropDown GetBranchCombo()
    {
        PXToolBarContainer cont     = (PXToolBarContainer)tlbPath.Items["branch"];
        PXDropDown         dropDown = null;

        foreach (Control c in cont.TemplateContainer.Controls)
        {
            if (c.ID == "cmdBranch")
            {
                dropDown = c as PXDropDown; break;
            }
        }
        return(dropDown);
    }