Software Development |
| |

| | Thread Tools |
|
22-Dec-2003, 09:36 AM
#1 |
| I have been trying to figure out a problem with a table for over a week now and I am baffled. The code below works fine for any month in 2002 or 2003, but in 2004 it has alignment problems. We have our periods laid out based on a 4-4-5 month plan where January=4, February=4, and March=5 - the rest of the year repeats this pattern no matter how many days are actually in the month. In 2004, the months with 4 weeks, will not line up (while the months with 5 weeks do). I thought at one time it must be the data provided to build the table with (from our db), but everything checks out fine. The table is suppose to have Sunday - Friday listed on the top row, the month (text) and day (number) that corresponds to the day of the week in row one should be in row 2, a dropdown box with some values to select from for each date should be in row 3. After that point, the row 2 / row 3 pattern should repeat to complete the calendar (and it does perfectly in 2002 and 2003). In 2004 the second line of month/date combinations does not break after Saturday to the next line, but rather lists the rest of the month all on the same line. This section of code is found in the ***** R 3 ******** section of code. I posted the code for the whole page because there is other parts of the code that may help. I can supply a definition of the fields named in the code if you think it will help. I am at my wits end with this one. Code: <%@language="vbscript"%>
<%
varBusName = Session("varRedirectBus")
varBusName = Session("varRedirectTo")
%>
<!--#include file="global.asa"-->
<!--#include file="include/Connect.asp"-->
<html>
<head>
<title>Trainer Attendance and Utilization Input Page</title>
</head>
<body background="WB00760_.gif">
<%
'select case request("RedirectTo")
select case Session("varRedirectTo")
case "MenuDefault02.asp"
varYear = "2002"
case "MenuDefault03.asp"
varYear = "2003"
case "MenuDefault04.asp"
varYear = "2004"
End select
%>
<form ACTION="TAUCALCP.asp?Yr=<%=varYrA%>" METHOD="POST">
<input type="hidden" name="MonMonth" value="<%=Request("Month")%>"><input type="hidden"
name="YrYear" value="<%=varYear%>"><hr>
<hr>
<p><font size="6">Trainer Attendance and Utilization Input Page</font></p>
<hr>
<hr>
<%
varMonth = Request.Form("Month")
varYear = varYrA
If (varMonth=" ") Then
Response.Write "<H2>ERRORS PLEASE CORRECT</H2>"
Response.Write "Please Enter: <H2>'MONTH'</H2> <BR><BR>"
Response.Write "Use your Back Button to correct field or: <BR><BR>"
Response.Write "<A HREF='TAUCAL.asp'>Click Here to Clear and Correct all fields</A>"
Response.End
End If
varYear = Right(varYear,2)
varMonYr = (varMonth & "/" & varYear)
'Pull data from DBase table for building tables on Form
'
SQLCal = " SELECT ZZCalendar.MonYr, ZZCalendar.DateSt, ZZCalendar.DaySt, "
SQLCal = SQLCal & " ZZCalendar.MonSt, ZZCalendar.PosSt, ZZCalendar.DateEnd, "
SQLCal = SQLCal & " ZZCalendar.DayEnd, ZZCalendar.PosEnd, ZZCalendar.DInM, "
SQLCal = SQLCal & " ZZCalendar.DInMDSt, ZZCalendar.WksInM, ZZCalendar.[445] "
SQLCal = SQLCal & " FROM ZZCalendar "
SQLCal = SQLCal & " WHERE ZZCalendar.MonYr LIKE '%"& varMonYr &"%'"' "
'
SQLCal = SQLCal & " ORDER BY ZZCalendar.DateSt ASC "
Set rsCal=Conn.Execute(SQLCal)
varDateSt = rsCal("DateSt")
varDaySt = rsCal("DaySt")
varMonSt = rsCal("MonSt")
varPosSt = rsCal("PosSt")
varDateEnd = rsCal("DateEnd")
varDayEnd = rsCal("DayEnd")
varPosEnd = rsCal("PosEnd")
varDInM = rsCal("DInM")
varDInMDSt = rsCal("DInMDSt")
varWksInM = rsCal("WksInM")
var445 = rsCal("445")
rsCal.Close
Set rsCal=nothing
'Header for Page Month and Year
'
varMonMonth = Month(varMonSt)
varYrYear = Year(varMonSt)
varMonthH = MonthName(varMonth)
varMonthDS = MonthName(Month(varDateSt))
varYearH = Year(varMonSt)
Response.Write ("<H3>For Month/Year: " & varMonthH & ", " & varYearH & "</H3>")
%>
<table cellSpacing="0" cellPadding="0" width="10%" align="left" border="1">
<tr>
<td noWrap bgcolor="#008080"><div align="center"><center><p><font
style="BACKGROUND-COLOR: #008080" color="white">Trainer Name</font></td>
</tr>
<tr align="center">
<td noWrap bgcolor="#808080" align="Center"><select NAME="TName" SIZE="1" id="TName"
tabindex="1">
<option Selected value=" "> </option>
<% Set rsTNPD=Conn.Execute(" SELECT DISTINCT Trainers.TName FROM Trainers ORDER BY TName ASC ")
MArTNPD = rsTNPD.GetRows()
rsTNPD.Close
Set rsTNPD=Nothing
For x = 0 to Ubound(MArTNPD,2)
%> <option VALUE="<%Response.Write MArTNPD(0,x)%>"><%Response.Write MArTNPD(0,x)%></option>
<% Next %> </select> </td>
</tr>
</table>
<div align="center"><center><p><br>
<br>
<br>
<br>
</p>
</center></div><div align="center"><center><h3>Attendance & Utilization Form</h3>
</center></div><div align="center"><center><table cellSpacing="1" cellPadding="1"
width="90%" align="center" border="1">
<tr>
<th noWrap bgcolor="#008080"><font Color="White">Sunday</font></th>
<th noWrap bgcolor="#008080"><font Color="White">Monday</font></th>
<th noWrap bgcolor="#008080"><font Color="White">Tuesday</font></th>
<th noWrap bgcolor="#008080"><font Color="White">Wednesday</font></th>
<th noWrap bgcolor="#008080"><font Color="White">Thursday</font></th>
<th noWrap bgcolor="#008080"><font Color="White">Friday</font></th>
<th noWrap bgcolor="#008080"><font Color="White">Saturday</font></th>
<th height="5"></th>
<%
tab = 2
wu = varDateSt
xu = (Month(varDateSt))
yu = (Day(varDateSt))
zu = var445
wu1 = varDInMDSt
xu1 = ((wu1 - yu)+1)
yu1 = varDInM
zu1 = varMonthDS
wu2 = varMonthH
xu2 = 1
'**************Row 1 build****************
'
if xu1 > 7 Then
xu1 = (xu1 - 7)
'R 1
Response.Write ("<TR>")
For x1 = 1 to 7
Response.Write ("<TD align='center' bgcolor='#008080'><Font Color=White>" & zu1 & _
" " & yu & "</Font></TD>")
yu = (yu + 1 )
Next
Response.Write ("</TR>")
'**************R 2*******************
Response.Write ("<tr>")
' make 7 columns
For y1 = 1 to 7
'insert a table def tag with alignment center and grey color
Response.Write ("<td align=""center"" bgcolor=""#808080"">")
' create a combobox for this column as well as a blank entry to start
Response.Write ("<select name=""UCodes"" size=""1"" id=""UCodes"" tabindex=""" & tab & """>")
Response.Write ("<option selected value="" ""> </option>")
'get the data to input into an array (i'll assume this works properly)
Set rsUCAbPD=Conn.Execute(" SELECT DISTINCT ZZAttdCode.AttdCodeAb FROM ZZAttdCode ORDER BY AttdCodeAb ASC ")
MArUCAbPD = rsUCAbPD.GetRows()
rsUCAbPD.Close
Set rsUCAbPD=Nothing
'for each item in the array, make it an option in the combobox
For x = 0 to Ubound(MArUCAbPD,2)
Response.Write ("<option value=""" & MArUCAbPD(0,x) & """>" & MArUCAbPD(0,x) & "</option>")
Next
Response.Write ("</select>")
Response.Write ("</td>")
tab = (tab + 1)
Next
Response.Write ("</tr>")
'************R 3********************
'
Response.Write ("<TR>")
For x1 = 1 to xu1
Response.Write ("<TD align='center' bgcolor='#008080'><Font Color=White>" & zu1 & _
" " & yu & "</Font></TD>")
yu = (yu + 1 )
Next
For x2 = 1 to (7 - xu1)
Response.Write ("<TD align='center' bgcolor='#008080'><Font Color=White>" & wu2 & _
" " & xu2 & "</Font></TD>")
xu2 = (xu2 + 1 )
Next
Response.Write ("</TR>")
'***************R 4********************
'
Response.Write ("<TR>")
For y1 = 1 to 7
Response.Write ("<TD align='center' bgcolor='#808080'>")
%>
<select NAME="UCodes" SIZE="1" id="UCodes" tabindex="<%=tab%>">
<option Selected value=" "> </option>
<%
Set rsUCAbPD=Conn.Execute(" SELECT DISTINCT ZZAttdCode.AttdCodeAb FROM ZZAttdCode ORDER BY AttdCodeAb ASC ")
MArUCAbPD = rsUCAbPD.GetRows()
rsUCAbPD.Close
Set rsUCAbPD=Nothing
For x = 0 to Ubound(MArUCAbPD,2)
%>
<option VALUE="<%Response.Write MArUCAbPD(0,x)%>"><%Response.Write MArUCAbPD(0,x)%></option>
<%
Next
%>
</select>
<%
tab = (tab + 1)
Next
Response.Write ("</TD></TR>")
Else if xu1 = 7 Then
'**************R 1***************
'
Response.Write ("<TR>")
For x1 = 1 to 7
Response.Write ("<TD align='center' bgcolor='#008080'><Font Color=White>" & zu1 & _
" " & yu & "</Font></TD>")
yu = (yu + 1 )
Next
Response.Write ("</TR>")
'************R 2********************
'
Response.Write ("<TR>")
For y1 = 1 to 7
Response.Write ("<TD align='center' bgcolor='#808080'>")
%>
<select NAME="UCodes" SIZE="1" id="UCodes" tabindex="<%=tab%>">
<option Selected value=" "> </option>
<%
Set rsUCAbPD=Conn.Execute(" SELECT DISTINCT ZZAttdCode.AttdCodeAb FROM ZZAttdCode ORDER BY AttdCodeAb ASC ")
MArUCAbPD = rsUCAbPD.GetRows()
rsUCAbPD.Close
Set rsUCAbPD=Nothing
For x = 0 to Ubound(MArUCAbPD,2)
%>
<option VALUE="<%Response.Write MArUCAbPD(0,x)%>"><%Response.Write MArUCAbPD(0,x)%></option>
<%
Next
%>
</select>
<%
tab = (tab + 1)
Next
Response.Write ("</TD></TR>")
'***************R 3***************
'
Response.Write ("<TR>")
For x2 = 1 to 7
Response.Write ("<TD align='center' bgcolor='#008080'><Font Color=White>" & wu2 & _
" " & xu2 & "</Font></TD>")
xu2 = (xu2 + 1)
Next
Response.Write ("</TR>")
'************R 4**************
'
Response.Write ("<TR>")
For y1 = 1 to 7
Response.Write ("<TD align='center' bgcolor='#808080'>")
%>
<select NAME="UCodes" SIZE="1" id="UCodes" tabindex="<%=tab%>">
<option Selected value=" "> </option>
<%
Set rsUCAbPD=Conn.Execute(" SELECT DISTINCT ZZAttdCode.AttdCodeAb FROM ZZAttdCode ORDER BY AttdCodeAb ASC ")
MArUCAbPD = rsUCAbPD.GetRows()
rsUCAbPD.Close
Set rsUCAbPD=Nothing
For x = 0 to Ubound(MArUCAbPD,2)
%>
<option VALUE="<%Response.Write MArUCAbPD(0,x)%>"><%Response.Write MArUCAbPD(0,x)%></option>
<%
Next
%>
</select>
<%
tab = (tab + 1)
Next
Response.Write ("</TD></TR>")
Else
'***************R 1******************
'
Response.Write ("<TR>")
For x1 = 1 to xu1
Response.Write ("<TD align='center' bgcolor='#008080'><Font Color=White>" & zu1 & _
" " & yu & "</Font></TD>")
yu = (yu + 1)
Next
For y1 = 1 to (7 - xu1)
Response.Write ("<TD align='center' bgcolor='#008080'><Font Color=White>" & wu2 & _
" " & xu2 & "</Font></TD>")
xu2 = (xu2 + 1)
Next
Response.Write ("</TR>")
'************R 2****************
'
Response.Write ("<TR>")
For y1 = 1 to 7
Response.Write ("<TD align='center' bgcolor='#808080'>")
%> <select NAME="UCodes" SIZE="1" id="UCodes" tabindex="<%=tab%>">
<option Selected value=" "> </option>
<% Set rsUCAbPD=Conn.Execute(" SELECT DISTINCT ZZAttdCode.AttdCodeAb FROM ZZAttdCode ORDER BY AttdCodeAb ASC ")
MArUCAbPD = rsUCAbPD.GetRows()
rsUCAbPD.Close
Set rsUCAbPD=Nothing
For x = 0 to Ubound(MArUCAbPD,2)
%> <option VALUE="<%Response.Write MArUCAbPD(0,x)%>"><%Response.Write MArUCAbPD(0,x)%></option>
<% Next %> </select> <%
tab = (tab + 1)
Next
Response.Write ("</TD></TR>") Code: '
Response.Write ("<TR>")
For x1 = 1 to 7
Response.Write ("<TD align='center' bgcolor='#008080'><Font Color=White>" & wu2 & _
" " & xu2 & "</Font></TD>")
xu2 = (xu2 + 1)
Next
Response.Write ("</TR>")
'**************R 4***************
'
Response.Write ("<TR>")
For y1 = 1 to 7
Response.Write ("<TD align='center' bgcolor='#808080'>")
%> <select NAME="UCodes" SIZE="1" id="UCodes" tabindex="<%=tab%>">
<option Selected value=" "> </option>
<% Set rsUCAbPD=Conn.Execute(" SELECT DISTINCT ZZAttdCode.AttdCodeAb FROM ZZAttdCode ORDER BY AttdCodeAb ASC ")
MArUCAbPD = rsUCAbPD.GetRows()
rsUCAbPD.Close
Set rsUCAbPD=Nothing
For x = 0 to Ubound(MArUCAbPD,2)
%> <option VALUE="<%Response.Write MArUCAbPD(0,x)%>"><%Response.Write MArUCAbPD(0,x)%></option>
<% Next %> </select> <%
tab = (tab + 1)
Next
Response.Write ("</TD></TR>")
End if
End if
'**************Row 5***************
'
Response.Write ("<TR>")
For x1 = 1 to 7
Response.Write ("<TD align='center' bgcolor='#008080'><Font Color=White>" & wu2 & _
" " & xu2 & "</Font></TD>")
xu2 = (xu2 + 1)
Next
Response.Write ("</TR>")
'***************Row 6***************
'
Response.Write ("<TR>")
For y1 = 1 to 7
Response.Write ("<TD align='center' bgcolor='#808080'>")
%>
<select NAME="UCodes" SIZE="1" id="UCodes" tabindex="<%=tab%>">
<option Selected value=" "> </option>
<%
Set rsUCAbPD=Conn.Execute(" SELECT DISTINCT ZZAttdCode.AttdCodeAb FROM ZZAttdCode ORDER BY AttdCodeAb ASC ")
MArUCAbPD = rsUCAbPD.GetRows()
rsUCAbPD.Close
Set rsUCAbPD=Nothing
For x = 0 to Ubound(MArUCAbPD,2)
%>
<option VALUE="<%Response.Write MArUCAbPD(0,x)%>"><%Response.Write MArUCAbPD(0,x)%></option>
<%
Next
%>
</select>
<%
tab = (tab + 1)
Next
Response.Write ("</TD></TR>")
'***************Row 7******************
'
Response.Write ("<TR>")
For x1 = 1 to 7
Response.Write ("<TD align='center' bgcolor='#008080'><Font Color=White>" & wu2 & _
" " & xu2 & "</Font></TD>")
xu2 = (xu2 + 1)
Next
Response.Write ("</TR>")
'***************Row 8******************
'
Response.Write ("<TR>")
For y1 = 1 to 7
Response.Write ("<TD align='center' bgcolor='#808080'>")
%>
<select NAME="UCodes" SIZE="1" id="UCodes" tabindex="<%=tab%>">
<option Selected value=" "> </option>
<%
Set rsUCAbPD=Conn.Execute(" SELECT DISTINCT ZZAttdCode.AttdCodeAb FROM ZZAttdCode ORDER BY AttdCodeAb ASC ")
MArUCAbPD = rsUCAbPD.GetRows()
rsUCAbPD.Close
Set rsUCAbPD=Nothing
For x = 0 to Ubound(MArUCAbPD,2)
%>
<option VALUE="<%Response.Write MArUCAbPD(0,x)%>"><%Response.Write MArUCAbPD(0,x)%></option>
<%
Next
%>
</select>
<%
tab = (tab + 1)
Next
Response.Write ("</TD></TR>")
if zu = 5 Then
'******************Row 9***************
'
Response.Write ("<TR>")
For x1 = 1 to 7
Response.Write ("<TD align='center' bgcolor='#008080'><Font Color=White>" & wu2 & _
" " & xu2 & "</Font></TD>")
xu2 = (xu2 + 1)
Next
Response.Write ("</TR>")
'***************Row 10******************
'
Response.Write ("<TR>")
For y1 = 1 to 7
Response.Write ("<TD align='center' bgcolor='#808080'>")
%>
<select NAME="UCodes" SIZE="1" id="UCodes" tabindex="<%=tab%>">
<option Selected value=" "> </option>
<%
Set rsUCAbPD=Conn.Execute(" SELECT DISTINCT ZZAttdCode.AttdCodeAb FROM ZZAttdCode ORDER BY AttdCodeAb ASC ")
MArUCAbPD = rsUCAbPD.GetRows()
rsUCAbPD.Close
Set rsUCAbPD=Nothing
For x = 0 to Ubound(MArUCAbPD,2)
%>
<option VALUE="<%Response.Write MArUCAbPD(0,x)%>"><%Response.Write MArUCAbPD(0,x)%></option>
<%
Next
%>
</select>
<%
tab = (tab + 1)
Next
Response.Write ("</TD></TR>")
End if
%>
</td>
</tr>
<tr>
<td align="left" bgcolor="#C0C0C0" colspan="2">Submit Data: <input id="submit1"
type="submit" value="Submit" name="submit1"> </td>
</tr>
<tr>
<td align="left" bgcolor="#C0C0C0" colspan="2">Reset Form: <input id="reset1"
type="reset" value="Reset" name="reset1"> </td>
</tr>
</table>
</center></div><div align="center"><center><table cellSpacing="1" cellPadding="1"
width="90%" align="center" border="1">
<tr>
<td><b><u>AD</u></b>-Adopt a Child<b><u>CB</u></b>-Out of the Unit on Company Business <b><u>CBT</u></b>-Out
of the Unit on Company Business,Trained Full Day <b><u>CBT.5</u></b>-Out of the Unit on
Company Business,Trained 1/2 Day <b><u>CBX.5</u></b>-Out of the Unit on Company
Business,Worked 1/2 Day <b><u>D</u></b>-Designated Day Off<b><u>F</u></b>-Funeral <b><u>FMLA</u></b>-Family
Medical Leave Act <b><u>H</u></b>-Legal Holiday <b><u>IG</u></b>-Paid Illness<b><u>IGT.5</u></b>-Trained
1/2 Day,Illness 1/2Day <b><u>IGX.5</u></b>-Worked 1/2 Day, Illness 1/2 Day, No Training <b><u>IW</u></b>-Inclement
Weather<b><u>J</u></b>-Jury Duty <b><u>NA</u></b>-Used Prior to Start Date or after Last
Day in Training to Complete Month <b><u>NCNS</u></b>-No Call, No Show <b><u>PH</u></b>-Personal
Holiday<b><u>STD</u></b>-ShortTerm Disability <b><u>Susp</u></b>-Suspended <b><u>T</u></b>-Trained
Full Day, Worked Full Day <b><u>T.5</u></b>-Trained 1/2 Day, Worked Full Day<b><u>UL</u></b>-Unpaid
LOA <b><u>V</u></b>-Vacation<b><u>V.5</u></b>-1/2 Day Vacation, No Training, No Work <b><u>VT.5</u></b>-1/2
Day Vacation,1/2 Day Training<b><u>WC</u></b>-Workers Comp <b><u>X</u></b>-Full Day
Worked, No Training<b><u>X.5</u></b>-Worked 1/2Day, No Training <b><u>XT.5</u></b>-Worked
1/2 Day,Trained 1/2 Day<b><u>XV.5</u></b>-1/2Day Vacation ,Worked 1/2Day, No Training </td>
</tr>
</table>
</center></div><div align="center"><center><p><br>
<br>
</p>
</center></div>
</form>
</body>
<%
Conn.Close
Set Conn=Nothing
%>
</html>
__________________ CoachDan http://www.malehsbaseball.com Gateway Pentium 4 3.0 GHz 200G Sata HD 800 FSB 512 DDR DVD +-R/W XP Home |
22-Dec-2003, 11:02 AM
#2 | ||||||
| Is the calendar data being returned for 2002 and 2004 data that already exists in the tables for building the recordset? Is there data in the tables for 2004 to build the recordset and display the tables correctly? Out of curiosity, what is this variable for: var445 = rsCal("445") |
|
22-Dec-2003, 11:48 AM
#3 |
| There is data in the table to build the calendar with. The variable var445 is to store the records in the calendar table for the field 445. That field is a numeric field that consists of only two value posibilities (4 or 5). This field is the one used to determine whether the calendar should allow 4 weeks in the table or 5. I will give you a breakdown of the data in the calendar table for for January 2004: Field 1 (CalId) - is just an autonumber, primary key Field 2 (Year) - is the year; value = 2004 Field 3 (Month) - is a numeric value; value = 1 Field 4 (MonYr) - is a date format; value = 1/04 Field 5 (DateSt) - is a date format that designates the starting date for the period; value = 1/4/04 Field 6 (DaySt) - is a text value that designates the day of the week that corresonds to the date in DateSt (field 5); value = Thursday Field 7 (MonSt) - is a date format that designates the date the actual calendar month begins (always the 1st); value = 1/1/04 Field 8 (PosSt) - is a numeric value that designates the position the MonSt (field 7) is located in the table; value = 5 (Thursday is the fifth position in a Sunday - Saturday calendar) Field 9 (DateEnd) - is a date format that designates the actual date the period should end; value = 1/31/04 (this is 28 days or 4 weeks in the 4-4-5 scheme) Field 10 (Day End) - is a text value that designates the particular day of the week DateEnd falls on; value = Saturday Field 11 (PosEnd) - is a numeric value that designates the position in the table that DateEnd will fall on; value = 7 (Saturday is the 7th day) Field 12 (DInM) - is a numeric value that deisgnates how many days there are in the calendar month (not in the period); value = 31 Field 13 (DInMDSt) - is a numeric value (I have not been able to figure out what the field is used for); value = 31 Field 14 (WksInM) - is a numeric value that designates how many weeks (rows) in the calendar month; value = 5 (this value is either 5 or 6 always) Field 15 (445) - is the numeric value you asked about above; value = 4 I hope this will help you understand better how it is setup. I inherited this system and as you can see there are some things I have been unable to figure out as well. I appreciate you trying to help, as I am apparently in over my head trying to figure this one out.
__________________ CoachDan http://www.malehsbaseball.com Gateway Pentium 4 3.0 GHz 200G Sata HD 800 FSB 512 DDR DVD +-R/W XP Home |
![]() |

| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |

| Thread Tools | |
| |
| You Are Using: |
Advertisements do not imply our endorsement of that product or service. All times are GMT -4. The time now is 07:45 AM. Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved. Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd. Search Engine Optimization by vBSEO 3.1.0 | |




