Exemplo n.º 1
0
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                string nome  = txtNome.Text;
                string senha = txtSenha.Text;

                ObjAux.Criptografia Crip = new ObjAux.Criptografia();
                string crip_nome         = Crip.Criptografar(nome);
                string crip_senha        = Crip.Criptografar(senha);

                Database.Entity.tb_login tb = new Database.Entity.tb_login();
                tb.id_funcionario = Convert.ToInt32(txtID.Text);
                tb.nm_senha       = senha;
                tb.nm_usuario     = nome;

                Business.BusinessLogin bs = new Business.BusinessLogin();
                bs.Inserir(tb);
                MessageBox.Show("Cadastro feito com sucesso");
                this.Hide();

                Telas.Login tela = new Login();
                tela.Show();
            }
            catch
            {
                MessageBox.Show("Algum erro");
            }
        }
Exemplo n.º 2
0
 public void Alterar(Database.Entity.tb_login tb)
 {
     if (tb.nm_usuario == string.Empty || tb.nm_senha == string.Empty)
     {
         throw new ArgumentException("Preencha todos os campos");
     }
     db.Alterar(tb);
 }
Exemplo n.º 3
0
 public void Inserir(Database.Entity.tb_login tb)
 {
     if (tb.nm_senha == string.Empty || tb.nm_usuario == string.Empty)
     {
         throw new Exception("Preencha todos os campos");
     }
     db.Inserir(tb);
 }
Exemplo n.º 4
0
        private void BtnTrocar_Click(object sender, EventArgs e)
        {
            if (TxtSenha != txtConfirmar)
            {
                throw new ArgumentException("As senhas não estão corretas.");
            }
            Database.Entity.tb_login tb = new Database.Entity.tb_login();
            tb.nm_usuario     = TxtUsuario.Text;
            tb.nm_senha       = TxtSenha.Text;
            tb.cd_confirmacao = Convert.ToString(TxtCodigo.Text);

            Business.BusinessLogin bs = new Business.BusinessLogin();
            bs.Alterar(tb);
        }
Exemplo n.º 5
0
        public Database.Entity.tb_login Consultar(Database.Entity.tb_login tb)
        {
            Database.Entity.tb_login tbs = db.Consultar(tb);;

            if (tb.nm_usuario == string.Empty || tb.nm_senha == string.Empty)
            {
                throw new Exception("Preencher todos os campos.");
            }
            if (tb.nm_usuario != tbs.nm_usuario || tb.nm_senha != tbs.nm_senha || tbs == null)
            {
                throw new Exception("Usuario não cadastrado.");
            }

            return(tbs);
        }
Exemplo n.º 6
0
        private void btnLogin_Click_1(object sender, EventArgs e)
        {
            //Abraão a criptografia n tem q ficar apenas no cadastro do login.
            //Aqui é uma consulta, é só pegar os campos e mandar pra business, n precisa de uma model.
            //A business q vai comparar as infos daqui com a model ai dps abre a tela.
            //Ex:Se a senha e o nome for tal n vai poder abrir tais telas. isso tudo fica na business.
            string nome  = txtNome.Text;
            string senha = txtSenha.Text;

            Bistro.menu tela = new menu();

            //Isso é para estar na business.
            //{
            if (nome == "adm" && senha == "1234")
            {
                tela.Show();
            }
            //}
            ObjAux.Criptografia Crip = new ObjAux.Criptografia();
            string crip_nome         = Crip.Criptografar(nome);
            string crip_senha        = Crip.Criptografar(senha);

            Database.Entity.tb_login login = new Database.Entity.tb_login();
            login.nm_senha   = crip_nome;
            login.nm_usuario = crip_senha;


            Business.BusinessLogin   bs  = new Business.BusinessLogin();
            Database.Entity.tb_login tbs = bs.Consultar(login);

            if (tbs == null)
            {
                throw new ArgumentException("Credenciais invalidas.");
            }

            Models.UsuarioLogado.Usuario = tbs;

            tela.Show();
        }