예제 #1
0
        /// <summary>
        /// 添加
        /// </summary>
        protected void insert()
        {
            string value = "", values = "", sqlText = "";
            string roleName = Request["roleName"];
            int    row      = roleBll.selectByroleName(roleName);

            if (row == 0)
            {
                role.RoleName = roleName;
                Result insert = roleBll.Insert(role);
                if (insert == Result.添加成功)
                {
                    int      roleIds   = roleBll.selectByroleName(roleName);
                    string   funIds    = Request["functionId"];
                    string   func      = funIds.Substring(0, funIds.Length - 1);
                    string[] functions = func.Split('?');
                    role.RoleName = roleName;
                    for (int i = 0; i < functions.Length; i++)
                    {
                        int functionId = Convert.ToInt32(functions[i]);
                        value  = "(" + roleIds + "," + functionId + "),";
                        values = values + value;
                    }
                    sqlText = values.Substring(0, values.Length - 1);
                    Result inserts = roleBll.InsertPer(sqlText, roleIds, "添加");
                    if (inserts == Result.添加失败)
                    {
                        Response.Write("添加失败");
                        Response.End();
                    }
                    else
                    {
                        Response.Write("添加成功");
                        Response.End();
                    }
                }
                else
                {
                    Response.Write("添加失败");
                    Response.End();
                }
            }
            else
            {
                Response.Write("该职位名已存在,请您输入新的职位名");
                Response.End();
            }
        }
예제 #2
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            RegionBll        regionBll = new RegionBll();
            UserBll          userBll   = new UserBll();
            RoleBll          roleBll   = new RoleBll();
            RSACryptoService rsa       = new RSACryptoService();

            string roleName = "微信零售";
            int    row      = roleBll.selectByroleName(roleName);
            int    roleId   = 0;

            if (row <= 0)
            {
                Role role = new Role();
                role.RoleName = roleName;
                Result insert = roleBll.Insert(role);
                if (insert == Result.添加成功)
                {
                    roleId = roleBll.selectByroleName(roleName);
                    string sqlText = "(" + roleId + "," + 14 + ")";
                    Result inserts = roleBll.InsertPer(sqlText, roleId, "添加");
                    if (inserts == Result.添加失败)
                    {
                        Response.Write("添加失败");
                        Response.End();
                    }
                }
            }
            else
            {
                roleId = row;
            }
            DataSet ds    = regionBll.select();
            int     count = ds.Tables[0].Rows.Count;

            if (count > 0 && ds != null)
            {
                for (int i = 0; i < count; i++)
                {
                    string regionId   = ds.Tables[0].Rows[i]["regionId"].ToString();
                    string regionName = ds.Tables[0].Rows[i]["regionName"].ToString();
                    Region region     = new Region();
                    region.RegionId = Convert.ToInt32(regionId);
                    Role role = new Role();
                    role.RoleId = roleId;
                    User user = new User();
                    user.UserId   = regionId + "01";
                    user.UserName = regionName + "微信零售";
                    user.ReginId  = region;
                    user.Pwd      = rsa.Encrypt("000000");
                    user.RoleId   = role;
                    Result rows = userBll.Insert(user);
                    if (rows == Result.添加失败)
                    {
                        Response.Write("添加失败:" + regionId);
                    }
                }
                Response.Write("添加成功");
            }
            else
            {
                Response.Write("未查到任何组织信息");
            }
        }
        public void Insert()
        {
            int    roleId   = 0;
            string roleName = "微信零售";
            int    row      = roleBll.selectByroleName(roleName);

            if (row == 0)
            {
                Role role = new Role();
                role.RoleName = roleName;
                Result insert = roleBll.Insert(role);
                if (insert == Result.添加成功)
                {
                    roleId = roleBll.selectByroleName(roleName);
                    string sqlText = "(" + roleId + "," + 14 + ")";
                    Result inserts = roleBll.InsertPer(sqlText, roleId, "添加");
                    if (inserts == Result.添加失败)
                    {
                        Response.Write("添加失败");
                        Response.End();
                    }
                }
            }
            else
            {
                roleId = row;
            }
            string reName = Request["name"];
            Result result = regionBll.isExit(reName);

            if (result == Result.记录不存在)
            {
                Result rsInsert = regionBll.insert(reName);
                if (rsInsert == Result.添加成功)
                {
                    int    regionId = regionBll.getRegionIdByName(reName);
                    Region region   = new Region();
                    region.RegionId = Convert.ToInt32(regionId);
                    Role userRole = new Role();
                    userRole.RoleId = roleId;
                    User user = new User();
                    user.UserId   = regionId + "01";
                    user.UserName = reName + "微信零售";
                    user.Pwd      = rsa.Encrypt("000000");
                    user.ReginId  = region;
                    user.RoleId   = userRole;
                    Result rows = userBll.Insert(user);
                    if (rows == Result.记录存在)
                    {
                        Response.Write("添加失败");
                        Response.End();
                    }
                    else if (rows == Result.添加失败)
                    {
                        Response.Write("添加失败");
                        Response.End();
                    }
                    else
                    {
                        Response.Write("添加成功");
                        Response.End();
                    }
                }
                else
                {
                    Response.Write("添加失败");
                    Response.End();
                }
            }
            else
            {
                Response.Write("该组织已经存在");
                Response.End();
            }
        }