<%
Response.Buffer = EW_RESPONSE_BUFFER
%>
<!--#include file="ewcfg7.asp"-->
<!--#include file="websetinfo.asp"-->
<!--#include file="zlogininfo.asp"-->
<!--#include file="aspfn7.asp"-->
<!--#include file="userfn7.asp"-->
<% Session.Timeout = 900 %>
<%
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 webset_list
Set webset_list = New cwebset_list
Set Page = webset_list

' Page init processing
Call webset_list.Page_Init()

' Page main processing
Call webset_list.Page_Main()
%>
<!--#include file="header.asp"-->
<% If webset.Export = "" Then %>
<script type="text/javascript">
<!--
// Create page object
var webset_list = new ew_Page("webset_list");
// page properties
webset_list.PageID = "list"; // page ID
var EW_PAGE_ID = webset_list.PageID; // for backward compatibility
// extend page with Form_CustomValidate function
webset_list.Form_CustomValidate = 
 function(fobj) { // DO NOT CHANGE THIS LINE!
 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
webset_list.SelectAllKey = function(elem) {
	ew_SelectAll(elem);
}
<% If EW_CLIENT_VALIDATE Then %>
webset_list.ValidateRequired = true; // uses JavaScript validation
<% Else %>
webset_list.ValidateRequired = false; // no JavaScript validation
<% End If %>
//-->
</script>
<script type="text/javascript">
<!--
var ew_DHTMLEditors = [];
//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--
// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js"); 
//-->
</script>
<% End If %>
<% If webset.Export = "" Then %>
<% End If %>
<%

' Load recordset
Set Rs = webset_list.LoadRecordset()
	webset_list.lTotalRecs = Rs.RecordCount
	webset_list.lStartRec = 1
	If webset_list.lDisplayRecs <= 0 Then ' Display all records
		webset_list.lDisplayRecs = webset_list.lTotalRecs
	End If
	If Not (webset.ExportAll And webset.Export <> "") Then
		webset_list.SetUpStartRec() ' Set up start record position
	End If
%>
<p style='display:none'><span class="aspmaker" style="white-space: nowrap;">表: 站点信息
</span></p>
<% webset_list.ShowMessage %>
<br>
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<% If webset.Export = "" Then %>
<div class="ewGridUpperPanel">
<% If webset.CurrentAction <> "gridadd" And webset.CurrentAction <> "gridedit" Then %>
<form name="ewpagerform" id="ewpagerform" class="ewForm" action="<%= ew_CurrentPage %>">
<table border="0" cellspacing="0" cellpadding="0" class="ewPager">
	<tr>
		<td>
<% If Not IsObject(webset_list.Pager) Then Set webset_list.Pager = ew_NewPrevNextPager(webset_list.lStartRec, webset_list.lDisplayRecs, webset_list.lTotalRecs) %>
<% If webset_list.Pager.RecordCount > 0 Then %>
	<table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="aspmaker">页&nbsp;</span></td>
<!--first page button-->
	<% If webset_list.Pager.FirstButton.Enabled Then %>
	<td><a href="<%= webset_list.PageUrl %>start=<%= webset_list.Pager.FirstButton.Start %>"><img src="images/first.gif" alt="首页" width="16" height="16" border="0"></a></td>
	<% Else %>
	<td><img src="images/firstdisab.gif" alt="首页" width="16" height="16" border="0"></td>
	<% End If %>
<!--previous page button-->
	<% If webset_list.Pager.PrevButton.Enabled Then %>
	<td><a href="<%= webset_list.PageUrl %>start=<%= webset_list.Pager.PrevButton.Start %>"><img src="images/prev.gif" alt="上一页" width="16" height="16" border="0"></a></td>
	<% Else %>
	<td><img src="images/prevdisab.gif" alt="上一页" width="16" height="16" border="0"></td>
	<% End If %>
<!--current page number-->
	<td><input type="text" name="<%= EW_TABLE_PAGE_NO %>" id="<%= EW_TABLE_PAGE_NO %>" value="<%= webset_list.Pager.CurrentPage %>" size="4"></td>
<!--next page button-->
	<% If webset_list.Pager.NextButton.Enabled Then %>
	<td><a href="<%= webset_list.PageUrl %>start=<%= webset_list.Pager.NextButton.Start %>"><img src="images/next.gif" alt="下一页" width="16" height="16" border="0"></a></td>
	<% Else %>
	<td><img src="images/nextdisab.gif" alt="下一页" width="16" height="16" border="0"></td>
	<% End If %>
<!--last page button-->
	<% If webset_list.Pager.LastButton.Enabled Then %>
	<td><a href="<%= webset_list.PageUrl %>start=<%= webset_list.Pager.LastButton.Start %>"><img src="images/last.gif" alt="尾页" width="16" height="16" border="0"></a></td>	
	<% Else %>
	<td><img src="images/lastdisab.gif" alt="尾页" width="16" height="16" border="0"></td>
	<% End If %>
	<td><span class="aspmaker">&nbsp;的 <%= webset_list.Pager.PageCount %></span></td>
	</tr></table>
	</td>	
	<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
	<td>
	<span class="aspmaker">记录数 <%= webset_list.Pager.FromIndex %> 到 <%= webset_list.Pager.ToIndex %> 的 <%= webset_list.Pager.RecordCount %></span>
<% Else %>
	<% If Security.CanList Then %>
	<% If webset_list.sSrchWhere = "0=101" Then %>
	<span class="aspmaker">请输入查询条件</span>
	<% Else %>
	<span class="aspmaker">没有找到记录</span>
	<% End If %>
	<% Else %>
	<span class="aspmaker">你无权查看</span>
	<% End If %>
<% End If %>
		</td>
	</tr>
</table>
</form>
<% End If %>
<span class="aspmaker">
<% If Security.CanAdd Then %>
<a href="<%= webset.AddUrl %>">增加</a>&nbsp;&nbsp;
<% End If %>
<% If webset_list.lTotalRecs > 0 Then %>
<% If Security.CanDelete Then %>
<a href="" onclick="if (!ew_KeySelected(document.fwebsetlist)) alert('没有选择记录'); else {document.fwebsetlist.action='websetdelete.asp';document.fwebsetlist.encoding='application/x-www-form-urlencoded';document.fwebsetlist.submit();};return false;">删除所选记录</a>&nbsp;&nbsp;
<% End If %>
<% End If %>
</span>
</div>
<% End If %>
<div class="ewGridMiddlePanel">
<form name="fwebsetlist" id="fwebsetlist" class="ewForm" action="" method="post">
<% If webset_list.lTotalRecs > 0 Then %>
<table cellspacing="0" rowhighlightclass="ewTableHighlightRow" rowselectclass="ewTableSelectRow" roweditclass="ewTableEditRow" class="ewTable ewTableSeparate">
<%
	webset_list.lOptionCnt = 0
If Security.CanView Then
	webset_list.lOptionCnt = webset_list.lOptionCnt + 1 ' View
End If
If Security.CanEdit Then
	webset_list.lOptionCnt = webset_list.lOptionCnt + 1 ' Edit
End If
If Security.CanAdd Then
	webset_list.lOptionCnt = webset_list.lOptionCnt + 1 ' Copy
End If
If Security.CanDelete Then
	webset_list.lOptionCnt = webset_list.lOptionCnt + 1 ' Multi-select
End If
	webset_list.lOptionCnt = webset_list.lOptionCnt + webset_list.ListOptions.Items.Count ' Custom list options
%>
<%= webset.TableCustomInnerHTML %>
<thead><!-- Table header -->
	<tr class="ewTableHeader">
<% If webset.id.Visible Then ' id %>
	<% If webset.SortUrl(webset.id) = "" Then %>
		<td>编号</td>
	<% Else %>
		<td class="ewPointer" onmousedown="ew_Sort(event,'<%= webset.SortUrl(webset.id) %>',1);">
			<table cellspacing="0" class="ewTableHeaderBtn"><tr><td>编号</td><td style="width: 10px;"><% If webset.id.Sort = "ASC" Then %><img src="images/sortup.gif" width="10" height="9" border="0"><% ElseIf webset.id.Sort = "DESC" Then %><img src="images/sortdown.gif" width="10" height="9" border="0"><% End If %></td></tr></table>
		</td>
	<% End If %>
<% End If %>		
<% If webset.webname.Visible Then ' webname %>
	<% If webset.SortUrl(webset.webname) = "" Then %>
		<td>站点名称</td>
	<% Else %>
		<td class="ewPointer" onmousedown="ew_Sort(event,'<%= webset.SortUrl(webset.webname) %>',1);">
			<table cellspacing="0" class="ewTableHeaderBtn"><tr><td>站点名称</td><td style="width: 10px;"><% If webset.webname.Sort = "ASC" Then %><img src="images/sortup.gif" width="10" height="9" border="0"><% ElseIf webset.webname.Sort = "DESC" Then %><img src="images/sortdown.gif" width="10" height="9" border="0"><% End If %></td></tr></table>
		</td>
	<% End If %>
<% End If %>		
<% If webset.icp.Visible Then ' icp %>
	<% If webset.SortUrl(webset.icp) = "" Then %>
		<td>备案号</td>
	<% Else %>
		<td class="ewPointer" onmousedown="ew_Sort(event,'<%= webset.SortUrl(webset.icp) %>',1);">
			<table cellspacing="0" class="ewTableHeaderBtn"><tr><td>备案号</td><td style="width: 10px;"><% If webset.icp.Sort = "ASC" Then %><img src="images/sortup.gif" width="10" height="9" border="0"><% ElseIf webset.icp.Sort = "DESC" Then %><img src="images/sortdown.gif" width="10" height="9" border="0"><% End If %></td></tr></table>
		</td>
	<% End If %>
<% End If %>		
<% If webset.Export = "" Then %>
<% If Security.CanView Then %>
<td style="white-space: nowrap;">&nbsp;</td>
<% End If %>
<% If Security.CanEdit Then %>
<td style="white-space: nowrap;">&nbsp;</td>
<% End If %>
<% If Security.CanAdd Then %>
<td style="white-space: nowrap;">&nbsp;</td>
<% End If %>
<% If Security.CanDelete Then %>
<td style="white-space: nowrap;">
<input type="checkbox" name="key" id="key" class="aspmaker" onclick="webset_list.SelectAllKey(this);">
</td>
<% End If %>
<%

' Custom list options
For i = 0 to webset_list.ListOptions.Items.Count -1
	If webset_list.ListOptions.Items(i).Visible Then Response.Write webset_list.ListOptions.Items(i).HeaderCellHtml
Next
%>
<% End If %>
	</tr>
</thead>
<tbody><!-- Table body -->
<%
If (webset.ExportAll And webset.Export <> "") Then
	webset_list.lStopRec = webset_list.lTotalRecs
Else
	webset_list.lStopRec = webset_list.lStartRec + webset_list.lDisplayRecs - 1 ' Set the last record to display
End If

' Move to first record
webset_list.lRecCnt = webset_list.lStartRec - 1
If Not Rs.Eof Then
	Rs.MoveFirst
	If webset_list.lStartRec > 1 Then Rs.Move webset_list.lStartRec - 1
End If
webset_list.lRowCnt = 0

' Output date rows
Do While (Not Rs.Eof Or webset.CurrentAction = "gridadd") And (webset_list.lRecCnt < webset_list.lStopRec)
	webset_list.lRecCnt = webset_list.lRecCnt + 1
	If CLng(webset_list.lRecCnt) >= CLng(webset_list.lStartRec) Then
		webset_list.lRowCnt = webset_list.lRowCnt + 1
	webset.CssClass = ""
	webset.CssStyle = ""
	webset.RowClientEvents = "onmouseover='ew_MouseOver(event, this);' onmouseout='ew_MouseOut(event, this);' onclick='ew_Click(event, this);'"
	If webset.CurrentAction = "gridadd" Then
		Call webset_list.LoadDefaultValues() ' Load default values
	Else
		Call webset_list.LoadRowValues(Rs) ' Load row values
	End If
	webset.RowType = EW_ROWTYPE_VIEW ' Render view

	' Render row
	Call webset_list.RenderRow()
%>
	<tr<%= webset.RowAttributes %>>
	<% If webset.id.Visible Then ' id %>
		<td<%= webset.id.CellAttributes %>>
<div<%= webset.id.ViewAttributes %>><%= webset.id.ListViewValue %></div>
</td>
	<% End If %>
	<% If webset.webname.Visible Then ' webname %>
		<td<%= webset.webname.CellAttributes %>>
<div<%= webset.webname.ViewAttributes %>><%= webset.webname.ListViewValue %></div>
</td>
	<% End If %>
	<% If webset.icp.Visible Then ' icp %>
		<td<%= webset.icp.CellAttributes %>>
<div<%= webset.icp.ViewAttributes %>><%= webset.icp.ListViewValue %></div>
</td>
	<% End If %>
<% If webset.Export = "" Then %>
<% If Security.CanView Then %>
<td style="white-space: nowrap;"><span class="aspmaker">
<a href="<%= webset.ViewUrl %>">查看</a>
</span></td>
<% End If %>
<% If Security.CanEdit Then %>
<td style="white-space: nowrap;"><span class="aspmaker">
<a href="<%= webset.EditUrl %>">编辑</a>
</span></td>
<% End If %>
<% If Security.CanAdd Then %>
<td style="white-space: nowrap;"><span class="aspmaker">
<a href="<%= webset.CopyUrl %>">复制</a>
</span></td>
<% End If %>
<% If Security.CanDelete Then %>
<td style="white-space: nowrap;"><span class="aspmaker">
<input type="checkbox" name="key_m" id="key_m" value="<%= Server.HtmlEncode(webset.id.CurrentValue) %>" class="aspmaker" onclick='ew_ClickMultiCheckbox(this);'>
</span></td>
<% End If %>
<%

' Custom list options
For i = 0 to webset_list.ListOptions.Items.Count -1
	If webset_list.ListOptions.Items(i).Visible Then Response.Write webset_list.ListOptions.Items(i).BodyCellHtml
Next
%>
<% End If %>
	</tr>
<%
	End If
	If webset.CurrentAction <> "gridadd" Then Rs.MoveNext
Loop
%>
</tbody>
</table>
<% End If %>
</form>
<%

' Close recordset and connection
Rs.Close
Set Rs = Nothing
%>
</div>
<% If webset_list.lTotalRecs > 0 Then %>
<% If webset.Export = "" Then %>
<div class="ewGridLowerPanel">
<% If webset.CurrentAction <> "gridadd" And webset.CurrentAction <> "gridedit" Then %>
<form name="ewpagerform" id="ewpagerform" class="ewForm" action="<%= ew_CurrentPage %>">
<table border="0" cellspacing="0" cellpadding="0" class="ewPager">
	<tr>
		<td>
<% If Not IsObject(webset_list.Pager) Then Set webset_list.Pager = ew_NewPrevNextPager(webset_list.lStartRec, webset_list.lDisplayRecs, webset_list.lTotalRecs) %>
<% If webset_list.Pager.RecordCount > 0 Then %>
	<table border="0" cellspacing="0" cellpadding="0"><tr><td><span class="aspmaker">页&nbsp;</span></td>
<!--first page button-->
	<% If webset_list.Pager.FirstButton.Enabled Then %>
	<td><a href="<%= webset_list.PageUrl %>start=<%= webset_list.Pager.FirstButton.Start %>"><img src="images/first.gif" alt="首页" width="16" height="16" border="0"></a></td>
	<% Else %>
	<td><img src="images/firstdisab.gif" alt="首页" width="16" height="16" border="0"></td>
	<% End If %>
<!--previous page button-->
	<% If webset_list.Pager.PrevButton.Enabled Then %>
	<td><a href="<%= webset_list.PageUrl %>start=<%= webset_list.Pager.PrevButton.Start %>"><img src="images/prev.gif" alt="上一页" width="16" height="16" border="0"></a></td>
	<% Else %>
	<td><img src="images/prevdisab.gif" alt="上一页" width="16" height="16" border="0"></td>
	<% End If %>
<!--current page number-->
	<td><input type="text" name="<%= EW_TABLE_PAGE_NO %>" id="<%= EW_TABLE_PAGE_NO %>" value="<%= webset_list.Pager.CurrentPage %>" size="4"></td>
<!--next page button-->
	<% If webset_list.Pager.NextButton.Enabled Then %>
	<td><a href="<%= webset_list.PageUrl %>start=<%= webset_list.Pager.NextButton.Start %>"><img src="images/next.gif" alt="下一页" width="16" height="16" border="0"></a></td>
	<% Else %>
	<td><img src="images/nextdisab.gif" alt="下一页" width="16" height="16" border="0"></td>
	<% End If %>
<!--last page button-->
	<% If webset_list.Pager.LastButton.Enabled Then %>
	<td><a href="<%= webset_list.PageUrl %>start=<%= webset_list.Pager.LastButton.Start %>"><img src="images/last.gif" alt="尾页" width="16" height="16" border="0"></a></td>	
	<% Else %>
	<td><img src="images/lastdisab.gif" alt="尾页" width="16" height="16" border="0"></td>
	<% End If %>
	<td><span class="aspmaker">&nbsp;的 <%= webset_list.Pager.PageCount %></span></td>
	</tr></table>
	</td>	
	<td>&nbsp;&nbsp;&nbsp;&nbsp;</td>
	<td>
	<span class="aspmaker">记录数 <%= webset_list.Pager.FromIndex %> 到 <%= webset_list.Pager.ToIndex %> 的 <%= webset_list.Pager.RecordCount %></span>
<% Else %>
	<% If Security.CanList Then %>
	<% If webset_list.sSrchWhere = "0=101" Then %>
	<span class="aspmaker">请输入查询条件</span>
	<% Else %>
	<span class="aspmaker">没有找到记录</span>
	<% End If %>
	<% Else %>
	<span class="aspmaker">你无权查看</span>
	<% End If %>
<% End If %>
		</td>
	</tr>
</table>
</form>
<% End If %>
<% 'If webset_list.lTotalRecs > 0 Then %>
<span class="aspmaker">
<% If Security.CanAdd Then %>
<a href="<%= webset.AddUrl %>">增加</a>&nbsp;&nbsp;
<% End If %>
<% If webset_list.lTotalRecs > 0 Then %>
<% If Security.CanDelete Then %>
<a href="" onclick="if (!ew_KeySelected(document.fwebsetlist)) alert('没有选择记录'); else {document.fwebsetlist.action='websetdelete.asp';document.fwebsetlist.encoding='application/x-www-form-urlencoded';document.fwebsetlist.submit();};return false;">删除所选记录</a>&nbsp;&nbsp;
<% End If %>
<% End If %>
</span>
<% 'End If %>
</div>
<% End If %>
<% End If %>
</td></tr></table>
<% If webset.Export = "" And webset.CurrentAction = "" Then %>
<script type="text/javascript">
<!--
//ew_ToggleSearchPanel(webset_list); // uncomment to init search panel as collapsed
//-->
</script>
<% End If %>
<% If webset.Export = "" Then %>
<script language="JavaScript" type="text/javascript">
<!--
// Write your table-specific startup script here
// document.write("page loaded");
//-->
</script>
<% End If %>
<!--#include file="footer.asp"-->
<%

' Drop page object
Set webset_list = Nothing
%>
<%

' -----------------------------------------------------------------
' Page Class
'
Class cwebset_list

	' Page ID
	Public Property Get PageID()
		PageID = "list"
	End Property

	' Table Name
	Public Property Get TableName()
		TableName = "webset"
	End Property

	' Page Object Name
	Public Property Get PageObjName()
		PageObjName = "webset_list"
	End Property

	' Page Name
	Public Property Get PageName()
		PageName = ew_CurrentPage()
	End Property

	' Page Url
	Public Property Get PageUrl()
		PageUrl = ew_CurrentPage() & "?"
		If webset.UseTokenInUrl Then PageUrl = PageUrl & "t=" & webset.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) & "<br>" & 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 "<p><span class=""ewMessage"">" & Message & "</span></p>"
			Session(EW_SESSION_MESSAGE) = "" ' Clear message in Session
		End If
	End Sub

	' -----------------------
	'  Validate Page request
	'
	Public Function IsPageRequest()
		If webset.UseTokenInUrl Then
			IsPageRequest = False
			If Not (ObjForm Is Nothing) Then
				IsPageRequest = (webset.TableVar = ObjForm.GetValue("t"))
			End If
			If Request.QueryString("t").Count > 0 Then
				IsPageRequest = (webset.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 webset = New cwebset

		' Initialize other table object
		Set zlogin = New czlogin

		' 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 = "webset"

		' 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()
		Set Security = New cAdvancedSecurity
		If Not Security.IsLoggedIn() Then Call Security.AutoLogin()
		If Not Security.IsLoggedIn() Then
			Call Security.SaveLastUrl()
			Call Page_Terminate("login.asp")
		End If

		' Table Permission loading event
		Call Security.TablePermission_Loading()
		Call Security.LoadCurrentUserLevel(TableName)

		' Table Permission loaded event
		Call Security.TablePermission_Loaded()
		If Not Security.CanList Then
			Call Security.SaveLastUrl()
			Call Page_Terminate("login.asp")
		End If
		webset.Export = Request.QueryString("export") ' Get export parameter
		gsExport = webset.Export ' Get export parameter, used in header
		gsExportFile = webset.TableVar ' Get export file, used in header

		' 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 Security = Nothing
		Set webset = 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

			' Handle reset command
			ResetCmd()

			' Set Up Sorting Order
			SetUpSortOrder()
		End If ' End Validate Request

		' Restore display records
		If webset.RecordsPerPage <> "" Then
			lDisplayRecs = webset.RecordsPerPage ' Restore from Session
		Else
			lDisplayRecs = 20 ' Load default
		End If

		' Load Sorting Order
		LoadSortOrder()

		' Build filter
		sFilter = ""
		If Not Security.CanList Then
			sFilter = "(0=1)" ' Filter all records
		End If
		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
		webset.SessionWhere = sFilter
		webset.CurrentFilter = ""
	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
			webset.CurrentOrder = Request.QueryString("order")
			webset.CurrentOrderType = Request.QueryString("ordertype")

			' Field id
			Call webset.UpdateSort(webset.id)

			' Field webname
			Call webset.UpdateSort(webset.webname)

			' Field icp
			Call webset.UpdateSort(webset.icp)
			webset.StartRecordNumber = 1 ' Reset start position
		End If
	End Sub

	' -----------------------------------------------------------------
	' Load Sort Order parameters
	'
	Sub LoadSortOrder()
		Dim sOrderBy
		sOrderBy = webset.SessionOrderBy ' Get order by from Session
		If sOrderBy = "" Then
			If webset.SqlOrderBy <> "" Then
				sOrderBy = webset.SqlOrderBy
				webset.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 Sort Criteria
			If LCase(sCmd) = "resetsort" Then
				Dim sOrderBy
				sOrderBy = ""
				webset.SessionOrderBy = sOrderBy
				webset.id.Sort = ""
				webset.webname.Sort = ""
				webset.icp.Sort = ""
			End If

			' Reset start position
			lStartRec = 1
			webset.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)
				webset.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
					webset.StartRecordNumber = lStartRec
				End If
			End If
		End If
		lStartRec = webset.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
			webset.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
			webset.StartRecordNumber = lStartRec
		ElseIf (lStartRec-1) Mod lDisplayRecs <> 0 Then
			lStartRec = ((lStartRec-1)\lDisplayRecs)*lDisplayRecs+1 ' Point to page boundary
			webset.StartRecordNumber = lStartRec
		End If
	End Sub

	' -----------------------------------------------------------------
	' Load recordset
	'
	Function LoadRecordset()

		' Call Recordset Selecting event
		Call webset.Recordset_Selecting(webset.CurrentFilter)

		' Load list page sql
		Dim sSql
		sSql = webset.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 webset.Recordset_Selected(RsRecordset)
		Set LoadRecordset = RsRecordset
	End Function

	' -----------------------------------------------------------------
	' Load row based on key values
	'
	Function LoadRow()
		Dim RsRow, sSql, sFilter
		sFilter = webset.KeyFilter

		' Call Row Selecting event
		Call webset.Row_Selecting(sFilter)

		' Load sql based on filter
		webset.CurrentFilter = sFilter
		sSql = webset.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 webset.Row_Selected(RsRow)
		End If
		RsRow.Close
		Set RsRow = Nothing
	End Function

	' -----------------------------------------------------------------
	' Load row values from recordset
	'
	Sub LoadRowValues(RsRow)
		webset.id.DbValue = RsRow("id")
		webset.webname.DbValue = RsRow("webname")
		webset.icp.DbValue = RsRow("icp")
		webset.tongji.DbValue = RsRow("tongji")
	End Sub

	' -----------------------------------------------------------------
	' Render row values based on field settings
	'
	Sub RenderRow()

		' Call Row Rendering event
		Call webset.Row_Rendering()

		' ---------------------------------------
		'  Common render codes for all row types
		' ---------------------------------------
		' id

		webset.id.CellCssStyle = ""
		webset.id.CellCssClass = ""

		' webname
		webset.webname.CellCssStyle = ""
		webset.webname.CellCssClass = ""

		' icp
		webset.icp.CellCssStyle = ""
		webset.icp.CellCssClass = ""

		' -----------
		'  View  Row
		' -----------

		If webset.RowType = EW_ROWTYPE_VIEW Then ' View row

			' id
			webset.id.ViewValue = webset.id.CurrentValue
			webset.id.CssStyle = ""
			webset.id.CssClass = ""
			webset.id.ViewCustomAttributes = ""

			' webname
			webset.webname.ViewValue = webset.webname.CurrentValue
			webset.webname.CssStyle = ""
			webset.webname.CssClass = ""
			webset.webname.ViewCustomAttributes = ""

			' icp
			webset.icp.ViewValue = webset.icp.CurrentValue
			webset.icp.CssStyle = ""
			webset.icp.CssClass = ""
			webset.icp.ViewCustomAttributes = ""

			' View refer script
			' id

			webset.id.HrefValue = ""

			' webname
			webset.webname.HrefValue = ""

			' icp
			webset.icp.HrefValue = ""
		End If

		' Call Row Rendered event
		Call webset.Row_Rendered()
	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
%>
