Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Navigation;
- using Microsoft.Phone.Controls;
- using Microsoft.Phone.Shell;
- using MyDailyHealth.Resources;
- using System.IO;
- using System.IO.IsolatedStorage;
- using System.Threading;
- namespace MyDailyHealth
- {
- public partial class MainPage : PhoneApplicationPage
- {
- private string[] Username = new string[100]; //Holds the usernames for the login
- private string[] Password = new string[100]; //Holds the passwords for the login
- private string Gender;
- private int[] Logged = new int[3];
- private string Error001 = "Wrong user input please input username and password";
- private string Error002 = "Missing attribures, please contact our support team or reinstall the application.";
- // Constructor
- public MainPage()
- {
- InitializeComponent();
- // Sample code to localize the ApplicationBar
- //BuildLocalizedApplicationBar();
- }
- private void Button_Click(object sender, RoutedEventArgs e)
- {
- NavigationService.Navigate(new Uri("/Page1.xaml",UriKind.Relative));
- }
- private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
- {
- }
- private void TextBox_TextChanged_1(object sender, TextChangedEventArgs e)
- {
- }
- private void Login_Click(object sender, RoutedEventArgs e)
- {
- IsolatedStorageFile isf1 = IsolatedStorageFile.GetUserStoreForApplication();
- StreamReader sr = null;
- try
- {
- sr = new StreamReader(new IsolatedStorageFileStream("UnameBox.txt", FileMode.Open, isf1));
- Username[0] = sr.ReadLine();
- sr.Close();
- }
- catch
- {
- MessageBox.Show(Error002);
- Thread.Sleep(400);
- MessageBox.Show("Reinstalling the application may cause fatal data loss!");
- }
- if(UnameBox.Text == Username[0])
- {
- Logged[0] = 1;
- }
- else if(UnameBox.Text != Username[0])
- {
- MessageBox.Show(Error001);
- }
- IsolatedStorageFile isf6 = IsolatedStorageFile.GetUserStoreForApplication();
- StreamReader sr1 = null;
- try
- {
- sr1 = new StreamReader(new IsolatedStorageFileStream("PassBox.txt", FileMode.Open, isf6));
- Password[0] = sr1.ReadLine();
- sr1.Close();
- }
- catch (Exception)
- {
- MessageBox.Show(Error002);
- Thread.Sleep(400);
- MessageBox.Show("Reinstalling the application may cause fatal data loss!");
- }
- if(PassBox.Text == Password[0])
- {
- Logged[1] = 1;
- }
- else if(PassBox.Text != Password[0])
- {
- MessageBox.Show(Error001);
- }
- if(Logged[0] == 1 && Logged[1] == 1)
- {
- IsolatedStorageFile isf5b = IsolatedStorageFile.GetUserStoreForApplication();
- StreamReader sr3 = null;
- IsolatedStorageFile isf5a = IsolatedStorageFile.GetUserStoreForApplication();
- StreamReader sr4 = null;
- IsolatedStorageFile isf5c = IsolatedStorageFile.GetUserStoreForApplication();
- StreamReader sr5 = null;
- IsolatedStorageFile isf5d = IsolatedStorageFile.GetUserStoreForApplication();
- StreamReader sr6 = null;
- try
- {
- MessageBox.Show("Success");
- sr3 = new StreamReader(new IsolatedStorageFileStream("MaleGender.txt", FileMode.Open, isf5b));
- Gender = Convert.ToString(sr3.ReadLine());
- sr3.Close();
- sr4 = new StreamReader(new IsolatedStorageFileStream("FemaleGender.txt", FileMode.Open, isf5a));
- Gender = Convert.ToString(sr4.ReadLine());
- sr4.Close();
- sr5 = new StreamReader(new IsolatedStorageFileStream("MaleGender.txt", FileMode.Open, isf5c));
- Gender = Convert.ToString(sr5.ReadLine());
- sr5.Close();
- sr6 = new StreamReader(new IsolatedStorageFileStream("FemaleGedner.txt", FileMode.Open, isf5d));
- Gender = Convert.ToString(sr6.ReadLine());
- sr6.Close();
- if(Gender == "Male")
- {
- NavigationService.Navigate(new Uri("PanoramaPage1.xaml", UriKind.Relative));
- }
- else if(Gender == "Female")
- {
- NavigationService.Navigate(new Uri("PanoramaPage2.xaml", UriKind.Relative));
- }
- Thread.Sleep(300);
- MessageBox.Show(Gender);
- }
- catch
- {
- }
- }
- }
- // Sample code for building a localized ApplicationBar
- //private void BuildLocalizedApplicationBar()
- //{
- // // Set the page's ApplicationBar to a new instance of ApplicationBar.
- // ApplicationBar = new ApplicationBar();
- // // Create a new button and set the text value to the localized string from AppResources.
- // ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
- // appBarButton.Text = AppResources.AppBarButtonText;
- // ApplicationBar.Buttons.Add(appBarButton);
- // // Create a new menu item with the localized string from AppResources.
- // ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
- // ApplicationBar.MenuItems.Add(appBarMenuItem);
- //}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement