Guest User

Untitled

a guest
May 24th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8.  
  9. namespace WindowsApplication2
  10. {
  11. public partial class addButton : Form
  12. {
  13. public addButton()
  14. {
  15. InitializeComponent();
  16. }
  17.  
  18. private void button1_Click(object sender, EventArgs e)
  19. {
  20.  
  21. listBox1.Items.Add("*** 1 ***");
  22. listBox1.Items.Add(firstnameTextBox.Text);
  23. listBox1.Items.Add(lastnameTextBox.Text);
  24. listBox1.Items.Add(phoneTextBox.Text);
  25. listBox1.Items.Add(salaryTextBox.Text);
  26. listBox1.Items.Add(employedTextBox.Text);
  27. listBox1.Items.Add(jobroleTextBox.Text);
  28.  
  29. int count = listBox1.Items.Count;
  30.  
  31. string employeeRecord = null;
  32.  
  33. for (int i = 0; i < count; i++)
  34. {
  35. employeeRecord = employeeRecord + listBox1.Items[i] + " | ";
  36. }
  37.  
  38. string path = @"C:\employees.txt";
  39. if (System.IO.File.Exists(path))
  40. System.IO.File.Delete(path);
  41.  
  42. System.IO.StreamWriter file = new System.IO.StreamWriter(@"C:\employees.txt");
  43. file.WriteLine(employeeRecord);
  44. file.Close();
  45.  
  46.  
  47.  
  48. MessageBox.Show("Save was successful");
  49. }
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56. }
  57.  
  58. private void clearButton_Click(object sender, EventArgs e)
  59. {
  60. listBox1.Items.Clear();
  61. }
  62.  
  63. private void button2_Click(object sender, EventArgs e)
  64. {
  65. string[] detailsArray = new string[5];
  66.  
  67.  
  68. for (int j = 0; j < 1; j++)
  69. {
  70. detailsArray[j] = Convert.ToString(listBox1.Items[j]);
  71. }
  72.  
  73. Array.Sort(detailsArray);
  74.  
  75. }
  76.  
  77. private void button3_Click(object sender, EventArgs e)
  78. {
  79. this.Close();
  80. }
  81. }
  82. }
Add Comment
Please, Sign In to add comment