我正在尝试将颜色应用于某些数据行,这是使用下面的colswitch
变量完成的。它在软件中的工作原理是无关紧要的,所以我只是包含了一个片段。它是将各种逻辑应用于数据的循环的一部分。编辑添加更多代码...
我希望它遵循的规则如下,不幸的是,一切都变红了,除非我用if语句删除行,然后除非状态为Open
,否则它会正确地保留一些东西。
dateadded
是一个包含日期时间值的变量。其中至少有一个超过7天。
objstatus = Open
- 将colswitch
设为黄色
objstatus = Third Party or Waiting for reply, unless older than 7 days
- 将colswitch
设为蓝色
objstatus = >7 days after 'date_added'
- 将colswitch
设为红色
代码:
<%
if DispLastUpd_val = "Y" then
IF DBType = "Access" then response.write "<TD bgcolor='" & bghicol & "'><font face='" & stanfont & "' size='" & textsizenorm & "' color='" & menhcol & "'><a href='DispOpenCalls.asp?Type=" & ListType & "&sortit=Max(event_dateadded)&sortorder=" & SortOrder & "&callstat=" & request.querystring("callstat") & "&stat=" & request.querystring("stat")& "'>Last Update</a></font></TD>"
IF DBType = "SQL" then response.write "<TD bgcolor='" & bghicol & "'><font face='" & stanfont & "' size='" & textsizenorm & "' color='" & menhcol & "'><a href='DispOpenCalls.asp?Type=" & ListType & "&sortit=LastEvt&sortorder=" & SortOrder & "&callstat=" & request.querystring("callstat") & "&stat=" & request.querystring("stat")& "'>Last Update</a></font></TD>"
end if
if DispToFix_val = "Y" then
if SLAmonitor = 0 then
IF DBType = "Access" then response.write "<TD bgcolor='" & bghicol & "'><font face='" & stanfont & "' size='" & textsizenorm & "' color='" & menhcol & "'><a href='DispOpenCalls.asp?Type=" & ListType & "&sortit=(DateDiff({sq}h{sq},call_dateadded,Now())-PRIORITY_FIXHOURS)&sortorder=" & SortOrder & "&callstat=" & request.querystring("callstat") & "&stat=" & request.querystring("stat")& "'>To Fix</a></font></TD>"
IF DBType = "SQL" then response.write "<TD bgcolor='" & bghicol & "'><font face='" & stanfont & "' size='" & textsizenorm & "' color='" & menhcol & "'><a href='DispOpenCalls.asp?Type=" & ListType & "&sortit=(DateDiff(hh,call_dateadded,getdate())-PRIORITY_FIXHOURS)&sortorder=" & SortOrder & "&callstat=" & request.querystring("callstat") & "&stat=" & request.querystring("stat")& "'>To Fix</a></font></TD>"
end if
if SLAmonitor = 1 then
response.write "<TD bgcolor='" & bghicol & "'><font face='" & stanfont & "' size='" & textsizenorm & "' color='" & menhcol & "'><a href='DispOpenCalls.asp?Type=" & ListType & "&sortit=((sla_callhours - sla_defhours)-PRIORITY_FIXHOURS)&sortorder=" & SortOrder & "&callstat=" & request.querystring("callstat") & "&stat=" & request.querystring("stat")& "'>To Fix</a></font></TD>"
end if
end if
colswitch = LISTCOL1
Do Until myset.EOF
if colswitch = LISTCOL1 then colswitch = LISTCOL2 else colswitch = LISTCOL1
'
'
'MY CODE IS BELOW
if objstatus = "Open" then colswitch = "yellow" 'this works
calldays = DateDiff("d",dateadded,now())
if calldays > 7 then colswitch = "red" 'this is where it breaks
if objstatus = "Third Party" or objstatus = "Waiting for Reply") and (calldays < 7) then colswitch = "blue"
'
'
' end of my code
'
objslastat = "<img border='0' src='../IMAGES/blanksla.gif'>"
masticon = ""
urgicon = ""
probicon = ""
changeicon = ""
atticon = ""
if SLAmonitor = 0 then
If objCallTime => objtimeesc and objstatus = "Open" then objslastat = "<img border='0' src='../IMAGES/Button_sla_esc.gif' title='Exceeds Response Escalation time'>"
If objCallTime => objtimesla and objstatus = "Open" then objslastat = "<img border='0' src='../IMAGES/Button_sla.gif' title='Exceeds Response time'>"
If objCallTime => objtimefixesc and objstatus <> "Closed" then objslastat = "<img border='0' src='../IMAGES/Button_fix_esc.gif' title='Exceeds Resolve Escalation time'>"
If objCallTime => objtimefix and objstatus <> "Closed" then objslastat = "<img border='0' src='../IMAGES/Button_fix.gif' title='Exceeds Resolve time'>"
end if
if SLAmonitor = 1 then
If objsla = "ESC" and objstatus = "Open" then objslastat = "<img border='0' src='../IMAGES/Button_sla_esc.gif' title='Exceeds Response Escalation time'>"
If objsla = "RES" and objstatus = "Open" then objslastat = "<img border='0' src='../IMAGES/Button_sla.gif' title='Exceeds Response time'>"
If objsla = "ESF" and objstatus <> "Closed" then objslastat = "<img border='0' src='../IMAGES/Button_fix_esc.gif' title='Exceeds Resolve Escalation time'>"
If objsla = "FIX" and objstatus <> "Closed" then objslastat = "<img border='0' src='../IMAGES/Button_fix.gif' title='Exceeds Resolve time'>"
End if
if objmastcallcode > 0 then masticon = "<img border='0' src='../IMAGES/linked.gif' title='Linked " & tgencallterm & " - Master " & objMastCallCode & "'>"
if objmastcall = "Y" then masticon = "<img border='0' src='../IMAGES/linkedm.gif' title='Master " & tgencallterm & "'>"
if objurg = "T" then urgicon = "<img border='0' src='../IMAGES/urgent.gif' title='Urgent'>"
if objurguser = "T" then urgicon = "<img border='0' src='../IMAGES/urgent.gif' title='Urgent'>"
if objki = "T" then probicon = "<img border='0' src='../IMAGES/prob.gif' title='Problem " & tgencallterm & "'>"
if objnochange > 0 then changeicon = "<img border='0' src='../IMAGES/change.gif' title='" & tchangetext & "'>"
if objnoatt > 0 then atticon = "<img border='0' src='../IMAGES/attachment.gif' title='Attachments'>"
' This bit avoids issue with Team Calls when using Next / Prev
if request.querystring("type") = "Team" then qry = ""
Response.Write "<TR><TD nowrap bgcolor='" & colswitch & "'>" & urgicon & "</TD>"
Response.Write "<TD nowrap bgcolor='" & colswitch & "'>" & atticon & "</TD>"
Response.Write "<TD nowrap bgcolor='" & colswitch & "'><a href='UpdateCall.asp?inp_call_id=" & objcallcode & "&qry=" & qry & "'><font face='" & stanfont & "' size='" & textsizelist & "' color='" & menicol & "'>" & objcallcode & "</font></TD><TD bgcolor='" & colswitch & "'><font face='" & stanfont & "' size='" & textsizelist & "' color='" & menicol & "'>" & objslastat & "</font></TD>"
response.write "<TD bgcolor='" & colswitch & "'>" & masticon & "</font></TD>"
response.write "<TD bgcolor='" & colswitch & "'>" & probicon & "</font></TD>"
response.write "<TD bgcolor='" & colswitch & "'>" & changeicon & "</font></TD>"
' Loop through data results
For x = 0 to ColCount
response.write "<TD " & ColWrap(x) & " bgcolor='" & colswitch & "'><font face='" & stanfont & "' size='" & textsizelist & "' color='" & menicol & "'>"
if isdate(ColResults(x)) then response.write FmtDateDisp(ColResults(x)) else response.write ColResults(x)
response.write "</font></TD>"
Next
if DispLastUpd_val = "Y" then response.write "<TD nowrap bgcolor='" & colswitch & "'><font face='" & stanfont & "' size='" & textsizelist & "' color='" & menicol & "'>" & FmtDateDisp(objLastEvt) & " (" & DateDiff("d",objLastEvt ,now()) & " Days)</font></TD>"
if DispToFix_val = "Y" then
if objtimefix = "" or isnull(objtimefix) then objtimefix = 0
if objCallTime= "" or isnull(objCallTime) then objCallTime= 0
response.write "<TD nowrap align='right' bgcolor='" & colswitch & "'><font face='" & stanfont & "' size='" & textsizelist & "' color='" & menicol & "'>" & formatnumber(objtimefix - objCallTime,2) & " Hrs</font></TD></TR>"
end if
colswitch = ocolswitch
myset.MoveNext
Loop
%>
我在这里做错了吗?
答案 0 :(得分:0)
我的问题不是那么清楚。
尝试用以下代码替换您的代码:
if objstatus = "Open" then colswitch = "yellow"
calldays = DateDiff("d",dateadded,now())
elseif calldays > 7 then colswitch = "red"
elseif (objstatus = "Third Party" or objstatus = "Waiting for Reply") and (calldays < 7) then colswitch = "blue"
end if
如果有任何问题,请告诉我。