Exemple #1
0
        public static int setClassRequest(string id, string CourseName, int proj_s, int lab_s)
        {
            DataSet d = SqlWorker.GetDataSet("SELECT TeacherId FROM ClassRequest WHERE TeacherId = '" + id + "' AND CourseName LIKE '" + CourseName + "'");

            string query;

            try
            {
                if (d.Tables[0].Rows.Count == 0)
                {
                    query = "INSERT INTO ClassRequest(TeacherId,CourseName,Projector,Lab) VALUES('" + id + "','" + CourseName + "','" + proj_s + "','" + lab_s + "')";
                    SqlWorker.ExecuteQueries(query);
                    return(1);
                }
                else
                {
                    query = "UPDATE ClassRequest SET Projector = '" + proj_s + "' ,Lab = '" + lab_s + "' WHERE TeacherId = '" + id + "' AND CourseName LIKE '" + CourseName + "'";
                    SqlWorker.ExecuteQueries(query);
                    return(2);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void Test_add_new_course()
        {
            //Add course with lecture, practice and lab
            //Limit lecture, practice and lab duration
            SqlWorker.addCourse(courseName, lecturerID, practitionerID, LectureDuration, PracticeDuration, LabDuration, true);
            Assert.IsTrue(SqlWorker.GetDataSet("select * from Courses where CourseName='" + courseName +
                                               "' and Lecturer=" + lecID + " and practitioner=" + PracID + " and MaxStudent=20 and " +
                                               "LectureDuration=" + LecDuration + " and PracticeDuration=" + PracDuration + " and LabDuration=" + LabDur +
                                               " and Must=" + must).Tables[0].Rows.Count == 1);
            SqlWorker.ExecuteQueries("Delete from Courses where CourseName='" + courseName + "'");

            //Add course with lecture and practice without lab
            //Limit lecture and practice duration
            SqlWorker.addCourse(courseName, lecturerID, practitionerID, LectureDuration, PracticeDuration, null, true);
            Assert.IsTrue(SqlWorker.GetDataSet("select * from Courses where CourseName='" + courseName +
                                               "' and Lecturer=" + lecID + " and practitioner=" + PracID + " and MaxStudent=20 and " +
                                               "LectureDuration=" + LecDuration + " and PracticeDuration=" + PracDuration +
                                               " and Must=" + must + " and LabDuration is null").Tables[0].Rows.Count == 1);
            SqlWorker.ExecuteQueries("Delete from Courses where CourseName='" + courseName + "'");

            //Add course with lecture and lab
            //Limit lecture and lab duration
            SqlWorker.addCourse(courseName, lecturerID, practitionerID, LectureDuration, null, LabDuration, true);
            Assert.IsTrue(SqlWorker.GetDataSet("select * from Courses where CourseName='" + courseName +
                                               "' and Lecturer=" + lecID + " and practitioner=" + PracID + " and MaxStudent=20 and " +
                                               "LectureDuration=" + LecDuration + " and LabDuration=" + LabDur +
                                               " and Must=" + must + " and PracticeDuration is null").Tables[0].Rows.Count == 1);
            SqlWorker.ExecuteQueries("Delete from Courses where CourseName='" + courseName + "'");
        }
 public void Test_check_course_existence()
 {
     //Add new course
     SqlWorker.addCourse(courseName, lecturerID, practitionerID, LectureDuration, PracticeDuration, LabDuration, true);
     Assert.IsTrue(SqlWorker.GetDataSet("select * from Courses where CourseName='" + courseName +
                                        "' and Lecturer=" + lecID + " and practitioner=" + PracID + " and MaxStudent=20 and " +
                                        "LectureDuration=" + LecDuration + " and PracticeDuration=" + PracDuration + " and LabDuration=" + LabDur +
                                        " and Must=" + must).Tables[0].Rows.Count == 1 && SqlWorker.checkCourseExistence(courseName));
     SqlWorker.ExecuteQueries("Delete from Courses where CourseName='" + courseName + "'");
 }
Exemple #4
0
        public static bool LimitAmountOfStu(int lim, string CourseName)
        {
            string query;

            if (lim < 20)
            {
                return(false);
            }
            else
            {
                query = "update Courses set MaxStudent=" + lim + " WHERE CourseName LIKE '" + CourseName + "'";
                try
                {
                    SqlWorker.ExecuteQueries(query);
                }
                catch (Exception ex) { throw ex; }
                return(true);
            }
        }
Exemple #5
0
        public void Test_add_pre_course()
        {
            //Add pre course
            //0 - already exists
            //1 - opposite exists
            //2 - operation successfull

            //Add brand new courses
            SqlWorker.addCourse(course1, lecturerID, practitionerID, LectureDuration, PracticeDuration, LabDuration, true);
            SqlWorker.addCourse(course2, lecturerID, practitionerID, LectureDuration, PracticeDuration, LabDuration, true);
            //Set course1 as pre course of course2
            Assert.IsTrue(SqlWorker.addPreCourse(course1, course2) == 2);

            //Try again
            Assert.IsTrue(SqlWorker.addPreCourse(course1, course2) == 0);

            //Try to set the opposite
            Assert.IsTrue(SqlWorker.addPreCourse(course2, course1) == 1);

            SqlWorker.ExecuteQueries("Delete from Courses where CourseName='" + course1 + "' or CourseName='" + course2 + "'");
            SqlWorker.ExecuteQueries("Delete from PreCourses where PreCourse='" + course1 + "' and course='" + course2 + "'");
        }
Exemple #6
0
        public void class_req_Test()
        {
            //insert one request for class in temp course.
            SqlWorker.addCourse(courseName, lecturerID, practitionerID, LectureDuration, PracticeDuration, LabDuration, true);
            SqlWorker.setClassRequest(lecID.ToString(), courseName, p, l);

            Assert.IsTrue(SqlWorker.GetDataSet("select * from ClassRequest where TeacherID LIKE '" + lecID +
                                               "' AND CourseName LIKE '" + courseName + "' AND Projector = '" + p + "' AND Lab = '" + l + "'").Tables[0].Rows.Count == 1);

            //try to update the request
            p = 0;
            SqlWorker.addCourse(courseName, lecturerID, practitionerID, LectureDuration, PracticeDuration, LabDuration, true);
            SqlWorker.setClassRequest(lecID.ToString(), courseName, p, l);

            Assert.IsTrue(SqlWorker.GetDataSet("select * from ClassRequest where TeacherID LIKE '" + lecID +
                                               "' AND CourseName LIKE '" + courseName + "' AND Projector = '" + p + "' AND Lab = '" + l + "'").Tables[0].Rows.Count == 1);

            //delete the temp course.
            SqlWorker.ExecuteQueries("Delete from Courses where CourseName='" + courseName + "'");

            //delete the request
            SqlWorker.ExecuteQueries("Delete from ClassRequest where CourseName='" + courseName + "'");
        }