Example #1
0
        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);
            }
        }
Example #2
0
        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);
            }
        }
Example #3
0
        //-------------------------------------------------------------------------------------------------------------------
        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();
            }
        }
Example #4
0
        private void btSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                // 0 - Gerente
                // 1 - Atendente
                // 2 - Caixa
                int perfil = 0;

                if (rbtGerente.Checked == true)
                {
                    perfil = 1;
                }
                if (rbtAtendente.Checked == true)
                {
                    perfil = 2;
                }
                if (rbtCaixa.Checked == true)
                {
                    perfil = 3;
                }
                if (rdbSeparador.Checked == true)
                {
                    perfil = 4;
                }

                ModeloUsuario modelo = new ModeloUsuario();
                modelo.NomeUser   = txtLogin.Text;
                modelo.SenhaUser  = txtSenha.Text;
                modelo.PerfilUser = Convert.ToInt32(perfil);
                DALConexao cx  = new DALConexao(DadosDaConexao.StringDeConexao);
                BLLUsuario bll = new BLLUsuario(cx);
                if (this.operacao == "inserir")
                {
                    bll.Incluir(modelo);
                    MessageBox.Show("Cadastro efetuado com sucesso");
                }
                else
                {
                    //alterar uma categoria
                    modelo.CodUser    = Convert.ToInt32(txtCodUser.Text);
                    modelo.SenhaUser  = txtSenha.Text;
                    modelo.PerfilUser = Convert.ToInt32(perfil);
                    bll.Alterar(modelo);
                    MessageBox.Show("Cadastro alterado");
                }
                this.LimpaTela();
                this.alteraBotoes(1);
            }
            catch (Exception erro)
            {
                MessageBox.Show(erro.Message);
            }
        }
Example #5
0
 private void btnSalvar_Click(object sender, EventArgs e)
 {
     try
     {
         ModeloUsuario modelo = new ModeloUsuario()
         {
             usu_nome          = txtNome.Text,
             usu_cpf           = mktCpfCnpj.Text,
             usu_rg            = mktRgIe.Text,
             usu_cep           = mktCep.Text,
             usu_estado        = cbxEstado.Text,
             usu_sgl           = cbxSgl.Text,
             usu_cidade        = cbxCidade.Text,
             usu_bairro        = cbxBairro.Text,
             usu_logradouro    = cbxLogradouro.Text,
             usu_numero        = txtNumero.Text,
             usu_complemento   = txtComplemento.Text,
             usu_email         = txtEmail.Text,
             usu_telefone      = mktTelefone.Text,
             usu_celular       = mktCelular.Text,
             usu_login         = txtLogin.Text,
             usu_senha         = txtSenha.Text,
             usu_lembretesenha = txtLembreteSenha.Text
         };
         DALConexao cx  = new DALConexao(DadosDaConexao.StringDeConexão);
         BLLUsuario bll = new BLLUsuario(cx);
         if (txtCodigo.Text == "")
         {
             bll.Inserir(modelo);
             CadastraPermissao(modelo.usu_cod);
             Mensagem("USUÁRIO INSERIDO CÓDIGO: " + modelo.usu_cod, Color.Blue);
         }
         else
         {
             modelo.usu_cod = Convert.ToInt32(txtCodigo.Text);
             bll.Alterar(modelo);
             CadastraPermissao(modelo.usu_cod);
             Mensagem("USUÁRIO ATUALIZADO COM SUCESSO ", Color.Blue);
             //AtulizaMenu();
         }
         LimpaTela();
         alteraBotoes();
     }
     catch (Exception erro)
     {
         Erro(erro.Message);
     }
 }
Example #6
0
        private void btSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                //leitura dos dados
                ModeloUsuario modelo = new ModeloUsuario();
                modelo.UsuNome    = txtNome.Text;
                modelo.UsuUsuario = txtUsuario.Text;
                modelo.UsuSenha   = txtSenha.Text;
                modelo.RegraNivel = cbNivelAcesso.SelectedItem.ToString();


                //obj para gravar os dados no banco
                DAOConexao cx  = new DAOConexao(DAOBanco.StringDeConexao);
                BLLUsuario bll = new BLLUsuario(cx);
                if (this.operacao == "inserir")
                {
                    //cadastrar uma categoria
                    modelo.CarregaImagem(this.foto);
                    bll.Incluir(modelo);
                    MessageBox.Show("Cadastro efetuado: Código " + modelo.UsuCod.ToString());
                }
                else
                {
                    //alterar uma categoria
                    modelo.UsuCod = Convert.ToInt32(txtCodigo.Text);
                    if (this.foto == "Foto Original")
                    {
                        ModeloUsuario mt = bll.CarregaModeloUsuario(modelo.UsuCod);
                        modelo.UsuFoto = mt.UsuFoto;
                    }
                    else
                    {
                        modelo.CarregaImagem(this.foto);
                    }

                    bll.Alterar(modelo);
                    MessageBox.Show("Cadastro alterado");
                }
                this.LimpaTela();
                this.alteraBotoes(1);
            }
            catch (Exception erro)
            {
                MessageBox.Show(erro.Message);
            }
        }
        private void BtnGravar_Click(object sender, EventArgs e)
        {
            try
            {
                ModelUsuario modelo = new ModelUsuario();
                modelo.Nome        = txtNomeUsu.Text;
                modelo.Senha       = txtSenha.Text;
                modelo.NivelAcesso = Convert.ToString(cbNivelAcesso.SelectedItem);
                if (chbAtivo.Checked == true)
                {
                    modelo.Situacao = "A";
                }
                else if (chbAtivo.Checked == false)
                {
                    modelo.Situacao = "I";
                }

                DALConexao cx  = new DALConexao(DadosDaConexao.StringDeConexao);
                BLLUsuario bll = new BLLUsuario(cx);
                if (txtCodigo.Text == "")
                {
                    bll.Incluir(modelo);
                    MessageBox.Show("Cadastro efetuado: Código " + modelo.IdUsuario.ToString(), "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    modelo.IdUsuario = Int32.Parse(txtCodigo.Text);
                    bll.Alterar(modelo);
                    MessageBox.Show("Cadastro alterado com sucesso!", "Informação", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                this.LimpaTela();
            }
            catch (Exception erro)
            { MessageBox.Show(erro.Message); }
        }
        protected void BtnAlterar_Click(object sender, EventArgs e)
        {
            MODUsuario   usuario    = new MODUsuario();
            Criptografia cripto     = new Criptografia();
            EnviaEmail   enviaEmail = new EnviaEmail();
            string       senha      = "";
            string       extensao   = Path.GetExtension(FUFoto.FileName);
            bool         senhaForte = ValidaSenhaForte.ValidaSenha(TxtSenha.Text.Trim());

            if (senhaForte == false)
            {
                LblResposta.Text = Erros.SenhaFraca;
            }
            else if (!FUFoto.HasFile)
            {
                LblResposta.Text = Erros.FotoVazio;
            }
            else if (extensao != ".jpg" && extensao != ".jpeg" && extensao != ".png" && extensao != ".bmp")
            {
                LblResposta.Text = "Arquivo de foto inválido, utilize fotos nas seguintes extensões: .jpg/.jpeg/.png/.bmp";
            }
            else if (TxtLattes.Text.Trim() == "" || TxtLattes.Text.Length > 70)
            {
                LblResposta.Text = Erros.LattesVazio;
            }
            else if (TxtSenha.Text.Trim() == "" || TxtSenha.Text.Length > 12)
            {
                LblResposta.Text = Erros.SenhaVazio;
            }
            else if (TxtSenha2.Text.Trim() == "" || TxtSenha2.Text.Length > 12)
            {
                LblResposta.Text = Erros.Senha2Vazio;
            }
            else if (TxtSenha.Text.Trim() != TxtSenha2.Text.Trim())
            {
                LblResposta.Text = Erros.SenhaInvalida;
            }
            else
            {
                try
                {
                    string foto = "Imagens/" + PegaLogin.RetornaLogin() + extensao;
                    if (File.Exists(Server.MapPath(foto)))
                    {
                        File.Delete(Server.MapPath(foto));
                    }

                    this.FUFoto.SaveAs(Server.MapPath("Imagens/" + FUFoto.FileName));

                    System.IO.File.Move(Server.MapPath("Imagens/" + FUFoto.FileName), Server.MapPath("Imagens/" + PegaLogin.RetornaLogin() + extensao));
                    usuario.Imagem = "Imagens/" + PegaLogin.RetornaLogin() + extensao;

                    usuario.Login        = PegaLogin.RetornaLogin();
                    usuario.Lattes       = TxtLattes.Text.Trim();
                    usuario.DataCadastro = Convert.ToDateTime(DateTime.Now.ToShortDateString());

                    if (TxtSenha.Text.Trim() == TxtSenha2.Text.Trim())
                    {
                        senha = TxtSenha.Text.Trim();
                    }

                    usuario.Senha          = cripto.criptografia(senha);
                    usuario.PrimeiroAcesso = 'n';

                    BLLUsuario.Alterar(usuario);

                    LblResposta.Text = "Usuário alterado com sucesso!";
                }
                catch (Exception)
                {
                    Response.Write("<script>alert('Erro ao inserir!');</script>");
                    throw;
                }
            }
        }
        private void btSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                //leitura dos dados
                DTOUsuario modelo = new DTOUsuario();
                modelo.NomeUsuario  = txtNome.Text;
                modelo.LoginUsuario = txtLogin.Text;

                modelo.SenhaUsuario = "dado@" + DateTime.Now.Year;

                modelo.IniciaisUsuario = txtIniciais.Text;
                modelo.EmailUsuario    = txtemail.Text;

                if (CbNivel.Text == "Visualizador")
                {
                    NvAcesso = 1;
                }
                else if (CbNivel.Text == "Operador")
                {
                    NvAcesso = 2;
                }
                else if (CbNivel.Text == "Líder")
                {
                    NvAcesso = 3;
                }
                else if (CbNivel.Text == "Administrador")
                {
                    NvAcesso = 4;
                }
                modelo.PermissaoUsuario = NvAcesso;

                modelo.IdUnidade = Convert.ToInt32(cbUnidade.Text);


                //conexão
                DALConexao cx  = new DALConexao(DadosDaConexao.StringDaConexao);
                BLLUsuario bll = new BLLUsuario(cx);

                if (this.operacao == "inserir")
                {
                    // cadastra usuario
                    bll.Incluir(modelo);
                    MessageBox.Show("Cadastro efetuado com sucesso. Usuário: " + modelo.LoginUsuario.ToString() + ".");
                    this.LimpaCampos();
                    this.alteraBotoes(1);
                }
                else
                {
                    // altera fornecedor
                    modelo.IdUsuario = Convert.ToInt32(txtIdUsuario.Text);
                    bll.Alterar(modelo);
                    MessageBox.Show("Cadastro alterado com sucesso. Usuário: " + modelo.LoginUsuario.ToString() + ".");
                    this.LimpaCampos();
                    this.alteraBotoes(1);
                }
            }
            catch (Exception erro)
            {
                MessageBox.Show(erro.Message);
            }
        }