private void saveButton_Click(object sender, System.EventArgs e) { Boolean AddToCollection = false; if (Employee == null) { Employee = new HourlyEmployee( ); AddToCollection = true; } Employee.FirstName = firstBox.Text; Employee.LastName = lastBox.Text; Employee.Address = adBox.Text; Employee.PostCode = postBox.Text; Employee.PhoneNumber = mobBox.Text; Employee.DateOfBirth = dobPicker.Value; Employee.HourlyPay = decimal.Parse(hourlyBox.Text); Employee.OvertimePay = decimal.Parse(overtimeBox.Text); if (AddToCollection && Employees != null) { Employees.Add(Employee); } Close( ); }
private void HEmplyeeFromString(string data) { var DataArray = data.Split('|'); HourlyEmployee _HourlyEmployee = new HourlyEmployee( ); _HourlyEmployee.Address = DataArray[3]; _HourlyEmployee.DateOfBirth = new DateTime(Int32.Parse(DataArray[6]), Int32.Parse(DataArray[7]), Int32.Parse(DataArray[8])); _HourlyEmployee.FirstName = DataArray[2]; _HourlyEmployee.HourlyPay = decimal.Parse(DataArray[9]); _HourlyEmployee.LastName = DataArray[1]; _HourlyEmployee.OvertimePay = decimal.Parse(DataArray[10]); _HourlyEmployee.PhoneNumber = DataArray[5]; _HourlyEmployee.PostCode = DataArray[4]; this.Add(_HourlyEmployee); }