コード例 #1
0
    //Mostrar el tiempo que se ha utilizado el temporizador en el dia
    private void ActualizarTiempoTotal()
    {
        //Recuperar de la bd el tiempo de trabajo almacenado hoy
        EstadisticasDB estadisticasDB = new EstadisticasDB(); //Abrir conexion a la bd
        string         fechaActual    = DateTime.Today.Date.ToShortDateString();
        float          tiempoHoy      = 0.0f;

        System.Data.IDataReader reader = estadisticasDB.TiempoTotalActividadHoy(fechaActual); //Realizar consulta a la bd
        while (reader.Read())
        {
            if (!reader.IsDBNull(0))
            {
                tiempoHoy = reader.GetFloat(0);
            }
        }

        int horas   = (int)(tiempoHoy / 60.0f);
        int minutos = (int)(tiempoHoy % 60.0f);

        tiempoTotal.text = horas.ToString("D2") + ":" + minutos.ToString("D2");

        estadisticasDB.close(); //Cerrar la conexion a la bd
    }