private void frmLogin_FormClosing(object sender, FormClosingEventArgs e) { try { if (!Login && !String.IsNullOrEmpty(Acesso.NM_CONFIG)) { Acesso.NM_CONFIG_TEMP = Acesso.NM_CONFIG; HlpDbFuncoesGeral.NovaConexao(); Acesso.CarregaDadosBanco(); } } catch (Exception ex) { new HLPexception(ex); } }
private void btnSair_Click(object sender, EventArgs e) { try { errorProvider1.Dispose(); Erros = belValidaCampos.Validar(this.Controls, false); if (Erros == 0) { SalvarXml(); KryptonMessageBox.Show(null, "Todas as Alterações foram Salvas", Mensagens.MSG_Aviso, MessageBoxButtons.OK, MessageBoxIcon.Information); Acesso.CarregaDadosBanco(); if (daoUtil.VerificaConexaoOk()) { if (Acesso.USER_LOGADO) { Acesso.CarregaAcesso(); this.Close(); } else { Application.Restart(); } } else { KryptonMessageBox.Show(null, "Configuração de Conexão com o Banco de Dados é inválida.", Mensagens.MSG_Aviso, MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (Exception ex) { new HLPexception(ex); if (KryptonMessageBox.Show(null, "Deseja Sair sem Salvar ?", Mensagens.MSG_Alerta, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == System.Windows.Forms.DialogResult.Yes) { this.Close(); } } }
private void btnEntrar_Click(object sender, EventArgs e) { try { errorProvider1.Dispose(); if (txtUsuario.Text.Equals("")) { errorProvider1.SetError(txtUsuario, "Campo Obrigatório"); } else if (txtSenha.Text.Equals("")) { errorProvider1.SetError(txtSenha, "Campo Obrigatório"); } else { HlpDbFuncoesGeral.NovaConexao(); Acesso.CarregaDadosBanco(); string sUser = txtUsuario.Text.ToUpper().Trim().PadLeft(10, '0'); string sSenha = txtSenha.Text.ToUpper().Trim(); int iCountUser = Convert.ToInt32(HlpDbFuncoes.qrySeekValue("ACESSO", "count(acesso.CD_OPERADO)", "acesso.CD_OPERADO = '" + sUser + "'")); string sTipoUsuario = ""; if (iCountUser > 0) { StringBuilder sQuery = new StringBuilder(); if (Acesso.NM_RAMO != Acesso.BancoDados.TRANSPORTE) { sQuery.Append("select acesso.tp_operado, acesso.cd_senha, COALESCE(acesso.st_altera_dados_nfe,'S') st_altera_dados_nfe "); if (HlpDbFuncoes.fExisteCampo("ST_ACESSA_CONFIG_NFE", "ACESSO")) { sQuery.Append(", COALESCE(ACESSO.ST_ACESSA_CONFIG_NFE,'N')ST_ACESSA_CONFIG_NFE "); } else { sQuery.Append(", 'N' ST_ACESSA_CONFIG_NFE "); } sQuery.Append("from acesso "); sQuery.Append("where acesso.cd_senha = '" + belCriptografia.Encripta(sSenha) + "' "); sQuery.Append("and acesso.CD_OPERADO = '" + sUser + "'"); } else { sQuery.Append("select acesso.tp_operado, acesso.cd_senha "); sQuery.Append("from acesso "); sQuery.Append("where acesso.cd_senha = '" + belCriptografia.Encripta(sSenha) + "' "); sQuery.Append("and acesso.CD_OPERADO = '" + sUser + "'"); } DataTable dt = HlpDbFuncoes.qrySeekRet(sQuery.ToString()); foreach (DataRow dr in dt.Rows) { sTipoUsuario = dr["tp_operado"].ToString(); if (Acesso.NM_RAMO != Acesso.BancoDados.TRANSPORTE) { Acesso.bALTERA_DADOS = (dr["st_altera_dados_nfe"].ToString().Equals("N") ? false : true); Acesso.bALTER_CONFIG = (dr["ST_ACESSA_CONFIG_NFE"].ToString().Equals("S") ? true : false); } } if (sTipoUsuario != "") { Login = true; Acesso.NM_CONFIG = Acesso.NM_CONFIG_TEMP; Acesso.USER_LOGADO = true; Acesso.CarregaAcesso(); CarregaVariavesSistema(); Acesso.NM_USER = sUser; this.Close(); } else { errorProvider1.SetError(txtSenha, "Senha Incorreta"); txtSenha.Focus(); txtSenha.Text = ""; } } else { errorProvider1.SetError(txtUsuario, "Usuário Incorreto"); txtUsuario.Focus(); txtUsuario.Text = ""; } } } catch (Exception ex) { new HLPexception(ex); } }