示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            using (LabBookDBDataContext LabDB = new LabBookDBDataContext())
            {
                try
                {
                    BulletinToDelete = LabDB.Bulletin.SingleOrDefault(d => d.Id.ToString() == Request.QueryString["id"]);
                    if (BulletinToDelete != null)
                    {
                        LabDB.Bulletin.DeleteOnSubmit(BulletinToDelete);
                        LabDB.SubmitChanges();
                        //Response.Write("<script type=\"text/javascript\"> alert('删除成功!');</script>");
                        //Response.Write("<script type=\"text/javascript\"> window.location='BulletinManage.aspx'</script>");
                        Response.Write("1");
                        //return;
                        //Response.Redirect("BulletinManage.aspx");

                    }

                }

                catch (Exception ex)
                {
                    //Response.Write("<script type=\"text/javascript\"> alert('"+ex.Message+"');</script>");
                    //Response.Write("<script type=\"text/javascript\"> window.location='BulletinManage.aspx'</script>");

                    Response.Write("0");
                    //return;
                    //Response.Redirect("BulletinManage.aspx");
                }
            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.HttpMethod == "POST")
            {
                Semester newTerm = new Semester
                {
                    SchoolYear = Request.Form["SchoolYear"],
                    Season     = Request.Form["Season"],
                };

                LabDB.Semester.InsertOnSubmit(newTerm);
                try
                {
                    LabDB.SubmitChanges();
                }
                catch (Exception ex)
                {
                    Response.Write("<script type=\"text/javascript\"> alert('添加数据时发生错误!请重试或联系管理员!');</script>");
                    return;
                }

                Response.Write("<script type=\"text/javascript\"> alert('添加成功!');</script>");
                Response.Write("<script type=\"text/javascript\"> window.location='ExperimentManage.aspx'</script>");
            }
        }
示例#3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.HttpMethod == "POST")
            {
                if (Request.Form["OldPwd"].ToMD5() == Student.Account.Password && Request.Form["NewPwd"].Length >= 6 && Request.Form["NewPwd"].Length <= 12 && Request.Form["NewPwd"] == Request.Form["ConfirmPwd"])
                {
                    Student.Account.Password = Request.Form["NewPwd"].ToMD5();

                    try
                    {
                        LabDB.SubmitChanges();
                    }
                    catch
                    {
                        Message = "密码修改失败,请检查输入";
                    }
                    Message = "修改成功!";
                    //SuccessMessage = "修改成功!";
                    //Response.Write("<script type=\"text/javascript\">alert(\"修改成功!\");</script>");
                    //Response.Write(" <script> window.location.href= 'Home.aspx ' </script> ");
                    return;
                }
                else
                {
                    //FailMessage = "密码修改失败,请检查输入";
                    Message = "密码修改失败,请检查输入!";
                }
            }
        }
示例#4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            using (LabBookDBDataContext LabDB = new LabBookDBDataContext())
            {
                try
                {
                    BulletinToDelete = LabDB.Bulletin.SingleOrDefault(d => d.Id.ToString() == Request.QueryString["id"]);
                    if (BulletinToDelete != null)
                    {
                        LabDB.Bulletin.DeleteOnSubmit(BulletinToDelete);
                        LabDB.SubmitChanges();
                        //Response.Write("<script type=\"text/javascript\"> alert('删除成功!');</script>");
                        //Response.Write("<script type=\"text/javascript\"> window.location='BulletinManage.aspx'</script>");
                        Response.Write("1");
                        //return;
                        //Response.Redirect("BulletinManage.aspx");
                    }
                }

                catch (Exception ex)
                {
                    //Response.Write("<script type=\"text/javascript\"> alert('"+ex.Message+"');</script>");
                    //Response.Write("<script type=\"text/javascript\"> window.location='BulletinManage.aspx'</script>");

                    Response.Write("0");
                    //return;
                    //Response.Redirect("BulletinManage.aspx");
                }
            }
        }
示例#5
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> ");
            }
        }
示例#6
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";


            //PackageArrange arrange = LabDB.PackageArrange.SingleOrDefault(d => d.Id.ToString() == context.Request["arrangeId"]);
            CoursePackage package = LabDB.CoursePackage.SingleOrDefault(d => d.Id.ToString() == context.Request["packageId"]);

            LabDB.CoursePackage.DeleteOnSubmit(package);

            try
            {
                LabDB.SubmitChanges();
                LabDB.Connection.Close();
            }
            catch (Exception ex)
            {
                //删除失败返回错误信息。
                context.Response.Write(ex.Message);
                return;
            }

            //删除成功返回1。
            context.Response.Write("1");
        }
示例#7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Arrange = LabDB.CourseArrange.SingleOrDefault(d => d.Id.ToString() == Request.QueryString["arrangeId"]);

            if (!Common.isNullorWhiteSpace(Request["Capacity"]))
            {
                //添加新课堂时间安排。
                Arrange = LabDB.CourseArrange.SingleOrDefault(d => d.Id.ToString() == Request.QueryString["arrangeId"]);

                //修改课堂时间安排。
                if (Arrange == null)
                {
                    Arrange             = new CourseArrange();
                    Arrange.CourseId    = Course.Id;
                    Arrange.Capacity    = Convert.ToInt32(Request["Capacity"]);
                    Arrange.Week        = Convert.ToByte(Request["Week"]);
                    Arrange.WeekDay     = Convert.ToByte(Request["WeekDay"]);
                    Arrange.BeginLesson = Convert.ToByte(Request["BeginLesson"]);
                    Arrange.EndLesson   = Convert.ToByte(Request["EndLesson"]);
                    LabDB.CourseArrange.InsertOnSubmit(Arrange);
                }

                else
                {
                    Arrange.Capacity    = Convert.ToInt32(Request["Capacity"]);
                    Arrange.Week        = Convert.ToByte(Request["Week"]);
                    Arrange.WeekDay     = Convert.ToByte(Request["WeekDay"]);
                    Arrange.BeginLesson = Convert.ToByte(Request["BeginLesson"]);
                    Arrange.EndLesson   = Convert.ToByte(Request["EndLesson"]);
                }

                try
                {
                    LabDB.SubmitChanges();
                }


                catch
                {
                    return;
                }

                //页面跳回本课堂管理页面。
                string link = "../Manage/CourseArrangeManage.aspx?courseId=";
                if (Course != null)
                {
                    link += Course.Id;
                }
                else
                {
                    link += Arrange.CourseId;
                }

                Response.Redirect(link);
            }
        }
示例#8
0
        public void ProcessRequest(HttpContext context)
        {
            using (LabBookDBDataContext LabDB = new LabBookDBDataContext())
            {
                ExperimentInfo experiment = LabDB.ExperimentInfo.SingleOrDefault(d => d.Id.ToString() == context.Request.QueryString["id"]);
                LabDB.ExperimentInfo.DeleteOnSubmit(experiment);
                LabDB.SubmitChanges();
            }

            context.Response.ContentType = "text/plain";
        }
示例#9
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["id"] != null)
            {
                try
                {
                    BulletinToModify = LabDB.Bulletin.SingleOrDefault(d => d.Id.ToString() == Request.QueryString["id"]);
                    if (BulletinToModify == null)
                    {
                        Response.Write("<script type=\"text/javascript\"> alert('错误!该公告不存在!');</script>");
                    }
                }
                catch (Exception ex)
                {
                    Response.Write("<script type=\"text/javascript\"> alert('错误!" + ex.Message + "');</script>");
                }
            }

            if (Request.HttpMethod == "POST")
            {
                if (Request.Form["Title"].isNullorWhiteSpace())
                {
                    Response.Write("<script type=\"text/javascript\"> alert('公告标题不能为空!');</script>");
                    return;
                }
                if (Request.Form["Bulletiner"].isNullorWhiteSpace())
                {
                    Response.Write("<script type=\"text/javascript\"> alert('发布人不能为空!');</script>");
                    return;
                }
                if (Request.Form["editorValue"].isNullorWhiteSpace())
                {
                    Response.Write("<script type=\"text/javascript\"> alert('公告内容不能为空!');</script>");
                    return;
                }

                try
                {
                    BulletinToModify.Title      = Request.Form["Title"].Trim();
                    BulletinToModify.Bulletiner = Request.Form["Bulletiner"];
                    BulletinToModify.Content    = Request.Form["editorValue"];
                    BulletinToModify.Date       = DateTime.Now;

                    LabDB.SubmitChanges();
                }
                catch (Exception ex)
                {
                    Response.Write("<script type=\"text/javascript\"> alert('" + ex.Message + "');</script>");
                    return;
                }

                Response.Redirect("../Bulletin.aspx?id=" + BulletinToModify.Id);
            }
        }
示例#10
0
        public void ProcessRequest(HttpContext context)
        {
            using (LabBookDBDataContext LabDB = new LabBookDBDataContext())
            {
                ExperimentInfo experiment = LabDB.ExperimentInfo.SingleOrDefault(d=>d.Id.ToString()==context.Request.QueryString["id"]);
                LabDB.ExperimentInfo.DeleteOnSubmit(experiment);
                LabDB.SubmitChanges();
            }

            context.Response.ContentType = "text/plain";
        }
示例#11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.HttpMethod == "POST")
            {
                #region 检查提交信息是否为空。

                //实验名称。
                if (Request.Form["Name"] == "")
                {
                    Response.Write("<script type=\"text/javascript\"> alert('实验大类名称不能为空!');</script>");
                    return;
                }

                //实验照片。
                if (Request.Files["Photo"] == null || Request.Files["Photo"].ContentLength == 0)
                {
                    Response.Write("<script type=\"text/javascript\"> alert('照片不能为空!');</script>");
                    return;
                }
                #endregion
                HttpPostedFile photo     = Request.Files["Photo"];
                string         photoName = Request.Form["Name"] + DateTime.Now.ToString("yyyy-mm-dd-hh-mm-ss") + "." + photo.ContentType.Split('/')[1];

                ExperimentInfo newExperiment = new ExperimentInfo
                {
                    Name     = Request.Form["Name"].Trim(),
                    Semester = presentTerm,
                    //Order=
                    PhotoUrl = "../Datas/Photos/Experiment/" + photoName,
                };


                photo.SaveAs(Request.PhysicalApplicationPath + "Datas\\Photos\\Experiment\\" + photoName);
                LabDB.ExperimentInfo.InsertOnSubmit(newExperiment);
                try
                {
                    LabDB.SubmitChanges();
                    Response.Write("<script type=\"text/javascript\"> alert('添加成功!');</script>");
                    return;
                }
                catch
                {
                    Response.Write("<script type=\"text/javascript\"> alert('发生错误!请重试或联系管理员!');</script>");
                    return;
                }
            }
        }
示例#12
0
        //protected string Message = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.HttpMethod == "POST")
            {
                if (Request.Form["Title"].isNullorWhiteSpace())
                {
                    Response.Write("<script type=\"text/javascript\"> alert('公告标题不能为空!');</script>");
                    return;
                } if (Request.Form["Bulletiner"].isNullorWhiteSpace())
                {
                    Response.Write("<script type=\"text/javascript\"> alert('发布人不能为空!');</script>");
                    return;
                }
                if (Request.Form["editorValue"].isNullorWhiteSpace())
                {
                    Response.Write("<script type=\"text/javascript\"> alert('公告内容不能为空!');</script>");
                    return;
                }

                try
                {
                    Bulletin bulletin = new Bulletin
                    {
                        Title = Request.Form["Title"].Trim(),
                        Bulletiner = Request.Form["Bulletiner"].Trim(),
                        Content = Request.Form["editorValue"],
                        Date = DateTime.Now,
                    };

                    using (LabBookDBDataContext LabDB = new LabBookDBDataContext())
                    {
                        LabDB.Bulletin.InsertOnSubmit(bulletin);
                        LabDB.SubmitChanges();
                    }

                     Response.Redirect("../Bulletin.aspx?id="+bulletin.Id);
                }
                catch (Exception ex)
                {
                    Response.Write("<script type=\"text/javascript\"> alert('" + ex.Message + "');</script>");
                    return;
                }

            }
        }
示例#13
0
        //protected string Message = "";

        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.HttpMethod == "POST")
            {
                if (Request.Form["Title"].isNullorWhiteSpace())
                {
                    Response.Write("<script type=\"text/javascript\"> alert('公告标题不能为空!');</script>");
                    return;
                }
                if (Request.Form["Bulletiner"].isNullorWhiteSpace())
                {
                    Response.Write("<script type=\"text/javascript\"> alert('发布人不能为空!');</script>");
                    return;
                }
                if (Request.Form["editorValue"].isNullorWhiteSpace())
                {
                    Response.Write("<script type=\"text/javascript\"> alert('公告内容不能为空!');</script>");
                    return;
                }

                try
                {
                    Bulletin bulletin = new Bulletin
                    {
                        Title      = Request.Form["Title"].Trim(),
                        Bulletiner = Request.Form["Bulletiner"].Trim(),
                        Content    = Request.Form["editorValue"],
                        Date       = DateTime.Now,
                    };

                    using (LabBookDBDataContext LabDB = new LabBookDBDataContext())
                    {
                        LabDB.Bulletin.InsertOnSubmit(bulletin);
                        LabDB.SubmitChanges();
                    }

                    Response.Redirect("../Bulletin.aspx?id=" + bulletin.Id);
                }
                catch (Exception ex)
                {
                    Response.Write("<script type=\"text/javascript\"> alert('" + ex.Message + "');</script>");
                    return;
                }
            }
        }
示例#14
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> ");
        }
示例#15
0
 public void ProcessRequest(HttpContext context)
 {
     context.Response.ContentType = "text/plain";
     using (LabBookDBDataContext LabDB = new LabBookDBDataContext())
     {
         try
         {
             Semester term = LabDB.Semester.SingleOrDefault(d => d.Id.ToString() == context.Request.QueryString["id"]);
             LabDB.Semester.DeleteOnSubmit(term);
             LabDB.SubmitChanges();
         }
         catch (Exception ex)
         {
             context.Response.Write("<script type=\"text/javascript\"> alert('发生错误!错误信息:" + ex.Message + "');</script>");
         }
         context.Response.Write("删除成功!");
     }
 }
示例#16
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");
            }
        }
示例#17
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            using (LabBookDBDataContext LabDB = new LabBookDBDataContext())
            {
                try
                {

                    Semester term = LabDB.Semester.SingleOrDefault(d => d.Id.ToString() == context.Request.QueryString["id"]);
                    LabDB.Semester.DeleteOnSubmit(term);
                    LabDB.SubmitChanges();
                }
                catch (Exception ex)
                {
                    context.Response.Write("<script type=\"text/javascript\"> alert('发生错误!错误信息:"+ex.Message+"');</script>");
                }
                context.Response.Write("删除成功!");

            }
        }
示例#18
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            StudentInfo student = LabDB.StudentInfo.SingleOrDefault(d => d.Id.ToString() == context.Request.QueryString["id"]);

            LabDB.StudentInfo.DeleteOnSubmit(student);


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

            catch
            {
                context.Response.Write("0");
            }
            LabDB.Connection.Close();
        }
示例#19
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);
            }
        }
示例#20
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                using (LabBookDBDataContext LabDB = new LabBookDBDataContext())
                {
                    CourseInfo course = LabDB.CourseInfo.SingleOrDefault(d => d.Id.ToString() == Request.QueryString["courseId"]);

                    LabDB.CourseInfo.DeleteOnSubmit(course);
                    LabDB.SubmitChanges();

                    Response.Write("<script type=\"text/javascript\"> alert('删除成功!');</script>");
                    Response.Write("<script type=\"text/javascript\">window.location='CourseManage.aspx?id=" + Request.QueryString["experimentId"] + "';</script>");
                }
            }
            catch
            {
                Response.Write("<script type=\"text/javascript\"> alert('发生错误!删除失败!请联系管理员。');</script>");
                Response.Write("<script type=\"text/javascript\">window.location='CourseManage.aspx?id=" + Request.QueryString["experimentId"] + "';</script>");
            }
        }
示例#21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //修改安排。
            if (Request.QueryString["packageId"].isNullorWhiteSpace())
            {
                Arrange = LabDB.PackageArrange.SingleOrDefault(d => d.Id.ToString() == Request.QueryString["arrangeId"]);
                Package = Arrange.CoursePackage;
            }
            //添加新安排。
            else
            {
                Package = LabDB.CoursePackage.SingleOrDefault(d => d.Id.ToString() == Request.QueryString["packageId"]);
            }

            if (Request.HttpMethod == "POST")
            {
                if (Arrange == null)
                {
                    Arrange = new PackageArrange {
                        CoursePackage = Package
                    };
                    LabDB.PackageArrange.InsertOnSubmit(Arrange);
                }

                //收集安排信息。
                Arrange.CustomTime = Request.Form["CustomTime"];

                try
                {
                    Arrange.Capacity = Int32.Parse(Request.Form["Capacity"]);//Int32的Parse方法可能会抛出错误。

                    LabDB.SubmitChanges();
                }
                catch
                {
                }

                Response.Redirect("PackageArrangeManage.aspx?packageId=" + Package.Id);
            }
        }
示例#22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                using (LabBookDBDataContext LabDB = new LabBookDBDataContext())
                {
                    CourseInfo course = LabDB.CourseInfo.SingleOrDefault(d => d.Id.ToString() == Request.QueryString["courseId"]);

                    LabDB.CourseInfo.DeleteOnSubmit(course);
                    LabDB.SubmitChanges();

                    Response.Write("<script type=\"text/javascript\"> alert('删除成功!');</script>");
                    Response.Write("<script type=\"text/javascript\">window.location='CourseManage.aspx?id="+Request.QueryString["experimentId"]+"';</script>");
                }

            }
            catch
            {
                Response.Write("<script type=\"text/javascript\"> alert('发生错误!删除失败!请联系管理员。');</script>");
                Response.Write("<script type=\"text/javascript\">window.location='CourseManage.aspx?id="+Request.QueryString["experimentId"]+"';</script>");
            }
        }
示例#23
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.HttpMethod == "POST")
            {
                if (Request.Form["Sex"] != null)
                {
                    Student.Sex = Request.Form["Sex"] == "male";// 男性保存为真,女性保存为假。
                }
                //表单信息格式验证。
                if (!Request.Form["PhoneNumber"].IsPhoneNumber())
                {
                    //Response.Write("<script type=\"text/javascript\"> alert('电话号码格式错误!请检查输入!');</script>");
                    Message = "电话号码格式错误!请检查输入!";
                    return;
                }

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

                Student.PhoneNumber = Request.Form["PhoneNumber"];
                Student.Email       = Request.Form["Email"];
                try
                {
                    LabDB.SubmitChanges();
                    Message = "个人信息修改成功!";
                }
                catch
                {
                    Message = "发生错误!请检查输入后重试!";
                }
            }
        }
示例#24
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("预约失败!请联系管理员!");
            }
        }
示例#25
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            #region 检查输入是否完整且合法。

            //实验包名称。
            if (context.Request.Form["name"].isNullorWhiteSpace())
            {
                context.Response.Write("实验包名称不能为空");
                return;
            }

            //实验地点。
            if (context.Request.Form["address"].isNullorWhiteSpace())
            {
                context.Response.Write("实验地点不能为空!");
                return;
            }

            //学时。
            if (context.Request.Form["classHour"].isNullorWhiteSpace())
            {
                context.Response.Write("学时不能为空!");
                return;
            }



            //指导老师。
            if (context.Request.Form["teacherId"].isNullorWhiteSpace())
            {
                context.Response.Write("指导老师不能为空!");
                return;
            }


            #endregion


            if (context.Request.Form["packageId"].isNullorWhiteSpace())
            {
                Package = new CoursePackage     //课程包添加。
                {
                    ExperimentInfo = LabDB.ExperimentInfo.SingleOrDefault(d => d.Id.ToString() == context.Request.Form["experimentId"]),
                };

                LabDB.CoursePackage.InsertOnSubmit(Package);
            }
            else       //课程包修改。
            {
                Package = LabDB.CoursePackage.SingleOrDefault(d => d.Id.ToString() == context.Request.Form["packageId"]);
                foreach (var packageList in Package.PackagedCourse)
                {
                    LabDB.PackagedCourse.DeleteOnSubmit(packageList);
                }
            }


            Package.Name        = context.Request.Form["name"];
            Package.ClassHour   = Convert.ToByte(context.Request.Form["classHour"]);
            Package.TeacherInfo = LabDB.TeacherInfo.SingleOrDefault(d => d.Id.ToString() == context.Request.Form["teacherId"]);
            Package.Address     = context.Request.Form["address"];



            foreach (var item in context.Request.Form)
            {
                if (Common.RegexValidate("^[0-9]*$", item.ToString()))
                {
                    PackagedCourse packageList = new PackagedCourse
                    {
                        CourseInfo    = LabDB.CourseInfo.SingleOrDefault(d => d.Id.ToString() == item.ToString()),
                        CoursePackage = Package,
                    };

                    LabDB.PackagedCourse.InsertOnSubmit(packageList);
                }
            }

            //LabDB.CoursePackage.InsertOnSubmit(Package);

            try
            {
                LabDB.SubmitChanges();
                context.Response.Write("1");
            }
            catch (Exception ex)
            {
                context.Response.Write("错误!" + ex.Message);
            }
        }
示例#26
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.HttpMethod == "POST")
            {
                #region 检查提交的信息是否完整。
                if (Request.HttpMethod == "POST")
                {
                    //姓名。
                    if (Request.Form["Name"].isNullorWhiteSpace())
                    {
                        Response.Write("<script type=\"text/javascript\"> alert('教师姓名不能为空!');</script>");
                        return;
                    }

                    //用户名。
                    if (Request.Form["Account"].isNullorWhiteSpace())
                    {
                        Response.Write("<script type=\"text/javascript\"> alert('用户名不能为空!');</script>");
                        return;
                    }

                    //密码。
                    if (Request.Form["Password"].isNullorWhiteSpace())
                    {
                        Response.Write("<script type=\"text/javascript\"> alert('密码不能为空!');</script>");
                        return;
                    }
                    //电话。
                    if (Request.Form["Tel"].isNullorWhiteSpace())
                    {
                        Response.Write("<script type=\"text/javascript\"> alert('电话号码不能为空!');</script>");
                        return;
                    }

                    if (Request.Form["Sex"].isNullorWhiteSpace())
                    {
                        Response.Write("<script type=\"text/javascript\"> alert('性别不能为空!');</script>");
                        return;
                    }
                    //照片。
                    if (Request.Files["Photo"] == null || Request.Files["Photo"].ContentLength == 0)
                    {
                        Response.Write("<script type=\"text/javascript\"> alert('照片不能为空!');</script>");
                        return;
                    }
                }
                #endregion

                #region 检查信息电话格式合法性。
                if (!Request.Form["Tel"].IsPhoneNumber())
                {
                    Response.Write("<script type=\"text/javascript\"> alert('电话号码格式不正确!请检查输入!');</script>");
                    return;
                }

                #endregion

                #region 新建教师信息并存入数据库。
                try
                {
                    Teacher.Account.UserName = Request.Form["Account"].Trim();
                    Teacher.Account.Password = Request.Form["Password"].Trim().ToMD5();


                    HttpPostedFile photo = Request.Files["Photo"];

                    string photoName = Request.Form["Name"] + DateTime.Now.ToString("yyyy-mm-dd-hh-mm-ss") + "." + photo.ContentType.Split('/')[1];


                    Teacher.Name        = Request.Form["Name"].Trim();
                    Teacher.Sex         = Request.Form["Sex"] == "male" ? true : false;
                    Teacher.PhoneNumber = Request.Form["Tel"].Trim();
                    Teacher.Remarks     = Request.Form["Remarks"].Trim();
                    Teacher.PhotoUrl    = "Datas/Photos/Teacher/" + photoName;


                    photo.SaveAs(Request.PhysicalApplicationPath + "Datas\\Photos\\Teacher\\" + photoName);


                    LabDB.SubmitChanges();
                }
                catch
                {
                    Response.Write("<script type=\"text/javascript\"> alert('发生错误!请检查信息录入是否合法!');</script>");
                    return;
                }
                Response.Write("<script type=\"text/javascript\">alert('修改成功!')</script>");
                Response.Write("<script type=\"text/javascript\">window.location='TeachersManage.aspx'</script>");
                //Response.Redirect("TeachersManage.aspx");
                #endregion
            }
        }
示例#27
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.HttpMethod == "POST" && Request.Files["StudentInfoList"] != null)
            {
                //检查学院名是否为空。
                if (Request.Form["College"].isNullorWhiteSpace())
                {
                    Response.Write("<script type=\"text/javascript\">alert('学院名不能为空!')</script>");
                    return;
                }

                //检查默认密码是否为空。
                if (Request.Form["DefaultPwd"].isNullorWhiteSpace())
                {
                    Response.Write("<script type=\"text/javascript\">alert('默认密码不能为空!')</script>");
                    return;
                }

                //检查上传的学生名单是够为空。
                var uploadFile = Request.Files["StudentInfoList"];
                if (uploadFile.ContentLength == 0)
                {
                    Response.Write("<script type=\"text/javascript\">alert('学生名单不能为空!')</script>");
                    return;
                }

                try
                {
                    if (uploadFile.ContentLength > 100000)
                    {
                        throw new Exception("");
                    }

                    #region 读取学生名单。
                    //实例化文件读取对象。
                    Stream       fileStream   = uploadFile.InputStream;
                    StreamReader streamReader = new StreamReader(fileStream, System.Text.Encoding.Default);

                    string   line = streamReader.ReadLine();
                    string[] words;
                    while (line != null)
                    {
                        words = line.Trim().Split('\t');

                        switch (words.Count())
                        {
                        case 3:
                        {
                            ClassName = words[0].Trim();
                            NewStudent(words[1], words[2]);
                            break;
                        }

                        case 2:
                        {
                            NewStudent(words[0], words[1]);
                            break;
                        }

                        default:
                            //提示文件格式错误预留。
                            break;
                        }
                        line = streamReader.ReadLine();
                    }
                    streamReader.Close();
                }
                catch (Exception exp)
                {
                    Response.Write("<script type=\"text/javascript\">alert('文件格式错误!" + exp.Message + "')</script>");
                    return;
                }

                #endregion



                LabDB.Account.InsertAllOnSubmit(StudentsAccountList);
                LabDB.StudentInfo.InsertAllOnSubmit(StudentsToUpload);

                try
                {
                    LabDB.SubmitChanges();
                }
                catch (Exception exp)
                {
                    Response.Write("<script type=\"text/javascript\">alert('请检查是否上传了已有的学生信息!')</script>");
                    return;
                }

                Response.Write("<script type=\"text/javascript\"> alert('学生上传成功!" + Message + "');</script>");
                Response.Write("<script type=\"text/javascript\">window.location=AddStudent.aspx;</script>");
                //return;
            }
        }
示例#28
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;
                }
            }
        }
示例#29
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.HttpMethod == "POST")
            {
                #region 检查用户信息是否合法
                if (LabDB.Account.Where(d => d.UserName == Request.Form["Name"].Trim()).Count() >= 1)
                {
                    Response.Write("<script type=\"text/javascript\"> alert('该用户名已经存在!');</script>");
                    return;
                }
                #endregion

                #region 检查提交的信息是否完整。
                if (Request.HttpMethod == "POST")
                {
                    //姓名。
                    if (Request.Form["Name"].isNullorWhiteSpace())
                    {
                        Response.Write("<script type=\"text/javascript\"> alert('教师姓名不能为空!');</script>");
                        return;
                    }

                    //用户名。
                    if (Request.Form["Account"].isNullorWhiteSpace())
                    {
                        Response.Write("<script type=\"text/javascript\"> alert('用户名不能为空!');</script>");
                        return;
                    }

                    //密码。
                    if (Request.Form["Password"].isNullorWhiteSpace())
                    {
                        Response.Write("<script type=\"text/javascript\"> alert('密码不能为空!');</script>");
                        return;
                    }
                    //电话。
                    if (Request.Form["Tel"].isNullorWhiteSpace())
                    {
                        Response.Write("<script type=\"text/javascript\"> alert('电话号码不能为空!');</script>");
                        return;
                    }

                    if (Request.Form["Sex"].isNullorWhiteSpace())
                    {
                        Response.Write("<script type=\"text/javascript\"> alert('性别不能为空!');</script>");
                        return;
                    }
                    //照片。
                    if (Request.Files["Photo"] == null || Request.Files["Photo"].ContentLength == 0)
                    {
                        Response.Write("<script type=\"text/javascript\"> alert('照片不能为空!');</script>");
                        return;
                    }
                }
                #endregion

                #region 检查信息电话格式合法性。
                if (!Request.Form["Tel"].IsPhoneNumber())
                {
                    Response.Write("<script type=\"text/javascript\"> alert('电话号码格式不正确!请检查输入!');</script>");
                    return;
                }

                #endregion



                #region 新建教师信息并存入数据库。
                try
                {
                    TeacherAccount = new Account
                    {
                        UserName = Request.Form["Account"].Trim(),
                        Password = Request.Form["Password"].Trim().ToMD5(),
                        Type     = 3,
                    };
                    LabDB.Account.InsertOnSubmit(TeacherAccount);


                    HttpPostedFile photo = Request.Files["Photo"];

                    string photoName = Request.Form["Name"] + DateTime.Now.ToString("yyyy-mm-dd-hh-mm-ss") + "." + photo.ContentType.Split('/')[1];

                    Teacher = new TeacherInfo
                    {
                        Name        = Request.Form["Name"].Trim(),
                        Sex         = Request.Form["Sex"] == "male" ? true : false,
                        Account     = TeacherAccount,
                        PhoneNumber = Request.Form["Tel"].Trim(),
                        Remarks     = Request.Form["Remarks"].Trim(),
                        PhotoUrl    = "Datas/Photos/Teacher/" + photoName,
                    };

                    photo.SaveAs(Request.PhysicalApplicationPath + "Datas\\Photos\\Teacher\\" + photoName);

                    LabDB.TeacherInfo.InsertOnSubmit(Teacher);
                    LabDB.SubmitChanges();
                }
                catch
                {
                    Response.Write("<script type=\"text/javascript\"> alert('发生错误!请检查信息录入是否合法!');</script>");
                    return;
                }
                return;

                #endregion
            }
        }
示例#30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.HttpMethod == "POST")
            {
                #region 检查输入是否完整且合法。

                //实验名称。
                if (Request.Form["Name"].isNullorWhiteSpace())
                {
                    Response.Write("<script type=\"text/javascript\"> alert('实验名称不能为空!');</script>");
                    return;
                }

                //学时。
                if (Request.Form["ClassHour"].isNullorWhiteSpace())
                {
                    Response.Write("<script type=\"text/javascript\"> alert('学时不能为空!');</script>");
                    return;
                }



                //指导老师。
                if (Request.Form["TeacherId"].isNullorWhiteSpace())
                {
                    Response.Write("<script type=\"text/javascript\"> alert('指导老师不能为空!');</script>");
                    return;
                }

                //实验简介。
                if (Request.Form["Introduction"].isNullorWhiteSpace())
                {
                    Response.Write("<script type=\"text/javascript\"> alert('实验简介不能为空!');</script>");
                    return;
                }

                //照片。
                if (Request.Files["Photo"] == null || Request.Files["Photo"].ContentLength == 0)
                {
                    Response.Write("<script type=\"text/javascript\"> alert('照片不能为空!');</script>");
                    return;
                }

                #endregion
                HttpPostedFile photo     = Request.Files["Photo"];
                string         photoName = Request.Form["Name"] + DateTime.Now.ToString("yyyy-mm-dd-hh-mm-ss") + "." + photo.ContentType.Split('/')[1];

                try
                {
                    CourseInfo course = new CourseInfo
                    {
                        Name           = Request.Form["Name"].Trim(),
                        Address        = Request.Form["Address"].Trim(),
                        ClassHour      = Convert.ToInt16(Request.Form["ClassHour"]),
                        TeacherInfo    = LabDB.TeacherInfo.SingleOrDefault(d => d.Id.ToString() == Request.Form["TeacherId"]),
                        Introduction   = Request.Form["Introduction"].Trim(),
                        ExperimentInfo = LabDB.ExperimentInfo.SingleOrDefault(d => d.Id.ToString() == Request.Form["ExperimentId"]),
                        PhotoUrl       = "../Datas/Photos/Course/" + photoName,
                    };

                    photo.SaveAs(Request.PhysicalApplicationPath + "Datas\\Photos\\Course\\" + photoName);

                    LabDB.CourseInfo.InsertOnSubmit(course);
                    LabDB.SubmitChanges();
                    Response.Write("<script type=\"text/javascript\"> alert('操作成功!');</script>");
                    Response.Write("<script type=\"text/javascript\">window.location='CourseManage.aspx?id=" + Experiment.Id + "'</script>");
                    //return;

                    //Response.Redirect("CourseManage.aspx", true);
                }
                catch
                {
                    Response.Write("<script type=\"text/javascript\"> alert('操作失败!请检查输入!');</script>");
                    Response.Write("<script type=\"text/javascript\">window.location='CourseManage.aspx?id=" + Experiment.Id + "'</script>");
                    // return;
                }
            }
        }
示例#31
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.HttpMethod == "POST")
            {
                #region 检查输入是否完整且合法。

                //实验名称。
                if (Request.Form["Name"].isNullorWhiteSpace())
                {
                    Response.Write("<script type=\"text/javascript\"> alert('实验名称不能为空!');</script>");
                    return;
                }

                //学时。
                if (Request.Form["ClassHour"].isNullorWhiteSpace())
                {
                    Response.Write("<script type=\"text/javascript\"> alert('学时不能为空!');</script>");
                    return;
                }



                //指导老师。
                if (Request.Form["TeacherId"].isNullorWhiteSpace())
                {
                    Response.Write("<script type=\"text/javascript\"> alert('指导老师不能为空!');</script>");
                    return;
                }

                //实验简介。
                if (Request.Form["Introduction"].isNullorWhiteSpace())
                {
                    Response.Write("<script type=\"text/javascript\"> alert('实验简介不能为空!');</script>");
                    return;
                }

                ////照片。
                //if (Request.Files["Photo"] == null || Request.Files["Photo"].ContentLength == 0)
                //{
                //    Response.Write("<script type=\"text/javascript\"> alert('照片不能为空!');</script>");
                //    return;
                //}

                ////注意事项
                //if (Request.Form["Attention"].isNullorWhiteSpace())
                //{
                //    Response.Write("<script type=\"text/javascript\"> alert('注意事项不能为空!');</script>");
                //    return;
                //}


                #endregion



                string         photoName = "";
                HttpPostedFile photo     = null;
                if (Request.Files["Photo"] != null && Request.Files["Photo"].ContentLength != 0)
                {
                    photo     = Request.Files["Photo"];
                    photoName = Request.Form["Name"] + DateTime.Now.ToString("yyyy-mm-dd-hh-mm-ss") + "." + photo.ContentType.Split('/')[1];
                }

                try
                {
                    Course.Name         = Request.Form["Name"].Trim();
                    Course.Address      = Request.Form["Address"].Trim();
                    Course.ClassHour    = Convert.ToInt16(Request.Form["ClassHour"]);
                    Course.TeacherInfo  = LabDB.TeacherInfo.SingleOrDefault(d => d.Id.ToString() == Request.Form["TeacherId"]);
                    Course.Introduction = Request.Form["Introduction"].Trim();
                    Course.Attention    = Request.Form["Attention"].Trim();
                    //Course.ExperimentInfo = LabDB.ExperimentInfo.SingleOrDefault(d => d.Id.ToString() == Request.Form["ExperimentId"]);
                    if (photoName != "")
                    {
                        Course.PhotoUrl = "../Datas/Photos/Course/" + photoName;
                        photo.SaveAs(Request.PhysicalApplicationPath + "Datas\\Photos\\Course\\" + photoName);
                    }


                    LabDB.SubmitChanges();
                    Response.Write("<script type=\"text/javascript\"> alert('修改成功!');</script>");
                    Response.Write("<script type=\"text/javascript\"> window.location='DetailsOfCourse.aspx?courseId=" + Course.Id + "'</script>");
                    return;
                }
                catch
                {
                    Response.Write("<script type=\"text/javascript\"> alert('操作失败!请检查输入!');</script>");
                    return;
                }
            }
        }