private void ButtonClockOut_Clicked(object sender, RoutedEventArgs e)
        {
            if (pickerTechnicianStatus.SelectedIndex < 0)
            {
                MessageBoxResult result = System.Windows.MessageBox.Show("Select a technician status.", "Status", MessageBoxButton.OK);
                if (result == MessageBoxResult.OK)
                {
                    return;
                }
            }
            if (pickerTicketStatus.SelectedIndex < 0)
            {
                MessageBoxResult result = System.Windows.MessageBox.Show("Select a ticket status.", "Status", MessageBoxButton.OK);
                if (result == MessageBoxResult.OK)
                {
                    return;
                }
            }
            if (pickerEarningsCode.SelectedIndex < 0)
            {
                MessageBoxResult result = System.Windows.MessageBox.Show("Select an earnings code.", "Status", MessageBoxButton.OK);
                if (result == MessageBoxResult.OK)
                {
                    return;
                }
            }
            if (pickerActivityCode.SelectedIndex < 0)
            {
                //await DisplayAlert("Activity Code", "Select an activity code.", "OK");
                //return;
                MessageBoxResult result = System.Windows.MessageBox.Show("Select an activity code.", "Status", MessageBoxButton.OK);
                if (result == MessageBoxResult.OK)
                {
                    return;
                }
            }

            // Validate Dates
            DateTime dtDepart    = DateTime.Now;
            double   hoursWorked = 0;

            // dch rkl 01/23/2017 captureTimeInTimeTracker == "Y", date and time must be entered
            if (_captureTimeInTimeTracker == "Y")
            {
                DateTime dtArrive;
                if (textStartTime.Text != null)
                {
                    if (DateTime.TryParse(textStartTime.Text, out dtArrive) == false)
                    {
                        MessageBoxResult result = System.Windows.MessageBox.Show("Enter a valid Arrive Date.", "Arrive Date", MessageBoxButton.OK);
                        if (result == MessageBoxResult.OK)
                        {
                            return;
                        }
                    }
                }
                else
                {
                    MessageBoxResult result = System.Windows.MessageBox.Show("Enter a valid Arrive Date.", "Arrive Date", MessageBoxButton.OK);
                    if (result == MessageBoxResult.OK)
                    {
                        return;
                    }
                }

                if (textDepartTime.Text != null)
                {
                    if (DateTime.TryParse(textDepartTime.Text, out dtDepart) == false)
                    {
                        MessageBoxResult result = System.Windows.MessageBox.Show("Enter a valid Depart Date.", "Depart Date", MessageBoxButton.OK);
                        if (result == MessageBoxResult.OK)
                        {
                            return;
                        }
                    }
                }
                else
                {
                    MessageBoxResult result = System.Windows.MessageBox.Show("Enter a valid Depart Date.", "Depart Date", MessageBoxButton.OK);
                    if (result == MessageBoxResult.OK)
                    {
                        return;
                    }
                }

                // dch rkl 02/03/2017 Capture hours worked, for validation
                if (editorHoursWorked != null)
                {
                    double.TryParse(editorHoursWorked.Text, out hoursWorked);
                }
            }
            else
            {
                // dch rkl 01/23/2017 captureTimeInTimeTracker == "N", hours must be entered
                if (editorHoursWorked != null)
                {
                    double.TryParse(editorHoursWorked.Text, out hoursWorked);
                }
                if (hoursWorked == 0)
                {
                    MessageBoxResult result = System.Windows.MessageBox.Show("Enter valid Hours Worked.", "Hours Worked", MessageBoxButton.OK);
                    if (result == MessageBoxResult.OK)
                    {
                        return;
                    }
                }
            }
            if (hoursWorked > 24)
            {
                MessageBoxResult result = System.Windows.MessageBox.Show("Time entry cannot exceed 24 hours.  Please adjust your Depart Date/Time and create separate Clock In/Clock Out for additional hours.", "Hours Worked", MessageBoxButton.OK);
                if (result == MessageBoxResult.OK)
                {
                    return;
                }
            }

            double meterReading = 0;
            double hoursBilled  = 0;

            JT_TechnicianStatus   selectedTechnicianStatus = pickerTechnicianStatus.SelectedItem as JT_TechnicianStatus;
            JT_MiscellaneousCodes selectedTicketStatus     = pickerTicketStatus.SelectedItem as JT_MiscellaneousCodes;
            JT_EarningsCode       selectedEarningsCode     = pickerEarningsCode.SelectedItem as JT_EarningsCode;
            JT_ActivityCode       selectedActivityCode     = pickerActivityCode.SelectedItem as JT_ActivityCode;

            try
            {
                if (_vm.IsRepairItemAnEquipmentAsset)
                {
                    meterReading = double.Parse(editorMeterReading.Text);
                }
                else
                {
                    meterReading = 0;
                }
            }
            catch
            {
                // empty
            }
            try
            {
                hoursBilled = double.Parse(editorHoursBilled.Text);
            }
            catch
            {
                // empty
            }

            // dch rkl 01/23/2017 captureTimeInTimeTracker == "Y", date and time must be entered
            if (_captureTimeInTimeTracker == "Y")
            {
                // dch rkl 02/03/2017 use arrive date
                //_vm.ClockOut(dtDepart.TimeOfDay, selectedTechnicianStatus, selectedTicketStatus, selectedActivityCode,
                //    pickerDepartment.SelectedValue.ToString(), selectedEarningsCode, hoursBilled, meterReading, editorWorkPerformed.Text,
                //    textEndDate.Text, _captureTimeInTimeTracker, hoursWorked, _vm.WorkTicket.ServiceAgreement.ServiceAgreementNumber);
                _vm.ClockOut(dtDepart.TimeOfDay, selectedTechnicianStatus, selectedTicketStatus, selectedActivityCode,
                             pickerDepartment.SelectedValue.ToString(), selectedEarningsCode, hoursBilled, meterReading, editorWorkPerformed.Text,
                             textStartDate.Text, _captureTimeInTimeTracker, hoursWorked, _vm.WorkTicket.ServiceAgreement.ServiceAgreementNumber);
            }
            else
            {
                TimeSpan ts = new TimeSpan();
                _vm.ClockOut(ts, selectedTechnicianStatus, selectedTicketStatus, selectedActivityCode,
                             pickerDepartment.SelectedValue.ToString(), selectedEarningsCode, hoursBilled, meterReading, editorWorkPerformed.Text,
                             "", _captureTimeInTimeTracker, hoursWorked, _vm.WorkTicket.ServiceAgreement.ServiceAgreementNumber);
            }

            ContentControl contentArea = (ContentControl)this.Parent;

            contentArea.Content = new SchedulePage();
        }
        protected async void ButtonClockOut_Clicked(object sender, EventArgs e)
        {
            if (_pickerTechnicianStatus.SelectedIndex < 0)
            {
                await DisplayAlert("Status", "Select a technician status.", "OK");

                return;
            }
            if (_pickerTicketStatus.SelectedIndex < 0)
            {
                await DisplayAlert("Status", "Select a ticket status.", "OK");

                return;
            }
            if (_pickerEarningsCode.SelectedIndex < 0)
            {
                await DisplayAlert("Earnings Code", "Select an earnings code.", "OK");

                return;
            }
            if (_pickerActivityCode.SelectedIndex < 0)
            {
                await DisplayAlert("Activity Code", "Select an activity code.", "OK");

                return;
            }

            DateTime dtDepart    = DateTime.Now;
            double   hoursWorked = 0;

            if (_captureTimeInTimeTracker == "Y")
            {
                DateTime dtArrive;
                if (_pickerStartDate.Date == null)
                {
                    await DisplayAlert("Arrive Date", "Enter a valid arrival date.", "OK");

                    return;
                }

                if (_pickerDepartDate.Date == null)
                {
                    await DisplayAlert("Depart Date", "Enter a valid departure date.", "OK");

                    return;
                }

                // dch rkl 02/03/2017 Capture hours worked, for validation
                if (_editorHoursWorked.Text != null)
                {
                    double.TryParse(_editorHoursWorked.Text, out hoursWorked);
                }
            }
            else
            {
                // dch rkl 01/23/2017 captureTimeInTimeTracker == "N", hours must be entered
                if (_editorHoursWorked.Text != null)
                {
                    double.TryParse(_editorHoursWorked.Text, out hoursWorked);
                }
                if (hoursWorked == 0)
                {
                    await DisplayAlert("Hours Worked", "Enter valid hours worked.", "OK");

                    return;
                }
            }
            if (hoursWorked > 24)
            {
                await DisplayAlert("Hours Worked", "Time entry cannot exceed 24 hours.  Please adjust your Depart Date/Time and create a separate Clock In/Clock Out for additional hours.", "OK");

                return;
            }

            double meterReading = 0;
            double hoursBilled  = 0;

            JT_TechnicianStatus   selectedTechnicianStatus = _pickerTechnicianStatus.SelectedItem as JT_TechnicianStatus;
            JT_MiscellaneousCodes selectedTicketStatus     = _pickerTicketStatus.SelectedItem as JT_MiscellaneousCodes;
            JT_EarningsCode       selectedEarningsCode     = _pickerEarningsCode.SelectedItem as JT_EarningsCode;
            JT_ActivityCode       selectedActivityCode     = _pickerActivityCode.SelectedItem as JT_ActivityCode;

            try
            {
                if (_vm.IsRepairItemAnEquipmentAsset)
                {
                    meterReading = double.Parse(_editorMeterReading.Text);
                }
                else
                {
                    meterReading = 0;
                }
            }
            catch
            {
                // empty
            }
            try
            {
                hoursBilled = double.Parse(_editorHoursBilled.Text);
            }
            catch
            {
                // empty
            }
            JT_MiscellaneousCodes deptCode = (JT_MiscellaneousCodes)_pickerDepartment.SelectedItem;

            ClockOutPageViewModel.App_Billable appBillable = (ClockOutPageViewModel.App_Billable)_pickerBillable.SelectedItem;

            if (_captureTimeInTimeTracker == "Y")
            {
                //_vm.ClockOut(_pickerDepartTime.Time, selectedTechnicianStatus, selectedTicketStatus, selectedActivityCode, string.Empty,
                //             selectedEarningsCode, hoursBilled, meterReading, _editorWorkPerformed.Text, _pickerDepartDate.Date.ToShortDateString());
                _vm.ClockOut(_pickerDepartTime.Time, selectedTechnicianStatus, selectedTicketStatus, selectedActivityCode, deptCode.MiscellaneousCode,
                             selectedEarningsCode, hoursBilled, meterReading, _editorWorkPerformed.Text, _pickerDepartDate.Date.ToShortDateString(), _captureTimeInTimeTracker,
                             hoursWorked, _vm.WorkTicket.ServiceAgreement.ServiceAgreementNumber, appBillable.BillableFlag);
            }
            else
            {
                _vm.ClockOut(new TimeSpan(), selectedTechnicianStatus, selectedTicketStatus, selectedActivityCode, deptCode.MiscellaneousCode,
                             selectedEarningsCode, hoursBilled, meterReading, _editorWorkPerformed.Text, "", _captureTimeInTimeTracker, hoursWorked,
                             _vm.WorkTicket.ServiceAgreement.ServiceAgreementNumber, appBillable.BillableFlag);
            }
            await Navigation.PopToRootAsync();
        }