Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
122 additions
and
1 deletion.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Coursework1.Views.LogInPage"> | ||
<ContentPage.Content> | ||
<ScrollView> | ||
<StackLayout> | ||
<Grid VerticalOptions="CenterAndExpand"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition/> | ||
<RowDefinition/> | ||
<RowDefinition/> | ||
<RowDefinition/> | ||
</Grid.RowDefinitions> | ||
|
||
<Entry Placeholder="Username" x:Name="EntryUsername" Grid.Row="0"/> | ||
<Entry Placeholder="Passwrod" x:Name="EntryPassword" Grid.Row="1"/> | ||
<Button Text="Log In" Grid.Row="2" BackgroundColor="Blue" TextColor="White" Clicked="Button_Clicked_1"/> | ||
<Button Text="SignUp" Grid.Row="3" BackgroundColor="Blue" TextColor="White" Clicked="Button_Clicked"/> | ||
|
||
</Grid> | ||
</StackLayout> | ||
</ScrollView> | ||
</ContentPage.Content> | ||
</ContentPage> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
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()); | ||
|
||
}); | ||
} | ||
|
||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Coursework1.Views.MainPage"> | ||
<ContentPage.Content> | ||
<StackLayout> | ||
<Label Text="Welcome to Xamarin.Forms!" | ||
VerticalOptions="CenterAndExpand" | ||
HorizontalOptions="CenterAndExpand" /> | ||
</StackLayout> | ||
</ContentPage.Content> | ||
</ContentPage> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
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 MainPage : ContentPage | ||
{ | ||
public MainPage() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |
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