示例#1
0
    private void SaveRight(TreeNodeCollection TNC)
    {
        IList <Right_Assign> assignlist = (IList <Right_Assign>)ViewState["RightAssign"];

        foreach (TreeNode node in TNC)
        {
            int model  = 1;
            int action = 1;
            if (node.Value.StartsWith("M"))
            {
                model  = int.Parse(node.Value.Substring(1));
                action = 1;
            }
            else
            {
                action = int.Parse(node.Value.Substring(1));

                if (node.Parent != null)
                {
                    model = int.Parse(node.Parent.Value.Substring(1));
                }
            }

            Right_Assign assign = assignlist.FirstOrDefault(m => m.Module == model && m.Action == action);
            if (node.Checked)
            {
                if (assign == null)
                {
                    Right_Assign_BLL bll = new Right_Assign_BLL();
                    bll.Model.Module   = model;
                    bll.Model.Action   = action;
                    bll.Model.RoleName = tr_Role.SelectedValue;
                    bll.Model.Based_On = 2;
                    bll.Add();
                }
            }
            else
            {
                if (assign != null)
                {
                    Right_Assign_BLL bll = new Right_Assign_BLL(assign.ID);
                    bll.Delete();
                }
            }

            if (node.ChildNodes.Count > 0)
            {
                SaveRight(node.ChildNodes);
            }
        }
    }
    protected void bt_SaveGridView_Click(object sender, EventArgs e)
    {
        foreach (GridViewRow row in gv_list.Rows)
        {
            CheckBox cb_check = (CheckBox)row.FindControl("cb_check");

            if (cb_check.Checked)
            {
                Right_Assign_BLL bll = new Right_Assign_BLL((int)gv_list.DataKeys[row.RowIndex][0]);
                bll.Delete();
            }
        }
        BindModuleTree();
    }
示例#3
0
    protected void bt_SaveGridView_Click(object sender, EventArgs e)
    {
        foreach (GridViewRow row in gv_list.Rows)
        {
            CheckBox cb_check = (CheckBox)row.FindControl("cb_check");

            if (cb_check.Checked)
            {
                Right_Assign_BLL bll = new Right_Assign_BLL((int)gv_list.DataKeys[row.RowIndex][0]);
                bll.Delete();
            }
        }
        BindModuleTree();
    }
    private void SaveRight(TreeNodeCollection TNC)
    {
        IList<Right_Assign> assignlist = (IList<Right_Assign>)ViewState["RightAssign"];
        foreach (TreeNode node in TNC)
        {
            int model = 1;
            int action = 1;
            if (node.Value.StartsWith("M"))
            {
                model = int.Parse(node.Value.Substring(1));
                action = 1;
            }
            else
            {
                action = int.Parse(node.Value.Substring(1));

                if (node.Parent != null)
                    model = int.Parse(node.Parent.Value.Substring(1));
            }

            Right_Assign assign = assignlist.FirstOrDefault(m => m.Module == model && m.Action == action);
            if (node.Checked)
            {
                if (assign == null)
                {
                    Right_Assign_BLL bll = new Right_Assign_BLL();
                    bll.Model.Module = model;
                    bll.Model.Action = action;
                    bll.Model.RoleName = tr_Role.SelectedValue;
                    bll.Model.Based_On = 2;
                    bll.Add();
                }
            }
            else
            {
                if (assign != null)
                {
                    Right_Assign_BLL bll = new Right_Assign_BLL(assign.ID);
                    bll.Delete();
                }
            }

            if (node.ChildNodes.Count > 0)
            {
                SaveRight(node.ChildNodes);
            }
        }
    }