コード例 #1
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        STreeFunctionData model = new STreeFunctionData();
        STreeFunctionBB treeFunctionBB = new STreeFunctionBB();
        try
        {
            //项目编号不允许重复
            string strWhere = "nodeId=" + this.NodeId.ToString() + " and functionNo='" + this.functionNo.Text + "'";
            if (treeFunctionBB.GetList(strWhere).Tables[0].Rows.Count > 0)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"该功能编号已存在,请重新输入!\");", true);
                this.functionNo.Focus();
                return;
            }

            model.nodeId= this.NodeId;
            model.functionNo= this.functionNo.Text;
            model.functionNm= this.functionNm.Text;
            treeFunctionBB.AddRecord(model);
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            treeFunctionBB.Dispose();
        }

        this.ClientScript.RegisterStartupScript(this.GetType(), "CloseSubmit", "CloseSubmit()", true);
    }
コード例 #2
0
    /// <summary>
    /// 根据当前人员绑定DataList
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        PEmpPermissionsBB empPermissionsBB = new PEmpPermissionsBB();
        STreeFunctionBB treeFunctionBB = new STreeFunctionBB();
        HEemployeeBB eemployeeBB = new HEemployeeBB();
        SCommBB commBB = new SCommBB();
        DataSet perDs = new DataSet();
        DataSet ds = new DataSet();
        try
        {
            HtmlInputHidden hid = (HtmlInputHidden)e.Item.FindControl("nodeId");
            string nodeId = hid.Value;

            Label label = (Label)e.Item.FindControl("itemNo");
            string itemNo = label.Text;
            if (itemNo.IndexOf('-') >= 0)
            {
                itemNo = itemNo.Substring(itemNo.LastIndexOf('-') + 1);
            }

            //除了超级管理员,其他用户只能在自己的权限列表范围之内进行分配
            if (this.IsHaveRole(1))
            {
                ds = treeFunctionBB.GetList("nodeId=" + nodeId);
            }
            else
            {
                ds = commBB.Query("select distinct permissionsTypeId,permissionsTypeNo as functionNo,permissionsTypeNm as functionNm from vSTree where empId="
                    + this.currentUser.empId.ToString() + " and nodeId=" + nodeId + " order by permissionsTypeId");
            }

            for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
            {
                DataRow row = ds.Tables[0].Rows[i];

                //添加文本“<TD></TD>"以控制格式
                HtmlGenericControl td = new HtmlGenericControl();
                td.InnerHtml = "</td><td>";
                e.Item.Controls.Add(td);

                CheckBox checkBox = new CheckBox();
                checkBox.ID = "checkBox" + i.ToString();
                checkBox.Text = row["functionNm"].ToString();
                checkBox.ToolTip = row["functionNo"].ToString();

                //给checkBox赋值
                if (eemployeeBB.HasPermissions(this.EmpId, itemNo, row["functionNo"].ToString()))
                {
                    checkBox.Checked = true;
                }
                e.Item.Controls.Add(checkBox);
            }
        }
        finally
        {
            empPermissionsBB.Dispose();
            treeFunctionBB.Dispose();
            eemployeeBB.Dispose();
            commBB.Dispose();
        }
    }
コード例 #3
0
 /// <summary>
 /// 初始化默认权限数据
 /// </summary>
 private void InitPermissionData()
 {
     PRolePermissionsBB rolePermissionsBB = new PRolePermissionsBB();
     STreeFunctionBB treeFunctionBB = new STreeFunctionBB();
     SCommBB commBB = new SCommBB();
     try
     {
         //除了超级管理员,其他用户只能在自己的权限列表范围之内进行分配
         if (this.IsHaveRole(1))
         {
             this.treeFunctionDs = treeFunctionBB.GetList("");
         }
         else
         {
             this.treeFunctionDs = commBB.Query("select distinct nodeId,permissionsTypeId,permissionsTypeNo as functionNo,permissionsTypeNm as functionNm from vSTree where empId="
                 + this.currentUser.empId.ToString() + " order by permissionsTypeId");
         }
         //获取岗位具体权限
         this.rolePermissionsDs = rolePermissionsBB.GetList("roleId=" + this.RoleId.ToString());
     }
     finally
     {
         rolePermissionsBB.Dispose();
         treeFunctionBB.Dispose();
         commBB.Dispose();
     }
 }
コード例 #4
0
    /// <summary>
    /// ���ݵ�ǰ��ɫ��Ȩ������grid
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
    {
        STreeFunctionBB treeFunctionBB = new STreeFunctionBB();
        DataSet ds = new DataSet();
        try
        {
            HtmlInputHidden hid = (HtmlInputHidden)e.Item.FindControl("typeNo");
            string typeNo = hid.Value;

            CheckBox checkBox = (CheckBox)e.Item.FindControl("typeNm");
            //��checkBox��ֵ
            ds = treeFunctionBB.GetList("nodeId=" + this.NodeId.ToString() + " and functionNo='" + typeNo + "'");
            if (ds.Tables[0].Rows.Count > 0)
            {
                checkBox.Checked = true;
            }
        }
        finally
        {
            treeFunctionBB.Dispose();
        }
    }