% Response.Buffer = EW_RESPONSE_BUFFER %> <% Session.Timeout = 20 %> <% Response.Expires = 0 Response.ExpiresAbsolute = Now() - 1 Response.AddHeader "pragma", "no-cache" Response.AddHeader "cache-control", "private, no-cache, no-store, must-revalidate" %> <% ' Define page object Dim dimonds_search Set dimonds_search = New cdimonds_search Set Page = dimonds_search ' Page init processing Call dimonds_search.Page_Init() ' Page main processing Call dimonds_search.Page_Main() %>
<% dimonds_search.ShowMessage %> <% ' Drop page object Set dimonds_search = Nothing %> <% ' ----------------------------------------------------------------- ' Page Class ' Class cdimonds_search ' Page ID Public Property Get PageID() PageID = "search" End Property ' Table Name Public Property Get TableName() TableName = "dimonds" End Property ' Page Object Name Public Property Get PageObjName() PageObjName = "dimonds_search" End Property ' Page Name Public Property Get PageName() PageName = ew_CurrentPage() End Property ' Page Url Public Property Get PageUrl() PageUrl = ew_CurrentPage() & "?" If dimonds.UseTokenInUrl Then PageUrl = PageUrl & "t=" & dimonds.TableVar & "&" ' add page token End Property ' Message Public Property Get Message() Message = Session(EW_SESSION_MESSAGE) End Property Public Property Let Message(v) If Session(EW_SESSION_MESSAGE) <> "" Then ' Append Session(EW_SESSION_MESSAGE) = Session(EW_SESSION_MESSAGE) & "" & Message & "
" Session(EW_SESSION_MESSAGE) = "" ' Clear message in Session End If End Sub ' ----------------------- ' Validate Page request ' Public Function IsPageRequest() If dimonds.UseTokenInUrl Then IsPageRequest = False If Not (ObjForm Is Nothing) Then IsPageRequest = (dimonds.TableVar = ObjForm.GetValue("t")) End If If Request.QueryString("t").Count > 0 Then IsPageRequest = (dimonds.TableVar = Request.QueryString("t")) End If Else IsPageRequest = True End If End Function ' ----------------------------------------------------------------- ' Class initialize ' - init objects ' - open ADO connection ' Private Sub Class_Initialize() ' Initialize table object Set dimonds = New cdimonds ' Initialize form object Set ObjForm = Nothing ' Intialize page id (for backward compatibility) EW_PAGE_ID = "search" ' Initialize table name (for backward compatibility) EW_TABLE_NAME = "dimonds" ' Open connection to the database Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open EW_DB_CONNECTION_STRING End Sub ' ----------------------------------------------------------------- ' Subroutine Page_Init ' - called before page main ' - check Security ' - set up response header ' - call page load events ' Sub Page_Init() ' Global page loading event (in userfn7.asp) Call Page_Loading() ' Page load event, used in current page Call Page_Load() End Sub ' ----------------------------------------------------------------- ' Class terminate ' - clean up page object ' Private Sub Class_Terminate() Call Page_Terminate("") End Sub ' ----------------------------------------------------------------- ' Subroutine Page_Terminate ' - called when exit page ' - clean up ADO connection and objects ' - if url specified, redirect to url ' Sub Page_Terminate(url) ' Page unload event, used in current page Call Page_Unload() ' Global page unloaded event (in userfn60.asp) Call Page_Unloaded() If Not (Conn Is Nothing) Then Conn.Close ' Close Connection Set Conn = Nothing Set dimonds = Nothing ' Go to url if specified If url <> "" Then Response.Clear Response.Redirect url End If End Sub ' ' Subroutine Page_Terminate (End) ' ---------------------------------------- ' ----------------------------------------------------------------- ' Page main processing ' Sub Page_Main() Set ObjForm = New cFormObj If IsPageRequest Then ' Validate request ' Get action dimonds.CurrentAction = ObjForm.GetValue("a_search") Select Case dimonds.CurrentAction Case "S" ' Get Search Criteria ' Build search string for advanced search, remove blank field Dim sSrchStr Call LoadSearchValues() ' Get search values If ValidateSearch() Then sSrchStr = BuildAdvancedSearch() Else sSrchStr = "" Message = gsSearchError End If If sSrchStr <> "" Then Set ObjForm = Nothing ' Close form object sSrchStr = dimonds.UrlParm(sSrchStr) Call Page_Terminate("dimondslist.asp" & "?" & sSrchStr) ' Go to list page End If End Select End If ' Close form object Set ObjForm = Nothing ' Restore search settings from Session If gsSearchError = "" Then Call LoadAdvancedSearch() End If ' Render row for search dimonds.RowType = EW_ROWTYPE_SEARCH Call RenderRow() End Sub ' ----------------------------------------------------------------- ' Build advanced search ' Function BuildAdvancedSearch() Dim sSrchUrl sSrchUrl = "" ' Field Item No Call BuildSearchUrl(sSrchUrl, dimonds.Item_No) ' Field Date Added Call BuildSearchUrl(sSrchUrl, dimonds.Date_Added) ' Field Shape Call BuildSearchUrl(sSrchUrl, dimonds.Shape) ' Field Carat Weight Call BuildSearchUrl(sSrchUrl, dimonds.Carat_Weight) ' Field Cut Call BuildSearchUrl(sSrchUrl, dimonds.Cut) ' Field Color Call BuildSearchUrl(sSrchUrl, dimonds.Color) ' Field Clarity Call BuildSearchUrl(sSrchUrl, dimonds.Clarity) ' Field Certificate Call BuildSearchUrl(sSrchUrl, dimonds.Certificate) ' Field Price Call BuildSearchUrl(sSrchUrl, dimonds.Price) ' Field Depth Call BuildSearchUrl(sSrchUrl, dimonds.Depth) ' Field Table Call BuildSearchUrl(sSrchUrl, dimonds.Table) ' Field Polish Call BuildSearchUrl(sSrchUrl, dimonds.Polish) ' Field Symmetry Call BuildSearchUrl(sSrchUrl, dimonds.Symmetry) ' Field Girdle Call BuildSearchUrl(sSrchUrl, dimonds.Girdle) ' Field Culet Call BuildSearchUrl(sSrchUrl, dimonds.Culet) ' Field Fluorescence Call BuildSearchUrl(sSrchUrl, dimonds.Fluorescence) ' Field Measurements Call BuildSearchUrl(sSrchUrl, dimonds.Measurements) ' Field Crown Angle Call BuildSearchUrl(sSrchUrl, dimonds.Crown_Angle) ' Field Crown % Call BuildSearchUrl(sSrchUrl, dimonds.Crown_25) ' Field Pavilion Angle Call BuildSearchUrl(sSrchUrl, dimonds.Pavilion_Angle) ' Field Pavilion % Call BuildSearchUrl(sSrchUrl, dimonds.Pavilion_25) ' Field Slideshow Call BuildSearchUrl(sSrchUrl, dimonds.Slideshow) ' Field Ratio Call BuildSearchUrl(sSrchUrl, dimonds.Ratio) ' Field Description Call BuildSearchUrl(sSrchUrl, dimonds.Description) BuildAdvancedSearch = sSrchUrl End Function ' ----------------------------------------------------------------- ' Function to build search URL ' Sub BuildSearchUrl(Url, Fld) Dim FldVal, FldOpr, FldCond, FldVal2, FldOpr2 Dim FldParm Dim IsValidValue, sWrk sWrk = "" FldParm = Mid(Fld.FldVar, 3) FldVal = ObjForm.GetValue("x_" & FldParm) FldOpr = ObjForm.GetValue("z_" & FldParm) FldCond = ObjForm.GetValue("v_" & FldParm) FldVal2 = ObjForm.GetValue("y_" & FldParm) FldOpr2 = ObjForm.GetValue("w_" & FldParm) FldOpr = UCase(Trim(FldOpr)) If FldOpr = "BETWEEN" Then IsValidValue = (Fld.FldDataType <> EW_DATATYPE_NUMBER) Or _ (Fld.FldDataType = EW_DATATYPE_NUMBER And IsNumeric(FldVal) And IsNumeric(FldVal2)) If FldVal <> "" And FldVal2 <> "" And IsValidValue Then sWrk = "x_" & FldParm & "=" & Server.URLEncode(FldVal) & _ "&y_" & FldParm & "=" & Server.URLEncode(FldVal2) & _ "&z_" & FldParm & "=" & Server.URLEncode(FldOpr) End If ElseIf FldOpr = "IS NULL" Or FldOpr = "IS NOT NULL" Then sWrk = "x_" & FldParm & "=" & Server.URLEncode(FldVal) & _ "&z_" & FldParm & "=" & Server.URLEncode(FldOpr) Else IsValidValue = (Fld.FldDataType <> EW_DATATYPE_NUMBER) Or _ (Fld.FldDataType = EW_DATATYPE_NUMBER And IsNumeric(FldVal)) If FldVal <> "" And IsValidValue And ew_IsValidOpr(FldOpr, Fld.FldDataType) Then sWrk = "x_" & FldParm & "=" & Server.URLEncode(FldVal) & _ "&z_" & FldParm & "=" & Server.URLEncode(FldOpr) End If IsValidValue = (Fld.FldDataType <> EW_DATATYPE_NUMBER) Or _ (Fld.FldDataType = EW_DATATYPE_NUMBER And IsNumeric(FldVal2)) If FldVal2 <> "" And IsValidValue And ew_IsValidOpr(FldOpr2, Fld.FldDataType) Then If sWrk <> "" Then sWrk = sWrk & "&v_" & FldParm & "=" & FldCond & "&" sWrk = sWrk & "y_" & FldParm & "=" & Server.URLEncode(FldVal2) & _ "&w_" & FldParm & "=" & Server.URLEncode(FldOpr2) End If End If If sWrk <> "" Then If Url <> "" Then Url = Url & "&" Url = Url & sWrk End If End Sub ' ----------------------------------------------------------------- ' Load search values for validation ' Function LoadSearchValues() ' Load search values dimonds.Item_No.AdvancedSearch.SearchValue = ObjForm.GetValue("x_Item_No") dimonds.Date_Added.AdvancedSearch.SearchValue = ObjForm.GetValue("x_Date_Added") dimonds.Shape.AdvancedSearch.SearchValue = ObjForm.GetValue("x_Shape") dimonds.Carat_Weight.AdvancedSearch.SearchValue = ObjForm.GetValue("x_Carat_Weight") dimonds.Carat_Weight.AdvancedSearch.SearchValue2 = ObjForm.GetValue("y_Carat_Weight") dimonds.Cut.AdvancedSearch.SearchValue = ObjForm.GetValue("x_Cut") dimonds.Color.AdvancedSearch.SearchValue = ObjForm.GetValue("x_Color") dimonds.Clarity.AdvancedSearch.SearchValue = ObjForm.GetValue("x_Clarity") dimonds.Certificate.AdvancedSearch.SearchValue = ObjForm.GetValue("x_Certificate") dimonds.Price.AdvancedSearch.SearchValue = ObjForm.GetValue("x_Price") dimonds.Price.AdvancedSearch.SearchValue2 = ObjForm.GetValue("y_Price") dimonds.Depth.AdvancedSearch.SearchValue = ObjForm.GetValue("x_Depth") dimonds.Depth.AdvancedSearch.SearchValue2 = ObjForm.GetValue("y_Depth") dimonds.Table.AdvancedSearch.SearchValue = ObjForm.GetValue("x_Table") dimonds.Table.AdvancedSearch.SearchValue2 = ObjForm.GetValue("y_Table") dimonds.Polish.AdvancedSearch.SearchValue = ObjForm.GetValue("x_Polish") dimonds.Symmetry.AdvancedSearch.SearchValue = ObjForm.GetValue("x_Symmetry") dimonds.Girdle.AdvancedSearch.SearchValue = ObjForm.GetValue("x_Girdle") dimonds.Culet.AdvancedSearch.SearchValue = ObjForm.GetValue("x_Culet") dimonds.Fluorescence.AdvancedSearch.SearchValue = ObjForm.GetValue("x_Fluorescence") dimonds.Measurements.AdvancedSearch.SearchValue = ObjForm.GetValue("x_Measurements") dimonds.Crown_Angle.AdvancedSearch.SearchValue = ObjForm.GetValue("x_Crown_Angle") dimonds.Crown_25.AdvancedSearch.SearchValue = ObjForm.GetValue("x_Crown_25") dimonds.Pavilion_Angle.AdvancedSearch.SearchValue = ObjForm.GetValue("x_Pavilion_Angle") dimonds.Pavilion_25.AdvancedSearch.SearchValue = ObjForm.GetValue("x_Pavilion_25") dimonds.Slideshow.AdvancedSearch.SearchValue = ObjForm.GetValue("x_Slideshow") dimonds.Ratio.AdvancedSearch.SearchValue = ObjForm.GetValue("x_Ratio") dimonds.Description.AdvancedSearch.SearchValue = ObjForm.GetValue("x_Description") End Function ' ----------------------------------------------------------------- ' Render row values based on field settings ' Sub RenderRow() ' Call Row Rendering event Call dimonds.Row_Rendering() ' --------------------------------------- ' Common render codes for all row types ' --------------------------------------- ' Item No dimonds.Item_No.CellCssStyle = "" dimonds.Item_No.CellCssClass = "" ' Date Added dimonds.Date_Added.CellCssStyle = "" dimonds.Date_Added.CellCssClass = "" ' Shape dimonds.Shape.CellCssStyle = "" dimonds.Shape.CellCssClass = "" ' Carat Weight dimonds.Carat_Weight.CellCssStyle = "" dimonds.Carat_Weight.CellCssClass = "" ' Cut dimonds.Cut.CellCssStyle = "" dimonds.Cut.CellCssClass = "" ' Color dimonds.Color.CellCssStyle = "" dimonds.Color.CellCssClass = "" ' Clarity dimonds.Clarity.CellCssStyle = "" dimonds.Clarity.CellCssClass = "" ' Certificate dimonds.Certificate.CellCssStyle = "" dimonds.Certificate.CellCssClass = "" ' Certificate pic dimonds.Certificate_pic.CellCssStyle = "" dimonds.Certificate_pic.CellCssClass = "" ' Price dimonds.Price.CellCssStyle = "" dimonds.Price.CellCssClass = "" ' Picture dimonds.Picture.CellCssStyle = "" dimonds.Picture.CellCssClass = "" ' Depth dimonds.Depth.CellCssStyle = "" dimonds.Depth.CellCssClass = "" ' Table dimonds.Table.CellCssStyle = "" dimonds.Table.CellCssClass = "" ' Polish dimonds.Polish.CellCssStyle = "" dimonds.Polish.CellCssClass = "" ' Symmetry dimonds.Symmetry.CellCssStyle = "" dimonds.Symmetry.CellCssClass = "" ' Girdle dimonds.Girdle.CellCssStyle = "" dimonds.Girdle.CellCssClass = "" ' Culet dimonds.Culet.CellCssStyle = "" dimonds.Culet.CellCssClass = "" ' Fluorescence dimonds.Fluorescence.CellCssStyle = "" dimonds.Fluorescence.CellCssClass = "" ' Measurements dimonds.Measurements.CellCssStyle = "" dimonds.Measurements.CellCssClass = "" ' Crown Angle dimonds.Crown_Angle.CellCssStyle = "" dimonds.Crown_Angle.CellCssClass = "" ' Crown % dimonds.Crown_25.CellCssStyle = "" dimonds.Crown_25.CellCssClass = "" ' Pavilion Angle dimonds.Pavilion_Angle.CellCssStyle = "" dimonds.Pavilion_Angle.CellCssClass = "" ' Pavilion % dimonds.Pavilion_25.CellCssStyle = "" dimonds.Pavilion_25.CellCssClass = "" ' Slideshow dimonds.Slideshow.CellCssStyle = "" dimonds.Slideshow.CellCssClass = "" ' Ratio dimonds.Ratio.CellCssStyle = "" dimonds.Ratio.CellCssClass = "" ' Description dimonds.Description.CellCssStyle = "" dimonds.Description.CellCssClass = "" ' ----------- ' View Row ' ----------- If dimonds.RowType = EW_ROWTYPE_VIEW Then ' View row ' Item No dimonds.Item_No.ViewValue = dimonds.Item_No.CurrentValue dimonds.Item_No.ViewValue = ew_FormatNumber(dimonds.Item_No.ViewValue, 0, -2, -2, -2) dimonds.Item_No.CssStyle = "font-weight:bold;" dimonds.Item_No.CssClass = "" dimonds.Item_No.ViewCustomAttributes = "" ' Date Added dimonds.Date_Added.ViewValue = dimonds.Date_Added.CurrentValue dimonds.Date_Added.ViewValue = ew_FormatDateTime(dimonds.Date_Added.ViewValue, 2) dimonds.Date_Added.CssStyle = "" dimonds.Date_Added.CssClass = "" dimonds.Date_Added.ViewCustomAttributes = "" ' Shape If dimonds.Shape.CurrentValue & "" <> "" Then sSqlWrk = "SELECT [shape], [Pic] FROM [shape] WHERE [shape] = '" & ew_AdjustSql(dimonds.Shape.CurrentValue) & "'" Set RsWrk = Conn.Execute(sSqlWrk) If Not RsWrk.Eof Then dimonds.Shape.ViewValue = RsWrk("shape") dimonds.Shape.ViewValue = dimonds.Shape.ViewValue & ew_ValueSeparator(0) & RsWrk("Pic") Else dimonds.Shape.ViewValue = dimonds.Shape.CurrentValue End If RsWrk.Close Set RsWrk = Nothing Else dimonds.Shape.ViewValue = Null End If dimonds.Shape.CssStyle = "font-weight:bold;" dimonds.Shape.CssClass = "" dimonds.Shape.ViewCustomAttributes = "" ' Carat Weight dimonds.Carat_Weight.ViewValue = dimonds.Carat_Weight.CurrentValue dimonds.Carat_Weight.ViewValue = ew_FormatNumber(dimonds.Carat_Weight.ViewValue, 2, -2, 0, 0) dimonds.Carat_Weight.CssStyle = "font-weight:bold;" dimonds.Carat_Weight.CssClass = "" dimonds.Carat_Weight.ViewCustomAttributes = "" ' Cut If dimonds.Cut.CurrentValue & "" <> "" Then arwrk = Split(dimonds.Cut.CurrentValue&"",",") sSqlWrk = "SELECT [Cut] FROM [cut] WHERE " sWhereWrk = "" For ari = 0 to UBound(arwrk) If sWhereWrk <> "" Then sWhereWrk = sWhereWrk & " OR " sWhereWrk = sWhereWrk & "[Cut] = '" & ew_AdjustSql(Trim(arwrk(ari))) & "'" Next If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & "(" & sWhereWrk & ")" Set RsWrk = Conn.Execute(sSqlWrk) dimonds.Cut.ViewValue = "" ari = 0 Do While Not RsWrk.Eof dimonds.Cut.ViewValue = dimonds.Cut.ViewValue & RsWrk("Cut") RsWrk.MoveNext If Not RsWrk.Eof Then dimonds.Cut.ViewValue = dimonds.Cut.ViewValue & ew_ViewOptionSeparator(ari) ' Separate Options End If ari = ari + 1 Loop RsWrk.Close Set RsWrk = Nothing Else dimonds.Cut.ViewValue = Null End If dimonds.Cut.CssStyle = "font-weight:bold;" dimonds.Cut.CssClass = "" dimonds.Cut.ViewCustomAttributes = "" ' Color If dimonds.Color.CurrentValue & "" <> "" Then arwrk = Split(dimonds.Color.CurrentValue&"",",") sSqlWrk = "SELECT [Color] FROM [color] WHERE " sWhereWrk = "" For ari = 0 to UBound(arwrk) If sWhereWrk <> "" Then sWhereWrk = sWhereWrk & " OR " sWhereWrk = sWhereWrk & "[Color] = '" & ew_AdjustSql(Trim(arwrk(ari))) & "'" Next If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & "(" & sWhereWrk & ")" Set RsWrk = Conn.Execute(sSqlWrk) dimonds.Color.ViewValue = "" ari = 0 Do While Not RsWrk.Eof dimonds.Color.ViewValue = dimonds.Color.ViewValue & RsWrk("Color") RsWrk.MoveNext If Not RsWrk.Eof Then dimonds.Color.ViewValue = dimonds.Color.ViewValue & ew_ViewOptionSeparator(ari) ' Separate Options End If ari = ari + 1 Loop RsWrk.Close Set RsWrk = Nothing Else dimonds.Color.ViewValue = Null End If dimonds.Color.CssStyle = "font-weight:bold;" dimonds.Color.CssClass = "" dimonds.Color.ViewCustomAttributes = "" ' Clarity If dimonds.Clarity.CurrentValue & "" <> "" Then arwrk = Split(dimonds.Clarity.CurrentValue&"",",") sSqlWrk = "SELECT [Clarity] FROM [clarity] WHERE " sWhereWrk = "" For ari = 0 to UBound(arwrk) If sWhereWrk <> "" Then sWhereWrk = sWhereWrk & " OR " sWhereWrk = sWhereWrk & "[Clarity] = '" & ew_AdjustSql(Trim(arwrk(ari))) & "'" Next If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & "(" & sWhereWrk & ")" Set RsWrk = Conn.Execute(sSqlWrk) dimonds.Clarity.ViewValue = "" ari = 0 Do While Not RsWrk.Eof dimonds.Clarity.ViewValue = dimonds.Clarity.ViewValue & RsWrk("Clarity") RsWrk.MoveNext If Not RsWrk.Eof Then dimonds.Clarity.ViewValue = dimonds.Clarity.ViewValue & ew_ViewOptionSeparator(ari) ' Separate Options End If ari = ari + 1 Loop RsWrk.Close Set RsWrk = Nothing Else dimonds.Clarity.ViewValue = Null End If dimonds.Clarity.CssStyle = "font-weight:bold;" dimonds.Clarity.CssClass = "" dimonds.Clarity.ViewCustomAttributes = "" ' Certificate dimonds.Certificate.ViewValue = dimonds.Certificate.CurrentValue dimonds.Certificate.CssStyle = "" dimonds.Certificate.CssClass = "" dimonds.Certificate.ViewCustomAttributes = "" ' Certificate pic If Not IsNull(dimonds.Certificate_pic.Upload.DbValue) Then dimonds.Certificate_pic.ViewValue = dimonds.Certificate_pic.Upload.DbValue Else dimonds.Certificate_pic.ViewValue = "" End If dimonds.Certificate_pic.CssStyle = "" dimonds.Certificate_pic.CssClass = "" dimonds.Certificate_pic.ViewCustomAttributes = "" ' Price dimonds.Price.ViewValue = dimonds.Price.CurrentValue dimonds.Price.ViewValue = ew_FormatCurrency(dimonds.Price.ViewValue, 0, -2, -2, -2) dimonds.Price.CssStyle = "font-weight:bold;" dimonds.Price.CssClass = "" dimonds.Price.ViewCustomAttributes = "" ' Picture If Not IsNull(dimonds.Picture.Upload.DbValue) Then dimonds.Picture.ViewValue = dimonds.Picture.Upload.DbValue dimonds.Picture.ImageAlt = "" Else dimonds.Picture.ViewValue = "" End If dimonds.Picture.CssStyle = "" dimonds.Picture.CssClass = "" dimonds.Picture.ViewCustomAttributes = "" ' Depth dimonds.Depth.ViewValue = dimonds.Depth.CurrentValue dimonds.Depth.ViewValue = ew_FormatPercent(dimonds.Depth.ViewValue, 1, -2, 0, 0) dimonds.Depth.CssStyle = "font-weight:bold;" dimonds.Depth.CssClass = "" dimonds.Depth.ViewCustomAttributes = "%" ' Table dimonds.Table.ViewValue = dimonds.Table.CurrentValue dimonds.Table.ViewValue = ew_FormatPercent(dimonds.Table.ViewValue, 1, -2, 0, 0) dimonds.Table.CssStyle = "font-weight:bold;" dimonds.Table.CssClass = "" dimonds.Table.ViewCustomAttributes = "" ' Polish If dimonds.Polish.CurrentValue & "" <> "" Then arwrk = Split(dimonds.Polish.CurrentValue&"",",") sSqlWrk = "SELECT [Polish] FROM [polish] WHERE " sWhereWrk = "" For ari = 0 to UBound(arwrk) If sWhereWrk <> "" Then sWhereWrk = sWhereWrk & " OR " sWhereWrk = sWhereWrk & "[Polish] = '" & ew_AdjustSql(Trim(arwrk(ari))) & "'" Next If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & "(" & sWhereWrk & ")" Set RsWrk = Conn.Execute(sSqlWrk) dimonds.Polish.ViewValue = "" ari = 0 Do While Not RsWrk.Eof dimonds.Polish.ViewValue = dimonds.Polish.ViewValue & RsWrk("Polish") RsWrk.MoveNext If Not RsWrk.Eof Then dimonds.Polish.ViewValue = dimonds.Polish.ViewValue & ew_ViewOptionSeparator(ari) ' Separate Options End If ari = ari + 1 Loop RsWrk.Close Set RsWrk = Nothing Else dimonds.Polish.ViewValue = Null End If dimonds.Polish.CssStyle = "font-weight:bold;" dimonds.Polish.CssClass = "" dimonds.Polish.ViewCustomAttributes = "" ' Symmetry If dimonds.Symmetry.CurrentValue & "" <> "" Then arwrk = Split(dimonds.Symmetry.CurrentValue&"",",") sSqlWrk = "SELECT [Symmetry] FROM [symmetry] WHERE " sWhereWrk = "" For ari = 0 to UBound(arwrk) If sWhereWrk <> "" Then sWhereWrk = sWhereWrk & " OR " sWhereWrk = sWhereWrk & "[Symmetry] = '" & ew_AdjustSql(Trim(arwrk(ari))) & "'" Next If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & "(" & sWhereWrk & ")" Set RsWrk = Conn.Execute(sSqlWrk) dimonds.Symmetry.ViewValue = "" ari = 0 Do While Not RsWrk.Eof dimonds.Symmetry.ViewValue = dimonds.Symmetry.ViewValue & RsWrk("Symmetry") RsWrk.MoveNext If Not RsWrk.Eof Then dimonds.Symmetry.ViewValue = dimonds.Symmetry.ViewValue & ew_ViewOptionSeparator(ari) ' Separate Options End If ari = ari + 1 Loop RsWrk.Close Set RsWrk = Nothing Else dimonds.Symmetry.ViewValue = Null End If dimonds.Symmetry.CssStyle = "font-weight:bold;" dimonds.Symmetry.CssClass = "" dimonds.Symmetry.ViewCustomAttributes = "" ' Girdle dimonds.Girdle.ViewValue = dimonds.Girdle.CurrentValue dimonds.Girdle.CssStyle = "" dimonds.Girdle.CssClass = "" dimonds.Girdle.ViewCustomAttributes = "" ' Culet dimonds.Culet.ViewValue = dimonds.Culet.CurrentValue dimonds.Culet.CssStyle = "" dimonds.Culet.CssClass = "" dimonds.Culet.ViewCustomAttributes = "" ' Fluorescence dimonds.Fluorescence.ViewValue = dimonds.Fluorescence.CurrentValue dimonds.Fluorescence.CssStyle = "" dimonds.Fluorescence.CssClass = "" dimonds.Fluorescence.ViewCustomAttributes = "" ' Measurements dimonds.Measurements.ViewValue = dimonds.Measurements.CurrentValue dimonds.Measurements.CssStyle = "" dimonds.Measurements.CssClass = "" dimonds.Measurements.ViewCustomAttributes = "" ' Crown Angle dimonds.Crown_Angle.ViewValue = dimonds.Crown_Angle.CurrentValue dimonds.Crown_Angle.ViewValue = ew_FormatNumber(dimonds.Crown_Angle.ViewValue, 2, -2, 0, 0) dimonds.Crown_Angle.CssStyle = "" dimonds.Crown_Angle.CssClass = "" dimonds.Crown_Angle.ViewCustomAttributes = "" ' Crown % dimonds.Crown_25.ViewValue = dimonds.Crown_25.CurrentValue dimonds.Crown_25.ViewValue = ew_FormatPercent(dimonds.Crown_25.ViewValue, 2, -1, 0, 0) dimonds.Crown_25.CssStyle = "" dimonds.Crown_25.CssClass = "" dimonds.Crown_25.ViewCustomAttributes = "" ' Pavilion Angle dimonds.Pavilion_Angle.ViewValue = dimonds.Pavilion_Angle.CurrentValue dimonds.Pavilion_Angle.ViewValue = ew_FormatNumber(dimonds.Pavilion_Angle.ViewValue, 2, -2, 0, 0) dimonds.Pavilion_Angle.CssStyle = "" dimonds.Pavilion_Angle.CssClass = "" dimonds.Pavilion_Angle.ViewCustomAttributes = "" ' Pavilion % dimonds.Pavilion_25.ViewValue = dimonds.Pavilion_25.CurrentValue dimonds.Pavilion_25.ViewValue = ew_FormatPercent(dimonds.Pavilion_25.ViewValue, 2, -2, -1, 0) dimonds.Pavilion_25.CssStyle = "" dimonds.Pavilion_25.CssClass = "" dimonds.Pavilion_25.ViewCustomAttributes = "" ' Slideshow If dimonds.Slideshow.CurrentValue = "1" Then dimonds.Slideshow.ViewValue = "Yes" Else dimonds.Slideshow.ViewValue = "No" End If dimonds.Slideshow.CssStyle = "" dimonds.Slideshow.CssClass = "" dimonds.Slideshow.ViewCustomAttributes = "" ' Ratio dimonds.Ratio.ViewValue = dimonds.Ratio.CurrentValue dimonds.Ratio.ViewValue = ew_FormatNumber(dimonds.Ratio.ViewValue, 2, -2, 0, 0) dimonds.Ratio.CssStyle = "" dimonds.Ratio.CssClass = "" dimonds.Ratio.ViewCustomAttributes = "" ' Description dimonds.Description.ViewValue = dimonds.Description.CurrentValue dimonds.Description.CssStyle = "" dimonds.Description.CssClass = "" dimonds.Description.ViewCustomAttributes = "" ' View refer script ' Item No dimonds.Item_No.HrefValue = "" ' Date Added dimonds.Date_Added.HrefValue = "" ' Shape dimonds.Shape.HrefValue = "" ' Carat Weight dimonds.Carat_Weight.HrefValue = "" ' Cut dimonds.Cut.HrefValue = "" ' Color dimonds.Color.HrefValue = "" ' Clarity dimonds.Clarity.HrefValue = "" ' Certificate dimonds.Certificate.HrefValue = "" ' Certificate pic If Not IsNull(dimonds.Certificate_pic.Upload.DbValue) Then dimonds.Certificate_pic.HrefValue = ew_UploadPathEx(False, "certificates/") & ew_IIf(dimonds.Certificate_pic.ViewValue<>"", dimonds.Certificate_pic.ViewValue, dimonds.Certificate_pic.CurrentValue) If dimonds.Export <> "" Then dimonds.Certificate_pic.HrefValue = ew_ConvertFullUrl(dimonds.Certificate_pic.HrefValue) Else dimonds.Certificate_pic.HrefValue = "" End If ' Price dimonds.Price.HrefValue = "" ' Picture If Not IsNull(dimonds.Picture.Upload.DbValue) Then dimonds.Picture.HrefValue = ew_UploadPathEx(False, EW_UPLOAD_DEST_PATH) & ew_IIf(dimonds.Picture.ViewValue<>"", dimonds.Picture.ViewValue, dimonds.Picture.CurrentValue) If dimonds.Export <> "" Then dimonds.Picture.HrefValue = ew_ConvertFullUrl(dimonds.Picture.HrefValue) Else dimonds.Picture.HrefValue = "" End If ' Depth dimonds.Depth.HrefValue = "" ' Table dimonds.Table.HrefValue = "" ' Polish dimonds.Polish.HrefValue = "" ' Symmetry dimonds.Symmetry.HrefValue = "" ' Girdle dimonds.Girdle.HrefValue = "" ' Culet dimonds.Culet.HrefValue = "" ' Fluorescence dimonds.Fluorescence.HrefValue = "" ' Measurements dimonds.Measurements.HrefValue = "" ' Crown Angle dimonds.Crown_Angle.HrefValue = "" ' Crown % dimonds.Crown_25.HrefValue = "" ' Pavilion Angle dimonds.Pavilion_Angle.HrefValue = "" ' Pavilion % dimonds.Pavilion_25.HrefValue = "" ' Slideshow dimonds.Slideshow.HrefValue = "" ' Ratio dimonds.Ratio.HrefValue = "" ' Description dimonds.Description.HrefValue = "" ' ------------ ' Search Row ' ------------ ElseIf dimonds.RowType = EW_ROWTYPE_SEARCH Then ' Search row ' Item No dimonds.Item_No.EditCustomAttributes = "" dimonds.Item_No.EditValue = ew_HtmlEncode(dimonds.Item_No.AdvancedSearch.SearchValue) ' Date Added dimonds.Date_Added.EditCustomAttributes = "" dimonds.Date_Added.EditValue = dimonds.Date_Added.AdvancedSearch.SearchValue ' Shape dimonds.Shape.EditCustomAttributes = "" sSqlWrk = "SELECT [shape], [shape], [Pic], '' AS SelectFilterFld FROM [shape]" sWhereWrk = "" If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk Set RsWrk = Server.CreateObject("ADODB.Recordset") RsWrk.Open sSqlWrk, Conn If Not RsWrk.Eof Then arwrk = RsWrk.GetRows Else arwrk = "" End If RsWrk.Close Set RsWrk = Nothing dimonds.Shape.EditValue = arwrk ' Carat Weight dimonds.Carat_Weight.EditCustomAttributes = "" dimonds.Carat_Weight.EditValue = ew_HtmlEncode(dimonds.Carat_Weight.AdvancedSearch.SearchValue) dimonds.Carat_Weight.EditCustomAttributes = "" dimonds.Carat_Weight.EditValue2 = ew_HtmlEncode(dimonds.Carat_Weight.AdvancedSearch.SearchValue2) ' Cut dimonds.Cut.EditCustomAttributes = "" sSqlWrk = "SELECT [Cut], [Cut], '' AS Disp2Fld, '' AS SelectFilterFld FROM [cut]" sWhereWrk = "" If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk Set RsWrk = Server.CreateObject("ADODB.Recordset") RsWrk.Open sSqlWrk, Conn If Not RsWrk.Eof Then arwrk = RsWrk.GetRows Else arwrk = "" End If RsWrk.Close Set RsWrk = Nothing dimonds.Cut.EditValue = arwrk ' Color dimonds.Color.EditCustomAttributes = "" sSqlWrk = "SELECT [Color], [Color], '' AS Disp2Fld, '' AS SelectFilterFld FROM [color]" sWhereWrk = "" If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk Set RsWrk = Server.CreateObject("ADODB.Recordset") RsWrk.Open sSqlWrk, Conn If Not RsWrk.Eof Then arwrk = RsWrk.GetRows Else arwrk = "" End If RsWrk.Close Set RsWrk = Nothing dimonds.Color.EditValue = arwrk ' Clarity dimonds.Clarity.EditCustomAttributes = "" sSqlWrk = "SELECT [Clarity], [Clarity], '' AS Disp2Fld, '' AS SelectFilterFld FROM [clarity]" sWhereWrk = "" If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk Set RsWrk = Server.CreateObject("ADODB.Recordset") RsWrk.Open sSqlWrk, Conn If Not RsWrk.Eof Then arwrk = RsWrk.GetRows Else arwrk = "" End If RsWrk.Close Set RsWrk = Nothing dimonds.Clarity.EditValue = arwrk ' Certificate dimonds.Certificate.EditCustomAttributes = "" dimonds.Certificate.EditValue = ew_HtmlEncode(dimonds.Certificate.AdvancedSearch.SearchValue) ' Certificate pic dimonds.Certificate_pic.EditCustomAttributes = "" If Not IsNull(dimonds.Certificate_pic.Upload.DbValue) Then dimonds.Certificate_pic.EditValue = dimonds.Certificate_pic.Upload.DbValue Else dimonds.Certificate_pic.EditValue = "" End If ' Price dimonds.Price.EditCustomAttributes = "" dimonds.Price.EditValue = ew_HtmlEncode(dimonds.Price.AdvancedSearch.SearchValue) dimonds.Price.EditCustomAttributes = "" dimonds.Price.EditValue2 = ew_HtmlEncode(dimonds.Price.AdvancedSearch.SearchValue2) ' Picture dimonds.Picture.EditCustomAttributes = "" If Not IsNull(dimonds.Picture.Upload.DbValue) Then dimonds.Picture.EditValue = dimonds.Picture.Upload.DbValue dimonds.Picture.ImageAlt = "" Else dimonds.Picture.EditValue = "" End If ' Depth dimonds.Depth.EditCustomAttributes = "" dimonds.Depth.EditValue = ew_HtmlEncode(dimonds.Depth.AdvancedSearch.SearchValue) dimonds.Depth.EditCustomAttributes = "" dimonds.Depth.EditValue2 = ew_HtmlEncode(dimonds.Depth.AdvancedSearch.SearchValue2) ' Table dimonds.Table.EditCustomAttributes = "" dimonds.Table.EditValue = ew_HtmlEncode(dimonds.Table.AdvancedSearch.SearchValue) dimonds.Table.EditCustomAttributes = "" dimonds.Table.EditValue2 = ew_HtmlEncode(dimonds.Table.AdvancedSearch.SearchValue2) ' Polish dimonds.Polish.EditCustomAttributes = "" sSqlWrk = "SELECT [Polish], [Polish], '' AS Disp2Fld, '' AS SelectFilterFld FROM [polish]" sWhereWrk = "" If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk Set RsWrk = Server.CreateObject("ADODB.Recordset") RsWrk.Open sSqlWrk, Conn If Not RsWrk.Eof Then arwrk = RsWrk.GetRows Else arwrk = "" End If RsWrk.Close Set RsWrk = Nothing dimonds.Polish.EditValue = arwrk ' Symmetry dimonds.Symmetry.EditCustomAttributes = "" sSqlWrk = "SELECT [Symmetry], [Symmetry], '' AS Disp2Fld, '' AS SelectFilterFld FROM [symmetry]" sWhereWrk = "" If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk Set RsWrk = Server.CreateObject("ADODB.Recordset") RsWrk.Open sSqlWrk, Conn If Not RsWrk.Eof Then arwrk = RsWrk.GetRows Else arwrk = "" End If RsWrk.Close Set RsWrk = Nothing dimonds.Symmetry.EditValue = arwrk ' Girdle dimonds.Girdle.EditCustomAttributes = "" dimonds.Girdle.EditValue = ew_HtmlEncode(dimonds.Girdle.AdvancedSearch.SearchValue) ' Culet dimonds.Culet.EditCustomAttributes = "" dimonds.Culet.EditValue = ew_HtmlEncode(dimonds.Culet.AdvancedSearch.SearchValue) ' Fluorescence dimonds.Fluorescence.EditCustomAttributes = "" dimonds.Fluorescence.EditValue = ew_HtmlEncode(dimonds.Fluorescence.AdvancedSearch.SearchValue) ' Measurements dimonds.Measurements.EditCustomAttributes = "" dimonds.Measurements.EditValue = ew_HtmlEncode(dimonds.Measurements.AdvancedSearch.SearchValue) ' Crown Angle dimonds.Crown_Angle.EditCustomAttributes = "" dimonds.Crown_Angle.EditValue = ew_HtmlEncode(dimonds.Crown_Angle.AdvancedSearch.SearchValue) ' Crown % dimonds.Crown_25.EditCustomAttributes = "" dimonds.Crown_25.EditValue = ew_HtmlEncode(dimonds.Crown_25.AdvancedSearch.SearchValue) ' Pavilion Angle dimonds.Pavilion_Angle.EditCustomAttributes = "" dimonds.Pavilion_Angle.EditValue = ew_HtmlEncode(dimonds.Pavilion_Angle.AdvancedSearch.SearchValue) ' Pavilion % dimonds.Pavilion_25.EditCustomAttributes = "" dimonds.Pavilion_25.EditValue = ew_HtmlEncode(dimonds.Pavilion_25.AdvancedSearch.SearchValue) ' Slideshow dimonds.Slideshow.EditCustomAttributes = "" ' Ratio dimonds.Ratio.EditCustomAttributes = "" dimonds.Ratio.EditValue = ew_HtmlEncode(dimonds.Ratio.AdvancedSearch.SearchValue) ' Description dimonds.Description.EditCustomAttributes = "" dimonds.Description.EditValue = ew_HtmlEncode(dimonds.Description.AdvancedSearch.SearchValue) End If ' Call Row Rendered event Call dimonds.Row_Rendered() End Sub ' ----------------------------------------------------------------- ' Validate search ' Function ValidateSearch() ' Initialize gsSearchError = "" ' Check if validation required If Not EW_SERVER_VALIDATE Then ValidateSearch = True Exit Function End If If Not ew_CheckInteger(dimonds.Item_No.AdvancedSearch.SearchValue) Then If gsSearchError <> "" Then gsSearchError = gsSearchError & "