private void SetTreeNode(TreeNode treeNode, AuthorizationDS.OrganizationUnitRow ou)
 {
     treeNode.Text         = ou.OrganizationUnitName;
     treeNode.Value        = "OU" + ou.OrganizationUnitId;
     treeNode.ShowCheckBox = false;
     treeNode.ImageUrl     = "../Images/department.png";
 }
    private TreeNode NewTreeNode(AuthorizationDS.OrganizationUnitRow ou)
    {
        TreeNode treeNode = new TreeNode();

        this.SetTreeNode(treeNode, ou);
        return(treeNode);
    }
    protected void AddRootOrganizationUnitBtn_Click(object sender, EventArgs e)
    {
        string strTypeId = this.RootUnitTypeCtl.SelectedValue;
        int?   typeId    = null;

        if (strTypeId.Length == 0)
        {
            typeId = null;
        }
        else
        {
            typeId = int.Parse(strTypeId);
        }
        int?costCenterID = null;

        if (this.RootCostCenterDDL.SelectedValue != "0")
        {
            costCenterID = int.Parse(this.RootCostCenterDDL.SelectedValue);
        }
        AuthorizationDS.OrganizationUnitRow organizationUnit = this.AuthBLL.AddOrganizationUnit(this.RootUnitNameCtl.Text, this.RootUnitCodeCtl.Text, null, typeId, costCenterID);
        this.OrganizationTreeView.Nodes.Add(NewTreeNode(organizationUnit));
        this.RootUnitNameCtl.Text            = "";
        this.RootUnitCodeCtl.Text            = "";
        this.RootUnitTypeCtl.SelectedIndex   = 0;
        this.RootCostCenterDDL.SelectedIndex = 0;
    }
 private void SetTreeNode(TreeNode treeNode, AuthorizationDS.OrganizationUnitRow ou)
 {
     treeNode.Text         = ou.OrganizationUnitName;
     treeNode.Value        = NodeValue.FromObject(ou).ToString();
     treeNode.ShowCheckBox = true;
     treeNode.ImageUrl     = "~/Images/department.png";
 }
    protected void AddOrganizationUnitBtn_Click(object sender, EventArgs e)
    {
        TreeNode  parentNode      = this.OrganizationTreeView.SelectedNode;
        NodeValue parentNodeValue = NodeValue.Parse(parentNode.Value);
        string    strTypeId       = this.NewUnitTypeCtl.SelectedValue;
        int?      typeId          = null;

        if (strTypeId.Length == 0)
        {
            typeId = null;
        }
        else
        {
            typeId = int.Parse(strTypeId);
        }
        int?costCenterID = null;

        if (this.NewCostCenterDDL.SelectedValue != "0")
        {
            costCenterID = int.Parse(this.NewCostCenterDDL.SelectedValue);
        }

        AuthorizationDS.OrganizationUnitRow newOU = this.AuthBLL.AddOrganizationUnit(this.NewUnitNameCtl.Text, this.NewUnitCodeCtl.Text, parentNodeValue.ObjectId, typeId, costCenterID);
        parentNode.ChildNodes.Add(NewTreeNode(newOU));
        this.ClearNewOUPanel();
    }
    private TreeNode CreateOUTreeNode(AuthorizationDS.OrganizationUnitRow organizationUnit)
    {
        AuthorizationDS.OrganizationUnitRow[] childOU;
        if ((bool)this.ViewState["ShowActiveOU"])
        {
            childOU = organizationUnit.GetActiveChildren();
        }
        else
        {
            childOU = organizationUnit.GetChildren();
        }

        TreeNode newNode = NewTreeNode(organizationUnit);

        foreach (AuthorizationDS.OrganizationUnitRow subOU in childOU)
        {
            newNode.ChildNodes.Add(CreateOUTreeNode(subOU));
        }
        AuthorizationDS.PositionRow[] childPosition;
        if ((bool)this.ViewState["ShowActiveOU"])
        {
            childPosition = (AuthorizationDS.PositionRow[]) new PositionTableAdapter().GetActiveDataByOrganizationUnitId(organizationUnit.OrganizationUnitId).Select();
        }
        else
        {
            childPosition = organizationUnit.GetPositionRows();
        }

        foreach (AuthorizationDS.PositionRow position in childPosition)
        {
            newNode.ChildNodes.Add(NewTreeNode(position));
        }
        return(newNode);
    }
示例#7
0
    private static TreeNode CreateOUTreeNode(AuthorizationDS.OrganizationUnitRow organizationUnit, bool showPosition, bool checkOU, bool checkPosition, bool selectOU, bool selectPosition, bool showActiveOU)
    {
        TreeNode newNode = NewTreeNode(organizationUnit, checkOU, selectOU);

        AuthorizationDS.OrganizationUnitRow[] childOU;
        if (showActiveOU)
        {
            childOU = organizationUnit.GetActiveChildren();
        }
        else
        {
            childOU = organizationUnit.GetChildren();
        }
        foreach (AuthorizationDS.OrganizationUnitRow subOU in childOU)
        {
            newNode.ChildNodes.Add(CreateOUTreeNode(subOU, showPosition, checkOU, checkPosition, selectOU, selectPosition, showActiveOU));
        }
        if (showPosition)
        {
            foreach (AuthorizationDS.PositionRow position in organizationUnit.GetPositionRows())
            {
                newNode.ChildNodes.Add(NewTreeNode(position, checkPosition, selectPosition));
            }
        }
        return(newNode);
    }
        public static NodeValue FromObject(AuthorizationDS.OrganizationUnitRow organizationUnit)
        {
            NodeValue result = new NodeValue();

            result.ObjectId = organizationUnit.OrganizationUnitId;
            result.IsActive = organizationUnit.IsActive;
            result.OType    = ValueType.OU;
            return(result);
        }
    private TreeNode CreateOUTreeNode(AuthorizationDS.OrganizationUnitRow organizationUnit)
    {
        TreeNode newNode = NewTreeNode(organizationUnit);

        foreach (AuthorizationDS.OrganizationUnitRow subOU in organizationUnit.GetChildren())
        {
            newNode.ChildNodes.Add(CreateOUTreeNode(subOU));
        }
        foreach (AuthorizationDS.PositionRow position in organizationUnit.GetPositionRows())
        {
            newNode.ChildNodes.Add(NewTreeNode(position));
        }
        return(newNode);
    }
示例#10
0
    private static TreeNode NewTreeNode(AuthorizationDS.OrganizationUnitRow ou, bool checkOU, bool selectOU)
    {
        TreeNode treeNode = new TreeNode();

        treeNode.Text         = ou.OrganizationUnitName;
        treeNode.ShowCheckBox = checkOU;
        if (selectOU)
        {
            treeNode.SelectAction = TreeNodeSelectAction.Select;
        }
        else
        {
            treeNode.SelectAction = TreeNodeSelectAction.Expand;
        }
        treeNode.Value    = "OU" + ou.OrganizationUnitId;
        treeNode.ImageUrl = "~/Images/department.png";
        return(treeNode);
    }
    protected void UpdataOrganizationUnitBtn_Click(object sender, EventArgs e)
    {
        try {
            NodeValue nodeValue = NodeValue.Parse(this.OrganizationTreeView.SelectedNode.Value);
            string    strTypeId = this.UnitTypeCtl.SelectedValue;
            int?      typeId    = null;
            if (strTypeId.Length == 0)
            {
                typeId = null;
            }
            else
            {
                typeId = int.Parse(strTypeId);
            }
            int?costCenterID = null;
            if (this.CostCenterDDL.SelectedValue != "0")
            {
                costCenterID = int.Parse(this.CostCenterDDL.SelectedValue);
            }

            this.AuthBLL.UpdateOrganizationUnit(nodeValue.ObjectId, this.UnitNameCtl.Text, this.UnitCodeCtl.Text, typeId, costCenterID);
            AuthorizationDS.OrganizationUnitRow ou = this.AuthBLL.ActiveOrganizationUnit(nodeValue.ObjectId, this.UnitIsActiveCtl.Checked);
            this.SetTreeNode(this.OrganizationTreeView.SelectedNode, ou);
            if (ou.IsActive)
            {
                this.NewOUPanelArea.Style["Display"]       = "";
                this.NewPositionPanelArea.Style["Display"] = "";
            }
            else
            {
                this.NewOUPanelArea.Style["Display"]       = "none";
                this.NewPositionPanelArea.Style["Display"] = "none";
            }
            //this.NewOUPanel.Update();
            //this.NewPositionPanel.Update();
            PageUtility.ShowModelDlg(this, "更新成功");
        } catch (ApplicationException ex) {
            PageUtility.DealWithException(this, ex);
        }
    }
    protected void OrganizationTreeView_SelectedNodeChanged(object sender, EventArgs e)
    {
        if (this.OrganizationTreeView.SelectedNode != null)
        {
            NodeValue nodeValue = NodeValue.Parse(this.OrganizationTreeView.SelectedNode.Value);
            switch (nodeValue.OType)
            {
            case NodeValue.ValueType.OU:
                AuthorizationDS.OrganizationUnitRow organizationUnit = this.AuthBLL.GetOrganizationUnitById(nodeValue.ObjectId);
                this.UnitNameCtl.Text            = organizationUnit.OrganizationUnitName;
                this.UnitCodeCtl.Text            = organizationUnit.OrganizationUnitCode;
                this.UnitIsActiveCtl.Checked     = organizationUnit.IsActive;
                this.UnitTypeCtl.SelectedValue   = organizationUnit.IsOrganizationUnitTypeIdNull() ? "" : organizationUnit.OrganizationUnitTypeId.ToString();
                this.CostCenterDDL.SelectedValue = organizationUnit.IsCostCenterIDNull() ? "0" : organizationUnit.CostCenterID.ToString();

                this.ClearNewOUPanel();
                this.ClearNewPositionPanel();

                this.EditPositionPanelArea.Style["Display"] = "none";
                this.StuffPanel.Style["Display"]            = "none";
                this.EditOUPanelArea.Style["Display"]       = "";
                if (organizationUnit.IsActive)
                {
                    this.NewOUPanelArea.Style["Display"]       = "";
                    this.NewPositionPanelArea.Style["Display"] = "";
                }
                else
                {
                    this.NewOUPanelArea.Style["Display"]       = "none";
                    this.NewPositionPanelArea.Style["Display"] = "none";
                }
                break;

            case NodeValue.ValueType.Position:
                AuthorizationDS.PositionRow position = this.AuthBLL.GetPositionById(nodeValue.ObjectId);
                this.PositionNameCtl.Text        = position.PositionName;
                this.PositionIsActiveCtl.Checked = position.IsActive;
                this.PositionTypeCtl.ClearSelection();
                BusinessObjects.AuthorizationDS.PositionAndPositionTypeRow[] positionTypes = position.GetPositionAndPositionTypeRows();
                if (positionTypes == null || positionTypes.Length == 0)
                {
                    //this.PositionTypeCtl.SelectedIndex = 0;
                }
                else
                {
                    foreach (AuthorizationDS.PositionAndPositionTypeRow positionType in positionTypes)
                    {
                        foreach (ListItem li in this.PositionTypeCtl.Items)
                        {
                            if (li.Value.Equals(positionType.PositionTypeId.ToString()))
                            {
                                li.Selected = true;
                                break;
                            }
                        }
                    }
                }

                this.EditPositionPanelArea.Style["Display"] = "";
                this.StuffPanel.Style["Display"]            = "";
                this.PositionStuffDS.SelectParameters["PositionId"].DefaultValue = nodeValue.ObjectId.ToString();
                this.EditOUPanelArea.Style["Display"]      = "none";
                this.NewOUPanelArea.Style["Display"]       = "none";
                this.NewPositionPanelArea.Style["Display"] = "none";
                break;
            }
        }
        else
        {
            this.EditPositionPanelArea.Style["Display"] = "none";
            this.StuffPanel.Style["Display"]            = "none";
            this.EditOUPanelArea.Style["Display"]       = "none";
            this.NewOUPanelArea.Style["Display"]        = "none";
            this.NewPositionPanelArea.Style["Display"]  = "none";
        }
        //this.NewOUPanel.Update();
        //this.EditOUPanel.Update();
        //this.NewPositionPanel.Update();
        //this.EditPositionPanel.Update();
    }