Files
extras/suerte.aspx.vb

144 lines
5.5 KiB
VB.net
Raw Normal View History

2025-06-23 15:28:32 -03:00
Option Strict On
Imports System.Data
Imports System.Data.SqlClient
Imports System.Globalization
Partial Class suerte
Inherits System.Web.UI.Page
Public suertenum, ff, chinum 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
suertenum = ""
Dim d_fecha As Date
d_fecha = Date.Now ''noticias.UltimaFecha(32, Date.Now.ToString("yyyyMMdd")) '' 32 es suerte
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")
fechahoy = d_fecha.ToString("MMdd")
Dim id As Integer = 0
If fechahoy < "0121" Or fechahoy > "1221" Then ''determino el id correspondiente al signo actual
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 "suerte" 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_suerte(f1, f2)
Dim sue(), suerte As String
suerte = ""
If dreader.Read Then
suerte = CStr(dreader.Item("texto")) '' lee el archivo en BD correspondiente a hoy
End If
dreader.Close()
suerte = suerte.Trim
suerte = suerte.Replace(" ", "\")
''suerte = suerte.Replace(Chr(10) + Chr(10), "\")
sue = suerte.Split(CChar("\")) ''divide el archivo horos
Dim j As Integer = 0
Dim n_pos As Integer
If sue(j) = "" Then
suertenum = ""
Else
For j = 0 To 11
n_pos = sue(j).IndexOf(" ")
If n_pos > 0 Then
sue(j) = sue(j).Remove(0, n_pos + 1)
End If
Next
Dim signos(11), textos(11), signosresumido(11) As String
Dim i As Integer = 0
Dim largo As Integer = sue.Length
While CBool(i <= largo - 1)
If CBool(i <> id) Then
dreader = func.lee_signos(CInt(i))
If dreader.Read Then
textos(CInt(i)) = sue(i)
signos(CInt(i)) = dreader.Item("nombre").ToString + " (" + dreader.Item("texto").ToString + ")"
signosresumido(CInt(i)) = dreader.Item("nombre").ToString
suertenum += "<h2 class=""signo"">" + signos(CInt(i)) + "</h2>" _
+ "<div class=""detalle"">" _
+ "<img src=""http://" + sitio + "/imag/horoscopo/suerte/" + signosresumido(CInt(i)) + ".jpg"" " _
+ " alt=""" + signos(CInt(i)) + """ />" _
+ textos(CInt(i)) + "<div style=""clear:both""></div></div><br />"
End If
dreader.Close()
End If
i += 1
End While
i = id
dreader = func.lee_signos(CInt(i))
If dreader.Read Then
textos(CInt(i)) = sue(i)
signos(CInt(i)) = dreader.Item("nombre").ToString + " (" + dreader.Item("texto").ToString + ")"
signosresumido(CInt(i)) = dreader.Item("nombre").ToString
suertenum = "<H2 class=""signo"">" + signos(CInt(i)) + "</H2>" _
+ "<div class=""detalle"">" _
+ "<img src=""http://" + sitio + "/imag/horoscopo/suerte/" + signosresumido(CInt(i)) + ".jpg"" " _
+ " alt=""" + signos(CInt(i)) + """ />" _
+ textos(CInt(i)) + "<div style=""clear:both""></div></div>" + suertenum
End If
dreader.Close()
suertenum = "<div style=""padding: 20px 0"">Conocé los números de la suerte del día de hoy de acuerdo a tu signo del zodíaco. " + _
"También podés consultar el <a href=""https://www.eldia.com/horoscopo"" title=""Horóscopo Zodiacal"">horóscopo zodiacal</a>" + _
" y el <a href=""https://www.eldia.com/chino"" title=""Horóscopo Chino"">horóscopo chino</a>.</div>" + func.ConvertUTF(suertenum)
End If
End Sub
End Class