<%@ Import Namespace="system.data.sqlclient" %>
<script language="vbscript" runat="server">
Sub page_load()
If Not IsPostBack Then
Dim mycon As SqlConnection
Dim mycmd As SqlCommand
Dim myrd As SqlDataReader
Dim tmpsql As String
mycon = New SqlConnection("data source=.;Initial Catalog=hotel;Integrated Security=true")
mycon.Open()
tmpsql = "select DepartmentName from Department "
mycmd = New SqlCommand(tmpsql, mycon)
myrd = mycmd.ExecuteReader()
DropDownList1.DataSource = myrd
DropDownList1.DataTextField = "DepartmentName"
DropDownList1.DataBind()
DropDownList1.Items.Insert(0, New ListItem("select DepartmentName", -1))
myrd.Close()
mycon.Close()
End If
End Sub
Sub bindproducts(ByVal intcatid As Integer)
Dim myconn As SqlConnection
Dim mycommand As SqlCommand
Dim myreader As SqlDataReader
Dim tmpsql As String
myconn = New SqlConnection("data source=.;initial catalog=hotel;integrated security=true")
myconn.Open()
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"
mycommand = New SqlCommand(tmpsql, myconn)
mycommand.Parameters.AddWithValue("@catid", intcatid)
myreader = mycommand.ExecuteReader()
Repeater1.DataSource = myreader
Repeater1.DataBind()
myreader.Close()
myconn.Close()
End Sub
Sub dropdownlist1_changed(ByVal s As Object, ByVal e As EventArgs)
Dim intcatid As Integer
intcatid = DropDownList1.SelectedIndex.ToString
If intcatid <> -1 Then
bindproducts(intcatid)
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body bgcolor="#6600cc">
<form id="form1" runat="server">
<div style="text-align: center">
<span style="font-size: 32pt"><span style="color: #cc0000">Management Hotel System</span><br />
<br />
<span style="font-size: 16pt; color: #ffcc33">Select Department
<br />
<br />
<asp:dropdownlist style="left: 311px; top: 142px;" id="DropDownList1" autopostback="true"
onselectedindexchanged="DropDownList1_changed" runat="server" height="32px" width="197px">
</asp:dropdownlist>
<asp:button style="left: 362px; top: 199px;" id="Button1" runat="server" text="View"
width="87px" height="21px" />
<table border="1" width="" style="background-color: yellow">
<?xml namespace="" prefix="ASP" ?>
<?xml namespace="" prefix="ASP" ?>
<asp:repeater id="Repeater1" enableviewstate="false" runat="server">
<ItemTemplate>
<tr>
<td width="300"> <%#Container.DataItem("fullName")%></td>
<td width="200" align ="right" ><%#Container.DataItem("BOD")%> </td>
<td width="" align ="center" ><%#Container.DataItem("Gender")%> </td>
<td width="100" align ="right" ><%#Container.DataItem("PhoneNumber")%> </td>
<td width="100" align ="right" ><%#Container.DataItem("Village")%> </td>
<td width="100" align ="right" ><%#Container.DataItem("City")%> </td>
</tr>
</ItemTemplate></asp:repeater>
<td style="width: 300px">
</td>
<td align="right" width="200">
</td>
<td style="width: 300px">
</td>
</table>
<br />
</span></span>
</div>
</form>
</body>
</html>