Ejemplo n.º 1
0
        private void AppSettingsPage_SettingsSaved(object sender, EventArgs e)
        {
            Database.CreateGlobalTables();

            TechnicianListPageViewModel viewModel = new TechnicianListPageViewModel();

            viewModel.PropertyChanged += TechnicianListPageViewModel_PropertyChanged;

            MainPage = new TechnicianListPage(viewModel);
        }
Ejemplo n.º 2
0
        public void LogOff()
        {
            if (CurrentTechnician != null)
            {
                // puke... log off current tech
            }

            TechnicianListPageViewModel vm = new TechnicianListPageViewModel();

            MainPage = new TechnicianListPage(vm);
        }
Ejemplo n.º 3
0
        public void TechnicianListPageViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            TechnicianListPageViewModel vm = sender as TechnicianListPageViewModel;

            switch (e.PropertyName)
            {
            case "IsLoading":
                IHud hud = DependencyService.Get <IHud>();
                if (vm.IsLoading)
                {
                    //XHUD.HUD.Show("Loading data...", -1, XHUD.MaskType.Black);

                    hud.Show("Loading data...");
                }
                else
                {
                    hud.Dismiss();
                }
                break;

            case "IsSignedIn":
                if (vm.IsSignedIn)
                {
                    Device.BeginInvokeOnMainThread(() =>
                                                   MainPage = new MainDashboard());
                    //MainPage = new MainDashboard(this);
                }
                else
                {
                    if (!(MainPage is TechnicianListPage))
                    {
                        MainPage = new TechnicianListPage(vm);
                    }
                }
                break;

            default:
                break;
            }
        }
Ejemplo n.º 4
0
        protected async override void OnStart()
        {
            // Handle when your app starts
            bool          hasValidSetup = false;
            App_Settings  appSettings   = App.Database.GetApplicationSettings();
            string        loggiedintechnicianno;
            JT_Technician technician  = null;
            bool          tableExists = false;

            try
            {
                hasValidSetup = await Database.HasValidSetup(appSettings);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine(ex.Message);
                await MainPage.DisplayAlert("Error!", ex.Message, "OK");

                throw;
            }

            tableExists = App.Database.TableExists <JT_Technician>();

            // Are the settings valid?
            if (hasValidSetup)
            {
                // Yes, so move on to the technician login
                //App_Settings appSettings = App.Database.GetApplicatioinSettings();
                loggiedintechnicianno = (appSettings.LoggedInTechnicianNo != null) ? appSettings.LoggedInTechnicianNo : "";

                if (tableExists && loggiedintechnicianno.Length > 0) // we've already established we do && Database.HasDataConnection())
                {
                    technician = App.Database.GetTechnician(appSettings.LoggedInTechnicianDeptNo, appSettings.LoggedInTechnicianNo);
                    if (technician != null)
                    {
                        App.Database.SaveTechnicianAsCurrent(technician);
                        App.Database.CreateDependentTables(technician);

                        MainPage = new MainDashboard();
                    }
                    else
                    {
                        if (Database.HasDataConnection())
                        {
                            Database.CreateGlobalTables();
                        }

                        Thread.Sleep(5000);
                        TechnicianListPageViewModel viewModel = new TechnicianListPageViewModel();
                        viewModel.PropertyChanged += TechnicianListPageViewModel_PropertyChanged;

                        MainPage = new TechnicianListPage(viewModel);
                    }
                }
                else
                {
                    if (Database.HasDataConnection())
                    {
                        Database.CreateGlobalTables();
                    }

                    Thread.Sleep(5000);
                    TechnicianListPageViewModel viewModel = new TechnicianListPageViewModel();
                    viewModel.PropertyChanged += TechnicianListPageViewModel_PropertyChanged;

                    MainPage = new TechnicianListPage(viewModel);
                }
            }
            else
            {
                // Invalid settings, so show the settings page.
                //  Otherwise, data calls will never work.
                AppSettingsPage settingsPage = new AppSettingsPage();
                settingsPage.SettingsSaved += AppSettingsPage_SettingsSaved;

                MainPage = settingsPage;

                return;
            }
        }