Esempio n. 1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AuthHelper.LoginCheck(Session, Request, Response, Server);
        AuthHelper.TeacherOnlyPage(Session, Request, Response, Server);


        var teacher = new Teacher();

        if (Session["user"] is Teacher t)
        {
            teacher = t;
        }
        else
        {
            Session.RemoveAll();
            Response.Redirect("/Login.aspx");
        }

        TeacherName[0] = teacher.Name;
        TeacherName[1] = teacher.TeacherId.ToString();

        Course = new CourseServiceImpl().GetByTeacher(teacher);

        if (Request.QueryString["courseId"] != null)
        {
            //¸´ÖƿγÌ
            int CourseId = int.Parse(Request.QueryString["courseId"]);
            CourseServiceImpl courseServiceImpl = new CourseServiceImpl();
            Course            course            = (Course)courseServiceImpl.GetById(CourseId);
            course.Name = course.Name + "_Copy";
            int newId = courseServiceImpl.Create(course);
            Response.Redirect("EditCourse.aspx?id=" + newId);
        }
    }
Esempio n. 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     AuthHelper.LoginCheck(Session, Request, Response, Server);
     if (!IsPostBack)
     {
         if (Request.QueryString["id"] != null)
         {
             int CourseId = int.Parse(Request.QueryString["id"]);
             CourseServiceImpl courseServiceImpl = new CourseServiceImpl();
             Course            course            = (Course)courseServiceImpl.GetById(CourseId);
             //绑定数据
             Description.Value = course.Description.Replace("<br/>", "\n");
         }
     }
 }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Request.QueryString["tid"]))
            {
                return;
            }
            //tid不为空,根据tid获取该老师还没结束的课程
            var courses = new CourseServiceImpl()
                          .GetByTeacherNotEndYet(new Models.Teacher()
            {
                TeacherId = int.Parse(Request.QueryString["tid"])
            });

            //绑定数据
            RepeaterCourseList.DataSource = courses;
            RepeaterCourseList.DataBind();
        }
Esempio n. 4
0
    protected void NextStep(object sender, EventArgs e)
    {
        try
        {
            int id = int.Parse(Request.QueryString["id"]);
            CourseServiceImpl courseServiceImpl = new CourseServiceImpl();
            Course            course            = (Course)courseServiceImpl.GetById(id);
            course.Description = Description.Value.Replace("\n", "<br/>");

            //之后再验证数据
            courseServiceImpl.Modify(course);

            Response.Redirect("CourseSchedule.aspx?id=" + id);
        }catch (Exception ex)
        {
            Label.Text = "填写错误";
        }
    }
Esempio n. 5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     AuthHelper.LoginCheck(Session, Request, Response, Server);
     if (!IsPostBack)
     {
         if (Request.QueryString["id"] != null)
         {
             int CourseId = int.Parse(Request.QueryString["id"]);
             CourseServiceImpl courseServiceImpl = new CourseServiceImpl();
             Course            course            = (Course)courseServiceImpl.GetById(CourseId);
             //绑定数据
             BeginDate.Value           = course.BeginDate.GetValueOrDefault().ToString("yyyy-MM-dd");
             EndDate.Value             = course.EndDate.GetValueOrDefault().ToString("yyyy-MM-dd");
             TheoryClassHour.Value     = course.TheoryClassHour.ToString();
             ExperimentClassHour.Value = course.ExperimentClassHour.ToString();
         }
     }
 }
Esempio n. 6
0
    protected void NextStep(object sender, EventArgs e)
    {
        try
        {
            Teacher teacher = (Teacher)Session["user"];
            string  Path    = null;
            if (CourseImage.PostedFile != null && CourseImage.PostedFile.FileName != "")
            {
                var savePath = Request.MapPath("~/TeacherUpload/CourseImage/") +
                               teacher.JobNumber +
                               "\\";
                if (!Directory.Exists(savePath))
                {
                    Directory.CreateDirectory(savePath);
                }
                var millisecond = DateTime.Now.Millisecond;
                CourseImage.SaveAs(savePath + millisecond + CourseImage.FileName);
                Path = "/TeacherUpload/CourseImage/" + teacher.JobNumber + "/" + millisecond + CourseImage.FileName;
            }


            int CourseId = int.Parse(Request.QueryString["id"]);
            CourseServiceImpl courseServiceImpl = new CourseServiceImpl();
            Course            course            = (Course)courseServiceImpl.GetById(CourseId);
            course.Name = CourseName.Value;
            course.ShortIntroduction = ShortCourseIntro.Value;
            course.TeacherId         = teacher.TeacherId;
            course.SchoolYear        = SchoolYear.Text;
            course.Semester          = Semester.Text;
            course.IntroImage        = Path == null ? null : Path;
            course.ClassId           = int.Parse(DropDownList1.Text);
            //之后再验证数据

            course = (Course)courseServiceImpl.Modify(course);

            Response.Redirect("EditIntroDetail.aspx?id=" + course.CourseId);
        }
        catch (Exception ex)
        {
            Label.Text = "填写错误";
        }
    }
Esempio n. 7
0
    protected void NextStep(object sender, EventArgs e)
    {
        try
        {
            int id = int.Parse(Request.QueryString["id"]);
            CourseServiceImpl courseServiceImpl = new CourseServiceImpl();
            Course            course            = (Course)courseServiceImpl.GetById(id);
            course.CourseId            = id;
            course.BeginDate           = DateTime.Parse(BeginDate.Value);
            course.EndDate             = DateTime.Parse(EndDate.Value);
            course.TheoryClassHour     = int.Parse(TheoryClassHour.Value);
            course.ExperimentClassHour = int.Parse(ExperimentClassHour.Value);

            //之后再验证数据

            courseServiceImpl.Modify(course);

            Response.Redirect("UploadCourseware.aspx?id=" + id);
        }catch (Exception ex)
        {
            Label.Text = "填写有误";
        }
    }
Esempio n. 8
0
    protected void Page_Load(object sender, EventArgs e)
    {
        AuthHelper.LoginCheck(Session, Request, Response, Server);

        if (!IsPostBack)
        {
            var all = new ClassServiceImpl().GetAll();

            DropDownList1.DataSource     = all; //绑定班级
            DropDownList1.DataTextField  = "Name";
            DropDownList1.DataValueField = "ClassId";
            DropDownList1.DataBind();
            ArrayList schoolYear = new ArrayList();  //绑定学年
            for (int i = DateTime.Now.Year; i >= DateTime.Now.Year - 6; i--)
            {
                schoolYear.Add((i) + "-" + (i + 1));
            }
            SchoolYear.DataSource = schoolYear;
            SchoolYear.DataBind();
            ArrayList semester = new ArrayList(new int[] { 1, 2, 3 });
            Semester.DataSource = semester;
            Semester.DataBind();

            if (Request.QueryString["id"] != null)
            {
                int CourseId = int.Parse(Request.QueryString["id"]);
                CourseServiceImpl courseServiceImpl = new CourseServiceImpl();
                Course            course            = (Course)courseServiceImpl.GetById(CourseId);
                //绑定数据
                CourseName.Value       = course.Name;
                DropDownList1.Text     = string.Concat(course.ClassId);
                SchoolYear.Text        = course.SchoolYear;
                Semester.Text          = course.Semester;
                ShortCourseIntro.Value = course.ShortIntroduction;
            }
        }
    }
Esempio n. 9
0
    protected void NextStep(object sender, EventArgs e)
    {
        try
        {
            Teacher teacher  = (Teacher)Session["user"];
            var     savePath = Request.MapPath("~/TeacherUpload/CourseImage/") +
                               teacher.JobNumber +
                               "\\";
            if (!Directory.Exists(savePath))
            {
                Directory.CreateDirectory(savePath);
            }
            var millisecond = DateTime.Now.Millisecond;
            CourseImage.SaveAs(savePath + millisecond + CourseImage.FileName);
            string Path = "/TeacherUpload/CourseImage/" + teacher.JobNumber + "/" + millisecond + CourseImage.FileName;

            Course course = new Course()
            {
                Name = CourseName.Value,
                ShortIntroduction = ShortCourseIntro.Value,
                TeacherId         = teacher.TeacherId,
                SchoolYear        = SchoolYear.Text,
                Semester          = Semester.Text,
                IntroImage        = Path,
                ClassId           = int.Parse(DropDownList1.SelectedValue)
            };
            //之后再验证数据

            CourseServiceImpl courseServiceImpl = new CourseServiceImpl();
            int id = courseServiceImpl.Create(course);

            Response.Redirect("IntroductionInDetail.aspx?id=" + id);
        }catch (Exception ex)
        {
            Label.Text = "填写错误";
        }
    }
Esempio n. 10
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //需要登录才能看到
            AuthHelper.LoginCheck(Session, Request, Response, Server);
            AuthHelper.StudentOnlyPage(Session, Request, Response, Server);

            Models.Student student;
            if (Session["user"] is Models.Student s)
            {
                student = s;
            }
            else
            {
                //登录的不是学生,转到登录界面
                Session.Remove("user");
                Response.Redirect("~/Login.aspx");
                return;
            }

            //用学生对象的院系id去获取该院系的对象
            var departmentService = new DepartmentServiceImpl();
            var did        = student.DepartmentId;
            var department = (Department)departmentService.GetById(did);

            //赋值:学号
            SpanStudentNumber.InnerText = student.StudentNumber;
            //赋值:学生姓名
            SpanName.InnerText = student.Name;
            //赋值:院系中文名
            SpanDepartment.InnerText = department.ChinesaeName;

            //利用学生的班级id获取该班对象
            var classService = new ClassServiceImpl();
            var cid          = student.ClassId;
            var aClass       = (Class)classService.GetById(cid);

            //利用课程号查老师获得老师所属院系
            //赋值:班级名称
            SpanClass.InnerText = aClass.Name;

            //该生的课程数据绑定
            var courses       = new CourseServiceImpl().Get(student);
            var studentCourse = courses as Course[] ?? courses.ToArray();

            _thisStudentCourse = studentCourse;
            foreach (var course in studentCourse)
            {
                var thisCourseTeacherId = new CourseServiceImpl().GetTeacherIdByCourseId(course.CourseId);
                var thisTeacher         = new TeacherServiceImpl().GetByTeacherId(thisCourseTeacherId);
                var thisTeacherDep      = new DepartmentServiceImpl().GetByDepId(thisTeacher.DepartmentId);
                //得到当前学生的某个课程的成绩
                var thisStudentScore =
                    new ScoreServiceImpl().GetByCourseIdAndStudentId(course.CourseId, student.StudentId);
                string[] str1 =
                {
                    course.CourseId.ToString(), course.Name, thisStudentScore.Mark.ToString(),
                    thisTeacherDep.ChinesaeName
                };
                dep.Add(str1);
            }
        }
Esempio n. 11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //需要登录才能看到
            AuthHelper.LoginCheck(Session, Request, Response, Server);
            AuthHelper.TeacherOnlyPage(Session, Request, Response, Server);

            var    teacher   = new Models.Teacher();
            string cidString = "";

            if (Session["user"] is Models.Teacher t)
            {
                teacher = t;
                //需要登录和cid(courseId)才能访问到的页面
                cidString = Request.QueryString["course"];
                if (string.IsNullOrEmpty(cidString))
                {
                    Response.Redirect("/Default.aspx");
                }
            }
            else
            {
                //登录的不是老师,转到登录界面
                Session.Remove("user");
                Response.Redirect("~/Login.aspx?pre=" + Server.UrlEncode(Request.Url.AbsoluteUri));
            }


            var courseAttachment = new CourseAttachmentServiceimpl();
            var teacherCourse    = new CourseServiceImpl();
            //获得当前老师教的课程
            var nowCourse     = new CourseServiceImpl().GetByCourseId(int.Parse(cidString));
            var nowAttachment = courseAttachment.Get(nowCourse);

            thisTeacherAttachment = nowAttachment;
            //var nowAttachment_id =((CourseAttachment)thisTeacherAttachment).AttachmentId;
            try
            {
                //通过js修改表单中提交的值,然后遍历正则找到 xxneededdeleted
                string pattern = @"\d{1,}neededdeleted";
                int    neededDeleteAttachmentId;
                for (int i = 0; i < Request.Form.Count; i++)
                {
                    if (Regex.IsMatch(Request.Form.Keys[i], pattern))
                    {
                        neededDeleteAttachmentId = int.Parse(Request.Form.Keys[i].ToString().Split('n')[0]);
                        var deletePath = new CourseAttachmentServiceimpl().GetByAttachmentId(neededDeleteAttachmentId);
                        if (new CourseAttachmentServiceimpl().DeleteByAttachemtId(neededDeleteAttachmentId))
                        {
                            //删除数据库成功
                            //删除当前目录下文件
                            var      temp = Server.MapPath("~" + deletePath.Path);
                            FileInfo file = new FileInfo(temp); //指定文件路径
                            try                                 //判断文件是否存在
                            {
                                //file.Attributes = FileAttributes.Normal;//将文件属性设置为普通,比方说只读文件设置为普通
                                file.Delete();//删除文件
                                Response.Write("<script language='javascript'>alert('删除成功!请按F5刷新');</script>");
                                //Response.Redirect(Request.Url.ToString());
                            }
                            catch (Exception ex)
                            { }
                            finally
                            {
                                Response.Redirect(Request.Url.ToString());
                            }
                            Response.Redirect(Request.Url.ToString());
                        }
                        else
                        {
                            //删除失败
                            Response.Write("<script language='javascript'>alert('删除失败!请重试');window.location.reload();</script>");
                        }
                    }
                }
            }
            catch (Exception)
            {
                //没有提交表单不做处理
                //Console.Write("...");
            }
        }