我基本上试图合并两段现有代码。
第一部分是一个SQL填充的选择框。获取登录管理器下面的所有人员的列表,并使用此列表填充选择选项。
第二部分是一个由SQL填充的表,它会为预订的休假期间的每个实例带回一个新行。
因为它只是我有一张桌子,显示我自己的假期和一个包含所有经理的选择框
我如何加入这两个,所以当我更改所选项目时,它会重新填充表格?
我有一个变量
strEmployee = Request.Form("selectUN")
但我不知道该把它放在哪里以及如何使表格重新填充。
提前致谢!
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#INCLUDE virtual="/incs/KAMBE_SQL.asp" -->
<!--#INCLUDE virtual="/incs/KAMHR_SQL.asp" -->
<%
'Query O/S for User and etc
Dim strUser
strUser = mid(Request.ServerVariables("LOGON_USER"),12)
Dim msqlSQL, objRSSQL, strManager, strFullname, strEmailAddress,strEmployee, strEntitlement, cnum, HolidayRows, strNoRecords, TeamMemberRows, strYourTeam
strEmployee = Request.Form("selectUN")
'USER SELECTION ----------------------------------------------------------------------------------------------------------------
'Creates variable containing logged in users full name--------------------
msqlSQL = "SELECT KAM_STAFF.Fullname " & _
"FROM KAM_STAFF " & _
"WHERE (((KAM_STAFF.Username)='" & strUser & "'))"
Set objRSSQL = Server.CreateObject("ADODB.Recordset")
objRSSQL.Open msqlSQL, objConnSQL
If Not objRSSQL.EOF Then
strFullname = objRSSQL.Fields("FullName")
End If
objRSSQL.Close
Set objRSSQL = Nothing
'Creates variable containing logged in users full name--------------------
'collects all users where line manager = full name of logged in user------
msqlSQL = "SELECT kam_staff.fullname, kam_staff.username, kam_staff.ManagerCopy " & _
"FROM KAM_STAFF " & _
"WHERE (((KAM_STAFF.Username) Is Not Null) AND ((KAM_STAFF.[Line Manager])='" & strFullname & "')) " & _
"ORDER BY KAM_STAFF.FullName"
Set objRSSQL = Server.CreateObject("ADODB.Recordset")
objRSSQL.Open msqlSQL, objConnSQL
If Not objRSSQL.EOF Then
strFullname = objRSSQL.Fields("FullName")
TeamMemberRows = objRSSQL.GetRows
End If
objRSSQL.Close
Set objRSSQL = Nothing
'collects all users where line manager = full name of logged in user------
'USER SELECTION ---------------------------------------------------------------------------------------------------------------
'HOLIDAY TABLE ----------------------------------------------------------------------------------------------------------------
'total holiday entitlement from personnel table----------------------------------------------------------------------------
msqlSQL = "SELECT Personnel.Holiday_Entitlement " & _
"FROM Personnel " & _
"WHERE (((Personnel.Username)='" & strEmployee & "'))"
Set objRSSQL = Server.CreateObject("ADODB.Recordset")
objRSSQL.Open msqlSQL, objConnHRSQL
If Not objRSSQL.EOF Then
strEntitlement = objRSSQL.Fields("Holiday_Entitlement")
End If
objRSSQL.Close
Set objRSSQL = Nothing
'strEntitlement ----------------------------------------------------------------------------
'select fields for holiday section----------------------------------------------------------
msqlSQL = "SELECT HR_Forms.HR_Form_ID, HR_Forms.Hol_LastWorkingDate, HR_Forms.Hol_FirstWorkingDate, HR_Forms.Hol_NoOfDaysOff, HR_Forms.ManagersSignature, HR_Forms.Hol_SSUpdatedBy, HR_Forms.Hol_LastWorkingDateHalf, HR_Forms.Hol_FirstWorkingDateHalf, HR_Forms.Declined " & _
"FROM HR_Forms LEFT JOIN Personnel ON HR_Forms.ClaimsHandlerUN = Personnel.Username " & _
"WHERE (((HR_Forms.Type)='HOL') AND ((HR_Forms.ClaimsHandlerUN)='" & strEmployee & "') AND (DatePart(yyyy, Hol_LastWorkingDate)=" & DatePart("yyyy", Date()) & ") AND ((Personnel.Employment_Status)<>'Left')) " & _
"ORDER BY HR_Forms.Hol_LastWorkingDate"
Set objRSSQL = Server.CreateObject("ADODB.Recordset")
objRSSQL.Open msqlSQL, objConnHRSQL
If Not objRSSQL.EOF Then
strNoRecords = 0
HolidayRows = objRSSQL.GetRows
Else
strNoRecords = 1
End If
objRSSQL.Close
Set objRSSQL = Nothing
objConnHRSQL.Close
Set objConnHRSQL = Nothing
'-------------------------------------------------------------------------------------------
'HOLIDAY TABLE ----------------------------------------------------------------------------------------------------------------
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>HR Homepage</title>
<style type="text/css">
body,td,th {font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #666666;}
a {font-family: Arial, Helvetica, sans-serif; font-size: 12px; color: #5677B4;}
a:link {text-decoration: none;}
a:visited {text-decoration: none;color: #5677B4;}
a:hover {text-decoration: underline; color: #000000;}
a:active {text-decoration: none;color: #000000;}
.style1 {font-size:16px; color:#5677B4; font-weight:bold}
.style2 {color:#000000}
.style3 {font-size:11px; color:#000000}
</style>
</head>
<body>
<!-- List filled by people in managers team---------------------------------------------------------------------------------------------------------------------------------------------->
Select the user on your team whose holidays you wish to view
<select name="SelectUN" class="style4 style3">
<option value=""></option>
<%For cnum = 0 to Ubound(TeamMemberRows,2)%>
<option value="<%= TeamMemberRows(1,cnum)%>"<%If Request.Form("SelectUN") = TeamMemberRows(1,cnum) Then Response.Write(" selected")%>><%= TeamMemberRows(0,cnum)%></option>
<%Next%>
</select>
<br/>
<!-- List filled by people in managers team---------------------------------------------------------------------------------------------------------------------------------------------->
<!-- Generates Table with holiday-------------------------------------------------------------------------------------------------------------------------------------------------------->
<p class="style2" style="font-weight:bold">Current Holiday entitlement for <%= strEmployee%> is <%= strEntitlement%> days</p>
<table width="600" border="0" cellspacing="0" cellpadding="2" style="margin-top:8px">
<tr>
<td width="100" align="center" class="style2">Last Working Day Before Holiday</td>
<td width="100" align="center" class="style2">First Day Back After Holiday</td>
<td width="60" align="center" class="style2">No. of<br />Days</td>
<td align="center" class="style2">Authorised By</td>
<td width="64" align="center" class="style2">Days Remaining</td>
</tr>
<%
If strNoRecords = 0 Then
For cnum = 0 to Ubound(HolidayRows,2)
If HolidayRows(8,cnum) = "N" Then
strEntitlement = CSng(strEntitlement) - CSng(HolidayRows(3,cnum))
End If
%>
<tr>
<td align="center"><%= HolidayRows(1,cnum)%><%If HolidayRows(6,cnum) = "Y" Then Response.Write(" <font color=""#5677B4"">½</font>")%></td> <!-- if half day 1-->
<td align="center"><%= HolidayRows(2,cnum)%><%If HolidayRows(7,cnum) = "Y" Then Response.Write(" <font color=""#5677B4"">½</font>")%></td> <!-- if half day 2-->
<td align="center"><%= HolidayRows(3,cnum)%></td>
<td align="center"><%= HolidayRows(4,cnum)%></td>
<td align="center"><%= strEntitlement%></td>
</tr>
<%Next
End If%>
</table>
<!-- Generates Table with holiday-------------------------------------------------------------------------------------------------------------------------------------------------------->
</body>
</html>