public ProfilePageViewModel() { UserDatabaseController controller = new UserDatabaseController(); var user = controller.GetUser(); if (user != null) { imageData = user.Image; name = user.Name; } AddPictureCommand = new Command(AddPictureCommand_Execute); SaveCommand = new Command(this.SaveCommand_Execute); }
public App() { InitializeComponent(); userDatabase = new UserDatabaseController(DependencyService.Get <ISQLHelper>().getLocalFilePath("LifeBudgetDB.db3")); // always get instance of the database at the opening of the app //DeleteUsers(); // this is for development purposes // Determine if there is already a user in the data base if (userDatabase.CountUsers() == 0) { MainPage = new newUser(); } else { MainPage = new MasterDetail("Nick"); // change this back to loginPage() } }
public DatabaseViewer() { //SQL local database connection _UserDB = new User(); _UserQuery = new UserDatabaseController(); var createBtn = new Button { Text = "Create note" }; lstView = new ListView { }; lstView.ItemTemplate = new DataTemplate(typeof(DisplayCell)); lstView.ItemSelected += async(sender, e) => { if (e.SelectedItem == null) { return; // ensures we ignore this handler when the selection is just being cleared } var detail_Item = (User)e.SelectedItem; var detailPage = new EditPage(); detailPage.BindingContext = detail_Item; await Navigation.PushAsync(detailPage); ((ListView)sender).SelectedItem = null; // clears the 'selected' background //InitializeComponent(); // BindingContext = new DatabaseViewerViewModel(); }; var mainlayout = new StackLayout { }; mainlayout.Children.Add(createBtn); mainlayout.Children.Add(lstView); Content = mainlayout; }
void Init() { //header styling Header.BackgroundColor = Constants.KleynGroupBG; Logo.HeightRequest = 40; Return.HorizontalOptions = LayoutOptions.EndAndExpand; UserDatabaseController UserData = new UserDatabaseController(); var Userinfo = UserData.GetAllUsers(); if (Userinfo[0].picturePermisson == 1) { //Upload Button Style UploadButton.BackgroundColor = Constants.KleynGroupTXT; UploadButton.TextColor = Constants.LoginEntryBgColor; } else { //Upload Button Style UploadButton.BackgroundColor = Constants.KleynGroupTXT; UploadButton.TextColor = Constants.LoginEntryBgColor; UploadButton.IsVisible = false; } //footer styling Footer.BackgroundColor = Constants.KleynGroupBG; Lbl_CR.TextColor = Constants.MainTextColor; Lbl_CR.HorizontalOptions = LayoutOptions.Center; Lbl_CR.VerticalOptions = LayoutOptions.EndAndExpand; Lbl_CR.VerticalTextAlignment = TextAlignment.Center; Lbl_CR.HeightRequest = 80; //Activty Spinner Spinner.Color = Constants.KleynGroupTXT; }
async void LoginRequest(object sender, EventArgs e) { if (CheckNetwork.IsInternet()) { var user = new User { Username = EntryUsername.Text, Password = EntryPassword.Text }; if (user.Username == "" || user.Password == "") { LblLogingin.TextColor = Color.Red; LblLogingin.Text = "Please fill in the fields before logging in!"; } else { LblLogingin.TextColor = Color.GreenYellow; LblLogingin.Text = "Logging in! please wait....."; var result = await App.RestserviceLogin.Login(user); Console.WriteLine("Add result"); var dbclear = new UserDatabaseController(); dbclear.UserDatabase(); Console.WriteLine("DbCLEAR AREA"); dbclear.Droptable(); Console.WriteLine("Passed Droptable"); if (result.remember_token != null) { Console.WriteLine("Token is not null"); if (result.IsFrozen == 0) { Console.WriteLine("Not Frozen"); var userDatabase = new UserDatabaseController(); userDatabase.AddUser(result); var DashBoard = new NavigationPage(new Dashboard()); NavigationPage.SetHasNavigationBar(DashBoard, false); await Navigation.PushAsync(DashBoard); LblLogingin.Text = ""; EntryPassword.Text = ""; } else { LblLogingin.TextColor = Color.Red; LblLogingin.Text = "Your account has been deactivated. Please contact a administrator"; } } else { LblLogingin.TextColor = Color.Red; LblLogingin.Text = "Invalid login information... please try again!"; } } } else { LblLogingin.TextColor = Color.FromRgb(255, 0, 0); LblLogingin.HorizontalTextAlignment = TextAlignment.Center; LblLogingin.Text = "OOPS! Please connect to a network first."; await Task.Delay(250); LblLogingin.TextColor = Color.FromRgb(170, 0, 0); await Task.Delay(250); LblLogingin.TextColor = Color.FromRgb(255, 0, 0); await Task.Delay(250); LblLogingin.TextColor = Color.FromRgb(170, 0, 0); await Task.Delay(250); LblLogingin.TextColor = Color.FromRgb(255, 0, 0); await Task.Delay(250); LblLogingin.TextColor = Color.FromRgb(170, 0, 0); await Task.Delay(250); LblLogingin.TextColor = Color.FromRgb(255, 0, 0); await Task.Delay(250); LblLogingin.TextColor = Color.FromRgb(170, 0, 0); await Task.Delay(250); LblLogingin.TextColor = Color.FromRgb(255, 0, 0); await Task.Delay(250); LblLogingin.TextColor = Color.FromRgb(170, 0, 0); await Task.Delay(250); LblLogingin.TextColor = Color.FromRgb(255, 0, 0); await Task.Delay(250); LblLogingin.TextColor = Color.FromRgb(170, 0, 0); await Task.Delay(250); LblLogingin.TextColor = Color.FromRgb(255, 0, 0); await Task.Delay(250); LblLogingin.TextColor = Color.FromRgb(170, 0, 0); await Task.Delay(250); LblLogingin.TextColor = Color.FromRgb(255, 0, 0); await Task.Delay(250); LblLogingin.TextColor = Color.FromRgb(170, 0, 0); await Task.Delay(250); LblLogingin.TextColor = Color.FromRgb(255, 0, 0); LblLogingin.Text = ""; } }
public async Task GetImages(List <PictureInfo> pictureInfo, string itemnummer) { //Make a new ByteConvertController var byteConverter = new ByteConverterController(); //For each element in pictureInfo retrive the image for (int i = 0; i < pictureInfo.Count(); ++i) { //Show the Activity spinner this.IsBusy = true; //Get the image source from the api var Sources = await byteConverter.DownloadImage(itemnummer, pictureInfo[i].typecode); //Make a new image var img = new Image { //Set the source to what we got from the api Source = ImageSource.FromStream(() => new MemoryStream(Sources)), }; //Make a new label var LabelType = new Label { Text = pictureInfo[i].label + " - " + pictureInfo[i].typecode, HorizontalOptions = LayoutOptions.StartAndExpand }; //Add all the elements to the image page MasterContent.Children.Add(LabelType); MasterContent.Children.Add(img); //Make a new button the upload/change the image UserDatabaseController UserData = new UserDatabaseController(); var Userinfo = UserData.GetAllUsers(); if (Userinfo[0].picturePermisson == 1) { var ActionButton = new Button { Text = "Choose an action", BackgroundColor = Constants.KleynGroupTXT, TextColor = Constants.LoginEntryBgColor }; MasterContent.Children.Add(ActionButton); //Make a new var with the type code var TypeCode = pictureInfo[i].typecode; // Check if the user pressed one of the Buttons ActionButton.Clicked += async(sender, args) => { // If so ask the user what he wants to do with the image var action = await DisplayActionSheet("Select What you want to do with the image", "Cancel", null, "Delete Image", "Edit Image"); //Make a new switch switch (action) { //User pressed Delete case "Delete Image": //Make a new ByteController var Deleted = new ByteConverterController(); // Do the delete request var removeImage = Deleted.DeleteImage(itemnummer, TypeCode); //Send the user back to the detail page Navigation.InsertPageBefore(new DetailPage(itemnummer), this); await Navigation.PopAsync(true); break; // User pressed Edit case "Edit Image": // Ask if the user wants to choose a image from the gallery or take one with the camera var Editanswer = await DisplayActionSheet("Edit Choosed, Do you want to pick a photo from the gallery or one from the camera", "Abort", null, "Camera", "Gallery"); // If the user pressed Camera open the camera switch (Editanswer) { case "Camera": //Send the user to the camera and go on to the next function BtnCamera_ClickedAsync(itemnummer, TypeCode, "PUT"); break; case "Gallery": //Send the user to his/her Gallery and go on to the next function BtnPickPhoto_CickedAsync(itemnummer, TypeCode, "PUT"); break; default: await DisplayAlert("Action Canceld", "Action has been aborted", "Okay"); break; } break; //if the user pressed canceld or press some where else on the screen cancel the question default: //Show the user he/she canceld it await DisplayAlert("Nothing Choosed", "Nothing has been chosen", "Abort"); return; } ; }; } // Hide the Activity spinner this.IsBusy = false; } }
public UserRepository() { database = new UserDatabaseController(); }
public EditPage() { //SQL local database connection _UserDB = new User(); _UserQuery = new UserDatabaseController(); var UsernameEntry = new Entry { }; UsernameEntry.SetBinding(Entry.TextProperty, "Username"); UsernameEntry.IsVisible = false; var PasswordEntry = new Entry { }; PasswordEntry.SetBinding(Entry.TextProperty, "Password"); var updateButton = new Button { Text = "UPDATE" }; var deleteButton = new Button { Text = "DELETE" }; var cancelButton = new Button { Text = "CANCEL" }; //Update the selected data updateButton.Clicked += (object sender, EventArgs e) => { try { _DateTime = DateTime.Now; UpdateData(UsernameEntry.ToString(), PasswordEntry.ToString()); DisplayAlert("Alert", "Updated Succesfully.", "OK"); Navigation.PushAsync(new DatabaseViewer()); } catch (Exception ex) { string error = ex.ToString(); DisplayAlert("Sorry...", "Something went wrong. Try after sometime.", "OK"); } }; //Delete selected data deleteButton.Clicked += (object sender, EventArgs e) => { try { _UserQuery.DeleteUser(UsernameEntry.ToString()); DisplayAlert("Alert", "Deleted Succesfully.", "OK"); Navigation.PushAsync(new DatabaseViewer()); } catch (Exception ex) { string error = ex.ToString(); DisplayAlert("Sorry...", "Something went wrong. Try after sometime.", "OK"); } }; cancelButton.Clicked += (sender, e) => { var NoteItem = (User)BindingContext; this.Navigation.PopAsync(); }; var btnStack = new StackLayout { HorizontalOptions = LayoutOptions.FillAndExpand, Orientation = StackOrientation.Horizontal, Children = { updateButton, deleteButton, cancelButton } }; Content = new StackLayout { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand, Padding = new Thickness(20), Children = { UsernameEntry, PasswordEntry, btnStack } }; }
protected override void OnStart() { // Handle when your app starts UserDatabaseController db = new UserDatabaseController(); }