<% 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_list Set dimonds_list = New cdimonds_list Set Page = dimonds_list ' Page init processing Call dimonds_list.Page_Init() ' Page main processing Call dimonds_list.Page_Main() %> <% If dimonds.Export = "" Then %> <% End If %> <% If dimonds.Export = "" Then %> <% End If %> <% ' Load recordset Set Rs = dimonds_list.LoadRecordset() dimonds_list.lTotalRecs = Rs.RecordCount dimonds_list.lStartRec = 1 If dimonds_list.lDisplayRecs <= 0 Then ' Display all records dimonds_list.lDisplayRecs = dimonds_list.lTotalRecs End If If Not (dimonds.ExportAll And dimonds.Export <> "") Then dimonds_list.SetUpStartRec() ' Set up start record position End If %>

<% If dimonds.Export = "" And dimonds.CurrentAction = "" Then %> <% End If %>

<% If dimonds.Export = "" And dimonds.CurrentAction = "" Then %>
<% If gsSearchError = "" Then Call dimonds_list.LoadAdvancedSearch() ' Load advanced search End If ' Render for search dimonds.RowType = EW_ROWTYPE_SEARCH ' Render row Call dimonds_list.RenderRow() %>
Shape
>
<% emptywrk = True arwrk = dimonds.Shape.EditValue If IsArray(arwrk) Then rowswrk = UBound(arwrk, 2) For rowcntwrk = 0 To rowswrk If dimonds.Shape.AdvancedSearch.SearchValue&"" = arwrk(0, rowcntwrk)&"" Then selwrk = " checked=""checked""" emptywrk = False Else selwrk = "" End If ' Note: No spacing within the LABEL tag %> <%= ew_RepeatColumnTable(rowswrk, rowcntwrk, 10, 1) %> <%= ew_RepeatColumnTable(rowswrk, rowcntwrk, 10, 2) %> <% Next End If %>
<% sSqlWrk = "SELECT [shape], [shape] AS DispFld, [Pic] FROM [shape]" sWhereWrk = "" If sWhereWrk <> "" Then sSqlWrk = sSqlWrk & " WHERE " & sWhereWrk sSqlWrk = ew_Encode(TEAencrypt(sSqlWrk, EW_RANDOM_KEY)) %>
Carat Weight
>  -  >
Cut
>
<% emptywrk = True arwrk = dimonds.Cut.EditValue If IsArray(arwrk) Then armultiwrk= Split(dimonds.Cut.AdvancedSearch.SearchValue&"",",") rowswrk = UBound(arwrk, 2) For rowcntwrk = 0 To rowswrk selwrk = "" For ari = 0 to UBound(armultiwrk) If arwrk(0, rowcntwrk)&"" = Trim(armultiwrk(ari)&"") Then selwrk = " checked=""checked""" emptywrk = False Exit For End If Next ' Note: No spacing within the LABEL tag %> <%= ew_RepeatColumnTable(rowswrk, rowcntwrk, 10, 1) %> <%= ew_RepeatColumnTable(rowswrk, rowcntwrk, 10, 2) %> <% Next End If %>
Color
>
<% emptywrk = True arwrk = dimonds.Color.EditValue If IsArray(arwrk) Then armultiwrk= Split(dimonds.Color.AdvancedSearch.SearchValue&"",",") rowswrk = UBound(arwrk, 2) For rowcntwrk = 0 To rowswrk selwrk = "" For ari = 0 to UBound(armultiwrk) If arwrk(0, rowcntwrk)&"" = Trim(armultiwrk(ari)&"") Then selwrk = " checked=""checked""" emptywrk = False Exit For End If Next ' Note: No spacing within the LABEL tag %> <%= ew_RepeatColumnTable(rowswrk, rowcntwrk, 15, 1) %> <%= ew_RepeatColumnTable(rowswrk, rowcntwrk, 15, 2) %> <% Next End If %>
Clarity
>
<% emptywrk = True arwrk = dimonds.Clarity.EditValue If IsArray(arwrk) Then armultiwrk= Split(dimonds.Clarity.AdvancedSearch.SearchValue&"",",") rowswrk = UBound(arwrk, 2) For rowcntwrk = 0 To rowswrk selwrk = "" For ari = 0 to UBound(armultiwrk) If arwrk(0, rowcntwrk)&"" = Trim(armultiwrk(ari)&"") Then selwrk = " checked=""checked""" emptywrk = False Exit For End If Next ' Note: No spacing within the LABEL tag %> <%= ew_RepeatColumnTable(rowswrk, rowcntwrk, 10, 1) %> <%= ew_RepeatColumnTable(rowswrk, rowcntwrk, 10, 2) %> <% Next End If %>
Price
>  -  >

Show all  Advanced Search 


<% End If %> <% dimonds_list.ShowMessage %>
<% If dimonds_list.lTotalRecs > 0 Then %> <% dimonds_list.lOptionCnt = 0 dimonds_list.lOptionCnt = dimonds_list.lOptionCnt + 1 ' View dimonds_list.lOptionCnt = dimonds_list.lOptionCnt + dimonds_list.ListOptions.Items.Count ' Custom list options %> <%= dimonds.TableCustomInnerHTML %> <% If dimonds.Carat_Weight.Visible Then ' Carat Weight %> <% If dimonds.SortUrl(dimonds.Carat_Weight) = "" Then %> <% Else %> <% End If %> <% End If %> <% If dimonds.Cut.Visible Then ' Cut %> <% If dimonds.SortUrl(dimonds.Cut) = "" Then %> <% Else %> <% End If %> <% End If %> <% If dimonds.Color.Visible Then ' Color %> <% If dimonds.SortUrl(dimonds.Color) = "" Then %> <% Else %> <% End If %> <% End If %> <% If dimonds.Clarity.Visible Then ' Clarity %> <% If dimonds.SortUrl(dimonds.Clarity) = "" Then %> <% Else %> <% End If %> <% End If %> <% If dimonds.Certificate.Visible Then ' Certificate %> <% If dimonds.SortUrl(dimonds.Certificate) = "" Then %> <% Else %> <% End If %> <% End If %> <% If dimonds.Price.Visible Then ' Price %> <% If dimonds.SortUrl(dimonds.Price) = "" Then %> <% Else %> <% End If %> <% End If %> <% If dimonds.Depth.Visible Then ' Depth %> <% If dimonds.SortUrl(dimonds.Depth) = "" Then %> <% Else %> <% End If %> <% End If %> <% If dimonds.Table.Visible Then ' Table %> <% If dimonds.SortUrl(dimonds.Table) = "" Then %> <% Else %> <% End If %> <% End If %> <% If dimonds.Polish.Visible Then ' Polish %> <% If dimonds.SortUrl(dimonds.Polish) = "" Then %> <% Else %> <% End If %> <% End If %> <% If dimonds.Symmetry.Visible Then ' Symmetry %> <% If dimonds.SortUrl(dimonds.Symmetry) = "" Then %> <% Else %> <% End If %> <% End If %> <% If dimonds.Export = "" Then %> <% ' Custom list options For i = 0 to dimonds_list.ListOptions.Items.Count -1 If dimonds_list.ListOptions.Items(i).Visible Then Response.Write dimonds_list.ListOptions.Items(i).HeaderCellHtml Next %> <% End If %> <% If (dimonds.ExportAll And dimonds.Export <> "") Then dimonds_list.lStopRec = dimonds_list.lTotalRecs Else dimonds_list.lStopRec = dimonds_list.lStartRec + dimonds_list.lDisplayRecs - 1 ' Set the last record to display End If ' Move to first record dimonds_list.lRecCnt = dimonds_list.lStartRec - 1 If Not Rs.Eof Then Rs.MoveFirst If dimonds_list.lStartRec > 1 Then Rs.Move dimonds_list.lStartRec - 1 End If dimonds_list.lRowCnt = 0 ' Output date rows Do While (Not Rs.Eof Or dimonds.CurrentAction = "gridadd") And (dimonds_list.lRecCnt < dimonds_list.lStopRec) dimonds_list.lRecCnt = dimonds_list.lRecCnt + 1 If CLng(dimonds_list.lRecCnt) >= CLng(dimonds_list.lStartRec) Then dimonds_list.lRowCnt = dimonds_list.lRowCnt + 1 dimonds.CssClass = "" dimonds.CssStyle = "" dimonds.RowClientEvents = "onmouseover='ew_MouseOver(event, this);' onmouseout='ew_MouseOut(event, this);' onclick='ew_Click(event, this);'" If dimonds.CurrentAction = "gridadd" Then Call dimonds_list.LoadDefaultValues() ' Load default values Else Call dimonds_list.LoadRowValues(Rs) ' Load row values End If dimonds.RowType = EW_ROWTYPE_VIEW ' Render view ' Render row Call dimonds_list.RenderRow() %> > <% If dimonds.Carat_Weight.Visible Then ' Carat Weight %> >><%= dimonds.Carat_Weight.ListViewValue %> <% End If %> <% If dimonds.Cut.Visible Then ' Cut %> >>
<%= dimonds.Cut.ListViewValue %>
<% End If %> <% If dimonds.Color.Visible Then ' Color %> >>
<%= dimonds.Color.ListViewValue %>
<% End If %> <% If dimonds.Clarity.Visible Then ' Clarity %> >>
<%= dimonds.Clarity.ListViewValue %>
<% End If %> <% If dimonds.Certificate.Visible Then ' Certificate %> >>
<%= dimonds.Certificate.ListViewValue %>
<% End If %> <% If dimonds.Price.Visible Then ' Price %> >>
<%= dimonds.Price.ListViewValue %>
<% End If %> <% If dimonds.Depth.Visible Then ' Depth %> >>
<%= dimonds.Depth.ListViewValue %>
<% End If %> <% If dimonds.Table.Visible Then ' Table %> >>
<%= dimonds.Table.ListViewValue %>
<% End If %> <% If dimonds.Polish.Visible Then ' Polish %> >>
<%= dimonds.Polish.ListViewValue %>
<% End If %> <% If dimonds.Symmetry.Visible Then ' Symmetry %> >>
<%= dimonds.Symmetry.ListViewValue %>
<% End If %> <% If dimonds.Export = "" Then %>
<% ' Custom list options For i = 0 to dimonds_list.ListOptions.Items.Count -1 If dimonds_list.ListOptions.Items(i).Visible Then Response.Write dimonds_list.ListOptions.Items(i).BodyCellHtml Next %> <% End If %> <% End If If dimonds.CurrentAction <> "gridadd" Then Rs.MoveNext Loop %>
Carat Weight
Carat Weight (*) <% If dimonds.Carat_Weight.Sort = "ASC" Then %> <% ElseIf dimonds.Carat_Weight.Sort = "DESC" Then %> <% End If %>
Cut
Cut <% If dimonds.Cut.Sort = "ASC" Then %> <% ElseIf dimonds.Cut.Sort = "DESC" Then %> <% End If %>
Color
Color <% If dimonds.Color.Sort = "ASC" Then %> <% ElseIf dimonds.Color.Sort = "DESC" Then %> <% End If %>
Clarity
Clarity <% If dimonds.Clarity.Sort = "ASC" Then %> <% ElseIf dimonds.Clarity.Sort = "DESC" Then %> <% End If %>
Certificate
Certificate (*) <% If dimonds.Certificate.Sort = "ASC" Then %> <% ElseIf dimonds.Certificate.Sort = "DESC" Then %> <% End If %>
Price
Price (*) <% If dimonds.Price.Sort = "ASC" Then %> <% ElseIf dimonds.Price.Sort = "DESC" Then %> <% End If %>
Depth
Depth (*) <% If dimonds.Depth.Sort = "ASC" Then %> <% ElseIf dimonds.Depth.Sort = "DESC" Then %> <% End If %>
Table
Table (*) <% If dimonds.Table.Sort = "ASC" Then %> <% ElseIf dimonds.Table.Sort = "DESC" Then %> <% End If %>
Polish
Polish <% If dimonds.Polish.Sort = "ASC" Then %> <% ElseIf dimonds.Polish.Sort = "DESC" Then %> <% End If %>
Symmetry
Symmetry <% If dimonds.Symmetry.Sort = "ASC" Then %> <% ElseIf dimonds.Symmetry.Sort = "DESC" Then %> <% End If %>
 
<% End If %>
<% ' Close recordset and connection Rs.Close Set Rs = Nothing %>
<% If dimonds.Export = "" Then %>
<% If dimonds.CurrentAction <> "gridadd" And dimonds.CurrentAction <> "gridedit" Then %>

<% If dimonds_list.lTotalRecs > 0 Then %> <% End If %>
<% If Not IsObject(dimonds_list.Pager) Then Set dimonds_list.Pager = ew_NewNumericPager(dimonds_list.lStartRec, dimonds_list.lDisplayRecs, dimonds_list.lTotalRecs, dimonds_list.lRecRange) %> <% If dimonds_list.Pager.RecordCount > 0 Then %> <% If dimonds_list.Pager.FirstButton.Enabled Then %> First  <% End If %> <% If dimonds_list.Pager.PrevButton.Enabled Then %> Previous  <% End If %> <% For Each PagerItem In dimonds_list.Pager.Items %> <% If PagerItem.Enabled Then %><% End If %><%= PagerItem.Text %><% If PagerItem.Enabled Then %><% End If %>  <% Next %> <% If dimonds_list.Pager.NextButton.Enabled Then %> Next  <% End If %> <% If dimonds_list.Pager.LastButton.Enabled Then %> Last  <% End If %> <% If dimonds_list.Pager.ButtonCount > 0 Then %>    <% End If %> Records <%= dimonds_list.Pager.FromIndex %> to <%= dimonds_list.Pager.ToIndex %> of <%= dimonds_list.Pager.RecordCount %> <% Else %> <% If dimonds_list.sSrchWhere = "0=101" Then %> Please enter search criteria <% Else %> No records found <% End If %> <% End If %>     
   
<% End If %> <% 'If dimonds_list.lTotalRecs > 0 Then %> <% 'End If %>

<% End If %>

<% If dimonds.Export = "" And dimonds.CurrentAction = "" Then %> <% End If %> <% If dimonds.Export = "" Then %> <% End If %> <% ' Drop page object Set dimonds_list = Nothing %> <% ' ----------------------------------------------------------------- ' Page Class ' Class cdimonds_list ' Page ID Public Property Get PageID() PageID = "list" End Property ' Table Name Public Property Get TableName() TableName = "dimonds" End Property ' Page Object Name Public Property Get PageObjName() PageObjName = "dimonds_list" 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) & "
" & v Else Session(EW_SESSION_MESSAGE) = v End If End Property ' Show Message Public Sub ShowMessage() If Message <> "" Then ' Message in Session, display Response.Write "

" & 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 = "list" ' 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 ' Initialize list options Set ListOptions = New cListOptions End Sub ' ----------------------------------------------------------------- ' Subroutine Page_Init ' - called before page main ' - check Security ' - set up response header ' - call page load events ' Sub Page_Init() dimonds.Export = Request.QueryString("export") ' Get export parameter gsExport = dimonds.Export ' Get export parameter, used in header gsExportFile = dimonds.TableVar ' Get export file, used in header If dimonds.Export = "print" Or dimonds.Export = "html" Then ' Printer friendly / Export to html, no action required End If If dimonds.Export = "word" Then Response.ContentType = "application/vnd.ms-word" Response.AddHeader "Content-Disposition:", "attachment; filename=" & gsExportFile & ".doc" End If ' 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 Set ListOptions = Nothing ' Go to url if specified If url <> "" Then Response.Clear Response.Redirect url End If End Sub ' ' Subroutine Page_Terminate (End) ' ---------------------------------------- Dim lDisplayRecs ' Number of display records Dim lStartRec, lStopRec, lTotalRecs, lRecRange Dim sSrchWhere Dim lRecCnt Dim lEditRowCnt Dim lRowCnt, lRowIndex Dim lOptionCnt Dim lRecPerRow, lColCnt Dim sDeleteConfirmMsg ' Delete confirm message Dim sDbMasterFilter, sDbDetailFilter Dim bMasterRecordExists Dim ListOptions Dim sMultiSelectKey ' ----------------------------------------------------------------- ' Page main processing ' Sub Page_Main() lDisplayRecs = 20 lRecRange = 10 lRecCnt = 0 ' Record count ' Search filters Dim sSrchAdvanced, sSrchBasic, sFilter sSrchAdvanced = "" ' Advanced search filter sSrchBasic = "" ' Basic search filter sSrchWhere = "" ' Search where clause sFilter = "" ' Master/Detail sDbMasterFilter = "" ' Master filter sDbDetailFilter = "" ' Detail filter If IsPageRequest Then ' Validate request ' Set up records per page dynamically SetUpDisplayRecs() ' Handle reset command ResetCmd() ' Get search criteria for advanced search Call LoadSearchValues() ' Get search values If ValidateSearch() Then sSrchAdvanced = AdvancedSearchWhere() Else Message = gsSearchError End If ' Get basic search criteria If gsSearchError = "" Then sSrchBasic = BasicSearchWhere() End If ' Set Up Sorting Order SetUpSortOrder() End If ' End Validate Request ' Restore display records If dimonds.RecordsPerPage <> "" Then lDisplayRecs = dimonds.RecordsPerPage ' Restore from Session Else lDisplayRecs = 20 ' Load default End If ' Load Sorting Order LoadSortOrder() ' Build search criteria If sSrchAdvanced <> "" Then If sSrchWhere <> "" Then sSrchWhere = "(" & sSrchWhere & ") AND (" & sSrchAdvanced & ")" Else sSrchWhere = sSrchAdvanced End If End If If sSrchBasic <> "" Then If sSrchWhere <> "" Then sSrchWhere = "(" & sSrchWhere & ") AND (" & sSrchBasic & ")" Else sSrchWhere = sSrchBasic End If End If ' Call Recordset Searching event Call dimonds.Recordset_Searching(sSrchWhere) ' Save search criteria If sSrchWhere <> "" Then If sSrchBasic = "" Then Call ResetBasicSearchParms() If sSrchAdvanced = "" Then Call ResetAdvancedSearchParms() dimonds.SearchWhere = sSrchWhere ' Save to Session lStartRec = 1 ' Reset start record counter dimonds.StartRecordNumber = lStartRec Else Call RestoreSearchParms() End If ' Build filter sFilter = "" If sDbDetailFilter <> "" Then If sFilter <> "" Then sFilter = "(" & sFilter & ") AND (" & sDbDetailFilter & ")" Else sFilter = sDbDetailFilter End If End If If sSrchWhere <> "" Then If sFilter <> "" Then sFilter = "(" & sFilter & ") AND (" & sSrchWhere & ")" Else sFilter = sSrchWhere End If End If ' Set up filter in Session dimonds.SessionWhere = sFilter dimonds.CurrentFilter = "" ' Export Data only If dimonds.Export = "html" Or dimonds.Export = "csv" Or dimonds.Export = "word" Or dimonds.Export = "excel" Or dimonds.Export = "xml" Then Call ExportData() Call Page_Terminate("") ' Clean up Response.End ' Terminate response End If End Sub ' ----------------------------------------------------------------- ' Set up number of records displayed per page ' Sub SetUpDisplayRecs() Dim sWrk sWrk = Request.QueryString(EW_TABLE_REC_PER_PAGE) If sWrk <> "" Then If IsNumeric(sWrk) Then lDisplayRecs = CInt(sWrk) Else If LCase(sWrk) = "all" Then ' Display all records lDisplayRecs = -1 Else lDisplayRecs = 10 ' Non-numeric, load default End If End If dimonds.RecordsPerPage = lDisplayRecs ' Save to Session ' Reset start position lStartRec = 1 dimonds.StartRecordNumber = lStartRec End If End Sub ' ----------------------------------------------------------------- ' Return Advanced Search Where based on QueryString parameters ' Function AdvancedSearchWhere() Dim sWhere sWhere = "" ' Field Item No Call BuildSearchSql(sWhere, dimonds.Item_No, False) ' Field Date Added Call BuildSearchSql(sWhere, dimonds.Date_Added, False) ' Field Shape Call BuildSearchSql(sWhere, dimonds.Shape, False) ' Field Carat Weight Call BuildSearchSql(sWhere, dimonds.Carat_Weight, False) ' Field Cut Call BuildSearchSql(sWhere, dimonds.Cut, True) ' Field Color Call BuildSearchSql(sWhere, dimonds.Color, True) ' Field Clarity Call BuildSearchSql(sWhere, dimonds.Clarity, True) ' Field Certificate Call BuildSearchSql(sWhere, dimonds.Certificate, False) ' Field Price Call BuildSearchSql(sWhere, dimonds.Price, False) ' Field Depth Call BuildSearchSql(sWhere, dimonds.Depth, False) ' Field Table Call BuildSearchSql(sWhere, dimonds.Table, False) ' Field Polish Call BuildSearchSql(sWhere, dimonds.Polish, True) ' Field Symmetry Call BuildSearchSql(sWhere, dimonds.Symmetry, True) ' Field Girdle Call BuildSearchSql(sWhere, dimonds.Girdle, False) ' Field Culet Call BuildSearchSql(sWhere, dimonds.Culet, False) ' Field Fluorescence Call BuildSearchSql(sWhere, dimonds.Fluorescence, False) ' Field Measurements Call BuildSearchSql(sWhere, dimonds.Measurements, False) ' Field Crown Angle Call BuildSearchSql(sWhere, dimonds.Crown_Angle, False) ' Field Crown % Call BuildSearchSql(sWhere, dimonds.Crown_25, False) ' Field Pavilion Angle Call BuildSearchSql(sWhere, dimonds.Pavilion_Angle, False) ' Field Pavilion % Call BuildSearchSql(sWhere, dimonds.Pavilion_25, False) ' Field Slideshow Call BuildSearchSql(sWhere, dimonds.Slideshow, False) ' Field Ratio Call BuildSearchSql(sWhere, dimonds.Ratio, False) ' Field Description Call BuildSearchSql(sWhere, dimonds.Description, False) AdvancedSearchWhere = sWhere ' Set up search parm If AdvancedSearchWhere <> "" Then ' Field Item No Call SetSearchParm(dimonds.Item_No) ' Field Date Added Call SetSearchParm(dimonds.Date_Added) ' Field Shape Call SetSearchParm(dimonds.Shape) ' Field Carat Weight Call SetSearchParm(dimonds.Carat_Weight) ' Field Cut Call SetSearchParm(dimonds.Cut) ' Field Color Call SetSearchParm(dimonds.Color) ' Field Clarity Call SetSearchParm(dimonds.Clarity) ' Field Certificate Call SetSearchParm(dimonds.Certificate) ' Field Price Call SetSearchParm(dimonds.Price) ' Field Depth Call SetSearchParm(dimonds.Depth) ' Field Table Call SetSearchParm(dimonds.Table) ' Field Polish Call SetSearchParm(dimonds.Polish) ' Field Symmetry Call SetSearchParm(dimonds.Symmetry) ' Field Girdle Call SetSearchParm(dimonds.Girdle) ' Field Culet Call SetSearchParm(dimonds.Culet) ' Field Fluorescence Call SetSearchParm(dimonds.Fluorescence) ' Field Measurements Call SetSearchParm(dimonds.Measurements) ' Field Crown Angle Call SetSearchParm(dimonds.Crown_Angle) ' Field Crown % Call SetSearchParm(dimonds.Crown_25) ' Field Pavilion Angle Call SetSearchParm(dimonds.Pavilion_Angle) ' Field Pavilion % Call SetSearchParm(dimonds.Pavilion_25) ' Field Slideshow Call SetSearchParm(dimonds.Slideshow) ' Field Ratio Call SetSearchParm(dimonds.Ratio) ' Field Description Call SetSearchParm(dimonds.Description) End If End Function ' ----------------------------------------------------------------- ' Build search sql ' ' ----------------------------------------------------------------- ' Build search sql ' Sub BuildSearchSql(Where, Fld, MultiValue) Dim FldParm, FldVal, FldOpr, FldCond, FldVal2, FldOpr2 FldParm = Mid(Fld.FldVar, 3) FldVal = Request.QueryString("x_" & FldParm) FldOpr = Request.QueryString("z_" & FldParm) FldCond = Request.QueryString("v_" & FldParm) FldVal2 = Request.QueryString("y_" & FldParm) FldOpr2 = Request.QueryString("w_" & FldParm) Dim sWrk sWrk = "" FldOpr = UCase(Trim(FldOpr)) If (FldOpr = "") Then FldOpr = "=" FldOpr2 = UCase(Trim(FldOpr2)) If FldOpr2 = "" Then FldOpr2 = "=" If EW_SEARCH_MULTI_VALUE_OPTION = 1 Then MultiValue = False If FldOpr <> "LIKE" Then MultiValue = False If FldOpr2 <> "LIKE" And FldVal2 <> "" Then MultiValue = False If MultiValue Then Dim sWrk1, sWrk2 ' Field value 1 If FldVal <> "" Then sWrk1 = ew_GetMultiSearchSql(Fld, FldVal) Else sWrk1 = "" End If ' Field value 2 If FldVal2 <> "" And FldCond <> "" Then sWrk2 = ew_GetMultiSearchSql(Fld, FldVal2) Else sWrk2 = "" End If ' Build final SQL sWrk = sWrk1 If sWrk2 <> "" Then If sWrk <> "" Then sWrk = "(" & sWrk & ") " & FldCond & " (" & sWrk2 & ")" Else sWrk = sWrk2 End If End If Else FldVal = ConvertSearchValue(Fld, FldVal) FldVal2 = ConvertSearchValue(Fld, FldVal2) sWrk = ew_GetSearchSql(Fld, FldVal, FldOpr, FldCond, FldVal2, FldOpr2) End If If sWrk <> "" Then If Where <> "" Then Where = Where & " AND " Where = Where & "(" & sWrk & ")" End If End Sub ' ----------------------------------------------------------------- ' Set search parm ' Sub SetSearchParm(Fld) Dim FldParm FldParm = Mid(Fld.FldVar, 3) Call dimonds.SetAdvancedSearch("x_" & FldParm, Request.QueryString("x_" & FldParm)) Call dimonds.SetAdvancedSearch("z_" & FldParm, Request.QueryString("z_" & FldParm)) Call dimonds.SetAdvancedSearch("v_" & FldParm, Request.QueryString("v_" & FldParm)) Call dimonds.SetAdvancedSearch("y_" & FldParm, Request.QueryString("y_" & FldParm)) Call dimonds.SetAdvancedSearch("w_" & FldParm, Request.QueryString("w_" & FldParm)) End Sub ' ----------------------------------------------------------------- ' Convert search value ' Function ConvertSearchValue(Fld, FldVal) ConvertSearchValue = FldVal If Fld.FldDataType = EW_DATATYPE_BOOLEAN Then If FldVal <> "" Then ConvertSearchValue = ew_IIf(FldVal="1", "True", "False") ElseIf Fld.FldDataType = EW_DATATYPE_DATE Then If FldVal <> "" Then ConvertSearchValue = ew_UnFormatDateTime(FldVal, Fld.FldDateTimeFormat) End If End Function ' ----------------------------------------------------------------- ' Return Basic Search sql ' Function BasicSearchSQL(Keyword) Dim sKeyword sKeyword = ew_AdjustSql(Keyword) BasicSearchSQL = "" If IsNumeric(sKeyword) Then BasicSearchSQL = BasicSearchSQL & "[Item No] = " & sKeyword & " OR " BasicSearchSQL = BasicSearchSQL & "[Shape] LIKE '%" & sKeyword & "%' OR " If IsNumeric(sKeyword) Then BasicSearchSQL = BasicSearchSQL & "[Carat Weight] = " & sKeyword & " OR " BasicSearchSQL = BasicSearchSQL & "[Cut] LIKE '%" & sKeyword & "%' OR " BasicSearchSQL = BasicSearchSQL & "[Color] LIKE '%" & sKeyword & "%' OR " BasicSearchSQL = BasicSearchSQL & "[Clarity] LIKE '%" & sKeyword & "%' OR " BasicSearchSQL = BasicSearchSQL & "[Certificate] LIKE '%" & sKeyword & "%' OR " BasicSearchSQL = BasicSearchSQL & "[Certificate pic] LIKE '%" & sKeyword & "%' OR " If IsNumeric(sKeyword) Then BasicSearchSQL = BasicSearchSQL & "[Price] = " & sKeyword & " OR " BasicSearchSQL = BasicSearchSQL & "[Picture] LIKE '%" & sKeyword & "%' OR " If IsNumeric(sKeyword) Then BasicSearchSQL = BasicSearchSQL & "[Depth] = " & sKeyword & " OR " If IsNumeric(sKeyword) Then BasicSearchSQL = BasicSearchSQL & "[Table] = " & sKeyword & " OR " BasicSearchSQL = BasicSearchSQL & "[Polish] LIKE '%" & sKeyword & "%' OR " BasicSearchSQL = BasicSearchSQL & "[Symmetry] LIKE '%" & sKeyword & "%' OR " If Right(BasicSearchSQL, 4) = " OR " Then BasicSearchSQL = Left(BasicSearchSQL, Len(BasicSearchSQL)-4) End Function ' ----------------------------------------------------------------- ' Return Basic Search Where based on search keyword and type ' Function BasicSearchWhere() Dim sSearchStr, sSearchKeyword, sSearchType Dim sSearch, arKeyword, sKeyword sSearchStr = "" sSearchKeyword = Request.QueryString(EW_TABLE_BASIC_SEARCH) sSearchType = Request.QueryString(EW_TABLE_BASIC_SEARCH_TYPE) If sSearchKeyword <> "" Then sSearch = Trim(sSearchKeyword) If sSearchType <> "" Then While InStr(sSearch, " ") > 0 sSearch = Replace(sSearch, " ", " ") Wend arKeyword = Split(Trim(sSearch), " ") For Each sKeyword In arKeyword If sSearchStr <> "" Then sSearchStr = sSearchStr & " " & sSearchType & " " sSearchStr = sSearchStr & "(" & BasicSearchSQL(sKeyword) & ")" Next Else sSearchStr = BasicSearchSQL(sSearch) End If End If If sSearchKeyword <> "" then dimonds.BasicSearchKeyword = sSearchKeyword dimonds.BasicSearchType = sSearchType End If BasicSearchWhere = sSearchStr End Function ' ----------------------------------------------------------------- ' Clear all search parameters ' Sub ResetSearchParms() ' Clear search where sSrchWhere = "" dimonds.SearchWhere = sSrchWhere ' Clear basic search parameters Call ResetBasicSearchParms() ' Clear advanced search parameters Call ResetAdvancedSearchParms() End Sub ' ----------------------------------------------------------------- ' Clear all basic search parameters ' Sub ResetBasicSearchParms() ' Clear basic search parameters dimonds.BasicSearchKeyword = "" dimonds.BasicSearchType = "" End Sub ' ----------------------------------------------------------------- ' Clear all advanced search parameters ' Sub ResetAdvancedSearchParms() ' Clear advanced search parameters Call dimonds.SetAdvancedSearch("x_Item_No", "") Call dimonds.SetAdvancedSearch("x_Date_Added", "") Call dimonds.SetAdvancedSearch("x_Shape", "") Call dimonds.SetAdvancedSearch("x_Carat_Weight", "") Call dimonds.SetAdvancedSearch("y_Carat_Weight", "") Call dimonds.SetAdvancedSearch("x_Cut", "") Call dimonds.SetAdvancedSearch("x_Color", "") Call dimonds.SetAdvancedSearch("x_Clarity", "") Call dimonds.SetAdvancedSearch("x_Certificate", "") Call dimonds.SetAdvancedSearch("x_Price", "") Call dimonds.SetAdvancedSearch("y_Price", "") Call dimonds.SetAdvancedSearch("x_Depth", "") Call dimonds.SetAdvancedSearch("y_Depth", "") Call dimonds.SetAdvancedSearch("x_Table", "") Call dimonds.SetAdvancedSearch("y_Table", "") Call dimonds.SetAdvancedSearch("x_Polish", "") Call dimonds.SetAdvancedSearch("x_Symmetry", "") Call dimonds.SetAdvancedSearch("x_Girdle", "") Call dimonds.SetAdvancedSearch("x_Culet", "") Call dimonds.SetAdvancedSearch("x_Fluorescence", "") Call dimonds.SetAdvancedSearch("x_Measurements", "") Call dimonds.SetAdvancedSearch("x_Crown_Angle", "") Call dimonds.SetAdvancedSearch("x_Crown_25", "") Call dimonds.SetAdvancedSearch("x_Pavilion_Angle", "") Call dimonds.SetAdvancedSearch("x_Pavilion_25", "") Call dimonds.SetAdvancedSearch("x_Slideshow", "") Call dimonds.SetAdvancedSearch("x_Ratio", "") Call dimonds.SetAdvancedSearch("x_Description", "") End Sub ' ----------------------------------------------------------------- ' Restore all search parameters ' Sub RestoreSearchParms() sSrchWhere = dimonds.SearchWhere ' Restore advanced search settings If gsSearchError = "" Then Call RestoreAdvancedSearchParms() End If End Sub ' ----------------------------------------------------------------- ' Restore all advanced search parameters ' Sub RestoreAdvancedSearchParms() ' Restore advanced search parms dimonds.Item_No.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Item_No") dimonds.Date_Added.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Date_Added") dimonds.Shape.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Shape") dimonds.Carat_Weight.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Carat_Weight") dimonds.Carat_Weight.AdvancedSearch.SearchValue2 = dimonds.GetAdvancedSearch("y_Carat_Weight") dimonds.Cut.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Cut") dimonds.Color.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Color") dimonds.Clarity.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Clarity") dimonds.Certificate.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Certificate") dimonds.Price.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Price") dimonds.Price.AdvancedSearch.SearchValue2 = dimonds.GetAdvancedSearch("y_Price") dimonds.Depth.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Depth") dimonds.Depth.AdvancedSearch.SearchValue2 = dimonds.GetAdvancedSearch("y_Depth") dimonds.Table.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Table") dimonds.Table.AdvancedSearch.SearchValue2 = dimonds.GetAdvancedSearch("y_Table") dimonds.Polish.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Polish") dimonds.Symmetry.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Symmetry") dimonds.Girdle.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Girdle") dimonds.Culet.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Culet") dimonds.Fluorescence.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Fluorescence") dimonds.Measurements.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Measurements") dimonds.Crown_Angle.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Crown_Angle") dimonds.Crown_25.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Crown_25") dimonds.Pavilion_Angle.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Pavilion_Angle") dimonds.Pavilion_25.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Pavilion_25") dimonds.Slideshow.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Slideshow") dimonds.Ratio.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Ratio") dimonds.Description.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Description") End Sub ' ----------------------------------------------------------------- ' Set up Sort parameters based on Sort Links clicked ' Sub SetUpSortOrder() Dim sOrderBy Dim sSortField, sLastSort, sThisSort Dim bCtrl ' Check for an Order parameter If Request.QueryString("order").Count > 0 Then dimonds.CurrentOrder = Request.QueryString("order") dimonds.CurrentOrderType = Request.QueryString("ordertype") ' Field Shape Call dimonds.UpdateSort(dimonds.Item_No) ' Field Carat Weight Call dimonds.UpdateSort(dimonds.Carat_Weight) ' Field Cut Call dimonds.UpdateSort(dimonds.Cut) ' Field Color Call dimonds.UpdateSort(dimonds.Color) ' Field Clarity Call dimonds.UpdateSort(dimonds.Clarity) ' Field Certificate Call dimonds.UpdateSort(dimonds.Certificate) ' Field Price Call dimonds.UpdateSort(dimonds.Price) ' Field Depth Call dimonds.UpdateSort(dimonds.Depth) ' Field Table Call dimonds.UpdateSort(dimonds.Table) ' Field Polish Call dimonds.UpdateSort(dimonds.Polish) ' Field Symmetry Call dimonds.UpdateSort(dimonds.Symmetry) dimonds.StartRecordNumber = 1 ' Reset start position End If End Sub ' ----------------------------------------------------------------- ' Load Sort Order parameters ' Sub LoadSortOrder() Dim sOrderBy sOrderBy = dimonds.SessionOrderBy ' Get order by from Session If sOrderBy = "" Then If dimonds.SqlOrderBy <> "" Then sOrderBy = dimonds.SqlOrderBy dimonds.SessionOrderBy = sOrderBy End If End If End Sub ' ----------------------------------------------------------------- ' Reset command based on querystring parameter cmd= ' - RESET: reset search parameters ' - RESETALL: reset search & master/detail parameters ' - RESETSORT: reset sort parameters ' Sub ResetCmd() Dim sCmd ' Get reset cmd If Request.QueryString("cmd").Count > 0 Then sCmd = Request.QueryString("cmd") ' Reset search criteria If LCase(sCmd) = "reset" Or LCase(sCmd) = "resetall" Then Call ResetSearchParms() End If ' Reset Sort Criteria If LCase(sCmd) = "resetsort" Then Dim sOrderBy sOrderBy = "" dimonds.SessionOrderBy = sOrderBy dimonds.Item_No.Sort = "" dimonds.Carat_Weight.Sort = "" dimonds.Cut.Sort = "" dimonds.Color.Sort = "" dimonds.Clarity.Sort = "" dimonds.Certificate.Sort = "" dimonds.Price.Sort = "" dimonds.Depth.Sort = "" dimonds.Table.Sort = "" dimonds.Polish.Sort = "" dimonds.Symmetry.Sort = "" End If ' Reset start position lStartRec = 1 dimonds.StartRecordNumber = lStartRec End If End Sub Dim Pager ' ----------------------------------------------------------------- ' Set up Starting Record parameters based on Pager Navigation ' Sub SetUpStartRec() Dim nPageNo ' Exit if lDisplayRecs = 0 If lDisplayRecs = 0 Then Exit Sub If IsPageRequest Then ' Validate request ' Check for a START parameter If Request.QueryString(EW_TABLE_START_REC).Count > 0 Then lStartRec = Request.QueryString(EW_TABLE_START_REC) dimonds.StartRecordNumber = lStartRec ElseIf Request.QueryString(EW_TABLE_PAGE_NO).Count > 0 Then nPageNo = Request.QueryString(EW_TABLE_PAGE_NO) If IsNumeric(nPageNo) Then lStartRec = (nPageNo-1)*lDisplayRecs+1 If lStartRec <= 0 Then lStartRec = 1 ElseIf lStartRec >= ((lTotalRecs-1)\lDisplayRecs)*lDisplayRecs+1 Then lStartRec = ((lTotalRecs-1)\lDisplayRecs)*lDisplayRecs+1 End If dimonds.StartRecordNumber = lStartRec End If End If End If lStartRec = dimonds.StartRecordNumber ' Check if correct start record counter If Not IsNumeric(lStartRec) Or lStartRec = "" Then ' Avoid invalid start record counter lStartRec = 1 ' Reset start record counter dimonds.StartRecordNumber = lStartRec ElseIf CLng(lStartRec) > CLng(lTotalRecs) Then ' Avoid starting record > total records lStartRec = ((lTotalRecs-1)\lDisplayRecs)*lDisplayRecs+1 ' Point to last page first record dimonds.StartRecordNumber = lStartRec ElseIf (lStartRec-1) Mod lDisplayRecs <> 0 Then lStartRec = ((lStartRec-1)\lDisplayRecs)*lDisplayRecs+1 ' Point to page boundary dimonds.StartRecordNumber = lStartRec End If End Sub ' ----------------------------------------------------------------- ' Load search values for validation ' Function LoadSearchValues() ' Load search values dimonds.Shape.AdvancedSearch.SearchValue = Request.QueryString("x_Shape") dimonds.Carat_Weight.AdvancedSearch.SearchValue = Request.QueryString("x_Carat_Weight") dimonds.Carat_Weight.AdvancedSearch.SearchValue2 = Request.QueryString("y_Carat_Weight") dimonds.Cut.AdvancedSearch.SearchValue = Request.QueryString("x_Cut") dimonds.Color.AdvancedSearch.SearchValue = Request.QueryString("x_Color") dimonds.Clarity.AdvancedSearch.SearchValue = Request.QueryString("x_Clarity") dimonds.Price.AdvancedSearch.SearchValue = Request.QueryString("x_Price") dimonds.Price.AdvancedSearch.SearchValue2 = Request.QueryString("y_Price") dimonds.Depth.AdvancedSearch.SearchValue = Request.QueryString("x_Depth") dimonds.Depth.AdvancedSearch.SearchValue2 = Request.QueryString("y_Depth") dimonds.Table.AdvancedSearch.SearchValue = Request.QueryString("x_Table") dimonds.Table.AdvancedSearch.SearchValue2 = Request.QueryString("y_Table") dimonds.Polish.AdvancedSearch.SearchValue = Request.QueryString("x_Polish") dimonds.Symmetry.AdvancedSearch.SearchValue = Request.QueryString("x_Symmetry") End Function ' ----------------------------------------------------------------- ' Load recordset ' Function LoadRecordset() ' Call Recordset Selecting event Call dimonds.Recordset_Selecting(dimonds.CurrentFilter) ' Load list page sql Dim sSql sSql = dimonds.ListSQL If EW_DEBUG_ENABLED Then Response.Write sSql ' Show SQL for debugging ' Load recordset Dim RsRecordset Set RsRecordset = Server.CreateObject("ADODB.Recordset") RsRecordset.CursorLocation = EW_CURSORLOCATION RsRecordset.Open sSql, Conn, 1, 2 ' Call Recordset Selected event Call dimonds.Recordset_Selected(RsRecordset) Set LoadRecordset = RsRecordset End Function ' ----------------------------------------------------------------- ' Load row based on key values ' Function LoadRow() Dim RsRow, sSql, sFilter sFilter = dimonds.KeyFilter ' Call Row Selecting event Call dimonds.Row_Selecting(sFilter) ' Load sql based on filter dimonds.CurrentFilter = sFilter sSql = dimonds.SQL If EW_DEBUG_ENABLED Then Response.Write sSql ' Show SQL for debugging Set RsRow = Server.CreateObject("ADODB.Recordset") RsRow.Open sSql, Conn If RsRow.Eof Then LoadRow = False Else LoadRow = True RsRow.MoveFirst Call LoadRowValues(RsRow) ' Load row values ' Call Row Selected event Call dimonds.Row_Selected(RsRow) End If RsRow.Close Set RsRow = Nothing End Function ' ----------------------------------------------------------------- ' Load row values from recordset ' Sub LoadRowValues(RsRow) dimonds.Item_No.DbValue = RsRow("Item No") dimonds.Date_Added.DbValue = RsRow("Date Added") dimonds.Shape.DbValue = RsRow("Shape") dimonds.Carat_Weight.DbValue = RsRow("Carat Weight") dimonds.Cut.DbValue = RsRow("Cut") dimonds.Color.DbValue = RsRow("Color") dimonds.Clarity.DbValue = RsRow("Clarity") dimonds.Certificate.DbValue = RsRow("Certificate") dimonds.Certificate_pic.Upload.DbValue = RsRow("Certificate pic") dimonds.Price.DbValue = RsRow("Price") dimonds.Picture.Upload.DbValue = RsRow("Picture") dimonds.Depth.DbValue = RsRow("Depth") dimonds.Table.DbValue = RsRow("Table") dimonds.Polish.DbValue = RsRow("Polish") dimonds.Symmetry.DbValue = RsRow("Symmetry") dimonds.Girdle.DbValue = RsRow("Girdle") dimonds.Culet.DbValue = RsRow("Culet") dimonds.Fluorescence.DbValue = RsRow("Fluorescence") dimonds.Measurements.DbValue = RsRow("Measurements") dimonds.Crown_Angle.DbValue = RsRow("Crown Angle") dimonds.Crown_25.DbValue = RsRow("Crown %") dimonds.Pavilion_Angle.DbValue = RsRow("Pavilion Angle") dimonds.Pavilion_25.DbValue = RsRow("Pavilion %") dimonds.Slideshow.DbValue = ew_IIf(RsRow("Slideshow"), "1", "0") dimonds.Ratio.DbValue = RsRow("Ratio") dimonds.Description.DbValue = RsRow("Description") End Sub ' ----------------------------------------------------------------- ' Render row values based on field settings ' Sub RenderRow() ' Call Row Rendering event Call dimonds.Row_Rendering() ' --------------------------------------- ' Common render codes for all row types ' --------------------------------------- ' 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 = "" ' Price dimonds.Price.CellCssStyle = "" dimonds.Price.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 = "" ' ----------- ' 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 = "" ' 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 = "" ' 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 ' 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 = "" ' Price dimonds.Price.HrefValue = "" ' Depth dimonds.Depth.HrefValue = "" ' Table dimonds.Table.HrefValue = "" ' Polish dimonds.Polish.HrefValue = "" ' Symmetry dimonds.Symmetry.HrefValue = "" ' ------------ ' Search Row ' ------------ ElseIf dimonds.RowType = EW_ROWTYPE_SEARCH Then ' Search row ' 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) ' 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) ' 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 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_CheckNumber(dimonds.Carat_Weight.AdvancedSearch.SearchValue) Then If gsSearchError <> "" Then gsSearchError = gsSearchError & "
" gsSearchError = gsSearchError & "Incorrect floating point number - Carat Weight" End If If Not ew_CheckNumber(dimonds.Carat_Weight.AdvancedSearch.SearchValue2) Then If gsSearchError <> "" Then gsSearchError = gsSearchError & "
" gsSearchError = gsSearchError & "Incorrect floating point number - Carat Weight" End If If Not ew_CheckNumber(dimonds.Price.AdvancedSearch.SearchValue) Then If gsSearchError <> "" Then gsSearchError = gsSearchError & "
" gsSearchError = gsSearchError & "Incorrect floating point number - Price" End If If Not ew_CheckNumber(dimonds.Price.AdvancedSearch.SearchValue2) Then If gsSearchError <> "" Then gsSearchError = gsSearchError & "
" gsSearchError = gsSearchError & "Incorrect floating point number - Price" End If If Not ew_CheckNumber(dimonds.Depth.AdvancedSearch.SearchValue) Then If gsSearchError <> "" Then gsSearchError = gsSearchError & "
" gsSearchError = gsSearchError & "Incorrect floating point number - Depth" End If If Not ew_CheckNumber(dimonds.Depth.AdvancedSearch.SearchValue2) Then If gsSearchError <> "" Then gsSearchError = gsSearchError & "
" gsSearchError = gsSearchError & "Incorrect floating point number - Depth" End If If Not ew_CheckNumber(dimonds.Table.AdvancedSearch.SearchValue) Then If gsSearchError <> "" Then gsSearchError = gsSearchError & "
" gsSearchError = gsSearchError & "Incorrect floating point number - Table" End If If Not ew_CheckNumber(dimonds.Table.AdvancedSearch.SearchValue2) Then If gsSearchError <> "" Then gsSearchError = gsSearchError & "
" gsSearchError = gsSearchError & "Incorrect floating point number - Table" End If ' Return validate result ValidateSearch = (gsSearchError = "") ' Call Form Custom Validate event Dim sFormCustomError sFormCustomError = "" ValidateSearch = ValidateSearch And Form_CustomValidate(sFormCustomError) If sFormCustomError <> "" Then If gsSearchError <> "" Then gsSearchError = gsSearchError & "
" gsSearchError = gsSearchError & sFormCustomError End If End Function ' ----------------------------------------------------------------- ' Load advanced search ' Function LoadAdvancedSearch() dimonds.Shape.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Shape") dimonds.Carat_Weight.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Carat_Weight") dimonds.Carat_Weight.AdvancedSearch.SearchValue2 = dimonds.GetAdvancedSearch("y_Carat_Weight") dimonds.Cut.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Cut") dimonds.Color.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Color") dimonds.Clarity.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Clarity") dimonds.Price.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Price") dimonds.Price.AdvancedSearch.SearchValue2 = dimonds.GetAdvancedSearch("y_Price") dimonds.Depth.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Depth") dimonds.Depth.AdvancedSearch.SearchValue2 = dimonds.GetAdvancedSearch("y_Depth") dimonds.Table.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Table") dimonds.Table.AdvancedSearch.SearchValue2 = dimonds.GetAdvancedSearch("y_Table") dimonds.Polish.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Polish") dimonds.Symmetry.AdvancedSearch.SearchValue = dimonds.GetAdvancedSearch("x_Symmetry") End Function ' ----------------------------------------------------------------- ' Export data in HTML/CSV/Word/Excel/XML format ' Sub ExportData() Dim oXmlDoc, oXmlTbl, oXmlRec, oXmlFld Dim sExportStr, sExportValue, sExportStyle ' Default export style sExportStyle = "h" ' Load recordset Set Rs = LoadRecordset() lTotalRecs = Rs.RecordCount lStartRec = 1 ' Export all If dimonds.ExportAll Then lStopRec = lTotalRecs ' Export 1 page only Else SetUpStartRec() ' Set Up Start Record Position ' Set the last record to display If lDisplayRecs < 0 Then lStopRec = lTotalRecs Else lStopRec = lStartRec + lDisplayRecs - 1 End If End If If dimonds.Export = "xml" Then Set oXmlDoc = Server.CreateObject("MSXML.DOMDocument") Set oXmlTbl = oXmlDoc.createElement("table") Else Response.Write ew_ExportHeader(dimonds.Export) ' Horizontal format, write header If sExportStyle <> "v" Or dimonds.Export = "csv" Then sExportStr = "" Call ew_ExportAddValue(sExportStr, "Item No", dimonds.Export) Call ew_ExportAddValue(sExportStr, "Shape", dimonds.Export) Call ew_ExportAddValue(sExportStr, "Carat Weight", dimonds.Export) Call ew_ExportAddValue(sExportStr, "Cut", dimonds.Export) Call ew_ExportAddValue(sExportStr, "Color", dimonds.Export) Call ew_ExportAddValue(sExportStr, "Clarity", dimonds.Export) Call ew_ExportAddValue(sExportStr, "Certificate", dimonds.Export) Call ew_ExportAddValue(sExportStr, "Certificate pic", dimonds.Export) Call ew_ExportAddValue(sExportStr, "Price", dimonds.Export) Call ew_ExportAddValue(sExportStr, "Picture", dimonds.Export) Call ew_ExportAddValue(sExportStr, "Depth", dimonds.Export) Call ew_ExportAddValue(sExportStr, "Table", dimonds.Export) Call ew_ExportAddValue(sExportStr, "Polish", dimonds.Export) Call ew_ExportAddValue(sExportStr, "Symmetry", dimonds.Export) Call ew_ExportAddValue(sExportStr, "Girdle", dimonds.Export) Call ew_ExportAddValue(sExportStr, "Culet", dimonds.Export) Call ew_ExportAddValue(sExportStr, "Fluorescence", dimonds.Export) Call ew_ExportAddValue(sExportStr, "Measurements", dimonds.Export) Call ew_ExportAddValue(sExportStr, "Crown Angle", dimonds.Export) Call ew_ExportAddValue(sExportStr, "Crown %", dimonds.Export) Call ew_ExportAddValue(sExportStr, "Pavilion Angle", dimonds.Export) Call ew_ExportAddValue(sExportStr, "Pavilion %", dimonds.Export) Call ew_ExportAddValue(sExportStr, "Ratio", dimonds.Export) Call ew_ExportAddValue(sExportStr, "Description", dimonds.Export) Response.Write ew_ExportLine(sExportStr, dimonds.Export) End If End If ' Move to first record lRecCnt = lStartRec - 1 If Not Rs.Eof Then Rs.MoveFirst Rs.Move lStartRec - 1 End If Do While (Not Rs.Eof) And (lRecCnt < lStopRec) lRecCnt = lRecCnt + 1 If CLng(lRecCnt) >= CLng(lStartRec) Then Call LoadRowValues(Rs) ' Render row for display dimonds.RowType = EW_ROWTYPE_VIEW ' Render view Call RenderRow() If dimonds.Export = "xml" Then Set oXmlRec = oXmlDoc.createElement("record") Call oXmlTbl.appendChild(oXmlRec) ' Field Item No Set oXmlFld = oXmlDoc.createElement("Item_No") oXmlFld.Text = dimonds.Item_No.ExportValue(dimonds.Export, dimonds.ExportOriginalValue) Call oXmlRec.AppendChild(oXmlFld) ' Field Shape Set oXmlFld = oXmlDoc.createElement("Shape") oXmlFld.Text = dimonds.Shape.ExportValue(dimonds.Export, dimonds.ExportOriginalValue) Call oXmlRec.AppendChild(oXmlFld) ' Field Carat Weight Set oXmlFld = oXmlDoc.createElement("Carat_Weight") oXmlFld.Text = dimonds.Carat_Weight.ExportValue(dimonds.Export, dimonds.ExportOriginalValue) Call oXmlRec.AppendChild(oXmlFld) ' Field Cut Set oXmlFld = oXmlDoc.createElement("Cut") oXmlFld.Text = dimonds.Cut.ExportValue(dimonds.Export, dimonds.ExportOriginalValue) Call oXmlRec.AppendChild(oXmlFld) ' Field Color Set oXmlFld = oXmlDoc.createElement("Color") oXmlFld.Text = dimonds.Color.ExportValue(dimonds.Export, dimonds.ExportOriginalValue) Call oXmlRec.AppendChild(oXmlFld) ' Field Clarity Set oXmlFld = oXmlDoc.createElement("Clarity") oXmlFld.Text = dimonds.Clarity.ExportValue(dimonds.Export, dimonds.ExportOriginalValue) Call oXmlRec.AppendChild(oXmlFld) ' Field Certificate Set oXmlFld = oXmlDoc.createElement("Certificate") oXmlFld.Text = dimonds.Certificate.ExportValue(dimonds.Export, dimonds.ExportOriginalValue) Call oXmlRec.AppendChild(oXmlFld) ' Field Certificate pic Set oXmlFld = oXmlDoc.createElement("Certificate_pic") oXmlFld.Text = dimonds.Certificate_pic.ExportValue(dimonds.Export, dimonds.ExportOriginalValue) Call oXmlRec.AppendChild(oXmlFld) ' Field Price Set oXmlFld = oXmlDoc.createElement("Price") oXmlFld.Text = dimonds.Price.ExportValue(dimonds.Export, dimonds.ExportOriginalValue) Call oXmlRec.AppendChild(oXmlFld) ' Field Picture Set oXmlFld = oXmlDoc.createElement("Picture") oXmlFld.Text = dimonds.Picture.ExportValue(dimonds.Export, dimonds.ExportOriginalValue) Call oXmlRec.AppendChild(oXmlFld) ' Field Depth Set oXmlFld = oXmlDoc.createElement("Depth") oXmlFld.Text = dimonds.Depth.ExportValue(dimonds.Export, dimonds.ExportOriginalValue) Call oXmlRec.AppendChild(oXmlFld) ' Field Table Set oXmlFld = oXmlDoc.createElement("Table") oXmlFld.Text = dimonds.Table.ExportValue(dimonds.Export, dimonds.ExportOriginalValue) Call oXmlRec.AppendChild(oXmlFld) ' Field Polish Set oXmlFld = oXmlDoc.createElement("Polish") oXmlFld.Text = dimonds.Polish.ExportValue(dimonds.Export, dimonds.ExportOriginalValue) Call oXmlRec.AppendChild(oXmlFld) ' Field Symmetry Set oXmlFld = oXmlDoc.createElement("Symmetry") oXmlFld.Text = dimonds.Symmetry.ExportValue(dimonds.Export, dimonds.ExportOriginalValue) Call oXmlRec.AppendChild(oXmlFld) ' Field Girdle Set oXmlFld = oXmlDoc.createElement("Girdle") oXmlFld.Text = dimonds.Girdle.ExportValue(dimonds.Export, dimonds.ExportOriginalValue) Call oXmlRec.AppendChild(oXmlFld) ' Field Culet Set oXmlFld = oXmlDoc.createElement("Culet") oXmlFld.Text = dimonds.Culet.ExportValue(dimonds.Export, dimonds.ExportOriginalValue) Call oXmlRec.AppendChild(oXmlFld) ' Field Fluorescence Set oXmlFld = oXmlDoc.createElement("Fluorescence") oXmlFld.Text = dimonds.Fluorescence.ExportValue(dimonds.Export, dimonds.ExportOriginalValue) Call oXmlRec.AppendChild(oXmlFld) ' Field Measurements Set oXmlFld = oXmlDoc.createElement("Measurements") oXmlFld.Text = dimonds.Measurements.ExportValue(dimonds.Export, dimonds.ExportOriginalValue) Call oXmlRec.AppendChild(oXmlFld) ' Field Crown Angle Set oXmlFld = oXmlDoc.createElement("Crown_Angle") oXmlFld.Text = dimonds.Crown_Angle.ExportValue(dimonds.Export, dimonds.ExportOriginalValue) Call oXmlRec.AppendChild(oXmlFld) ' Field Crown % Set oXmlFld = oXmlDoc.createElement("Crown_25") oXmlFld.Text = dimonds.Crown_25.ExportValue(dimonds.Export, dimonds.ExportOriginalValue) Call oXmlRec.AppendChild(oXmlFld) ' Field Pavilion Angle Set oXmlFld = oXmlDoc.createElement("Pavilion_Angle") oXmlFld.Text = dimonds.Pavilion_Angle.ExportValue(dimonds.Export, dimonds.ExportOriginalValue) Call oXmlRec.AppendChild(oXmlFld) ' Field Pavilion % Set oXmlFld = oXmlDoc.createElement("Pavilion_25") oXmlFld.Text = dimonds.Pavilion_25.ExportValue(dimonds.Export, dimonds.ExportOriginalValue) Call oXmlRec.AppendChild(oXmlFld) ' Field Ratio Set oXmlFld = oXmlDoc.createElement("Ratio") oXmlFld.Text = dimonds.Ratio.ExportValue(dimonds.Export, dimonds.ExportOriginalValue) Call oXmlRec.AppendChild(oXmlFld) ' Field Description Set oXmlFld = oXmlDoc.createElement("Description") oXmlFld.Text = dimonds.Description.ExportValue(dimonds.Export, dimonds.ExportOriginalValue) Call oXmlRec.AppendChild(oXmlFld) Set oXmlRec = Nothing Else ' Vertical format If sExportStyle = "v" And dimonds.Export <> "csv" Then ' Field Item No Response.Write ew_ExportField("Item No", dimonds.Item_No.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Shape Response.Write ew_ExportField("Shape", dimonds.Shape.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Carat Weight Response.Write ew_ExportField("Carat Weight", dimonds.Carat_Weight.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Cut Response.Write ew_ExportField("Cut", dimonds.Cut.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Color Response.Write ew_ExportField("Color", dimonds.Color.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Clarity Response.Write ew_ExportField("Clarity", dimonds.Clarity.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Certificate Response.Write ew_ExportField("Certificate", dimonds.Certificate.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Certificate pic Response.Write ew_ExportField("Certificate pic", dimonds.Certificate_pic.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Price Response.Write ew_ExportField("Price", dimonds.Price.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Picture Response.Write ew_ExportField("Picture", dimonds.Picture.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Depth Response.Write ew_ExportField("Depth", dimonds.Depth.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Table Response.Write ew_ExportField("Table", dimonds.Table.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Polish Response.Write ew_ExportField("Polish", dimonds.Polish.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Symmetry Response.Write ew_ExportField("Symmetry", dimonds.Symmetry.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Girdle Response.Write ew_ExportField("Girdle", dimonds.Girdle.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Culet Response.Write ew_ExportField("Culet", dimonds.Culet.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Fluorescence Response.Write ew_ExportField("Fluorescence", dimonds.Fluorescence.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Measurements Response.Write ew_ExportField("Measurements", dimonds.Measurements.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Crown Angle Response.Write ew_ExportField("Crown Angle", dimonds.Crown_Angle.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Crown % Response.Write ew_ExportField("Crown %", dimonds.Crown_25.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Pavilion Angle Response.Write ew_ExportField("Pavilion Angle", dimonds.Pavilion_Angle.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Pavilion % Response.Write ew_ExportField("Pavilion %", dimonds.Pavilion_25.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Ratio Response.Write ew_ExportField("Ratio", dimonds.Ratio.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Description Response.Write ew_ExportField("Description", dimonds.Description.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Horizontal format Else sExportStr = "" ' Field Item No Call ew_ExportAddValue(sExportStr, dimonds.Item_No.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Shape Call ew_ExportAddValue(sExportStr, dimonds.Shape.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Carat Weight Call ew_ExportAddValue(sExportStr, dimonds.Carat_Weight.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Cut Call ew_ExportAddValue(sExportStr, dimonds.Cut.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Color Call ew_ExportAddValue(sExportStr, dimonds.Color.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Clarity Call ew_ExportAddValue(sExportStr, dimonds.Clarity.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Certificate Call ew_ExportAddValue(sExportStr, dimonds.Certificate.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Certificate pic Call ew_ExportAddValue(sExportStr, dimonds.Certificate_pic.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Price Call ew_ExportAddValue(sExportStr, dimonds.Price.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Picture Call ew_ExportAddValue(sExportStr, dimonds.Picture.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Depth Call ew_ExportAddValue(sExportStr, dimonds.Depth.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Table Call ew_ExportAddValue(sExportStr, dimonds.Table.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Polish Call ew_ExportAddValue(sExportStr, dimonds.Polish.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Symmetry Call ew_ExportAddValue(sExportStr, dimonds.Symmetry.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Girdle Call ew_ExportAddValue(sExportStr, dimonds.Girdle.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Culet Call ew_ExportAddValue(sExportStr, dimonds.Culet.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Fluorescence Call ew_ExportAddValue(sExportStr, dimonds.Fluorescence.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Measurements Call ew_ExportAddValue(sExportStr, dimonds.Measurements.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Crown Angle Call ew_ExportAddValue(sExportStr, dimonds.Crown_Angle.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Crown % Call ew_ExportAddValue(sExportStr, dimonds.Crown_25.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Pavilion Angle Call ew_ExportAddValue(sExportStr, dimonds.Pavilion_Angle.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Pavilion % Call ew_ExportAddValue(sExportStr, dimonds.Pavilion_25.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Ratio Call ew_ExportAddValue(sExportStr, dimonds.Ratio.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) ' Field Description Call ew_ExportAddValue(sExportStr, dimonds.Description.ExportValue(dimonds.Export, dimonds.ExportOriginalValue), dimonds.Export) Response.Write ew_ExportLine(sExportStr, dimonds.Export) End If End If End If Rs.MoveNext Loop ' Close recordset and connection Rs.Close Set Rs = Nothing If dimonds.Export = "xml" Then Response.Write "" & vbcrlf Response.Write oXmlTbl.xml Set oXmlTbl = Nothing Set oXmlDoc = Nothing Else Response.Write ew_ExportFooter(dimonds.Export) End If End Sub ' Page Load event Sub Page_Load() 'Response.Write "Page Load" End Sub ' Page Unload event Sub Page_Unload() 'Response.Write "Page Unload" End Sub ' Form Custom Validate event Function Form_CustomValidate(CustomError) 'Return error message in CustomError Form_CustomValidate = True End Function End Class %>