Ejemplo n.º 1
0
 //加载页面的时候验证
 //此处userName 其实是student.Stu_ID
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         StudentInfo student = new StudentInfo();
         if (Request.QueryString["userName"] != null)
         {
             student = bllStudent.Get(Convert.ToInt32(Request.QueryString["userName"]));
             if (Request.QueryString["validateCode"] != null && student.Stu_Validation.Equals(Request.QueryString["validateCode"]))
             {
                 student.Stu_Validation = "success";
                 bllStudent.Modify(student);
                 Validate.Text = "验证成功!";
                 Response.Redirect("~/Student/Login.aspx");
             }
             else
             {
                 Validate.Text = "验证失败";
             }
         }
         else
         {
             Validate.Text = "ao";
         }
     }
 }
Ejemplo n.º 2
0
    //点击修改密码,向用户发送激活账户的邮件
    //并且修改用户的验证码,自动生成随机字符串
    protected void ResetPassword_Click(object sender, EventArgs e)
    {
        HttpCookie  cookie  = Request.Cookies["usr"];
        StudentInfo student = bllStudent.Get(Convert.ToInt32(cookie.Values["ID"]));

        student.Stu_Password = Password1.Text.Trim();
        if (bllStudent.CheckLogin(student) && Password2.Text.Trim().Equals(Password3.Text.Trim()))
        {
            student.Stu_Password   = Md5Support.GetMd5String(Password2.Text.Trim());
            student.Stu_Validation = Str(10, false);
            bllStudent.Modify(student);
            try
            {
                String        strSmtpServer = "smtp.163.com";
                String        strFrom       = "*****@*****.**";
                String        strFromPass   = "******";
                String        strTo         = student.Stu_Email;
                String        strSubject    = "Viki账号激活";
                StringBuilder sb            = new StringBuilder();


                //邮件内容
                sb.AppendFormat("点击下面链接激活账号,否则重新注册账号,链接只能使用一次,请尽快激活!</br>");
                sb.AppendFormat("<a href='http://{0}/WebFrontEnd/Student/MailValidateSuccess.aspx?userName={1}&validateCode={2}''>点击这里</a></br>", Request.Url.Authority, student.Stu_ID, student.Stu_Validation);
                sb.AppendFormat("如未能激活请点击下面链接:<a href='http://{0}/WebFrontEnd/Student/MailValidateSuccess.aspx?userName={1}&validateCode={2}'>{3}/Student/MailValidateSuccess.aspx?userName={4}&validateCode={5}</a></br>", Request.Url.Authority, student.Stu_ID, student.Stu_Validation, Server.UrlPathEncode(Request.ApplicationPath), student.Stu_ID, student.Stu_Validation);
                SendSMTPEMail(strSmtpServer, strFrom, strFromPass, strTo, strSubject, sb.ToString());
                Response.Redirect("~/Student/Login.aspx");
            }
            catch (Exception ex)
            {
                Console.Out.WriteLine(ex.Data);
                throw ex;
            }
        }
    }
Ejemplo n.º 3
0
    protected void Submit_Click(object sender, EventArgs e)
    {
        if (!Regex.IsMatch(StuNickName.Text.ToString(), @"^\S{2,10}$"))
        {
            throw new Exception();
        }
        if (!Regex.IsMatch(StuNickName.Text.ToString(), @"^\S[^\^]+$"))
        {
            throw new Exception();
        }
        if (!Regex.IsMatch(StuEmail.Text.ToString(), @"^([a-zA-Z0-9]+[_|_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$"))
        {
            throw new Exception();
        }


        if (Request.QueryString["id"] != null)
        {
            StuNo.Value = Request.QueryString["id"].ToString();
        }
        else
        {
            return;
        }

        string server    = Server.MapPath("~/");
        string imageName = UploadSupport.GenerateRandom(10) + ".jpg";
        string error;

        if (!UploadSupport.SaveImage(ImageFile, server, imageName, out error))
        {
            return;
        }

        StudentInfo student = bllStudent.Get(Int32.Parse(StuNo.Value));

        student.Stu_UserName    = StuNickName.Text.ToString();
        student.Stu_Email       = StuEmail.Text.ToString();
        student.Stu_LastLogin   = DateTime.Now;
        student.Stu_RegisteTime = DateTime.Now;
        student.Stu_Image       = UploadSupport.Image(imageName);
        //头像
        //时长

        bllStudent.Modify(student);

        Response.Redirect("~/User/UserList.aspx");
    }
Ejemplo n.º 4
0
    //点击提交,对个人信息内容进行修改
    protected void Submit_Click(object sender, EventArgs e)
    {
        HttpCookie  cookie  = Request.Cookies["usr"];
        StudentInfo student = bllStudent.Get(Convert.ToInt32(cookie.Values["ID"]));

        //student.Stu_UserName = Name.Text.ToString();
        //student.Stu_Email = Mailbox.Text.ToString();
        student.Stu_Tel = Telephone.Text.ToString();
        if (Radio.SelectedItem != null)
        {
            student.Stu_Sex = Radio.SelectedItem.Value;
        }

        if (HeadImage.HasFile)
        {
            student.Stu_Image = SaveFile(HeadImage.PostedFile);
        }
        Console.WriteLine("xiugai");
        bllStudent.Modify(student);
        Response.Redirect("~/Student/StudentModifyAccount.aspx");
    }
Ejemplo n.º 5
0
    //验证登录
    //在cookie中添加user
    protected void Login_Click(object sender, EventArgs e)
    {
        StudentInfo student  = new StudentInfo();
        StudentInfo student2 = bllStudent.GetByName(Username.Text.Trim());

        if (student2 == null)
        {
            return;
        }
        student.Stu_ID       = student2.Stu_ID;
        student.Stu_Password = Password.Text.ToString().Trim();
        if (bllStudent.CheckLogin(student))
        {
            student2.Stu_LastLogin = DateTime.Now;
            bllStudent.Modify(student2);
            HttpCookie cookie = new HttpCookie("usr");
            cookie.Values["ID"]   = student.Stu_ID.ToString();
            cookie.Values["pass"] = Password.Text.ToString().Trim();
            cookie.Expires        = System.DateTime.Now.AddDays(1);//设置过期时间  1天
            Response.Cookies.Add(cookie);
            Response.Redirect("~/Home/Home.aspx");
        }
    }