From Rockford Lhotka's Expert C# 2008 and VB 2008 Business Objects books
I am developing an Human Resources and payroll system.I have created an employee object which can be of four types contract employee,Permanent employee,temporal employee and expariate.I want to be able to change an employee from one type to another type of employee.I have created a polymorphic child object called EmployeeType which can be of any of the types mentioned above.on the employees form i have put a combobox which is bound to the employeetype namevalue list.When I select any options in the combobox a new type of child if the employee type is differennt from the current employee type is created.However the the bound text boxes are not updated to reflect the initial values of the newly created child object of the employee.For example both the temporal employee and contract employee types have the startdate and enddate properties to reflect the start and expiry of the contracts/temporal assignement.When I change a temporal employee to contract employee the startdate and enddate continue to reflect the same startdate and enddate properties of the temporal employee and if save the objects to the database only the employeeid is inserted into the database,startdate and enddate are null.my code snippets are show below .Can someone help me
InitializeComponent()
mEmployee = Employee
mEmployee.BeginEdit()
.DataSource = Payroll.Library.EmployeeTypeList.GetList
.DisplayMember =
.ValueMember =
.DataBindings.Add(
.DataBindings(0).DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged
Employee Object
Private
OldEmployeeType = mEmployeeType
mOldEmployeeType.Delete()
mEmployeeType = EmployeeTypeFactory.NewEmployeeType(ID)
Public
mType = mTypeList.Key(value)
SetEmployeeType(mType)
PropertyHasChanged()