Esempio n. 1
0
        private bool VerificaSenha(String strLido)
        {
            Txt2CodigosInterpretaveis txt2CI = null;

            txt2CI = new Txt2CodigosInterpretaveis(strLido);

            if (txt2CI.ExisteCabecalho())
            {
                txt2CI.ObtemInformacoesCabecalho();
                if (txt2CI.bSolicitarSenha)
                {
                    DialogResult _result;
                    //String _strSenha = "";
                    bool     _bSenhaOK = false;
                    frmSenha _frmSenha = new frmSenha();

                    _frmSenha.Text = "Digite a senha (1/2):";
                    _frmSenha.lblSenhaAtual.Text = "Senha:";

                    for (int i = 0; i < 2; i++)
                    {
                        _result = _frmSenha.ShowDialog();

                        if (_result == DialogResult.Cancel)
                        {
                            MessageBox.Show("Operação cancelada!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return(false);
                        }
                        else
                        {
                            if (txt2CI.strSenha != _frmSenha.txtSenha.Text)
                            {
                                _frmSenha.txtSenha.Text = "";
                                _frmSenha.Text          = "Digite a senha (1/2):";
                                //return;
                            }
                            else
                            {
                                _bSenhaOK = true;
                                i         = 5; //sai
                            }
                        }
                    }
                    if (!_bSenhaOK)
                    {
                        MessageBox.Show("Operação cancelada!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return(false);
                    }
                }
            }

            return(true);
        }
Esempio n. 2
0
        private void carregaUsuario()
        {
            try
            {
                if (txtUsuario.Text.Equals(string.Empty))
                {
                    txtSenha.Text = string.Empty;
                    txtUsuario.Focus();
                    txtUsuario.SelectAll();
                    throw new Exception("Olá para acessar o sistema é necessário" + '\n' + "informar o seu Usuário e Senha.");
                }
                objBLL = new BLL_usuario();
                lista  = new List <MOD_usuario>();
                lista  = objBLL.buscarUsuario(txtUsuario.Text, "Sim");

                if (lista.Count > 0)
                {
                    vAlteraSenha = lista[0].AlteraSenha;

                    if (vAlteraSenha.Equals("Sim"))
                    {
                        MessageBox.Show("Foi solicitado pelo Supervisor do sistema, que você " + '\n' +
                                        "deverá alterar sua senha nesse login!" + '\n' + '\n' + "Por gentileza, informe a nova senha na próxima tela.", "Atenção", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        FormSenha           = new frmSenha(this, lista);
                        FormSenha.MdiParent = MdiParent;
                        FormSenha.Show();
                        Enabled = false;
                    }
                    else
                    {
                        listaSenha = new List <MOD_usuario>();
                        listaSenha = objBLL.buscarSenha(txtUsuario.Text, txtSenha.Text, "Sim");
                        if (listaSenha.Count > 0)
                        {
                            //buscando os Parametros do sistema
                            objBLL_Param = new BLL_parametros();

                            new BLL_Session(1, out listaParam);

                            modulos.CodRegional    = listaParam[0].CodRegional.PadLeft(3, '0');
                            modulos.CodigoRegional = listaParam[0].CodigoRegional;
                            modulos.DescRegional   = listaParam[0].DescricaoRegional;

                            new BLL_Session(Convert.ToInt64(listaSenha[0].CodUsuario), out listaSenha);
                            modulos.CodUsuario     = listaSenha[0].CodUsuario;
                            modulos.CodPessoaUser  = listaSenha[0].CodPessoa;
                            modulos.NomePessoaUser = listaSenha[0].Nome;
                            modulos.Usuario        = listaSenha[0].Usuario;
                            modulos.Supervisor     = listaSenha[0].Supervisor;

                            apoio.preencheUsuarioCCB(listaSenha[0].CodUsuario);
                            apoio.preencheUsuarioCargo(listaSenha[0].CodUsuario);

                            FormPrincipal = new frmPrincipal();
                            FormPrincipal.Show();
                            Hide();
                        }
                        else
                        {
                            if (txtSenha.Text.Equals(string.Empty))
                            {
                                txtSenha.Text = string.Empty;
                                txtSenha.Focus();
                                throw new Exception("Olá " + lista[0].Usuario + ", por favor informe a senha!");
                            }
                            else
                            {
                                txtSenha.Text = string.Empty;
                                txtSenha.Focus();
                                throw new Exception("Olá " + lista[0].Usuario + ", a senha que você informou não confere!" + '\n' + "Por favor, tente novamente.");
                            }
                        }
                    }
                }
                else
                {
                    txtSenha.Text = string.Empty;
                    txtUsuario.Focus();
                    txtUsuario.SelectAll();
                    throw new Exception("Usuário não encontrado!" + '\n' + "Impossível logar no sistema.");
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }