Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Coursework1/Coursework1/Coursework1/Views/RegisterPage.xaml.cs
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
67 lines (56 sloc)
1.97 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Coursework1.Tables; | |
using SQLite; | |
using System; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using Xamarin.Forms; | |
using Xamarin.Forms.Xaml; | |
namespace Coursework1.Views | |
{ | |
[XamlCompilation(XamlCompilationOptions.Compile)] | |
public partial class RegisterPage : ContentPage | |
{ | |
public RegisterPage() | |
{ | |
InitializeComponent(); | |
} | |
void Button_Clicked(object sender, EventArgs e) | |
{ | |
var dbpath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "UserDatabase.db"); | |
var db = new SQLiteConnection(dbpath); | |
db.CreateTable<RegisteredUsers>(); | |
var item = new RegisteredUsers() | |
{ | |
Username = EntryUsername.Text, | |
Password = EntryPassword.Text, | |
Email = EntryEmail.Text | |
}; | |
db.Insert(item); | |
if (EntryUsername.Text.Equals(null) || EntryPassword.Text.Equals(null) || EntryEmail.Text.Equals(null)) | |
{ | |
Device.BeginInvokeOnMainThread(async () => | |
{ | |
var output = await this.DisplayAlert("Please fill all the fields", "Registration failed", "Okay", "Cancel"); | |
if (output) | |
await Navigation.PushModalAsync(new RegisterPage()); | |
}); | |
} | |
else | |
{ | |
Device.BeginInvokeOnMainThread(async () => | |
{ | |
var result = await this.DisplayAlert("Registration Succesful", "Press okay to go to log in page", "Okay", "Cancel"); | |
if (result) | |
await Navigation.PushModalAsync(new LogInPage()); | |
}); | |
} | |
} | |
void Button_Clicked_1(object sender, EventArgs e) | |
{ | |
App.Current.MainPage = new NavigationPage(new LogInPage()); | |
} | |
} | |
} |