124 lines
4.8 KiB
VB.net
124 lines
4.8 KiB
VB.net
Option Strict On
|
|
Imports System.Data
|
|
Imports System.Data.SqlClient
|
|
Imports System.Globalization
|
|
|
|
Partial Class horoscopo
|
|
Inherits System.Web.UI.Page
|
|
|
|
Public horoscopo, comohoy, ff As String
|
|
Private dreader As SqlDataReader
|
|
Private hoy As Date = Now
|
|
Private fechahoy, f1, f2 As String
|
|
Private sitio As String = System.Configuration.ConfigurationManager.AppSettings("sitio")
|
|
Private cultura As New CultureInfo("es-ES", True)
|
|
|
|
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
|
|
|
|
Dim d_fecha As Date
|
|
d_fecha = Date.Now '' noticias.UltimaFecha(30, Date.Now.ToString("yyyyMMdd")) '' 30 es horóscopo
|
|
''
|
|
If d_fecha.ToString("MMdd") = "1225" Or d_fecha.ToString("MMdd") = "0101" Or d_fecha.ToString("MMdd") = "0501" Then ' días feriados
|
|
d_fecha = d_fecha.AddDays(-1) 'día anterior
|
|
End If
|
|
|
|
|
|
''!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
|
ff = d_fecha.ToString("D", cultura)
|
|
ff = ff.Substring(0, ff.IndexOf(","))
|
|
ff = ff + " | " + d_fecha.ToString("dd.MM.yyyy")
|
|
|
|
horoscopo = ""
|
|
|
|
fechahoy = d_fecha.ToString("MMdd")
|
|
Dim id As Integer = 0
|
|
If fechahoy < "0121" Or fechahoy > "1221" Then ''determino el id correspondiente al signo actual" Then
|
|
id = 9 ''con el cambio de año se hace lío así que lo fijo
|
|
Else
|
|
dreader = func.ver_signo(fechahoy)
|
|
If dreader.Read Then
|
|
id = CInt(dreader.Item("id")) ''determino el id correspondiente al signo actual
|
|
End If
|
|
dreader.Close()
|
|
End If
|
|
''
|
|
'' el año es par o impar ?
|
|
Dim paridad As Integer = CInt(Date.Now.ToString("yyyy")) Mod 2 '' para aprovechar los 2 años de datos que tenemos
|
|
Dim diferencia As Integer
|
|
If paridad > 0 Then
|
|
'' es impar
|
|
diferencia = 2007 - CInt(Date.Now.ToString("yyyy"))
|
|
Else
|
|
'' es año par
|
|
diferencia = 2008 - CInt(Date.Now.ToString("yyyy"))
|
|
End If
|
|
'' esto tiene en cuenta que hay "horóscopo" desde el 27/03/2007 hasta 10/11/2009
|
|
f1 = d_fecha.AddYears(diferencia).AddMonths(3).ToString("yyyyMMdd")
|
|
f2 = d_fecha.AddYears(diferencia).AddMonths(3).AddDays(1).ToString("yyyyMMdd")
|
|
dreader = func.lee_horos(f1, f2)
|
|
Dim hor(), Horos As String
|
|
Horos = ""
|
|
If dreader.Read Then
|
|
Horos = CStr(dreader.Item("texto")) '' lee el archivo en BD correspondiente a hoy
|
|
End If
|
|
dreader.Close()
|
|
Horos = Horos.Replace(" ", "\")
|
|
''Horos = Horos.Replace(Chr(10) + Chr(10), "\")
|
|
hor = Horos.Split(CChar("\")) ''divide el archivo horos
|
|
|
|
Dim signos(11), textos(11), signosresumido(11) As String
|
|
|
|
Dim i As Integer = 0
|
|
Dim largo As Integer = hor.Length
|
|
comohoy = func.ConvertUTF(hor(largo - 1))
|
|
|
|
|
|
While CBool(i <= largo - 3)
|
|
If CBool(i / 2 <> id) Then
|
|
|
|
dreader = func.lee_signos(CInt(i / 2))
|
|
If dreader.Read Then
|
|
|
|
textos(CInt(i / 2)) = hor(i + 1)
|
|
signos(CInt(i / 2)) = dreader.Item("nombre").ToString + " (" + dreader.Item("texto").ToString + ")"
|
|
signosresumido(CInt(i / 2)) = dreader.Item("nombre").ToString
|
|
|
|
horoscopo += "<div class=""signo"">" + signos(CInt(i / 2)) + "</div>" _
|
|
+ "<div class=""detalle"">" _
|
|
+ "<img src=""http://" + sitio + "/imag/horoscopo/zodiacal/" + signosresumido(CInt(i / 2)) + ".jpg"" " _
|
|
+ " alt=""" + signos(CInt(i / 2)) + """ />" _
|
|
+ textos(CInt(i / 2)) + "<div style=""clear:both""></div></div>"
|
|
|
|
End If
|
|
dreader.Close()
|
|
End If
|
|
|
|
i += 2
|
|
End While
|
|
|
|
i = 2 * id '' corrección
|
|
|
|
dreader = func.lee_signos(CInt(i / 2))
|
|
If dreader.Read Then
|
|
|
|
textos(CInt(i / 2)) = hor(i + 1)
|
|
signos(CInt(i / 2)) = dreader.Item("nombre").ToString + " (" + dreader.Item("texto").ToString + ")"
|
|
signosresumido(CInt(i / 2)) = dreader.Item("nombre").ToString
|
|
|
|
|
|
horoscopo = "<div class=""signo"">" + signos(CInt(i / 2)) + "</div>" _
|
|
+ "<div class=""detalle"">" _
|
|
+ "<img src=""http://" + sitio + "/imag/horoscopo/zodiacal/" + signosresumido(CInt(i / 2)) + ".jpg"" " _
|
|
+ " alt=""" + signos(CInt(i / 2)) + """ />" _
|
|
+ textos(CInt(i / 2)) + "<div style=""clear:both""></div></div>" + horoscopo
|
|
|
|
End If
|
|
dreader.Close()
|
|
horoscopo = func.ConvertUTF(horoscopo)
|
|
|
|
|
|
End Sub
|
|
|
|
|
|
End Class
|