예제 #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            TelaPrincipal telaPrincipal = new TelaPrincipal();

            telaPrincipal.Hide();


            Login add = new Login();

            add.Show();
        }
예제 #2
0
 private void btnEntrar_Click(object sender, EventArgs e)
 {
     if ((txtUsuario.Text == "admin") &&
         (txtSenha.Text == "123456"))
     {
         TelaPrincipal telaPrincipal = new TelaPrincipal();
         telaPrincipal.Show();
         this.Visible = false;
         MessageBox.Show("Login efetuado com sucesso!");
     }
     else
     {
         MessageBox.Show("Usuário ou senha inválidos!");
     }
 }
예제 #3
0
        public void Logar()
        {
            Controle controle = new Controle();

            controle.acessar(txbLogin.Text, txbSenha.Text);
            if (controle.mensagem.Equals(""))
            {
                if (txbLogin.Text == string.Empty) //Ou qualquer outro número que você definir
                {
                    MessageBox.Show("DIGITE O E-MAIL!", "ATENÇÃO!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else if (txbSenha.Text == string.Empty) //Ou qualquer outro número que você definir
                {
                    MessageBox.Show("DIGITE A SENHA!", "ATENÇÃO!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
                else
                {
                    if (controle.tem)
                    {
                        strSql = "SELECT NivelAcesso, usuario FROM Logins WHERE email='" + txbLogin.Text + "'";
                        sqlCon = new SqlConnection(strCon);
                        sqlCon.Open();
                        SqlCommand    comando = new SqlCommand(strSql, sqlCon);
                        SqlDataReader dr      = comando.ExecuteReader();
                        dr.Read();
                        string lvlAcesso = dr["NivelAcesso"].ToString();
                        string nome      = dr["usuario"].ToString();

                        if (lvlAcesso == "GERENTE" || lvlAcesso == "ATENDENTE")
                        {
                            if (lvlAcesso == "GERENTE")
                            {
                                TelaPrincipal tela = new TelaPrincipal();
                                tela.lblnome.Text = "BEM VINDO(A) " + nome.ToUpper();
                                tela.lblfunc.Text = "GERENTE";
                                tela.ShowDialog();

                                txbLogin.Clear();
                                txbSenha.Clear();
                            }
                            else if (lvlAcesso == "ATENDENTE")
                            {
                                TelaPrincipal tela = new TelaPrincipal();
                                tela.lblnome.Text = "BEM VINDO(A) " + nome.ToUpper();
                                tela.lblfunc.Text = "ATENDENTE";
                                tela.clienteToolStripMenuItem.Enabled    = false;
                                tela.fornecedorToolStripMenuItem.Enabled = false;
                                tela.produtoToolStripMenuItem.Enabled    = false;
                                tela.ShowDialog();

                                txbLogin.Clear();
                                txbSenha.Clear();
                            }
                        }
                        else
                        {
                            MessageBox.Show("O FUNCIONÁRIO NÃO TEM PERMISSÃO\nPARA ACESSAR O SISTEMA!", "USUÁRIO SEM PERMISSÃO!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            txbSenha.Clear();
                        }
                    }
                    else
                    {
                        txbSenha.Clear();
                        MessageBox.Show("Login não encontrado", "ERRO!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        txbSenha.Clear();
                    }
                }
            }
            else
            {
                MessageBox.Show(controle.mensagem);
            }
        }