Question

***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)

Main Form 4 / 10 Name === Add Name === Name : Tom Wood Email: tom.wood@eich.edu Phone : 734-909-2356 E-mail Phone Add Find Na

2. User can type name in the Name Textbox and click Find Name button to look for the that person. If the name is in the record, display the record in the Name, E-mail and Phone text box. If not, use Message.Show() to send out a not found message.

Main Form - 0 X 4 / 10 Name Su Mall === Add Name === Name : Tom Wood Email: tom.wood@emich.edu Phone: 345-345-1122 E-mail sum

3. If the record is found by the Find Name button, user can change any field (Name, E-mail and Phone) in the Textboxes and click Update button to update the information. All the records should be displayed in the display box again.

Main Form - DX 4 / 10 Name == Update = Name : Tom Wood Email: tom.wood @emich.edu Phone: 345-345-1122 E-mail Phone Name : Su

4. User can click the Sort by Name Button to sort all the record in the ascending order by name and display in the display box. DO NOT print out any empty element/spot in the array. (Only sort the copies of the Arrays)

Main Form - DX 4 / 10 Name E-mail Phone === Sorted By Name === Name : Joe Timer Email: jt@gmail.com Phone: 745-909-4544 EEEEE

5. Data validation and Record counter: 5 and 5 points

If user try to add empty data in the record (Name, E-mail, or Phone), the program must be able to check and show the proper error message by using Message.Show() (Example: Name is a required field!!)

Please have a record counter displayed on the top (Error Message over 10 records).

Important Note:

The output TextBox properties:

Multiline: true

ScrollBars: Vertical

TextBox output string line breaker: \r\n

0 0
Add a comment Improve this question Transcribed image text
Answer #1

//Create Solution with name Record_Manager. If you want to use another name, Change the namespace name accordingly in each file.

//Form interface

. Main Form status Name E-mail Phone Add Find Name Update O o Sort By Name o Close

//C# code

//Form1.Designer.cs

namespace Record_Manager
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;

/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}

#region Windows Form Designer generated code

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.txtName = new System.Windows.Forms.TextBox();
this.txtEmail = new System.Windows.Forms.TextBox();
this.label2 = new System.Windows.Forms.Label();
this.txtPhone = new System.Windows.Forms.TextBox();
this.label3 = new System.Windows.Forms.Label();
this.txtRecord = new System.Windows.Forms.TextBox();
this.btnAdd = new System.Windows.Forms.Button();
this.btnFindName = new System.Windows.Forms.Button();
this.btnUpdate = new System.Windows.Forms.Button();
this.btnClose = new System.Windows.Forms.Button();
this.lblStatus = new System.Windows.Forms.Label();
this.btnSort = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(13, 43);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(35, 13);
this.label1.TabIndex = 0;
this.label1.Text = "Name";
//
// txtName
//
this.txtName.Location = new System.Drawing.Point(64, 40);
this.txtName.Name = "txtName";
this.txtName.Size = new System.Drawing.Size(100, 20);
this.txtName.TabIndex = 1;
//
// txtEmail
//
this.txtEmail.Location = new System.Drawing.Point(64, 80);
this.txtEmail.Name = "txtEmail";
this.txtEmail.Size = new System.Drawing.Size(100, 20);
this.txtEmail.TabIndex = 3;
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(13, 83);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(35, 13);
this.label2.TabIndex = 2;
this.label2.Text = "E-mail";
//
// txtPhone
//
this.txtPhone.Location = new System.Drawing.Point(64, 122);
this.txtPhone.Name = "txtPhone";
this.txtPhone.Size = new System.Drawing.Size(100, 20);
this.txtPhone.TabIndex = 5;
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(13, 125);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(38, 13);
this.label3.TabIndex = 4;
this.label3.Text = "Phone";
//
// txtRecord
//
this.txtRecord.Location = new System.Drawing.Point(205, 35);
this.txtRecord.Multiline = true;
this.txtRecord.Name = "txtRecord";
this.txtRecord.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.txtRecord.Size = new System.Drawing.Size(198, 321);
this.txtRecord.TabIndex = 6;
//
// btnAdd
//
this.btnAdd.Location = new System.Drawing.Point(64, 168);
this.btnAdd.Name = "btnAdd";
this.btnAdd.Size = new System.Drawing.Size(100, 23);
this.btnAdd.TabIndex = 7;
this.btnAdd.Text = "Add";
this.btnAdd.UseVisualStyleBackColor = true;
this.btnAdd.Click += new System.EventHandler(this.btnAdd_Click);
//
// btnFindName
//
this.btnFindName.Location = new System.Drawing.Point(64, 210);
this.btnFindName.Name = "btnFindName";
this.btnFindName.Size = new System.Drawing.Size(100, 23);
this.btnFindName.TabIndex = 8;
this.btnFindName.Text = "Find Name";
this.btnFindName.UseVisualStyleBackColor = true;
this.btnFindName.Click += new System.EventHandler(this.btnFindName_Click);
//
// btnUpdate
//
this.btnUpdate.Location = new System.Drawing.Point(64, 252);
this.btnUpdate.Name = "btnUpdate";
this.btnUpdate.Size = new System.Drawing.Size(100, 23);
this.btnUpdate.TabIndex = 9;
this.btnUpdate.Text = "Update";
this.btnUpdate.UseVisualStyleBackColor = true;
this.btnUpdate.Click += new System.EventHandler(this.btnUpdate_Click);
//
// btnClose
//
this.btnClose.Location = new System.Drawing.Point(64, 333);
this.btnClose.Name = "btnClose";
this.btnClose.Size = new System.Drawing.Size(100, 23);
this.btnClose.TabIndex = 10;
this.btnClose.Text = "Close";
this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
//
// lblStatus
//
this.lblStatus.AutoSize = true;
this.lblStatus.Location = new System.Drawing.Point(261, 13);
this.lblStatus.Name = "lblStatus";
this.lblStatus.Size = new System.Drawing.Size(35, 13);
this.lblStatus.TabIndex = 11;
this.lblStatus.Text = "status";
//
// btnSort
//
this.btnSort.Location = new System.Drawing.Point(64, 295);
this.btnSort.Name = "btnSort";
this.btnSort.Size = new System.Drawing.Size(100, 23);
this.btnSort.TabIndex = 12;
this.btnSort.Text = "Sort By Name";
this.btnSort.UseVisualStyleBackColor = true;
this.btnSort.Click += new System.EventHandler(this.btnSort_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(439, 392);
this.Controls.Add(this.btnSort);
this.Controls.Add(this.lblStatus);
this.Controls.Add(this.btnClose);
this.Controls.Add(this.btnUpdate);
this.Controls.Add(this.btnFindName);
this.Controls.Add(this.btnAdd);
this.Controls.Add(this.txtRecord);
this.Controls.Add(this.txtPhone);
this.Controls.Add(this.label3);
this.Controls.Add(this.txtEmail);
this.Controls.Add(this.label2);
this.Controls.Add(this.txtName);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Main Form";
this.ResumeLayout(false);
this.PerformLayout();

}

#endregion

private System.Windows.Forms.Label label1;
private System.Windows.Forms.TextBox txtName;
private System.Windows.Forms.TextBox txtEmail;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.TextBox txtPhone;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox txtRecord;
private System.Windows.Forms.Button btnAdd;
private System.Windows.Forms.Button btnFindName;
private System.Windows.Forms.Button btnUpdate;
private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.Label lblStatus;
private System.Windows.Forms.Button btnSort;
}
}

//Program.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Record_Manager
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}

//Contact.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Record_Manager
{

class Contact
{
private string person_name;
private string email;
private string phone;
public string Person_Name
{
get
{
return person_name;
}
set
{
person_name = value;
}
}
public string Email
{
get
{
return email;
}
set
{
email = value;
}
}
public string Phone
{
get
{
return phone;
}
set
{
phone = value;
}
}
public override string ToString()
{
return "Name: " + person_name + "\r\nEmail: " + email + "\r\nPhone: " + phone + "\r\n======================\r\n";
}

}
}

//Form1.cs

using System;

using System.Windows.Forms;

namespace Record_Manager
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
lblStatus.Text = count + "/" + MAX;
}

const int MAX = 10;
Contact[] contacts = new Contact[MAX];
int count = 0;
public void display()
{
lblStatus.Text = count + "/" + MAX;
for (int i=0; i<count; i++)
{
txtRecord.Text += contacts[i];
}
}
public int searchRecord(string n)
{
for(int i=0;i<count;i++)
{
if(contacts[i].Person_Name.ToLower().Equals(n.ToLower()))
{
return i;
}
}

return -1;
}
public void clear()
{
txtEmail.Clear();
txtName.Clear();
txtPhone.Clear();
}
private void btnAdd_Click(object sender, EventArgs e)
{
if(txtEmail.Text.Equals("")||txtName.Text.Equals("")||txtPhone.Text.Equals(""))
{
MessageBox.Show("Please enter values in input boxes...");
}
else
{
if (count == 10)
{
MessageBox.Show("No more storage to add new record");

}
else
{
Contact contact = new Contact();
contact.Person_Name = txtName.Text;
contact.Email = txtEmail.Text;
contact.Phone = txtPhone.Text;
contacts[count] = contact;
txtRecord.Text = "=====ADD========\r\n";
count++;
display();


clear();
}
clear();
}

}

private void btnFindName_Click(object sender, EventArgs e)
{
if(txtName.Text.Equals(""))
{
MessageBox.Show("Please enter name to find record...");
}
else
{
int index = searchRecord(txtName.Text);
if (index==-1)
{
MessageBox.Show("Record not found..");
}
else
{
txtName.Text = contacts[index].Person_Name;
txtEmail.Text = contacts[index].Email;
txtPhone.Text = contacts[index].Phone;
}
}
}

private void btnUpdate_Click(object sender, EventArgs e)
{
if (txtName.Text.Equals(""))
{
MessageBox.Show("Please enter name to find and update record...");
}
else
{
int index = searchRecord(txtName.Text);
if (index == -1)
{
MessageBox.Show("Record not found..");
}
else
{
if(!txtName.Text.Equals(""))
contacts[index].Person_Name =txtName.Text;
if(!txtEmail.Text.Equals(""))
contacts[index].Email = txtEmail.Text;
if(!txtPhone.Text.Equals(""))
contacts[index].Phone= txtPhone.Text;
txtRecord.Text = "====Update=======\r\n";
display();
}
}

}

private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}

private void btnSort_Click(object sender, EventArgs e)
{
Contact[] temp = new Contact[count];
for(int i=0;i<count;i++)
{
temp[i] = contacts[i];
}
Array.Sort(temp, (x, y) => String.Compare(x.Person_Name, y.Person_Name));
lblStatus.Text = count + "/" + MAX;
  
txtRecord.Clear();
txtRecord.Text = "=== SORT BY NAME =====\r\n";
for (int i = 0; i < count; i++)
{
txtRecord.Text += temp[i];
}
}
}
}

//Output

.: Main Form - O X 2/10 Name =====ADD======== Name: Tim Mark Email: tm@ff.com Phone: 455-456-6666 E-mail Phone Name: Jack Boc

//If you need any help regarding this solution......... please leave a comment....... thanks

Add a comment
Know the answer?
Add Answer to:
***PLEASE AVOID USING A "CLASS" IN SOLUTION*** thank you. Please use Visual Studio to write a...
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
  • // Write the compiler used: Visual studio // READ BEFORE YOU START: // You are given...

    // Write the compiler used: Visual studio // READ BEFORE YOU START: // You are given a partially completed program that creates a list of patients, like patients' record. // Each record has this information: patient's name, doctor's name, critical level of patient, room number. // The struct 'patientRecord' holds information of one patient. Critical level is enum type. // An array of structs called 'list' is made to hold the list of patients. // To begin, you should trace...

  • you must implement public class Student by following the instructions as follows exactly. You may reference...

    you must implement public class Student by following the instructions as follows exactly. You may reference Chapter 7 for the similar examples to get the ideas and concepts. Each student must have the following 5 attributes (i.e., instance variables): private String   studentID ;              // student’s ID such as                         1 private String lastName   ;                         // student’s last name such as              Doe private String firstName ;             // student’s first name such as            John private double gpa...

  • write a code on .C file Problem Write a C program to implement a banking application...

    write a code on .C file Problem Write a C program to implement a banking application system. The program design must use a main and the below functions only. The program should use the below three text files that contain a set of lines. Sample data of these files are provided with the assessment. Note that you cannot use the library string.h to manipulate string variables. For the file operations and manipulations, you can use only the following functions: fopen(),...

  • New Perspectives on HTML5 and CSS3. Solve Chapter 13 Case Problem 3. mas_register.js "use strict"; /*...

    New Perspectives on HTML5 and CSS3. Solve Chapter 13 Case Problem 3. mas_register.js "use strict"; /* New Perspectives on HTML5, CSS3, and JavaScript 6th Edition Tutorial 13 Case Problem 3 Filename: mas_register.js Author: Date: Function List ============= formTest() Performs a validation test on the selection of the conference session package and the conference discount number calcCart() Calculates the cost of the registration and saves data in session storage    writeSessionValues() Writes data values from session storage in to the registration...

  • Create a program that will use the attached input file and perform the following operations. Read...

    Create a program that will use the attached input file and perform the following operations. Read the file into an appropriate JCF data structure. Look up a (list of) names and numbers matching a last name or the first letters of a last name, ignoring case. Look up a (list of) names and numbers matching a number or the first digits of a number. Add a name and number to the list. Sort the list by first name, last name...

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
ADVERTISEMENT