using
System;
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
System.Text;
System.Windows.Forms;
System.IO;
namespace
Lab7A
{
public partial class Form1 : Form
public Form1()
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
private void nameLabel_Click(object sender, EventArgs e)
private void nameTextBox_TextChanged(object sender, EventArgs e)
private void emailLabel_Click(object sender, EventArgs e)
private void emailTextBox_TextChanged(object sender, EventArgs e)
private void button1_Click(object sender, EventArgs e)
string name, email;
try
using (StreamWriter storeInfo = new StreamWriter("info.txt", true))
name = nameTextBox.Text;
email = emailTextBox.Text;
storeInfo.WriteLine(name +
"|" + email);
this.button2.Visible = true;
nameTextBox.Text =
string.Empty;
emailTextBox.Text =
catch (Exception exc)
MessageBox.Show("Error!\n" + exc.Message);
private void contactsLabel_Click(object sender, EventArgs e)
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
private void button2_Click(object sender, EventArgs e)
string info;
string [ ] recordData = new string [2];
string cname = string.Empty;
string cemail = string.Empty;
string outInfo = string.Empty;;
using (StreamReader getInfo = new StreamReader("info.txt"))
listBox1.Items.Clear();
while (!getInfo.EndOfStream)
info = getInfo.ReadLine();
recordData = info.Split (
'|');
outInfo = recordData[0] +
" " +
String.Format("{0:c}", double.Parse(recordData[0]));
listBox1.Items.Add(outInfo);
listBox1.Visible =
true;
listBox1.Text = exc.Message;