private void UpdatePaysheet(BabysitterTimeCard timeCard, BabysitterPaySheet paySheet) { HoursBeforeBedtime_TextBox.Text = timeCard.CalculateHoursBeforeBedtime().ToString(); HoursBedTimeToMidnight_TextBox.Text = timeCard.CalculateHoursBetweenBedtimeAndMidnight().ToString(); HoursAfterMidnight_TextBox.Text = timeCard.CalculateHoursAfterMidnight().ToString(); Pay_TextBox.Text = paySheet.Pay.ToString(); }
private void TimeCardSubmit_Button_Click(object sender, EventArgs e) { TwentyFourHourTime startTime; TwentyFourHourTime endTime; TwentyFourHourTime bedTime; BabysitterTimeCard timeCard; BabysitterPaySheet paySheet; startTime = InitializeTime((TIME_OF_DAY)StartTime_AMPM_ComboBox.SelectedItem, StartTimeHour_NumericUpDown.Value, StartTimeMinute_NumericUpDown.Value); endTime = InitializeTime((TIME_OF_DAY)EndTime_AMPM_ComboBox.SelectedItem, EndTimeHour_NumericUpDown.Value, EndTimeMinute_NumericUpDown.Value); bedTime = InitializeTime((TIME_OF_DAY)BedTime_AMPM_ComboBox.SelectedItem, BedTimeHour_NumericUpDown.Value, BedTimeMinute_NumericUpDown.Value); try { timeCard = new BabysitterTimeCard(startTime, endTime, bedTime); if (timeCard.CalculateHoursAfterMidnight() != 0) { paySheet = new BabysitterPaySheet(timeCard.CalculateHoursBeforeBedtime(), timeCard.CalculateHoursBetweenBedtimeAndMidnight(), timeCard.CalculateHoursAfterMidnight()); } else { paySheet = new BabysitterPaySheet(timeCard.CalculateHoursBeforeBedtime(), timeCard.CalculateHoursBetweenBedtimeAndMidnight()); } UpdatePaysheet(timeCard, paySheet); } catch (ArgumentException ex) { MessageBox.Show(ex.Message.ToString(), "Time Sheet Error"); } }