コード例 #1
0
 protected void btncreateuser_Click(object sender, EventArgs e)
 {
     //创建用户的操作
     if (CheckInputForCreate())
     {
         AdminUser user = new AdminUser();
         user.ID              = AdminUserBLL.GetMaxId() + 1;//注意获取最大ID后使用时要在ID基础上+1
         user.UserID          = textboxUserId.Text;
         user.UserPwd         = MD5PWD.EnCode(textboxPwd.Text);
         user.UserCreatedDate = DateTime.Now;
         if (AdminUserBLL.CheckUserId(textboxUserId.Text))
         {
             if (AdminUserBLL.Add(user) != null)
             {
                 JqHelper.ResponseScript("alert(\"创建用户成功!\")");
                 GetAdmins();
             }
             else
             {
                 JqHelper.ResponseScript("alert(\"创建失败,请重新尝试!\")");
             }
         }
         else
         {
             JqHelper.ResponseScript("alert(\"该用户名已经被使用请更换一个!\")");
             textboxUserId.Text = "";
             textboxPwd.Text    = "";
             textboxUserId.Focus();
         }
     }
 }