Question
How do i finish this C# code. The only section that needs finished is this part, based on this (OnFormClosing This method must call its
How do i finish this C# code. The only section that needs finished is this part, based on this (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) -------------------------------
protected override void OnFormClosing(FormClosingEventArgs e) { base.OnFormClosing(e);
}
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Below is the whole code for my Main
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started