private void frmCMVGestaoAVista_Load(object sender, EventArgs e) { inicializado = false; DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao); BLLUsuario bllu = new BLLUsuario(cx); DTOUsuario modelou = bllu.CarregaModeloUsuario(Convert.ToInt32(idUsuario)); this.Text = this.Text + " - " + modelou.LoginUsuario.ToString() + " (" + modelou.IniciaisUsuario.ToString() + ")"; BLLUnidade bllun = new BLLUnidade(cx); cbUnidade.DataSource = bllun.ListarUnidades(); cbUnidade.DisplayMember = "cod_unidade"; cbUnidade.ValueMember = "id_unidade"; cbUnidade.Text = modelou.IdUnidade.ToString("00"); if (modelou.PermissaoUsuario < 4) { cbUnidade.Enabled = false; } DateTime data = DateTime.Today; numAno.Value = data.Year; CarregaMes(); inicializado = true; AtualizaPagina(); }
public void Login(string login, string senha) { ModeloUsuario modelo = new ModeloUsuario(); modelo.usu_login = login; modelo.usu_senha = senha; DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexão); BLLUsuario bll = new BLLUsuario(cx); BLLControlePermissao cbll = new BLLControlePermissao(cx); bll.UsuarioLogar(modelo).ToString(); if (modelo.usu_nome != "") { tssStatusLogin.Text = "USUÁRIO LOGADO: " + modelo.usu_nome; grbLogin.Visible = false; lklLogout.Visible = true; cbll.Localizar(modelo.usu_cod); PermissoesUsuario(); } else { tssStatusLogin.Text = "USUÁRIO OU SENHA INCORRETO "; txtLogin.Focus(); btnLogin.Enabled = false; } }
/// <summary> /// Reenviar senha /// </summary> /// <param name="sch"></param> /// <param name="e"></param> /// <returns></returns> public JsonResult json16(string sch, string e) { try { VerificaSessao(sch); var bll = new BLLUsuario(); var b = bll.RenovarSenha(e); if (b) { return(Json(new RetornoJsonPadrao("Um email com instruções foi enviado.", true, null))); } else { throw new Exception("Problemas ao reenviar a senha."); } } catch (Exception ex) { return(Json(new RetornoJsonPadrao(ex.Message, false, null))); } }
private void btLocalizar_Click(object sender, EventArgs e) { DAOConexao cx = new DAOConexao(DAOBanco.StringDeConexao); BLLUsuario bll = new BLLUsuario(cx); dgvDados.DataSource = bll.Localizar(txtValor.Text); }
private void frmEntrada_Load(object sender, EventArgs e) { dgvProdutos.Columns.Add(new DeleteColumn()); DALConexao con = new DALConexao(DadosDaConexao.StringDaConexao); BLLUsuario bllu = new BLLUsuario(con); DTOUsuario modelou = bllu.CarregaModeloUsuario(idUsuario); idUnidade = modelou.IdUnidade; permissaoUsuario = modelou.PermissaoUsuario; this.Text = this.Text + " - " + modelou.LoginUsuario.ToString() + " (" + modelou.IniciaisUsuario.ToString() + ")"; DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao); BLLUnidade bllun = new BLLUnidade(cx); cbUnidade.DataSource = bllun.Localizar(""); cbUnidade.DisplayMember = "cod_unidade"; cbUnidade.ValueMember = "id_unidade"; cbUnidade.Text = modelou.IdUnidade.ToString("00"); if (modelou.PermissaoUsuario < 4) { cbUnidade.Enabled = false; } this.AlteraBotoes(1); }
private void Localizar() { DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexão); BLLUsuario bll = new BLLUsuario(cx); dgvDados.DataSource = bll.LocalizarNome(txtValor.Text); }
protected void Page_Load(object sender, EventArgs e) { if (Session["login"] == null) { Session.RemoveAll(); Response.Redirect("../../Pages/Login.aspx"); } MODUsuario usuario = new MODUsuario(); usuario.Login = PegaLogin.RetornaLogin(); usuario = BLLUsuario.PesquisarLogin(usuario); ImagemUser.ImageUrl = "../../Pages/" + usuario.Imagem; ImagemUser2.ImageUrl = "../../Pages/" + usuario.Imagem; LblNome.Text = usuario.Nome; if (usuario.FkTipo == 1) { LblFuncao.Text = "Administrador"; } else { LblFuncao.Text = "Lider"; } if (!Page.IsPostBack) { CarregaGrupos(); CarregaProjetos(); } }
//------------------------------------------------------------------------------------------------------------------- private void btLocalizar_Click(object sender, EventArgs e) { try { frmConsultaUsuario fcusuario = new frmConsultaUsuario(); fcusuario.ShowDialog(); if (fcusuario.codigo != -1) { BLLUsuario bll = new BLLUsuario(); ModeloUsuario modelo = bll.carregaModelo(fcusuario.codigo); txtCodigo.Text = modelo.usu_cod.ToString(); txtTipoUsuario.Text = modelo.usu_nome.ToString(); txtSenha.Text = modelo.usu_senha.ToString(); txtEmail.Text = modelo.usu_email.ToString(); NUDTipoUsuario.Text = modelo.usu_tipo.ToString(); if (modelo.usu_ativo == true) { rbDesbloqueado.Checked = true; } if (modelo.usu_ativo == false) { rbBloqueado.Checked = true; } this.alteraBotoes(3); } fcusuario.Dispose(); }catch (Exception error) { MessageBox.Show(error.Message); } }
//------------------------------------------------------------------------------------------------------------------- private void frmPrincipal_Load(object sender, EventArgs e) { //MessageBox.Show("Tipo de Funcionario: " + Convert.ToString(v)); AtivarDesativar(admin.usu_tipo); BLLUsuario blluser = new BLLUsuario(); //ModeloLogin modelologin = blluser.carregaModeloLogin(v); tsslNomeUser.Text = admin.usu_nome.ToString(); //vefirica conexao com o banco try { StreamReader arquivo = new StreamReader("ConfiguracaoBanco.txt"); DALDadosDoBanco.servidor = arquivo.ReadLine(); DALDadosDoBanco.banco = arquivo.ReadLine(); DALDadosDoBanco.usuario = arquivo.ReadLine(); DALDadosDoBanco.senha = arquivo.ReadLine(); arquivo.Close(); //testar a conexao SqlConnection conexao = new SqlConnection(); conexao.ConnectionString = DALDadosDoBanco.stringDeConexao; conexao.Open(); conexao.Close(); } catch (SqlException errob) { MessageBox.Show("Erro ao se conectar no banco de dados \n" + "Acesse as configurações de banco do dados e informe os parâmetros de conexão", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception erros) { MessageBox.Show(erros.Message); } }
private void DefaultValues() { DALConexao con = new DALConexao(DadosDaConexao.StringDaConexao); BLLUnidade bllun = new BLLUnidade(con); BLLUsuario bllu = new BLLUsuario(con); DTOUsuario modelou = bllu.CarregaModeloUsuario(Convert.ToInt32(idUsuario)); cbUnidade.DataSource = bllun.ListarUnidades(); cbUnidade.DisplayMember = "cod_unidade"; cbUnidade.ValueMember = "id_unidade"; cbUnidade.Text = modelou.IdUnidade.ToString("00"); if (modelou.PermissaoUsuario < 4) { cbUnidade.Enabled = false; } unidade = Convert.ToInt32(cbUnidade.SelectedValue); LimpaCampos(); AlteraBotoes(); dgvFicha.Rows.Clear(); CarregaCat(); txtId.Clear(); }
private void frmCadastroFornecedores_Load(object sender, EventArgs e) { DALConexao con = new DALConexao(DadosDaConexao.StringDaConexao); BLLUsuario bllu = new BLLUsuario(con); DTOUsuario modelou = bllu.CarregaModeloUsuario(idUsuario); this.Text = this.Text + " - " + modelou.LoginUsuario.ToString() + " (" + modelou.IniciaisUsuario.ToString() + ")"; this.alteraBotoes(1); txtFantasia.GotFocus += txtFantasia_GotFocus; txtRazao.GotFocus += txtRazao_GotFocus; txtFone1.GotFocus += txtFone1_GotFocus; txtFone2.GotFocus += txtFone2_GotFocus; txtEmail1.GotFocus += txtEmail1_GotFocus; txtEmail2.GotFocus += txtEmail2_GotFocus; txtContato.GotFocus += txtContato_GotFocus; txtCnpj.GotFocus += txtCnpj_GotFocus; txtCep.GotFocus += txtCep_GotFocus; txtLogradouro.GotFocus += txtLogradouro_GotFocus; txtNumero.GotFocus += txtNumero_GotFocus; txtComplemento.GotFocus += txtComplemento_GotFocus; txtBairro.GotFocus += txtBairro_GotFocus; txtCidade.GotFocus += txtCidade_GotFocus; txtEstado.GotFocus += txtEstado_GotFocus; }
public GestionRoles() { InitializeComponent(); setup(); bllRol = new BLLRol(); bllUsuario = new BLLUsuario(); }
private void btLocalizar_Click(object sender, EventArgs e) { try { frmConsultaUsuario f = new frmConsultaUsuario(); f.ShowDialog(); if (f.codigo != 0) { DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao); BLLUsuario bll = new BLLUsuario(cx); ModeloUsuario modelo = bll.CarregaModeloUsuario(f.codigo); txtCodigo.Text = modelo.UsuId.ToString(); txtGrupo.Text = modelo.UsuGrupo; txtLogin.Text = modelo.UsuLogin; txtNome.Text = modelo.UsuNome; txtSenha.Text = modelo.UsuSenha; alterarBotoes(3, perInserir, perAlterar, perExcluir, perImprimir); } else { LimpaTela(); alterarBotoes(1, perInserir, perAlterar, perExcluir, perImprimir); } f.Dispose(); } catch (Exception erro) { MessageBox.Show("NÃO FOI POSSIVEL REALIZAR A OPERAÇÃO!\nERRO OCORRIDO:" + erro.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
private void DafaultValues() { pn01.Visible = false; liberado = false; CarregaMes(); DateTime data = DateTime.Today; numAno.Value = data.Year; DALConexao con = new DALConexao(DadosDaConexao.StringDaConexao); BLLUnidade bllun = new BLLUnidade(con); BLLUsuario bllu = new BLLUsuario(con); DTOUsuario modelou = bllu.CarregaModeloUsuario(Convert.ToInt32(idUsuario)); cbUnidade.DataSource = bllun.ListarUnidades(); cbUnidade.DisplayMember = "cod_unidade"; cbUnidade.ValueMember = "id_unidade"; cbUnidade.Text = modelou.IdUnidade.ToString("00"); if (modelou.PermissaoUsuario < 4) { cbUnidade.Enabled = false; } unidade = Convert.ToInt32(cbUnidade.SelectedValue); CarregaDgvs(); liberado = true; pn01.Visible = true; }
private void btSalvar_Click(object sender, EventArgs e) { try { //leitura dos dados ModeloUsuario modelo = new ModeloUsuario(); modelo.UsuNome = txtNome.Text; modelo.UsuLogin = txtLogin.Text; modelo.UsuGrupo = txtGrupo.Text; modelo.UsuSenha = txtSenha.Text; //obj para gravar os dados no banco DaoConexao cx = new DaoConexao(DadosDeConexao.StringDeConexao); BLLUsuario bll = new BLLUsuario(cx); if (this.operacao == "inserir") { //cadastrar uma cliente bll.Incluir(modelo); MessageBox.Show("Cadastro Efetuado com Sucesso!!!\n\n Código:" + modelo.UsuId.ToString(), "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { //alterar uma cliente modelo.UsuId = Convert.ToInt32(txtCodigo.Text); bll.Alterar(modelo); MessageBox.Show("Cadastro Alterado com Sucesso!!!\n\n Código:" + modelo.UsuId.ToString(), "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information); } this.LimpaTela(); this.alteraBotoes(1); } catch (Exception erro) { MessageBox.Show("Não foi possivel Realizar a Operação!!!\n\n Contate o Administrador do Sistema!!!\n\nErro Ocorrido:" + erro.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btSalvar_Click(object sender, EventArgs e) { try { ModeloUsuario modelo = new ModeloUsuario(); modelo.UsuGrupo = txtGrupo.Text; modelo.UsuNome = txtNome.Text; modelo.UsuSenha = txtSenha.Text; modelo.UsuLogin = txtLogin.Text; DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao); BLLUsuario bll = new BLLUsuario(cx); if (operacao == "inserir") { //CADASTRO DO USUÁRIO bll.Incluir(modelo); MessageBox.Show("CADASTRO EFETUADO COM SUCESSO !! CÓDIGO:" + modelo.UsuId.ToString(), "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { //Alterar os Dados modelo.UsuId = Convert.ToInt32(txtCodigo.Text); bll.Alterar(modelo); MessageBox.Show("CADASTRO ALTERADO COM SUCESSO !! CÓDIGO:" + modelo.UsuId.ToString(), "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information); } LimpaTela(); alterarBotoes(1, perInserir, perAlterar, perExcluir, perImprimir); } catch (Exception erro) { MessageBox.Show("NÃO FOI POSSIVEL REALIZAR A OPERAÇÃO! \n ERRO OCORRIDO:" + erro.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
private void frmConsultaInventario_Load(object sender, EventArgs e) { DALConexao con = new DALConexao(DadosDaConexao.StringDaConexao); BLLUsuario bllu = new BLLUsuario(con); DTOUsuario modelou = bllu.CarregaModeloUsuario(idUsuario); this.Text = this.Text + " - " + modelou.LoginUsuario.ToString() + " (" + modelou.IniciaisUsuario.ToString() + ")"; DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao); BLLUnidade bllun = new BLLUnidade(cx); cbUnidade.DataSource = bllun.Localizar(""); cbUnidade.DisplayMember = "cod_unidade"; cbUnidade.ValueMember = "id_unidade"; cbUnidade.Text = modelou.IdUnidade.ToString("00"); if (modelou.PermissaoUsuario < 4) { cbUnidade.Enabled = false; } DateTime Hoje = DateTime.Today; cbAbertos.Checked = true; txtDataDe.GotFocus += txtDataDe_GotFocus; txtDataA.GotFocus += txtDataA_GotFocus; txtNumero.GotFocus += txttxtNumero_GotFocus; dgvInventario.Columns.Add(new DeleteColumn()); }
private void Conecta() { try { DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao); DALUsuario usuario = new DALUsuario(cx); BLLUsuario bllu = new BLLUsuario(cx); DataTable dt = bllu.LocalizarIp(bllu.IpLocal()); if (dt.Rows[0][0].ToString() == "1") { txtId.Text = Convert.ToString(dt.Rows[0][1]); txtUsuario.Text = Convert.ToString(dt.Rows[0][2]); txtLogin.Text = Convert.ToString(dt.Rows[0][3]); txtSenha.Text = Convert.ToString(dt.Rows[0][4]); txtIniciais.Text = Convert.ToString(dt.Rows[0][5]); txtUnidade.Text = Convert.ToString(dt.Rows[0][6]); txtPermissao.Text = Convert.ToString(dt.Rows[0][7]); txtEmail.Text = Convert.ToString(dt.Rows[0][8]); txtNomeUnidade.Text = Convert.ToString(dt.Rows[0][9]); this.PreencheCampos(); } } catch { this.Loga(); } }
private void DefaultValues() { DALConexao con = new DALConexao(DadosDaConexao.StringDaConexao); BLLUnidade bllun = new BLLUnidade(con); BLLUsuario bllu = new BLLUsuario(con); DTOUsuario modelou = bllu.CarregaModeloUsuario(Convert.ToInt32(idUsuario)); cbUnidade.DataSource = bllun.ListarUnidades(); cbUnidade.DisplayMember = "cod_unidade"; cbUnidade.ValueMember = "id_unidade"; cbUnidade.Text = modelou.IdUnidade.ToString("00"); if (modelou.PermissaoUsuario < 4) { cbUnidade.Enabled = false; } unidade = Convert.ToInt32(cbUnidade.SelectedValue); txtId.Clear(); txtNome.Clear(); dgvCat.Rows.Clear(); lbNome.Text = "Nome " + tipo; lbDesc.Text = "Descrição " + tipo; }
protected void Page_Load(object sender, EventArgs e) { MODReuniao reuniao = new MODReuniao(); if (Session["login"] == null) { Session.RemoveAll(); Response.Redirect("../Pages/Login.aspx"); } MODUsuario usuario = new MODUsuario(); usuario.Login = PegaLogin.RetornaLogin(); usuario = BLLUsuario.PesquisarLogin(usuario); ImagemUser.ImageUrl = "../Pages/" + usuario.Imagem; ImagemUser2.ImageUrl = "../Pages/" + usuario.Imagem; LblNome.Text = usuario.Nome; if (usuario.FkTipo == 1) { LblFuncao.Text = "Administrador"; } else { LblFuncao.Text = "Lider de Pesquisa"; } if (!IsPostBack) { RptConsulta.DataSource = BLLReuniao.Pesquisar(reuniao, "todos"); RptConsulta.DataBind(); } }
private void btLocalizar_Click(object sender, EventArgs e) { try { frmConsultaUsuario f = new frmConsultaUsuario(); f.ShowDialog(); if (f.codigo != 0) { DaoConexao cx = new DaoConexao(DadosDeConexao.StringDeConexao); BLLUsuario bll = new BLLUsuario(cx); ModeloUsuario modelo = bll.CarregaModeloUsuario(f.codigo); txtCodigo.Text = modelo.UsuId.ToString(); txtNome.Text = modelo.UsuNome; txtLogin.Text = modelo.UsuLogin; txtGrupo.Text = modelo.UsuGrupo; txtSenha.Text = modelo.UsuSenha; this.alteraBotoes(3); } else { this.LimpaTela(); this.alteraBotoes(1); } f.Dispose(); } catch (Exception erro) { MessageBox.Show("Não foi possivel Realizar a Operação!!!\n\n Contate o Administrador do Sistema!!!\n\nErro Ocorrido:" + erro.Message, "Erro", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
protected void Page_Load(object sender, EventArgs e) { if (Session["login"] == null) { Session.RemoveAll(); Response.Redirect("../Pages/Login.aspx"); } MODUsuario usuario = new MODUsuario(); usuario.Login = PegaLogin.RetornaLogin(); usuario = BLLUsuario.PesquisarLogin(usuario); ImagemUser.ImageUrl = "../Pages/" + usuario.Imagem; ImagemUser2.ImageUrl = "../Pages/" + usuario.Imagem; LblNome.Text = usuario.Nome; if (usuario.FkTipo == 1) { LblFuncao.Text = "Administrador"; } else { LblFuncao.Text = "Lider de Pesquisa"; } MODArea_Conhecimento areaConhecimento = new MODArea_Conhecimento(); List <MODArea_Conhecimento> lista = new List <MODArea_Conhecimento>(); lista = BLLLinha_Pesquisa.PesquisarAreaConhecimento(areaConhecimento, "todas"); RptConsulta.DataSource = lista; RptConsulta.DataBind(); }
private void frmCadastroSetor_Load(object sender, EventArgs e) { DALConexao con = new DALConexao(DadosDaConexao.StringDaConexao); BLLUsuario bllu = new BLLUsuario(con); DTOUsuario modelou = bllu.CarregaModeloUsuario(IdUsuario); IdUnidadeUser = modelou.IdUnidade; this.Text = this.Text + " - " + modelou.LoginUsuario.ToString() + " (" + modelou.IniciaisUsuario.ToString() + ")"; if (modelou.PermissaoUsuario < 4) { cbUnidade.Text = modelou.IdUnidade.ToString("00"); cbUnidade.Enabled = false; } else { DALConexao cx = new DALConexao(DadosDaConexao.StringDaConexao); BLLUnidade bll = new BLLUnidade(cx); cbUnidade.DataSource = bll.Localizar(""); cbUnidade.DisplayMember = "cod_unidade"; cbUnidade.ValueMember = "cod_unidade"; cbUnidade.Text = IdUnidadeUser.ToString(); } alteraBotoes(2); this.operacao = "inserir"; this.CarregaDados(); carregaUnidade = 1; }
protected void BtnAlterar_Click(object sender, EventArgs e) { MODUsuario usuario = new MODUsuario(); Criptografia cripto = new Criptografia(); EnviaEmail enviaEmail = new EnviaEmail(); string senha = ""; bool senhaForte = ValidaSenhaForte.ValidaSenha(TxtSenha.Text.Trim()); if (senhaForte == false) { LblResposta.Text = Erros.SenhaFraca; } else if (TxtSenha.Text.Trim() == "" || TxtSenha.Text.Length > 12) { LblResposta.Text = Erros.SenhaVazio; } else { try { senha = TxtSenha.Text.Trim(); usuario.Senha = cripto.criptografia(senha); usuario.Login = Page.Request.QueryString["login"]; BLLUsuario.AlterarSenha2(usuario); LblResposta.Text = "Senha alterado com sucesso!"; } catch (Exception) { Response.Write("<script>alert('Erro ao inserir!');</script>"); throw; } } }
public GestionNutricionista() { InitializeComponent(); setup(); bllUsuario = new BLLUsuario(); bllNutricionista = new BLLNutricionista(); }
//------------------------------------------------------------------------------------------------------------------- private void btSalvar_Click(object sender, EventArgs e) { if (txtSenha.Text == txtRepitaSenha.Text) { lbSenhasDiferentes.Visible = false; try { BLLUsuario bll = new BLLUsuario(); ModeloUsuario modelo = new ModeloUsuario(); modelo.usu_nome = txtTipoUsuario.Text; modelo.usu_senha = txtSenha.Text; modelo.usu_email = txtEmail.Text; modelo.usu_tipo = Convert.ToInt32(NUDTipoUsuario.Text); if (rbBloqueado.Checked == true) { pbBlock.Visible = true; modelo.usu_ativo = false; } else { pbBlock.Visible = false; } if (rbDesbloqueado.Checked == true) { pbUnlock.Visible = true; modelo.usu_ativo = true; } else { pbUnlock.Visible = false; } if (this.operacao == "inserir") { bll.Incluir(modelo); MessageBox.Show("Registro incluido com sucesso \n Código Gerado: " + modelo.usu_cod, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { modelo.usu_cod = Convert.ToInt32(txtCodigo.Text); bll.Alterar(modelo); MessageBox.Show("Registro alterado com sucesso", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information); } this.alteraBotoes(1); this.limpaTela(); } catch (Exception erro) { MessageBox.Show(erro.Message); } } else { lbSenhasDiferentes.Visible = true; //MessageBox.Show("As senhas não correspondem, por favor, digite novamente!"); txtRepitaSenha.Focus(); txtRepitaSenha.Clear(); } }
private void btLocalizar_Click(object sender, EventArgs e) { DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao); BLLUsuario bll = new BLLUsuario(cx); dgvDados.DataSource = bll.Localizar(txtValor.Text); CarregaTituloDgv(); }
//------------------------------------------------------------------------------------------------------------------- private void btLocalizar_Click(object sender, EventArgs e) { BLLUsuario bll = new BLLUsuario(); dgvDados.DataSource = bll.ListagemComFiltro(txtValor.Text); txtValor.Clear(); txtValor.Focus(); }
private void btLocalizar_Click(object sender, EventArgs e) { DaoConexao cx = new DaoConexao(DadosDeConexao.StringDeConexao); BLLUsuario bll = new BLLUsuario(cx); dgvDados.DataSource = bll.Localizar(txtValor.Text); this.AtualizaCabeçalhoDGridUsuario(); }
private void txtSenha_KeyDown(object sender, KeyEventArgs e) { try { if (e.KeyCode == Keys.Enter && !String.IsNullOrEmpty(txtSenha.Text)) { StreamReader arquivo = new StreamReader("ConfiguracaoBanco.txt"); DadosDaConexao.servidor = arquivo.ReadLine(); DadosDaConexao.banco = arquivo.ReadLine(); DadosDaConexao.usuario = arquivo.ReadLine(); DadosDaConexao.senha = arquivo.ReadLine(); arquivo.Close(); //testar a conexao SqlConnection conexao = new SqlConnection(); conexao.ConnectionString = DadosDaConexao.StringDeConexao; conexao.Open(); conexao.Close(); DALConexao cx = new DALConexao(DadosDaConexao.StringDeConexao); BLLUsuario bll = new BLLUsuario(cx); ModeloUsuario modelo = bll.CarregaModeloUsuario(txtUser.Text, txtSenha.Text); vUsuario = modelo.NomeUser.ToString(); vSenha = modelo.SenhaUser.ToString(); Perfil = modelo.PerfilUser; PerfilTed = modelo.PerfilUser; if (this.txtUser.Text == vUsuario && this.txtSenha.Text == vSenha) { Logado = true; Usuario = txtUser.Text; Perfil = modelo.PerfilUser; PerfilTed = modelo.PerfilTed; //Salvar o nome de usuário nas configurações do aplicativo Properties.Settings.Default.Usuario = txtUser.Text; Properties.Settings.Default.Perfil = modelo.PerfilUser; Properties.Settings.Default.PerfilTed = modelo.PerfilUser; Properties.Settings.Default.Save(); this.Close(); } else { MessageBox.Show("Login inválido", "Atenção"); } } } catch (SqlException errob) { MessageBox.Show("Erro ao se conectar no banco de dados \n" + "Acesse as configurações do banco de dados e informe os parâmetros de conexao"); } catch (Exception erros) { MessageBox.Show(erros.Message); frmConfiguracaoBancoDados f = new frmConfiguracaoBancoDados(); f.ShowDialog(); f.Dispose(); } }
private void btnMudarSenha_Click(object sender, EventArgs e) { try { //leitura dos dados para verificar CPF ModeloUsuario validacpflogin = new ModeloUsuario(); validacpflogin.UsuCpf = txtCPF.Text; validacpflogin.UsuLogin = txtEsqueceLogin.Text; //leitura dos dados para mudar senha ModeloUsuario mudarsenha = new ModeloUsuario(); mudarsenha.UsuSenha = txtEsqueceSenha.Text; mudarsenha.UsuCpf = txtCPF.Text; //obj para gravar os dados no banco DALConexao cx = new DALConexao(DadosConexao.StringDeConexao); BLLUsuario bll = new BLLUsuario(cx); if (bll.VerificarCPFLogin(validacpflogin)) { bll.VerificarCPFLogin(validacpflogin); if (bll.AlterarSenha(mudarsenha)) { bll.AlterarSenha(mudarsenha); lbAlteradaSucesso.Visible = true; } else { MessageBox.Show("O CPF ou Login é inválido", "Verifique", MessageBoxButtons.OK); } } else { MessageBox.Show("O CPF ou Login é inválido", "Verifique", MessageBoxButtons.OK); } } catch (Exception erro) { MessageBox.Show(erro.Message); } }
private void btnEntrar_Click(object sender, EventArgs e) { //leitura dos dados ModeloUsuario modelo = new ModeloUsuario(); modelo.UsuLogin = txtLogin.Text; modelo.UsuSenha = txtSenha.Text; DALConexao cx = new DALConexao(DadosConexao.StringDeConexao); BLLUsuario bll = new BLLUsuario(cx); if (bll.AutenticarUsuario(modelo)) { this.Hide(); frmPrincipal f = new frmPrincipal(); f.ShowDialog(); f.Dispose(); this.Close(); } else { MessageBox.Show("Usuário ou Senha inválidos", "Verifique", MessageBoxButtons.OK); } }