My Code:
ok this calculates hours spent on a client and their retainer hours, their hours left over and wot gets carried to the next month.
now their hours carried over to the next month can never exceed their retainer hours.
when i initally execute the script everything works out perfect, but if i execute it again on the same month, it gets it all wrong?
i have uploaded to documents showing the first and 2nd execution of this file.
thanks
Code:
<%@LANGUAGE="VBSCRIPT"%>
<!-- #include file="common.asp" -->
<!-- #include file="../adovbs.inc" -->
<%
' technocurve arc 3 asp vb bv block1/3 start
Dim myColor1, myColor2, myColor
myColor1 = "#FFFFFF"
myColor2 = "#CCCCCC"
myColor = myColor1
' technocurve arc 3 asp vb bv block1/3 start
%>
<html>
<head>
<link rel=stylesheet href="backOfficeCssNet.css" type="text/css">
<title><-------------------------- Altra.Net ----------------------------------------------------------------------------------------------></title>
</head>
<BODY>
<span Class = "TData_Text">
<%
dtmTargetDate = Date
intDay = Day(dtmTargetDate)
dtmLastDay = dtmTargetDate - intDay
dtmFirstDay = Month(dtmLastDay) & "/1/" & Year(dtmLastDay)
strFrom = dtmFirstDay
strTo = dtmLastDay
strSQL = "SELECT * FROM tClient WHERE dormant = 'No' ORDER BY id"
dim objRS
Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open objConn
Set objRS = Server.CreateObject("ADODB.Recordset")
objRS.open strSQL,Conn
PreviousHours = objRS("HoursCarried")
%>
<TABLE width = 100%>
<TR Class = "TData_Info">
<TD width="8%">Client ID</TD>
<TD width="14%">Client</TD>
<TD width="10%">Total Hours</TD>
<TD width="8%">Retainer Hours</TD>
<TD width="8%">Hours Over</TD>
<TD width="15%">Previous Hours Carried</TD>
<TD width="10%">New Hours Carried</TD>
<TD width="8%"></TD>
<TD width="8%"></TD>
</TR>
<%
While Not objRS.EOF
strSQL2 = "SELECT ClientId, SUM(HoursSpent) AS Total FROM tJob WHERE ClientId = " & objRS("id") & " AND theDate BETWEEN #" & strFrom & "# AND #" & strTo & "# GROUP BY ClientId"
Set rs = Server.CreateObject("ADODB.Recordset")
rs.open strSQL2,Conn
While Not rs.EOF
FreeHours = objRS("NoFreeHours")
TotalHours = rs("Total")
if TotalHours > FreeHours then
HoursOver = 0
else if FreeHours > TotalHours then
HoursOver = Freehours - TotalHours
end if
end if
HoursCarried = 0
if HoursOver < PreviousHours then
HoursCarried = HoursOver - PreviousHours
else if PreviousHours > HoursOver then
HoursCarried = FreeHours
else if PreviousHours = 0 then
HoursCarried = HoursOver
end if
end if
end if
Conn.Execute "UPDATE tClient SET hoursCarried = "& HoursCarried &" WHERE id = " & rs("ClientId")
%>
<TR <%
' technocurve arc 3 asp vb bv block2/3 start
Response.Write(" style='background-color:" & myColor & "'")
' technocurve arc 3 asp vb bv block2/3 start
%> Class = "TData_Text" >
<td width="8%"><%=rs("ClientId")%></td>
<td width="25%"><%=objRS("Name")%></td>
<TD width="10%"><%=rs("Total")%></TD>
<TD width="8%"><%=objRS("NoFreeHours")%></TD>
<TD width="8%"><%=HoursOver%></TD>
<TD width="15%"><%=PreviousHours%></TD>
<TD width="10%"><%=HoursCarried%></TD>
<TD width="8%"></TD>
<TD width="8%"></TD>
</TR>
<%
' technocurve arc 3 asp vb bv block3/3 start
if myColor = myColor1 then
myColor = myColor2
else
myColor = myColor1
end if
' technocurve arc 3 asp vb bv block3/3 start
%>
<%
rs.MoveNext
Wend
objRS.MoveNext
Wend
objRS.Close
Set objRS = Nothing
Conn.Close
set Conn = Nothing
%>
</TABLE>
</SPAN>
<!--------------/page information--------------->
</body>
</html>
ok this calculates hours spent on a client and their retainer hours, their hours left over and wot gets carried to the next month.
now their hours carried over to the next month can never exceed their retainer hours.
when i initally execute the script everything works out perfect, but if i execute it again on the same month, it gets it all wrong?
i have uploaded to documents showing the first and 2nd execution of this file.
thanks



