Example #1
0
        private void ComprobarComunicadosYFaltasConIngreso()  //Comprueba si hemos visto el comunicado más reciente
        {
            Cls.ClsUsuario ObjUsuario    = new Cls.ClsUsuario();
            DataTable      DTComunicados = ObjUsuario.BuscarComunicado();

            if (DTComunicados.Rows.Count != 0)
            {                                      //Si existe un comunicado sigo con los condicionales
                string ComunicadoLocal = DTComunicados.Rows[0][1].ToString();
                if (Comunicado != ComunicadoLocal) //Si no se ha visto el comunicado lo muestro
                {
                    PnlMensaje.Invoke((MethodInvoker)(() => PnlMensaje.Visible = true));
                    LblAutor.Invoke((MethodInvoker)(() => LblAutor.Text = "AUTOR: " + DTComunicados.Rows[0][0].ToString()));
                    LblContenido.Invoke((MethodInvoker)(() => LblContenido.Text = DTComunicados.Rows[0][1].ToString()));
                    Comunicado = LblContenido.Text;//Almaceno el comunicado como el más reciente
                    DateTime Fecha = DateTime.Parse(DTComunicados.Rows[0][2].ToString());
                    LblFecha.Invoke((MethodInvoker)(() => LblFecha.Text = Fecha.Day.ToString() + "/" + Fecha.Month.ToString() + "/" + Fecha.Year.ToString()));
                    LblCreditos.Invoke((MethodInvoker)(() => LblCreditos.Visible = false));
                }
            }
            try
            {                                                                                                //intento cargar el gridview
                DestGVDest.Invoke((MethodInvoker)(() => DestGVDest.DataSource = ObjUsuario.BuscarFaltas())); //Actualizo el gridview
            }
            catch {                                                                                          //sino sigo sin detener el programa
            }
            Thread.Sleep(5000);                                                                              //Duermo el hilo 5 segundos antes de seguir
            ComprobarComunicadosYFaltasConIngreso();                                                         //vuelvo a realizarlo
        }
Example #2
0
        private void CargarComunicado()  //Carga por primera vez el último comunicado ingresado
        {
            Cls.ClsUsuario ObjUsuario    = new Cls.ClsUsuario();
            DataTable      DTComunicados = ObjUsuario.BuscarComunicado();

            try{  //si no puedo realizarlo sigo
                if (DTComunicados.Rows.Count != 0)
                { //Si existe un comunicado muestro el panel de comunicados y cargo el comunicado
                    PnlMensaje.Visible = true;
                    LblAutor.Text      = "AUTOR: " + DTComunicados.Rows[0][0].ToString();
                    LblContenido.Text  = DTComunicados.Rows[0][1].ToString();
                    Comunicado         = LblContenido.Text;//Almaceno el comunicado como el más reciente
                    DateTime Fecha = DateTime.Parse(DTComunicados.Rows[0][2].ToString());
                    LblFecha.Text       = Fecha.Day.ToString() + "/" + Fecha.Month.ToString() + "/" + Fecha.Year.ToString();
                    LblCreditos.Visible = false;
                }

                Thread Tr = new Thread(ComprobarComunicadosYFaltasConIngreso); //Comienzo a buscar por nuevo contenido
                Tr.IsBackground = true;                                        //Lo utilizo para que el hilo se cierre con el programa
                Tr.Start();
            }
            catch { }
        }