<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="System.Data.SqlClient"%>
<%@ Page Language="VB" %>
<script runat="server">
Dim objConn As SqlConnection
Dim objCmd As SqlCommand
Dim dtReader As SqlDataReader
Dim strConnString, strSQL As String
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
strConnString = "Data Source=.\SQLEXPRESS;AttachDbFilename=D:\Project\web site\App_Data\Activity.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"
objConn = New SqlConnection(strConnString)
objConn.Open()
'Dim empid As String = Request.QueryString("emp")
'Me.lblempid.Text = empid
Dim acid As String = Request.QueryString("acid")
Me.lblacid.Text = acid
Dim dtAdapter As SqlDataAdapter
Dim dt1 As New DataTable
strSQL = "SELECT * FROM Calendar_Activity WHERE AcID = '" & Me.lblacid.Text & "'"
dtAdapter = New SqlDataAdapter(strSQL, objConn)
dtAdapter.Fill(dt1)
If dt1.Rows.Count > 0 Then
Me.lblname.Text = dt1.Rows(0)("AcName")
Me.lbldate.Text = dt1.Rows(0)("AcDate")
Me.lblmonth.Text = dt1.Rows(0)("AcMonth")
Me.lblyear.Text = dt1.Rows(0)("AcYear")
Me.lblterm.Text = dt1.Rows(0)("Term")
Me.lbledu.Text = dt1.Rows(0)("Eduyear")
End If
If Not Page.IsPostBack() Then
BindData()
End If
End Sub
Sub BindData()
Dim objConn As New SqlConnection
Dim objCmd As New SqlCommand
Dim dtAdapter As New SqlDataAdapter
Dim ds As New DataSet
Dim strConnString, strSQL As String
Dim acid As String = Request.QueryString("acid")
Me.lblacid.Text = acid
strConnString = "Data Source=.\SQLEXPRESS;AttachDbFilename=D:\Project\web site\App_Data\Activity.mdf;Integrated Security=True;Max Pool Size=5000;Connect Timeout=30;User Instance=True"
strSQL = "SELECT Student.StdID,StdFName,StdLName,Gender,Faculty,HouseNo,SubDistrict,District,Province,ZipCode,Email,Phone FROM Student,Calendar_Activity ,Do_Activitys WHERE(Do_Activitys.StdID = Student.StdID) AND Do_Activitys.AcID = '" & Me.lblacid.Text & "'"
objConn = New SqlConnection(strConnString)
With objCmd
.Connection = objConn
.CommandText = strSQL
.CommandType = CommandType.Text
End With
dtAdapter.SelectCommand = objCmd
dtAdapter.Fill(ds)
'*** BindData to GridView ***'
myGridView.DataSource = ds
myGridView.DataBind()
dtAdapter = Nothing
'objConn.Close()
'objConn = Nothing
End Sub
Sub myGridView_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
'*** StdID ***'
Dim stdid As Label = CType(e.Row.FindControl("StdID"), Label)
If Not IsNothing(stdid) Then
stdid.Text = e.Row.DataItem("StdID")
End If
'*** StdFName ***'
Dim stdfname As Label = CType(e.Row.FindControl("StdFName"), Label)
If Not IsNothing(stdfname) Then
stdfname.Text = e.Row.DataItem("StdFName")
End If
'*** StdLName ***'
Dim stdlname As Label = CType(e.Row.FindControl("StdLName"), Label)
If Not IsNothing(stdlname) Then
stdlname.Text = e.Row.DataItem("StdLName")
End If
'*** Gender ***'
Dim gender As Label = CType(e.Row.FindControl("Gender"), Label)
If Not IsNothing(gender) Then
gender.Text = e.Row.DataItem("Gender")
End If
'*** Faculty ***'
Dim faculty As Label = CType(e.Row.FindControl("Faculty"), Label)
If Not IsNothing(faculty) Then
faculty.Text = e.Row.DataItem("Faculty")
End If
'*** HouseNo ***'
Dim houseno As Label = CType(e.Row.FindControl("HouseNo"), Label)
If Not IsNothing(houseno) Then
houseno.Text = e.Row.DataItem("HouseNo")
End If
'*** SubDistrict ***'
Dim subdistrict As Label = CType(e.Row.FindControl("SubDistrict"), Label)
If Not IsNothing(subdistrict) Then
subdistrict.Text = e.Row.DataItem("SubDistrict")
End If
'*** District ***'
Dim district As Label = CType(e.Row.FindControl("District"), Label)
If Not IsNothing(district) Then
district.Text = e.Row.DataItem("District")
End If
'*** Province ***'
Dim province As Label = CType(e.Row.FindControl("Province"), Label)
If Not IsNothing(province) Then
province.Text = e.Row.DataItem("Province")
End If
'*** ZipCode ***'
Dim zipcode As Label = CType(e.Row.FindControl("ZipCode"), Label)
If Not IsNothing(zipcode) Then
zipcode.Text = e.Row.DataItem("ZipCode")
End If
'*** Email ***'
Dim email As Label = CType(e.Row.FindControl("Email"), Label)
If Not IsNothing(email) Then
email.Text = e.Row.DataItem("Email")
End If
'*** Phone ***'
Dim phone As Label = CType(e.Row.FindControl("Phone"), Label)
If Not IsNothing(phone) Then
phone.Text = e.Row.DataItem("Phone")
End If
End Sub
Sub ShowPageCommand(ByVal s As Object, ByVal e As GridViewPageEventArgs)
myGridView.PageIndex = e.NewPageIndex
BindData()
End Sub
Protected Sub btn_close_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim empid As String = Request.QueryString("emp")
Response.Redirect("employee_search_acid.aspx?def=" & empid)
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<style type="text/css">
#form1
{
width: 1302px;
}
.newStyle1
{
background-color: #FFFF99;
border: thin solid #800080;
}
</style>
</head>
<body bgcolor="White">
<form id="form1" runat="server">
<asp:Label ID="lblempid" runat="server"></asp:Label>
<b>
<br />
</b>
รหัสกิจกรรม :<b>
<asp:Label ID="lblacid" runat="server" Font-Size="14pt"></asp:Label>
</b>
ชื่อกิจกรรม :<b>
<asp:Label ID="lblname" runat="server" Font-Size="14pt"></asp:Label>
<br />
</b>
วันที่ดำเนินกิจกรรม : <b>
<asp:Label ID="lbldate" runat="server" Font-Size="14pt"></asp:Label>
<asp:Label ID="lblmonth" runat="server" Font-Size="14pt"></asp:Label>
<asp:Label ID="lblyear" runat="server" Font-Size="14pt"></asp:Label>
<br />
</b>
ภาคเรียนที่ : <b>
<asp:Label ID="lblterm" runat="server" Font-Size="14pt"></asp:Label>
</b>
ปีการศึกษา :<b>
<asp:Label ID="lbledu" runat="server" Font-Size="14pt"></asp:Label>
<br />
</b>
<br />
<br />
<asp:GridView ID="myGridView" runat="server" BorderColor="Black" Width="1300px">
<FooterStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<RowStyle BorderColor="Black" Font-Size="14pt" HorizontalAlign="Center"
VerticalAlign="Middle" />
<PagerStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<SelectedRowStyle BorderColor="Black" HorizontalAlign="Center"
VerticalAlign="Middle" />
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<EmptyDataRowStyle HorizontalAlign="Center" VerticalAlign="Middle" />
<Columns>
<asp:TemplateField HeaderText="#" >
<ItemTemplate>
<%# Container.DataItemIndex + 1 %>
</ItemTemplate>
<ControlStyle Width="40px" />
<FooterStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="40px" />
<HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="40px" />
<ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="40px" />
</asp:TemplateField>
</Columns>
<EditRowStyle HorizontalAlign="Center" VerticalAlign="Middle" />
</asp:GridView>
<br />
<br />
<asp:Button ID="btn_close" runat="server" Font-Size="Medium" Text="กลับ"
Width="70px" onclick="btn_close_Click" />
<br />
</form>
</body>
</html>