protected void btnSave_Click(object sender, EventArgs e) { try { ISysAccountService userService = IoC.Resolve <ISysAccountService>(); if (this.txtCode.Text.Trim().Length < 6 || this.txtCode.Text.Trim().Length > 16) { JsAlert("登录名验证错误!"); return; } if (this.txtPassWord.Text.Trim().Length < 6 || this.txtPassWord.Text.Trim().Length > 16) { JsAlert("登录密码验证错误!"); return; } if (!userService.IsUnique(this.txtCode.Text.Trim())) { JsAlert("登录名已经存在!"); return; } SysAccount account = new SysAccount(); account.Code = this.txtCode.Text.Trim(); account.Name = this.txtName.Text.Trim(); account.PassWord = this.txtPassWord.Text.Trim(); account.IsEnabled = true; if (userService.AddAccount(account)) { this.txtCode.Text = string.Empty; this.txtName.Text = string.Empty; this.txtPassWord.Text = string.Empty; JsAlert("保存成功!", true); } else { JsAlert("保存失败,请稍后再试!"); } } catch (Exception ex) { JsAlert("保存失败,请稍后再试!"); } }