示例#1
0
        /// <summary>
        /// ����һ������
        /// </summary>
        /// <param name="model">model</param>
        public int AddRecord(STreeData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("set nocount on; ");
            strSql.Append(@"
            insert into STree(itemNo,nodeNm,parentId,orderId,comment,url,imageUrl,isAlowSeeOtherData,isAlowManageOtherData,isManageDepart,
            isEffect,childPage,isNssTree)
            values (@itemNo,@nodeNm,@parentId,@orderId,@comment,@url,@imageUrl,@isAlowSeeOtherData,@isAlowManageOtherData,@isManageDepart,
            @isEffect,@childPage,@isNssTree)");
            strSql.Append(@"
            ; select @@identity; set nocount off; ");
            SqlParameter[] parameters = {
                    new SqlParameter("@itemNo", SqlDbType.NVarChar,20),
                    new SqlParameter("@nodeNm", SqlDbType.NVarChar,100),
                    new SqlParameter("@parentId", SqlDbType.Int),
                    new SqlParameter("@orderId", SqlDbType.Int),
                    new SqlParameter("@comment", SqlDbType.NVarChar,50),
                    new SqlParameter("@url", SqlDbType.NVarChar,200),
                    new SqlParameter("@imageUrl", SqlDbType.NVarChar,100),
                    new SqlParameter("@isAlowSeeOtherData", SqlDbType.Bit),
                    new SqlParameter("@isAlowManageOtherData", SqlDbType.Bit),
                    new SqlParameter("@isManageDepart", SqlDbType.Bit),
                    new SqlParameter("@isEffect", SqlDbType.Bit),
                    new SqlParameter("@childPage", SqlDbType.NVarChar,4000),
                    new SqlParameter("@isNssTree", SqlDbType.Bit)
                };
            parameters[0].Value = model.itemNo;
            parameters[1].Value = model.nodeNm;
            parameters[2].Value = model.parentId;
            parameters[3].Value = model.orderId;
            parameters[4].Value = model.comment;
            parameters[5].Value = model.url;
            parameters[6].Value = model.imageUrl;
            parameters[7].Value = model.isAlowSeeOtherData;
            parameters[8].Value = model.isAlowManageOtherData;
            parameters[9].Value = model.isManageDepart;
            parameters[10].Value = model.isEffect;
            parameters[11].Value = model.childPage;
            parameters[12].Value = model.isNssTree;

            int id = 0;
            object ret = SqlHelper.ExecuteScalar(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

            if (ret != null && ret != DBNull.Value)
            {
                id = Convert.ToInt32(ret);
            }
            return id;
        }
示例#2
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);
    }
示例#3
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();
                }
            }
        }
    }
示例#4
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();
        }
    }
示例#5
0
 /// <summary>
 /// 从缓存中获取STree
 /// </summary>
 /// <param name="itemNo"></param>
 /// <returns></returns>
 public STreeData GetTreeData(string itemNo)
 {
     STreeData treeData = new STreeData();
     if (Application["TreeTable"] != null)
     {
         DataTable dtTree = (Application["TreeTable"] as DataTable);
         string strWhere = "itemNo = '" + itemNo + "'";
         DataRow[] drN = dtTree.Select(strWhere);
         if (drN.Length > 0)
         {
             DataRow row = drN[0];
             if (row["nodeId"] != DBNull.Value)
             {
                 treeData.nodeId = Convert.ToInt32(row["nodeId"]);
             }
             if (row["itemNo"] != DBNull.Value)
             {
                 treeData.itemNo = Convert.ToString(row["itemNo"]);
             }
             if (row["nodeNm"] != DBNull.Value)
             {
                 treeData.nodeNm = Convert.ToString(row["nodeNm"]);
             }
             if (row["parentId"] != DBNull.Value)
             {
                 treeData.parentId = Convert.ToInt32(row["parentId"]);
             }
             if (row["orderId"] != DBNull.Value)
             {
                 treeData.orderId = Convert.ToInt32(row["orderId"]);
             }
             if (row["comment"] != DBNull.Value)
             {
                 treeData.comment = Convert.ToString(row["comment"]);
             }
             if (row["url"] != DBNull.Value)
             {
                 treeData.url = Convert.ToString(row["url"]);
             }
             if (row["imageUrl"] != DBNull.Value)
             {
                 treeData.imageUrl = Convert.ToString(row["imageUrl"]);
             }
             if (row["isAlowSeeOtherData"] != DBNull.Value)
             {
                 treeData.isAlowSeeOtherData = Convert.ToBoolean(row["isAlowSeeOtherData"]);
             }
             if (row["isAlowManageOtherData"] != DBNull.Value)
             {
                 treeData.isAlowManageOtherData = Convert.ToBoolean(row["isAlowManageOtherData"]);
             }
             if (row["isManageDepart"] != DBNull.Value)
             {
                 treeData.isManageDepart = Convert.ToBoolean(row["isManageDepart"]);
             }
             if (row["isEffect"] != DBNull.Value)
             {
                 treeData.isEffect = Convert.ToBoolean(row["isEffect"]);
             }
             if (row["childPage"] != DBNull.Value)
             {
                 treeData.childPage = Convert.ToString(row["childPage"]);
             }
         }
     }
     return treeData;
 }
示例#6
0
 /// <summary>
 /// ����һ������
 /// </summary>
 /// <param name="model">model</param>
 public void ModifyRecord(STreeData model)
 {
     this.treeDB.ModifyRecord(model);
 }
示例#7
0
 /// <summary>
 /// ����һ������
 /// </summary>
 /// <param name="model">model</param>
 public int AddRecord(STreeData model)
 {
     return this.treeDB.AddRecord(model);
 }
示例#8
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();
        }
    }
示例#9
0
 private void SetModel(ref STreeData model)
 {
     model.itemNo = this.itemNo.Text;
     model.nodeNm = this.nodeNm.Text;
     if (this.parentId.SelectedValue != "")
     {
         model.parentId = Convert.ToInt32(this.parentId.SelectedValue);
     }
     else
     {
         model.parentId = 0;
     }
     if (this.orderId.Text != "")
     {
         model.orderId = Convert.ToInt32(this.orderId.Text);
     }
     else
     {
         model.orderId = 0;
     }
     model.url = this.url.Text;
     model.imageUrl = this.imageUrl.Value;
     model.isAlowManageOtherData = this.isAlowManageOtherData.Checked;
     model.isAlowSeeOtherData = this.isAlowSeeOtherData.Checked;
     model.isManageDepart = this.isManageDepart.Checked;
     model.comment = this.comment.Text;
     model.childPage = this.childPage.Text;
 }
示例#10
0
        /// <summary>
        /// ����һ������
        /// </summary>
        /// <param name="model">model</param>
        public void ModifyRecord(STreeData model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"
            update STree set
            itemNo=@itemNo,
            nodeNm=@nodeNm,
            parentId=@parentId,
            orderId=@orderId,
            comment=@comment,
            url=@url,
            imageUrl=@imageUrl,
            isAlowSeeOtherData=@isAlowSeeOtherData,
            isAlowManageOtherData=@isAlowManageOtherData,
            isManageDepart=@isManageDepart,
            isEffect=@isEffect,
            childPage=@childPage,
            isNssTree=@isNssTree
            where nodeId = @nodeId ");
            SqlParameter[] parameters = {
                    new SqlParameter("@nodeId", SqlDbType.Int),
                    new SqlParameter("@itemNo", SqlDbType.NVarChar,20),
                    new SqlParameter("@nodeNm", SqlDbType.NVarChar,100),
                    new SqlParameter("@parentId", SqlDbType.Int),
                    new SqlParameter("@orderId", SqlDbType.Int),
                    new SqlParameter("@comment", SqlDbType.NVarChar,50),
                    new SqlParameter("@url", SqlDbType.NVarChar,200),
                    new SqlParameter("@imageUrl", SqlDbType.NVarChar,100),
                    new SqlParameter("@isAlowSeeOtherData", SqlDbType.Bit),
                    new SqlParameter("@isAlowManageOtherData", SqlDbType.Bit),
                    new SqlParameter("@isManageDepart", SqlDbType.Bit),
                    new SqlParameter("@isEffect", SqlDbType.Bit),
                    new SqlParameter("@childPage", SqlDbType.NVarChar,4000),
                    new SqlParameter("@isNssTree", SqlDbType.Bit)
                };
            parameters[0].Value = model.nodeId;
            parameters[1].Value = model.itemNo;
            parameters[2].Value = model.nodeNm;
            parameters[3].Value = model.parentId;
            parameters[4].Value = model.orderId;
            parameters[5].Value = model.comment;
            parameters[6].Value = model.url;
            parameters[7].Value = model.imageUrl;
            parameters[8].Value = model.isAlowSeeOtherData;
            parameters[9].Value = model.isAlowManageOtherData;
            parameters[10].Value = model.isManageDepart;
            parameters[11].Value = model.isEffect;
            parameters[12].Value = model.childPage;
            parameters[13].Value = model.isNssTree;

            SqlHelper.ExecuteNonQuery(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);
        }
示例#11
0
        //*****************************************************************************
        //do it later      do it later      do it later
        //*****************************************************************************
        /// <summary>
        /// �õ�һ��model
        /// </summary>
        /// <param name="itemNo">itemNo</param>
        /// <returns>model</returns>
        public STreeData GetModel(string itemNo)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(@"
            select nodeId,itemNo,nodeNm,parentId,orderId,comment,url,imageUrl,isAlowSeeOtherData,isAlowManageOtherData,isManageDepart,
            isEffect,childPage,isNssTree
            from STree");
            strSql.Append(@"
            where itemNo = @itemNo ");
            SqlParameter[] parameters = {
                    new SqlParameter("@itemNo", SqlDbType.NVarChar, 20)
                };
            parameters[0].Value = itemNo;

            STreeData model = new STreeData();
            DataSet ds = SqlHelper.ExecuteDataset(this.connection, this.transaction, CommandType.Text, strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                DataRow row = ds.Tables[0].Rows[0];
                if (row["nodeId"] != DBNull.Value)
                {
                    model.nodeId = Convert.ToInt32(row["nodeId"]);
                }
                if (row["itemNo"] != DBNull.Value)
                {
                    model.itemNo = Convert.ToString(row["itemNo"]);
                }
                if (row["nodeNm"] != DBNull.Value)
                {
                    model.nodeNm = Convert.ToString(row["nodeNm"]);
                }
                if (row["parentId"] != DBNull.Value)
                {
                    model.parentId = Convert.ToInt32(row["parentId"]);
                }
                if (row["orderId"] != DBNull.Value)
                {
                    model.orderId = Convert.ToInt32(row["orderId"]);
                }
                if (row["comment"] != DBNull.Value)
                {
                    model.comment = Convert.ToString(row["comment"]);
                }
                if (row["url"] != DBNull.Value)
                {
                    model.url = Convert.ToString(row["url"]);
                }
                if (row["imageUrl"] != DBNull.Value)
                {
                    model.imageUrl = Convert.ToString(row["imageUrl"]);
                }
                if (row["isAlowSeeOtherData"] != DBNull.Value)
                {
                    model.isAlowSeeOtherData = Convert.ToBoolean(row["isAlowSeeOtherData"]);
                }
                if (row["isAlowManageOtherData"] != DBNull.Value)
                {
                    model.isAlowManageOtherData = Convert.ToBoolean(row["isAlowManageOtherData"]);
                }
                if (row["isManageDepart"] != DBNull.Value)
                {
                    model.isManageDepart = Convert.ToBoolean(row["isManageDepart"]);
                }
                if (row["isEffect"] != DBNull.Value)
                {
                    model.isEffect = Convert.ToBoolean(row["isEffect"]);
                }
                if (row["childPage"] != DBNull.Value)
                {
                    model.childPage = Convert.ToString(row["childPage"]);
                }
                if (row["isNssTree"] != DBNull.Value)
                {
                    model.isNssTree = Convert.ToBoolean(row["isNssTree"]);
                }
                return model;
            }
            else
            {
                return null;
            }
        }
示例#12
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;
        }
示例#13
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;
        }
示例#14
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;
        }