private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (TxtBoxCaridade_Email.Text == "" || PswBoxCaridade.Password.ToString().Equals("") || PswBoxConfirmCaridade.Password.ToString().Equals(""))
            {
                MessageBox.Show("Please fill in all fields");
            }
            else
            {
                if (emailIsValid(TxtBoxCaridade_Email.Text) == 1)
                {
                    MessageBox.Show("Please insert a valid email");
                }
                else if (emailIsValid(TxtBoxCaridade_Email.Text) == 2)
                {
                    MessageBox.Show("That email is already taken, please insert another one");
                }
                else if (passIsValid(PswBoxCaridade.Password.ToString()) == 1)
                {
                    MessageBox.Show("Please insert a password between 6 and 16 characters");
                }
                else if (passIsValid(PswBoxCaridade.Password.ToString()) == 2)
                {
                    MessageBox.Show("Please insert at least one letter and one digit");
                }
                else if (!PswBoxCaridade.Password.Equals(PswBoxConfirmCaridade.Password))
                {
                    MessageBox.Show("Passwords inserted dont match");
                }
                else
                {
                    caridadeFinal.emailCaridade    = TxtBoxCaridade_Email.Text;
                    caridadeFinal.passwordCaridade = PswBoxCaridade.Password.ToString();
                    CreateClasses.ListaCaridades.Add(caridadeFinal);

                    HelloCharity helloCharity = new HelloCharity(caridadeFinal);
                    this.NavigationService.Navigate(helloCharity);
                }
            }
        }
        private void ButtonBack_Click(object sender, RoutedEventArgs e)
        {
            HelloCharity helloCharity = new HelloCharity(caridade);

            this.NavigationService.Navigate(helloCharity);
        }
Example #3
0
        private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            Boolean         existeCaridade    = false;
            Boolean         existeRestaurante = false;
            UserCaridade    caridade          = new UserCaridade();
            UserRestaurante restaurante       = new UserRestaurante();


            if (txtBox_EmailLogIn.Text == "" || txtBox_PswLogIn.Password.ToString().Equals(""))
            {
                MessageBox.Show("Please fill in all fields");
            }

            else
            {
                foreach (UserCaridade c in CreateClasses.ListaCaridades)
                {
                    if (c.emailCaridade == txtBox_EmailLogIn.Text)
                    {
                        existeCaridade = true;
                        caridade       = c;
                    }
                }

                foreach (UserRestaurante r in CreateClasses.ListaRestaurantes)
                {
                    if (r.emailRestaurante == txtBox_EmailLogIn.Text)
                    {
                        existeRestaurante = true;
                        restaurante       = r;
                    }
                }

                if (existeCaridade)
                {
                    if (!caridade.passwordCaridade.Equals(txtBox_PswLogIn.Password))
                    {
                        MessageBox.Show("The password provided is incorrect");
                    }
                    else
                    {
                        HelloCharity helloCharity = new HelloCharity(caridade);
                        this.NavigationService.Navigate(helloCharity);
                    }
                }

                else if (existeRestaurante)
                {
                    if (!restaurante.passwordRestaurante.Equals(txtBox_PswLogIn.Password))
                    {
                        MessageBox.Show("The password provided is incorrect");
                    }
                    else
                    {
                        HelloRestaurant helloRestaurant = new HelloRestaurant(restaurante);
                        this.NavigationService.Navigate(helloRestaurant);
                    }
                }

                else
                {
                    MessageBox.Show("Unknown username");
                }
            }
        }