private void btnAtualizar_Click(object sender, EventArgs e) { string senhaCriptografada = MD5Hash.CalcularHash(mskSenha.Text); pojoUsuario.setNome(txtNome.Text); pojoUsuario.setEmail(txtEmail.Text); pojoUsuario.setSenha(senhaCriptografada); pojoUsuario.setLogradouro(txtLogradouro.Text); pojoUsuario.setNumero(txtNumero.Text); pojoUsuario.setCep(mskCep.Text); pojoUsuario.setBairro(txtBairro.Text); pojoUsuario.setCidade(txtCidade.Text); pojoUsuario.setUf(txtUf.Text); pojoUsuario.setPais(txtPais.Text); switch (tipoUsuario) { case "PF": pojoPf.setCpf(mskCpf.Text); pojoPf.setDataNasc(mskDataNasc.Text); break; case "PJ": pojoPj.setCnpj(mskCnpj.Text); pojoPj.setInscricaoEstadual(mskInscEst.Text); pojoPj.setRazaoSocial(txtRazaoSocial.Text); pojoPj.setNomeFantasia(txtNomeFantasia.Text); break; case "FCN": pojoFcn.setCargo(txtCargo.Text); pojoFcn.setSetor(txtSetor.Text); pojoFcn.setTurno(txtTurno.Text); break; } usuarioDao.AtualizarUsuario(idUsuario, tipoUsuario, pojoUsuario, pojoPf, pojoPj, pojoFcn); BloquearControles(); }
private void btnInserir_Click(object sender, EventArgs e) { usuarioDao = new UsuarioDao(); string senhaCriptografada = MD5Hash.CalcularHash(mskSenha.Text); #region PojoUsuario pojoUsuario = new PojoUsuario(); pojoUsuario.setNome(txtNome.Text); pojoUsuario.setEmail(txtEmail.Text); pojoUsuario.setSenha(senhaCriptografada); pojoUsuario.setLogradouro(txtLogradouro.Text); pojoUsuario.setNumero(txtNumero.Text); pojoUsuario.setCep(mskCep.Text); pojoUsuario.setBairro(txtBairro.Text); pojoUsuario.setCidade(txtCidade.Text); pojoUsuario.setUf(txtUf.Text); pojoUsuario.setPais(txtPais.Text); #endregion switch (tipoUsuario) { case "PF": #region PojoPessoaFisica pojoPf = new PojoPessoaFisica(); pojoPf.setCpf(mskCpf.Text); pojoPf.setDataNasc(mskDataNasc.Text); pojoPf.setTipo(tipoUsuario); #endregion break; case "PJ": #region PojoPessoaJuridica pojoPj = new PojoPessoaJuridica(); pojoPj.setCnpj(mskCnpj.Text); pojoPj.setInscricaoEstadual(mskInscEst.Text); pojoPj.setRazaoSocial(txtRazaoSocial.Text); pojoPj.setNomeFantasia(txtNomeFantasia.Text); pojoPj.setTipo(tipoUsuario); #endregion break; case "FCN": #region PojoFuncionario pojoFcn = new PojoFuncionario(); pojoFcn.setCargo(txtCargo.Text); pojoFcn.setSetor(txtSetor.Text); pojoFcn.setTurno(txtTurno.Text); #endregion break; } response = usuarioDao.CadastrarUsuario(pojoUsuario, pojoPf, pojoPj, pojoFcn, tipoUsuario); if (response == 1) { MessageBox.Show(MessageSender.Positive.getMessage("sucessoCadastrar"), "Projeto Genesys", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show(MessageSender.Negative.getMessage("erroCadastrar"), "Projeto Genesys", MessageBoxButtons.OK, MessageBoxIcon.Information); } }