<% 'If the directory selected is not Country then redirect it to the 'relevant page. 'ON ERROR RESUME NEXT CONST EXPORTER_PATH = "/Search/directory/results_diff_dirs_exp.asp" CONST MANUFACTURER_PATH = "/Search/directory/results_diff_dirs_Manuf.asp" CONST COMPANY_PATH = "/Search/directory/results_diff_dirs_Company.asp" CONST IMPORTER_PATH = "/Search/directory/results_diff_dirs.asp" CONST COUNTRY_QUERY_WITH_OUT_WORLD = " Select Country_Master.Country_Name, Country_Master.Country_Code from Country_Master,Country_Profile where ltrim(rtrim(Country_name)) not in ('World') and country_master.country_code = country_profile.country_code order by country_name" Const ERROR_PATH = "/inc/commoninc/error.asp?errno=" '---------Pagination Related Variables declarations-----------' dim NO_OF_REC_PER_PAGE NO_OF_REC_PER_PAGE = Cint(Application("numrecords")) 'NO_OF_REC_PER_PAGE = 2 NO_OF_PAGES_PER_SET = 10 '--------Pagination related Variables Declaration Ends--------' ' Pagination Code if Request.QueryString("pgno")="" then intPageno=1 else intpageNo= Cint(Request.QueryString("pgno")) end if ' End Pagination Code '----------------------------------------------------- 'dim NO_OF_REC_PER_PAGE 'NO_OF_REC_PER_PAGE = Cint(Application("numrecords")) dim strDirName strDirName = ucase(trim(Request.Form("cboDir"))) dim strKeyword 'change dim lngCountryCode dim lngProductCode strKeyWord = "" lngCountryCode = 0 lngProductCode = 0 dim txtKeyword txtKeyword = "" if trim(Request.Form("txtKeyword")) <> "" then txtKeyword = trim(server.htmlEncode(Request.Form("txtKeyword"))) strKeyWord = trim(Request.Form("txtKeyword")) else txtKeyword = trim(server.htmlEncode(Request.querystring("crt"))) strKeyWord = trim(Request.querystring("crt")) end if '--------------Redirection Code-----------------------------' 'if page is accessed directly then redirect it to 'the main first page default.asp. If (trim(Request.Form("cboCtry")) = "") And (trim(Request.querystring("CtryCd") = "")) then Response.Redirect ERROR_PATH end if 'If (trim(Request.Form("cboProd")) = "") And (trim(Request.querystring("ProdCd") = "")) then ' Response.Redirect ERROR_PATH 'end if '--------------Redirection Code is Over----------------------' 'change 'Country Code if trim(Request.Form("cboCtry")) <> "" then lngCountryCode = Clng(trim(Request.Form("cboCtry"))) else lngCountryCode = Clng(trim(Request.querystring("CtryCd"))) end if 'In case of Country , Product Catg is not entertained. 'change 'Product Code 'if trim(Request.Form("cboProd")) <> "" then ' lngProductCode = Clng(trim(Request.Form("cboProd"))) 'else ' lngProductCode = Clng(trim(Request.querystring("ProdCd"))) 'end if 'lngProductCode = -1 'Only in case of Country 'Response.Write "
lngProductCode = " & lngProductCode dim strQryString strQryString = "" 'strQryString = "?Crt=" & server.urlEncode(strKeyWord) & "&CtryCd=" & lngCountryCode & "&ProdCd=" & lngProductCode strQryString = "?Crt=&CtryCd=-1&ProdCd=-1&fromdiff=Y" Select case strDirName case "E" 'EXPORTER Response.redirect EXPORTER_PATH & strQryString case "M" 'MANUFACTURER Response.redirect MANUFACTURER_PATH & strQryString case "C" 'COMPANY Response.redirect COMPANY_PATH & strQryString case "I" 'IMPORTER Response.redirect IMPORTER_PATH & strQryString case "P" 'PRODUCT Response.redirect PRODUCT_PATH & strQryString end select strDirName = "Country" 'To be posted. dim strCountry_Name dim strProductCatgName strCountry_Name = "" strProductCatgName = "" %> <% 'Security Code......... dim strPageCode strPageCode = "442Dr05" %> ITPO - Search Results For Country's Directory
<% dim NavigArray() Redim NavigArray(1,0) NavigArray(0,0) = "/search/directory/" NavigArray(1,0) = "Search From Different Directories" Redim Preserve NavigArray(1,1) NavigArray(0,1) = "" if (trim(Request.Form("Search"))) <> "" Or (trim(Request.QueryString("Search") <> "")) then NavigArray(1,1) = "Country's Search Result" else NavigArray(1,1) = "Country's Search" end if Proc_TO_Display_NavigationPath NavigArray, "U" %>
Country Search
<% dim strDirVal strDirVal = "" strDirVal = "T" 'Country %> <% strKeyWord = WorkingOnSpecialCharacters_IN_Keywords(strKeyWord) %>
Directory
Country
<% dim rs dim strQry strQry = "" dim strCaption dim strLabel strLabel = "" strCaption = "" set rs = server.CreateObject("adodb.recordset") Select Case strDirVal case "I" 'Importer strQry = COUNTRY_QUERY_WITH_OUT_WORLD strCaption = "-ALL-" strLabel = "Country" case "E" 'Exporter strQry = "Select City_Name,City_Code from City_Master" & _ " Order by City_Name" strCaption = "-ALL-" strLabel = "City" case "M" 'Manufacturer strQry = COUNTRY_QUERY_WITH_OUT_WORLD strCaption = "-ALL-" strLabel = "Country" case "C" 'Company strQry = COUNTRY_QUERY_WITH_OUT_WORLD strCaption = "-ALL-" strLabel = "Country" case "T" 'Country strQry = COUNTRY_QUERY_WITH_OUT_WORLD strCaption = "-ALL-" strLabel = "Country" end select set rs = objConn.execute(strQry) %>
Keywords
Search Tips
<%if Request.QueryString("fromDiff") = "" then %> <% if rs.State <> 0 then rs.Close end if strQry = "" dim bln_NotEmptyAfterReplacements bln_NotEmptyAfterReplacements = 1 'Conditions with Keyword involvement ie Full - Text Search . if trim(strKeyWord) <> "" then 'For Search the words entered by the user will be taken as 'different members of an Array and then where Clause will be made 'against those words with ORing them . dim arrCrt if strKeyWord <> "" then 'Removing All the "," , "'", and ";" from the string. 'rules for OR ing or taking Keywords as a single word. strKeyWord = trim(strKeyWord) strKeyWord = replace(strKeyWord,"'","",1,-1,1) strKeyWord = replace(strKeyWord,","," ",1,-1,1) strKeyWord = replace(strKeyWord,";"," ",1,-1,1) strKeyWord = replace(strKeyWord,":","",1,-1,1) 'Response.Write "strKeyWord = " & strKeyWord if trim(strKeyWord) <> "" then dim intKeyWordType intKeyWordType = 0 intKeyWordType = DoubleQuotes_Processing(strKeyWord) if (intKeyWordType = 2 ) Or (intKeyWordType = 3 ) then arrCrt = split(strKeyWord," ",-1,1) end if else bln_NotEmptyAfterReplacements = 0 end if end if 'When Country is not selected. if (lngCountryCode = -1) then 'When All country Option is selected. strQry = " Select distinct CM.Country_Code,CM.Currency, " & _ " CM.Country_Name from Country_Master CM,Country_Code where " & _ " CM.country_code = country_profile.country_code And CONTAINS(CM.*,'" elseif (lngCountryCode <> -1) then strQry = " Select distinct CM.Country_Code,CM.Currency, " & _ " CM.Country_Name from Country_Master CM where " & _ " CM.Country_Code = " & lngCountryCode & _ " And CONTAINS(CM.*,'" end if 'If there are multiple keywords separated by a delimiter 'viz. a space..then Where Clause will be constructed in a diff. 'way. dim strWhereClause strWhereClause = "" if (intKeyWordType = 2 ) Or (intKeyWordType = 3 ) then if Isarray(arrCrt) then dim I dim strWord strWord = "" for I = 0 to ubound(arrCrt) strWord = trim(arrCrt(i)) if strWord <> "" then strWhereClause = strWhereClause & """" & strWord & "*""" & " OR " end if next end if strWhereClause = trim(strWhereClause) if strWhereClause <> "" then 'Removing the unwanted OR word from the last . strWhereClause = trim(left(strWhereClause,len(strWhereClause) - 2)) end if elseif intKeyWordType = 1 then 'For single Word strWhereClause = strKeyWord strWhereClause = trim(strWhereClause) end if 'Response.Write "
where clause = " & strWhereClause strQry = strQry & strWhereClause & "')" 'Response.Write "
qry = " & strQry 'Conditions without Keyword involvement ie Full - Text Search . elseif (trim(strKeyWord) = "") And (lngCountryCode = -1) then strQry = " Select distinct CM.Country_Code,CM.Currency, " & _ " CM.Country_Name from Country_Master CM, country_Profile where " & _ " CM.country_code = country_profile.country_code " elseif (trim(strKeyWord) = "") And (lngCountryCode <> -1) then strQry = " Select distinct CM.Country_Code,CM.Currency, " & _ " CM.Country_Name from Country_Master CM where " & _ " CM.Country_Code = " & lngCountryCode end if strQry = strQry & " Order by CM.Country_Name " '----------------------------------------------- 'variables defined for holding the Column header 'values which will vary according to the 'Directory selected by the user for search.. dim ColHead1 dim ColHead2 dim ColHead3 dim ColHead4 ColHead1 = "" ColHead2 = "" ColHead3 = "" ColHead4 = "" ColHead1 = "Country Name" ColHead2 = "Capital" ColHead3 = "Population" ColHead4 = "Currency" '----------------------------------------------- rs.ActiveConnection = objConn rs.CursorType = AdOpenStatic rs.LockType = adLockOptimistic if bln_NotEmptyAfterReplacements = 1 then 'Error Handling in the Search : especially of Ignored Words. dim EncodedSectionName EncodedSectionName = "Search from Different Directories - Country" On error resume next 'Response.Write strQry rs.Open strQry if cint(Err.number)=-2147217900 then Response.Redirect "/inc/commoninc/error.asp?section=" & EncodedSectionName & "&errorno=M11" end if on error goto 0 '---------Error Handling Ends----------' 'Response.Write strQry '-----------Pagination Code-------------' dim PgNo PgNo = 0 if not ( rs.EOF and rs.BOF ) then rs.PageSize = NO_OF_REC_PER_PAGE dim intPageCount intPageCount = rs.PageCount rs.AbsolutePage = intPageno end if '------------Pagination Related Code ends---------------' end if %> <% dim StartRecNo dim EndRecNo dim rCount rCount = 0 if Not ( rs.EOF and rs.BOF ) then rCount = rs.RecordCount StartRecNo = 0 EndRecNo = 0 ReturnRecNumbers intPageNo, StartRecNo, EndRecNo, rCount end if 'Latest changes 27th July dim strMsg dim strNoDataMsg strMsg = "" dim strMsgIMP strMsgIMP = "" strNoDataMsg = "" strNoDataMsg = Produce_NO_DATA_FOUND_String() strMsg = Produce_SEARCH_FOR_String() dim strSrchCaption strSrchCaption = "" 'strSrchCaption = strMsg strSrchCaption = replace(strMsg,"*","",1,-1,0) strSrchCaption = replace(strSrchCaption,"" & chr(34) & "","",1,-1,0) '---changes finished------' %>
<%if rs.RecordCount > 0 then %> <%=StartRecNo%> to <%=EndRecNo%> of <%=rCount%> Matching Records <%else%> 0 Matching Records <%End if %>
<%=strSrchCaption%> 
<%if bln_NotEmptyAfterReplacements = 1 then dim bln_NoRecord bln_NoRecord = 1 if not ( rs.EOF and rs.BOF ) then %> <% bln_NoRecord = 0 for i = 1 to rs.PageSize %> <% rs.MoveNext If rs.EOF Then Exit For Next Else %> <% end if else%> <% end if %>
Country Name
Capital
Population (in millions)
Currency
<% 'Capital dim strQ strQ = "" strQ = " Select Town_Name from Town_Master where " & _ " Capital_Flag = 'C' and Country_Code = " & rs("Country_Code") 'Response.Write strQ %> <%=GetNameFromCode(objConn, strQ )%> 
<% 'Population strQ = "" strQ = " Select Top 1 Population from INFL_GDP_RES_DETail " & _ " where Country_Code = " & rs("Country_Code") & " order by Year Desc" %> <% dim lngPopul lngPopul = "" lngPopul = GetNameFromCode(objConn, strQ ) if lngPopul <> "" then if Clng(lngPopul) = 0 then Response.Write "" else Response.Write lngPopul end if end if %> 
<% if trim(rs("Currency")) <> "" then dim strQQ 'rs("Currency") strQQ = "" strQQ = " select Currency_desc from Currency_master where " & _ " currency_code = " & Clng(trim(rs("Currency"))) 'Response.Write " currency = " & rs("Currency") %> <%=GetNamefromCode(objConn, strQQ)%> <%end if%>  
<% strNoDataMsg = replace(strNoDataMsg,"*","",1,-1,0) strNoDataMsg = replace(strNoDataMsg,"" & chr(34) & "","",1,-1,0) %> <%=strNoDataMsg%>
<% strNoDataMsg = replace(strNoDataMsg,"*","",1,-1,0) strNoDataMsg = replace(strNoDataMsg,"" & chr(34) & "","",1,-1,0) %> <%=strNoDataMsg%>
<% if not (rs.EOF and rs.BOF ) then if rs.RecordCount > NO_OF_REC_PER_PAGE then %>
<% 'Code specific to a section strCrt = "" strCrt = server.URLEncode(trim(strKeyWord)) '--Pagination code--' call pagination(rs.pagecount , strKeyword) %>
<% end if end if %>
<%end if%>
<% if not rs is nothing then if rs.state <> 0 then rs.close end if end if %> <% function GetProducts(Code) dim rsProd dim strQry dim strListProducts strListProducts = "" strQry = "" strQry = "Imp_Products " & Code & ",'I'" set rsProd = objConn.execute(strQry) 'Calling Stored Procedure if not ( rsProd.eof and rsProd.bof) then do while not rsProd.eof strListProducts = strListProducts & rsProd(0) & ", " rsProd.movenext loop strListProducts = trim(strListProducts) strListProducts = left(strListProducts,len(strListProducts)-1) end if GetProducts = strListProducts end function %> <% 'This function removes in between double 'quotes from the string having double quotes. 'eg. "ajay" "singh" will be returned as "ajay singh". 'even if there is a single quote like "ajay singh, it 'will be returned as "ajay singh". 'So three cases will be entertained in this function '1) "ajay" "singh" will be returned as "ajay singh". '2) "ajay singh, it will be returned as "ajay singh". '3) ajay "singh" it will be returned as ajay singh to be ORed. function DoubleQuotes_Processing(strKeyWords) 'Checking for the presence of first double quote. dim intPos1 dim intPos2 dim NumberToBEPassed intPos1 = 0 intPos2 = 0 NumberToBEPassed = -1 strKeyWords = trim(strKeyWords) intPos1 = instr(1,strKeyWords,"" & chr(34) & "",0) if intPos1 > 0 and intPos1 = 1 then 'ie the first Character is a Double quote ..eg "ajay singh " 'Changed on 6th Aug 01 'strKeyWords = trim(replace(strKeyWords,"" & chr(34) & "","",1,-1,0)) 'Putting an * after exact phrase removes the error for 'Ignored words in the Free text Search eg "as" will throw error 'but "as*" will not 'Changed on 6th Aug 01 'strKeyWords = chr(34) & strKeyWords & "*" & chr(34) 'strKeyWord = strKeyWords NumberToBEPassed = 1 'DoubleQuotes_Processing = 1 'Return value elseif intPos1 > 1 then 'ie the Double quote character is in betwwen ..eg ajay "singh " strKeyWords = trim(replace(strKeyWords,"" & chr(34) & "","",1,-1,0)) strKeyWord = strKeyWords NumberToBEPassed = 2 'DoubleQuotes_Processing = 2 'Return value elseif intPos1 = 0 then 'Double quote Not found strKeyWord = trim(strKeyWords) NumberToBEPassed = 3 'DoubleQuotes_Processing = 3 'Return value end if 'Remove error when user puts ""a or ""b in the keywords field ie ignored words 'within double quotes. DoubleQuotes_Processing = NumberToBEPassed end function %> <% function WorkingOnSpecialCharacters_IN_Keywords(lstrKeyWord) lstrKeyWord = trim(lstrKeyWord) lstrKeyWord = replace(lstrKeyWord,"'","",1,-1,1) lstrKeyWord = replace(lstrKeyWord,","," ",1,-1,1) lstrKeyWord = replace(lstrKeyWord,";"," ",1,-1,1) lstrKeyWord = replace(lstrKeyWord,"%","",1,-1,1) lstrKeyWord = replace(lstrKeyWord,"+"," ",1,-1,1) lstrKeyWord = trim(lstrKeyWord) 'Removal of Single double Quote when it is the only value in the 'keyword dim intPosOfDoubleQuote intPosOfDoubleQuote = instr(1,lstrKeyWord,"" & chr(34) & "",0) 'CHANGED ON 6TH OF AUGUST 'if ((len(lstrKeyWord) <=1) and (intPosOfDoubleQuote > 0 )) then 'lstrKeyWord = "" 'end if intPosOfDoubleQuote = instr(1,lstrKeyWord,"'",0) if ((len(lstrKeyWord) <=1) and (intPosOfDoubleQuote > 0 )) then lstrKeyWord = "" end if intPosOfDoubleQuote = instr(1,lstrKeyWord,",",0) if ((len(lstrKeyWord) <=1) and (intPosOfDoubleQuote > 0 )) then lstrKeyWord = "" end if intPosOfDoubleQuote = instr(1,lstrKeyWord,";",0) if ((len(lstrKeyWord) <=1) and (intPosOfDoubleQuote > 0 )) then lstrKeyWord = "" end if 'changed on 6th aug 2001 'Remove error when user puts "" in the keywords field. 'lstrKeyWord = trim(lstrKeyWord) 'if len(lstrKeyWord) = 2 then ' dim intPos1 ' dim intPos2 ' intPos1 = instr(1,lstrKeyWord,"" & chr(34) & "",0) ' ' if intPos1 > 0 and intPos1 = 1 then ' intPos2 = instr((intPos1+1),lstrKeyWord,"" & chr(34) & "",0) ' if intPos2 > 0 and intPos2 = 2 then ' lstrKeyWord = "" ' end if ' end if 'end if 'Remove error when user puts " " (a space character within double quotes) in the keywords field ie ignored words 'within double quotes. 'lstrKeyWord = trim(lstrKeyWord) 'if len(lstrKeyWord) = 3 then ' if instr(1,lstrKeyWord," ",0) > 0 then lstrKeyWord = "" 'end if WorkingOnSpecialCharacters_IN_Keywords = lstrKeyWord end function %> <% function Produce_SEARCH_FOR_String() dim LstrMsg LstrMsg = "Search Result for Country for " if trim(strCountry_Name) <> "" then LstrMsg = LstrMsg & " " & strCountry_Name & "," else LstrMsg = LstrMsg & " All," end if 'if trim(strProductCatgName) <> "" then ' LstrMsg = LstrMsg & " " & strProductCatgName & "," 'else ' LstrMsg = LstrMsg & " All," 'end if if trim(strKeyWord) <> "" then LstrMsg = LstrMsg & " " & strKeyWord & "" end if LstrMsg = trim(LstrMsg) if instr(len(LstrMsg)-3,LstrMsg,"for",1) > 0 then LstrMsg = left(LstrMsg,len(LstrMsg) - 3) end if LstrMsg = trim(LstrMsg) if instr(len(LstrMsg),LstrMsg,",",0) > 0 then LstrMsg = left(LstrMsg,len(LstrMsg) - 1) end if Produce_SEARCH_FOR_String = LstrMsg end function %> <% function Produce_NO_DATA_FOUND_String() strMsgIMP = "No matching record found for" if trim(strCountry_Name) <> "" then strMsgIMP = strMsgIMP & " " & strCountry_Name & "," else strMsgIMP = strMsgIMP & " All," end if 'if trim(strProductCatgName) <> "" then ' strMsgIMP = strMsgIMP & " " & strProductCatgName & "," 'else ' strMsgIMP = strMsgIMP & " All," 'end if if trim(strKeyWord) <> "" then strMsgIMP = strMsgIMP & " " & strKeyWord & "" end if strMsgIMP = trim(strMsgIMP) if instr(len(strMsgIMP)-3,strMsgIMP,"for",1) > 0 then strMsgIMP = left(strMsgIMP,len(strMsgIMP) - 3) end if strMsgIMP = trim(strMsgIMP) if instr(len(strMsgIMP),strMsgIMP,",",0) > 0 then strMsgIMP = left(strMsgIMP,len(strMsgIMP) - 1) end if Produce_NO_DATA_FOUND_String = strMsgIMP end function %> <% 'this procedure returns Start and End Record no. of the 'selected page. sub ReturnRecNumbers(lintPageNo, lStartRecNo, lEndRecNo, tot_recs) lEndRecNo = lintPageNo * NO_OF_REC_PER_PAGE lStartRecNo = (lEndRecNo - NO_OF_REC_PER_PAGE) + 1 if lEndRecNo >= tot_recs then lEndRecNo = tot_recs end if StartRecNo = lStartRecNo EndRecNo = lEndRecNo end sub %> <% function SelectOption(optionVal,SelectedDirVal) if trim(SelectedDirVal) = "" then SelectOption = " Selected" end if Select case SelectedDirVal case optionVal SelectOption = " Selected" end select end function %> <% Function pagination(rsmaxpages,keywords) Dim intstartpage ' starting page Dim intendpage ' Ending Page Dim intPageNo 'intpageno the Current Page No. Dim Maxpages ' set it to the recordset.pagecount Dim Maxpageset ' set it to one set Dim pagestring ' set it to pagestring ' Setting Maxpages = Recordset Maxpages maxpages = rsmaxpages ' If pgno is not there is querystring then set it to 1 if len(trim(Request("pgno"))) > 0 then intpageno=Request("pgno") else intpageno=1 end if '---ajay's Code-----------------' dim StrQryString StrQryString = "" 'change here StrQryString = "/Search/directory/results_diff_dirs_Country.asp?" & _ "crt=" & strCrt & "&CtryCd=" & lngCountryCode & "&ProdCd=" & lngProductCode & "&pgno=" 'Defining the PageString Here ' Change this pagestring = StrQryString '---ajay's Code ends------------' ' Defining the MaxPageSet Here ' Change This 'maxpageset=3 maxpageset = NO_OF_PAGES_PER_SET 'Initializing maxpages to the Record ' Change the Recordset Name maxpages = rsmaxpages if ((intpageno/maxpageset)=(intpageno\maxpageset)) then if (Cint(intendpage)>=Cint(maxpages)) then intendpage=maxpages else intendpage = ((maxpageset)*(intpageno\maxpageset)) intstartpage = intendpage-maxpageset+1 end if else intstartpage = ((maxpageset)*(intpageno\maxpageset))+1 intendpage = intstartpage+maxpageset-1 end if ' For Restricting the records in case the maxpageset is more than the maxpages if maxpageset > maxpages then intendpage = maxpages end if ' For Restricting the records in case the intendpage is more than the maxpages if intendpage > maxpages then intendpage = maxpages end if if (Cint(intstartpage)" if not(Cint(intpageno)=1) then Response.write "" & "«Prev" & "" & "  " end if For I = Cint(intstartpage) to Cint(intendpage) if Not (maxpages=1) then if (I = Cint(intpageno)) then ' if it is the current page disable the Link Response.write I & "  " else Response.write "" & I & "" & "  " end if End if Next ' Next Processing if not(Cint(intpageno)>=Cint(maxpages)) then Response.write "" & "Next »" & "" & "  " end if Response.write "" End if end function %>