private void SignIn_Click(object sender, EventArgs e) { if (UserName.Text.ToString().Length == 0) { Toast.MakeText(this, "Invalid User Name", ToastLength.Short).Show(); } else if (Password.Text.ToString().Length == 0) { Toast.MakeText(this, "Invalid Password", ToastLength.Short).Show(); } else { //! Check is strings are Valid! UserDataBase database = new UserDataBase(this); bool valid = database.Validity(UserName.Text.ToString().Trim(), Password.Text.ToString().Trim()); if (valid) { Intent intent = new Intent(this, typeof(CameraSurface)).PutExtra("StringName", UserName.Text.ToString()); StartActivity(intent); //TO DECIDE ---------> With or without Finish? //Finish(); } else { Toast.MakeText(this, "Wrong User Name or Password", ToastLength.Short).Show(); } } }
private void Sign_Up_Click(object sender, EventArgs e) { UserDataBase database = new UserDataBase(this);//Used to check if the username and/or email is already in the DB if (UserName.Text.ToString().Length == 0) { Toast.MakeText(this, "Please enter a valid User Name", ToastLength.Short).Show(); } else if (Password.Text.ToString().Length == 0) { Toast.MakeText(this, "Please enter a valid Password", ToastLength.Short).Show(); } else if (Email.Text.ToString().Length == 0 || !Android.Util.Patterns.EmailAddress.Matcher(Email.Text.ToString()).Matches()) { Toast.MakeText(this, "Please enter a valid Email", ToastLength.Short).Show(); } else if (database.CheckExistingUserNameOrEmail(UserName.Text.ToString(), Email.Text.ToString())) { Toast.MakeText(this, "This User Name or Email is already registered", ToastLength.Short).Show(); } else { User NewUser = new User(); NewUser.UserName = UserName.Text.ToString(); NewUser.Password = Password.Text.ToString(); NewUser.Email = Email.Text.ToString(); database.AddNewUser(NewUser); Intent intent = new Intent(this, typeof(LogIn)); StartActivity(intent); //TO DECIDE ---------> With or without Finish? //Finish(); } }