SHARE
TWEET

Untitled

a guest May 21st, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. using System.IO;
  11. namespace lda58_Homework2
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.  
  20.         private void btnSearch_Click(object sender, EventArgs e)
  21.         {
  22.             StreamReader inputfile;
  23.             string employeeinfo;
  24.             int specificID;
  25.             inputfile = File.OpenText("company.txt");
  26.             //inputfile variable opens the desired text file "company.txt"
  27.  
  28.  
  29.  
  30.  
  31.             while (!inputfile.EndOfStream)
  32.             {
  33.                 employeeinfo = inputfile.ReadLine();
  34.                 //employeeinfo variable now contains everything that was in the file
  35.  
  36.  
  37.                 string employeeline = employeeinfo;
  38.  
  39.                 string[] employeeID = employeeline.Split(',');
  40.  
  41.  
  42.                 specificID = int.Parse(employeeID[0]);
  43.  
  44.  
  45.                
  46.                 if (TbxEmployeeID.Text == specificID.ToString())
  47.  
  48.                 {
  49.                     if (int.Parse(employeeID[1]) == 1)
  50.                     {
  51.                         Lboutput.Text = "The employee's name is " + employeeID[2] + " " + employeeID[3] + " They work in the Hardware Department";
  52.  
  53.                     }
  54.                     if (int.Parse(employeeID[1]) == 2)
  55.                     {
  56.                         Lboutput.Text = "The employee's name is " + employeeID[2] + " " + employeeID[3] + " They work in the Legal Department";
  57.  
  58.                     }
  59.                     if (int.Parse(employeeID[1]) == 3)
  60.                     {
  61.                         Lboutput.Text = "The employee's name is " + employeeID[2] + " " + employeeID[3] + " They work in the Marketing Department";
  62.  
  63.                     }
  64.                     if (int.Parse(employeeID[1]) == 4)
  65.                     {
  66.                         Lboutput.Text = "The employee's name is " + employeeID[2] + " " + employeeID[3] + " They work in the Operations Department";
  67.  
  68.                     }
  69.                     if (int.Parse(employeeID[1]) == 5)
  70.                     {
  71.                         Lboutput.Text = "The employee's name is " + employeeID[2] + " " + employeeID[3] + " They work in the Production Department";
  72.  
  73.                     }
  74.                     if (int.Parse(employeeID[1]) == 6)
  75.                     {
  76.                         Lboutput.Text = "The employee's name is " + employeeID[2] + " " + employeeID[3] + " They work in the Shipping Department";
  77.  
  78.                     }
  79.                     if (int.Parse(employeeID[1]) == 7)
  80.                     {
  81.                         Lboutput.Text = "The employee's name is " + employeeID[2] + " " + employeeID[3] + " They work in the Software Department";
  82.                     }
  83.  
  84.  
  85.             break;
  86.                 }
  87.  
  88.  
  89.             }
  90.  
  91.             if (Lboutput.Text == "")
  92.             {
  93.                 MessageBox.Show("Incorrect ID");
  94.             }
  95.  
  96.  
  97.                
  98.                
  99.            
  100.  
  101.  
  102.                
  103.                  
  104.  
  105.                
  106.                
  107.  
  108.            
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.         }
  117.  
  118.  
  119.         private void BtnExit_Click(object sender, EventArgs e)
  120.         {
  121.             this.Close();
  122.         }
  123.  
  124.         private void Btnreset_Click(object sender, EventArgs e)
  125.         {
  126.             Lboutput.Text = "";
  127.         }
  128.     }
  129. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top