Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You will create a Windows form application that is responsible for managing a collection of Employee records. Each employee record will have properties for data,

You will create a Windows form application that is responsible for managing a collection of Employee records. Each employee record will have properties for data, and a property to retain a record number that will be used as a key. A key is like a unique identifier for a record. In this case, a record number can be an integer.

Each Employee object must have a first name, last name, department, salary, and record number. The record number should be unique for every Employee object. The Employee class will have private fields and public properties to get/set the data for first name, last name, salary, department, and record number.

The backend "database" will be simulated in this Windows form application as a generic List. You will create Employee records based on the Employee class, and store them in a collection (i.e. a List of Employee objects), in the code, in your form's code behind file (i.e. Form1.cs).

That collection must be built/accessible in a way so that your Form's code behind has access to the data at all times - it should be structured in such a way so that the data persists as long as the form is open on the screen. One option would be to make a generic Employee List variable at the class level in the Form's code-behind file (i.e. Form1.cs).

The layout of the form will need to include the following:

First Name - label and text box - enabled and allows data entry

Last name - label and text box - enabled and allows data entry

Department - label and text box - enabled and allows data entry

Salary - label and text box - enabled and allows data entry

Record number - record number of the employee - Read only / disabled - users should not be able to modify the employee record number

Previous Record button - will navigate to the previous record in the list and display the content of that employee in the controls above - For example, if I am on record #2 and click previous it will go back to #1. If you have no previous records to show, display a message box (ie MessageBox.Show(...)) indicating no more records are available.

Next record button - will navigate to the next record in the list and display the content of that employee in the controls above. For example, if I am on record #2 and click next it will go to #3. If you have no next records to show, display a message box indicating no more records are available.

Create new record - will add a record to the end of the list only if first name, last name, department, and salary are populated in the controls above. The record number will need to be generated based on whatever the next record number should be in your list. Finally, the assigned record number needs to display in the record number field above. After hitting click, everything about that new employee record should display in the controls above, including the new record number. A record should only create if the first name, last name, department, and salary text boxes are filled in. If any of that data is missing, you should show a message box indicating there is missing data that needs to be populated. Duplicate name/department/salary info is ok, but each employee must have a unique record and a unique record number. For example, you can have 6 "John Smith" records in "Human Resources" with a Salary of "50000" but each one of those John Smith records must have a unique record number.

Update Record - this should update the editable fields (first name, last name, department, and salary) on that specific / current record number that is showing in the controls above. After the update occurs, show a message box indicating the record has been updated. Updates should only occur if the first name, last name, department number, and salary info is populated. If any one of those fields are empty, you should disrupt the update process, and show a message box indicating fields must be populated before the update.

Delete record button - will delete a record from the list if the list is not empty. if the list is empty, display a message box indicating that the list is empty and an employee cannot be deleted. If the delete is successful, show the record either before or after the one that was deleted with the appropriate content/record number. If all employees are deleted, you should show blanks in all of the controls above, including record number.

Search record number label and text box - will allow a user to enter a record number to search on. This text box is enabled and should allow data entry.

Search for Record based on key button: must invoke a LINQ expression to identify an employee based on record number. If one is found, populate the controls above with the employee information including the record number. If not found, show a message box indicating the employee was not found.

Record numbers do not need to remain in sequential order. For example, let's assume you start with 3 employees, with record numbers 1, 2, and 3 respectively. Then, assume you delete record 2, and after that, add a new Employee record. Your new record sequence can be 1, 3, and 4 (2 was removed, and 4 is the new record).

You have the option of populating your Employee list with seed data using code on startup, or you can use the create new record functionality to add an initial set of records.

The search must utilize a LINQ expression to get full credit on this part of the lab assignment.

To help you, code for the Employee class is being provided - feel free to modify as needed. - code will format properly once you copy/paste into visual studio:

public class Employee { private string _firstName; private string _lastName; private string _department; private int _salary; private int _recordNumber; public Employee() { }

public Employee(string firstName, string lastName, string department, int salary, int recordNumber) { _firstName = firstName; _lastName = lastName; _department = department; _salary = salary; _recordNumber = recordNumber; } public string FirstName { get { return _firstName; } set { _firstName = value; } } public string LastName { get { return _lastName; } set { _lastName = value; } } public string Department { get { return _department; } set { _department = value; } } public int Salary { get { return _salary; } set { _salary = value; } } public int RecordNumber { get { return _recordNumber; } set { _recordNumber = value; } } }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions