예제 #1
0
        public Usuario IniciarSesion()
        {
            DALUsuario     dalUser = new DALUsuario();
            DataTable      tabal   = dalUser.Autenticar(this.User, this.Password);
            List <Usuario> lista   = new List <Usuario>();
            //Usuario pUser = new Usuario();
            TipoUsuario pTipoUsuario;

            foreach (DataRow fila in tabal.Rows)
            {
                //pUser = new Usuario();
                pTipoUsuario = new TipoUsuario();

                //pUser.IdUsuario = int.Parse(fila["idUsuario"].ToString());
                //pUser.User = fila["Usuario"].ToString();
                //pTipoUsuario.IdTipoUsuario = int.Parse(fila["idTipoUsuario"].ToString());
                //pTipoUsuario.Descripcion = fila["Descripcion"].ToString();
                //pTipoUsuario.CodUsuario = fila["CodUsuario"].ToString();
                //pUser.TipoUsuario = pTipoUsuario;
                //pUser = new Usuario();
                //pTipoUsuario = new TipoUsuario();

                this.IdUsuario             = int.Parse(fila["idUsuario"].ToString());
                this.User                  = fila["Usuario"].ToString();
                this.Password              = fila["Password"].ToString();
                pTipoUsuario.IdTipoUsuario = int.Parse(fila["idTipoUsuario"].ToString());
                pTipoUsuario.Descripcion   = fila["Descripcion"].ToString();
                pTipoUsuario.CodUsuario    = fila["CodUsuario"].ToString();
                this.TipoUsuario           = pTipoUsuario;
            }

            return(this);
        }
예제 #2
0
        public void altaCliente(ClsCliente oCliente, ClsUsuario oUsuario)
        {
            try
            {
                IHash  interfazSeguridad = new Hash();
                string passHasheada      = interfazSeguridad.obtenerHash(oUsuario.password);
                oUsuario.password = passHasheada;

                //Activo el usuario, ya que es un nuevo empleado.
                oUsuario.activo = true;

                DALUsuario oDalUsuario = new DALUsuario();
                oDalUsuario.altaUsuario(oUsuario, oCliente);

                string pDetalle = "Nuevo Cliente generado ID:" + oCliente.nombre.ToString() + " con susuario: " + oUsuario.usr.ToString() + "satisfactoriamente.";
                string pModulo  = "BLL";
                interfazServiceLayer.registrarEventoNegocio(pDetalle, pModulo);
            }
            catch (DalExcepcion ex)
            {
                DalExcepcion oDExcepcion = new DalExcepcion(ex.Message);
                interfazServiceLayer.registrarEvento(oDExcepcion);
            }
            catch (Exception ex)
            {
                BllExcepcion oBExcepcion = new BllExcepcion(ex.Message);
                interfazServiceLayer.registrarEvento(oBExcepcion);
            }
        }
예제 #3
0
        public void AtualizaGrid()
        {
            DALUsuario cat = new DALUsuario();

            gvDadosUsuario.DataSource = cat.Localizar();
            gvDadosUsuario.DataBind();
        }
예제 #4
0
        public void Alterar(ModeloUsuario modelo)
        {
            if (modelo.UsuGrupo.Trim().Length == 0)
            {
                throw new Exception("O GRUPO DO USUÁRIO DEVE SER INFORMADO!");
            }
            if (modelo.UsuLogin.Trim().Length == 0)
            {
                throw new Exception("O LOGIN DO USUÁRIO DEVE SER INFORMADO!");
            }
            if (modelo.UsuNome.Trim().Length == 0)
            {
                throw new Exception("O NOME DO USUÁRIO DEVE SER INFORMADO!");
            }
            if (modelo.UsuSenha.Trim().Length == 0)
            {
                throw new Exception("A SENHA DO USUÁRIO DEVE SER INFORMADO!");
            }
            if (modelo.UsuId <= 0)
            {
                throw new Exception("O CÓDIGO DO USUÁRIO DEVE SER INFORMADO!");
            }
            //Altera os dados
            DALUsuario DALobj = new DALUsuario(conexao);

            DALobj.Alterar(modelo);
        }
예제 #5
0
 public bool retroceder(SPaquetePuntoControl ppc)
 {
     try
     {
         var _dalPPC = new DALPaquetePuntoControl();
         List <SPaquetePuntoControl> ppcList = _dalPPC.getAllByPaquete(ppc.IdPaquete);
         if (ppcList.Count() > 0)
         {
             int ppcAEliminarId = ppcList.Max(x => x.Id);
             SPaquetePuntoControl ppcAEliminar = ppcList.First(x => x.Id == ppcAEliminarId);
             if (ppcAEliminar != null)
             {
                 var      _dalU    = new DALUsuario();
                 SUsuario empleado = _dalU.getUsuario(ppc.IdEmpleado);
                 if ((empleado.Rol == "Funcionario" && empleado.Id == ppcAEliminar.IdEmpleado) || empleado.Rol == "Encargado" || empleado.Rol == "Admin")
                 {
                     BLEmail.actualizacionEstado(new BLPaquete().getPaquete(ppc.IdPaquete));
                     return(_dalPPC.deletePaquetePuntoControl(ppcAEliminar.Id));
                 }
                 else
                 {
                     throw new ECompartida("El usuario que realizo la peticion no tiene autorizacion para realizar esta operacion");
                 }
             }
             throw new ECompartida("No se encontro ningun paquete con el ID enviado");
         }
         throw new ECompartida("No se puede retroceder mas el paquete");
     }
     catch (Exception)
     {
         throw;
     }
 }
예제 #6
0
        public void Alterar(ModelUsuario modelo)
        {
            if (modelo.IdUsuario <= 0)
            {
                throw new Exception("Digite o código!");
            }
            if (modelo.Nome.Trim().Length == 0)
            {
                throw new Exception("O nome é obrigatório!");
            }
            modelo.Nome = modelo.Nome.ToUpper();

            if (modelo.Senha.Trim().Length == 0)
            {
                throw new Exception("A senha é obrigatória!");
            }
            if (modelo.Senha.Length < 3)
            {
                throw new Exception("A senha digitada não atinge o limite permitido de 3 caracteres!");
            }
            modelo.Senha = modelo.Senha.ToUpper();

            if (modelo.NivelAcesso.Trim().Length == 0)
            {
                throw new Exception("O nível de acesso é obrigatório!");
            }

            DALUsuario DALObj = new DALUsuario(conexao);

            DALObj.Alterar(modelo);
        }
예제 #7
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            clsUsuario Usuario = new clsUsuario();

            Usuario.Email = Request.Form["login"];
            Usuario.Senha = Request.Form["senha"];
            if (Usuario.Email == "" || Usuario.Senha == "")
            {
                //Response.Write("<script>alert('Preencha todos os campos');window.location.href='Login.aspx'</script>");
                ClientScript.RegisterStartupScript(this.GetType(), "clientScript", "modalMessage('Atenção','Preencha todos os campos!!')", true);
            }
            else
            {
                var x = DALUsuario.Logar(Usuario);
                if (x.TipoUsuario == 0)
                {
                    Session["TIPO_USUARIO"] = 0;
                }
                else
                {
                    Session["TIPO_USUARIO"] = 1;
                }
                if (x.Id != 0)
                {
                    Session["Id"] = x.Id;
                    Response.Redirect("Pages/Default.aspx");
                }
                else
                {
                    //Response.Write("<script>alert('Usuário não encontrado, verifique as credenciais digitadas!!');window.location.href='Login.aspx'</script>");
                    ClientScript.RegisterStartupScript(this.GetType(), "clientScript", "modalMessage('Atenção','Usuário não encontrado, verifique as credenciais digitadas!!');", true);
                }
            }
        }
예제 #8
0
        public void Inserir(ModeloUsuario modelo)
        {
            ValidaCampos(modelo);
            DALUsuario DALObj = new DALUsuario(conexao);

            DALObj.Inserir(modelo);
        }
예제 #9
0
        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();
            }
        }
예제 #10
0
 public string IncluirUsuaio(ModUsuario md, int tam, int senha, string senha1, string senha2)
 {
     if (tam == 0)
     {
         return("O campo login deve ser preenchido !");
     }
     else
     {
         if (senha == 0)
         {
             return("O campo senha deve ser preenchido !");
         }
         else
         {
             if (senha1 != senha2)
             {
                 return("As Senhas não coincidem !");
             }
             else
             {
                 DALUsuario user = new DALUsuario(conexao);
                 return(user.Incluir(md));
             }
         }
     }
 }
예제 #11
0
        public SqlDataReader IniciaSessao()
        {
            SqlDataReader Logar;
            DALUsuario    DalObj = new DALUsuario(Conexao);

            Logar = DalObj.iniciaSessao(usuario, senha);
            return(Logar);
        }
예제 #12
0
        public void Alterar(ModeloUsuario modelo)
        {
            if (modelo.usu_cod < 1)
            {
                throw new Exception("codigo");
            }
            ValidaCampos(modelo);
            DALUsuario DALObj = new DALUsuario(conexao);

            DALObj.Alterar(modelo);
        }
예제 #13
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["email"] != null)
     {
         DALUsuario du = new DALUsuario();
         Usuario    u  = du.GetRegistro(Session["email"].ToString());
         lbNome.Text    = u.Nome;
         lbEmail.Text   = u.Email;
         IUser.ImageUrl = "imagens/usuarios/" + u.Foto;
     }
 }
예제 #14
0
        public void Incluir(ModeloUsuario modelo)
        {
            if (modelo.Nome.Trim().Length == 0)
            {
                throw new Exception("O nome do usuário é obrigatório");
            }
            //modelo.Nome = modelo.Nome.ToUpper();

            DALUsuario DALobj = new DALUsuario(conexao);

            DALobj.Incluir(modelo);
        }
예제 #15
0
        protected void btSalvar_Click(object sender, EventArgs e)
        {
            try
            {
                DALUsuario dal = new DALUsuario();
                Usuario    obj = new Usuario();
                obj.Nome  = txbNome.Text;
                obj.Email = txbEmail.Text;
                obj.Senha = txbSenha.Text;
                if (cbAdm.Checked)
                {
                    obj.Administrador = 1;
                }
                else
                {
                    obj.Administrador = 0;
                }
                String caminho = Server.MapPath(@"imagens\usuarios\");
                //faz o upload da foto e salva o nome no obj
                if (fuFoto.PostedFile.FileName != "")
                {
                    obj.Foto = DateTime.Now.Millisecond.ToString() + fuFoto.PostedFile.FileName;
                    String img = caminho + obj.Foto;
                    fuFoto.PostedFile.SaveAs(img);
                }
                string msg = "<script> alert('Registro atualizado com sucesso!!!!'); </script>";

                if (txbId.Text == "")
                {
                    //inserir
                    dal.Inserir(obj);
                    msg = "<script> alert('O código gerado foi: " + obj.Id.ToString() + "'); </script>";
                }
                else
                {
                    obj.Id = Convert.ToInt32(txbId.Text);
                    //verificar se existe foto existe e deletar
                    Usuario uold = dal.GetRegistro(obj.Id);
                    if (uold.Foto != "")
                    {
                        File.Delete(caminho + uold.Foto);
                    }
                    dal.Alterar(obj);
                }
                Response.Write(msg);
                GridView1.DataBind();
                LimpaCampos();
            }
            catch (Exception erro)
            {
                Response.Write("<script> alert('" + erro.Message + "'); </script>");
            }
        }
예제 #16
0
        protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            int        id = Convert.ToInt32(GridView1.Rows[e.RowIndex].Cells[1].Text);
            DALUsuario du = new DALUsuario();
            Usuario    u  = du.GetRegistro(id);

            if (u.Foto != "")
            {
                String caminho = Server.MapPath(@"imagens\usuarios\");
                File.Delete(caminho + u.Foto);
            }
        }
예제 #17
0
        protected void btnSalvar_Click(object sender, EventArgs e)
        {
            DALUsuario dal = new DALUsuario();
            Usuario    cat = new Usuario();

            string msg = "";

            cat.Nome  = txtAutor.Text;
            cat.Email = txtEmail.Text;
            cat.Senha = txtSenha.Text;
            Usuario valida = dal.GetRegistro(cat.Email);

            try
            {
                if (btnSalvar.Text == "Inserir")
                {
                    //  Validação email
                    if (valida.Id == 0)
                    {
                        dal.Inserir(cat);
                        msg = "<script>alert('o codigo gerado foi: " + cat.Id.ToString() + "')</script>";
                    }
                    else
                    {
                        msg = "<script>alert('Esse email já foi cadastrado!.')</script>";
                    }
                }
                else
                {
                    //alterar
                    cat.Id = int.Parse(txtId.Text);

                    if ((valida.Id != 0 && valida.Id == cat.Id) || valida.Id == 0)
                    {
                        dal.Alterar(cat);
                        msg = "<script>alert('Registro atualizado com sucesso!.')</script>";
                    }
                    else
                    {
                        msg = "<script>alert('Já há um email cadastrado com esse nome.')</script>";
                    }
                    //  Validação Email
                }
                Response.Write(msg);
                Limpar();
            }
            catch (Exception error)
            {
                msg = "<script>alert('Houve um erro: " + error.Message + "')</script>";
            }
            AtualizaGrid();
            Limpar();
        }
예제 #18
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (Session["email"] == null)
     {
         // Response.Redirect("~/login.aspx");
     }
     else
     {
         DALUsuario du = new DALUsuario();
         Usuario    u  = du.GetRegistro(Session["email"].ToString());
         AlteraMenu(u.Administrador);
     }
 }
예제 #19
0
        public int Agregar()
        {
            DALUsuario user = new DALUsuario();

            try
            {
                return(user.AgregarUsuario(this.IdUsuario, this.User, this.Password, this.TipoUsuario.IdTipoUsuario));
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #20
0
        public void ModificarContraseña()
        {
            DALUsuario user = new DALUsuario();

            try
            {
                user.ModificarContraseña(this.IdUsuario, this.User, this.Password);
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #21
0
        public int Modificar()
        {
            DALUsuario user = new DALUsuario();

            try
            {
                return(user.ModificarUsuario(this.IdUsuario, this.User, this.TipoUsuario.IdTipoUsuario));
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #22
0
        public int ObtenerId()
        {
            DALUsuario user = new DALUsuario();

            try
            {
                return(user.ObtenerId());
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #23
0
        protected void Button2_Click(object sender, EventArgs e)
        {
            DALUsuario oDALUsuario = new DALUsuario();

            if (oDALUsuario.Insert(new Usuario(Pass.Text, 2, TextBox1.Text, "0", TXTEmail.Text, TXTPhones.Text)))
            {
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "mensagem", "AlertInsertSuccessful()", true);
            }
            else
            {
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "mensagem", "AlertInsertFailed()", true);
            }
        }
예제 #24
0
        private void btnSalvar_Click(object sender, EventArgs e)
        {
            Usuario usuario = new Usuario();

            usuario.Nome     = txtNome.Text;
            usuario.Username = txtUsername.Text;
            usuario.Senha    = txtSenha.Text;
            usuario.Status   = cbStatus.Text;
            usuario.Nivel    = Convert.ToInt32(numNivel.Value);

            DALUsuario dal = new DALUsuario();

            dal.NovoUsuario(usuario);
        }
예제 #25
0
        //-------------------------------------------------------------------------------------------------------------------
        public void Alterar(ModeloUsuario obj)
        {
            //O nome da categoria é obrigatório
            if (obj.usu_nome.Trim().Length == 0)
            {
                throw new Exception("O nome do Perfil é obrigatório");
            }

            obj.usu_nome = obj.usu_nome;

            //Se tudo está Ok, chama a rotina de inserção.
            DALUsuario DALobj = new DALUsuario(new DALConexao(DALDadosDoBanco.stringDeConexao));

            DALobj.Alterar(obj);
        }
예제 #26
0
        public void Incluir(ModeloUsuario modelo)
        {
            if (modelo.NomeUser.Trim().Length == 0)
            {
                throw new Exception("O nome do usuario é obrigatório");
            }
            if (modelo.SenhaUser.Trim().Length == 0)
            {
                throw new Exception("A senha do usuario é obrigatório");
            }

            DALUsuario DALobj = new DALUsuario(conexao);

            DALobj.Incluir(modelo);
        }
예제 #27
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["email"] == null)
            {
                Response.Redirect("~/wfLogin.aspx");
            }
            else
            {
                DALUsuario dal = new DALUsuario();
                Usuario    usu = dal.GetRegistro(Session["email"].ToString());

                lNome.Text  = usu.Nome;
                lEmail.Text = usu.Email;
            }
        }
예제 #28
0
        protected void btlogar_Click(object sender, EventArgs e)
        {
            string email = txbLogin.Text;
            string senha = txbSenha.Text;

            DALUsuario du = new DALUsuario();
            Usuario    u  = du.GetRegistro(email);

            if (email == u.Email && senha == u.Senha)
            {
                Session["id"]    = u.Id;
                Session["nome"]  = u.Nome;
                Session["email"] = email;
                Response.Redirect("~/Default.aspx");
            }
        }
예제 #29
0
        public void Alterar(ModeloUsuario modelo)
        {
            if (modelo.IdUsuario <= 0)
            {
                throw new Exception("O código do usuário é obrigatório");
            }

            if (modelo.Nome.Trim().Length == 0)
            {
                throw new Exception("O nome do usuário é obrigatório");
            }
            //modelo.Nome = modelo.Nome.ToUpper();

            DALUsuario DALobj = new DALUsuario(conexao);

            DALobj.Alterar(modelo);
        }
예제 #30
0
 protected void btSalvar_Click(object sender, EventArgs e)
 {
     try
     {
         DALUsuario dal = new DALUsuario();
         Usuario    obj = new Usuario();
         obj.Nome  = txbNome.Text;
         obj.Email = txbEmail.Text;
         obj.Senha = txbSenha.Text;
         String caminho = Server.MapPath(@"imagens\usuarios\");
         if (fuFoto.PostedFile.FileName != "")
         {
             obj.Foto = DateTime.Now.Millisecond.ToString() + fuFoto.PostedFile.FileName;
         }
         if (cbAdm.Checked)
         {
             obj.Administrador = 1;
         }
         else
         {
             obj.Administrador = 0;
         }
         if (txbId.Text == "")
         {
             //inserir
             dal.Inserir(obj);
             String img = caminho + obj.Foto;
             txbNome.Text = img;
             if (fuFoto.PostedFile.FileName != "")
             {
                 fuFoto.PostedFile.SaveAs(img);
             }
             Response.Write("<script> alert('O código gerado foi: " + obj.Id.ToString() + "'); </script>");
             GridView1.DataBind();
             //LimpaCampos();
         }
         else
         {
             //alterar
         }
     }catch (Exception erro)
     {
         txbNome.Text = erro.Message;
         Response.Write("<script> alert('" + erro.Message + "'); </script>");
     }
 }