<%
Response.Buffer = EW_RESPONSE_BUFFER
%>
<!--#include file="ewcfg7.asp"-->
<!--#include file="xwlminfo.asp"-->
<!--#include file="bhlminfo.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 xwlm_add
Set xwlm_add = New cxwlm_add
Set Page = xwlm_add

' Page init processing
Call xwlm_add.Page_Init()

' Page main processing
Call xwlm_add.Page_Main()
%>
<!--#include file="header.asp"-->
<script type="text/javascript">
<!--
// Create page object
var xwlm_add = new ew_Page("xwlm_add");
// page properties
xwlm_add.PageID = "add"; // page ID
var EW_PAGE_ID = xwlm_add.PageID; // for backward compatibility
// extend page with ValidateForm function
xwlm_add.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) : "";
		// Call Form Custom Validate event
		if (!this.Form_CustomValidate(fobj)) return false;
	}
	return true;
}
// extend page with Form_CustomValidate function
xwlm_add.Form_CustomValidate = 
 function(fobj) { // DO NOT CHANGE THIS LINE!
 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
xwlm_add.SelectAllKey = function(elem) {
	ew_SelectAll(elem);
}
<% If EW_CLIENT_VALIDATE Then %>
xwlm_add.ValidateRequired = true; // uses JavaScript validation
<% Else %>
xwlm_add.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">增加 表: 信息二级栏目<br><br>
<a href="<%= xwlm.ReturnUrl %>">返回</a></span></p>
<% xwlm_add.ShowMessage %>
<form name="fxwlmadd" id="fxwlmadd" action="<%= ew_CurrentPage %>" method="post" onsubmit="return xwlm_add.ValidateForm(this);">
<p>
<input type="hidden" name="t" id="t" value="xwlm">
<input type="hidden" name="a_add" id="a_add" value="A">
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable">
<% If xwlm.bh.Visible Then ' bh %>
	<tr<%= xwlm.bh.RowAttributes %>>
		<td class="ewTableHeader">上级栏目</td>
		<td<%= xwlm.bh.CellAttributes %>><span id="el_bh">
<% If xwlm.bh.SessionValue <> "" Then %>
<div<%= xwlm.bh.ViewAttributes %>><%= xwlm.bh.ViewValue %></div>
<input type="hidden" id="x_bh" name="x_bh" value="<%= ew_HtmlEncode(xwlm.bh.CurrentValue) %>">
<% Else %>
<select id="x_bh" name="x_bh"<%= xwlm.bh.EditAttributes %>>
<%
emptywrk = True
If IsArray(xwlm.bh.EditValue) Then
	arwrk = xwlm.bh.EditValue
	For rowcntwrk = 0 To UBound(arwrk, 2)
		If arwrk(0, rowcntwrk)&"" = xwlm.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>
<% End If %>
</span><%= xwlm.bh.CustomMsg %></td>
	</tr>
<% End If %>
<% If xwlm.lmmc.Visible Then ' lmmc %>
	<tr<%= xwlm.lmmc.RowAttributes %>>
		<td class="ewTableHeader">栏目名称</td>
		<td<%= xwlm.lmmc.CellAttributes %>><span id="el_lmmc">
<input type="text" name="x_lmmc" id="x_lmmc" size="30" maxlength="50" value="<%= xwlm.lmmc.EditValue %>"<%= xwlm.lmmc.EditAttributes %>>
</span><%= xwlm.lmmc.CustomMsg %></td>
	</tr>
<% End If %>
<% If xwlm.px.Visible Then ' px %>
	<tr<%= xwlm.px.RowAttributes %>>
		<td class="ewTableHeader">排序</td>
		<td<%= xwlm.px.CellAttributes %>><span id="el_px">
<input type="text" name="x_px" id="x_px" size="30" maxlength="50" value="<%= xwlm.px.EditValue %>"<%= xwlm.px.EditAttributes %>>
</span><%= xwlm.px.CustomMsg %></td>
	</tr>
<% End If %>
<% If xwlm.urllb.Visible Then ' urllb %>
	<tr<%= xwlm.urllb.RowAttributes %>>
		<td class="ewTableHeader">展示类别</td>
		<td<%= xwlm.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}"<%= xwlm.urllb.EditAttributes %>></div>
<div id="dsl_x_urllb" repeatcolumn="5">
<%
emptywrk = True
arwrk = xwlm.urllb.EditValue
If IsArray(arwrk) Then
	rowswrk = UBound(arwrk, 2)	
	For rowcntwrk = 0 To rowswrk
		If xwlm.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 %><%= xwlm.urllb.EditAttributes %>><%= arwrk(1, rowcntwrk) %></label>
<%= ew_RepeatColumnTable(rowswrk, rowcntwrk, 5, 2) %>
<%
	Next
End If
%>
</div>
</span><%= xwlm.urllb.CustomMsg %></td>
	</tr>
<% End If %>
</table>
</div>
</td></tr></table>
<p>
<input type="submit" name="btnAction" id="btnAction" value="    增加    ">
</form>
<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 xwlm_add = Nothing
%>
<%

' -----------------------------------------------------------------
' Page Class
'
Class cxwlm_add

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

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

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

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

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

		' Initialize other table object
		Set bhlm = New cbhlm

		' Initialize other table object
		Set zlogin = New czlogin

		' Initialize form object
		Set ObjForm = Nothing

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

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

		' 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.CanAdd Then
			Call Security.SaveLastUrl()
			Call Page_Terminate("xwlmlist.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 xwlm = Nothing

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

	'
	'  Subroutine Page_Terminate (End)
	' ----------------------------------------

	Dim x_ewPriv

	' -----------------------------------------------------------------
	' Page main processing
	'
	Sub Page_Main()

		' Load key values from QueryString
		Dim bCopy
		bCopy = True
		If Request.QueryString("lmid").Count > 0 Then
			xwlm.lmid.QueryStringValue = Request.QueryString("lmid")
		Else
			bCopy = False
		End If

		' Create form object
		Set ObjForm = New cFormObj

		' Process form if post back
		If ObjForm.GetValue("a_add")&"" <> "" Then
			xwlm.CurrentAction = ObjForm.GetValue("a_add") ' Get form action
			Call LoadFormValues() ' Load form values

			' Validate Form
			If Not ValidateForm() Then
				xwlm.CurrentAction = "I" ' Form error, reset action
				Message = gsFormError
			End If

		' Not post back
		Else
			If bCopy Then
				xwlm.CurrentAction = "C" ' Copy Record
			Else
				xwlm.CurrentAction = "I" ' Display Blank Record
				Call LoadDefaultValues() ' Load default values
			End If
		End If

		' Close form object
		Set ObjForm = Nothing

		' Perform action based on action code
		Select Case xwlm.CurrentAction
			Case "I" ' Blank record, no action required
			Case "C" ' Copy an existing record
				If Not LoadRow() Then ' Load record based on key
					Message = "没有找到记录" ' No record found
					Call Page_Terminate("xwlmlist.asp") ' No matching record, return to list
				End If
			Case "A" ' Add new record
				xwlm.SendEmail = True ' Send email on add success
				If AddRow() Then ' Add successful
					Message = "记录增加成功" ' Set up success message
					Dim sReturnUrl
					sReturnUrl = xwlm.ReturnUrl
					If ew_GetPageName(sReturnUrl) = "xwlmview.asp" Then sReturnUrl = xwlm.ViewUrl ' View paging, return to view page with keyurl directly
					Call Page_Terminate(sReturnUrl) ' Clean up and return
				Else
					Call RestoreFormValues() ' Add failed, restore form values
				End If
		End Select

		' Render row based on row type
		xwlm.RowType = EW_ROWTYPE_ADD ' Render add type

		' Render row
		Call RenderRow()
	End Sub

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

		' Get upload data
	End Function

	' -----------------------------------------------------------------
	' Load default values
	'
	Function LoadDefaultValues()
		xwlm.bh.CurrentValue = 0
		xwlm.px.CurrentValue = 0
		xwlm.urllb.CurrentValue = 0
	End Function

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

		' Load values from form
		xwlm.bh.FormValue = ObjForm.GetValue("x_bh")
		xwlm.bh.OldValue = ObjForm.GetValue("o_bh")
		xwlm.lmmc.FormValue = ObjForm.GetValue("x_lmmc")
		xwlm.lmmc.OldValue = ObjForm.GetValue("o_lmmc")
		xwlm.px.FormValue = ObjForm.GetValue("x_px")
		xwlm.px.OldValue = ObjForm.GetValue("o_px")
		xwlm.urllb.FormValue = ObjForm.GetValue("x_urllb")
		xwlm.urllb.OldValue = ObjForm.GetValue("o_urllb")
		xwlm.lmid.FormValue = ObjForm.GetValue("x_lmid")
	End Function

	' -----------------------------------------------------------------
	' Restore form values
	'
	Function RestoreFormValues()
		xwlm.bh.CurrentValue = xwlm.bh.FormValue
		xwlm.lmmc.CurrentValue = xwlm.lmmc.FormValue
		xwlm.px.CurrentValue = xwlm.px.FormValue
		xwlm.urllb.CurrentValue = xwlm.urllb.FormValue
		xwlm.lmid.CurrentValue = xwlm.lmid.FormValue
	End Function

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

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

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

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

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

		' Call Row Rendering event
		Call xwlm.Row_Rendering()

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

		xwlm.bh.CellCssStyle = ""
		xwlm.bh.CellCssClass = ""

		' lmmc
		xwlm.lmmc.CellCssStyle = ""
		xwlm.lmmc.CellCssClass = ""

		' px
		xwlm.px.CellCssStyle = ""
		xwlm.px.CellCssClass = ""

		' urllb
		xwlm.urllb.CellCssStyle = ""
		xwlm.urllb.CellCssClass = ""

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

		If xwlm.RowType = EW_ROWTYPE_VIEW Then ' View row

			' lmid
			xwlm.lmid.ViewValue = xwlm.lmid.CurrentValue
			xwlm.lmid.CssStyle = ""
			xwlm.lmid.CssClass = ""
			xwlm.lmid.ViewCustomAttributes = ""

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

			' lmmc
			xwlm.lmmc.ViewValue = xwlm.lmmc.CurrentValue
			xwlm.lmmc.CssStyle = ""
			xwlm.lmmc.CssClass = ""
			xwlm.lmmc.ViewCustomAttributes = ""

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

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

			' View refer script
			' bh

			xwlm.bh.HrefValue = ""

			' lmmc
			xwlm.lmmc.HrefValue = ""

			' px
			xwlm.px.HrefValue = ""

			' urllb
			xwlm.urllb.HrefValue = ""

		' ---------
		'  Add Row
		' ---------

		ElseIf xwlm.RowType = EW_ROWTYPE_ADD Then ' Add row

			' bh
			xwlm.bh.EditCustomAttributes = ""
			If xwlm.bh.SessionValue <> "" Then
				xwlm.bh.CurrentValue = xwlm.bh.SessionValue
			If xwlm.bh.CurrentValue & "" <> "" Then
				sSqlWrk = "SELECT [bhmc] FROM [bhlm] WHERE [bh] = " & ew_AdjustSql(xwlm.bh.CurrentValue) & ""
				Set RsWrk = Conn.Execute(sSqlWrk)
				If Not RsWrk.Eof Then
					xwlm.bh.ViewValue = RsWrk("bhmc")
				Else
					xwlm.bh.ViewValue = xwlm.bh.CurrentValue
				End If
				RsWrk.Close
				Set RsWrk = Nothing
			Else
				xwlm.bh.ViewValue = Null
			End If
			xwlm.bh.CssStyle = ""
			xwlm.bh.CssClass = ""
			xwlm.bh.ViewCustomAttributes = ""
			Else
			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("", "请选择"))
			xwlm.bh.EditValue = arwrk
			End If

			' lmmc
			xwlm.lmmc.EditCustomAttributes = ""
			xwlm.lmmc.EditValue = ew_HtmlEncode(xwlm.lmmc.CurrentValue)

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

			' urllb
			xwlm.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) = "图片列表"
			xwlm.urllb.EditValue = arwrk
		End If

		' Call Row Rendered event
		Call xwlm.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

		' 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

	' -----------------------------------------------------------------
	' Add record
	'
	Function AddRow()
		If Not EW_DEBUG_ENABLED Then On Error Resume Next
		Dim Rs, sSql, sFilter
		Dim RsNew
		Dim bInsertRow
		Dim RsChk
		Dim sIdxErrMsg

		' Clear any previous errors
		Err.Clear

		' Add new record
		sFilter = "(0 = 1)"
		xwlm.CurrentFilter = sFilter
		sSql = xwlm.SQL
		Set Rs = Server.CreateObject("ADODB.Recordset")
		Rs.CursorLocation = EW_CURSORLOCATION
		Rs.Open sSql, Conn, 1, 2
		Rs.AddNew
		If Err.Number <> 0 Then
			Message = Err.Description
			Rs.Close
			Set Rs = Nothing
			AddRow = False
			Exit Function
		End If

		' Field bh
		Call xwlm.bh.SetDbValue(xwlm.bh.CurrentValue, Null)
		Rs("bh") = xwlm.bh.DbValue

		' Field lmmc
		Call xwlm.lmmc.SetDbValue(xwlm.lmmc.CurrentValue, Null)
		Rs("lmmc") = xwlm.lmmc.DbValue

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

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

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

		' Call Row Inserting event
		bInsertRow = xwlm.Row_Inserting(Rs)
		If bInsertRow Then

			' Clone new recordset object
			Set RsNew = ew_CloneRs(Rs)
			Rs.Update
			If Err.Number <> 0 Then
				Message = Err.Description
				AddRow = False
			Else
				AddRow = True
			End If
		Else
			Rs.CancelUpdate
			If xwlm.CancelMessage <> "" Then
				Message = xwlm.CancelMessage
				xwlm.CancelMessage = ""
			Else
				Message = "插入已取消"
			End If
			AddRow = False
		End If
		Rs.Close
		Set Rs = Nothing
		If AddRow Then
			xwlm.lmid.DbValue = RsNew("lmid")

			' Call Row Inserted event
			Call xwlm.Row_Inserted(RsNew)
		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
%>
