Advertisement
MGM_user1

Untitled

Nov 1st, 2014
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.26 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Net;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Navigation;
  8. using Microsoft.Phone.Controls;
  9. using Microsoft.Phone.Shell;
  10. using MyDailyHealth.Resources;
  11. using System.IO;
  12. using System.IO.IsolatedStorage;
  13. using System.Threading;
  14.  
  15. namespace MyDailyHealth
  16. {
  17. public partial class MainPage : PhoneApplicationPage
  18. {
  19. private string[] Username = new string[100]; //Holds the usernames for the login
  20. private string[] Password = new string[100]; //Holds the passwords for the login
  21. private string Gender;
  22. private int[] Logged = new int[3];
  23.  
  24. private string Error001 = "Wrong user input please input username and password";
  25. private string Error002 = "Missing attribures, please contact our support team or reinstall the application.";
  26. // Constructor
  27. public MainPage()
  28. {
  29. InitializeComponent();
  30.  
  31. // Sample code to localize the ApplicationBar
  32. //BuildLocalizedApplicationBar();
  33. }
  34.  
  35. private void Button_Click(object sender, RoutedEventArgs e)
  36. {
  37. NavigationService.Navigate(new Uri("/Page1.xaml",UriKind.Relative));
  38. }
  39. private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
  40. {
  41.  
  42. }
  43.  
  44. private void TextBox_TextChanged_1(object sender, TextChangedEventArgs e)
  45. {
  46.  
  47. }
  48.  
  49. private void Login_Click(object sender, RoutedEventArgs e)
  50. {
  51. IsolatedStorageFile isf1 = IsolatedStorageFile.GetUserStoreForApplication();
  52. StreamReader sr = null;
  53. try
  54. {
  55. sr = new StreamReader(new IsolatedStorageFileStream("UnameBox.txt", FileMode.Open, isf1));
  56. Username[0] = sr.ReadLine();
  57. sr.Close();
  58. }
  59. catch
  60. {
  61. MessageBox.Show(Error002);
  62. Thread.Sleep(400);
  63. MessageBox.Show("Reinstalling the application may cause fatal data loss!");
  64. }
  65. if(UnameBox.Text == Username[0])
  66. {
  67. Logged[0] = 1;
  68. }
  69. else if(UnameBox.Text != Username[0])
  70. {
  71. MessageBox.Show(Error001);
  72. }
  73. IsolatedStorageFile isf6 = IsolatedStorageFile.GetUserStoreForApplication();
  74. StreamReader sr1 = null;
  75. try
  76. {
  77. sr1 = new StreamReader(new IsolatedStorageFileStream("PassBox.txt", FileMode.Open, isf6));
  78. Password[0] = sr1.ReadLine();
  79. sr1.Close();
  80. }
  81. catch (Exception)
  82. {
  83. MessageBox.Show(Error002);
  84. Thread.Sleep(400);
  85. MessageBox.Show("Reinstalling the application may cause fatal data loss!");
  86. }
  87. if(PassBox.Text == Password[0])
  88. {
  89. Logged[1] = 1;
  90. }
  91. else if(PassBox.Text != Password[0])
  92. {
  93. MessageBox.Show(Error001);
  94. }
  95. if(Logged[0] == 1 && Logged[1] == 1)
  96. {
  97. IsolatedStorageFile isf5b = IsolatedStorageFile.GetUserStoreForApplication();
  98. StreamReader sr3 = null;
  99. IsolatedStorageFile isf5a = IsolatedStorageFile.GetUserStoreForApplication();
  100. StreamReader sr4 = null;
  101. IsolatedStorageFile isf5c = IsolatedStorageFile.GetUserStoreForApplication();
  102. StreamReader sr5 = null;
  103. IsolatedStorageFile isf5d = IsolatedStorageFile.GetUserStoreForApplication();
  104. StreamReader sr6 = null;
  105.  
  106.  
  107. try
  108. {
  109. MessageBox.Show("Success");
  110. sr3 = new StreamReader(new IsolatedStorageFileStream("MaleGender.txt", FileMode.Open, isf5b));
  111. Gender = Convert.ToString(sr3.ReadLine());
  112. sr3.Close();
  113. sr4 = new StreamReader(new IsolatedStorageFileStream("FemaleGender.txt", FileMode.Open, isf5a));
  114. Gender = Convert.ToString(sr4.ReadLine());
  115. sr4.Close();
  116. sr5 = new StreamReader(new IsolatedStorageFileStream("MaleGender.txt", FileMode.Open, isf5c));
  117. Gender = Convert.ToString(sr5.ReadLine());
  118. sr5.Close();
  119. sr6 = new StreamReader(new IsolatedStorageFileStream("FemaleGedner.txt", FileMode.Open, isf5d));
  120. Gender = Convert.ToString(sr6.ReadLine());
  121.  
  122. sr6.Close();
  123. if(Gender == "Male")
  124. {
  125. NavigationService.Navigate(new Uri("PanoramaPage1.xaml", UriKind.Relative));
  126. }
  127. else if(Gender == "Female")
  128. {
  129. NavigationService.Navigate(new Uri("PanoramaPage2.xaml", UriKind.Relative));
  130. }
  131. Thread.Sleep(300);
  132. MessageBox.Show(Gender);
  133. }
  134. catch
  135. {
  136.  
  137.  
  138. }
  139. }
  140.  
  141. }
  142.  
  143. // Sample code for building a localized ApplicationBar
  144. //private void BuildLocalizedApplicationBar()
  145. //{
  146. // // Set the page's ApplicationBar to a new instance of ApplicationBar.
  147. // ApplicationBar = new ApplicationBar();
  148.  
  149. // // Create a new button and set the text value to the localized string from AppResources.
  150. // ApplicationBarIconButton appBarButton = new ApplicationBarIconButton(new Uri("/Assets/AppBar/appbar.add.rest.png", UriKind.Relative));
  151. // appBarButton.Text = AppResources.AppBarButtonText;
  152. // ApplicationBar.Buttons.Add(appBarButton);
  153.  
  154. // // Create a new menu item with the localized string from AppResources.
  155. // ApplicationBarMenuItem appBarMenuItem = new ApplicationBarMenuItem(AppResources.AppBarMenuItemText);
  156. // ApplicationBar.MenuItems.Add(appBarMenuItem);
  157. //}
  158. }
  159. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement