private void initListView()
        {
            // Clear the ListView control items
            listView_lessons.Items.Clear();
            // there aren't any courses, exit
            if (list_lessons_fix != null && list_lessons_fix.Count > 0)
            {
                // add items to listView controll corses
                string[]     arr = new string[8];
                ListViewItem itm; //= new ListViewItem();
                for (int i = 0; i < list_lessons_fix.Count; i++)
                {
                    arr[0] = list_lessons_fix.ElementAt(i).Day.ToString();
                    arr[1] = formatTime(list_lessons_fix.ElementAt(i).Start);
                    arr[2] = formatTime(list_lessons_fix.ElementAt(i).End);
                    Course course = dal.courses.Find(list_lessons_fix.ElementAt(i).LCourseID);
                    if (course != null)
                    {
                        arr[3] = course.ID.ToString() + ":" + course.Name;
                        arr[4] = course.Points.ToString();
                    }
                    arr[5] = (list_lessons_fix.ElementAt(i).End - list_lessons_fix.ElementAt(i).Start).ToString();
                    if (list_lessons_fix.ElementAt(i).Type.Equals("Lecture"))
                    {
                        Lecturer l = dal.lecturers.Find(list_lessons_fix.ElementAt(i).LTeacherID);
                        if (l != null)
                        {
                            arr[6] = l.Name;
                        }
                    }
                    else if (list_lessons_fix.ElementAt(i).Type.Equals("Practise") || list_lessons_fix.ElementAt(i).Type.Equals("Lab"))
                    {
                        Practitioner p = dal.practitiners.Find(list_lessons_fix.ElementAt(i).LTeacherID);
                        if (p != null)
                        {
                            arr[6] = p.Name;
                        }
                    }
                    //if(list_lessons_fix.ElementAt(i).classroom != null)
                    arr[7] = list_lessons_fix.ElementAt(i).building + list_lessons_fix.ElementAt(i).number.ToString();


                    itm = new ListViewItem(arr);
                    listView_lessons.Items.Add(itm);

                    // colored the line in listview
                    if (i % 2 == 1)
                    {
                        listView_lessons.Items[i].BackColor = System.Drawing.ColorTranslator.FromHtml("#f2f2f2");
                    }
                    else
                    {
                        listView_lessons.Items[i].BackColor = System.Drawing.ColorTranslator.FromHtml("#ffffff");
                    }
                }
                listView_lessons.Sort();
                summery();
            }
        }
 public static int getAmountOfCourseofPractitioner(Practitioner l)
 {
     if (l.approvalOfPractitioners != null)
     {
         return(l.approvalOfPractitioners.Count);
     }
     return(-1);
 }
示例#3
0
 public bool removeCourseFromPractitioner(Practitioner p, Course c)
 {
     if (p.RemoveAllMyLessonsInCourse(c))                                                  // הסרת כל השיעורים השייכים למתרגל בקורס
     {
         (new Form_toastMassage("מחקת את כל השיעורים מהמרצה, כדי לבצע פעולה זאת")).Show(); // הצגת הודעת קופצת שהפעולה מחיקת השיעור לסטודנט בוצעה בהצלחה
         return(SettingDatabase.RemoveCourseFromPractitioner(p, c));                       // הסרת הקורס מהמתרגל
     }
     return(false);                                                                        // במידה והפעולה של הסרח שיעורים לא הצליחה, אז תחזיר שקר, כלומר אינה יכול למחוק כרגע את הקורס מהמרצה
 }
示例#4
0
 public bool removeCourseFromPractitioner(Practitioner p, Course c)
 {
     if (p.RemoveAllMyLessonsInCourse(c))
     {
         (new Form_toastMassage("מחקת את כל השיעורים מהמרצה, כדי לבצע פעולה זאת")).Show();
         return(SettingDatabase.RemoveCourseFromPractitioner(p, c));
     }
     return(false);
 }
示例#5
0
 public bool ScheduleLessonLabToPractitionerInCourse(Practitioner prac, Course c, Lesson les)
 {
     if (SettingDatabase.PractitionerHasMoreThenAllowsHours(prac, les))
     {
         MessageBox.Show("Can't register any more lessons to this Practitioner, because he above more then 16 weekly hours teaching");
         return(false);
     }
     return(SettingDatabase.AddLabInCourseToPractitioner(prac, c, les));
 }
 public static int getAmountOfPractisesOfPractitioner(Practitioner l)
 {
     if (l.LessonPractises != null)
     {
         return(l.LessonPractises.Count);
     }
     else
     {
         return(-1);
     }
 }
        public Form_AddConstraint(User u)
        {
            InitializeComponent();
            dal = new DbContextDal();

            //Receives a staff member indicating what authorization is, to know what actions are allowed
            user = u;
            if (user != null)
            {
                if (user.permission.Equals("Lecturer"))
                {
                    lecturer            = dal.lecturers.Find(user.ID);
                    listApprovedCourses = lecturer.getAllMyCourseInStateApproved();
                }
                else if (user.permission.Equals("Practitioner"))
                {
                    practitioner        = dal.practitiners.Find(user.ID);
                    listApprovedCourses = practitioner.getAllMyCourseInStateApproved();
                }
                else
                {
                    MessageBox.Show("Error: Could not identify user details! (Only Lecturer / Practitioner can enter to here)");
                    clickGoBack = true;
                    Close();
                }
            }
            else
            {
                MessageBox.Show("Error: Could not identify user details!");
                clickGoBack = true;
                Close();
            }

            if (listApprovedCourses != null)
            {
                string[] CB_coursesItems = new string[listApprovedCourses.Count + 1];
                CB_coursesItems[0] = "";
                for (int i = 0; i < listApprovedCourses.Count; i++)
                {
                    string str = listApprovedCourses.ElementAt(i).ID.ToString() + " : " + listApprovedCourses.ElementAt(i).Name;
                    CB_coursesItems[i + 1] = str;
                }

                txt_CB_coursesApproved.DataSource = CB_coursesItems;
            }

            txt_checkBox_allCourses.Checked = true;
            updateButtonsAndTextBoxes();
            GeneralFuntion.BlockResizeListViewColumns(listView_constraints);
            GeneralFuntion.Form_Center_FixedDialog(this);
        }
        public Form_addCourseToStaffAndStudent(User u)
        {
            InitializeComponent();
            // init connection to database
            dal = new DbContextDal();

            //Receives a staff member indicating what authorization is, to know what actions are allowed
            user = u;
            if (user != null)
            {
                if (user.permission.Equals("Secretary"))
                {
                    staffMember = secretary = dal.secretaries.Find(user.ID);
                }
                else if (user.permission.Equals("Admin"))
                {
                    staffMember = admin = dal.admins.Find(user.ID);
                }
                else if (user.permission.Equals("Lecturer"))
                {
                    staffMember = lecturer = dal.lecturers.Find(user.ID);
                }
                else if (user.permission.Equals("Practitioner"))
                {
                    staffMember = practitioner = dal.practitiners.Find(user.ID);
                }
                else if (user.permission.Equals("Student"))
                {
                    student = dal.students.Find(user.ID);
                }
                else
                {
                    MessageBox.Show("Error: Could not identify user details!");
                    clickGoBack = true;
                    Close();
                }
            }
            else
            {
                MessageBox.Show("Error: Could not identify user details!");
                clickGoBack = true;
                Close();
            }
            resertDetailCourse();
            UpdateDefaultButton();
            initPermission();
            GeneralFuntion.BlockResizeListViewColumns(listView_coursesFounded);
            GeneralFuntion.Form_Center_FixedDialog(this);
        }
 public static int getAmountOfApprovedCourseofPractitioner(Practitioner l)
 {
     if (l.approvalOfPractitioners != null)
     {
         int sum = 0;
         for (int i = 0; i < l.approvalOfPractitioners.Count; i++)
         {
             if (l.approvalOfPractitioners.ElementAt(i).Approved)
             {
                 sum++;
             }
         }
         return(sum);
     }
     return(-1);
 }
示例#10
0
 public static bool removeCourseFromPractitioner(Practitioner l, Course c)
 {
     if (l.approvalOfPractitioners != null)
     {
         int AmountBefore = l.approvalOfPractitioners.Count;
         for (int i = 0; i < l.approvalOfPractitioners.Count; i++)
         {
             if (l.approvalOfPractitioners.ElementAt(i).CourseId == c.ID)
             {
                 l.approvalOfPractitioners.Remove(l.approvalOfPractitioners.ElementAt(i));
             }
         }
         return(AmountBefore != l.approvalOfPractitioners.Count);
     }
     return(false);
 }
示例#11
0
 public bool setapprovedCourseForPractitioner(Practitioner p, Course c, bool approved = true)
 {
     if (approved == false && p.RemoveAllMyLessonsInCourse(c)) // הסרת כל השיעורים מהמרצה ב
     {
         (new Form_toastMassage("מחקת את כל השיעורים מהמתרגל, כדי לבצע פעולה זאת")).Show();
         return(SettingDatabase.ApprovedCourseForPractitioner(p, c, approved));
     }
     else if (approved)
     {
         return(SettingDatabase.ApprovedCourseForPractitioner(p, c, approved));
     }
     else
     {
         return(false);
     }
 }
        private void setApprovedCoursesOfPractitioner(Practitioner p)
        {
            list_ApprovedCourses = p.getAllMyCourseInStateApproved();

            if (list_ApprovedCourses != null)
            {
                string[] CB_CourseItems = new string[list_ApprovedCourses.Count + 1];
                CB_CourseItems[0] = "";
                for (int i = 0; i < list_ApprovedCourses.Count; i++)
                {
                    string str = list_ApprovedCourses.ElementAt(i).ID.ToString() + " : " + list_ApprovedCourses.ElementAt(i).Name;
                    CB_CourseItems[i + 1] = str;
                }

                txt_CB_coursesApproved.DataSource = CB_CourseItems;
            }
        }
        private void txt_CB_lecturers_SelectedIndexChanged(object sender, EventArgs e)
        {
            selected_Lecturer     = null;
            selected_Practitioner = null;

            if (txt_CB_lecturersPractitioners.SelectedIndex <= 0)
            {
                updateComponents();
                return;
            }
            if (list_lecturers != null && txt_CB_lecturersPractitioners.SelectedIndex <= list_lecturers.Count)
            {
                selected_Lecturer              = list_lecturers.ElementAt(txt_CB_lecturersPractitioners.SelectedIndex - 1);
                txt_CB_coursesApproved.Text    = "";
                txt_CB_coursesApproved.Enabled = false;
                setApprovedCoursesOfLecturer(list_lecturers.ElementAt(txt_CB_lecturersPractitioners.SelectedIndex - 1));
            }
            else if (list_practitiners != null && list_lecturers != null && txt_CB_lecturersPractitioners.SelectedIndex > list_lecturers.Count)
            {
                selected_Practitioner          = list_practitiners.ElementAt(txt_CB_lecturersPractitioners.SelectedIndex - 1 - list_lecturers.Count);
                txt_CB_coursesApproved.Text    = "";
                txt_CB_coursesApproved.Enabled = false;
                setApprovedCoursesOfPractitioner(list_practitiners.ElementAt(txt_CB_lecturersPractitioners.SelectedIndex - 1 - list_lecturers.Count));
            }
            else if (list_practitiners != null && list_lecturers == null && txt_CB_lecturersPractitioners.SelectedIndex < list_practitiners.Count)
            {
                selected_Practitioner          = list_practitiners.ElementAt(txt_CB_lecturersPractitioners.SelectedIndex - 1);
                txt_CB_coursesApproved.Text    = "";
                txt_CB_coursesApproved.Enabled = false;
                setApprovedCoursesOfPractitioner(list_practitiners.ElementAt(txt_CB_lecturersPractitioners.SelectedIndex - 1));
            }
            else
            {
                resetDataTimeTable();
                resetDetail();
                setDataInGridView();
                updateComponents();
                return;
            }

            updateComponents();
            resetDataTimeTable();
            setDataInGridView();
            setDataListClasses();
        }
 private StaffMember getStaffMemberFromID(int id)
 {
     try
     {
         Lecturer l = dal.lecturers.Find(id);
         if (l != null)
         {
             return(l);
         }
         Practitioner p = dal.practitiners.Find(id);
         if (p != null)
         {
             return(p);
         }
     }
     catch (Exception) { }
     return(null);
 }
        public Form_AddUpdateStaffMember(User u)
        {
            InitializeComponent();
            dal = new DbContextDal();

            //Receives a staff member indicating what authorization is, to know what actions are allowed
            user = u;
            if (user != null)
            {
                if (user.permission.Equals("Secretary"))
                {
                    secretary = dal.secretaries.Find(user.ID);
                }
                else if (user.permission.Equals("Admin"))
                {
                    admin = dal.admins.Find(user.ID);
                }
                else if (user.permission.Equals("Lecturer"))
                {
                    lecturer = dal.lecturers.Find(user.ID);
                }
                else if (user.permission.Equals("Practitioner"))
                {
                    practitioner = dal.practitiners.Find(user.ID);
                }
                else
                {
                    MessageBox.Show("Error: Could not identify user details!");
                    clickGoBack = true;
                    Close();
                }
            }
            else
            {
                MessageBox.Show("Error: Could not identify user details!");
                clickGoBack = true;
                Close();
            }

            updateButtons();
            listView_staffFounded.Items.Clear();
            GeneralFuntion.BlockResizeListViewColumns(listView_staffFounded);
            GeneralFuntion.Form_Center_FixedDialog(this);
        }
示例#16
0
        public static int getTotalHourOfAllLessonOfPractitioner(Practitioner l)
        {
            int sum = 0;

            if (l.LessonLabs != null)
            {
                for (int i = 0; i < l.LessonLabs.Count; i++)
                {
                    sum += l.LessonLabs.ElementAt(i).End - l.LessonLabs.ElementAt(i).Start;
                }
            }
            if (l.LessonPractises != null)
            {
                for (int i = 0; i < l.LessonPractises.Count; i++)
                {
                    sum += l.LessonPractises.ElementAt(i).End - l.LessonPractises.ElementAt(i).Start;
                }
            }
            return(sum);
        }
示例#17
0
 public static bool AddCourseToPractitioner(Practitioner l, Course c)
 {
     if (l.approvalOfPractitioners != null)
     {
         int AmountBefore = l.approvalOfPractitioners.Count;
         for (int i = 0; i < l.approvalOfPractitioners.Count; i++)
         {
             if (l.approvalOfPractitioners.ElementAt(i).CourseId == c.ID)
             {
                 return(false);
             }
         }
         l.approvalOfPractitioners.Add(new ApprovalOfPractitioner()
         {
             CourseId = c.ID, PractitionerId = l.ID, Approved = true
         });
         return(AmountBefore != l.approvalOfPractitioners.Count);
     }
     return(false);
 }
        public Form_MenuLecturerPractitioner(User u)
        {
            InitializeComponent();

            GeneralFuntion.Form_Center_FixedDialog(this);

            dal = new DbContextDal();

            user = u;
            if (user != null)
            {
                if (user.permission.Equals("Lecturer"))
                {
                    lecturer          = dal.lecturers.Find(user.ID);
                    lbl_userName.Text = lbl_userName.Text + lecturer.Name;
                    lbl_title.Text    = lbl_title.Text + "Lecturer";
                }
                else if (user.permission.Equals("Practitioner"))
                {
                    practitioner      = dal.practitiners.Find(user.ID);
                    lbl_userName.Text = lbl_userName.Text + practitioner.Name;
                    lbl_title.Text    = lbl_title.Text + "Practitioner";
                }
                else
                {
                    MessageBox.Show("Error: Could not identify user details! (Only Lecturer or Practitioner can enter to here)");
                    clickGoBack = true;
                    this.Close();
                }
            }
            else
            {
                MessageBox.Show("Error: Could not identify user details!");
                clickGoBack = true;
                this.Close();
            }
        }
        public Form_MySchedule(User u)
        {
            InitializeComponent();

            dal = new DbContextDal();

            //Receives a staff member indicating what authorization is, to know what actions are allowed
            user = u;

            if (user != null)
            {
                if (user.permission.Equals("Lecturer"))
                {
                    lecturer         = dal.lecturers.Find(user.ID);
                    list_lessons     = lecturer.GetAllMyLesson();
                    list_lessons_fix = lecturer.GetAllMyLesson();

                    checkBox_lectures.Enabled = true;
                    checkBox_lectures.Checked = true;

                    checkBox_practises.Enabled = false;
                    checkBox_practises.Checked = false;
                    checkBox_labs.Enabled      = false;
                    checkBox_labs.Checked      = false;
                }
                else if (user.permission.Equals("Practitioner"))
                {
                    practitioner     = dal.practitiners.Find(user.ID);
                    list_lessons     = practitioner.GetAllMyLesson();
                    list_lessons_fix = practitioner.GetAllMyLesson();


                    checkBox_practises.Enabled = true;
                    checkBox_practises.Checked = true;
                    checkBox_labs.Enabled      = true;
                    checkBox_labs.Checked      = true;


                    checkBox_lectures.Enabled = false;
                    checkBox_lectures.Checked = false;
                }
                else if (user.permission.Equals("Student"))
                {
                    student                    = dal.students.Find(user.ID);
                    list_lessons               = student.getAllMyLessons();
                    list_lessons_fix           = student.getAllMyLessons();
                    checkBox_practises.Enabled = true;
                    checkBox_practises.Checked = true;
                    checkBox_labs.Enabled      = true;
                    checkBox_labs.Checked      = true;
                    checkBox_lectures.Enabled  = true;
                    checkBox_lectures.Checked  = true;
                }
                else
                {
                    MessageBox.Show("Error: Could not identify user details! (Only Student / Lecturer / Practitioner can enter to here)");
                    clickGoBack = true;
                    Close();
                }
            }
            else
            {
                MessageBox.Show("Error: Could not identify user details!");
                clickGoBack = true;
                Close();
            }

            GeneralFuntion.Form_Center_FixedDialog(this);
            setEmptyDataInGridView();
            setDataInGridView();
            initListView();
        }
示例#20
0
 public bool setapprovedCourseForPractitioner(Practitioner p, Course c, bool approved = true)
 {
     return(SettingDatabase.ApprovedCourseForPractitioner(p, c, approved));
 }
示例#21
0
 public bool getApprovedStateOfCourseForPractitioner(Practitioner p, Course c)
 {
     return(SettingDatabase.GetStateApprovalOfSPractitionerInCourse(p, c));
 }
示例#22
0
 public List <Course> getAllCourseOfPractitioner(Practitioner p)
 {
     return(SettingDatabase.GetAllLearnedCoursesOfPractitioner(p));
 }
        private void updateButtons()
        {
            if (selected_lesson != null)
            {
                if (checkBox_LessonsOfStudentSelected.Checked != true)
                {
                    btn_Add.Enabled          = true;
                    btn_RemoveLesson.Enabled = false;
                }
                else
                {
                    btn_Add.Enabled          = false;
                    btn_RemoveLesson.Enabled = true;
                }

                checkBox_Lesson.Checked = true;
                txt_lbl_day.Text        = selected_lesson.Day;
                txt_lbl_End.Text        = GeneralFuntion.formatTime(selected_lesson.End);
                txt_lbl_Start.Text      = GeneralFuntion.formatTime(selected_lesson.Start);
                txt_lbl_Type.Text       = selected_lesson.Type;
                txt_TB_infoLesson.Text  = selected_lesson.InfoLesson;
                string nameTeacher    = "";
                int    amountStudent  = 0;
                int    maxStudInClass = 0;

                ClassRoom classroom = dal.class_rooms.Where(x => x.building.Equals(selected_lesson.building) && x.number == selected_lesson.number).FirstOrDefault();

                if (classroom != null)
                {
                    maxStudInClass = classroom.maxStudents;
                }

                if (selected_lesson.Type.Equals("Lecture"))
                {
                    Lecturer l = dal.lecturers.Find(selected_lesson.LTeacherID);
                    if (l != null)
                    {
                        nameTeacher = "L" + l.ID.ToString() + " : " + l.Name;
                    }
                    if (secretary != null)
                    {
                        Lecture lecture = secretary.geLectureFromLesson(selected_lesson);
                        if (lecture != null)
                        {
                            amountStudent = lecture.NumStudent;
                        }
                    }
                    else if (admin != null)
                    {
                        Lecture lecture = admin.geLectureFromLesson(selected_lesson);
                        if (lecture != null)
                        {
                            amountStudent = lecture.NumStudent;
                        }
                    }
                    else if (student != null)
                    {
                        Lecture lecture = SettingDatabase.geLectureFromLesson(selected_lesson);
                        if (lecture != null)
                        {
                            amountStudent = lecture.NumStudent;
                        }
                    }
                }
                else
                {
                    Practitioner p = dal.practitiners.Find(selected_lesson.LTeacherID);
                    if (p != null)
                    {
                        nameTeacher = "P" + p.ID.ToString() + " : " + p.Name;
                    }
                    if (secretary != null)
                    {
                        if (selected_lesson.Type.Equals("Practise"))
                        {
                            Practise Practise = secretary.getPractiseFormLesson(selected_lesson);
                            if (Practise != null)
                            {
                                amountStudent = Practise.NumStudent;
                            }
                        }
                        else if (selected_lesson.Type.Equals("Lab"))
                        {
                            Lab lab = secretary.geLabFromLesson(selected_lesson);
                            if (lab != null)
                            {
                                amountStudent = lab.NumStudent;
                            }
                        }

                        else if (student != null)
                        {
                            Lab lab = SettingDatabase.geLabFromLesson(selected_lesson);
                            if (lab != null)
                            {
                                amountStudent = lab.NumStudent;
                            }
                        }
                    }
                    else if (admin != null)
                    {
                        if (selected_lesson.Type.Equals("Practise"))
                        {
                            Practise Practise = admin.getPractiseFormLesson(selected_lesson);
                            if (Practise != null)
                            {
                                amountStudent = Practise.NumStudent;
                            }
                        }
                        else if (selected_lesson.Type.Equals("Lab"))
                        {
                            Lab lab = admin.geLabFromLesson(selected_lesson);
                            if (lab != null)
                            {
                                amountStudent = lab.NumStudent;
                            }
                        }
                    }
                }

                txt_lbl_teacher.Text = nameTeacher;
                if (maxStudInClass == 0)
                {
                    maxStudInClass = amountStudent;
                }
                txt_lbl_NumCurrentStudents.Text = amountStudent.ToString() + " / " + maxStudInClass.ToString();
            }
            else
            {
                btn_RemoveLesson.Enabled        = false;
                btn_Add.Enabled                 = false;
                txt_lbl_day.Text                = "";
                txt_lbl_End.Text                = "";
                txt_lbl_Start.Text              = "";
                txt_lbl_Type.Text               = "";
                txt_lbl_teacher.Text            = "";
                txt_lbl_NumCurrentStudents.Text = "";
            }
        }