001.
<%@ Import
Namespace
=
"system.data.sqlclient"
%>
002.
003.
<script language=
"vbscript"
runat=
"server"
>
004.
Sub
page_load()
005.
If
Not
IsPostBack
Then
006.
Dim
mycon
As
SqlConnection
007.
Dim
mycmd
As
SqlCommand
008.
Dim
myrd
As
SqlDataReader
009.
Dim
tmpsql
As
String
010.
mycon =
New
SqlConnection(
"data source=.;Initial Catalog=hotel;Integrated Security=true"
)
011.
mycon.Open()
012.
013.
tmpsql =
"select DepartmentName from Department "
014.
mycmd =
New
SqlCommand(tmpsql, mycon)
015.
myrd = mycmd.ExecuteReader()
016.
017.
DropDownList1.DataSource = myrd
018.
DropDownList1.DataTextField =
"DepartmentName"
019.
DropDownList1.DataBind()
020.
DropDownList1.Items.Insert(0,
New
ListItem(
"select DepartmentName"
, -1))
021.
myrd.Close()
022.
mycon.Close()
023.
End
If
024.
025.
End
Sub
026.
Sub
bindproducts(
ByVal
intcatid
As
Integer
)
027.
Dim
myconn
As
SqlConnection
028.
Dim
mycommand
As
SqlCommand
029.
Dim
myreader
As
SqlDataReader
030.
Dim
tmpsql
As
String
031.
myconn =
New
SqlConnection(
"data source=.;initial catalog=hotel;integrated security=true"
)
032.
myconn.Open()
033.
tmpsql =
"SELECT Department.DepartmentName AS Expr1, Employee.fullName AS Expr2, Employee.Gender AS Expr3, Employee.Age AS Expr4, Employee.BOD AS Expr5, Employee.phoneNumber AS Expr6, Address.Village AS Expr7, Address.City AS Expr8, Address.province AS Expr9, Income.[Position] AS Expr10, Income.salary AS Expr11, Income.serviceTag AS Expr12, [employee start].HireDate AS Expr13, [employee start].StaffDate AS Expr14 FROM Department INNER JOIN Employee ON Department.DepartmentID = Employee.DepartmentID INNER JOIN Address ON Employee.employeeID = Address.employeeID INNER JOIN Income ON Employee.employeeID = Income.employeeID INNER JOIN [employee start] ON Employee.employeeID = [employee start].employeeID where DepartmentID=@catid"
034.
mycommand =
New
SqlCommand(tmpsql, myconn)
035.
mycommand.Parameters.AddWithValue(
"@catid"
, intcatid)
036.
myreader = mycommand.ExecuteReader()
037.
Repeater1.DataSource = myreader
038.
Repeater1.DataBind()
039.
040.
myreader.Close()
041.
myconn.Close()
042.
043.
End
Sub
044.
045.
Sub
dropdownlist1_changed(
ByVal
s
As
Object
,
ByVal
e
As
EventArgs)
046.
Dim
intcatid
As
Integer
047.
intcatid = DropDownList1.SelectedIndex.ToString
048.
If
intcatid <> -1
Then
049.
bindproducts(intcatid)
050.
End
If
051.
End
Sub
052.
053.
</script>
054.
056.
<head runat=
"server"
>
057.
<title>Untitled Page</title>
058.
</head>
059.
<body bgcolor=
"#6600cc"
>
060.
<form id=
"form1"
runat=
"server"
>
061.
<div style=
"text-align: center"
>
062.
<span style=
"font-size: 32pt"
><span style=
"color: #cc0000"
>Management Hotel System</span><br />
063.
<br />
064.
<span style=
"font-size: 16pt; color: #ffcc33"
>
Select
Department
065.
<br />
066.
<br />
067.
<asp:dropdownlist style=
"left: 311px; top: 142px;"
id=
"DropDownList1"
autopostback=
"true"
068.
onselectedindexchanged=
"DropDownList1_changed"
runat=
"server"
height=
"32px"
width=
"197px"
>
069.
</asp:dropdownlist>
070.
<asp:button style=
"left: 362px; top: 199px;"
id=
"Button1"
runat=
"server"
text=
"View"
071.
width=
"87px"
height=
"21px"
/>
072.
<table border=
"1"
width=
""
style=
"background-color: yellow"
>
073.
<?xml namespace=
""
prefix=
"ASP"
?>
074.
<?xml namespace=
""
prefix=
"ASP"
?>
075.
<asp:repeater id=
"Repeater1"
enableviewstate=
"false"
runat=
"server"
>
076.
077.
<ItemTemplate>
078.
<tr>
079.
<td width=
"300"
> <%#Container.DataItem(
"fullName"
)%></td>
080.
081.
<td width=
"200"
align =
"right"
><%#Container.DataItem(
"BOD"
)%> </td>
082.
<td width=
""
align =
"center"
><%#Container.DataItem(
"Gender"
)%> </td>
083.
<td width=
"100"
align =
"right"
><%#Container.DataItem(
"PhoneNumber"
)%> </td>
084.
<td width=
"100"
align =
"right"
><%#Container.DataItem(
"Village"
)%> </td>
085.
<td width=
"100"
align =
"right"
><%#Container.DataItem(
"City"
)%> </td>
086.
</tr>
087.
088.
089.
090.
</ItemTemplate></asp:repeater>
091.
<td style=
"width: 300px"
>
092.
</td>
093.
<td align=
"right"
width=
"200"
>
094.
</td>
095.
<td style=
"width: 300px"
>
096.
</td>
097.
</table>
098.
<br />
099.
</span></span>
100.
</div>
101.
</form>
102.
</body>
103.
</html>