Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                if (CheckCode())
                {
                    Users u = new Users();
                    u.LoginId = Request.Form["txtName"];
                    u.LoginPwd = Common.WebCommon.GetStrDoubleMD5(Request.Form["txtPass"]);
                    u.Name = Request.Form["txtTrueName"];
                    u.Mail = Request.Form["txtEmail"];
                    u.Address = Request.Form["txtAddress"];
                    u.Phone = Request.Form["txtPhone"];
                    u.UserState.Id = 1;
                    u.ActiveCode = Guid.NewGuid().ToString().Replace("-", "");
                    string msg;
                    UsersBLL ub = new UsersBLL();
                    int uid = ub.Add(u, out msg);
                    if (uid > 0)
                    {
                        //注册成功
                        //发送激活链接
                        string link = "http://*****:*****@"亲爱的网上图书商城用户:<br /><br /><br />
                        //                                        请通过<a target='_blank' href='{0}'>{1}</a>激活账号,也可以复制激活链接至浏览器
                        //                                        <br /><br /><br />
                        //                                        网上图书商城
                        //                                        <br />
                        //                                        {2}
                        //                                        <br /><br /><br />
                        //                                        此邮件为系统自动发出的邮件,请勿直接回复。", link, link, DateTime.Now.ToString());
                        #endregion
                        string content = string.Format(new SettingsBLL().GetValueByName("激活邮件内容"), link, link, DateTime.Now.ToString());
                        string subject = "来自网上图书商城的注册确认邮件";
                        ub.SendEmail(content, u.Mail, subject);

                        //页面的跳转
                        Response.Redirect("/ShowMsg.aspx?m=" + HttpUtility.UrlEncode(msg+"<br />激活邮件已发到您的"+u.Mail+"的邮箱中,请激活账号后登录!") + "&t=" + HttpUtility.UrlEncode("登录页面") + "&u=/Member/Login.aspx");
                    }
                    else
                    {
                        //注册失败
                        txtMsg.Text = msg;
                        txtMsg.ForeColor = Color.Red;
                    }
                }
                else
                {
                    txtMsg.Text = "验证码错误,请重新输入!";
                    txtMsg.ForeColor = Color.Red;
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(BookShop.Model.Users model, out string msg)
 {
     //判断用户是否存在
     if (!CheckUserName(model.LoginId))
     {
         msg = "注册成功";
         return(dal.Add(model));
     }
     else
     {
         msg = " 此用户存在";
         return(-1);
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(BookShop.Model.Users model)
 {
     return(dal.Update(model));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(BookShop.Model.Users model)
 {
     return(dal.Add(model));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 登录成功后的处理
 /// </summary>
 /// <param name="u"></param>
 private void LoginSucess(Users u)
 {
     string key = Guid.NewGuid().ToString();
     Common.MemCacheHelper.Insert(key, u, DateTime.Now.AddMinutes(20));
     HttpCookie hc = new HttpCookie("userInfo");
     hc.Value = key;
     Response.Cookies.Add(hc);
     GoToPage("登录成功!");
 }