我試圖將顏色應用於某些數據行,這通過使用下面的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
%>
我在這裏做得不對?
嘗試評論我的答案。然後嘗試運行它。如果錯誤仍然存在,那麼錯誤必須在您的循環中 – Muj
錯誤只發生在'elseif' x2語句中。如果我將它們更改回'if'並移除'endif',它可以正常工作,但不能正確分配顏色。 –