private async void Register() { if (string.IsNullOrEmpty(this.Password)) { await Application.Current.MainPage.DisplayAlert( Languages.ExceptionLiteral1, Languages.RegisterLiteral1, Languages.ExceptionLiteral3); return; } //this.IsRunning = true; this.IsEnabled = false; try { var registerData = new T_Appuser { Name = "ApplicationUser", Password = Base64Encode(Password) }; var resultDB = db.Insert(registerData); if (resultDB == 1) { //this.IsRunning = false; Password = string.Empty; this.IsEnabled = true; MainViewModel.GetInstance().Register = new RegisterViewModel(); await Application.Current.MainPage.Navigation.PushAsync(new LoginPage()); } else { await Application.Current.MainPage.DisplayAlert( Languages.ExceptionLiteral1, Languages.RegisterLiteral2, Languages.ExceptionLiteral3); return; } } catch (SQLiteException sqlex) { await Application.Current.MainPage.DisplayAlert( Languages.ExceptionLiteral1, Languages.ExceptionLiteral2, Languages.ExceptionLiteral3); return; } }
private async void Change() { if (string.IsNullOrEmpty(this.Password)) { await Application.Current.MainPage.DisplayAlert( Languages.ExceptionLiteral1, Languages.SecurityLiteral1, Languages.ExceptionLiteral3); return; } this.IsEnabled = false; try { var changeData = new T_Appuser { Id = t_Appuser.Id, Name = "ApplicationUser", Password = Base64Encode(Password) }; var resultDB = db.Update(changeData); if (resultDB == 1) { Password = string.Empty; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert( Languages.AppLiteral1, Languages.SecurityLiteral2, Languages.ExceptionLiteral3); } else { await Application.Current.MainPage.DisplayAlert( Languages.ExceptionLiteral1, Languages.SecurityLiteral3, Languages.ExceptionLiteral3); return; } } catch (SQLiteException sqlex) { await Application.Current.MainPage.DisplayAlert( Languages.ExceptionLiteral1, Languages.ExceptionLiteral2, Languages.ExceptionLiteral3); return; } }
private async void Login() { if (string.IsNullOrEmpty(this.Password)) { await Application.Current.MainPage.DisplayAlert(Languages.ExceptionLiteral1, Languages.LoginLiteral2, Languages.ExceptionLiteral3); return; } //this.IsRunning = true; this.IsEnabled = false; try { IEnumerable <T_Appuser> getAppUser = GetAppUser(db, "ApplicationUser"); T_Appuser t_Appuser = getAppUser.ToList <T_Appuser>()[0]; _password = Base64Decode(t_Appuser.Password); } catch (SQLiteException sqlex) { await Application.Current.MainPage.DisplayAlert(Languages.ExceptionLiteral1, Languages.ExceptionLiteral2, Languages.ExceptionLiteral3); return; } if (string.CompareOrdinal(this.Password, this._password) != 0) { //this.IsRunning = false; this.IsEnabled = true; await Application.Current.MainPage.DisplayAlert(Languages.ExceptionLiteral1, Languages.LoginLiteral3, Languages.ExceptionLiteral3); this.Password = string.Empty; return; } this.IsEnabled = true; this.Password = string.Empty; MainViewModel.GetInstance().HomePageDetail = new HomePageDetailViewModel(); await Application.Current.MainPage.Navigation.PushAsync(new HomePage()); }