Example #1
0
    /// <summary>
    /// 得到所有权限
    /// </summary>
    public Dictionary <int, string> getAllPermission()
    {
        Dictionary <int, string> allDic = new Dictionary <int, string>();

        Tunnel.BLL.Tunnel_quanxian          tq     = new Tunnel.BLL.Tunnel_quanxian();
        List <Tunnel.Model.Tunnel_quanxian> tqList = new List <Tunnel.Model.Tunnel_quanxian>();

        if (ul.JiaoSe(ul.LoginID) == "系统管理员")
        {
            tqList = tq.GetModelList("1=1 order by q_rId asc ");
            foreach (Tunnel.Model.Tunnel_quanxian item in tqList)
            {
                allDic.Add(item.q_id, item.q_mark + "-->>" + item.q_name);
            }
        }
        else
        {
            Tunnel.BLL.Tunnel_menber   tm  = new Tunnel.BLL.Tunnel_menber();
            Tunnel.Model.Tunnel_menber tmm = new Tunnel.Model.Tunnel_menber();
            tmm = tm.GetModel(ul.LoginID);
            if (!string.IsNullOrEmpty(Convert.ToString(tmm.m_bum)))
            {
                Tunnel.BLL.Tunnel_byingshe          tb     = new Tunnel.BLL.Tunnel_byingshe();
                Tunnel.Model.Tunnel_byingshe        tbb    = new Tunnel.Model.Tunnel_byingshe();
                List <Tunnel.Model.Tunnel_byingshe> tbList = new List <Tunnel.Model.Tunnel_byingshe>();
                tbList = tb.GetModelList("by_bid = " + tmm.m_bum + "");
                if (tbList.Count > 0)
                {
                    tbb = tbList[0];
                    string byList = tbb.by_list;
                    if (byList.Length > 0)
                    {
                        string[] temp = byList.Split('|');
                        foreach (string item in temp)
                        {
                            Tunnel.Model.Tunnel_quanxian tqq = new Tunnel.Model.Tunnel_quanxian();
                            tqq = tq.GetModel(int.Parse(item));
                            if (tqq != null)
                            {
                                allDic.Add(tqq.q_id, tqq.q_mark + "-->>" + tqq.q_name);
                            }
                        }
                    }
                }
            }
        }
        return(allDic);
    }
Example #2
0
        /// <summary>
        /// 查看是否有权限
        /// </summary>
        /// <param name="userID">用户ID</param>
        /// <param name="XreqestStr">小类</param>
        /// <param name="BreqestStr">大类</param>
        /// <returns>true有权限</returns>
        public static bool IfHasPrimision(string userID, string XreqestStr, string BreqestStr, bool IfRead)
        {
            string tmpUid = string.Empty;
            string tmpBid = string.Empty;
            string tmpDid = string.Empty;
            string tmpJid = string.Empty;

            Tunnel.BLL.Tunnel_menber          tm     = new Tunnel_menber();
            Tunnel.Model.Tunnel_menber        tmm    = new Tunnel.Model.Tunnel_menber();
            List <Tunnel.Model.Tunnel_menber> tmlist = new List <Tunnel.Model.Tunnel_menber>();

            Tunnel.BLL.Tunnel_jiaose   tj  = new Tunnel_jiaose();
            Tunnel.Model.Tunnel_jiaose tjj = new Tunnel.Model.Tunnel_jiaose();


            Tunnel.BLL.Tunnel_quanxian          qx     = new Tunnel_quanxian();
            Tunnel.Model.Tunnel_quanxian        qxx    = new Tunnel.Model.Tunnel_quanxian();
            List <Tunnel.Model.Tunnel_quanxian> qxlist = new List <Tunnel.Model.Tunnel_quanxian>();

            Tunnel.BLL.Tunnel_yingshe          tyj     = new Tunnel_yingshe();
            Tunnel.Model.Tunnel_yingshe        tyjj    = new Tunnel.Model.Tunnel_yingshe();
            List <Tunnel.Model.Tunnel_yingshe> tyjlist = new List <Tunnel.Model.Tunnel_yingshe>();

            Tunnel.BLL.Tunnel_uyingshe          tyu     = new Tunnel_uyingshe();
            Tunnel.Model.Tunnel_uyingshe        tyuu    = new Tunnel.Model.Tunnel_uyingshe();
            List <Tunnel.Model.Tunnel_uyingshe> tyulist = new List <Tunnel.Model.Tunnel_uyingshe>();

            Tunnel.BLL.Tunnel_byingshe          tyb     = new Tunnel_byingshe();
            Tunnel.Model.Tunnel_byingshe        tybb    = new Tunnel.Model.Tunnel_byingshe();
            List <Tunnel.Model.Tunnel_byingshe> tyblist = new List <Tunnel.Model.Tunnel_byingshe>();

            Tunnel.BLL.Tunnel_dyingshe          tyd     = new Tunnel_dyingshe();
            Tunnel.Model.Tunnel_dyingshe        tydd    = new Tunnel.Model.Tunnel_dyingshe();
            List <Tunnel.Model.Tunnel_dyingshe> tydlist = new List <Tunnel.Model.Tunnel_dyingshe>();

            UserLogin ul    = new UserLogin();
            bool      b     = false;
            string    qxStr = string.Empty;

            tmm    = tm.GetModel(Convert.ToInt64(userID));
            tmpBid = tmm.m_bum.ToString();
            tmpJid = tmm.m_jiao.ToString();
            tmpDid = tmm.m_duty.ToString();
            tmpUid = userID;

            tyulist = tyu.GetModelList("uy_uid='" + tmpUid + "'");

            if (tyulist.Count > 0)
            {
                if (tyulist[0].uy_list.Length > 0)
                {
                    qxStr += tyulist[0].uy_list + "|";
                }
            }

            tyjlist = tyj.GetModelList("y_jsid=" + tmpJid + "");

            if (tyjlist.Count > 0)
            {
                if (tyjlist[0].y_qxlist.Length > 0)
                {
                    qxStr += tyjlist[0].y_qxlist + "|";
                }
            }

            tyblist = tyb.GetModelList("by_bid='" + tmpBid + "'");

            if (tyblist.Count > 0)
            {
                if (tyblist[0].by_list.Length > 0)
                {
                    qxStr += tyblist[0].by_list + "|";
                }
            }


            tydlist = tyd.GetModelList("dy_did='" + tmpDid + "'");
            if (tydlist.Count > 0)
            {
                if (tydlist[0].dy_list.Length > 0)
                {
                    qxStr += tydlist[0].dy_list + "|";
                }
            }


            if (qxStr.Length > 0)
            {
                qxStr = qxStr.Substring(0, qxStr.Length - 1);
            }
            if (userID != "1" && ul.JiaoSe(int.Parse(userID)) != "系统管理员")
            {
                if (IfRead)
                {
                    if (tmpJid != "0")
                    {
                        if (ul.JiaoSe(int.Parse(userID)) == "总经理")
                        {
                            b = true;
                        }
                    }
                }
                if (!string.IsNullOrEmpty(qxStr))
                {
                    qxlist = qx.GetModelList("q_name='" + XreqestStr + "' and q_mark='" + BreqestStr + "'");
                    if (qxlist.Count > 0)
                    {
                        foreach (string item in qxStr.Split('|'))
                        {
                            if (qxlist[0].q_id.ToString().Equals(item.ToString()))
                            {
                                b = true;
                            }
                        }
                    }
                }
            }
            else
            {
                b = true;
            }
            return(b);
        }
Example #3
0
    /// <summary>
    /// 更新权限
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Button1_Click(object sender, EventArgs e)
    {
        switch (typeId)
        {
            #region 添加/更新用户权限
        case 1:
            Tunnel.BLL.Tunnel_uyingshe          tyu    = new Tunnel.BLL.Tunnel_uyingshe();
            Tunnel.Model.Tunnel_uyingshe        tyuu   = new Tunnel.Model.Tunnel_uyingshe();
            List <Tunnel.Model.Tunnel_uyingshe> uslist = new List <Tunnel.Model.Tunnel_uyingshe>();
            uslist = tyu.GetModelList("uy_uid='" + tmpId + "'");
            if (uslist.Count > 0)
            {
                tyuu.uy_id   = uslist[0].uy_id;
                tyuu.uy_uid  = tmpId.ToString();
                tyuu.uy_list = getString();
                tyu.Update(tyuu);
                Tunnel.Common.Message.Show("更新用户权限成功");    //更新用户权限
            }
            else
            {
                tyuu.uy_uid  = tmpId.ToString();
                tyuu.uy_list = getString();
                tyu.Add(tyuu);
                Tunnel.Common.Message.Show("添加用户权限成功");    //更新用户权限
            }
            ListBox2.Items.Clear();

            break;
            #endregion

            #region 添加/更新角色权限
        case 2:
            Tunnel.BLL.Tunnel_yingshe          tyj    = new Tunnel.BLL.Tunnel_yingshe();
            Tunnel.Model.Tunnel_yingshe        tyjj   = new Tunnel.Model.Tunnel_yingshe();
            List <Tunnel.Model.Tunnel_yingshe> jslist = new List <Tunnel.Model.Tunnel_yingshe>();
            jslist = tyj.GetModelList("y_jsid=" + tmpId + "");
            if (jslist.Count > 0)
            {
                tyjj.y_id     = jslist[0].y_id;
                tyjj.y_jsid   = tmpId;
                tyjj.y_qxlist = getString();
                tyj.Update(tyjj);
                Tunnel.Common.Message.Show("更新角色权限成功");    //更新角色权限
            }
            else
            {
                tyjj.y_jsid   = tmpId;
                tyjj.y_qxlist = getString();
                tyj.Add(tyjj);
                Tunnel.Common.Message.Show("添加角色权限成功");    //添加角色权限
            }
            ListBox2.Items.Clear();
            break;
            #endregion

            #region 添加/更新职位权限
        case 3:
            Tunnel.BLL.Tunnel_dyingshe          tyd    = new Tunnel.BLL.Tunnel_dyingshe();
            Tunnel.Model.Tunnel_dyingshe        tydd   = new Tunnel.Model.Tunnel_dyingshe();
            List <Tunnel.Model.Tunnel_dyingshe> dulist = new List <Tunnel.Model.Tunnel_dyingshe>();
            dulist = tyd.GetModelList("dy_did='" + tmpId + "'");
            if (dulist.Count > 0)
            {
                tydd.dy_id   = dulist[0].dy_id;
                tydd.dy_did  = tmpId.ToString();
                tydd.dy_list = getString();
                tyd.Update(tydd);
                Tunnel.Common.Message.Show("更新职位权限成功");    //更新职务权限
            }
            else
            {
                tydd.dy_did  = tmpId.ToString();
                tydd.dy_list = getString();
                tyd.Add(tydd);
                Tunnel.Common.Message.Show("添加职位权限成功");    //添加职务权限
            }
            ListBox2.Items.Clear();
            break;
            #endregion

            #region 添加/更新部门权限
        case 4:
            Tunnel.BLL.Tunnel_byingshe          tyb    = new Tunnel.BLL.Tunnel_byingshe();
            Tunnel.Model.Tunnel_byingshe        tybb   = new Tunnel.Model.Tunnel_byingshe();
            List <Tunnel.Model.Tunnel_byingshe> bulist = new List <Tunnel.Model.Tunnel_byingshe>();
            bulist = tyb.GetModelList("by_bid='" + tmpId + "'");
            //判断是修改还是添加权限
            if (bulist.Count > 0)
            {
                tybb.by_id   = bulist[0].by_id;
                tybb.by_bid  = tmpId.ToString();
                tybb.by_list = getString();
                tyb.Update(tybb);
                Tunnel.Common.Message.Show("更新部门权限成功");    //更新部门权限
            }
            else
            {
                tybb.by_bid  = tmpId.ToString();
                tybb.by_list = getString();
                tyb.Add(tybb);
                Tunnel.Common.Message.Show("添加部门权限成功");    //添加部门权限
            }
            ListBox2.Items.Clear();
            break;

            #endregion
        default:
            break;
        }
    }
Example #4
0
    public static int typeId        = 0;  //管理类型编号


    /// <summary>
    /// 根据 用户编号获取用户拥有的所有权限
    /// </summary>
    /// <param name="userId"></param>
    public void GetUserAllPermission(int userId)
    {
        ListBox3.Items.Clear();
        int    bumId   = 0;
        int    dutyId  = 0;
        int    jueSeId = 0;
        string qxList  = string.Empty;

        Tunnel.BLL.Tunnel_menber   tm  = new Tunnel.BLL.Tunnel_menber();
        Tunnel.Model.Tunnel_menber tmm = new Tunnel.Model.Tunnel_menber();

        Tunnel.BLL.Tunnel_uyingshe   uy  = new Tunnel.BLL.Tunnel_uyingshe();
        Tunnel.Model.Tunnel_uyingshe uyy = new Tunnel.Model.Tunnel_uyingshe();

        Tunnel.BLL.Tunnel_dyingshe   dy  = new Tunnel.BLL.Tunnel_dyingshe();
        Tunnel.Model.Tunnel_dyingshe dyy = new Tunnel.Model.Tunnel_dyingshe();

        Tunnel.BLL.Tunnel_yingshe   jy  = new Tunnel.BLL.Tunnel_yingshe();
        Tunnel.Model.Tunnel_yingshe jyy = new Tunnel.Model.Tunnel_yingshe();

        Tunnel.BLL.Tunnel_byingshe   by  = new Tunnel.BLL.Tunnel_byingshe();
        Tunnel.Model.Tunnel_byingshe byy = new Tunnel.Model.Tunnel_byingshe();

        tmm = tm.GetModel(userId);

        #region 判断
        if (tmm != null)
        {
            bumId   = tmm.m_bum;
            dutyId  = tmm.m_duty;
            jueSeId = tmm.m_jiao;
            if (uy.GetModelList("uy_uid=" + userId).Count > 0)
            {
                uyy = uy.GetModelList("uy_uid=" + userId)[0];
                if (uyy != null)
                {
                    if (uyy.uy_list.Length > 0)
                    {
                        qxList += uyy.uy_list + "|";
                    }
                }
            }
            if (by.GetModelList("by_bid=" + bumId).Count > 0)
            {
                byy = by.GetModelList("by_bid=" + bumId)[0];
                if (byy != null)
                {
                    if (byy.by_list.Length > 0)
                    {
                        qxList += byy.by_list + "|";
                    }
                }
            }
            if (dy.GetModelList("dy_did=" + dutyId).Count > 0)
            {
                dyy = dy.GetModelList("dy_did=" + dutyId)[0];
                if (dyy != null)
                {
                    if (dyy.dy_list.Length > 0)
                    {
                        qxList += dyy.dy_list + "|";
                    }
                }
            }
            if (jy.GetModelList("y_jsid=" + jueSeId).Count > 0)
            {
                jyy = jy.GetModelList("y_jsid=" + jueSeId)[0];
                if (jyy != null)
                {
                    if (jyy.y_qxlist.Length > 0)
                    {
                        qxList += jyy.y_qxlist + "|";
                    }
                }
            }
            if (qxList.Length > 1)
            {
                qxList = qxList.Substring(0, qxList.Length - 1);
            }
        }
        #endregion
        Tunnel.BLL.Tunnel_quanxian tq = new Tunnel.BLL.Tunnel_quanxian();

        if (qxList.Length > 0)
        {
            foreach (string item in qxList.Split('|'))
            {
                Tunnel.Model.Tunnel_quanxian tqq = new Tunnel.Model.Tunnel_quanxian();
                tqq = tq.GetModel(int.Parse(item));
                if (tqq != null)
                {
                    ListItem li = new ListItem(tqq.q_mark + "-->>" + tqq.q_name, tqq.q_id.ToString());
                    if (!ListBox3.Items.Contains(li))
                    {
                        ListBox3.Items.Add(li);
                    }
                }
            }
        }
    }
Example #5
0
    /// <summary>
    /// 绑定listview
    /// </summary>
    /// <param name="tmpId">id</param>
    /// <param name="typeId">类系 1,用户  2,角色  3,职务 4.部门</param>
    public void PageBind(int tmpId, int typeId)
    {
        if (typeId == 1)
        {
            ListBox3.Visible = true;
        }
        Dictionary <int, string> cloneDic = new Dictionary <int, string>(getAllPermission());

        ListBox3.Items.Clear();
        ListBox2.Items.Clear();
        string TempList = string.Empty;

        switch (typeId)
        {
        case 1:
            TempList = string.Empty;
            Tunnel.BLL.Tunnel_uyingshe          tu      = new Tunnel.BLL.Tunnel_uyingshe();
            List <Tunnel.Model.Tunnel_uyingshe> tuuList = tu.GetModelList("uy_uid = " + tmpId + "");
            if (tuuList.Count > 0)
            {
                TempList = tuuList[0].uy_list;
                if (TempList.Length > 0)
                {
                    foreach (string item in TempList.Split('|'))
                    {
                        string tempValue = string.Empty;
                        if (getAllPermission().TryGetValue(int.Parse(item), out tempValue))
                        {
                            ListBox2.Items.Add(new ListItem(tempValue, item));
                            cloneDic.Remove(int.Parse(item));
                        }
                    }
                }
            }
            foreach (KeyValuePair <int, string> item in cloneDic)
            {
                ListBox1.Items.Add(new ListItem(item.Value, item.Key.ToString()));
            }
            GetUserAllPermission(tmpId);
            break;

        case 2:
            TempList = string.Empty;
            Tunnel.BLL.Tunnel_yingshe          tj      = new Tunnel.BLL.Tunnel_yingshe();
            List <Tunnel.Model.Tunnel_yingshe> tjjList = tj.GetModelList("y_jsid = " + tmpId + "");
            if (tjjList.Count > 0)
            {
                TempList = tjjList[0].y_qxlist;
                if (TempList.Length > 0)
                {
                    foreach (string item in TempList.Split('|'))
                    {
                        string tempValue = string.Empty;
                        if (getAllPermission().TryGetValue(int.Parse(item), out tempValue))
                        {
                            ListBox2.Items.Add(new ListItem(tempValue, item));
                            cloneDic.Remove(int.Parse(item));
                        }
                    }
                }
            }
            foreach (KeyValuePair <int, string> item in cloneDic)
            {
                ListBox1.Items.Add(new ListItem(item.Value, item.Key.ToString()));
            }
            break;

        case 3:
            TempList = string.Empty;
            Tunnel.BLL.Tunnel_dyingshe          td      = new Tunnel.BLL.Tunnel_dyingshe();
            List <Tunnel.Model.Tunnel_dyingshe> tddList = td.GetModelList("dy_did = " + tmpId + "");
            if (tddList.Count > 0)
            {
                TempList = tddList[0].dy_list;
                if (TempList.Length > 0)
                {
                    foreach (string item in TempList.Split('|'))
                    {
                        string tempValue = string.Empty;
                        if (getAllPermission().TryGetValue(int.Parse(item), out tempValue))
                        {
                            ListBox2.Items.Add(new ListItem(tempValue, item));
                            cloneDic.Remove(int.Parse(item));
                        }
                    }
                }
            }
            foreach (KeyValuePair <int, string> item in cloneDic)
            {
                ListBox1.Items.Add(new ListItem(item.Value, item.Key.ToString()));
            }
            break;

        case 4:
            TempList = string.Empty;
            Tunnel.BLL.Tunnel_byingshe          tb      = new Tunnel.BLL.Tunnel_byingshe();
            List <Tunnel.Model.Tunnel_byingshe> tbbList = tb.GetModelList("by_bid = " + tmpId + "");
            if (tbbList.Count > 0)
            {
                TempList = tbbList[0].by_list;
                if (TempList.Length > 0)
                {
                    foreach (string item in TempList.Split('|'))
                    {
                        string tempValue = string.Empty;
                        if (getAllPermission().TryGetValue(int.Parse(item), out tempValue))
                        {
                            ListBox2.Items.Add(new ListItem(tempValue, item));
                            cloneDic.Remove(int.Parse(item));
                        }
                    }
                }
            }
            foreach (KeyValuePair <int, string> item in cloneDic)
            {
                ListBox1.Items.Add(new ListItem(item.Value, item.Key.ToString()));
            }
            break;

        default:
            break;
        }
    }