-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainPage.xaml.cs
42 lines (34 loc) · 1.24 KB
/
MainPage.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Diagnostics;
namespace LearnPro
{
public partial class MainPage : ContentPage
{
// Define valid license codes for checking
private readonly string[] validLicenseCodes = { "ABC123", "XYZ456", "LMN789" };
public MainPage()
{
InitializeComponent();
}
// Event handler for the submit button click
private async void OnSubmitButtonClicked(object sender, EventArgs e)
{
string? enteredCode = LicenseCodeEntry.Text?.Trim(); // Get the entered license code
if (string.IsNullOrEmpty(enteredCode))
{
await DisplayAlert("Error", "License code cannot be empty!", "OK");
return;
}
if (Array.Exists(validLicenseCodes, code => code.Equals(enteredCode, StringComparison.OrdinalIgnoreCase)))
{
// License code is valid, navigate to the homepage
await Navigation.PushAsync(new HomePage()); // Navigate to HomePage
}
else
{
// License code is invalid
await DisplayAlert("Error", "Wrong license code. Please try again!", "OK");
}
}
}
}