Option Explicit On 
Option Strict On

Imports System.Data
Imports System.Data.SqlClient
Imports System.DateTime

Public MustInherit Class PicnicView
	Inherits System.Web.UI.UserControl
	Protected WithEvents lblError As System.Web.UI.WebControls.Label
	Protected WithEvents pnlViewCensus As System.Web.UI.WebControls.Panel
	Protected WithEvents lblLName As System.Web.UI.WebControls.Label
	Protected WithEvents lblMaidenName As System.Web.UI.WebControls.Label
	Protected WithEvents lblYrGraduate As System.Web.UI.WebControls.Label
	Protected WithEvents lblComments As System.Web.UI.WebControls.Label
	Protected WithEvents lblPhone As System.Web.UI.WebControls.Label

	Protected WithEvents lblFormerPos As System.Web.UI.WebControls.Label
	Protected WithEvents lblFormerPosYears As System.Web.UI.WebControls.Label
	Protected WithEvents lblAlumnus As System.Web.UI.WebControls.Label
	Protected WithEvents lblFormer As System.Web.UI.WebControls.Label
	Protected WithEvents lblNoAttendingsAdult As System.Web.UI.WebControls.Label
	Protected WithEvents lblNoAttendingsChild As System.Web.UI.WebControls.Label
	Dim _PicnicID As Integer

#Region " Web Form Designer Generated Code "

	'This call is required by the Web Form Designer.
	<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

	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

	Public Property PicnicID() As Integer
		Get
			Return _PicnicID
		End Get
		Set(ByVal Value As Integer)
			_PicnicID = Value
		End Set
	End Property


	Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		'On Error Resume Next
		If _PicnicID <> 0 Then
			Dim cmd As New SqlCommand()
			Dim dr As SqlDataReader
			Dim conn As New SqlConnection(ConfigurationSettings.AppSettings("sConnection"))
			With cmd
				.CommandText = "Select * from as_PicnicForm where ID=" & _PicnicID
				.Connection = conn
				.CommandType = CommandType.Text
				If conn.State = ConnectionState.Closed Then conn.Open()
				'Response.Write(.CommandText & vbCrLf)
				dr = .ExecuteReader()

				If Not dr.Read Then
					lblError.Text = "<BR><p align=center><span class=maintitle2><b>No parish picnic registration record data found !</b></span></p><BR>"
					lblError.Visible = True
					pnlViewCensus.Visible = False
					Exit Sub
				Else
					lblLName.Text = CStr(dr.Item("LastName"))
					lblNoAttendingsAdult.Text = CStr(dr.Item("AttendingsAdult"))
					lblNoAttendingsChild.Text = CStr(dr.Item("AttendingsChildren"))
					lblMaidenName.Text = CStr(dr.Item("MaidenName"))
					lblPhone.Text = "(" & CStr(dr.Item("PhoneExt")) & ") " & CStr(dr.Item("Phone"))

					lblAlumnus.Text = CType(IIf(CType(dr.Item("Alumnus"), Boolean), "YES", "NO"), String)
					lblYrGraduate.Text = CStr(dr.Item("GraduateYear"))

					lblFormer.Text = CType(IIf(CType(dr.Item("Former"), Boolean), "YES", "NO"), String)
					lblFormerPos.Text = CStr(dr.Item("FormerPosition"))
					lblFormerPosYears.Text = CStr(dr.Item("FormerYears"))

					lblComments.Text = CStr(dr.Item("Comments"))
				End If
			End With
		End If
	End Sub
End Class
