示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.HttpMethod == "POST")
            {
                Student = LabDB.StudentInfo.SingleOrDefault(d => d.Id == Request.Form["resetId"]);

                if (Student == null)
                {
                    Response.Redirect("Login.aspx");
                }

                if (Request.Form["NewPwd"].Length >= 4 && Request.Form["NewPwd"] == Request.Form["ConfirmPwd"])
                {
                    Student.Account.Password = Request.Form["NewPwd"].ToMD5();
                    LabDB.SubmitChanges();
                    Response.Write("<script type=\"text/javascript\">alert(\"修改成功!\");</script>");

                }
                else
                {
                    Response.Write("<script type=\"text/javascript\">alert(\"修改失败!请检查输入\");</script>");
                }
                Response.Write(" <script type=\"text/javascript\"> window.location.href= 'Login.aspx ' </script> ");

            }
        }
示例#2
0
        public void ProcessRequest(HttpContext context)
        {
            Account  user = (Account)context.Session["sid"];
            Student = LabDB.StudentInfo.SingleOrDefault(d => d.AccountId == user.Id);

            PackageBookInfo bookInfo = new PackageBookInfo
            {
                StudentInfo=Student,
                PackageArrangeId = Convert.ToInt32(context.Request.QueryString["arrangeid"].Trim()),
                BookTime = DateTime.Now,
                UserAgent = context.Request.UserAgent.ToString(),
            };

            context.Response.ContentType = "text/plain";

            try
            {
                if (LabDB.PackageBookInfo.FirstOrDefault(d => d.PackageArrangeId == bookInfo.PackageArrangeId && d.StudentId == bookInfo.StudentId) != null)
                {
                    throw (new Exception("已经预约!不能再次预约!"));
                }

                LabDB.PackageBookInfo.InsertOnSubmit(bookInfo);
                LabDB.SubmitChanges();
                context.Response.Write("1");

            }

            catch (Exception ex)
            {
                context.Response.Write("预约失败!请联系管理员!" );
            }
        }
示例#3
0
 /// <summary>
 /// 是否此实验已经预约过。
 /// </summary>
 /// <param name="student"></param>
 /// <param name="package"></param>
 /// <returns></returns>
 protected bool IsBooked(StudentInfo student, CoursePackage package)
 {
     PackageBookInfo info = LabDB.PackageBookInfo.FirstOrDefault(d => d.StudentInfo == student && d.PackageArrange.CoursePackage == package);
     if (info != null)
         return true;
     else return false;
 }
示例#4
0
 /// <summary>
 /// 此课堂能否预约。
 /// </summary>
 /// <param name="arrange"></param>
 /// <param name="student"></param>
 /// <returns></returns>
 protected bool CanBeBooked(PackageArrange arrange, StudentInfo student)
 {
     if (student == null || arrange == null || arrange.Capacity <= arrange.PackageBookInfo.Count || IsBooked(student, arrange.CoursePackage))
         return false;
     else return true;
 }
示例#5
0
 partial void DeleteStudentInfo(StudentInfo instance);
示例#6
0
 partial void UpdateStudentInfo(StudentInfo instance);
示例#7
0
 partial void InsertStudentInfo(StudentInfo instance);
示例#8
0
		private void detach_StudentInfo(StudentInfo entity)
		{
			this.SendPropertyChanging();
			entity.Account = null;
		}
示例#9
0
 protected bool IsBooked(StudentInfo student, CourseInfo course)
 {
     if (LabDB.CourseBookInfo.FirstOrDefault(d => d.StudentInfo == student && d.CourseArrange.CourseInfo == course) != null)
         return true;
     else return false;
 }
示例#10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //获取学生信息。
            var entrant = (Account)Session["sid"];
            Student = LabDB.StudentInfo.SingleOrDefault(d => d.AccountId == entrant.Id);

            //获取当前学生课程预约信息。
            IEnumerable<CourseBookInfo> courseBookList = LabDB.CourseBookInfo.Where(d => d.StudentId == Student.Id);
            CourseArrangeList = new List<CourseArrange>();
            foreach (var bookInfo in courseBookList)
            {
                CourseArrangeList.Add(LabDB.CourseArrange.SingleOrDefault(d => d.Id == bookInfo.CourseArrangeId));
            }

            //获取当前学生实验包预约信息。
            IEnumerable<PackageBookInfo> packageBookList = LabDB.PackageBookInfo.Where(d => d.StudentId == Student.Id);
            PackageArrangeList = new List<PackageArrange>();
            foreach (var bookInfo in packageBookList)
            {
                PackageArrangeList.Add(LabDB.PackageArrange.SingleOrDefault(d=>d.Id==bookInfo.PackageArrangeId));
            }

            //相应表单提交操作。
            if (Request.HttpMethod == "POST")
            {
                switch (Request.QueryString["id"])
                {
                    case "1"://个人信息表单。
                        if (Request.Form["Sex"] != null)
                        {
                            Student.Sex = Request.Form["Sex"] == "male";// 男性保存为真,女性保存为假。
                        }
                        //表单信息格式验证。
                        if (!Request.Form["PhoneNumber"].IsPhoneNumber())
                        {
                            Response.Write("<script type=\"text/javascript\"> alert('电话号码格式错误!请检查输入!');</script>");
                            return;
                        }

                        if (!Request.Form["Email"].IsEmailAddress())
                        {
                            Response.Write("<script type=\"text/javascript\"> alert('电子邮件格式错误!请检查输入!');</script>");
                            return;
                        }

                        Student.PhoneNumber = Request.Form["PhoneNumber"];
                        Student.Email = Request.Form["Email"];

                        LabDB.SubmitChanges();
                        SuccessMessage = "个人信息保存成功";
                        break;

                    case "2"://预约信息表单。
                        break;

                    case "3"://修改密码表单。
                        //新密码验证。

                        if (Request.Form["OldPwd"].ToMD5() == entrant.Password && Request.Form["NewPwd"].Length >= 4 && Request.Form["NewPwd"] == Request.Form["ConfirmPwd"])
                        {
                            Student.Account.Password = Request.Form["NewPwd"].ToMD5();
                            LabDB.SubmitChanges();
                            SuccessMessage = "修改成功!";
                            //Response.Write("<script type=\"text/javascript\">alert(\"修改成功!\");</script>");
                            //Response.Write(" <script> window.location.href= 'Home.aspx ' </script> ");
                            return;
                        }
                        else
                        {
                            FailMessage = "密码修改失败,请检查输入";
                        }
                        break;
                    default: break;
                }
            }
        }