/// <summary> /// Used to Open the 'StudentRegistration' Form and get new student details /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnAddNew_Click(object sender, EventArgs e) { try { //Increase CurrentStudentID ID currentStudentID = currentStudentID + 1; //Popup the 'StudentRegistrationDetails' form to get data StudentRegistration studRegDetils = new StudentRegistration(currentStudentID); studRegDetils.ShowDialog(this); //Check Successfull Addtion of Data. If not CurrentStudentID reduce by 1 if (studRegDetils.successStatus) { //Add New Row in Datagrid dataGridStudent.Rows.Add(); dataGridStudent.Rows[currentRowNumber].Cells[0].Value = studRegDetils.studentID; dataGridStudent.Rows[currentRowNumber].Cells[1].Value = studRegDetils.nameOfStudent; dataGridStudent.Rows[currentRowNumber].Cells[2].Value = studRegDetils.dob; dataGridStudent.Rows[currentRowNumber].Cells[3].Value = studRegDetils.gpa; dataGridStudent.Rows[currentRowNumber].Cells[4].Value = studRegDetils.active; //Increment Datagrid Row Number currentRowNumber = currentRowNumber + 1; } else { //Decrease CurrentStudentID ID due to Cancel button clicked currentStudentID = currentStudentID - 1; } //Clear and Close the Object studRegDetils.Dispose(); } catch (Exception exception) { MessageBox.Show(exception.Message, Constants.MessageCaptionStudentDetails, MessageBoxButtons.OK, MessageBoxIcon.Error); } }