Question
Using Visual Studio 2015, how would I code the following Uodate button event handler in c#?


then displayed in the student list box. Create an interface as follows The initial form for the application should appear as follows Student Scores Students dd New. Lpdate Delete Ext To update, delete or add student information create the following form Enter Student Information Name Student ID MdtemRna Cancel Note: the Control Box property is set to false
media%2F628%2F62851b91-976e-4151-ab0d-e9
media%2F348%2F34897f7e-67a5-4800-9c35-62
media%2F11d%2F11dadd04-0872-4f7d-908e-64
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Update button Handler :

In order to code for update button event handler following method needs to be added :

1. Add update button event handler in the code behind class for Student Scores form(.cs) file

protected void UpdateButton_Click(object sender, EventArgs e)

{

string studentName = null;

string studentID = null;

string studentIDNrank = null;

string studentInfo = null;

string studentRank = null;

if(this.studentListbox.SelectedIndex < 0)

{

MessageBox.Show("Please Select a student.");

studentLisbox.selectedIndex = 0;

return;

}

else

{

studentInfo = studentListbox.SelectedItem.Text;

int len = studentInfo.length;

int index = studentInfo.IndexOf(" ") + 1;// put number of spaces used to display between name and ID

studentName = studentInfo.Substring(0,index);

studentIDNrank = studentInfo.Substring(index,len).Trim();

index = studentIDNrank.IndexOf(" ") + 1;

studentID = studentIDNrank.SubString(0,index);

studentRank = (studentIDNrank.SubString(index,len)).Trim();

studentInfoForm f = new enterStudentInfoForm(studentName, studentID, studentRank);

f.ShowDialog();

}

}

//Method to update the listbox with updated details

protected void ModifyList(string studentName, string studentID, string studentRank)

{

int index = studentLisbox.FindString(studentName);

if(index >= 0)

{

studentLisbox.RemoveAt(index);

}

studentLisbox.Add(new studentNew(studentName, studentID, studentRank);

}

//Method to save the list in student.txt file

protected void SaveStudents()

{

//include code to add comma delimited

string itemText = null;

System.Text.StringBuilder sb = new System.Text.StringBuilder();  

foreach (object item in studentLisbox.Items)  

{  

itemText = item.ToString().Replace(" ", ","); //code to add comma delimter

sb.Append(itemText.ToString());  

sb.Append("/n ");  

}  

using (StreamWriter sw = new StreamWriter("C:\\student.txt", true))

{

sw.WriteLine(sb);

}

}

// Add the below code lines to code behind file of Student Information form(.cs)

//Constructor to set the student attributes as textbox text

protected void enterStudentInfoForm(string studentName, string studentID, string studentRank)

{

this.enterStudentInfoForm.txtbox_Name.Text = studentName;

this.enterStudentInfoForm.txtbox_ID.Text = studentID;

this.enterStudentInfoForm.txtbox_Name.Enabled = false;

this.enterStudentInfoForm.txtbox_ID.Enabled = false;

this.enterStudentInfoForm.txtbox_Midterm.Focus();

selectedStudent student = new selectedStudent();

student.Name = studentName;

student.ID = studentID;

}

//Okay button click event handler that will validate the entries in text boxes and

// set to the student object attributes

protected void okButton_click(Object sender, EventArgs e)

{

string studentName = txtbox_Name.Text;

string studentID = txtbox_ID.Text;

int studentMiderm = Convert.ToInt32(txtbox_Midterm.Text.ToString());

int studentFinal = Convert.ToInt32(txtbox_final.Text.ToString());

string studentRank = CalcLtrGrade(studentMiderm , studentFinal);

if( (studentName != null && studentName !="") &&

(studentID != null && studentID !="") &&

(studentMiderm != null) &&

(studentFinal !=null) &&

(studentRank != null && studentRank !="")

)

{

this.student.Midterm = studentMiderm;

this.student.Final = studentFinal ;

this.student.Rank = studentRank ;

if(student.valid) //object validation

{

// Add this to student list

studentScoresForm.ModifyList(studentName ,studentID , studentMiderm ,studentFinal ,studentRank );

// Save the student list to student.txt file

studentScoresForm.SaveStudents();

}

}

}

Add a comment
Know the answer?
Add Answer to:
Using Visual Studio 2015, how would I code the following Uodate button event handler in c#?...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Visual Studio Code C# Well Document everyline saying what the code does. Include designer code and...

    Visual Studio Code C# Well Document everyline saying what the code does. Include designer code and .cscode Extra 6-1 Create a simple calculator In this exercise, you'l1 create a form that accepts two operands and an operator from the user and then performs the requested operation. Simple Calculator Operand 1: 86 Operator Operand 2 11.11 Resut 7.7408 1. Start a new project named SimpleCalculator in the Extra Exercises Chapter 06SimpleCalculator directory 2. Add labels, text boxes, and buttons to the...

  • PLEASE USE VISUAL BASIC* BY VISUAL STUDIO. Visual Basic INTERMEDIATE Create a Windows Forms application. Use...

    PLEASE USE VISUAL BASIC* BY VISUAL STUDIO. Visual Basic INTERMEDIATE Create a Windows Forms application. Use the following names for the project and solution, respectively: Chopkins Project and Chopkins Solution. Save the application in the VB2017\Chap03 folder. Change the form file's name to Main Form.vb. Change the form's name to frmMain. Create the interface shown in Figure 3-37. The interface contains six labels, three text boxes, and two buttons. The application calculates and displays the total number of packs ordered...

  • must be visual basic code please include any properties that have to be changed. rcises-3.pdf -...

    must be visual basic code please include any properties that have to be changed. rcises-3.pdf - Adobe Acrobat Reader DC View Window Help Tools Extra exerases-3.pdf X 14 Extra exercises tor Murach's Visual Basie 2015 Extra 8-1 Display a test scores array In this exercise, you'll enhance the Score Caleulator form of extra exercise 4-2 so it saves the scores the user enters in an array and then lets the user display the sorted scores in a dialog box. Elle-a...

  • The questions below deal with Microsoft Visual Studio 2012 Reloaded, under the Visual Basic programming language....

    The questions below deal with Microsoft Visual Studio 2012 Reloaded, under the Visual Basic programming language. The book ISBN number that I am using is: 978-1-285-08416-9 or the UPC code is: 2-901285084168-1. Question 1 Visual Basic 2012 is an object-oriented programming language, which is a language that allows the programmer to use ____________________ to accomplish a program�s goal. Question 2 An application that has a Web user interface and runs on a server is called a(n) ____________________ application. Question 3...

  • How do you do this using visual studio on a Mac? You are tasked with creating...

    How do you do this using visual studio on a Mac? You are tasked with creating an application with five PictureBox controls. In the Poker Large folder, you will find JPEG image files for a complete deck of poker cards. Feel free to choose any card image that you like or be creative with this application. Each PictureBox should display a different card from the set of images. When the user clicks any of the PictureBox controls, the name of...

  • If you’re using Visual Studio Community 2015, as requested, the instructions below should be exact but...

    If you’re using Visual Studio Community 2015, as requested, the instructions below should be exact but minor discrepancies may require you to adjust. If you are attempting this assignment using another version of Visual Studio, you can expect differences in the look, feel, and/or step-by-step instructions below and you’ll have to determine the equivalent actions or operations for your version on your own. INTRODUCTION: In this assignment, you will develop some of the logic for, and then work with, the...

  • Programming question. Using Visual Studio 2019 C# Windows Form Application (.NET Framework) Please include code for...

    Programming question. Using Visual Studio 2019 C# Windows Form Application (.NET Framework) Please include code for program with ALL conditions met. Conditions to be met: Word Problem A person inherits a large amount of money. The person wants to invest it. He also has to withdraw it annually. How many years will it take him/her to spend all of the investment that earns at a 7% annual interest rate? Note that he/she needs to withdraw $40,000.00 a year. Also there...

  • ***PLEASE AVOID USING A "CLASS" IN SOLUTION*** thank you. Please use Visual Studio to write a...

    ***PLEASE AVOID USING A "CLASS" IN SOLUTION*** thank you. Please use Visual Studio to write a C# program to allow user to store contact information. 1. User should be able to type in name, E-mail and phone number in the text boxes and click Add button to save the contact record. Every time when user add record, user should be able to see all the information displayed in the right side display text box. (allow up to 10 records) 2....

  • Visual Basic 2015: Extra 18-1 Use inheritance with the Inventory Maintenance Application Source Code: 1. frmNewItem.vb...

    Visual Basic 2015: Extra 18-1 Use inheritance with the Inventory Maintenance Application Source Code: 1. frmNewItem.vb Public Class frmNewItem Public InvItem As InvItem Private Sub frmNewItem_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.LoadComboBox() End Sub Private Sub LoadComboBox() cboSizeOrManufacturer.Items.Clear() If rdoPlant.Checked Then cboSizeOrManufacturer.Items.Add("1 gallon") cboSizeOrManufacturer.Items.Add("5 gallon") cboSizeOrManufacturer.Items.Add("15 gallon") cboSizeOrManufacturer.Items.Add("24-inch box") cboSizeOrManufacturer.Items.Add("36-inch box") Else cboSizeOrManufacturer.Items.Add("Bayer") cboSizeOrManufacturer.Items.Add("Jobe's") cboSizeOrManufacturer.Items.Add("Ortho") cboSizeOrManufacturer.Items.Add("Roundup") cboSizeOrManufacturer.Items.Add("Scotts") End If End Sub Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click If IsValidData() Then InvItem = New InvItem(CInt(txtItemNo.Text),...

  • Using C# Language Develop a Visual C# .NET application that performs a colour control operation. The...

    Using C# Language Develop a Visual C# .NET application that performs a colour control operation. The main form contains a reset button and sets the form's background colour according to the colour values indicated by the colour control objects. Each colour control object is controlled by a corresponding colour control form which provides a progress bar to show the value (in the range 0 to 255) of the corresponding colour control object. The user can click the increase (+) or...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT