private void listEmployee_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         selectedEmployee            = (HourlyEmployee)roster.Find((string)listEmployee.SelectedItem);
         textBoxSsn.Text             = selectedEmployee.SSN;
         textBoxSsn.Enabled          = false;
         textBoxLastName.Text        = selectedEmployee.LastName;
         textBoxFirstname.Text       = selectedEmployee.FirstName;
         textBoxMi.Text              = selectedEmployee.MiddleInitial.ToString();
         dateHiredTimePicker.Value   = selectedEmployee.DateHired;
         dateHiredTimePicker.Enabled = true;
         textBoxEarnings.Text        = selectedEmployee.Earnings().ToString("C");
         textBoxEarnings.Enabled     = false;
         textBoxRate.Text            = selectedEmployee.PayRate.ToString();
         textBoxHoursWorked.Text     = selectedEmployee.CurrentHoursWorked.ToString();
     }
     catch (Exception)
     {
         MessageBox.Show(this, "Choose an employee SSN ");
         return;
     }
 }
        private void buttonUpdate_Click(object sender, EventArgs e)
        {
            char mi = ' ';

            if (textBoxMi.Text.Length == 1)
            {
                mi = textBoxMi.Text.ToCharArray()[0];
            }
            string   ssn   = textBoxSsn.Text;
            string   first = textBoxFirstname.Text;
            string   last  = textBoxLastName.Text;
            DateTime dt;

            try
            {
                dt = dateHiredTimePicker.Value;
            }
            catch (Exception)
            {
                MessageBox.Show(this, "Invalid date hired");
                return;
            }
            decimal rate;

            try
            {
                rate = Convert.ToDecimal(textBoxRate.Text);
            }
            catch (Exception)
            {
                MessageBox.Show(this, "Invalid rate");
                return;
            }
            int hours;

            try
            {
                hours = Convert.ToInt32(textBoxHoursWorked.Text);
            }
            catch (Exception)
            {
                MessageBox.Show(this, "Invalid hours worked");
                return;
            }
            try
            {
                selectedEmployee.SSN                = ssn;
                selectedEmployee.FirstName          = first;
                selectedEmployee.LastName           = last;
                selectedEmployee.MiddleInitial      = mi;
                selectedEmployee.DateHired          = dt;
                selectedEmployee.PayRate            = rate;
                selectedEmployee.CurrentHoursWorked = hours;
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message);
                return;
            }
            if (textBoxSsn.Enabled)
            {
                Employee emp = roster.Find(selectedEmployee.SSN);
                if (emp == null)
                {
                    roster.Add(selectedEmployee);
                    LoadEmployeeList();
                    textBoxSsn.Enabled = false;
                }
                else
                {
                    MessageBox.Show(this, "SSN already on file");
                    return;
                }
            }
            textBoxEarnings.Text = selectedEmployee.Earnings().ToString("C");
        }