// Button close method private void BtnClose_Click(object sender, EventArgs e) { // Try catch method try { // Attempt to save ClsInstitute.Save(); } // If failed catch the error catch (Exception ex) { // And display message box MessageBox.Show(ex.Message); } // Closes the program Close(); }
// Form constructor public FrmMain() { InitializeComponent(); // Try catch method try { // Attempt to retrieve the student list ClsInstitute.Retrieve(); // Update the total balance UpdateTotalStudents(); } // If failed catch the error catch (Exception ex) { // And display message box MessageBox.Show(ex.Message); } }
private void UpdateTotalStudents() { // Displaying the total students and the total balance in currenct format, 0 is the student count, 1 is the total balance, we use the C to show the balance in the country specific currency format LblStudentDetails.Text = string.Format("{0} Student(s)\nTotal Balance: {1:C}", ClsInstitute.StudentList.Count, ClsInstitute.TotalBalance()); }