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
51 lines (44 sloc) 1.5 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 LogInPage : ContentPage
{
public LogInPage()
{
InitializeComponent();
}
async void Button_Clicked(object sender, EventArgs e)
{
await Navigation.PushModalAsync(new RegisterPage());
}
void Button_Clicked_1(object sender, EventArgs e)
{
var dbpath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "UserDatabase.db");
var db = new SQLiteConnection(dbpath);
var myquery = db.Table<RegisteredUsers>().Where(u => u.Username.Equals(EntryUsername.Text) && u.Password.Equals(EntryPassword.Text)).FirstOrDefault();
if (myquery != null)
{
App.Current.MainPage = new NavigationPage(new MainPage());
}
else
{
Device.BeginInvokeOnMainThread(async () =>
{
var result = await this.DisplayAlert("Log In Failed", "Check both Username and Password", "Okay", "Cancel");
if (result)
await Navigation.PushModalAsync(new LogInPage());
});
}
}
}
}