public MiscellaneousTimePage()
        {
            InitializeComponent();
            _vm = new MiscellaneousTimePageViewModel();

            earningCodePicker.ItemsSource = _vm.EarningsCode;

            if (App.Database.GetApplicationSettings().TwentyFourHourTime)
            {
                startTimeText.Text = DateTime.Now.ToString("HH:mm");
            }
            else
            {
                startTimeText.Text = DateTime.Now.ToString("hh:mm tt");
            }

            textTransactionDate.Text = DateTime.Now.ToShortDateString();

            labelTechNo.Content = String.Format("{0}-{1}", _vm.AppTechnician.TechnicianDeptNo, _vm.AppTechnician.TechnicianNo);

            labelTechName.Content = _vm.AppTechnician.FirstName + " " + _vm.AppTechnician.LastName;

            // dch rkl 11/03/2016 Get Time Tracker Options to Determine what can be entered
            _captureTimeInTimeTracker = "N";
            JT_TimeTrackerOptions timeTrackerOptions = App.Database.GetTimeTrackerOptions();

            if (timeTrackerOptions != null && timeTrackerOptions.CaptureTimeInTimeTracker != null)
            {
                _captureTimeInTimeTracker = timeTrackerOptions.CaptureTimeInTimeTracker;
                if (_captureTimeInTimeTracker == "O")
                {
                    _captureTimeInTimeTracker = "Y";
                }                                                                           // treat "O" as "Y", per Chris M.
            }
            // if CaptureTimeInTimeTracker = "Y", they enter start/end time
            // if CaptureTimeInTimeTracker = "N", they enter hours
            if (_captureTimeInTimeTracker == "Y")
            {
                startTimeText.IsEnabled    = true;
                startTimeText.Text         = "";    // dch rkl 01/12/2017 set to blank by default
                endTimeText.IsEnabled      = true;
                durationTextCell.IsEnabled = false;
            }
            else
            {
                startTimeText.IsEnabled    = false;
                startTimeText.Text         = "";
                endTimeText.IsEnabled      = false;
                endTimeText.Text           = "";
                durationTextCell.IsEnabled = true;
            }
        }
        public MiscellaneousTimePage()
        {
            Title = "Miscellaneous Time";
            Color asbestos = Color.FromHex("#7F8C8D");

            BackgroundColor = Color.White;
            _vm             = new MiscellaneousTimePageViewModel();

            //  Create a label for the technician list
            _labelTitle            = new Xamarin.Forms.Label();
            _labelTitle.Text       = "MISCELLANEOUS TIME";
            _labelTitle.FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null);
            _labelTitle.FontSize   = 22;
            _labelTitle.TextColor  = Color.White;
            _labelTitle.HorizontalTextAlignment = TextAlignment.Center;
            _labelTitle.VerticalTextAlignment   = TextAlignment.Center;

            Grid titleLayout = new Grid()
            {
                BackgroundColor   = Color.FromHex("#2980b9"),
                HorizontalOptions = LayoutOptions.FillAndExpand,
                HeightRequest     = 80
            };

            titleLayout.RowDefinitions.Add(new RowDefinition {
                Height = new GridLength(1, GridUnitType.Star)
            });
            titleLayout.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            titleLayout.Children.Add(_labelTitle, 0, 0);

            Label durationTextCell = new Label {
                FontFamily        = Device.OnPlatform("OpenSans-Regular", "sans-serif", null),
                TextColor         = asbestos,
                HorizontalOptions = LayoutOptions.FillAndExpand
            };

            foreach (var item in _vm.EarningsCode)
            {
                earningCodeToDesc.Add(item.EarningsCode + " - " + item.EarningsDeductionDesc, item.EarningsCode);
                earningCodePicker.Items.Add(item.EarningsCode + " - " + item.EarningsDeductionDesc);
            }

            Button buttonAccept = new Button()
            {
                Text              = "ACCEPT",
                FontFamily        = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null),
                TextColor         = Color.White,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                BackgroundColor   = Color.FromHex("#2ECC71"),
            };

            buttonAccept.Clicked += ButtonAccept_Clicked;
            Button buttonCancel = new Button()
            {
                Text              = "CANCEL",
                FontFamily        = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null),
                TextColor         = Color.White,
                HorizontalOptions = LayoutOptions.FillAndExpand,
                BackgroundColor   = Color.FromHex("#E74C3C")
            };

            buttonCancel.Clicked += ButtonCancel_Clicked;

            startTimePicker.PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName == TimePicker.TimeProperty.PropertyName)
                {
                    // Calculate Hours
                    durationTextCell.Text = CalcHours();
                }
            };

            endTimePicker.PropertyChanged += (sender, e) =>
            {
                if (e.PropertyName == TimePicker.TimeProperty.PropertyName)
                {
                    // Calculate Hours
                    durationTextCell.Text = CalcHours();
                }
            };

            ListView timeEntries = new ListView()
            {
                ItemsSource         = _vm.TimeEntries,
                SeparatorVisibility = SeparatorVisibility.None,
                ItemTemplate        = new DataTemplate(typeof(TimeEntryCell)),
                Header = new Xamarin.Forms.Label
                {
                    Text              = "Date - Start Time - End Time",
                    FontFamily        = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null),
                    TextColor         = Color.FromHex("#FFFFFF"),
                    HorizontalOptions = LayoutOptions.CenterAndExpand,
                    VerticalOptions   = LayoutOptions.Center,
                    BackgroundColor   = peterriver
                }
            };

            Grid topGrid = new Grid();

            topGrid.RowDefinitions.Add(new RowDefinition {
                Height = 20
            });
            topGrid.RowDefinitions.Add(new RowDefinition {
                Height = 20
            });
            topGrid.RowDefinitions.Add(new RowDefinition {
                Height = 20
            });
            topGrid.RowDefinitions.Add(new RowDefinition {
                Height = 20
            });
            topGrid.RowDefinitions.Add(new RowDefinition {
                Height = 20
            });
            topGrid.RowDefinitions.Add(new RowDefinition {
                Height = 20
            });
            topGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = 300
            });
            topGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = 150
            });
            topGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = 250
            });

            topGrid.Children.Add(new Label
            {
                Text              = "EMPLOYEE NO",
                FontFamily        = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null),
                TextColor         = asbestos,
                HorizontalOptions = LayoutOptions.FillAndExpand
            }, 0, 0);
            topGrid.Children.Add(new Label
            {
                Text              = _vm.AppTechnician.TechnicianNo,
                FontFamily        = Device.OnPlatform("OpenSans-Regular", "sans-serif", null),
                TextColor         = asbestos,
                HorizontalOptions = LayoutOptions.FillAndExpand
            }, 1, 0);
            topGrid.Children.Add(new Label
            {
                Text              = _vm.AppTechnician.FirstName + " " + _vm.AppTechnician.LastName,
                FontFamily        = Device.OnPlatform("OpenSans-Regular", "sans-serif", null),
                TextColor         = asbestos,
                HorizontalOptions = LayoutOptions.FillAndExpand
            }, 2, 0);

            topGrid.Children.Add(new Label
            {
                Text              = "TRANSACTION DATE",
                FontFamily        = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null),
                TextColor         = asbestos,
                HorizontalOptions = LayoutOptions.FillAndExpand
            }, 0, 1);
            topGrid.Children.Add(transactionDatePicker, 1, 1);

            topGrid.Children.Add(new Label
            {
                Text              = "START TIME",
                FontFamily        = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null),
                TextColor         = asbestos,
                HorizontalOptions = LayoutOptions.FillAndExpand
            }, 0, 2);
            topGrid.Children.Add(startTimePicker, 1, 2);

            topGrid.Children.Add(new Label
            {
                Text              = "END TIME",
                FontFamily        = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null),
                TextColor         = asbestos,
                HorizontalOptions = LayoutOptions.FillAndExpand
            }, 0, 3);
            topGrid.Children.Add(endTimePicker, 1, 3);

            topGrid.Children.Add(new Label
            {
                Text              = "HOURS WORKED",
                FontFamily        = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null),
                TextColor         = asbestos,
                HorizontalOptions = LayoutOptions.FillAndExpand
            }, 0, 4);
            topGrid.Children.Add(durationTextCell, 1, 4);

            topGrid.Children.Add(new Label
            {
                Text              = "EARNINGS CODE",
                FontFamily        = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null),
                TextColor         = asbestos,
                HorizontalOptions = LayoutOptions.FillAndExpand
            }, 0, 5);
            topGrid.Children.Add(earningCodePicker, 1, 5);
            Grid.SetColumnSpan(earningCodePicker, 2);

            Content = new StackLayout()
            {
                Padding  = 30,
                Children =
                {
                    titleLayout,
                    topGrid,
                    new StackLayout {
                        Orientation       = StackOrientation.Horizontal,
                        HorizontalOptions = LayoutOptions.FillAndExpand,
                        Children          =
                        {
                            buttonAccept,
                            buttonCancel
                        }
                    },
                    timeEntries
                }
            };
        }