<%
Response.Buffer = EW_RESPONSE_BUFFER
%>
<!--#include file="ewcfg7.asp"-->
<!--#include file="sjlminfo.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 sjlm_edit
Set sjlm_edit = New csjlm_edit
Set Page = sjlm_edit

' Page init processing
Call sjlm_edit.Page_Init()

' Page main processing
Call sjlm_edit.Page_Main()
%>
<!--#include file="header.asp"-->
<script type="text/javascript">
<!--
// Create page object
var sjlm_edit = new ew_Page("sjlm_edit");
// page properties
sjlm_edit.PageID = "edit"; // page ID
var EW_PAGE_ID = sjlm_edit.PageID; // for backward compatibility
// extend page with ValidateForm function
sjlm_edit.ValidateForm = function(fobj) {
	if (!this.ValidateRequired)
		return true; // ignore validation
	if (fobj.a_confirm && fobj.a_confirm.value == "F")
		return true;
	var i, elm, aelm, infix;
	var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
	for (i=0; i<rowcnt; i++) {
		infix = (fobj.key_count) ? String(i+1) : "";
		elm = fobj.elements["x" + infix + "_id"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "无效的整数型 - 编号");
		elm = fobj.elements["x" + infix + "_px"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "无效的整数型 - 排序");
		// Call Form Custom Validate event
		if (!this.Form_CustomValidate(fobj)) return false;
	}
	return true;
}
// extend page with Form_CustomValidate function
sjlm_edit.Form_CustomValidate = 
 function(fobj) { // DO NOT CHANGE THIS LINE!
 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
sjlm_edit.SelectAllKey = function(elem) {
	ew_SelectAll(elem);
}
<% If EW_CLIENT_VALIDATE Then %>
sjlm_edit.ValidateRequired = true; // uses JavaScript validation
<% Else %>
sjlm_edit.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>
<p><span class="aspmaker">编辑 表: Sjlm<br><br>
<a href="<%= sjlm.ReturnUrl %>">返回</a></span></p>
<% sjlm_edit.ShowMessage %>
<form name="fsjlmedit" id="fsjlmedit" action="<%= ew_CurrentPage %>" method="post" onsubmit="return sjlm_edit.ValidateForm(this);">
<p>
<input type="hidden" name="a_table" id="a_table" value="sjlm">
<input type="hidden" name="a_edit" id="a_edit" value="U">
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable">
<% If sjlm.id.Visible Then ' id %>
	<tr<%= sjlm.id.RowAttributes %>>
		<td class="ewTableHeader">编号</td>
		<td<%= sjlm.id.CellAttributes %>><span id="el_id">
<div<%= sjlm.id.ViewAttributes %>><%= sjlm.id.EditValue %></div>
<input type="hidden" name="x_id" id="x_id" value="<%= Server.HTMLEncode(sjlm.id.CurrentValue&"") %>">
</span><%= sjlm.id.CustomMsg %></td>
	</tr>
<% End If %>
<% If sjlm.bh.Visible Then ' bh %>
	<tr<%= sjlm.bh.RowAttributes %>>
		<td class="ewTableHeader">一级栏目</td>
		<td<%= sjlm.bh.CellAttributes %>><span id="el_bh">
<select id="x_bh" name="x_bh" onchange="ew_UpdateOpt('x_lmid','x_bh',sjlm_edit.ar_x_lmid);"<%= sjlm.bh.EditAttributes %>>
<%
emptywrk = True
If IsArray(sjlm.bh.EditValue) Then
	arwrk = sjlm.bh.EditValue
	For rowcntwrk = 0 To UBound(arwrk, 2)
		If arwrk(0, rowcntwrk)&"" = sjlm.bh.CurrentValue&"" Then
			selwrk = " selected=""selected"""
			emptywrk = False
		Else
			selwrk = ""
		End If
%>
<option value="<%= Server.HtmlEncode(arwrk(0, rowcntwrk)&"") %>"<%= selwrk %>>
<%= arwrk(1, rowcntwrk) %>
</option>
<%
	Next
End If
%>
</select>
</span><%= sjlm.bh.CustomMsg %></td>
	</tr>
<% End If %>
<% If sjlm.lmid.Visible Then ' lmid %>
	<tr<%= sjlm.lmid.RowAttributes %>>
		<td class="ewTableHeader">二级栏目</td>
		<td<%= sjlm.lmid.CellAttributes %>><span id="el_lmid">
<select id="x_lmid" name="x_lmid"<%= sjlm.lmid.EditAttributes %>>
<%
emptywrk = True
If IsArray(sjlm.lmid.EditValue) Then
	arwrk = sjlm.lmid.EditValue
	For rowcntwrk = 0 To UBound(arwrk, 2)
		If arwrk(0, rowcntwrk)&"" = sjlm.lmid.CurrentValue&"" Then
			selwrk = " selected=""selected"""
			emptywrk = False
		Else
			selwrk = ""
		End If
%>
<option value="<%= Server.HtmlEncode(arwrk(0, rowcntwrk)&"") %>"<%= selwrk %>>
<%= arwrk(1, rowcntwrk) %>
</option>
<%
	Next
End If
%>
</select>
<%
jswrk = "" ' Initialise
If IsArray(sjlm.lmid.EditValue) Then
	arwrk = sjlm.lmid.EditValue
	For rowcntwrk = 1 To UBound(arwrk, 2)
		If jswrk <> "" Then jswrk = jswrk & ","
		jswrk = jswrk & "['" & ew_JsEncode(arwrk(0, rowcntwrk)) & "'," ' Value
		jswrk = jswrk & "'" & ew_JsEncode(arwrk(1, rowcntwrk)) & "'," ' Display field 1
		jswrk = jswrk & "'" & ew_JsEncode(arwrk(2, rowcntwrk)) & "'," ' Display field 2
		jswrk = jswrk & "'" & ew_JsEncode(arwrk(3, rowcntwrk)) & "']" ' Filter field
	Next
End If
%>
<script type="text/javascript">
<!--
sjlm_edit.ar_x_lmid = [<%= jswrk %>];
//-->
</script>
</span><%= sjlm.lmid.CustomMsg %></td>
	</tr>
<% End If %>
<% If sjlm.sjmc.Visible Then ' sjmc %>
	<tr<%= sjlm.sjmc.RowAttributes %>>
		<td class="ewTableHeader">栏目名称</td>
		<td<%= sjlm.sjmc.CellAttributes %>><span id="el_sjmc">
<input type="text" name="x_sjmc" id="x_sjmc" size="30" maxlength="50" value="<%= sjlm.sjmc.EditValue %>"<%= sjlm.sjmc.EditAttributes %>>
</span><%= sjlm.sjmc.CustomMsg %></td>
	</tr>
<% End If %>
<% If sjlm.px.Visible Then ' px %>
	<tr<%= sjlm.px.RowAttributes %>>
		<td class="ewTableHeader">排序</td>
		<td<%= sjlm.px.CellAttributes %>><span id="el_px">
<input type="text" name="x_px" id="x_px" size="30" value="<%= sjlm.px.EditValue %>"<%= sjlm.px.EditAttributes %>>
</span><%= sjlm.px.CustomMsg %></td>
	</tr>
<% End If %>
<% If sjlm.urllb.Visible Then ' urllb %>
	<tr<%= sjlm.urllb.RowAttributes %>>
		<td class="ewTableHeader">展示类别</td>
		<td<%= sjlm.urllb.CellAttributes %>><span id="el_urllb">
<div id="tp_x_urllb" class="<%= EW_ITEM_TEMPLATE_CLASSNAME %>"><input type="radio" name="x_urllb" id="x_urllb" value="{value}"<%= sjlm.urllb.EditAttributes %>></div>
<div id="dsl_x_urllb" repeatcolumn="5">
<%
emptywrk = True
arwrk = sjlm.urllb.EditValue
If IsArray(arwrk) Then
	rowswrk = UBound(arwrk, 2)	
	For rowcntwrk = 0 To rowswrk
		If sjlm.urllb.CurrentValue&"" = arwrk(0, rowcntwrk)&"" Then
			selwrk = " checked=""checked"""
			emptywrk = False
		Else
			selwrk = ""
		End If

		' Note: No spacing within the LABEL tag
%>
<%= ew_RepeatColumnTable(rowswrk, rowcntwrk, 5, 1) %>
<label><input type="radio" name="x_urllb" id="x_urllb" value="<%= Server.HtmlEncode(arwrk(0, rowcntwrk)&"") %>"<%= selwrk %><%= sjlm.urllb.EditAttributes %>><%= arwrk(1, rowcntwrk) %></label>
<%= ew_RepeatColumnTable(rowswrk, rowcntwrk, 5, 2) %>
<%
	Next
End If
%>
</div>
</span><%= sjlm.urllb.CustomMsg %></td>
	</tr>
<% End If %>
</table>
</div>
</td></tr></table>
<p>
<input type="submit" name="btnAction" id="btnAction" value="    编辑    ">
</form>
<script language="JavaScript">
<!--
ew_UpdateOpts([['x_lmid','x_bh',sjlm_edit.ar_x_lmid]]);
//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--
// Write your table-specific startup script here
// document.write("page loaded");
//-->
</script>
<!--#include file="footer.asp"-->
<%

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

' -----------------------------------------------------------------
' Page Class
'
Class csjlm_edit

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

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

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

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

	' Page Url
	Public Property Get PageUrl()
		PageUrl = ew_CurrentPage() & "?"
		If sjlm.UseTokenInUrl Then PageUrl = PageUrl & "t=" & sjlm.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 sjlm.UseTokenInUrl Then
			IsPageRequest = False
			If Not (ObjForm Is Nothing) Then
				IsPageRequest = (sjlm.TableVar = ObjForm.GetValue("t"))
			End If
			If Request.QueryString("t").Count > 0 Then
				IsPageRequest = (sjlm.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 sjlm = New csjlm

		' Initialize other table object
		Set zlogin = New czlogin

		' Initialize form object
		Set ObjForm = Nothing

		' Intialize page id (for backward compatibility)
		EW_PAGE_ID = "edit"

		' Initialize table name (for backward compatibility)
		EW_TABLE_NAME = "sjlm"

		' Open connection to the database
		Set Conn = Server.CreateObject("ADODB.Connection")
		Conn.Open EW_DB_CONNECTION_STRING
	End Sub

	' -----------------------------------------------------------------
	'  Subroutine Page_Init
	'  - called before page main
	'  - check Security
	'  - set up response header
	'  - call page load events
	'
	Sub Page_Init()
		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.CanEdit Then
			Call Security.SaveLastUrl()
			Call Page_Terminate("sjlmlist.asp")
		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 Security = Nothing
		Set sjlm = Nothing

		' Go to url if specified
		If url <> "" Then
			Response.Clear
			Response.Redirect url
		End If
	End Sub

	'
	'  Subroutine Page_Terminate (End)
	' ----------------------------------------
	' -----------------------------------------------------------------
	' Page main processing
	'
	Sub Page_Main()

		' Load key from QueryString
		If Request.QueryString("id").Count > 0 Then
			sjlm.id.QueryStringValue = Request.QueryString("id")
		End If

		' Create form object
		Set ObjForm = New cFormObj
		If ObjForm.GetValue("a_edit")&"" <> "" Then
			sjlm.CurrentAction = ObjForm.GetValue("a_edit") ' Get action code
			Call LoadFormValues() ' Get form values

			' Validate Form
			If Not ValidateForm() Then
				sjlm.CurrentAction = "" ' Form error, reset action
				Message = gsFormError
				Call LoadRow() ' Restore row
				Call RestoreFormValues() ' Restore form values if validate failed
			End If
		Else
			sjlm.CurrentAction = "I" ' Default action is display
		End If

		' Close form object
		Set ObjForm = Nothing

		' Check if valid key
		If sjlm.id.CurrentValue = "" Then Call Page_Terminate("sjlmlist.asp") ' Invalid key, return to list
		Select Case sjlm.CurrentAction
			Case "I" ' Get a record to display
				If Not LoadRow() Then ' Load Record based on key
					Message = "没有找到记录" ' No record found
					Call Page_Terminate("sjlmlist.asp") ' No matching record, return to list
				End If
			Case "U" ' Update
				sjlm.SendEmail = True ' Send email on update success
				If EditRow() Then ' Update Record based on key
					Message = "更新成功" ' Update success
					Dim sReturnUrl
					sReturnUrl = sjlm.ReturnUrl
					If ew_GetPageName(sReturnUrl) = "sjlmview.asp" Then sReturnUrl = sjlm.ViewUrl ' View paging, return to view page with keyurl directly
					Call Page_Terminate(sReturnUrl) ' Return to caller
				Else
					Call LoadRow() ' Restore row
					Call RestoreFormValues() ' Restore form values if update failed
				End If
		End Select

		' Render the record
		sjlm.RowType = EW_ROWTYPE_EDIT ' Render as edit

		' Render row
		Call RenderRow()
	End Sub

	' -----------------------------------------------------------------
	' Function Get upload files
	'
	Function GetUploadFiles()

		' Get upload data
	End Function

	' -----------------------------------------------------------------
	' Load form values
	'
	Function LoadFormValues()

		' Load values from form
		sjlm.id.FormValue = ObjForm.GetValue("x_id")
		sjlm.id.OldValue = ObjForm.GetValue("o_id")
		sjlm.bh.FormValue = ObjForm.GetValue("x_bh")
		sjlm.bh.OldValue = ObjForm.GetValue("o_bh")
		sjlm.lmid.FormValue = ObjForm.GetValue("x_lmid")
		sjlm.lmid.OldValue = ObjForm.GetValue("o_lmid")
		sjlm.sjmc.FormValue = ObjForm.GetValue("x_sjmc")
		sjlm.sjmc.OldValue = ObjForm.GetValue("o_sjmc")
		sjlm.px.FormValue = ObjForm.GetValue("x_px")
		sjlm.px.OldValue = ObjForm.GetValue("o_px")
		sjlm.urllb.FormValue = ObjForm.GetValue("x_urllb")
		sjlm.urllb.OldValue = ObjForm.GetValue("o_urllb")
	End Function

	' -----------------------------------------------------------------
	' Restore form values
	'
	Function RestoreFormValues()
		sjlm.id.CurrentValue = sjlm.id.FormValue
		sjlm.bh.CurrentValue = sjlm.bh.FormValue
		sjlm.lmid.CurrentValue = sjlm.lmid.FormValue
		sjlm.sjmc.CurrentValue = sjlm.sjmc.FormValue
		sjlm.px.CurrentValue = sjlm.px.FormValue
		sjlm.urllb.CurrentValue = sjlm.urllb.FormValue
	End Function

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

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

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

	' -----------------------------------------------------------------
	' Load row values from recordset
	'
	Sub LoadRowValues(RsRow)
		sjlm.id.DbValue = RsRow("id")
		sjlm.bh.DbValue = RsRow("bh")
		sjlm.lmid.DbValue = RsRow("lmid")
		sjlm.sjmc.DbValue = RsRow("sjmc")
		sjlm.px.DbValue = RsRow("px")
		sjlm.urllb.DbValue = RsRow("urllb")
	End Sub

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

		' Call Row Rendering event
		Call sjlm.Row_Rendering()

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

		sjlm.id.CellCssStyle = ""
		sjlm.id.CellCssClass = ""

		' bh
		sjlm.bh.CellCssStyle = ""
		sjlm.bh.CellCssClass = ""

		' lmid
		sjlm.lmid.CellCssStyle = ""
		sjlm.lmid.CellCssClass = ""

		' sjmc
		sjlm.sjmc.CellCssStyle = ""
		sjlm.sjmc.CellCssClass = ""

		' px
		sjlm.px.CellCssStyle = ""
		sjlm.px.CellCssClass = ""

		' urllb
		sjlm.urllb.CellCssStyle = ""
		sjlm.urllb.CellCssClass = ""

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

		If sjlm.RowType = EW_ROWTYPE_VIEW Then ' View row

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

			' bh
			If sjlm.bh.CurrentValue & "" <> "" Then
				sSqlWrk = "SELECT [bhmc] FROM [bhlm] WHERE [bh] = " & ew_AdjustSql(sjlm.bh.CurrentValue) & ""
				Set RsWrk = Conn.Execute(sSqlWrk)
				If Not RsWrk.Eof Then
					sjlm.bh.ViewValue = RsWrk("bhmc")
				Else
					sjlm.bh.ViewValue = sjlm.bh.CurrentValue
				End If
				RsWrk.Close
				Set RsWrk = Nothing
			Else
				sjlm.bh.ViewValue = Null
			End If
			sjlm.bh.CssStyle = ""
			sjlm.bh.CssClass = ""
			sjlm.bh.ViewCustomAttributes = ""

			' lmid
			If sjlm.lmid.CurrentValue & "" <> "" Then
				sSqlWrk = "SELECT [lmmc] FROM [xwlm] WHERE [lmid] = " & ew_AdjustSql(sjlm.lmid.CurrentValue) & ""
				Set RsWrk = Conn.Execute(sSqlWrk)
				If Not RsWrk.Eof Then
					sjlm.lmid.ViewValue = RsWrk("lmmc")
				Else
					sjlm.lmid.ViewValue = sjlm.lmid.CurrentValue
				End If
				RsWrk.Close
				Set RsWrk = Nothing
			Else
				sjlm.lmid.ViewValue = Null
			End If
			sjlm.lmid.CssStyle = ""
			sjlm.lmid.CssClass = ""
			sjlm.lmid.ViewCustomAttributes = ""

			' sjmc
			sjlm.sjmc.ViewValue = sjlm.sjmc.CurrentValue
			sjlm.sjmc.CssStyle = ""
			sjlm.sjmc.CssClass = ""
			sjlm.sjmc.ViewCustomAttributes = ""

			' px
			sjlm.px.ViewValue = sjlm.px.CurrentValue
			sjlm.px.CssStyle = ""
			sjlm.px.CssClass = ""
			sjlm.px.ViewCustomAttributes = ""

			' urllb
			If Not IsNull(sjlm.urllb.CurrentValue) Then
				Select Case sjlm.urllb.CurrentValue
					Case "0"
						sjlm.urllb.ViewValue = "列表"
					Case "1"
						sjlm.urllb.ViewValue = "单页"
					Case "2"
						sjlm.urllb.ViewValue = "图片列表"
					Case Else
						sjlm.urllb.ViewValue = sjlm.urllb.CurrentValue
				End Select
			Else
				sjlm.urllb.ViewValue = Null
			End If
			sjlm.urllb.CssStyle = ""
			sjlm.urllb.CssClass = ""
			sjlm.urllb.ViewCustomAttributes = ""

			' View refer script
			' id

			sjlm.id.HrefValue = ""

			' bh
			sjlm.bh.HrefValue = ""

			' lmid
			sjlm.lmid.HrefValue = ""

			' sjmc
			sjlm.sjmc.HrefValue = ""

			' px
			sjlm.px.HrefValue = ""

			' urllb
			sjlm.urllb.HrefValue = ""

		' ----------
		'  Edit Row
		' ----------

		ElseIf sjlm.RowType = EW_ROWTYPE_EDIT Then ' Edit row

			' id
			sjlm.id.EditCustomAttributes = ""
			sjlm.id.EditValue = sjlm.id.CurrentValue
			sjlm.id.CssStyle = ""
			sjlm.id.CssClass = ""
			sjlm.id.ViewCustomAttributes = ""

			' bh
			sjlm.bh.EditCustomAttributes = ""
			sSqlWrk = "SELECT [bh], [bhmc], '' AS Disp2Fld, '' AS SelectFilterFld FROM [bhlm]"
			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
			arwrk = ew_AddItemToArray(arwrk, 0, Array("", "请选择"))
			sjlm.bh.EditValue = arwrk

			' lmid
			sjlm.lmid.EditCustomAttributes = ""
			sSqlWrk = "SELECT [lmid], [lmmc], '' AS Disp2Fld, [bh] FROM [xwlm]"
			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
			arwrk = ew_AddItemToArray(arwrk, 0, Array("", "请选择", ""))
			sjlm.lmid.EditValue = arwrk

			' sjmc
			sjlm.sjmc.EditCustomAttributes = ""
			sjlm.sjmc.EditValue = ew_HtmlEncode(sjlm.sjmc.CurrentValue)

			' px
			sjlm.px.EditCustomAttributes = ""
			sjlm.px.EditValue = ew_HtmlEncode(sjlm.px.CurrentValue)

			' urllb
			sjlm.urllb.EditCustomAttributes = ""
			Redim arwrk(1, 2)
			arwrk(0, 0) = "0"
			arwrk(1, 0) = "列表"
			arwrk(0, 1) = "1"
			arwrk(1, 1) = "单页"
			arwrk(0, 2) = "2"
			arwrk(1, 2) = "图片列表"
			sjlm.urllb.EditValue = arwrk

			' Edit refer script
			' id

			sjlm.id.HrefValue = ""

			' bh
			sjlm.bh.HrefValue = ""

			' lmid
			sjlm.lmid.HrefValue = ""

			' sjmc
			sjlm.sjmc.HrefValue = ""

			' px
			sjlm.px.HrefValue = ""

			' urllb
			sjlm.urllb.HrefValue = ""
		End If

		' Call Row Rendered event
		Call sjlm.Row_Rendered()
	End Sub

	' -----------------------------------------------------------------
	' Validate form
	'
	Function ValidateForm()

		' Initialize
		gsFormError = ""

		' Check if validation required
		If Not EW_SERVER_VALIDATE Then
			ValidateForm = (gsFormError = "")
			Exit Function
		End If
		If Not ew_CheckInteger(sjlm.id.FormValue) Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & "无效的整数型 - 编号"
		End If
		If Not ew_CheckInteger(sjlm.px.FormValue) Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & "无效的整数型 - 排序"
		End If

		' Return validate result
		ValidateForm = (gsFormError = "")

		' Call Form Custom Validate event
		Dim sFormCustomError
		sFormCustomError = ""
		ValidateForm = ValidateForm And Form_CustomValidate(sFormCustomError)
		If sFormCustomError <> "" Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & sFormCustomError
		End If
	End Function

	' -----------------------------------------------------------------
	' Update record based on key values
	'
	Function EditRow()
		If Not EW_DEBUG_ENABLED Then On Error Resume Next
		Dim Rs, sSql, sFilter
		Dim RsChk, sSqlChk, sFilterChk
		Dim bUpdateRow
		Dim RsOld, RsNew
		Dim sIdxErrMsg

		' Clear any previous errors
		Err.Clear
		sFilter = sjlm.KeyFilter
		sjlm.CurrentFilter  = sFilter
		sSql = sjlm.SQL
		Set Rs = Server.CreateObject("ADODB.Recordset")
		Rs.CursorLocation = EW_CURSORLOCATION
		Rs.Open sSql, Conn, 1, 2
		If Err.Number <> 0 Then
			Message = Err.Description
			Rs.Close
			Set Rs = Nothing
			EditRow = False
			Exit Function
		End If

		' Clone old recordset object
		Set RsOld = ew_CloneRs(Rs)
		If Rs.Eof Then
			EditRow = False ' Update Failed
		Else

			' Field id
			' Field bh

			Call sjlm.bh.SetDbValue(sjlm.bh.CurrentValue, Null)
			Rs("bh") = sjlm.bh.DbValue

			' Field lmid
			Call sjlm.lmid.SetDbValue(sjlm.lmid.CurrentValue, Null)
			Rs("lmid") = sjlm.lmid.DbValue

			' Field sjmc
			Call sjlm.sjmc.SetDbValue(sjlm.sjmc.CurrentValue, Null)
			Rs("sjmc") = sjlm.sjmc.DbValue

			' Field px
			Call sjlm.px.SetDbValue(sjlm.px.CurrentValue, Null)
			Rs("px") = sjlm.px.DbValue

			' Field urllb
			Call sjlm.urllb.SetDbValue(sjlm.urllb.CurrentValue, Null)
			Rs("urllb") = sjlm.urllb.DbValue

			' Check recordset update error
			If Err.Number <> 0 Then
				Message = Err.Description
				Rs.Close
				Set Rs = Nothing
				EditRow = False
				Exit Function
			End If

			' Call Row Updating event
			bUpdateRow = sjlm.Row_Updating(RsOld, Rs)
			If bUpdateRow Then

				' Clone new recordset object
				Set RsNew = ew_CloneRs(Rs)
				Rs.Update
				If Err.Number <> 0 Then
					Message = Err.Description
					EditRow = False
				Else
					EditRow = True
				End If
			Else
				Rs.CancelUpdate
				If sjlm.CancelMessage <> "" Then
					Message = sjlm.CancelMessage
					sjlm.CancelMessage = ""
				Else
					Message = "取消更新"
				End If
				EditRow = False
			End If
		End If

		' Call Row Updated event
		If EditRow Then
			Call sjlm.Row_Updated(RsOld, RsNew)
		End If
		Rs.Close
		Set Rs = Nothing
		If IsObject(RsOld) Then
			RsOld.Close
			Set RsOld = Nothing
		End If
		If IsObject(RsNew) Then
			RsNew.Close
			Set RsNew = Nothing
		End If
	End Function

	' 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
%>
