Ejemplo n.º 1
0
    /// <summary>
    /// 绑定Grid
    /// </summary>
    protected void BindGrid()
    {
        STreeBB treeBB = new STreeBB();
        DataSet ds = new DataSet();

        try
        {
            ds = treeBB.GetList(this.StrWhere);
            DataTable dt = ds.Tables[0];

            // 组合列表属性
            StringBuilder sBuilder = new StringBuilder();
            sBuilder.Append("编号|@itemNo|@|@left");
            sBuilder.Append("|!名称|@nodeNm|@|@left");
            sBuilder.Append("|!链接|@url|@|@left");

            //关联属性
            this.dataGrid.TitleDescription = sBuilder.ToString();
            this.dataGrid.DataSource = dt;
        }
        finally
        {
            treeBB.Dispose();
        }
    }
Ejemplo n.º 2
0
 private void RefreshApplicationTreeTable()
 {
     //更新全局页面URL缓存
     STreeBB treeBB = new STreeBB();
     try
     {
         Application["TreeTable"] = treeBB.GetApplicationTreeTable();
     }
     finally
     {
         treeBB.Dispose();
     }
 }
Ejemplo n.º 3
0
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        STreeData model = new STreeData();
        STreeBB treeBB = new STreeBB();
        try
        {
            //项目编号不允许重复
            if (treeBB.GetList("itemNo='" + this.itemNo.Text + "' and nodeId<>" + this.IdValue.ToString()).Tables[0].Rows.Count > 0)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert(\"该项目编号已存在,请重新输入!\");", true);
                this.itemNo.Focus();
                return;
            }

            if (this.State == "1")
            {
                this.SetModel(ref model);
                model.isEffect = true;
                this.IdValue = treeBB.AddRecord(model);
            }
            else if (this.State == "2")
            {
                model = treeBB.GetModel(this.IdValue);
                this.SetModel(ref model);
                treeBB.ModifyRecord(model);
            }

            this.RefreshApplicationPageUrlTable();
            this.RefreshApplicationTreeTable();
        }
        catch (Exception ex)
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
            return;
        }
        finally
        {
            treeBB.Dispose();
        }

        this.ClientScript.RegisterStartupScript(this.GetType(), "CloseSubmit", "CloseSubmit()", true);
    }
Ejemplo n.º 4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string idValue = Request.Params["id"];
            if (idValue != null)
            {
                int id = int.Parse(idValue);
                //删除节点的同时,删除TreeFunction、角色权限、人员权限
                STreeData treeData = new STreeData();
                STreeBB treeBB = new STreeBB();
                STreeFunctionBB treeFunctionBB = new STreeFunctionBB();
                PRolePermissionsBB rolePermissionsBB = new PRolePermissionsBB();
                PEmpPermissionsBB empPermissionsBB = new PEmpPermissionsBB();
                try
                {
                    treeData = treeBB.GetModel(id);
                    treeBB.DeleteRecord(id);
                    treeFunctionBB.DeleteRecordByNode(id);
                    rolePermissionsBB.DeleteRecordByItem(treeData.itemNo);
                    empPermissionsBB.DeleteRecordByItem(treeData.itemNo);

                    this.RefreshApplicationPageUrlTable();
                    this.RefreshApplicationTreeTable();

                    ClientScript.RegisterStartupScript(this.GetType(), "CloseSubmit", "CloseSubmit()", true);
                }
                catch (Exception ex)
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(), "ShowErr", "ShowErr(\"" + Server.UrlEncode(ex.Message) + "\",3);", true);
                    return;
                }
                finally
                {
                    treeBB.Dispose();
                    treeFunctionBB.Dispose();
                    rolePermissionsBB.Dispose();
                    empPermissionsBB.Dispose();
                }
            }
        }
    }
Ejemplo n.º 5
0
    private void ShowInfo(int id)
    {
        STreeBB treeBB = new STreeBB();
        STreeData model = new STreeData();

        try
        {
            model = treeBB.GetModel(id);
            this.itemNo.Text = model.itemNo;
            this.nodeNm.Text = model.nodeNm;
            this.parentNodeNm.Text = model.parentId.ToString();
            this.orderId.Text = model.orderId.ToString();
            this.url.Text = model.url;
            this.imageUrl.Text = model.imageUrl;
            this.isAlowManageOtherData.Checked = model.isAlowManageOtherData;
            this.isAlowSeeOtherData.Checked = model.isAlowSeeOtherData;
            this.isManageDepart.Checked = model.isManageDepart;
            this.comment.Text = model.comment;
        }
        finally
        {
            treeBB.Dispose();
        }
    }
    /// <summary>
    /// 根据树列表绑定DataList
    /// </summary>
    private void BindDataList()
    {
        STreeBB treeBB = new STreeBB();
        SCommBB commBB = new SCommBB();
        DataSet ds = new DataSet();

        try
        {
            //除了超级管理员,其他用户只能在自己的权限列表范围之内进行分配
            if (this.IsHaveRole(1))
            {
                ds = treeBB.GetList("");
            }
            else
            {
                ds = commBB.Query("select distinct nodeId,itemNo,nodeNm,orderId,parentId from vSTree where empId="
                    + this.currentUser.empId.ToString() + " order by itemNo");
            }
            DataTable dt = treeBB.ConvertTreeList(ds.Tables[0]);
            this.DataList1.DataSource = dt;
            this.DataList1.DataKeyField = "nodeId";
            this.DataList1.DataBind();
        }
        finally
        {
            treeBB.Dispose();
            commBB.Dispose();
        }
    }
Ejemplo n.º 7
0
    private void ShowInfo(int id)
    {
        STreeBB treeBB = new STreeBB();
        STreeData model = new STreeData();
        try
        {
            model = treeBB.GetModel(id);
            this.itemNo.Text = model.itemNo;
            this.nodeNm.Text = model.nodeNm;
            if (this.parentId.Items.FindByValue(model.parentId.ToString()) != null)
            {
                this.parentId.SelectedValue = model.parentId.ToString();
            }
            this.orderId.Text = model.orderId.ToString();
            this.url.Text = model.url;
            this.imageUrl.Value = model.imageUrl;
            this.isAlowManageOtherData.Checked = model.isAlowManageOtherData;
            this.isAlowSeeOtherData.Checked = model.isAlowSeeOtherData;
            this.isManageDepart.Checked = model.isManageDepart;
            this.comment.Text = model.comment;
            this.childPage.Text = model.childPage;

            this.ClientScript.RegisterStartupScript(this.GetType(), "LoadImg", "LoadImg()", true);
        }
        finally
        {
            treeBB.Dispose();
        }
    }
Ejemplo n.º 8
0
    /// <summary>
    /// 绑定父级菜单
    /// </summary>
    private void BindParentTree()
    {
        STreeBB treeBB = new STreeBB();
        DataSet ds = new DataSet();

        try
        {
            ds = treeBB.GetList("");
            DataTable dt = ds.Tables[0];

            //加载树
            this.parentId.Items.Clear();
            this.parentId.Items.Add(new ListItem("根目录", "0"));
            DataRow[] drs = dt.Select("parentId=0", "orderId");
            foreach (DataRow row in drs)
            {
                string nodeId = row["nodeID"].ToString();
                string text = row["nodeNm"].ToString();
                text = "╋" + text;
                this.parentId.Items.Add(new ListItem(text, nodeId));
                int parentId = int.Parse(nodeId);
                string blank = "├";

                this.BindNode(parentId, dt, blank);
            }
            this.parentId.DataBind();
        }
        finally
        {
            treeBB.Dispose();
        }
    }
Ejemplo n.º 9
0
        /// <summary>
        /// ��ȡ���߾���������Ա����sql���
        /// </summary>
        /// <param name="empId">��ǰ��ԱId</param>
        /// <param name="itemNo">itemNo</param>
        /// <param name="permissionsTypeNo">Ȩ������</param>
        /// <param name="empField">���ݱ���Ա�ֶ�</param>
        /// <param name="tableNm">���ݱ�����</param>
        /// <returns></returns>
        public string LoadUppMgrManageSql(int empId, string itemNo, string permissionsTypeNo, string empField, string tableNm)
        {
            if (itemNo == "")
            {
                return "";
            }

            string manageSql = "";

            STreeBB treeBB = new STreeBB();
            STreeData treeData = new STreeData();
            try
            {
                treeData = treeBB.GetModel(itemNo);
                //�ж��Ƿ�����鿴��������
                if (treeData.isAlowSeeOtherData)
                {
                    manageSql = "";
                }
                else
                {
                    //�жϵ�ǰģ���Ƿ����������������
                    //�жϵ�ǰ��Ա�Ե�ǰģ���Ƿ��й���Ȩ��
                    if (treeData.isAlowManageOtherData && this.eemployeeDB.HasPermissions(empId, itemNo, "manage"))
                    {
                        manageSql = "";
                    }
                    else
                    {
                        manageSql = @" and exists
            (
            select 1 from
            (
            select c.empId from dbo.HOrgnization a inner join HOrgnization b
            on a.departId=b.uppDepartId inner join dbo.HEemployee c
            on b.departId=c.nowDepartId
            where a.departLeader=" + empId.ToString() + @" and b.departLeader<>c.empId and a.isDel=0
            union all
            select c.departLeader from dbo.HOrgnization a inner join HOrgnization b
            on a.departId=b.uppDepartId inner join dbo.HOrgnization c
            on b.departId=c.uppDepartId
            where a.departLeader=" + empId.ToString() + @" and a.isDel=0 and c.isDel=0
            ) t
            where t.empId=" + tableNm + @"." + empField + @"
            )";
                    }
                }
            }
            finally
            {
                treeBB.Dispose();
            }

            return manageSql;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// ��ȡ��ǰ��Աlist����Ȩ�ޣ�����������Դͨ��inner join��������
        /// </summary>
        /// <param name="empId">��ǰ��ԱId</param>
        /// <param name="itemNo">itemNo</param>
        /// <param name="permissionsTypeNo">Ȩ������</param>
        /// <returns></returns>
        public string LoadManageSql(int empId, string itemNo, string permissionsTypeNo)
        {
            if (itemNo == "")
            {
                return "";
            }

            string manageSql = "";

            STreeBB treeBB = new STreeBB();
            STreeData treeData = new STreeData();
            try
            {
                treeData = treeBB.GetModel(itemNo);
                //�ж��Ƿ�����鿴��������
                if (treeData.isAlowSeeOtherData)
                {
                    manageSql = "";
                }
                else
                {
                    //�жϵ�ǰģ���Ƿ����������������
                    //�жϵ�ǰ��Ա�Ե�ǰģ���Ƿ��й���Ȩ��
                    if (treeData.isAlowManageOtherData && this.eemployeeDB.HasPermissions(empId, itemNo, "manage"))
                    {
                        manageSql = "";
                    }
                    else
                    {
                        //�ж��Ƿ��߸�����
                        //�жϼ�¼Я�����Ƿ��ڵ�ǰ��Ա�ĸ����ŷ�Χ֮��
                        if (treeData.isManageDepart)
                        {
                            //                            manageSql = " and (" + empTable + "." + empField + " = " + empId.ToString() + @" or exists (select 1 from vPDepartManageUser
                            //    where empId=" + empId + " and (roleId=0 or exists(select 1 from PRolePermissions where itemNo='" + itemNo + @"'
                            //        and permissionsTypeNo='" + permissionsTypeNo + "' and roleId=vPDepartManageUser.roleId)) and manageUserId=" + empTable + "." + empField + "))";

                            //֧�����νṹ
                            manageSql = @"
            (
            select distinct manageUserId from vPDepartManageUserTA
            where empId=" + empId + @" and (roleId=0 or exists(select 1 from PRolePermissions where itemNo='" + itemNo + @"'
            and permissionsTypeNo='" + permissionsTypeNo + @"' and roleId=vPDepartManageUserT.roleId))
            union select " + empId.ToString() + @"
            ) tmp";
                        }
                        else
                        {
                            manageSql = "(select " + empId.ToString() + " as manageUserId) tmp";
                        }
                    }
                }
            }
            finally
            {
                treeBB.Dispose();
            }

            return manageSql;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// ��֤�ͻ��Ƿ��й�����������Ȩ��
        /// </summary>
        /// <param name="empId">��ԱId</param>
        /// <param name="itemNo">��Ŀ���</param>
        /// <param name="permissionsTypeNo">Ȩ������</param>
        /// <param name="recordEmpId">��¼Я����</param>
        /// <returns></returns>
        public bool HasDataPermissions(int empId, string itemNo, string permissionsTypeNo, int recordEmpId)
        {
            if (itemNo == "")
            {
                return true;
            }

            bool ret = false;
            //���������¼Я����Ϊͬһ��
            if (empId == recordEmpId)
            {
                ret = true;
            }
            else
            {
                STreeBB treeBB = new STreeBB();
                STreeData treeData = new STreeData();
                try
                {
                    treeData = treeBB.GetModel(itemNo);
                    //�жϵ�ǰģ���Ƿ����������������
                    //�жϵ�ǰ��Ա�Ե�ǰģ���Ƿ��й���Ȩ��
                    if (treeData.isAlowManageOtherData && this.eemployeeDB.HasPermissions(empId, itemNo, "manage"))
                    {
                        ret = true;
                    }
                    else
                    {
                        //�ж��Ƿ��߸�����
                        //�жϼ�¼Я�����Ƿ��ڵ�ǰ��Ա�ĸ����ŷ�Χ֮��
                        if (treeData.isManageDepart && this.eemployeeDB.IsManage(empId, itemNo, permissionsTypeNo, recordEmpId))
                        {
                            ret = true;
                        }
                    }
                }
                finally
                {
                    treeBB.Dispose();
                }
            }
            return ret;
        }