Advertisement
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.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using System.IO;
- namespace lda58_Homework2
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void btnSearch_Click(object sender, EventArgs e)
- {
- StreamReader inputfile;
- string employeeinfo;
- int specificID;
- inputfile = File.OpenText("company.txt");
- //inputfile variable opens the desired text file "company.txt"
- while (!inputfile.EndOfStream)
- {
- employeeinfo = inputfile.ReadLine();
- //employeeinfo variable now contains everything that was in the file
- string employeeline = employeeinfo;
- string[] employeeID = employeeline.Split(',');
- specificID = int.Parse(employeeID[0]);
- if (TbxEmployeeID.Text == specificID.ToString())
- {
- if (int.Parse(employeeID[1]) == 1)
- {
- Lboutput.Text = "The employee's name is " + employeeID[2] + " " + employeeID[3] + " They work in the Hardware Department";
- }
- if (int.Parse(employeeID[1]) == 2)
- {
- Lboutput.Text = "The employee's name is " + employeeID[2] + " " + employeeID[3] + " They work in the Legal Department";
- }
- if (int.Parse(employeeID[1]) == 3)
- {
- Lboutput.Text = "The employee's name is " + employeeID[2] + " " + employeeID[3] + " They work in the Marketing Department";
- }
- if (int.Parse(employeeID[1]) == 4)
- {
- Lboutput.Text = "The employee's name is " + employeeID[2] + " " + employeeID[3] + " They work in the Operations Department";
- }
- if (int.Parse(employeeID[1]) == 5)
- {
- Lboutput.Text = "The employee's name is " + employeeID[2] + " " + employeeID[3] + " They work in the Production Department";
- }
- if (int.Parse(employeeID[1]) == 6)
- {
- Lboutput.Text = "The employee's name is " + employeeID[2] + " " + employeeID[3] + " They work in the Shipping Department";
- }
- if (int.Parse(employeeID[1]) == 7)
- {
- Lboutput.Text = "The employee's name is " + employeeID[2] + " " + employeeID[3] + " They work in the Software Department";
- }
- break;
- }
- }
- if (Lboutput.Text == "")
- {
- MessageBox.Show("Incorrect ID");
- }
- }
- private void BtnExit_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- private void Btnreset_Click(object sender, EventArgs e)
- {
- Lboutput.Text = "";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement