Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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;

///

/// 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intelligent Information And Database Systems 6th Asian Conference Aciids 2014 Bangkok Thailand April 7 9 2014 Proceedings Part I 9 2014 Proceedings Part 1 Lnai 8397

Authors: Ngoc-Thanh Nguyen ,Boonwat Attachoo ,Bogdan Trawinski ,Kulwadee Somboonviwat

2014th Edition

3319054759, 978-3319054759

More Books

Students also viewed these Databases questions

Question

What is digital literacy? Why is it necessary?

Answered: 1 week ago