Notes for week 6

The Employee Project as a Windows Program.

During week 3 you were introduced to inheritence and scenarios. This week you will see how the employee program you worked on then can be implemented as a Windows program. You learned last week that the first thing to do when creating a windows program after determining what the program will do, design the menus . In this program you will add new employees, enter hours for hourly employee, edit employee information, delete employees and print the employee payroll in a window. You will of course want to open and save the file of employees. You may also want to create a new file. One organization of the menu bar that suggests itself is a File Menu, an Edit Menu (Employees - add, delete and edit info) and a Payroll Menu (enter hours and display payroll)

Scenarios in a Windows Program

After determining the menu commands, it is time to create a scenario for each command. The delete command is relatively straight forward and is left as an exercise (should use a MessageBox to determine if the user actually wants to delete the item in question. The process for the adding employee is very similar to that in week 3, but now you have to create an interface. You must gather information about the new employee. Create a new dialog box, EmployeeInfoDlg (as seen below)

You will know that this dialog is needed even before you create the scenario for the add employee and edit employee commands since the user must either provide or edit the information about an employee. Notice that you have two types of employee, so you need a way to distinguish which type you have. Whenever you need to make a choice of one from a few you may indicate the choices using radio buttons. If the number is large, the use a combo box which we will see later. The scenario for the add command is almost identical to that for the edit command. The main difference is that in the add command the boxes all have empty strings whereas in the edit command, you must retrieve the current data from the item being edited. This means your employee class must be agumented with functions that return the first name, last name and number of hours as a string. You also need to know the type of the object, so you must have a function that returns a number indicating the type.

New String Type

You will notice that when you look at the actual code for this program, the type string has been replaced by the type String. This is an ANSI String used by Borland in their VCL classes (Windows forms). For a brief description of this class click here .

Payroll Part

Once you have completed your scenario, you can implement the editor for your payroll. There are many ways to implement the payroll part of the program. You could scroll through the list of employess and when you find an hourly employee ask for the hours worked. After all employees have had their hours inserted, send the payroll to a separate window. To get more experience with windows, you will edit the hours of a selected employee and send the payroll to a window using separate commands.