예제 #1
0
        private void login(object sender, RoutedEventArgs e)
        {
            try
            {
                string emailView = email.Text;
                string senhaView = senha.Password;

                if ((bool)usuario.IsChecked)
                {
                    UsuarioController usuController = new UsuarioController();

                    if (usuController.Autenticar(emailView, senhaView))
                    {
                        Application.Current.Properties["_user"] = usuController.carregaUsuarioEmail(emailView);

                        var usuario = Application.Current.Properties["_user"] as Usuario;
                        emailView = usuario.NomeUsuario;

                        AlterarUsuario altUsu = new AlterarUsuario();
                        Home           home   = new Home(1);
                        home.Show();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("E-mail e/ou senha inválidos!");
                    }
                }

                else if ((bool)estabelecimento.IsChecked)
                {
                    EstabelecimentoController estController = new EstabelecimentoController();

                    if (estController.Autenticar(emailView, senhaView))
                    {
                        Application.Current.Properties["_user"] = estController.carregaEstabelecimentoEmail(emailView);

                        var estabelecimento = Application.Current.Properties["_user"] as Estabelecimento;
                        emailView = estabelecimento.nomeFantasia;

                        AlterarEstabelecimento altEst = new AlterarEstabelecimento();
                        Home home = new Home(2);
                        home.Show();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("E-mail e/ou senha inválidos!");
                    }
                }
                else
                {
                    MessageBox.Show("Selecione uma das opções de login!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception: " + ex);
            }
        }
예제 #2
0
 private void alterarDadosUsuario_Click(object sender, RoutedEventArgs e)
 {
     AlterarUsuario altUsu = new AlterarUsuario();
     altUsu.Show();
 }