Пример #1
0
        protected void AddCourseSureButton_Click(object sender, EventArgs e)
        {
            tea = (Teacher)Session["teacher"];
            Course newcourse = new Course();
            if (cournumTextBox.Text == "")
                CoursenumLabel.Visible = true;

            else if (cournameTextBox.Text == "")
            {
                CoursenumLabel.Visible = false;
                CoursenameLabel.Visible = true;
            }
            else
            {
                newcourse.teacher = tea.username;
                newcourse.name = cournameTextBox.Text;
                newcourse.num = cournumTextBox.Text;
                DateTime start = Convert.ToDateTime(courstart_timeTextBox.Text + " 00:00:00");
                newcourse.start_time = start;
                DateTime end = Convert.ToDateTime(courend_timeTextBox.Text + " 23:59:59");
                newcourse.end_time = end;

                CourMan.AddCourse(newcourse);
                Response.Write("<script>alert('成功添加!');location.href='AddCourse.aspx';</script>");
                //Response.Redirect("AddCourse.aspx");
            }
        }
Пример #2
0
 //添加课程
 public bool AddCourse(Course course)
 {
     DataClassesDataContext da = new DataClassesDataContext();
     da.Course.InsertOnSubmit(course);
     da.SubmitChanges();
     return true;
 }
Пример #3
0
        //删除课程
        public bool DeleteCourse(Course course)
        {
            DataClassesDataContext da = new DataClassesDataContext();
            var c=from s in da.Course
                  where s.teacher==course.teacher && s.name==course.name
                  select s;
            var cin = from s in da.Student_Course
                      where s.course == c.First().num
                      select s;
            var ca = from s in da.Assignment
                     where s.course == c.First().num
                     select s;
            if (ca.Count() > 0)
            {
                foreach (var n in ca)
                {
                    var p = from s in da.Problem
                            where s.assignment == n.id
                            select s;
                    if (p.Count() > 0)
                    {
                        var answer = from s in da.Answer
                                     where s.problem == p.First().id
                                     select s;
                        if (answer.Count() > 0)
                        {
                            da.Answer.DeleteAllOnSubmit(answer);            //删除answer
                        }
                    }
                    var accessory = from s in da.Accessory
                                    where s.assignment == n.id
                                    select s;
                    if (accessory.Count() > 0)
                        da.Accessory.DeleteAllOnSubmit(accessory);

                    da.Problem.DeleteAllOnSubmit(p);            //删除Problem
                }

                da.Assignment.DeleteAllOnSubmit(ca);           //删除assignment
            }
            if (cin.Count() > 0)
            {
                da.Student_Course.DeleteAllOnSubmit(cin);       //删除student_course
            }
            da.Course.DeleteAllOnSubmit(c);             //删除Course
            da.SubmitChanges();
            return true;
        }
Пример #4
0
        protected void dcnameTextBox_TextChanged(object sender, EventArgs e)
        {
            tea = (Teacher)Session["teacher"];
            Course deletecourse = new Course();
            List<Course> courseforteacher = CourMan.GetCourseForTeacher(tea.username);
            foreach (var c in courseforteacher)
            {
                if (c.name == dcnameTextBox.Text.ToString())
                {
                    deletecourse = c;
                    break;
                }
            }
            Session["deletecourse"] = deletecourse;

            dcnumTextBox.Text = deletecourse.num;
            dcstart_timeLabel.Text = deletecourse.start_time.ToString();
            dcend_timeLabel.Text = deletecourse.end_time.ToString();
        }
Пример #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserRole"] == null || Session["UserRole"].ToString() != "Teacher")
            {
                Response.Write("<Script language='javascript'>alert('您无权访问此页面,请重新登录!');window.history.go(-1);</Script>");
                return;
            }

             //获取课程信息
            tea = (Teacher)Session["teacher"];

            courseforteacher = CourMan.GetCourseForTeacher(tea.username);
            Session["courselist"] = courseforteacher;

            foreach (var c in courseforteacher)
            {
                if (c.num == Request.QueryString["Coursenum"])
                {
                    course = c;
                    break;
                }
            }
            allassigncoursenameLabel.Text = course.name;
        }
Пример #6
0
 partial void DeleteCourse(Course instance);
Пример #7
0
 partial void UpdateCourse(Course instance);
Пример #8
0
 partial void InsertCourse(Course instance);
Пример #9
0
		private void detach_Course(Course entity)
		{
			this.SendPropertyChanging();
			entity.Teacher1 = null;
		}
Пример #10
0
		private void attach_Course(Course entity)
		{
			this.SendPropertyChanging();
			entity.Teacher1 = this;
		}
Пример #11
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["UserRole"] == null || Session["UserRole"].ToString() != "Teacher")
            {
                Response.Write("<Script language='javascript'>alert('您无权访问此页面,请重新登录!');window.history.go(-1);</Script>");
                return;
            }

            //获取课程信息
            tea = (Teacher)Session["teacher"];

            List<Course> courseforteacher = CourMan.GetCourseForTeacher(tea.username);
            foreach (var c in courseforteacher)
            {
                if (c.num == Request.QueryString["Coursenum"])
                {
                    course = c;
                    break;
                }
            }
            //显示课程名
            coursenameLabel.Text = course.name;

            //删除问题时弹窗
            DeletePro.Attributes.Add("onclick", "return confirm('确定要删吗?');");
        }