Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- namespace WindowsApplication2
- {
- public partial class addButton : Form
- {
- public addButton()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- listBox1.Items.Add("*** 1 ***");
- listBox1.Items.Add(firstnameTextBox.Text);
- listBox1.Items.Add(lastnameTextBox.Text);
- listBox1.Items.Add(phoneTextBox.Text);
- listBox1.Items.Add(salaryTextBox.Text);
- listBox1.Items.Add(employedTextBox.Text);
- listBox1.Items.Add(jobroleTextBox.Text);
- int count = listBox1.Items.Count;
- string employeeRecord = null;
- for (int i = 0; i < count; i++)
- {
- employeeRecord = employeeRecord + listBox1.Items[i] + " | ";
- }
- string path = @"C:\employees.txt";
- if (System.IO.File.Exists(path))
- System.IO.File.Delete(path);
- System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\employees.txt");
- file.WriteLine(employeeRecord);
- file.Close();
- MessageBox.Show("Save was successful");
- }
- }
- private void clearButton_Click(object sender, EventArgs e)
- {
- listBox1.Items.Clear();
- }
- private void button2_Click(object sender, EventArgs e)
- {
- string[] detailsArray = new string[5];
- for (int j = 0; j < 1; j++)
- {
- detailsArray[j] = Convert.ToString(listBox1.Items[j]);
- }
- Array.Sort(detailsArray);
- }
- private void button3_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- }
- }
Add Comment
Please, Sign In to add comment