예제 #1
0
        }//end of edit account

        //method returns selected student object from data grid
        private Student GetSelectedStudent()
        {
            BLLAccountManager bllAccMngr = new BLLAccountManager();

            Student selStudent = null;

            int studentID = 0;
            // the StudentID is the last column in Main Display dgv - using enum instead of majic numbers
            int columnIndex = Convert.ToInt32(Convert.ToInt32(OOP2_SGetAccounts.SPGetAccounts_StudentID));
            int rowIndex    = 0;

            if (dgvDisplay.SelectedRows.Count > 0)
            {
                // this ensures you select only 1 row, not multi-select
                rowIndex = dgvDisplay.SelectedRows[0].Index;

                //getting the studentID
                studentID = (int)dgvDisplay.Rows[rowIndex].Cells[columnIndex].Value;

                // inputting a list of Students into stuList
                stuList = bllAccMngr.getStudents();

                // circulating through the list to find the matching student number
                for (int i = 0; i < stuList.Count; i++)
                {
                    if (stuList[i].StudentID == studentID)
                    {
                        selStudent = stuList[i];
                        break;
                    }
                }
            }
            return(selStudent);
        }//end of GetSelectedStudent
예제 #2
0
 private void SearchExistingStudents_Load(object sender, EventArgs e)
 {
     students = manager.getStudents();
     dgvDisplay.DataSource = students;
 }