Пример #1
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 = "填写错误";
        }
    }
Пример #2
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 = "填写错误";
        }
    }