Exemplo n.º 1
0
        public LoginPage()
        {
            InitializeComponent();

            btnLogin.Clicked   += OnLoginClicked;
            btnSetting.Clicked += (sender, e) =>
            {
                Navigation.PushAsync(new ElsaSettingPage());
            };
            onLoading(false);

            NavigationPage.SetHasNavigationBar(this, false);

            if (LocalPreferences.IsPropertyExists("database"))
            {
                SettingVariable.Database = LocalPreferences.LoadApplicationProperty <string>("database");
            }

            if (LocalPreferences.IsPropertyExists("instance"))
            {
                SettingVariable.Instance = LocalPreferences.LoadApplicationProperty <string>("instance");
            }

            Debug.WriteLine("database instance" + SettingVariable.Database + " " + SettingVariable.Instance);
        }
Exemplo n.º 2
0
 bool isLoggedIn()
 {
     if (LocalPreferences.IsPropertyExists("isLoggedIn"))
     {
         return(LocalPreferences.LoadApplicationProperty <bool>("isLoggedIn"));
     }
     return(false);
 }
Exemplo n.º 3
0
        private async void onLogout()
        {
            var answer = await DisplayAlert("Exit", "Do you want to exit ALTiUS Dashboard?", "Yes", "No");

            if (answer)
            {
                await LocalPreferences.SaveApplicationProperty <bool>("isLoggedIn", false);

                NavigationPage page = new NavigationPage(new LoginPage());
                Xamarin.Forms.Application.Current.MainPage = page;
            }

            IsPresented = false;
        }
Exemplo n.º 4
0
        async void onSaveClicked(object sender, EventArgs e)
        {
            string database = entryDatabase.Text;
            string instance = entryInstance.Text;

            await LocalPreferences.SaveApplicationProperty <string>(KEY_DB, database);

            await LocalPreferences.SaveApplicationProperty <string>(KEY_INS, instance);

            SettingVariable.Database = database;
            SettingVariable.Instance = instance;

            await DisplayAlert("Info", "Successfully saved", "OK");
        }
Exemplo n.º 5
0
        protected override async void OnAppearing()
        {
            if (isLoggedIn())
            {
                string usr = LocalPreferences.LoadApplicationProperty <string>("username");
                string pwd = LocalPreferences.LoadApplicationProperty <string>("password");

                entryUsername.Text = usr;
                entryPassword.Text = pwd;
                onLoading(true);
                bool valid = await Task.Run(() => validUser(usr, pwd));

                if (!valid)
                {
                    await DisplayAlert("Login failed", "Please check your username or password", "OK");

                    onLoading(false);
                    return;
                }
                loggingIn(usr, pwd);
            }
        }
Exemplo n.º 6
0
        void loadSavedSettings()
        {
            string database = "";

            if (LocalPreferences.IsPropertyExists(KEY_DB))
            {
                database = LocalPreferences.LoadApplicationProperty <string>(KEY_DB);
            }

            string instance = "";

            if (LocalPreferences.IsPropertyExists(KEY_INS))
            {
                instance = LocalPreferences.LoadApplicationProperty <string>(KEY_INS);
            }

            entryDatabase.Text = database;
            entryInstance.Text = instance;

            SettingVariable.Database = database;
            SettingVariable.Instance = instance;
        }
Exemplo n.º 7
0
        async Task <bool> validUser(string username, string password)
        {
            SettingVariable.Username = username;
            SettingVariable.Password = password;
            DependencyService.Get <IDbDataFetcher>().reloadConnectionString();

            string query = "select kode,nama,email,password from staff where email = '" + username + "'";

            Debug.WriteLine(query);
            var list = DependencyService.Get <IDbDataFetcher>().getUser(query);

            if (list != null && list.Count > 0)
            {
                await LocalPreferences.SaveApplicationProperty <bool>("isLoggedIn", true);

                await LocalPreferences.SaveApplicationProperty <string>("username", username);

                await LocalPreferences.SaveApplicationProperty <string>("password", password);

                return(true);
            }

            return(false);
        }