Employee Data, Part 3 Create an application thatperforms the following operation
ID: 3766513 • Letter: E
Question
Employee Data, Part 3
Create an application thatperforms the following operations with the employee file created by the application in programming challenge 1:
Uses an Open dialog box to allow the user to select it.
Allows the user to enter a new employee record and then saves the record to the file.
Allows the user to enter an employee number and searches for a record containing that employee number. If the record is found, the record is displayed.
Displays all records one after the other.
Prints an employee record.
Equip your application with either a mesu systm or a set of buttons to perform these operations.
Explanation / Answer
Declare streamwriter Dim EmployeeFile As StreamWriter If File.Exists(strInputFileName) Then ' Create the file EmployeeFile = File.AppendText(strInputFileName) ' Write our lines of text EmployeeFile.WriteLine(txtFirstName.Text) EmployeeFile.WriteLine(txtMiddleName.Text) EmployeeFile.WriteLine(txtLastName.Text) EmployeeFile.WriteLine(txtEmpNumber.Text) EmployeeFile.WriteLine(cmbDept.SelectedItem.ToStri ng()) EmployeeFile.WriteLine(txtPhone.Text) EmployeeFile.WriteLine(txtPhoneExt.Text) EmployeeFile.WriteLine(txtEmail.Text) EmployeeFile.Close() ' Tell the user that the file was updated MessageBox.Show("The data was added and the file " & strInputFileName & " was saved.") Else ' Create the file EmployeeFile = File.CreateText(strInputFileName) EmployeeFile.WriteLine(txtFirstName.Text) EmployeeFile.WriteLine(txtMiddleName.Text) EmployeeFile.WriteLine(txtLastName.Text) EmployeeFile.WriteLine(txtEmpNumber.Text) EmployeeFile.WriteLine(cmbDept.SelectedItem.ToStri ng()) EmployeeFile.WriteLine(txtPhone.Text) EmployeeFile.WriteLine(txtPhoneExt.Text) EmployeeFile.WriteLine(txtEmail.Text) EmployeeFile.Close() ' Tell the user that the file was created MessageBox.Show("The file " & strInputFileName & " was saved.") End If
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.