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()
Me.EmployeeBindingSource.DataSource = mEmployee Me.EmployeeTypeListBindingSource.DataSource = Payroll.Library.EmployeeTypeList.GetList Me.EmployeeListBindingSource.DataSource = Payroll.Library.EmployeeList.GetEmployeeList Me.TabPage1.Select() With ComboBox1.DataSource = Payroll.Library.EmployeeTypeList.GetList
.DisplayMember =
"Name".ValueMember =
"Value".DataBindings.Add(
"SelectedValue", mEmployee, "Type").DataBindings(0).DataSourceUpdateMode = DataSourceUpdateMode.OnPropertyChanged
End With With Me.TextBox1.DataBindings.Add(
"Text", mEmployee.EmployeeType, "StartDate") End WithEmployee Object
Private
Sub SetEmployeeType(ByVal ID As Integer)OldEmployeeType = mEmployeeType
mOldEmployeeType.Delete()
mEmployeeType = EmployeeTypeFactory.NewEmployeeType(ID)
End SubPublic
Property Type() As String Get Return mTypeList.Value(mType) End Get Set(ByVal value As String) If mType <> mTypeList.Key(value) ThenmType = mTypeList.Key(value)
SetEmployeeType(mType)
PropertyHasChanged()
End If End Set End PropertyCopyright (c) Marimer LLC