134 lines
5.0 KiB
VB.net
134 lines
5.0 KiB
VB.net
Option Strict On
|
|
|
|
Imports System.Data
|
|
Imports System.Data.SqlClient
|
|
Imports System.Globalization
|
|
|
|
Partial Class chino
|
|
Inherits System.Web.UI.Page
|
|
Public astrochino, ff As String
|
|
Private dreader As SqlDataReader
|
|
Private hoy As Date = Now
|
|
Private añohoy, f1, f2, chinum 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
|
|
|
|
astrochino = ""
|
|
|
|
Dim d_fecha As Date
|
|
d_fecha = Date.Now.AddDays(0) ''noticias.UltimaFecha(31, Date.Now.ToString("yyyyMMdd")) '' 31 es chino
|
|
''
|
|
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")
|
|
|
|
añohoy = d_fecha.ToString("yyyy")
|
|
dreader = func.ver_signochino(añohoy)
|
|
|
|
Dim id As Integer = 0
|
|
If dreader.Read Then
|
|
id = CInt(dreader.Item("id")) ''determino el id correspondiente al signo actual
|
|
End If
|
|
dreader.Close()
|
|
|
|
'' 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óscopos chinos 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")
|
|
''f1 = "20070320" ''para probar
|
|
''f2 = "20070321"
|
|
''
|
|
dreader = func.lee_chino(f1, f2)
|
|
Dim chi0(), chino0 As String
|
|
chino0 = ""
|
|
If dreader.Read Then
|
|
chino0 = CStr(dreader.Item("texto")) '' lee el archivo en BD correspondiente a hoy
|
|
End If
|
|
dreader.Close()
|
|
chino0 = chino0.Replace(" ", "\") ''.Replace(Chr(10) + Chr(13), "\")
|
|
''chino0 = chino0.Replace(Chr(10) + Chr(10), "\").Replace(Chr(10) + Chr(13), "\")
|
|
chi0 = chino0.Split(CChar("\")) ''divide el archivo horos
|
|
Dim i As Integer = 0
|
|
Dim n_pos As Integer
|
|
For i = 0 To 11
|
|
|
|
If chi0(i).IndexOf(".") > 0 And chi0(i).IndexOf(".") < 12 Then
|
|
n_pos = chi0(i).IndexOf(".")
|
|
ElseIf chi0(i).IndexOf(":") > 0 And chi0(i).IndexOf(":") < 12 Then
|
|
n_pos = chi0(i).IndexOf(":")
|
|
Else
|
|
n_pos = 0
|
|
End If
|
|
If n_pos > 0 Then
|
|
chi0(i) = chi0(i).Remove(0, n_pos + 2)
|
|
End If
|
|
Dim primero As Char
|
|
primero = CChar(chi0(i)(0).ToString.ToUpper)
|
|
chi0(i) = primero + chi0(i).Remove(0, 1)
|
|
Next
|
|
|
|
Dim signos(11), textos(11), signosresumido(11) As String
|
|
|
|
|
|
For i = 0 To 11
|
|
If i <> id Then
|
|
dreader = func.lee_signoschinos(CInt(i))
|
|
If dreader.Read Then
|
|
textos(CInt(i)) = chi0(i)
|
|
|
|
signos(CInt(i)) = dreader.Item("nombre").ToString + " (" + dreader.Item("años").ToString + ")"
|
|
signosresumido(CInt(i)) = dreader.Item("nombre").ToString
|
|
|
|
astrochino += "<div class=""signo"">" + signos(CInt(i)) + "</div>" _
|
|
+ "<div class=""detalle"">" _
|
|
+ "<img src=""http://" + sitio + "/imag/horoscopo/chino/" + signosresumido(CInt(i)) + ".jpg"" " _
|
|
+ " alt=""" + signos(CInt(i)) + """ />" _
|
|
+ textos(CInt(i)) + "<div style=""clear:both""></div></div>"
|
|
|
|
End If
|
|
dreader.Close()
|
|
End If
|
|
Next
|
|
|
|
i = id
|
|
|
|
dreader = func.lee_signoschinos(CInt(i))
|
|
If dreader.Read Then
|
|
textos(CInt(i)) = chi0(i)
|
|
|
|
signos(CInt(i)) = dreader.Item("nombre").ToString + " (" + dreader.Item("años").ToString + ")"
|
|
signosresumido(CInt(i)) = dreader.Item("nombre").ToString
|
|
|
|
astrochino = "<div class=""signo"">" + signos(CInt(i)) + "</div>" _
|
|
+ "<div class=""detalle"">" _
|
|
+ "<img src=""http://" + sitio + "/imag/horoscopo/chino/" + signosresumido(CInt(i)) + ".jpg"" " _
|
|
+ " alt=""" + signos(CInt(i)) + """ />" _
|
|
+ textos(CInt(i)) + "<div style=""clear:both""></div></div>" + astrochino
|
|
|
|
End If
|
|
dreader.Close()
|
|
astrochino = func.ConvertUTF(astrochino)
|
|
|
|
End Sub
|
|
|
|
|
|
End Class
|