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;
///
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);
}
///
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
