<% '************************************************************************* 'Retrieve the latest rates sub getRates Dim data(20,20) '************************************************************************* 'Do any updates If inEditMode Then Dim k : k =1 '************************************************************************* 'Loop through any items in the Request For Each x In Request.Form Dim dItem : dItem = CStr(x) Dim dCount : dCount = Request.Form(x).Count Dim dValue If dCount > 1 Then dValue = Request.Form(x)(1) Else dValue = Request.Form(x) End iF Dim idNumber If (InStr(dItem,"lang_") > 0 ) Then idNumber = Mid(dItem,6,Len(dItem)) sqlStr = "update t_text set r_text = '" &Replace(dValue,"'","''")&"' where r_id = " & idNumber objConn.Execute(sqlStr) ElseIf (InStr(dItem,"rate_") > 0 ) Then idNumber = Mid(dItem,6,Len(dItem)) sqlStr = "update t_rates set r_price = '" &Replace(dValue,"'","''")&"' where r_id = " & idNumber objConn.Execute(sqlStr) End IF Next End If 'End Updates '************************************************************************* '************************************************************************* 'Set the inital values for the table data(0,0) = "Room Type" data(0,1) = " " data(1,1) = "Euro €" data(2,1) = "Euro €" data(3,1) = "Euro €" data(4,1) = "Euro €" Dim colCount : colCount = 1 Dim rowCount : rowCount = 2 '************************************************************************* 'Retrieve all the dates in the database sqlStr = "select * from t_dates order by r_order ASC" set recordSet = Server.CreateObject("ADODB.RecordSet") set recordSet = objConn.Execute(sqlStr) '************************************************************************* 'If in Edit mde, supploy a form for the user to update with If inEditMode Then Response.Write("
") End IF '************************************************************************* 'Loop through the dates do while NOT recordSet.EOF Dim dateId : dateId = recordSet("r_id") Dim textId : textId = recordSet("r_textref") sqlStr = "select * from t_rates INNER JOIN t_type ON t_rates.r_type = t_type.r_id where t_rates.r_date = " & dateId set recordSet_2 = Server.CreateObject("ADODB.RecordSet") set recordSet_2 = objConn.Execute(sqlStr) 'Retrieve the text and add into the data array data(colCount,0) = getText(textId,r_language) rowCount = 2 '************************************************************************* 'Loop through the Rates do while NOT recordSet_2.EOF Dim rateId : rateId = recordSet_2("t_rates.r_id") Dim textAddId : textAddId = getText(recordSet_2("r_additional"),r_language) Dim textRateId : textRateId = getText(recordSet_2("r_textref"),r_language) Dim textFreqId : textFreqId = getText(recordSet_2("r_frequency"),r_language) '************************************************************************* 'If in Edit Mode, write out text fields containg the values instead of just text If inEditMode Then data(0,rowCOunt) = textRateId & " - " & textFreqId data(colCount,rowCount) = " " & textAddId Else data(0,rowCOunt) = textRateId & " - " & textFreqId data(colCount,rowCount) = currencyValue & recordSet_2("r_price") & " " & textAddId End If recordSet_2.MoveNext totRowCount = totRowCount + 1 rowCount = rowCount + 1 Loop recordSet_2.Close recordSet.MoveNext colCount = colCount + 1 Loop recordSet.Close '************************************************************************* 'Write the table to the page using the valus stored in the mutli dimensional array data() Dim y : y = 0 Dim x : x = 0 Dim cellType : cellType = "th" Response.Write("") For y =0 to rowCount -1 Response.Write("") For x =0 to colCount-1'UBound(data) 'The second row takes on an additional class Dim addclass : addclass = "" If y = 1 AND x > 0 Then addclass = "class='column1'" cellType="th" Else addclass="" End If Response.Write("<"&cellType&" "&addclass&">") Response.write(data(x,y)) Response.Write("") Next Response.Write("") cellType = "td" Next Response.Write("
") '************************************************************************* 'If in Edit Mode, supply the user with a submit button If inEditMode Then Response.Write("
") End IF end sub '************************************************************************* 'getText(Reference ID, Language) 'Returns the Text stored in the database corresponding to the Reference ID and language function getText(refId,refLangId) Dim pStr : pStr= "" If refId <> "" Then Dim langRecordSet set langRecordSet = Server.CreateObject("ADODB.RecordSet") set langRecordSet = objConn.Execute("select r_id, r_text from t_text where r_reference = " & refId &" AND r_language = " & refLangId) if NOT langRecordSet.EOF Then Dim langId : langId = langRecordSet("r_id") Dim langText : langText = langRecordSet("r_text") If inEditMode Then pStr = "" Else pStr = langText End If Else pStr = "" End If langRecordSet.Close Set langRecordSet = nothing Else pStr="" End IF getText = pStr end function %>