Question: I need to implement this final part of the code --OnFormClosing This method must call its base implementation, checks to see if the persister object

I need to implement this final part of the code --OnFormClosing This method must call its base implementation, checks to see if the persister object is null and if not, call its Dispose() method and assign null to it.--

Here is the code

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms;

namespace PFW.CSIST203.Project2 {

public partial class frmMain : Form { internal PFW.CSIST203.Project2.Persisters.Excel.ExcelPersister persister;

///

/// Initializes the form /// /// /// DO NOT EDIT /// public frmMain() { InitializeComponent(); }

private void FrmMain_Load(object sender, EventArgs e) { this.persister = new Persisters.Excel.ExcelPersister(); }

private void BtnPrevious_Click(object sender, EventArgs e) { //Get value from text, unable to reduce cow value below zero var selectedRow = int.Parse(this.txtRow.Text) - 1;

if (selectedRow <= 0) { //do nothing } else { //load the row var row = this.persister.GetRow(selectedRow - 1); txtFirstname.Text = System.Convert.ToString(row["First Name"]); txtLastname.Text = System.Convert.ToString(row["Last Name"]); txtEmailAddress.Text = System.Convert.ToString(row["E-mail Address"]); txtBusinessPhone.Text = System.Convert.ToString(row["Business Phone"]); txtCompany.Text = System.Convert.ToString(row["Company"]); txtTitle.Text = System.Convert.ToString(row["Job Title"]); this.txtRow.Text = selectedRow.ToString(); } }

private void BtnNext_Click(object sender, EventArgs e) { //Get value from text, unable to excede maximum row number var selectedRow = int.Parse(this.txtRow.Text) + 1;

var maximumRows = this.persister.CountRows();

if (selectedRow > maximumRows) { //do nothing } else { var row = this.persister.GetRow(selectedRow - 1); txtFirstname.Text = System.Convert.ToString(row["First Name"]); txtLastname.Text = System.Convert.ToString(row["Last Name"]); txtEmailAddress.Text = System.Convert.ToString(row["E-mail Address"]); txtBusinessPhone.Text = System.Convert.ToString(row["Business Phone"]); txtCompany.Text = System.Convert.ToString(row["Company"]); txtTitle.Text = System.Convert.ToString(row["Job Title"]); this.txtRow.Text = selectedRow.ToString(); } }

protected override void OnFormClosing(FormClosingEventArgs e) { base.OnFormClosing(e);

}

///

/// Handle the File -> Open dialog box used for selecting the excel file that is utilized by the front-end /// /// /// DO NOT EDIT /// /// /// private void OpenToolStripMenuItem_Click(object sender, EventArgs e) { var result = OpenFileDialog.ShowDialog(); if (result == DialogResult.OK) { persister.Dispose(); persister = new PFW.CSIST203.Project2.Persisters.Excel.ExcelPersister(OpenFileDialog.FileName); txtRow.Text = "0"; // reset back to zero txtFirstname.Text = string.Empty; txtLastname.Text = string.Empty; txtEmailAddress.Text = string.Empty; txtBusinessPhone.Text = string.Empty; txtCompany.Text = string.Empty; txtTitle.Text = string.Empty; } } }

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!