예제 #1
0
        public string AddUser(string strUserName, int RoleId)
        {
            Model.UserModel mod = new Model.UserModel();
            mod.LoginName = strUserName;
            mod.RoleId    = RoleId;
            mod.Pwd       = "666666"; //初始密码为666666
            BLL.UserBLL bll = new BLL.UserBLL();
            bool        b   = bll.Add(mod);

            if (b)
            {
                return("添加用户成功".ToJson());
            }
            else
            {
                return("添加用户失败".ToJson());
            }
        }
예제 #2
0
 protected void btnAdd_Click(object sender, ImageClickEventArgs e)
 {
     Model.User u = new Model.User() { UserName= txtUid.Text,UserPassword=txtPwd.Text,AddTime=DateTime.Now};
     if (String.IsNullOrEmpty(u.UserName)||String.IsNullOrEmpty(u.UserPassword)||!cvPwd.IsValid)
     {
         return;
     }
     u.UserPassword = Common.SecurityHelper.Encrypt(u.UserPassword);
     BLL.UserBLL helper = new BLL.UserBLL();
     if (helper.ExistUserName(u.UserName))
     {
         Response.Write("<script>alert('添加失败!该用户名已经存在')</script>");
         return;
     }
     if (helper.Add(u))
     {
         Response.Redirect("UserManage.aspx");
     }
     else
     {
         Response.Write("<script>alert('添加失败!请稍后重试')</script>");
     }
 }