コード例 #1
0
        private void gridStudents_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            DataGridViewRow row       = gridStudents.SelectedRows[0];
            int             studentId = Convert.ToInt32(row.Cells["StudentId"].Value);
            int             year      = Convert.ToInt32(row.Cells["StudyYear"].Value);
            String          name      = row.Cells["StudentName"].Value.ToString();
            String          surname   = row.Cells["StudentSurname"].Value.ToString();
            String          group     = row.Cells["StudyGroup"].Value.ToString();
            String          set       = row.Cells["StudySet"].Value.ToString();

            BLAdmin bl = new BLAdmin();

            bl.UpdateStudent(studentId, name, surname, year, group, set);

            gridStudents.Rows.Clear();
            gridStudents.Columns.Clear();
            List <StudentsModel> studentsModels = bl.GetStudents(txtNameFilter.Text, txtSurnameFilter.Text, txtGroupFilter.Text);

            gridStudents.Columns.Add("StudentId", "StudentId");
            gridStudents.Columns.Add("StudentName", "Nume");
            gridStudents.Columns.Add("StudentSurname", "Prenume");
            gridStudents.Columns.Add("StudyYear", "An");
            gridStudents.Columns.Add("StudyGroup", "Grupa");
            gridStudents.Columns.Add("StudySet", "Seria");
            gridStudents.Columns[0].Visible = false;

            foreach (StudentsModel student in studentsModels)
            {
                gridStudents.Rows.Add(student.StudentId, student.StudentName, student.StudentSurname, student.StudyYear, student.StudyGroup, student.StudySet);
            }
        }