1: Imports System.Data
2: Imports System.Data.SqlClient
3: Imports System.Configuration.ConfigurationManager
4:
5: Partial Class _Default
6: Inherits System.Web.UI.Page
7: Protected WithEvents EditControls As System.Web.UI.WebControls.Label
8: Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
9: If Request.Browser.Platform = "WinCE" Then
10: Response.Redirect("/mobile")
11: End If
12: Dim sqlConn As ConnectionStringSettings
13: sqlConn = ConfigurationManager.ConnectionStrings("SQLServer")
14: Dim objConn As New SqlConnection(sqlConn.ConnectionString)
15: objConn.Open()
16: Dim objRecords As New SqlDataAdapter
17: Dim objCommand As New SqlCommand
18:
19: Dim objSetPrevLinks As New DataSet
20: Dim objSetBlog As New DataSet
21: Dim strMonth, strYear, strSQL As String
22: Try
23: strSQL = "exec GetPrevPostCount"
24: objCommand = New SqlCommand(strSQL, objConn)
25: objRecords.SelectCommand = objCommand
26: objRecords.Fill(objSetPrevLinks)
27: objPrevEntries.DataSource = objSetPrevLinks
28: objPrevEntries.DataBind()
29: Catch ex As Exception
30: End Try
31:
32: If Request.QueryString("month") <> "" Then
33: strMonth = Left(Request.QueryString("month"), 2)
34: strYear = Right(Request.QueryString("month"), 4)
35: strSQL = "select * from Blog where PostType=1 and datepart(month, DateAdded)="
36: strSQL = strSQL & strMonth
37: strSQL = strSQL & " and datepart(year, DateAdded)="
38: strSQL = strSQL & strYear
39: strSQL = strSQL & " order by ID desc"
40: Else
41: If Request.QueryString("id") <> "" Then
42: strSQL = "select * from Blog where ID=" & Request.QueryString("id") & " and PostType=1"
43: Else
44: strSQL = "select top 10 * from Blog where PostType=1 order by ID desc"
45: End If
46: End If
47: Try
48: objCommand = New SqlCommand(strSQL, objConn)
49: objRecords.SelectCommand = objCommand
50: objRecords.Fill(objSetBlog)
51: objBlog.DataSource = objSetBlog
52: objBlog.DataBind()
53: If User.IsInRole("Administrator") Then
54: Trace.Warn("Identity Confirmed...")
55: For index As Integer = 0 To objBlog.Items.Count - 1
56: Dim lbl As Label = CType(objBlog.Items(index).FindControl("EditControls"), Label)
57: If lbl.Visible = False Then
58: lbl.Visible = True
59: End If
60: If lbl.Enabled = False Then
61: lbl.Enabled = True
62: End If
63: Next
64: End If
65: Catch ex As Exception
66: ' BlogFucked.Text = "Oh Oh... there seems to be a problem with my database connection. Try <a href=""http://davewhite.net"">reloading the page</a>. It'll get fixed as soon as I can."
67: BlogFucked.Text = ex.Message
68: Finally
69: objRecords.Dispose()
70: objCommand.Dispose()
71: objConn.Close()
72: End Try
73: If User.Identity.Name = "Dave White" Then
74: End If
75: End Sub
76:
77: Public Function UpdatedString(ByVal PostedDate As Date, ByVal UpdatedDate As Date)
78: If PostedDate.AddHours(1) >= UpdatedDate Then
79: Return " "
80: Else
81: Return " (Updated on " & UpdatedDate.ToLongDateString & " at " & UpdatedDate.Hour & ":" & UpdatedDate.Minute.ToString.PadLeft(2, "0") & ")"
82: End If
83: End Function
84: End Class