Option Explicit On 
Option Strict On
Option Compare Text

Imports System.Web.Security
Imports System.Data.SqlClient

Public Class MainPages
	Inherits System.Web.UI.Page
	Protected WithEvents dgMainPages As System.Web.UI.WebControls.DataGrid
	Protected WithEvents daParentPages As System.Data.SqlClient.SqlDataAdapter
	Protected WithEvents DsParentPages1 As AllSaints.dsParentPages
	Protected WithEvents SqlSelectCommand1 As System.Data.SqlClient.SqlCommand
	Protected WithEvents SqlInsertCommand1 As System.Data.SqlClient.SqlCommand
	Protected WithEvents SqlUpdateCommand1 As System.Data.SqlClient.SqlCommand
	Protected WithEvents SqlDeleteCommand1 As System.Data.SqlClient.SqlCommand
	Protected WithEvents Conn As System.Data.SqlClient.SqlConnection
	Protected WithEvents lnkLogOut As System.Web.UI.WebControls.LinkButton

#Region " Web Form Designer Generated Code "

	'This call is required by the Web Form Designer.
	<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
		Me.daParentPages = New System.Data.SqlClient.SqlDataAdapter()
		Me.SqlDeleteCommand1 = New System.Data.SqlClient.SqlCommand()
		Me.SqlInsertCommand1 = New System.Data.SqlClient.SqlCommand()
		Me.SqlSelectCommand1 = New System.Data.SqlClient.SqlCommand()
		Me.SqlUpdateCommand1 = New System.Data.SqlClient.SqlCommand()
		Me.DsParentPages1 = New AllSaints.dsParentPages()
		Me.Conn = New System.Data.SqlClient.SqlConnection()
		CType(Me.DsParentPages1, System.ComponentModel.ISupportInitialize).BeginInit()
		'
		'daParentPages
		'
		Me.daParentPages.DeleteCommand = Me.SqlDeleteCommand1
		Me.daParentPages.InsertCommand = Me.SqlInsertCommand1
		Me.daParentPages.SelectCommand = Me.SqlSelectCommand1
		Me.daParentPages.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "as_Pages", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("ID", "ID"), New System.Data.Common.DataColumnMapping("PageName", "PageName"), New System.Data.Common.DataColumnMapping("Body", "Body"), New System.Data.Common.DataColumnMapping("BodyHeading", "BodyHeading"), New System.Data.Common.DataColumnMapping("TopPicture", "TopPicture"), New System.Data.Common.DataColumnMapping("RightPicture", "RightPicture"), New System.Data.Common.DataColumnMapping("ParentID", "ParentID")})})
		Me.daParentPages.UpdateCommand = Me.SqlUpdateCommand1
		'
		'SqlDeleteCommand1
		'
		Me.SqlDeleteCommand1.CommandText = "DELETE FROM as_Pages WHERE (ID = @Original_ID) AND (Body = @Original_Body OR @Ori" & _
		"ginal_Body IS NULL AND Body IS NULL) AND (BodyHeading = @Original_BodyHeading OR" & _
		" @Original_BodyHeading IS NULL AND BodyHeading IS NULL) AND (PageName = @Origina" & _
		"l_PageName OR @Original_PageName IS NULL AND PageName IS NULL) AND (ParentID = @" & _
		"Original_ParentID OR @Original_ParentID IS NULL AND ParentID IS NULL) AND (Right" & _
		"Picture = @Original_RightPicture OR @Original_RightPicture IS NULL AND RightPict" & _
		"ure IS NULL) AND (TopPicture = @Original_TopPicture OR @Original_TopPicture IS N" & _
		"ULL AND TopPicture IS NULL)"
		Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "ID", System.Data.DataRowVersion.Original, Nothing))
		Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Body", System.Data.SqlDbType.VarChar, 255, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Body", System.Data.DataRowVersion.Original, Nothing))
		Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_BodyHeading", System.Data.SqlDbType.VarChar, 255, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "BodyHeading", System.Data.DataRowVersion.Original, Nothing))
		Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_PageName", System.Data.SqlDbType.VarChar, 255, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "PageName", System.Data.DataRowVersion.Original, Nothing))
		Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ParentID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "ParentID", System.Data.DataRowVersion.Original, Nothing))
		Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_RightPicture", System.Data.SqlDbType.VarChar, 255, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "RightPicture", System.Data.DataRowVersion.Original, Nothing))
		Me.SqlDeleteCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_TopPicture", System.Data.SqlDbType.VarChar, 255, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "TopPicture", System.Data.DataRowVersion.Original, Nothing))
		'
		'SqlInsertCommand1
		'
		Me.SqlInsertCommand1.CommandText = "INSERT INTO as_Pages(PageName, Body, BodyHeading, TopPicture, RightPicture, Paren" & _
		"tID) VALUES (@PageName, @Body, @BodyHeading, @TopPicture, @RightPicture, @Parent" & _
		"ID); SELECT ID, PageName, Body, BodyHeading, TopPicture, RightPicture, ParentID " & _
		"FROM as_Pages WHERE (ID = @@IDENTITY)"
		Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@PageName", System.Data.SqlDbType.VarChar, 255, "PageName"))
		Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Body", System.Data.SqlDbType.VarChar, 255, "Body"))
		Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@BodyHeading", System.Data.SqlDbType.VarChar, 255, "BodyHeading"))
		Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@TopPicture", System.Data.SqlDbType.VarChar, 255, "TopPicture"))
		Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RightPicture", System.Data.SqlDbType.VarChar, 255, "RightPicture"))
		Me.SqlInsertCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ParentID", System.Data.SqlDbType.Int, 4, "ParentID"))
		'
		'SqlSelectCommand1
		'
		Me.SqlSelectCommand1.CommandText = "SELECT ID, PageName, Body, BodyHeading, TopPicture, RightPicture, ParentID FROM a" & _
		"s_Pages WHERE (ParentID = 0)"
		Me.SqlSelectCommand1.Connection = Me.Conn
		'
		'SqlUpdateCommand1
		'
		Me.SqlUpdateCommand1.CommandText = "UPDATE as_Pages SET PageName = @PageName, Body = @Body, BodyHeading = @BodyHeadin" & _
		"g, TopPicture = @TopPicture, RightPicture = @RightPicture, ParentID = @ParentID " & _
		"WHERE (ID = @Original_ID) AND (Body = @Original_Body OR @Original_Body IS NULL A" & _
		"ND Body IS NULL) AND (BodyHeading = @Original_BodyHeading OR @Original_BodyHeadi" & _
		"ng IS NULL AND BodyHeading IS NULL) AND (PageName = @Original_PageName OR @Origi" & _
		"nal_PageName IS NULL AND PageName IS NULL) AND (ParentID = @Original_ParentID OR" & _
		" @Original_ParentID IS NULL AND ParentID IS NULL) AND (RightPicture = @Original_" & _
		"RightPicture OR @Original_RightPicture IS NULL AND RightPicture IS NULL) AND (To" & _
		"pPicture = @Original_TopPicture OR @Original_TopPicture IS NULL AND TopPicture I" & _
		"S NULL); SELECT ID, PageName, Body, BodyHeading, TopPicture, RightPicture, Paren" & _
		"tID FROM as_Pages WHERE (ID = @ID)"
		Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@PageName", System.Data.SqlDbType.VarChar, 255, "PageName"))
		Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Body", System.Data.SqlDbType.VarChar, 255, "Body"))
		Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@BodyHeading", System.Data.SqlDbType.VarChar, 255, "BodyHeading"))
		Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@TopPicture", System.Data.SqlDbType.VarChar, 255, "TopPicture"))
		Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RightPicture", System.Data.SqlDbType.VarChar, 255, "RightPicture"))
		Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ParentID", System.Data.SqlDbType.Int, 4, "ParentID"))
		Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "ID", System.Data.DataRowVersion.Original, Nothing))
		Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_Body", System.Data.SqlDbType.VarChar, 255, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "Body", System.Data.DataRowVersion.Original, Nothing))
		Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_BodyHeading", System.Data.SqlDbType.VarChar, 255, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "BodyHeading", System.Data.DataRowVersion.Original, Nothing))
		Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_PageName", System.Data.SqlDbType.VarChar, 255, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "PageName", System.Data.DataRowVersion.Original, Nothing))
		Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_ParentID", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "ParentID", System.Data.DataRowVersion.Original, Nothing))
		Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_RightPicture", System.Data.SqlDbType.VarChar, 255, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "RightPicture", System.Data.DataRowVersion.Original, Nothing))
		Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@Original_TopPicture", System.Data.SqlDbType.VarChar, 255, System.Data.ParameterDirection.Input, False, CType(0, Byte), CType(0, Byte), "TopPicture", System.Data.DataRowVersion.Original, Nothing))
		Me.SqlUpdateCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@ID", System.Data.SqlDbType.Int, 4, "ID"))
		'
		'DsParentPages1
		'
		Me.DsParentPages1.DataSetName = "dsParentPages"
		Me.DsParentPages1.Locale = New System.Globalization.CultureInfo("en-US")
		Me.DsParentPages1.Namespace = "http://www.tempuri.org/dsParentPages.xsd"
		'
		'Conn
		'
		Me.Conn.ConnectionString = "data source=localhost;initial catalog=allsaints;persist security info=False;user " & _
		"id=sa;workstation id=GALAXY;packet size=4096"
		CType(Me.DsParentPages1, System.ComponentModel.ISupportInitialize).EndInit()

	End Sub

	Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
		'CODEGEN: This method call is required by the Web Form Designer
		'Do not modify it using the code editor.
		InitializeComponent()
	End Sub

#End Region

	Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		Dim sConStr As String = ConfigurationSettings.AppSettings("sConnection")
		Conn.ConnectionString = sConStr

		If Not Page.IsPostBack Then
			daParentPages.Fill(DsParentPages1)
			dgMainPages.DataBind()
		End If
	End Sub

	Private Sub lnkLogOut_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lnkLogOut.Click
		FormsAuthentication.SignOut()
		Response.Redirect("Login.aspx")
	End Sub
End Class
