Exemplo n.º 1
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        tji.j_name = txtName.Text.Trim();
        tji.j_flag = txtfl.Text;

        if (tj.GetModelList("j_name='" + tji.j_name + "'").Count == 0)
        {
            int i = tj.Add(tji);
            if (i > 0)
            {
                tyy.y_jsid = i;
                ty.Add(tyy);
                Tunnel.Common.Message.Show("保存成功");
            }
        }
        else
        {
            Tunnel.Common.Message.Show("该角色已存在", "tunnel_jueseguanli.aspx");
        }
    }
Exemplo n.º 2
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;
        }
    }