Example #1
0
 private void lecturers_list_box_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this.lecturers_list_box.SelectedItem != null)
     {
         List <Course> lC = new List <Course>();
         courses_list_box.Visible = true;
         courses_list_box.Items.Clear();
         lC = SqlWorker.GetStudentCourses((StaffMemeber)lecturers_list_box.SelectedItem);
         foreach (Course c in lC)
         {
             courses_list_box.Items.Add(c);
         }
         course_name.Text     = "";
         course_ID.Text       = "";
         course_Lecturer.Text = "";
         course_type.Text     = "";
         have_pract.Text      = "";
         have_lab.Text        = "";
     }
     else
     {
         courses_list_box.Items.Clear();
         courses_list_box.Visible = false;
     }
 }
Example #2
0
        /// <summary>
        /// Login worker.
        /// Use this for testing log in
        /// </summary>
        /// <returns></returns>
        public bool auth()
        {
            if (!IsDigits(this.id_textbox.Text))
            {
                throw new Exception("Make sure that your id contains only digits");
            }
            if (!SqlWorker.CheckForInternetConnection())
            {
                throw new Exception("There is no internet connection.\nPlease try again later.");
            }

            string f_id  = this.id_textbox.Text.ToString();
            string f_pwd = this.pwd_textbox.Text.ToString();


            User usr = SqlWorker.GetUser(f_id);

            // check if we found it and if pwds much
            if (usr == null || usr.Pwd != f_pwd)
            {
                throw new Exception("User not found or Password is incorrect");
            }

            //  set session user
            Globals._session = usr;
            return(true);
        }
Example #3
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;
            }
        }
Example #4
0
        /// <summary>
        /// build courses list for curriculum
        /// </summary>
        /// <param name="coursesString"></param>
        /// <returns></returns>
        private List <Course> builder(string coursesString)
        {
            List <Course> result = new List <Course>();

            // for each crs name in splitted string
            foreach (string crsName in coursesString.Split(','))
            {
                if (crsName == "")
                {
                    continue;
                }
                // create new crs
                Course crs = new Course();
                // get course from db
                crs = SqlWorker.GetCoures(crsName.Trim());
                // fill lectures
                crs.LectEventsList = SqlWorker.GetLects(crs);
                // fill Practice and Lab of the curse
                crs.PractEventsList = SqlWorker.GetPracts(crs);
                crs.LabsEventsList  = SqlWorker.GetLabs(crs);

                result.Add(crs);
            }

            return(result);
        }
Example #5
0
        /// <summary>
        /// get event from curriculum by ID
        /// </summary>
        /// <param name="evID"></param>
        /// <returns></returns>
        private Event getEvent(string evID)
        {
            foreach (Course crs in currentStudent.Curriculum.Courses)
            {
                foreach (Event ev in crs.LectEventsList)
                {
                    if (ev.ID == int.Parse(evID))
                    {
                        return(ev);
                    }
                }

                foreach (Event ev in crs.PractEventsList)
                {
                    if (ev.ID == int.Parse(evID))
                    {
                        return(ev);
                    }
                }

                foreach (Event ev in crs.LabsEventsList)
                {
                    if (ev.ID == int.Parse(evID))
                    {
                        return(ev);
                    }
                }
            }

            // if we got here, this crs is not in the curriculum, create it
            return(SqlWorker.GetEvent(evID));
        }
Example #6
0
        //If all practitioners radio button was changed
        private void all_practitioner_radio_CheckedChanged(object sender, EventArgs e)
        {
            //If the radio button is checked
            if (all_practitioner_radio.Checked == true)
            {
                //Clear chart
                chart.Series["Work Hours"].Points.Clear();
                //Change title
                chart_title.Text = "Practitioners work hours";

                int amountOfPractitioners;
                //Get table containing all the practitioners
                DataSet practitionersDS = SqlWorker.GetDataSet("Select * from Users where type='Practitioner'");
                amountOfPractitioners = SqlWorker.getAmountOfPractitioners();
                //Get work hours for each practitioner and put it on the chart
                for (int i = 0; i < amountOfPractitioners; i++)
                {
                    String name      = practitionersDS.Tables[0].Rows[i]["Name"].ToString();
                    String id        = practitionersDS.Tables[0].Rows[i]["ID"].ToString();
                    int    workHours = SqlWorker.getWorkHours(Convert.ToInt32(id), true, -1);
                    chart.Series["Work Hours"].Points.AddXY(name, workHours);
                }
                //Remove lables with zero values in the pie chart
                updatePieChart();
            }
        }
Example #7
0
 //If lecturer radio button changed
 private void Lecturer_radio_CheckedChanged(object sender, EventArgs e)
 {
     //If the radio button is checked
     if (Lecturer_radio.Checked == true)
     {
         //Clear chart
         chart.Series["Work Hours"].Points.Clear();
         //Enable combobox of lecturers
         lecturers_combo.Enabled = true;
         string[] days = new string[] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" };
         //Get name and id of the lecturer
         DataRowView oDataRowView = lecturers_combo.SelectedItem as DataRowView;
         string      name         = oDataRowView.Row["Name"] as string;
         int         id           = (int)oDataRowView.Row["ID"];
         //Change title
         chart_title.Text        = name + " work hours";
         lecturers_combo.Enabled = true;
         int     workHours;
         DataSet LecturerDS;
         //Get all lectures of the lecturer
         LecturerDS = SqlWorker.GetDataSet("Select * From Lecture Where Lecturer='" + id + "'");
         for (int i = 1; i <= 6; i++)
         {
             //Add each day work hours to the chart
             workHours = SqlWorker.getWorkHours(Convert.ToInt32(id), false, i);
             chart.Series["Work Hours"].Points.AddXY(days[i - 1], workHours);
         }
         //Remove lables with zero values in the pie chart
         updatePieChart();
     }
     else
     {
         lecturers_combo.Enabled = false;
     }
 }
        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 + "'");
        }
 //Ctor
 public Set_pres_courses()
 {
     InitializeComponent();
     comboBox1.DataSource    = SqlWorker.GetDataSet("SELECT CourseName From Courses").Tables[0];
     comboBox1.DisplayMember = "CourseName";
     comboBox2.DataSource    = SqlWorker.GetDataSet("SELECT CourseName From Courses").Tables[0];
     comboBox2.DisplayMember = "CourseName";
     this.Size = new Size(404, 150);
 }
Example #10
0
        public CreateCurri(List <Course> l_c)
        {
            InitializeComponent();

            String[] arr = new String[8];
            sm = new Curriculum [8];
            for (int i = 0; i < 8; i++)
            {
                sm[i]         = new Curriculum();
                sm[i].Courses = new List <Course>();
                string[] words = SqlWorker.GetCurriculumString(i + 1).Split(',');
                foreach (string word in words)
                {
                    if (word == "")
                    {
                        continue;
                    }
                    Course temp = l_c.Find(crs => crs.Name == word);
                    sm[i].Courses.Add(temp);
                }
            }
            foreach (Course cur in this.sm[0].Courses)
            {
                if (cur == null)
                {
                    continue;
                }
                this.semester_list_box.Items.Add(cur);
            }

            foreach (Course cur in l_c)
            {
                Boolean flag = true;
                for (int i = 0; i < 8; i++)
                {
                    if (sm[i].Courses != null)
                    {
                        foreach (Course c in sm[i].Courses)
                        {
                            if (cur.Name == c.Name)
                            {
                                flag = false;
                            }
                        }
                    }
                }
                if (flag)
                {
                    this.courses_list_box.Items.Add(cur);
                }
            }

            this.add_btn.Enabled   = false;
            this.rem_btn.Enabled   = false;
            this.rem_btn.BackColor = Color.Gray;
            this.add_btn.BackColor = Color.Gray;
        }
Example #11
0
        private void BuildList()
        {
            for (int curr = 1; curr <= Globals.MaxSem; curr++)
            {
                CurriculumsList.Add(new Curriculum(curr));
            }

            foreach (Curriculum curr in CurriculumsList)
            {
                foreach (Course crs in curr.Courses)
                {
                    foreach (Event ev in crs.LectEventsList)
                    {
                        int num = SqlWorker.getRoomEq(ev.Room);
                        if (num == 0)
                        {
                            continue;
                        }
                        SemEqCount[curr.Semester - 1] += num;
                        WeekEqCount[ev.Day - 1]       += num;
                        ev.Equpment = num;
                        this.ev_list.Items.Add(ev);
                    }

                    foreach (Event ev in crs.PractEventsList)
                    {
                        int num = SqlWorker.getRoomEq(ev.Room);
                        if (num == 0)
                        {
                            continue;
                        }
                        SemEqCount[curr.Semester] += num;
                        WeekEqCount[ev.Day]       += num;
                        ev.Equpment = num;
                        this.ev_list.Items.Add(ev);
                    }

                    foreach (Event ev in crs.LabsEventsList)
                    {
                        int num = SqlWorker.getRoomEq(ev.Room);
                        if (num == 0)
                        {
                            continue;
                        }
                        SemEqCount[curr.Semester] += num;
                        WeekEqCount[ev.Day]       += num;
                        ev.Equpment = num;
                        this.ev_list.Items.Add(ev);
                    }
                }
            }


            setSemTilesText();
            setWeekTilesText();
        }
 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 + "'");
 }
Example #13
0
 private void saveBT_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < 8; i++)
     {
         sm[i].Semester = i + 1;
         SqlWorker.SetCurriculum(sm[i]);
     }
     MessageBox.Show("Saved Secc!");
     SqlWorker.ClearCurr();
     this.Close();
 }
Example #14
0
        public CourseDetails()
        {
            List <StaffMemeber> lect;

            InitializeComponent();
            lect = SqlWorker.GetAllLecturers();
            foreach (User u in lect)
            {
                lecturers_list_box.Items.Add(u);
            }
        }
Example #15
0
        public void set_schedule_Click(object sender, System.EventArgs e)
        {
            Student selected = (Student)this.student_list.SelectedItem;

            if (selected != null)
            {
                if (SqlWorker.DeleteStudent(selected))
                {
                    this.student_list.Items.Remove(selected);
                    MessageBox.Show("Student Removed");
                }
            }
        }
        public void TestAddLecturer()
        {
            Adding_User_Form form = new Adding_User_Form();

            form.addUser(LecturerID, password, name, type, startTime, endTime, day);
            try
            {
                Assert.IsTrue(SqlWorker.GetDataSet("SELECT * from Users WHERE ID LIKE '" + LecturerID + "' AND PWD LIKE '" + password + "' AND Name LIKE '" + name + "' AND Type LIKE '" + type + "'").Tables[0].Rows.Count == 1);
            }
            catch
            {
                Assert.Fail();
            }
            SqlWorker.GetDataSet("DELETE FROM Users WHERE ID='" + LecturerID + "'");
        }
Example #17
0
 //Constructor
 public Add_new_course()
 {
     InitializeComponent();
     this.Size = new Size(351, 375);
     if (SqlWorker.getAmountOfLecturers() > 1 && SqlWorker.getAmountOfPractitioners() > 1)
     {
         LecturerID_combo.DataSource        = SqlWorker.GetDataSet("SELECT * From Users Where type='Lecturer'").Tables[0];
         LecturerID_combo.DisplayMember     = "Name";
         practitionerID_combo.DataSource    = SqlWorker.GetDataSet("SELECT * From Users Where type='Practitioner'").Tables[0];
         practitionerID_combo.DisplayMember = "Name";
     }
     else
     {
         MessageBox.Show("There is no practitioners/lecturers in the system!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
         this.Close();
     }
 }
Example #18
0
        //Show course list
        private void View_courses_Click(object sender, EventArgs e)
        {
            if (View_courses.Text == "View courses")
            {
                View_courses.Text     = "Hide courses";
                this.Size             = new Size(351, 561);
                dataGridView1.Visible = true;

                dataGridView1.DataSource = SqlWorker.GetDataSet("SELECT CourseId,CourseName From Courses").Tables[0];
            }
            else
            {
                View_courses.Text     = "View courses";
                this.Size             = new Size(351, 375);
                dataGridView1.Visible = false;
            }
        }
        //Show all pre courses
        private void view_pre_courses_Click(object sender, EventArgs e)
        {
            if (view_pre_courses.Text == "View pre courses")
            {
                view_pre_courses.Text = "Hide pre courses";
                dataGridView1.Visible = true;
                this.Size             = new Size(404, 325);

                dataGridView1.DataSource = SqlWorker.GetDataSet("SELECT * From PreCourses").Tables[0];
            }
            else
            {
                view_pre_courses.Text = "View pre courses";
                dataGridView1.Visible = false;
                this.Size             = new Size(404, 150);
            }
        }
Example #20
0
 private void facebook_login_btn_Click(object sender, EventArgs e)
 {
     try
     {
         Globals._session.FB_ID = this.facebook_login_btn.getLoginData()["id"];
         if (Globals._session.FB_ID != null && Globals._session.FB_ID != "")
         {
             if (SqlWorker.SaveUser(Globals._session))
             {
                 MessageBox.Show("User Was Connected To Facebook seccessfuly!");
                 this.Close();
             }
         }
     }catch
     {
         MessageBox.Show("Login with Facebook Failded!\n Please try again!");
     }
 }
Example #21
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);
            }
        }
Example #22
0
 private void facebook_login_btn_Click(object sender, EventArgs e)
 {
     try
     {
         string facebook_id = this.facebook_login_btn.getLoginData()["id"];
         User   FB_User     = SqlWorker.FB_Exists(facebook_id);
         if (FB_User != null)
         {
             Globals._session = FB_User;
             starter(false);
         }
         else
         {
             MessageBox.Show("User does not found in DB. Did you register?");
         }
     } catch
     {
         MessageBox.Show("Login with Facebook Failded!\n Please try again!");
     }
 }
Example #23
0
        public void TestFilterLecturer()
        {
            Searching_Filtering_Lectures_Form form = new Searching_Filtering_Lectures_Form();

            SqlWorker.GetDataSet("INSERT INTO Lecture(StartTime,EndTime,Class,Lecturer,CourseName,Day,AmountOfStudents) VALUES('" + startTime + "','" + endTime + "','" + Class + "','" + lecturer + "','" + CourseName + "','" + day + "','" + amoOfStud + "')");
            DataSet data = SqlWorker.GetDataSet("SELECT ID FROM Lecture WHERE StartTime LIKE '" + startTime + "' AND EndTime LIKE '"
                                                + endTime + "' AND Class LIKE '" + Class + "' AND Lecturer LIKE '" + lecturer + "' AND CourseName LIKE '" + CourseName + "' AND Day LIKE '"
                                                + day + "' AND AmountOfStudents LIKE '" + amoOfStud + "'");

            try
            {
                Assert.IsTrue(form.searchLecture(startTime, endTime, Class, lecturer, data.Tables[0].Rows[0][0].ToString()).Tables[0].Rows.Count == 1);
            }
            catch
            {
                Assert.Fail();
            }

            SqlWorker.GetDataSet("DELETE FROM Lecture WHERE ID LIKE '" + data.Tables[0].Rows[0][0].ToString() + "'");
        }
        public void TestFilterPractice()
        {
            Searching_Filtering_Practices_Form form = new Searching_Filtering_Practices_Form();

            SqlWorker.GetDataSet("INSERT INTO TeachingExercises(StartTime,EndTime,Class,Practitioner,type,CourseName,Day,AmountOfStudents) VALUES('" + startTime + "','" + endTime + "','" + Class + "','" + practitioner + "','" + type + "','" + CourseName + "','" + day + "','" + amoOfStud + "')");
            DataSet data = SqlWorker.GetDataSet("SELECT ID FROM TeachingExercises WHERE StartTime LIKE '" + startTime + "' AND EndTime LIKE '"
                                                + endTime + "' AND Class LIKE '" + Class + "' AND Practitioner LIKE '" + practitioner + "' AND type LIKE '" + type + "' AND CourseName LIKE '" + CourseName + "' AND Day LIKE '"
                                                + day + "' AND AmountOfStudents LIKE '" + amoOfStud + "'");

            try
            {
                Assert.IsTrue(form.searchPractice(startTime, endTime, Class, practitioner, type, data.Tables[0].Rows[0][0].ToString()).Tables[0].Rows.Count == 1);
            }
            catch
            {
                Assert.Fail();
            }

            SqlWorker.GetDataSet("DELETE FROM TeachingExercises WHERE ID LIKE '" + data.Tables[0].Rows[0][0].ToString() + "'");
        }
Example #25
0
 public void save_btn_Click(object sender, EventArgs e)
 {
     try
     {
         user.Name = this.name_input.Text;
         user.Pwd  = this.pwd_input.Text;
         if (user.Type == "Student")
         {
             (user as Student).SemCount = this.sem_sbox.SelectedIndex + 1;
         }
         if (SqlWorker.SaveUser(user))
         {
             MessageBox.Show("Saved successfully!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "ERROR");
     }
 }
        //Save the pre course
        private void save_Click(object sender, EventArgs e)
        {
            //Check if any courses was chosen
            if (comboBox1.SelectedItem == null || comboBox2.SelectedItem == null)
            {
                MessageBox.Show("Please choose pre course and course", "Error"
                                , MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            //Get two strings from combobox
            DataRowView oDataRowView = comboBox1.SelectedItem as DataRowView;
            string      preCourse    = oDataRowView.Row["CourseName"] as string;

            oDataRowView = comboBox2.SelectedItem as DataRowView;
            string course = oDataRowView.Row["CourseName"] as string;

            //Check if the courses isn't the same
            if (preCourse == course)
            {
                MessageBox.Show("Course can't have himself as pre course", "Error"
                                , MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            int success = SqlWorker.addPreCourse(preCourse, course);

            //Show message according to add pre course function
            if (success == 2)
            {
                MessageBox.Show("Action successfully completed.", "Success!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else if (success == 0)
            {
                MessageBox.Show("The course " + course + " already has " + preCourse + " as pre course!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                MessageBox.Show("The course " + preCourse + " has " + course + " as pre course!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #27
0
        //Ctor
        public Work_Hours()
        {
            InitializeComponent();
            //Fill comboboxes of lecturers and practitioners
            if (SqlWorker.getAmountOfLecturers() > 0 || SqlWorker.getAmountOfPractitioners() > 0)
            {
                chart_type_combo.SelectedIndex = 0;
                if (SqlWorker.getAmountOfLecturers() > 0)
                {
                    lecturers_combo.DataSource    = SqlWorker.GetDataSet("SELECT * From Users Where type='Lecturer'").Tables[0];
                    lecturers_combo.DisplayMember = "Name";
                    lecturers_combo.SelectedIndex = 0;
                }
                else
                {
                    All_lectures_radio.Enabled = false;
                    Lecturer_radio.Enabled     = false;
                    lecturers_combo.Enabled    = false;
                }
                if (SqlWorker.getAmountOfPractitioners() > 0)
                {
                    practitioner_combo.DataSource    = SqlWorker.GetDataSet("SELECT * From Users Where type='Practitioner'").Tables[0];
                    practitioner_combo.DisplayMember = "Name";
                    practitioner_combo.SelectedIndex = 0;
                }
                else
                {
                    all_practitioner_radio.Enabled = false;
                    practitioner_radio.Enabled     = false;
                    practitioner_combo.Enabled     = false;
                }
            }
            else
            {
                MessageBox.Show("There is no practitioners/lecturers in the system!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                this.Close();
            }

            All_lectures_radio.Checked = true;
        }
Example #28
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 + "'");
        }
Example #29
0
        public void Test_Search_Class()
        {
            Search_Class_By_Type_Form form = new Search_Class_By_Type_Form();
            int count = 0;

            try
            {
                count = form.searchClass(true, true).Tables[0].Rows.Count;
            }
            catch {}

            SqlWorker.GetDataSet("INSERT INTO Class(Room,Capacity,IsLab,HasProjector,Hours,NumOfComputers,Days) VALUES('" + room + "','" + capacity + "','" + islab + "','" + hasProjector + "','" + hours + "','" + numComp + "','" + days + "')");
            try
            {
                Assert.IsTrue(form.searchClass(true, true).Tables[0].Rows.Count == count + 1);
            }
            catch
            {
                Assert.Fail();
            }
            SqlWorker.GetDataSet("DELETE FROM Class WHERE Room LIKE '" + room + "'");
        }
Example #30
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 + "'");
        }