예제 #1
0
        private void EditTeacher_Load(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();
            dataGridView1.Refresh();

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

            Teacher teacher = TeacherDB.TempLoad();

            lblTeacherID.Text = teacher.TeacherID.ToString();
            txtFirstName.Text = teacher.FirstName;
            txtLastName.Text  = teacher.LastName;

            Teacher        newTeacher = TeacherDB.TeacherFind(teacher.TeacherID);
            List <Classes> ClassList  = new List <Classes>();

            foreach (int classID in newTeacher.ClassID)
            {
                Classes  newClass = ClassesDB.ClassFind(classID);
                string[] row      = new string[] { newClass.ClassID.ToString(), newClass.ClassTitle, newClass.ClassTrack };
                dataGridView1.Rows.Add(row);
            }
        }
예제 #2
0
        private string CLR(int id)
        {
            string classString;

            Classes newClass = ClassesDB.ClassFind(id);

            classString = newClass.ClassID.ToString() + " " + newClass.ClassTitle + " " + newClass.ClassTrack;

            return(classString);
        }
예제 #3
0
        private void btnSave_Click(object sender, EventArgs e) //Needs validation
        {
            if (true)                                          //Validate everything
            {
                List <int>     ClassList     = new List <int>();
                List <Classes> ClassListSave = new List <Classes>();

                //Retrieves class data and populates list
                foreach (object classData in checkedListBox1.CheckedItems)
                {
                    string[] classInfo = classData.ToString().Split(' ');

                    Classes newClass = ClassesDB.ClassFind(Convert.ToInt32(classInfo[0]));
                    ClassListSave.Add(newClass);
                    ClassList.Add(newClass.ClassID);
                }

                //Find teacher and add data into teacher
                string[] teacherID = comboBox1.Text.Split(' ');

                Teacher newTeacher = TeacherDB.TeacherFind(Convert.ToInt32(teacherID[0]));
                newTeacher.ClassID = ClassList;

                foreach (Classes classes in ClassListSave)
                {
                    classes.TeacherID.Add(newTeacher.TeacherID);

                    ClassesDB.ClassDelete(classes);
                    ClassesDB.ClassSave(classes);
                }

                TeacherDB.TeacherDelete(newTeacher);
                TeacherDB.TeacherSave(newTeacher);
            }
            else
            {
                MessageBox.Show("Please select the correct number of classes or select a different teacher");
            }

            this.Close();
        }
예제 #4
0
        //Save all classes to student
        private void button1_Click(object sender, EventArgs e)
        {
            Student    student = StudentDB.StudentFind(Convert.ToInt32(label2.Text));
            List <int> ClassId = new List <int>();

            foreach (object classid in checkedListBox1.CheckedItems)
            {
                string[] id = classid.ToString().Split(' ');

                ClassId.Add(Convert.ToInt32(id[0]));
                Classes    classes   = ClassesDB.ClassFind(Convert.ToInt32(id[0]));
                List <int> studentID = new List <int>();
                studentID.Add(classes.ClassID);

                ClassesDB.ClassDelete(classes);
                ClassesDB.ClassSave(classes);
            }

            student.ClassID = ClassId;
            StudentDB.StudentDelete(student);
            StudentDB.StudentSave(student);
        }