Exemplo n.º 1
0
        /// <summary>Método que representa la llamada al procedure 'Usuario_Listar'</summary>
        static public List <Entity.Usuario.Listar> Listar(Entity.Usuario Item, Cursor oCursor)
        {
            var        ResultSet = new List <Entity.Usuario.Listar>();
            SqlCommand oComando  = oCursor.ObtenerComando(Contexto.CnControlPresupuesto);
            string     Esquema   = Galeria.Conexiones[(int)Contexto.CnControlPresupuesto].EsquemaDefecto;

            oComando.CommandText = Esquema + "Usuario_Listar";
            try
            {
                SqlParameterCollection oP = oComando.Parameters;
                oP.AddWithValue("usr", Uso.NoNulo(Item.usr, DBNull.Value));
                oP.AddWithValue("codigoPersona", Uso.NoNulo(Item.codigoPersona, DBNull.Value));
                oP.AddWithValue("idEstado", Uso.NoNulo(Item.idEstado, DBNull.Value));

                using (SqlDataReader oLector = oComando.ExecuteReader())
                {
                    while (oLector.Read())
                    {
                        var LItem = new Entity.Usuario.Listar();
                        LItem.usr           = (string)oLector["usr"];
                        LItem.codigoPersona = (string)Uso.NoNulo(oLector["codigoPersona"]);
                        LItem.usrNombre     = (string)oLector["usrNombre"];
                        LItem.clave         = (string)oLector["clave"];
                        LItem.idEstado      = (string)Uso.NoNulo(oLector["idEstado"]);
                        ResultSet.Add(LItem);
                    }
                }
                return(ResultSet);
            }
            catch (System.Exception)
            {
                throw;
            }
        }
Exemplo n.º 2
0
        /// <summary>Método que representa la llamada al procedure 'Usuario_Obtener'</summary>
        static public int Obtener(Entity.Usuario Item, Cursor oCursor)
        {
            SqlCommand oComando = oCursor.ObtenerComando(Contexto.CnControlPresupuesto);
            string     Esquema  = Galeria.Conexiones[(int)Contexto.CnControlPresupuesto].EsquemaDefecto;

            oComando.CommandText = Esquema + "Usuario_Obtener";
            try
            {
                SqlParameterCollection oP = oComando.Parameters;
                oP.AddWithValue("usr", Uso.NoNulo(Item.usr, DBNull.Value));
                oP.Add("codigoPersona", SqlDbType.Char, 8).Direction = ParameterDirection.Output;
                oP.Add("usrNombre", SqlDbType.VarChar, 20).Direction = ParameterDirection.Output;
                oP.Add("clave", SqlDbType.VarChar, 10).Direction     = ParameterDirection.Output;
                oP.Add("idEstado", SqlDbType.Char, 1).Direction      = ParameterDirection.Output;

                int NumFila = oComando.ExecuteNonQuery();

                Item.codigoPersona = (string)Uso.NoNulo(oP["codigoPersona"].Value);
                Item.usrNombre     = (string)Uso.NoNulo(oP["usrNombre"].Value);
                Item.clave         = (string)Uso.NoNulo(oP["clave"].Value);
                Item.idEstado      = (string)Uso.NoNulo(oP["idEstado"].Value);

                return(NumFila);
            }
            catch (System.Exception)
            {
                throw;
            }
        }
Exemplo n.º 3
0
 protected void AtualizarLivro(object sender, EventArgs e)
 {
     Entity.Usuario loUsuarioAlterarLivro = new Entity.Usuario(string.Empty, string.Empty, string.Empty, string.Empty);
     loUsuarioAlterarLivro.USR_id = (int)Session["ID_Usuario"];
     Entity.Livro loAlterarLivro = new Entity.Livro(this.txt_editar_livro_nome.Value.ToString(), loUsuarioAlterarLivro.USR_id);
     if (HttpContext.Current.Session["selecao_livro"] != null)
     {
         loAlterarLivro.LVR_id = Convert.ToInt32(HttpContext.Current.Session["selecao_livro"].ToString());
         string lsMensagemOperacao = string.Empty;
         if (!new Business.Livro().AlterarLivro(loAlterarLivro, out lsMensagemOperacao))
         {
             this.div_msg_alterar_livro.Visible = true;
             this.lbl_msg_alterar_livro.Text    = lsMensagemOperacao;
             ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "abrir_popup", "<script> $('#edit').modal('show'); </script>", false);
         }
         else
         {
             this.alert_topo_livro.Visible  = true;
             this.lbl_alert_topo_livro.Text = "Seu livro foi alterado com sucesso!";
             this.PreencheGridLivrosUsuario();
         }
     }
     else
     {
         this.alert_erro_topo_livro.Visible  = true;
         this.lbl_alert_erro_topo_livro.Text = "Não foi possível atualizar o livro. Tente novamente!";
     }
 }
Exemplo n.º 4
0
 // função que recebe o objeto do usuario do form principal
 internal void Usuario(Entity.Usuario objUsuario)
 {
     // instância o obejto Usuario
     _Usuario = new Usuario();
     // alimenta a variavel com o parametro objUsuario
     _Usuario = objUsuario;
 }
Exemplo n.º 5
0
        //Função que recebe o objeto do usuario

        internal void Usuario(Entity.Usuario objUsuario)
        {
            //Instancia o objeto Usuario
            _Usuario = new Usuario();
            //Alimenta a variavel com o parametro objUsuario
            _Usuario = objUsuario;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Consulta um registro da tabela Usuario
        /// </summary>
        /// <param name="Sql">Síntaxe Sql</param>
        /// <returns></returns>
        public Entity.Usuario Consultar(string Sql)
        {
            SqlConnection oConn = new SqlConnection(oConexao.ConexaoBancoDeDados);
            SqlCommand oComm = new SqlCommand(Sql, oConn);

            SqlDataReader oDr;

            Entity.Usuario usuario = new Entity.Usuario();
            try
            {
                oConn.Open();
                oDr = oComm.ExecuteReader();

                while (oDr.Read())
                    usuario = MontarObjeto(oDr);
            }
            catch (Exception e)
            {
                new Log(e);
            }
            finally
            {
                oDr = null;
                oComm = null;
                oConn.Close();
            }

            return usuario;
        }
Exemplo n.º 7
0
        private bool ValidarEliminacion(Entity.Usuario usuario)
        {
            SEG.Service.Patente patenteService = new SEG.Service.Patente();
            SEG.Service.Familia familiaService = new SEG.Service.Familia();

            foreach (Entity.Permiso permiso in usuario.Permisos)
            {
                if (permiso.Compuesto)
                {
                    SEG.Entity.Familia fam = familia.Consultar(permiso.Nombre);

                    foreach (SEG.Entity.Patente patente in fam.Permisos)
                    {
                        if (patenteService.ObtenerUsuariosAsignadosPorPatenteYFamilia(patente.Id, usuario) == 0 && patenteService.ObtenerUsuariosAsignados(patente.Id, usuario.Id) == 0)
                        {
                            return(false);
                        }
                    }
                }
                else
                {
                    if (patenteService.ObtenerUsuariosAsignadosPorPatenteYFamilia(permiso.Id, usuario) == 0 && patenteService.ObtenerUsuariosAsignados(permiso.Id, usuario.Id) == 0)
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Exemplo n.º 8
0
        public int Eliminar(Entity.Usuario usuario)
        {
            try
            {
                if (!this.ValidarEliminacion(usuario))
                {
                    throw new Exception("No se puede eliminar al usuario debido a que contiene patentes que no tienen otra asignacion.");
                }

                usuario.NombreUsuario = Encrypt.Encriptar(usuario.NombreUsuario, (int)TipoEncriptacion.Reversible);
                usuario.Eliminado     = true;
                usuario.DVH           = dv.CalcularDVH(this.ConcatenarRegistro(usuario));

                using (var scope = new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions {
                    IsolationLevel = IsolationLevel.ReadCommitted
                }))
                {
                    int result = repository.Eliminar(usuario, usuario.DVH);

                    //Control de Cambios
                    this.RegistrarControlCambios(usuario, usuario.Id);

                    dv.ActualizarDVV("Usuario");

                    scope.Complete();

                    return(result);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 9
0
        public int Desbloquear(Entity.Usuario usuario)
        {
            try
            {
                usuario.NombreUsuario = Encrypt.Encriptar(usuario.NombreUsuario, (int)TipoEncriptacion.Reversible);
                usuario.Bloqueado     = false;
                usuario.Reintentos    = 0;
                usuario.DVH           = dv.CalcularDVH(this.ConcatenarRegistro(usuario));

                using (var scope = new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions {
                    IsolationLevel = IsolationLevel.ReadCommitted
                }))
                {
                    int result = repository.Desbloquear(usuario.Id, usuario.DVH);

                    //Control de Cambios
                    this.RegistrarControlCambios(usuario, usuario.Id);

                    dv.ActualizarDVV("Usuario");

                    scope.Complete();

                    return(result);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 10
0
        public List <Entity.Permiso> ObtenerPermisos(Entity.Usuario usuario)
        {
            try
            {
                List <Entity.Permiso> permisos = repository.ObtenerPermisos(usuario.Id);

                foreach (Entity.Permiso p in permisos)
                {
                    if (p.Compuesto)
                    {
                        usuario.Permisos.Add(familia.Consultar(p.Nombre));
                    }
                    else
                    {
                        usuario.Permisos.Add(patente.Consultar(p.Nombre));
                    }
                }

                return(permisos);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 11
0
        protected void EmprestarLivro(object sender, EventArgs e)
        {
            Entity.Usuario loUsuarioEmprestimo = new Entity.Usuario(string.Empty, string.Empty, string.Empty, string.Empty);
            loUsuarioEmprestimo.USR_id = (int)Session["ID_Usuario"];
            string lsMensagemOperacao = string.Empty;

            Entity.Livro loLivroEmprestimo = new Entity.Livro(string.Empty, loUsuarioEmprestimo.USR_id);
            if (HttpContext.Current.Session["selecao_livro"] != null)
            {
                loLivroEmprestimo.LVR_id = Convert.ToInt32(HttpContext.Current.Session["selecao_livro"].ToString());

                Entity.Emprestimo loNovoEmprestimo = new Entity.Emprestimo(loLivroEmprestimo.LVR_id, loUsuarioEmprestimo.USR_id, this.txt_email_emprestante.Value.ToString(), this.txt_nome_emprestante.Value.ToString(), Convert.ToDateTime(this.txt_nova_data.Value.ToString()));
                if (new Business.Emprestimo().InserirNovoEmprestimo(loLivroEmprestimo, loNovoEmprestimo, out lsMensagemOperacao))
                {
                    this.alert_topo_livro.Visible  = true;
                    this.lbl_alert_topo_livro.Text = "Seu livro foi emprestado com sucesso. Você pode conferir na aba de Empréstimos!";
                    this.PreencheGridLivrosUsuario();
                    this.PreencheGridEmprestimosUsuario();
                }
                else
                {
                    this.div_msg_emprestimo.Visible = true;
                    this.lbl_emprestimo.Text        = lsMensagemOperacao;
                    ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "abrir_popup", "<script> $('#modal_novo_emprestimo').modal('show'); </script>", false);
                }
            }
            else
            {
                this.alert_erro_topo_livro.Visible  = true;
                this.lbl_alert_erro_topo_livro.Text = "Não foi possível emprestar o livro. Tente novamente!";
            }
        }
Exemplo n.º 12
0
        public Entity.Usuario Consultar(string username)
        {
            string sqlCommand = @"SELECT * FROM USUARIO WHERE Nombre_Usuario = " + "'" + username + "'" + " AND Eliminado = 0";

            DataTable tabla = db.ExecuteNonQuery(sqlCommand);

            if (tabla.Rows.Count == 0)
            {
                return(null);
            }

            Entity.Usuario user = new Entity.Usuario
            {
                Id            = int.Parse(tabla.Rows[0]["Id"].ToString()),
                NombreUsuario = Encrypt.Desencriptar(tabla.Rows[0]["Nombre_Usuario"].ToString()),
                Mail          = tabla.Rows[0]["Mail"].ToString(),
                Bloqueado     = (bool)tabla.Rows[0]["Bloqueado"],
                Eliminado     = (bool)tabla.Rows[0]["Eliminado"],
                Reintentos    = int.Parse(tabla.Rows[0]["Reintentos"].ToString()),
                Apellido      = tabla.Rows[0]["Apellido"].ToString(),
                Contraseña    = tabla.Rows[0]["Contraseña"].ToString(),
                DNI           = int.Parse(tabla.Rows[0]["DNI"].ToString()),
                Direccion     = tabla.Rows[0]["Direccion"].ToString(),
                FechaNac      = Convert.ToDateTime(tabla.Rows[0]["Fecha_Nac"].ToString()),
                Telefono      = int.Parse(tabla.Rows[0]["Telefono"].ToString()),
                Nombre        = tabla.Rows[0]["Nombre"].ToString()
            };

            return(user);
        }
Exemplo n.º 13
0
        public void CambiarContraseña(string nombre, string passwordVieja, string passwordNueva)
        {
            try
            {
                Entity.Usuario usuario = this.Consultar(nombre);

                if (!usuario.Contraseña.Equals(Util.Encrypt.Encriptar(passwordVieja, (int)TipoEncriptacion.Irreversible)))
                {
                    throw new Exception("Contraseña incorrecta.");
                }

                usuario.Contraseña = Util.Encrypt.Encriptar(passwordNueva, (int)TipoEncriptacion.Irreversible);

                usuario.DVH = dv.CalcularDVH(this.ConcatenarRegistro(usuario));

                using (var scope = new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions {
                    IsolationLevel = IsolationLevel.ReadCommitted
                }))
                {
                    int result = repository.GenerarContraseña(usuario);

                    //Control de Cambios
                    this.RegistrarControlCambios(usuario, usuario.Id);

                    dv.ActualizarDVV("Usuario");

                    scope.Complete();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemplo n.º 14
0
        public bool ChecarUsuario(string login)
        {
            try
            {
                var ret = new Repository.Repository();
                var obj = new Entity.Usuario()
                {
                    nome = login
                };

                if (ret.ChecarUsuario(login).idusuario > 0)
                {
                    return(true);
                }

                //return ret2;

                //return new Repository.Repository().ChecarUsuario(login);
            }
            catch (Exception ex)
            {
                new Exception(ex.Message.ToString());
            }
            // return new Entity.Usuario();

            return(false);
        }
Exemplo n.º 15
0
 public void LogarUsuario(string nome, string senha)
 {
     UsuarioLogado = repositorio.RecuperarUsuario(nome, senha);
     if (UsuarioLogado == null)
     {
         AdicionarMensagem("Usuário ou senha inválidos.", EnumStatusDoResultado.RegraDeNegocioInvalida);
     }
 }
Exemplo n.º 16
0
 public static void Login(Entity.Usuario usuario)
 {
     if (session == null)
     {
         session         = new SessionManager();
         session.Usuario = usuario;
     }
 }
Exemplo n.º 17
0
 /// <summary>
 /// Método responsável por preencher os campos do Perfil do Usuário.
 /// </summary>
 protected void PreenchePerfilUsuario()
 {
     Entity.Usuario loUsuarioLogado = new Entity.Usuario(string.Empty, string.Empty, string.Empty, string.Empty);
     loUsuarioLogado.USR_id = (int)Session["ID_Usuario"];
     loUsuarioLogado        = new Business.Usuario().CarregarDados(loUsuarioLogado);
     this.txt_nome.Value    = loUsuarioLogado.USR_nome;
     this.txt_email.Value   = loUsuarioLogado.USR_email;
 }
Exemplo n.º 18
0
        public int Alta(Entity.Usuario usuario)
        {
            string sqlCommand = @"INSERT INTO usuario (NOMBRE, APELLIDO, DNI, NOMBRE_USUARIO, CONTRASEÑA, DIRECCION, TELEFONO, REINTENTOS, MAIL, FECHA_NAC, ELIMINADO, BLOQUEADO, DVH)
                                VALUES (" + "'" + usuario.Nombre + "'" + "," + "'" + usuario.Apellido + "'" + "," + usuario.DNI + "," + "'" + usuario.NombreUsuario + "'" + "," +
                                "'" + usuario.Contraseña + "'" + "," + "'" + usuario.Direccion + "'" + "," + usuario.Telefono + "," + 0 + "," + "'" + usuario.Mail + "'" + "," +
                                "'" + usuario.FechaNac.ToShortDateString() + "'" + "," + Convert.ToInt16(usuario.Eliminado) + "," + Convert.ToInt16(usuario.Bloqueado) + "," + "'" + usuario.DVH + "'" + ")";

            return(db.ExecuteSqlCommand(sqlCommand));
        }
Exemplo n.º 19
0
 public void RegistrarNovoUsuario(string nome, string senha, EnumTipoUsuario tipoUsuario)
 {
     UsuarioLogado = new Entity.Usuario();
     UsuarioLogado.CodigoUsuario = GerarCodigoUnico();
     UsuarioLogado.Nome          = nome;
     UsuarioLogado.Senha         = senha;
     UsuarioLogado.Tipo          = tipoUsuario.ToString();
     ValidarEPersistir();
 }
Exemplo n.º 20
0
        protected void DesativarUsuario(object sender, EventArgs e)
        {
            Entity.Usuario loUsuarioDesativado = new Entity.Usuario(string.Empty, string.Empty, string.Empty, string.Empty);
            loUsuarioDesativado.USR_id = (int)Session["ID_Usuario"];
            string lsMensagem = string.Empty;

            new Business.Usuario().DesativarUsuario(loUsuarioDesativado, out lsMensagem);
            Response.Redirect("PaginaInicial.aspx");
        }
Exemplo n.º 21
0
        public int ConsultarUsuariosAsignadosPorPatenteYFamilia(int idPatente, Entity.Usuario usuario)
        {
            string sqlCommand = @"SELECT COUNT(u.id) FROM usuario_permiso up
                                INNER JOIN usuario u ON u.id = up.id_usuario
                                INNER JOIN permiso p ON p.id = up.id_permiso
                                INNER JOIN permiso_compuesto pc on pc.Id_Permiso = p.Id
                                WHERE p.Eliminado = 0 AND u.Eliminado = 0 AND pc.Id_Compuesto =" + idPatente + " AND u.Id <>" + usuario.Id;

            return(Convert.ToInt32(db.ExecuteScalar(sqlCommand)));
        }
Exemplo n.º 22
0
        private bool ValidarAsignacion(Entity.Usuario usuario, string nombrePatente)
        {
            SEG.Service.Usuario usuarioService = new SEG.Service.Usuario();

            if (usuario.Permisos == null)
            {
                return(false);
            }

            return(usuarioService.ObtenerPermisos(usuario).Any(p => !p.Compuesto && p.Nombre == nombrePatente));
        }
Exemplo n.º 23
0
 public bool CadastrarUsuario(Entity.Usuario objUsuario)
 {
     try
     {
         return(new Repository.Repository().CadastrarUsuario(objUsuario));
     }
     catch (Exception ex)
     {
         new Exception(ex.Message.ToString());
     }
     return(false);
 }
Exemplo n.º 24
0
        private bool ValidarAsignacion(Entity.Usuario usuario, string nombreFamilia)
        {
            Service.Usuario usuarioService = new Service.Usuario();

            var permisos = usuarioService.ObtenerPermisos(usuario);

            if (permisos != null)
            {
                return(permisos.Any(p => p.Compuesto && p.Nombre == nombreFamilia));
            }

            return(false);
        }
Exemplo n.º 25
0
        public Entity.Usuario Consultar(string nombre)
        {
            Entity.Usuario usuario = repository.Consultar(Util.Encrypt.Encriptar(nombre, (int)TipoEncriptacion.Reversible));

            if (usuario == null)
            {
                throw new Exception("No se encontro al usuario.");
            }

            ObtenerPermisos(usuario);

            return(usuario);
        }
Exemplo n.º 26
0
        public Caixa(ICaixaRepositorio repositorio, IVendaRepositorio vendaRepositorio, IEmail email, Parametros parametros, Venda.TipoPagamento tipoDoPagamento, Entity.Usuario usuario, string nomeDoCaixa = "")
        {
            _repositorio      = repositorio;
            _vendaRepositorio = vendaRepositorio;
            _parametros       = parametros;
            _email            = email;
            CaixaCorrente     = repositorio.RecuperarCaixaPorNome(nomeDoCaixa);
            TipoDoPagamento   = tipoDoPagamento;
            UsuarioCorrente   = usuario;

            if (CaixaCorrente == null)
            {
                RegistrarNovoCaixa(nomeDoCaixa, RecuperarIp());
            }
        }
Exemplo n.º 27
0
        private void Salvar()
        {
            try
            {
                var checarUsuario = new Agenda.Core.Service.Service();

                if (checarUsuario.ChecarUsuario(txtLogin.Text))
                {
                    MessageBox.Show("Login já cadastrado. Utilize outro nome de login.", "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }


                if (VerificaCampo())
                {
                    var _objUsuario = new Entity.Usuario()
                    {
                        nome            = txtNome.Text.ToUpper(),
                        sobrenome       = txtSobrenome.Text.ToUpper(),
                        login           = txtLogin.Text.ToUpper(),
                        senha           = txtSenha.Text,
                        email           = txtEmail.Text,
                        foto            = _ByteFoto,
                        nivelAcesso     = (int)((System.Collections.Generic.KeyValuePair <int, string>)(cmbPerfil.SelectedValue)).Key,
                        status          = (int)((System.Collections.Generic.KeyValuePair <int, string>)(cmbStatus.SelectedValue)).Key,
                        sexo            = cmbSexo.Text,
                        idUsuarioLogado = _Usuario.idUsuarioLogado,
                        loginLogado     = _Usuario.login
                    };

                    var retornoCadastro = new Agenda.Core.Service.Service().CadastrarUsuario(_objUsuario);

                    if (retornoCadastro)
                    {
                        MessageBox.Show("Cadatrado com sucesso.", "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("Dados não cadatrado, favor verifique.", "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), "Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemplo n.º 28
0
        protected void CadastrarUsuario(object sender, EventArgs e)
        {
            this.div_mensagem_modal.Visible = false;
            Entity.Usuario loNovoUsuario      = new Entity.Usuario(this.txt_email_cadastro.Value.ToString(), this.txt_name.Value.ToString(), this.txt_senha.Value.ToString(), this.txt_repete_senha.Value.ToString());
            string         lsMensagemOperacao = string.Empty;

            if (new Business.Usuario().InserirNovoUsuario(loNovoUsuario, out lsMensagemOperacao))
            {
                this.LimparCampos();
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "registro_sucesso", "<script> document.getElementById('" + btn_registro_sucesso.ClientID + "').click(); </script>", false);
            }
            else
            {
                this.div_mensagem_modal.Visible = true;
                this.lbl_mensagem_modal.Text    = lsMensagemOperacao;
                ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "abrir_popup", "<script> $('#modal_cadastro').modal('show'); </script>", false);
            }
        }
Exemplo n.º 29
0
        protected void AtualizarPerfil(object sender, EventArgs e)
        {
            Entity.Usuario loAlterarUsuario   = new Entity.Usuario(this.txt_email.Value.ToString(), this.txt_nome.Value.ToString(), this.txt_nova_senha.Value.ToString(), this.txt_nova_senha_confirmacao.Value.ToString());
            string         lsMensagemOperacao = string.Empty;

            loAlterarUsuario.USR_id = (int)Session["ID_Usuario"];
            if (!new Business.Usuario().AlterarUsuario(loAlterarUsuario, out lsMensagemOperacao))
            {
                this.div_mensagem_perfil.Visible = true;
                this.lbl_mensagem_perfil.Text    = lsMensagemOperacao;
            }
            else
            {
                this.div_mensagem_perfil.Visible = true;
                this.lbl_mensagem_perfil.Text    = "Seu perfil foi atualizado com sucesso!";
            }
            selecao_aba("aba3");
        }
Exemplo n.º 30
0
        public int Modificar(Entity.Usuario usuario, string DVH, bool esControlCambio)
        {
            string sqlCommand = string.Empty;

            if (!esControlCambio)
            {
                sqlCommand = @"UPDATE Usuario SET DVH=" + "'" + DVH + "'" + "," + "Direccion=" + "'" + usuario.Direccion + "'" + ","
                             + "Mail=" + "'" + usuario.Mail + "'" + "," + "Telefono=" + "'" + usuario.Telefono + "'" + " WHERE Id=" + usuario.Id;
            }
            else
            {
                sqlCommand = @"UPDATE Usuario SET DVH=" + "'" + DVH + "'" + "," + "Direccion=" + "'" + usuario.Direccion + "'" + ","
                             + "Mail=" + "'" + usuario.Mail + "'" + "," + "Telefono=" + usuario.Telefono + "," + "Contraseña=" + "'" + usuario.Contraseña + "'" + ","
                             + "Reintentos=" + usuario.Reintentos + "," + "Eliminado=" + Convert.ToInt16(usuario.Eliminado) + "," + "Bloqueado=" + Convert.ToInt16(usuario.Bloqueado) + " WHERE Id=" + usuario.Id;
            }

            return(db.ExecuteSqlCommand(sqlCommand));
        }
Exemplo n.º 31
0
        /// <summary>
        /// Método responsável por preencher o grid de emprestimos do Usuário.
        /// </summary>
        protected void PreencheGridEmprestimosUsuario()
        {
            Entity.Usuario loUsuarioLogado = new Entity.Usuario(string.Empty, string.Empty, string.Empty, string.Empty);
            loUsuarioLogado.USR_id = (int)Session["ID_Usuario"];
            StringBuilder            loHTMLGridEmprestimos = new StringBuilder();
            List <Entity.Emprestimo> loListaEmprestimos    = new Business.Emprestimo().CarregarEmprestimos(loUsuarioLogado);

            if (loListaEmprestimos == null || loListaEmprestimos.Count == 0)
            {
                this.literal_grid_emprestimos.Text = "<h2>Você não realizou nenhum emprestimo</h2>";
            }
            else
            {
                loHTMLGridEmprestimos.Append("<table id=\"grid_emprestimos\" class=\"table table-striped table-bordered\">");
                loHTMLGridEmprestimos.Append("<thead><tr><th>Nome do Livro</th><th>Nome do Emprestante</th><th>Email do Emprestante</th><th>Data de Devolução</th><th class=\"acao\">Ações</th></tr></thead>");
                loHTMLGridEmprestimos.Append("<tbody>");
                foreach (Entity.Emprestimo loEmprestimo in loListaEmprestimos)
                {
                    loHTMLGridEmprestimos.Append("<tr><td>");
                    loHTMLGridEmprestimos.Append(loEmprestimo.EMP_nome_livro);
                    loHTMLGridEmprestimos.Append("</td><td>");
                    loHTMLGridEmprestimos.Append(loEmprestimo.EMP_nome_emprestante);
                    loHTMLGridEmprestimos.Append("</td><td>");
                    loHTMLGridEmprestimos.Append(loEmprestimo.EMP_email_emprestante);
                    loHTMLGridEmprestimos.Append("</td><td>");
                    loHTMLGridEmprestimos.Append(loEmprestimo.EMP_devolucao.ToString("dd/MM/yyyy"));
                    loHTMLGridEmprestimos.Append("</td><td><span style=\"padding-left: 14px;\"><a title=\"Alterar prazo\" class=\"btn btn-warning btn-xs\" ");
                    loHTMLGridEmprestimos.Append(" onclick=\"selecionar_emprestimo('");
                    loHTMLGridEmprestimos.Append(loEmprestimo.EMP_id);
                    loHTMLGridEmprestimos.Append("', 'PRAZO', '");
                    loHTMLGridEmprestimos.Append(loEmprestimo.EMP_devolucao.ToString("dd/MM/yyyy"));
                    loHTMLGridEmprestimos.Append("');\" ");
                    loHTMLGridEmprestimos.Append("><span class=\"glyphicon glyphicon-calendar\"></span></a>");

                    loHTMLGridEmprestimos.Append("<a title=\"Finalizar empréstimo\" class=\"btn btn-success btn-xs\" ");
                    loHTMLGridEmprestimos.Append(" onclick=\"selecionar_emprestimo('");
                    loHTMLGridEmprestimos.Append(loEmprestimo.EMP_id);
                    loHTMLGridEmprestimos.Append("', 'FINALIZAR', ' ');\" ");
                    loHTMLGridEmprestimos.Append("><span class=\"glyphicon glyphicon-ok\"></span></a></span>");
                    loHTMLGridEmprestimos.Append("</td></tr></tbody></table>");
                }
                this.literal_grid_emprestimos.Text = loHTMLGridEmprestimos.ToString();
            }
        }
Exemplo n.º 32
0
        /// <summary>
        /// Monta o objeto Entity.Usuario
        /// </summary>
        /// <param name="oDr">Linha de resultado do banco de dados</param>
        /// <returns></returns>
        private Entity.Usuario MontarObjeto(SqlDataReader oDr)
        {
            Entity.Usuario usuario = new Entity.Usuario();

            if (Coluna(oDr, "IDUsuario")) usuario.IDUsuario = (int)oDr["IDUsuario"];
            if (Coluna(oDr, "Nome")) usuario.Nome = oDr["Nome"].ToString();
            if (Coluna(oDr, "Login")) usuario.Login = oDr["Login"].ToString();
            if (Coluna(oDr, "Senha")) usuario.Senha = oDr["Senha"].ToString();
            if (Coluna(oDr, "Apartamento")) usuario.Apartamento = (int)oDr["Apartamento"];
            if (Coluna(oDr, "Torre")) usuario.Torre = oDr["Torre"].ToString();
            if (Coluna(oDr, "DataInclusao")) usuario.DataInclusao = (DateTime)oDr["DataInclusao"];

            return usuario;
        }