Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Starting out with >>>> Visual C# - Contact Phone List Using this code- complete the program using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using

image text in transcribed

Starting out with >>>> Visual C# - Contact Phone List

Using this code- complete the program

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; using System.Text.RegularExpressions;

namespace Friends_Phone_List { public partial class frmContactList : Form { //Declare a string for a the Disk file name and assign it an empty value string strDiskFileName = "";

public frmContactList() { InitializeComponent(); }

private void btnOpen_Click(object sender, EventArgs e) { //define a StreamReader variable and name it inputFile string strInput;

//try //{

//Use the Show Open dialog to allow the user to select/open a Contact List disk file

//The filename that is selected should be assigned to the field strDiskFileName //Open the disk file using the OpenText method and passing strDisFileName as an argument //clear list box of any items it may have //Set up a while loop using the EndOfStream property

//Read disk record into strInput //Add contact to list box control

//Close disk file //} //catch (Exception ex) //{ // MessageBox.Show("Problems with disk file:" + Environment.NewLine + ex.Message, "Disk File", MessageBoxButtons.OK, MessageBoxIcon.Information);

//}

}

private void btnAddContact_Click(object sender, EventArgs e) { string strContact;

//Validate data

//Assign Contact name(30 chars) + Contact Phone + Phone Source(7 chars) to strContact

//Add contact to list box control using the string variable strContact

//clear Add contact controls (contact name, contact phone and phone source)

//set focus to contact name

} private bool Validate_Contact() { // Contact name cannot be blank (empty) if (txtContactName.Text == "") { MessageBox.Show("The contact name is required.", "Data Entry", MessageBoxButtons.OK, MessageBoxIcon.Information); txtContactName.Focus(); return false; }

// Make sure the phone number follows this pattern (###) ###-####. Area code will be required as well Match PhoneDigits = Regex.Match(txtContactPhone.Text, @"\([0-9][0-9][0-9]\) [0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]"); if (PhoneDigits.Success == false) { MessageBox.Show("The phone must have 10 digits when including the area code.", "Data Entry", MessageBoxButtons.OK, MessageBoxIcon.Information); txtContactPhone.Focus(); return false; }

}

private void btnExit_Click(object sender, EventArgs e) {

this.Close(); }

private void btnDeleteContact_Click(object sender, EventArgs e) { int intIndex;

//make sure a contact is selected, if a contact is not selected display an appropriate message //using the MessageBox class and exit the method.

//get selected index of the contact that was chosen and assign it to intIndex

//remove contact from list box by calling the RemoveAt method passing in the selected index (intIndex)

//lstContactNumbers.Items.?;

}

private void btnSave_Click(object sender, EventArgs e) { //Declare StreamWriter variable and name it outputFile int intCount, intloop; string strOutput;

//Make sure there is at least one contact to save if (lstContactNumbers.Items.Count==0) { MessageBox.Show("There are no contacts to save.", "Contact List", MessageBoxButtons.OK, MessageBoxIcon.Information); return; }

if (strDiskFileName=="") //If this is blank then a file was not opened, therefore, it is a new file that is to be saved. { sadSave.Title = "Save Contact List"; // Display Save As Dialog using if statement. Uncomment the following code and finish it //if (sadSave.ShowDialog() == DialogResult.OK) //{ // //assign Save As Dialog FileName to the field strDiskFileName //} //else //{ // return; //Saving a disk file was cancelled //}

}

//Open the disk file to be written over, not appended using the variable outputFile //Get the number of contacts in the list intCount = lstContactNumbers.Items.Count;

for (intloop = 0; intloop

}

// close disk file

}

private void Set_Form_AcceptButton(object sender, EventArgs e) { // set the Form's AcceptButton to btnAddContact

}

} }

Cis 130-Assignment #3 You will finish the following application which allows a user to keep track of a contact list of important phones numbers: Contact Phone List Phone source: Unknown Add Contact Contact name (last name, first name): Contact phone (222) 222-2222 (444) 444-4444 Cellt Unknown Alanson, Theresa Brown, Kelley Jones, David c1ii) 111-1111 tome Olpen Contacti. Save Contacts Delete Contact Exit Follow these steps to complete the assignment: 1. Select the ComboBox control (Phone source) and set the property DropDownStyle to DropDownList. This will force the user to select an item from the list. 2. Set the MaxLength property for the contact name TextBox control to 30. 3. The Validate_Contact method is missing code to make sure the user selects an item from the Phone source ComboBox control. This control is both a Textbox control and list box control. Test this after you have completed the code. Anytime the Contact name TextBox control is changed or the Contact phone number or the phone source write C# code to make sure the Add Contact button is the default button. Finish the one line of code for the following method: Set_Form_AcceptButton.This method should be called when the contact name, phone or phone source changes. Finish code for the Add Contact button click event. Comments are given to assist you with the logic. Test this after it is completed Finish code the Save Contacts button click event. Refer to the comments and again test the application when this logic is complete. Finish code the Open Co exceptions during runtime. Finish code the Delete Contact button 4. 5. 6. 7. ntacts click event procedure. Remember to uncomment the Try statement to catch any 8. Cis 130-Assignment #3 You will finish the following application which allows a user to keep track of a contact list of important phones numbers: Contact Phone List Phone source: Unknown Add Contact Contact name (last name, first name): Contact phone (222) 222-2222 (444) 444-4444 Cellt Unknown Alanson, Theresa Brown, Kelley Jones, David c1ii) 111-1111 tome Olpen Contacti. Save Contacts Delete Contact Exit Follow these steps to complete the assignment: 1. Select the ComboBox control (Phone source) and set the property DropDownStyle to DropDownList. This will force the user to select an item from the list. 2. Set the MaxLength property for the contact name TextBox control to 30. 3. The Validate_Contact method is missing code to make sure the user selects an item from the Phone source ComboBox control. This control is both a Textbox control and list box control. Test this after you have completed the code. Anytime the Contact name TextBox control is changed or the Contact phone number or the phone source write C# code to make sure the Add Contact button is the default button. Finish the one line of code for the following method: Set_Form_AcceptButton.This method should be called when the contact name, phone or phone source changes. Finish code for the Add Contact button click event. Comments are given to assist you with the logic. Test this after it is completed Finish code the Save Contacts button click event. Refer to the comments and again test the application when this logic is complete. Finish code the Open Co exceptions during runtime. Finish code the Delete Contact button 4. 5. 6. 7. ntacts click event procedure. Remember to uncomment the Try statement to catch any 8

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_2

Step: 3

blur-text-image_3

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

Pro SQL Server Wait Statistics

Authors: Enrico Van De Laar

1st Edition

1484211391, 9781484211397

More Books

Students also viewed these Databases questions