示例#1
0
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string[] studentID  = comboBox1.Text.Split(' ');
            Student  newStudent = StudentDB.StudentFind(Convert.ToInt32(studentID[0]));

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

            if (newStudent.ClassID != null)
            {
                for (int i = 0; i < checkedListBox1.Items.Count; i++)
                {
                    checkedListBox1.SetItemChecked(i, false);
                    foreach (int classid in newStudent.ClassID)
                    {
                        string[] id = checkedListBox1.Items[i].ToString().Split(' ');
                        if (classid == Convert.ToInt32(id[0]))
                        {
                            checkedListBox1.SetItemChecked(i, true);
                        }
                    }
                }
            }
        }
示例#2
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);
                        }
                    }
                }
            }
        }
示例#3
0
        private void button3_Click(object sender, EventArgs e)
        {
            dataGridView1.Rows.Clear();
            dataGridView1.Refresh();

            List <Student> StudentList = StudentDB.StudentLoad();

            dataGridView1.ColumnCount      = 12;
            dataGridView1.Columns[0].Name  = "Student ID";
            dataGridView1.Columns[1].Name  = "First Name";
            dataGridView1.Columns[2].Name  = "Last Name";
            dataGridView1.Columns[3].Name  = "Grade";
            dataGridView1.Columns[4].Name  = "Class 1";
            dataGridView1.Columns[5].Name  = "Class 2";
            dataGridView1.Columns[6].Name  = "Class 3";
            dataGridView1.Columns[7].Name  = "Class 4";
            dataGridView1.Columns[8].Name  = "Class 5";
            dataGridView1.Columns[9].Name  = "Class 6";
            dataGridView1.Columns[10].Name = "Class 7";
            dataGridView1.Columns[11].Name = "Class 8";

            foreach (Student student in StudentList)
            {
                int           count = 0;
                List <string> SCL   = new List <string>()
                {
                    "", "", "", "", "", "", "", ""
                };
                foreach (int classid in student.ClassID)
                {
                    SCL[count] = CLR(classid);
                    count++;
                }

                string[] row =
                    new string[] { student.StudentID.ToString(), student.FirstName, student.LastName, student.Grade.ToString(), SCL[0],
                         SCL[1], SCL[2], SCL[3], SCL[4], SCL[5], SCL[6], SCL[7] };
                dataGridView1.Rows.Add(row);
            }
        }
示例#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);
        }