//注册事件 protected void btnRegist_Click(object sender, EventArgs e) { if (ckAccept.Checked == false) { Maticsoft.Common.MessageBox.Show(this.Page, "必须同意注册协议才能注册"); return; } Model.eb_customer model = new Model.eb_customer(); model.IsDel = false; model.Password = this.txtPwd.Text.Trim(); // 此处没有对密码加密 model.Phone = this.txtTelephone.Text.Trim(); model.Sex = this.dropSex.SelectedValue.ToString(); model.UserName = this.txtUserName.Text.Trim(); model.Email = this.txtEmail.Text.Trim(); model.Birthday = DateTime.Parse(this.txtBirthday.Value); int UserId = new BLL.eb_customer().Add(model); if (UserId > 0) { //表示注册成功 ,向用户发送邮件 //跳转到主页面去 BLL.eb_customer customerManager = new BLL.eb_customer(); customerManager.SendRegistEmail(this.txtUserName.Text, this.txtEmail.Text); Response.Redirect("index.aspx"); } else { Maticsoft.Common.MessageBox.Show(this.Page, "注册失败,请重试或联系管理员"); } }
protected void btnLogin_Click(object sender, EventArgs e) { Model.eb_customer model = new BLL.eb_customer().CheckLogin(this.txtUserName.Text.Trim(), this.txtPassword.Text.Trim()); if (model != null) { //登陆成功 Session["CrmUserInfo"] = model; if (this.ckSaveme.Checked) { //记住我 HttpCookie cookieUserName = new HttpCookie("UserName", this.txtUserName.Text); HttpCookie cookiePwd = new HttpCookie("Pwd", this.txtPassword.Text); cookieUserName.Expires = DateTime.Now.AddDays(7); cookiePwd.Expires = DateTime.Now.AddDays(7); Response.Cookies.Add(cookieUserName); Response.Cookies.Add(cookiePwd); } Response.Redirect("index.aspx"); } else { //登陆失败 Maticsoft.Common.MessageBox.Show(this.Page, "用户名或密码错误,请重试"); } }
//用户登陆 protected void btnLogin_Click(object sender, EventArgs e) { string UserName = this.txtUserName.Text.Trim(); string Pwd = this.txtPwd.Text.Trim(); Model.eb_customer model = new BLL.eb_customer().CheckLogin(UserName, Pwd); if (model != null) { //如果用户登陆成功,我们就保存用户的信息 Session["CrmUserInfo"] = model; Maticsoft.Common.MessageBox.Show(this.Page, "登陆成功"); } else { Maticsoft.Common.MessageBox.Show(this.Page, "登陆失败"); } }
/// <summary> /// 注册时,检查邮箱是否已经注册 /// </summary> /// <param name="context"></param> private void CheckEmail(HttpContext context) { string email = context.Request.Form["Email"] == null ? "" : context.Request.Form["Email"].ToString(); if (!string.IsNullOrEmpty(email)) { bool flag = new BLL.eb_customer().CheckCrmEmail(email); if (flag) { //表示存在 context.Response.Write("1"); } else { //表示不存在 context.Response.Write("0"); } } else { context.Response.Write("2"); } }
/// <summary> /// 注册时,判断用户名是否重复 /// </summary> /// <param name="context"></param> private void CheckCrmUserName(HttpContext context) { string username = context.Request.Form["UserName"] == null ? "" : context.Request.Form["UserName"].ToString(); if (!string.IsNullOrEmpty(username)) { bool flag = new BLL.eb_customer().CheckCrmUserInfo(username); if (flag) { //表示账号存在 context.Response.Write("1"); } else { //表示不存在 context.Response.Write("0"); } } else { context.Response.Write("2"); } }