//点击注册进行注册 protected void btn_ZhuceClick(object sender, EventArgs e) { string email = this.Email.Value.ToString(); if (Regex.IsMatch(email, "[A-Za-z0-9][@][A-Za-z0-9]+[.][A-Za-z0-9]") == true) { string username = this.Zhuce_Username.Value.ToString(); string password = this.Zhuce_Password.Value.ToString(); user.Email = email; user.Username = username; user.Pwd = password; bool flag = ur.AddUser(user); if (flag) { Response.Write("<script>alert('注册成功!');</script>"); } else { Response.Write("<script>alert('注册失败!');</script>"); } } else { Response.Write("<script>alert('您的电子邮箱格式不正确!');</script>"); } }
private void AddUser() { BLL.MerchantBLL mbll = new BLL.MerchantBLL(); BLL.UserBLL ubll = new BLL.UserBLL(); Model.UserInfoModel model = new Model.UserInfoModel(); Model.MerRoleVsUserModel vsModel = new Model.MerRoleVsUserModel(); model.UserId = ReStr("uid", ""); if (model.UserId.Length < 5) { throw new Exception("用户名不能小于5个字符!"); } model.CreateTime = DateTime.Now; model.Birthday = DateTime.Parse("1900-01-01"); #region 事务开启 TransactionOptions transactionOption = new TransactionOptions(); transactionOption.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; using (TransactionScope transactionScope = new TransactionScope(TransactionScopeOption.Required, transactionOption)) { #endregion ubll.AddUser(model); vsModel.UserId = model.UserId; vsModel.BranchId = ReStr("BranchId", ""); vsModel.MerRoleId = ReDecimal("MerRoleId", 0); mbll.SaveMerRoleVsUser(vsModel); #region 事务关闭 transactionScope.Complete(); } #endregion ReTrue(); }