Example #1
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            string sError = "";

            lblError.Text = "";

            if (txtUsuario.Text != "" && txtContrasenia.Text != "")
            {
                oUsuario oUsuario = new oUsuario();
                nUsuario nUsuario = new nUsuario();

                oUsuario.usuario  = txtUsuario.Text;
                oUsuario.password = txtContrasenia.Text;

                sError = nUsuario.Validar(ref oUsuario);
                if (sError == "")
                {
                    Session["usuario"] = oUsuario;
                    Response.Redirect("default.aspx");
                }
                else
                {
                    lblError.Text = sError;
                }
            }
        }
Example #2
0
        private void btnAceptar_Click_1(object sender, EventArgs e)
        {
            string usuario     = this.txtUsuario.Text;
            string contrasena  = this.txtPassword.Text;
            int    tipousuario = 0;

            if (usuario != String.Empty && contrasena != String.Empty)
            {
                tipousuario = new nUsuario().GetValidaUsuario(usuario, contrasena);
                if (tipousuario == 1)
                {
                    this.obMenuAd.Show();
                    this.Hide();
                }
                else if (tipousuario != 1)
                {
                    MessageBox.Show("Acceso no Permitido");
                    LimpiaTexto();
                }
            }
            else
            {
                MessageBox.Show("Favor Ingresar Información");
                LimpiaTexto();
            }
        }
Example #3
0
        protected void btnSalvar_Click(object sender, EventArgs e)
        {
            nUsuario usr = new nUsuario();

            usr.Nome     = txtNome.Text;
            usr.Email    = txtEmail.Text;
            usr.Cpf      = txtCPF.Text;
            usr.DataNasc = txtDataNasc.Text;
            usr.Sexo     = rblSexo.SelectedValue;

            string erro = "";

            if (Session["usuarioID"] != null && !String.IsNullOrEmpty(Session["usuarioID"].ToString()))
            {
                usr.Id = Convert.ToInt32(Session["usuarioId"]);
                erro   = usr.AlterarUsuario();
            }
            else
            {
                usr.Senha = txtSenha.Text;
                //erro = usr.AdicionarUsuario();
            }
            LimparCampos();

            if (erro == "")
            {
                divSucesso.Style.Value = "display:block;";
                divErro.Style.Value    = "display:none;";
            }
            else
            {
                divSucesso.Style.Value = "display:none;";
                divErro.Style.Value    = "display:block;";
            }
        }
Example #4
0
        protected void gvUsuarios_Load(object sender, EventArgs e)
        {
            nUsuario  u = new nUsuario();
            DataTable d = u.ConsultarUsuario();

            gvUsuarios.DataSource = d;
            gvUsuarios.DataBind();
        }
Example #5
0
        protected void btnConsultar_ServerClick(object sender, EventArgs e)
        {
            nUsuario objU = new nUsuario
            {
                cd_perfil = Convert.ToInt32(ddlPerfilPesquisa.SelectedValue),
                ds_nome   = txtNomePesquisa.Value,
                v_login   = txtLoginPesquisa.Value
            };

            DataSet ds = objU.EfetuarConsulta();

            popularGrid(gvDados, ds.Tables[0]);
        }
Example #6
0
        protected void Recupera()
        {
            int i;

            nUsuario u = new nUsuario();

            i = Convert.ToInt32(Session["S_idUsuario"]);

            u.BuscarUsuario(i);

            lbId.InnerText = Session["S_idUsuario"].ToString();
            tbNome.Value   = u.NomeUsuario;
            tbemail.Value  = u.EmailUsuario;
        }
Example #7
0
        protected void btSalvarUsuario_Click(object sender, EventArgs e)
        {
            string senhaEncriptografada = Encriptacao.Encriptar(tbSenha.Value);

            nUsuario u = new nUsuario
            {
                EmailUsuario = tbemail.Value,
                NomeUsuario  = tbNome.Value,
                SenhaUsuario = senhaEncriptografada
            };

            u.Salvar();

            Response.Redirect("Default.aspx");
        }
Example #8
0
        protected void gvUsuarios_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "Editar")
            {
                Session["S_idUsuario"] = e.CommandArgument;

                Response.Redirect("Usuario.aspx");
            }
            else if (e.CommandName == "Excluir")
            {
                nUsuario u = new nUsuario
                {
                    IdUsuario = Convert.ToInt32(e.CommandArgument)
                };

                u.Excluir();

                Response.Redirect("ListaUsuarios.aspx");
            }
        }
Example #9
0
        protected void gvDados_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "EDITAR")
            {
                nUsuario objU = new nUsuario((int)(((GridView)sender).DataKeys[Convert.ToInt32(e.CommandArgument)]).Value);

                v_place_holder_ativo = e_place_holder_ativo.Editar;

                txtNomeInclusao.Value           = objU.ds_nome;
                txtLoginInclusao.Value          = objU.v_login;
                txtSenhaInclusao.Value          = objU.v_senha;
                hdnCdUsuario.Value              = objU.cd_usuario.ToString();
                ddlPerfilInclusao.SelectedValue = objU.cd_perfil.ToString();
            }
            else if (e.CommandName == "EXCLUIR")
            {
                nUsuario objU = new nUsuario
                {
                    cd_usuario  = (int)(((GridView)sender).DataKeys[Convert.ToInt32(e.CommandArgument)]).Value,
                    fg_excluido = true
                };
                if (objU.cd_usuario == c_cd_usuario_logado)
                {
                    ExibirMensagem("Não é possível excluir o usuário que está logado.");
                }
                else
                {
                    try
                    {
                        objU.EfetuarAtualizacao(c_cd_usuario_logado);
                        ExibirMensagem("Efetuada exclusão do usuário " + objU.v_login + " com sucesso.");

                        btnConsultar_ServerClick(null, null);
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
        }
Example #10
0
        protected void btAlterarUsuario_Click(object sender, EventArgs e)
        {
            nUsuario u = new nUsuario();

            u.IdUsuario    = Convert.ToInt32(lbId.InnerText);
            u.EmailUsuario = tbemail.Value;
            u.NomeUsuario  = tbNome.Value;
            u.SenhaUsuario = tbSenha.Value;

            if (chSituacao.Checked)
            {
                u.SituacaoUsuario = "S";
            }
            else
            {
                u.SituacaoUsuario = "N";
            }

            u.Atualizar();

            Response.Redirect("Default.aspx");
        }
Example #11
0
        protected void btLogin_Click(object sender, EventArgs e)
        {
            nUsuario nUsuario = new nUsuario
            {
                EmailUsuario = tbEmail.Text,
                SenhaUsuario = tbSenha.Text
            };

            string nomeUsuario = nUsuario.ConsultaLogin(nUsuario.EmailUsuario, nUsuario.SenhaUsuario);

            if (nomeUsuario == "")
            {
                Response.Redirect("Default.aspx");
            }

            int idUsuario = nUsuario.ConsultaIdUsuario(nUsuario.EmailUsuario, nUsuario.SenhaUsuario);

            Session["S_nomeUsuario"] = nomeUsuario;
            Session["I_idUsuario"]   = idUsuario;

            Response.Redirect("Default.aspx");
        }
Example #12
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (txtPassword.Text == txtConfirmar.Text)
     {
         nUsuario obUsuario = new nUsuario();
         obUsuario.Nombre     = txtNombre.Text;
         obUsuario.User       = txtUser.Text;
         obUsuario.Contraseña = txtPassword.Text;
         if (cmbTipo.SelectedValue.ToString() == "Administrador")
         {
             obUsuario.Idtipo = 1;
         }
         if (cmbTipo.SelectedValue.ToString() == "Usuario")
         {
             obUsuario.Idtipo = 2;
         }
         if (cmbTipo.SelectedValue.ToString() == "Jefe de Patio")
         {
             obUsuario.Idtipo = 3;
         }
         if (cmbTipo.SelectedValue.ToString() == "Jefe de Bodega")
         {
             obUsuario.Idtipo = 4;
         }
         obUsuario.crearUsuario();
         MessageBox.Show(obUsuario.Mensaje, "Crear");
         txtNombre.Text    = null;
         txtUser.Text      = null;
         txtPassword.Text  = null;
         txtConfirmar.Text = null;
     }
     else
     {
         MessageBox.Show("Las contraseñas no coinciden");
         txtPassword.Text  = null;
         txtConfirmar.Text = null;
     }
     usuariosDGV(dgvPersonas);
 }
Example #13
0
        protected override void btnSalvar_ServerClick(object sender, EventArgs e)
        {
            nUsuario objU = new nUsuario
            {
                cd_usuario = (!string.IsNullOrEmpty(hdnCdUsuario.Value) ? Convert.ToInt32(hdnCdUsuario.Value) : int.MinValue),
                cd_perfil  = Convert.ToInt32(ddlPerfilInclusao.SelectedValue),
                ds_nome    = txtNomeInclusao.Value,
                v_login    = txtLoginInclusao.Value,
                v_senha    = txtSenhaInclusao.Value
            };

            try
            {
                objU.EfetuarAtualizacao(c_cd_usuario_logado);
                ExibirMensagem("Efetuada Inclusao do usuário " + objU.v_login + " com sucesso.");
            }
            catch (Exception ex)
            {
                throw ex;
            }

            base.btnSalvar_ServerClick(sender, e);
        }
Example #14
0
        protected void btnAcessar_Click(object sender, EventArgs e)
        {
            nUsuario usuario = new nUsuario
            {
                v_login = txtLogin.Value,
                v_senha = txtSenha.Value
            };

            DataSet dsLogin = usuario.Login();

            if (dsLogin.Tables.Count > 0 && dsLogin.Tables[0].Rows.Count > 0)
            {
                if (Convert.ToInt32(dsLogin.Tables[0].Rows[0]["cd_usuario"]) != 0)
                {
                    CarregaSessoes(dsLogin);
                    if (Request.QueryString["ds_pagina"] == null || string.IsNullOrEmpty(Request.QueryString["ds_pagina"].ToString()))
                    {
                        Response.Redirect("Home.aspx", true);
                    }
                    else
                    {
                        Response.Redirect(Encrypt.DecryptString(Request.QueryString["ds_pagina"].ToString(), c_chave_criptografia), true);
                    }
                }
                else
                {
                    lblErro.Visible   = true;
                    lblErro.InnerText = dsLogin.Tables[0].Rows[0]["ds_msg"].ToString();
                }
            }
            else
            {
                lblErro.Visible   = true;
                lblErro.InnerText = "Erro ao tentar efetuar login.";
            }
        }