Ejemplo n.º 1
0
        public bool ValidarActualizacion()
        {
            bool     Resultado = false;
            DateTime FechaAux;
            string   Fecha1, Fecha2;

            Herramienta he = new Herramienta();
            int         Id = 0;

            Id = Convert.ToInt32(Session["UsuarioId"]);

            if (Id == 0 && Convert.ToInt32(Session["UsuarioCoId"]) > 0)
            {
                Id = Utilitario.ObtenerIdUsuarioAdm(Convert.ToInt32(Session["UsuarioCoId"]));
            }


            if (Id > 0)
            {
                btnCerrarSesion.Visible = true;
                UserName.InnerText      = Session["UserName"].ToString();
                UserName.Visible        = true;
            }
            else
            {
                btnCerrarSesion.Visible = false;
                UserName.InnerText      = "";
                UserName.Visible        = false;
            }

            try
            {
                //4 por el campo valor de la tabla herramienta
                if ((Utilitario.DatosHerramientas("Fecha", Id.ToString(), "4")) == "0")
                {
                    //SI EL USUARIO ES NUEVO QUE TIRE 0 PORQUE NO TIENE REGISTRO DE FECHA AUN
                }
                else
                {
                    FechaAux = Convert.ToDateTime(Utilitario.DatosHerramientas("Fecha", Id.ToString(), "4"));

                    Fecha1 = Utilitario.FormatoFecha(FechaAux.ToString());
                    Fecha2 = Utilitario.FormatoFecha(DateTime.Now.ToString());


                    if (Fecha2 != Fecha1)
                    {
                        //PONER DE ALGUNA MANERA QUE ESTA CONDICION SOLO ENTRE EL USUARIO ADMINISTRATIVO MEDIANTE OTRO LOGING SOLO PARA ADMINISTRATIVO O COMO SEA CUALQUIERA DE LOS DOS
                        he.UsuarioId = Id;
                        he.Fecha     = Utilitario.FormatoFecha(DateTime.Now.ToString());
                        he.ActualizarFecha();
                        Resultado = true;
                    }
                }
            }
            catch (Exception e)
            {
                throw e;
            }

            return(Resultado);
        }