Esempio n. 1
0
        private void comboBox1_TextChanged(object sender, EventArgs e)
        {
            for (int i = 0; i < checkedListBox1.Items.Count; i++)
            {
                checkedListBox1.SetItemChecked(i, false);
            }

            List <Teacher> TeacherList = TeacherDB.TeacherLoad();
            List <Classes> ClassList   = ClassesDB.ClassLoad();

            string[] teacherName = comboBox1.Text.Split(' ');
            Teacher  teacher     = TeacherDB.TeacherFind(Convert.ToInt32(teacherName[0]));

            for (int i = 0; i < checkedListBox1.Items.Count; i++)
            {
                string[] classid = checkedListBox1.Items[i].ToString().Split(' ');

                foreach (int id in teacher.ClassID)
                {
                    if (Convert.ToInt32(classid[0]) == id)
                    {
                        checkedListBox1.SetItemChecked(i, true);
                    }
                }
            }
        }
Esempio n. 2
0
        private void RefreshTable()
        {
            dataGridView1.Rows.Clear();
            dataGridView1.Refresh();

            List <Classes> classList = new List <Classes>();

            classList = ClassesDB.ClassLoad();

            dataGridView1.ColumnCount     = 3;
            dataGridView1.Columns[0].Name = "Class ID";
            dataGridView1.Columns[1].Name = "Class Title";
            dataGridView1.Columns[2].Name = "Class Track";

            foreach (Classes classes in classList)
            {
                string[] row;
                row = new string[] { classes.ClassID.ToString(), classes.ClassTitle, classes.ClassTrack };

                dataGridView1.Rows.Add(row);
            }

            int id = 0;

            foreach (Classes classes in classList)
            {
                if (classes.ClassID >= id)
                {
                    id = classes.ClassID + 1;
                }
            }

            classIDLabel1.Text = id.ToString();
        }
Esempio n. 3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            Student deleteStudent = new Student();

            deleteStudent.StudentID = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value.ToString());
            deleteStudent.FirstName = dataGridView1.CurrentRow.Cells[1].Value.ToString();
            deleteStudent.LastName  = dataGridView1.CurrentRow.Cells[2].Value.ToString();

            //Need to check all classes and see if teacher has that class and delete them.
            List <Classes> ListClasses = ClassesDB.ClassLoad();

            foreach (Classes classes in ListClasses)
            {
                if (classes.StudentID != null)
                {
                    foreach (int studentid in classes.StudentID)
                    {
                        if (deleteStudent.StudentID == studentid)
                        {
                            classes.StudentID.Remove(studentid);
                            ClassesDB.ClassDelete(classes);
                            ClassesDB.ClassSave(classes);
                        }
                    }
                }
            }

            StudentDB.StudentDelete(deleteStudent);
            RefreshTable();
        }
Esempio n. 4
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            Teacher deleteTeacher = new Teacher();

            deleteTeacher.TeacherID = Convert.ToInt32(dataGridView1.CurrentRow.Cells[0].Value.ToString());
            deleteTeacher.FirstName = dataGridView1.CurrentRow.Cells[1].Value.ToString();
            deleteTeacher.LastName  = dataGridView1.CurrentRow.Cells[2].Value.ToString();

            //Need to check all classes and see if teacher has that class and delete them.
            List <Classes> ListClasses = ClassesDB.ClassLoad();

            foreach (Classes classes in ListClasses)
            {
                foreach (int teacherid in classes.TeacherID)
                {
                    if (deleteTeacher.TeacherID == teacherid)
                    {
                        classes.TeacherID.Remove(teacherid);
                        ClassesDB.ClassDelete(classes);
                        ClassesDB.ClassSave(classes);
                    }
                }
            }

            TeacherDB.TeacherDelete(deleteTeacher);
            RefreshTable();
        }
Esempio n. 5
0
        private void AssignClasses_Load(object sender, EventArgs e)
        {
            List <Teacher> TeacherList = TeacherDB.TeacherLoad();
            List <Classes> ClassList   = ClassesDB.ClassLoad();

            foreach (Classes classes in ClassList)
            {
                string className = classes.ClassID + " " + classes.ClassTitle + " " + classes.ClassTrack;
                checkedListBox1.Items.Add(className, false);
            }

            foreach (Teacher teacher in TeacherList)
            {
                comboBox1.Items.Add(teacher.TeacherID + " " + teacher.FirstName + " " + teacher.LastName);
            }
        }
Esempio n. 6
0
        private void SchedulePlan_Load(object sender, EventArgs e)
        {
            List <Classes> ClassList   = ClassesDB.ClassLoad();
            List <Teacher> TeacherList = TeacherDB.TeacherLoad();
            List <Student> StudentList = StudentDB.StudentLoad();

            txtClasses.Text   = ClassList.Count.ToString();
            txtStudents.Text  = StudentList.Count.ToString();
            txtTeachers.Text  = TeacherList.Count.ToString();
            txtErrors.Text    = "3";
            txtClassSize.Text = "10"; //Needs to be set based on a formula (Total Teachers, Periods, Classes and Students)

            int    classSize      = Convert.ToInt32(txtClassSize.Text);
            double classesPerHour = StudentList.Count / classSize;

            txtClassesPerHour.Text = classesPerHour.ToString();
        }
Esempio n. 7
0
        private void AddClassesStudent_Load(object sender, EventArgs e)
        {
            List <Student> StudentList = StudentDB.StudentLoad();

            foreach (Student student in StudentList)
            {
                string entry = student.StudentID + " " + student.FirstName + " " + student.LastName + " " + student.Grade;
                comboBox1.Items.Add(entry);
            }

            Student newStudent = StudentDB.TempLoad();

            label2.Text   = newStudent.StudentID.ToString();
            textBox1.Text = newStudent.FirstName;
            textBox2.Text = newStudent.LastName;

            newStudent    = StudentDB.StudentFind(Convert.ToInt32(label2.Text));
            txtGrade.Text = newStudent.Grade.ToString();

            List <Classes> ClassList = ClassesDB.ClassLoad();

            foreach (Classes classes in ClassList)
            {
                checkedListBox1.Items.Add(classes.ClassID + " " + classes.ClassTitle + " " + classes.ClassTrack);
            }
            if (newStudent.ClassID != null)
            {
                for (int i = 0; i < checkedListBox1.Items.Count; i++)
                {
                    foreach (int classid in newStudent.ClassID)
                    {
                        string[] id = checkedListBox1.Items[i].ToString().Split(' ');
                        if (classid == Convert.ToInt32(id[0]))
                        {
                            checkedListBox1.SetItemChecked(i, true);
                        }
                    }
                }
            }
        }
Esempio n. 8
0
        public static void ScheduleClassCompatibility(int errorLimit, int maxClassSize)
        {
            //Establish Variables
            Schedule       schedule    = new Schedule();
            List <Classes> ClassList   = ClassesDB.ClassLoad();
            List <Student> StudentList = StudentDB.StudentLoad();
            int            errorCount  = 0;

            //Compares students from each class and determines which classes have no matches
            for (int i = 0; i < ClassList.Count; i++)                                          //Loops through all classes
            {
                List <Student> studentList1        = ClassesDB.ClassStudentFind(ClassList[i]); //List for current class
                List <Classes> CompatibleClasses   = new List <Classes>();
                List <Classes> IncompatibleClasses = new List <Classes>();
                List <int>     incompatibleErrors  = new List <int>();

                for (int x = i + 1; x < ClassList.Count; x++)                               //Loops through all classes and compares to existing class
                {
                    List <Student> studentList2 = ClassesDB.ClassStudentFind(ClassList[x]); //List for compared class

                    foreach (Student student1 in studentList1)
                    {
                        foreach (Student student2 in studentList2)
                        {
                            if (ClassList[i].TeacherID == ClassList[x].TeacherID)
                            {
                                errorCount += 10;
                            }
                            if (student1.StudentID == student2.StudentID)
                            {
                                errorCount++;
                            }
                        }
                    }

                    if (errorCount > errorLimit)
                    {
                        IncompatibleClasses.Add(ClassList[x]);
                        incompatibleErrors.Add(errorCount);
                    }
                    else
                    {
                        CompatibleClasses.Add(ClassList[x]);
                    }
                }

                schedule.PrincipleClass      = ClassList[i];
                schedule.CompatibleClasses   = CompatibleClasses;
                schedule.IncompatibleClasses = IncompatibleClasses;
                schedule.IncompatibleErrors  = incompatibleErrors;

                //Save
                File.Delete(@"Data\Schedule\ScheduleData_" + i + ".json");
                string fileName = @"Data\Schedule\ScheduleData_" + i + ".json";
                string json     = JsonConvert.SerializeObject(schedule);

                using (StreamWriter writer = new StreamWriter(fileName, false))
                {
                    writer.WriteLine(json);
                }
            }
        }