コード例 #1
0
ファイル: SendPwd.aspx.cs プロジェクト: neoloong/LabBook
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.HttpMethod == "POST")
            {
                using (LabBookDBDataContext LabDB = new LabBookDBDataContext())
                {
                    var Student = LabDB.StudentInfo.SingleOrDefault(d => d.Id == Request.Form["Id"]);
                    if (Student == null || Student.Name.Trim() != Request.Form["Name"].Trim())
                    {
                        Message = "该用户不存在!请检查输入!";
                        Response.Redirect("SendPwd.aspx");
                    }

                    if (Student.Email == null)
                    {
                        Message = "您没有设置安全邮箱!无法找回密码!请联系管理员!";
                        Response.Redirect("SendPwd.aspx");
                    }

                    //发送邮件。

                    MailMessage mail = new MailMessage(new MailAddress("*****@*****.**", "光电学院实验预约系统"), new MailAddress(Student.Email, Student.Name));

                    //邮件编码格式。
                    mail.BodyEncoding = System.Text.Encoding.UTF8;
                    mail.IsBodyHtml = true;

                    //邮件内容。
                    mail.Subject = "光电子科学与工程学院实验预约系统密码找回";

                    mail.Body = Student.Name + ":您好! 您在光电学院实验预约系统上申请了找回密码,请点击以下链接确认更改。" + Request.Url.GetLeftPart(UriPartial.Authority) + "/ResetPwd.aspx?resetId=" + Student.Id + "请在20分钟内完成密码重置。";
                    //mail.Body = Student.Name + ":您好! 您在光电学院实验预约系统上申请了找回密码,请点击以下链接确认更改。" + Request.PhysicalApplicationPath + "/ResetPwd.aspx?resetId=" + Student.Id + "请在20分钟内完成密码重置。";
                    mail.Priority = MailPriority.Normal;

                    SmtpClient client = new SmtpClient();

                    client.Host = "smtp.126.com";

                    client.UseDefaultCredentials = false;
                    client.Credentials = new System.Net.NetworkCredential("labbook", "~!@#$%^&*()_+");
                    client.DeliveryMethod = SmtpDeliveryMethod.Network;
                    client.Send(mail);

                    //设置Session。
                    Session["resetId"] = Student.Id;
                }
            }
        }
コード例 #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                using (LabBookDBDataContext LabDB = new LabBookDBDataContext())
                {
                    CourseBookInfo courseBookInfo = LabDB.CourseBookInfo.SingleOrDefault(d => d.CourseArrangeId.ToString() == Request.QueryString["arrangeId"].Trim() && d.StudentId == Request.QueryString["studentId"].Trim());
                    LabDB.CourseBookInfo.DeleteOnSubmit(courseBookInfo);
                    LabDB.SubmitChanges();
                }
            }
            catch { }

            //Response.Redirect("IndividualCenter.aspx");

            Response.Write("<script type=\"text/javascript\">alert(\"取消成功\");</script>");
            Response.Write(" <script> window.location.href= 'OrderState.aspx ' </script> ");
        }
コード例 #3
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                using (LabBookDBDataContext LabDB = new LabBookDBDataContext())
                {

                    string arrangeId = context.Request.QueryString["arrangeid"].Trim();
                    string studentId = context.Request.QueryString["studentid"].Trim();

                    //检查是否已经预约满。
                    if (LabDB.CourseBookInfo.Where(d => d.CourseArrangeId.ToString() == arrangeId).Count() >= LabDB.CourseArrange.FirstOrDefault(d => d.Id.ToString() == arrangeId).Capacity)
                    {
                        throw (new Exception("此实验已经预约满!"));
                    }

                    //检查是否已经预约过。
                        if (LabDB.CourseBookInfo.FirstOrDefault(d => d.CourseArrangeId.ToString() == arrangeId && d.StudentId == studentId) != null)
                    {
                        throw(new Exception("此实验你已经预约过!不能重复预约同一实验!"));
                    }
                    CourseBookInfo courseBookInfo = new CourseBookInfo
                    {
                        StudentId = context.Request.QueryString["studentid"],
                        CourseArrangeId = Convert.ToInt32(context.Request.QueryString["arrangeid"].Trim()),
                        BookTime=DateTime.Now,
                        UserAgent=context.Request.UserAgent.ToString(),
                    };

                    LabDB.CourseBookInfo.InsertOnSubmit(courseBookInfo);
                    LabDB.SubmitChanges();

                }
                context.Response.Write("1");
            }

            catch(Exception ex)
            {
                context.Response.Write(ex.Message);
            }
        }