Skip to content
Permalink
c49e60a976
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
67 lines (56 sloc) 1.97 KB
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());
}
}
}