コード例 #1
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);
            }
        }
コード例 #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            StudentInfo student = LabDB.StudentInfo.SingleOrDefault(d => d.Account == (Account)context.Session["sid"]);

            PackageBookInfo bookInfo = LabDB.PackageBookInfo.SingleOrDefault(d => d.PackageArrangeId.ToString() == context.Request.QueryString["arrangeId"]);

            LabDB.PackageBookInfo.DeleteOnSubmit(bookInfo);

            try
            {
                LabDB.SubmitChanges();
                context.Response.Write("1");
            }

            catch {
                context.Response.Write("0");
            }
        }
コード例 #3
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("预约失败!请联系管理员!");
            }
        }