Beispiel #1
0
 //添加课程
 public bool AddCourse(Course course)
 {
     DataClassesDataContext da = new DataClassesDataContext();
     da.Course.InsertOnSubmit(course);
     da.SubmitChanges();
     return true;
 }
Beispiel #2
0
 // 新建问题
 public bool create(Problem obj)
 {
     DataClassesDataContext da = new DataClassesDataContext();
     da.Problem.InsertOnSubmit(obj);
     da.SubmitChanges();
     return true;
 }
Beispiel #3
0
 //插入teacher
 public bool AddTeacher(Teacher teacher)
 {
     DataClassesDataContext da = new DataClassesDataContext();
     Teacher t = new Teacher();
     t = teacher;
     da.Teacher.InsertOnSubmit(t);
     da.SubmitChanges();
     return true;
 }
Beispiel #4
0
 // 添加学生
 public bool AddStudent(Student stu)
 {
     DataClassesDataContext da = new DataClassesDataContext();
     Student student = new Student();
     student = stu;
     da.Student.InsertOnSubmit(student);
     da.SubmitChanges();
     return true;
 }
Beispiel #5
0
 public bool Create(Accessory accessory)
 {
     if (accessory.adress.Length == 0)
         return false;
     DataClassesDataContext da = new DataClassesDataContext();
     da.Accessory.InsertOnSubmit(accessory);
     da.SubmitChanges();
     return true;
 }
Beispiel #6
0
 //学生选课
 public bool ChooseCourse(String stuname, String course_num)
 {
     DataClassesDataContext da = new DataClassesDataContext();
     Student_Course sc = new Student_Course();
     sc.course = course_num;
     sc.student = stuname;
     da.Student_Course.InsertOnSubmit(sc);
     da.SubmitChanges();
     return true;
 }
Beispiel #7
0
 public bool Update(Admin newadmin)
 {
     DataClassesDataContext da = new DataClassesDataContext();
     var a = from s in da.Admin
             where s.username == newadmin.username
             select s;
     a.First().passwd = newadmin.passwd;
     da.SubmitChanges();
     return true;
 }
Beispiel #8
0
 //根据Problem的Id来删除作业
 public bool DeleteProblem(int pro_id)
 {
     DataClassesDataContext da = new DataClassesDataContext();
     var answer = from s in da.Answer
                  where s.problem == pro_id
                  select s;
     da.Answer.DeleteAllOnSubmit(answer);
     var p = from s in da.Problem
             where s.id == pro_id
             select s;
     da.Problem.DeleteAllOnSubmit(p);
     da.SubmitChanges();
     return true;
 }
Beispiel #9
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;
        }
Beispiel #10
0
 //更新问题
 public bool UpdateProblem(Problem pro)
 {
     DataClassesDataContext da = new DataClassesDataContext();
     var p = from s in da.Problem
             where s.id == pro.id
             select s;
     foreach (Problem problem in p)
     {
         problem.id = pro.id;
         problem.assignment = pro.assignment;
         problem.title = pro.title;
         problem.descrip = pro.descrip;
         problem.score = pro.score;
     }
     da.SubmitChanges();
     return true;
 }
Beispiel #11
0
 //评分,pro_id代表问题ID,score代表分数
 public bool Score(int pro_id,float score)
 {
     DataClassesDataContext da = new DataClassesDataContext();
     var p = from s in da.Problem
             where s.id == pro_id
             select s;
     p.First().score = score;
     da.SubmitChanges();
     return true;
 }