Exemplo n.º 1
0
 //Login
 private void BtnSubmit_Clicked(object sender, EventArgs e)
 {
     if (String.IsNullOrEmpty(entPassword.Text) || String.IsNullOrEmpty(entUsername.Text))
     {
         lblError.Text      = "Please enter your credentials first.";
         lblError.IsVisible = true;
     }
     else
     {
         int userID = NetworkUtils.Login(entUsername.Text, entPassword.Text);
         if (userID == 0)
         {
             lblError.Text      = "Not a valid username and password.";
             lblError.IsVisible = true;
         }
         else
         {
             AppProperties.setSavedUserId(userID);
             AppProperties.saveUserName(entUsername.Text);
             if (Application.Current.Properties.ContainsKey("currentGroupID"))
             {
                 String groupName = Application.Current.Properties["currentGroup"].ToString();
                 CreatePage.createHamburgerIcon(new GroupPage(), groupName);
             }
             else
             {
                 CreatePage.createHamburgerIcon(new MainPage(), entUsername.Text);
             }
         }
     }
 }
Exemplo n.º 2
0
        //Add the user to the DB
        private void btnUsername_Clicked(object sender, EventArgs e)
        {
            //String userName = entryName.Text;
            //String password = entryPassword.Text;
            //Make sure the user entered a username
            if (string.IsNullOrWhiteSpace(entryName.Text))
            {
                lblNoUserName.IsVisible = true;
            }
            else if (string.IsNullOrEmpty(entryPassword.Text))
            {
                lblNoUserName.Text      = "You must enter a password";
                lblNoUserName.IsVisible = true;
            }
            else if (entryPassword.Text != entryPassword2.Text)
            {
                lblNoUserName.Text      = "Passwords do not match.";
                lblNoUserName.IsVisible = true;
            }
            else
            {
                //Insert user in DB and save username
                insertUser();
                if (userID == 0)
                {
                    lblNoUserName.Text      = "That user name already exists. Please choose a different username.";
                    lblNoUserName.IsVisible = true;
                }
                else
                {
                    AppProperties.saveUserName(entryName.Text);

                    string path     = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                    string filename = Path.Combine(path, "YouSee.txt");

                    using (var streamWriter = new StreamWriter(filename, false))
                    {
                        streamWriter.WriteLine(entryName.Text);
                    }

                    using (var streamReader = new StreamReader(filename))
                    {
                        string content = streamReader.ReadToEnd();
                        System.Diagnostics.Debug.WriteLine(content);
                    }
                    //Launch MainPage

                    CreatePage.createHamburgerIcon(new MainPage(), Application.Current.Properties["savedUserName"].ToString());
                }
            }
        }