private void BtnVoltar_Click(object sender, RoutedEventArgs e) { TelaPrincipal telaPrincipal = new TelaPrincipal(); telaPrincipal.Show(); this.Close(); }
//metodo para entrar no sistema public void Logar() { try { conexao.Conectar(); command = new MySqlCommand("select usuario, senha, tipo_usuario from loginfuncionario where usuario = @usuario and senha = @senha", conexao.conexao); command.Parameters.AddWithValue("@usuario", txtFuncionario.Text); command.Parameters.AddWithValue("@senha", pswSenha.Password); MySqlDataReader dr = command.ExecuteReader(); //verifica a informação no banco if (dr.Read()) { string user = dr["tipo_usuario"].ToString(); if (user.Equals("Usuario")) { TelaPrincipal telaPrincipal = new TelaPrincipal(); telaPrincipal.menuItemFuncionario.IsEnabled = false; telaPrincipal.menuItemPagarContas.IsEnabled = false; telaPrincipal.menuItemReceberContas.IsEnabled = false; telaPrincipal.menuItemFluxo.IsEnabled = false; telaPrincipal.menuItemTodasEntradas.IsEnabled = false; telaPrincipal.menuItemTodasSaidas.IsEnabled = false; telaPrincipal.menuVenda.IsEnabled = false; MessageBox.Show("Welcome !"); telaPrincipal.Show(); this.Close(); } else if (user.Equals("Administrador")) { MessageBox.Show("Welcome !"); TelaPrincipal telaPrincipal = new TelaPrincipal(); telaPrincipal.Show(); this.Close(); } } else { MessageBox.Show("Usuario/Senha incorretos!"); } } catch (Exception erro) { throw erro; } }