Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.SqlClient.SqlDataReader
Partial Class o_Admin_Manage_o_AdminServeiceIsos
Inherits System.Web.UI.Page
Dim objConn As New SqlConnection
Dim objCmd As New SqlCommand
Dim strConnString, strSQL As String
Dim strGalleryID As String
Dim strCusID As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
strConnString = "Data Source=.\SQLEXPRESS;AttachDbFilename=D:\ISOS-Web-Service\App_Data\IsosDB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
objConn = New SqlConnection(strConnString)
objConn.Open()
If Not Page.IsPostBack() Then
DataListBindData()
End If
Sub DataListBindData()
strSQL = "SELECT * FROM Car_Accident order by C_SendAcDate desc"
Dim dtReader As SqlDataReader
objCmd = New SqlCommand(strSQL, objConn)
dtReader = objCmd.ExecuteReader()
'*** BindData to DataList ***'
myDataList.DataSource = dtReader
myDataList.DataBind()
dtReader.Close()
dtReader = Nothing
End Sub
Sub FormViewBindData()
strSQL = "SELECT * FROM Car_Accident WHERE C_AccidentID = " & strGalleryID
Dim dtReader As SqlDataReader
objCmd = New SqlCommand(strSQL, objConn)
dtReader = objCmd.ExecuteReader()
'*** BindData to FormView ***'
myFormView.DataSource = dtReader
myFormView.DataBind()
dtReader.Close()
dtReader = Nothing
End Sub
Sub DetailsViewBindData()
strSQL = "SELECT * FROM Car_Accident WHERE C_AccidentID = '" & strCusID & "' "
Dim dtReader As SqlDataReader
objCmd = New SqlCommand(strSQL, objConn)
dtReader = objCmd.ExecuteReader()
'*** BindData to DetailsView ***'
myDetailsView.DataSource = dtReader
myDetailsView.DataBind()
dtReader.Close()
dtReader = Nothing
End Sub
Sub Page_UnLoad()
objConn.Close()
objConn = Nothing
End Sub
Sub myDataList_ItemCommand(ByVal source As Object, ByVal e As DataListCommandEventArgs) Handles myDataList.ItemCommand
If e.CommandName = "View" Then
strGalleryID = Me.myDataList.DataKeys(e.Item.ItemIndex)
FormViewBindData()
myFormView.Visible = True
'*** เมื่อ Click ให้แสดง Detail view ขึ้นมา ***'
strCusID = Me.myDataList.DataKeys(e.Item.ItemIndex)
DetailsViewBindData()
myDetailsView.Visible = True
End If
End Sub
Sub myDataList_ItemDataBound(ByVal sender As Object, ByVal e As DataListItemEventArgs)
'*** Image ***'
Dim Image1 As ImageButton = CType(e.Item.FindControl("Image1"), ImageButton)
If Not IsNothing(Image1) Then
Image1.ImageUrl = "../images/" & e.Item.DataItem("C_PhotoName")
Image1.Width = 100
Image1.Height = 100
Image1.Attributes.Add("OnClick", "JavaScript:showImage(oImg);")
Image1.Style.Add("cursor", "hand")
End If
'*** AccidentID ***'
Dim lblC_AccidentID As Label = CType(e.Item.FindControl("lblC_AccidentID"), Label)
If Not IsNothing(lblC_AccidentID) Then
lblC_AccidentID.Text = e.Item.DataItem("C_AccidentID")
End If
'*** C_PolicyID ***'
Dim lblC_PolicyID As Label = CType(e.Item.FindControl("lblC_PolicyID"), Label)
If Not IsNothing(lblC_PolicyID) Then
lblC_PolicyID.Text = e.Item.DataItem("C_PolicyID")
End If
'*** C_SendAcDate ***'
Dim lblC_SendAcDate As Label = CType(e.Item.FindControl("lblC_SendAcDate"), Label)
If Not IsNothing(lblC_SendAcDate) Then
lblC_SendAcDate.Text = e.Item.DataItem("C_SendAcDate")
End If
End Sub
End Class
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.SqlClient.SqlDataReader
Partial Class o_Admin_Manage_o_AdminServeiceIsos
Inherits System.Web.UI.Page
Dim objConn As New SqlConnection
Dim objCmd As New SqlCommand
Dim strConnString, strSQL As String
Dim strGalleryID As String
Dim strCusID As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
strConnString = "Data Source=.\SQLEXPRESS;AttachDbFilename=D:\ISOS-Web-Service\App_Data\IsosDB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
objConn = New SqlConnection(strConnString)
objConn.Open()
If Not Page.IsPostBack() Then
DataListBindData()
End If
Sub DataListBindData()
strSQL = "SELECT * FROM Car_Accident order by C_SendAcDate desc"
Dim dtReader As SqlDataReader
objCmd = New SqlCommand(strSQL, objConn)
dtReader = objCmd.ExecuteReader()
'*** BindData to DataList ***'
myDataList.DataSource = dtReader
myDataList.DataBind()
dtReader.Close()
dtReader = Nothing
End Sub
Sub FormViewBindData()
strSQL = "SELECT * FROM Car_Accident WHERE C_AccidentID = " & strGalleryID
Dim dtReader As SqlDataReader
objCmd = New SqlCommand(strSQL, objConn)
dtReader = objCmd.ExecuteReader()
'*** BindData to FormView ***'
myFormView.DataSource = dtReader
myFormView.DataBind()
dtReader.Close()
dtReader = Nothing
End Sub
Sub DetailsViewBindData()
strSQL = "SELECT * FROM Car_Insurance WHERE C_PolicyID = '" & strCusID & "' "
Dim dtReader As SqlDataReader
objCmd = New SqlCommand(strSQL, objConn)
dtReader = objCmd.ExecuteReader()
'*** BindData to DetailsView ***'
myDetailsView.DataSource = dtReader
myDetailsView.DataBind()
dtReader.Close()
dtReader = Nothing
End Sub
Sub Page_UnLoad()
objConn.Close()
objConn = Nothing
End Sub
Sub myDataList_ItemCommand(ByVal source As Object, ByVal e As DataListCommandEventArgs) Handles myDataList.ItemCommand
If e.CommandName = "View" Then
strGalleryID = Me.myDataList.DataKeys(e.Item.ItemIndex)
FormViewBindData()
myFormView.Visible = True
'*** เมื่อ Click ให้แสดง Detail view ขึ้นมา ***'
strCusID = Me.myDataList.DataKeys(e.Item.ItemIndex)
DetailsViewBindData()
myDetailsView.Visible = True
End If
End Sub
Sub myDataList_ItemDataBound(ByVal sender As Object, ByVal e As DataListItemEventArgs)
'*** Image ***'
Dim Image1 As ImageButton = CType(e.Item.FindControl("Image1"), ImageButton)
If Not IsNothing(Image1) Then
Image1.ImageUrl = "../images/" & e.Item.DataItem("C_PhotoName")
Image1.Width = 100
Image1.Height = 100
Image1.Attributes.Add("OnClick", "JavaScript:showImage(oImg);")
Image1.Style.Add("cursor", "hand")
End If
'*** AccidentID ***'
Dim lblC_AccidentID As Label = CType(e.Item.FindControl("lblC_AccidentID"), Label)
If Not IsNothing(lblC_AccidentID) Then
lblC_AccidentID.Text = e.Item.DataItem("C_AccidentID")
End If
'*** C_PolicyID ***'
Dim lblC_PolicyID As Label = CType(e.Item.FindControl("lblC_PolicyID"), Label)
If Not IsNothing(lblC_PolicyID) Then
lblC_PolicyID.Text = e.Item.DataItem("C_PolicyID")
End If
'*** C_SendAcDate ***'
Dim lblC_SendAcDate As Label = CType(e.Item.FindControl("lblC_SendAcDate"), Label)
If Not IsNothing(lblC_SendAcDate) Then
lblC_SendAcDate.Text = e.Item.DataItem("C_SendAcDate")
End If
End Sub
End Class