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

' Page init processing
Call UserLevelPermissions_edit.Page_Init()

' Page main processing
Call UserLevelPermissions_edit.Page_Main()
%>
<!--#include file="header.asp"-->
<script type="text/javascript">
<!--
// Create page object
var UserLevelPermissions_edit = new ew_Page("UserLevelPermissions_edit");
// page properties
UserLevelPermissions_edit.PageID = "edit"; // page ID
var EW_PAGE_ID = UserLevelPermissions_edit.PageID; // for backward compatibility
// extend page with ValidateForm function
UserLevelPermissions_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 + "_UserLevelID"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, "请输入必要内容 - User Level ID");
		elm = fobj.elements["x" + infix + "_UserLevelID"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "无效的整数型 - User Level ID");
		elm = fobj.elements["x" + infix + "_UserLevelTableName"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, "请输入必要内容 - User Level Table Name");
		elm = fobj.elements["x" + infix + "_UserLevelPermission"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, "请输入必要内容 - User Level Permission");
		elm = fobj.elements["x" + infix + "_UserLevelPermission"];
		if (elm && !ew_CheckInteger(elm.value))
			return ew_OnError(this, elm, "无效的整数型 - User Level Permission");
		// Call Form Custom Validate event
		if (!this.Form_CustomValidate(fobj)) return false;
	}
	return true;
}
// extend page with Form_CustomValidate function
UserLevelPermissions_edit.Form_CustomValidate = 
 function(fobj) { // DO NOT CHANGE THIS LINE!
 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
UserLevelPermissions_edit.SelectAllKey = function(elem) {
	ew_SelectAll(elem);
}
<% If EW_CLIENT_VALIDATE Then %>
UserLevelPermissions_edit.ValidateRequired = true; // uses JavaScript validation
<% Else %>
UserLevelPermissions_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">编辑 表: User Level Permissions<br><br>
<a href="<%= UserLevelPermissions.ReturnUrl %>">返回</a></span></p>
<% UserLevelPermissions_edit.ShowMessage %>
<form name="fUserLevelPermissionsedit" id="fUserLevelPermissionsedit" action="<%= ew_CurrentPage %>" method="post" onsubmit="return UserLevelPermissions_edit.ValidateForm(this);">
<p>
<input type="hidden" name="a_table" id="a_table" value="UserLevelPermissions">
<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 UserLevelPermissions.UserLevelID.Visible Then ' UserLevelID %>
	<tr<%= UserLevelPermissions.UserLevelID.RowAttributes %>>
		<td class="ewTableHeader">User Level ID<span class='ewmsg'>&nbsp;*</span></td>
		<td<%= UserLevelPermissions.UserLevelID.CellAttributes %>><span id="el_UserLevelID">
<div<%= UserLevelPermissions.UserLevelID.ViewAttributes %>><%= UserLevelPermissions.UserLevelID.EditValue %></div>
<input type="hidden" name="x_UserLevelID" id="x_UserLevelID" value="<%= Server.HTMLEncode(UserLevelPermissions.UserLevelID.CurrentValue&"") %>">
</span><%= UserLevelPermissions.UserLevelID.CustomMsg %></td>
	</tr>
<% End If %>
<% If UserLevelPermissions.UserLevelTableName.Visible Then ' UserLevelTableName %>
	<tr<%= UserLevelPermissions.UserLevelTableName.RowAttributes %>>
		<td class="ewTableHeader">User Level Table Name<span class='ewmsg'>&nbsp;*</span></td>
		<td<%= UserLevelPermissions.UserLevelTableName.CellAttributes %>><span id="el_UserLevelTableName">
<div<%= UserLevelPermissions.UserLevelTableName.ViewAttributes %>><%= UserLevelPermissions.UserLevelTableName.EditValue %></div>
<input type="hidden" name="x_UserLevelTableName" id="x_UserLevelTableName" value="<%= Server.HTMLEncode(UserLevelPermissions.UserLevelTableName.CurrentValue&"") %>">
</span><%= UserLevelPermissions.UserLevelTableName.CustomMsg %></td>
	</tr>
<% End If %>
<% If UserLevelPermissions.UserLevelPermission.Visible Then ' UserLevelPermission %>
	<tr<%= UserLevelPermissions.UserLevelPermission.RowAttributes %>>
		<td class="ewTableHeader">User Level Permission<span class='ewmsg'>&nbsp;*</span></td>
		<td<%= UserLevelPermissions.UserLevelPermission.CellAttributes %>><span id="el_UserLevelPermission">
<input type="text" name="x_UserLevelPermission" id="x_UserLevelPermission" size="30" value="<%= UserLevelPermissions.UserLevelPermission.EditValue %>"<%= UserLevelPermissions.UserLevelPermission.EditAttributes %>>
</span><%= UserLevelPermissions.UserLevelPermission.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 UserLevelPermissions_edit = Nothing
%>
<%

' -----------------------------------------------------------------
' Page Class
'
Class cUserLevelPermissions_edit

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

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

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

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

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

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

		' 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.CanAdmin Then
			Call Security.SaveLastUrl()
			Call Page_Terminate( "login.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 UserLevelPermissions = 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("UserLevelID").Count > 0 Then
			UserLevelPermissions.UserLevelID.QueryStringValue = Request.QueryString("UserLevelID")
		End If
		If Request.QueryString("UserLevelTableName").Count > 0 Then
			UserLevelPermissions.UserLevelTableName.QueryStringValue = Request.QueryString("UserLevelTableName")
		End If

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

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

		' Close form object
		Set ObjForm = Nothing

		' Check if valid key
		If UserLevelPermissions.UserLevelID.CurrentValue = "" Then Call Page_Terminate("UserLevelPermissionslist.asp") ' Invalid key, return to list
		If UserLevelPermissions.UserLevelTableName.CurrentValue = "" Then Call Page_Terminate("UserLevelPermissionslist.asp") ' Invalid key, return to list
		Select Case UserLevelPermissions.CurrentAction
			Case "I" ' Get a record to display
				If Not LoadRow() Then ' Load Record based on key
					Message = "没有找到记录" ' No record found
					Call Page_Terminate("UserLevelPermissionslist.asp") ' No matching record, return to list
				End If
			Case "U" ' Update
				UserLevelPermissions.SendEmail = True ' Send email on update success
				If EditRow() Then ' Update Record based on key
					Message = "更新成功" ' Update success
					Dim sReturnUrl
					sReturnUrl = UserLevelPermissions.ReturnUrl
					If ew_GetPageName(sReturnUrl) = "UserLevelPermissionsview.asp" Then sReturnUrl = UserLevelPermissions.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
		UserLevelPermissions.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
		UserLevelPermissions.UserLevelID.FormValue = ObjForm.GetValue("x_UserLevelID")
		UserLevelPermissions.UserLevelID.OldValue = ObjForm.GetValue("o_UserLevelID")
		UserLevelPermissions.UserLevelTableName.FormValue = ObjForm.GetValue("x_UserLevelTableName")
		UserLevelPermissions.UserLevelTableName.OldValue = ObjForm.GetValue("o_UserLevelTableName")
		UserLevelPermissions.UserLevelPermission.FormValue = ObjForm.GetValue("x_UserLevelPermission")
		UserLevelPermissions.UserLevelPermission.OldValue = ObjForm.GetValue("o_UserLevelPermission")
	End Function

	' -----------------------------------------------------------------
	' Restore form values
	'
	Function RestoreFormValues()
		UserLevelPermissions.UserLevelID.CurrentValue = UserLevelPermissions.UserLevelID.FormValue
		UserLevelPermissions.UserLevelTableName.CurrentValue = UserLevelPermissions.UserLevelTableName.FormValue
		UserLevelPermissions.UserLevelPermission.CurrentValue = UserLevelPermissions.UserLevelPermission.FormValue
	End Function

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

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

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

	' -----------------------------------------------------------------
	' Load row values from recordset
	'
	Sub LoadRowValues(RsRow)
		UserLevelPermissions.UserLevelID.DbValue = RsRow("UserLevelID")
		UserLevelPermissions.UserLevelTableName.DbValue = RsRow("UserLevelTableName")
		UserLevelPermissions.UserLevelPermission.DbValue = RsRow("UserLevelPermission")
	End Sub

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

		' Call Row Rendering event
		Call UserLevelPermissions.Row_Rendering()

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

		UserLevelPermissions.UserLevelID.CellCssStyle = ""
		UserLevelPermissions.UserLevelID.CellCssClass = ""

		' UserLevelTableName
		UserLevelPermissions.UserLevelTableName.CellCssStyle = ""
		UserLevelPermissions.UserLevelTableName.CellCssClass = ""

		' UserLevelPermission
		UserLevelPermissions.UserLevelPermission.CellCssStyle = ""
		UserLevelPermissions.UserLevelPermission.CellCssClass = ""

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

		If UserLevelPermissions.RowType = EW_ROWTYPE_VIEW Then ' View row

			' UserLevelID
			UserLevelPermissions.UserLevelID.ViewValue = UserLevelPermissions.UserLevelID.CurrentValue
			UserLevelPermissions.UserLevelID.CssStyle = ""
			UserLevelPermissions.UserLevelID.CssClass = ""
			UserLevelPermissions.UserLevelID.ViewCustomAttributes = ""

			' UserLevelTableName
			UserLevelPermissions.UserLevelTableName.ViewValue = UserLevelPermissions.UserLevelTableName.CurrentValue
			UserLevelPermissions.UserLevelTableName.CssStyle = ""
			UserLevelPermissions.UserLevelTableName.CssClass = ""
			UserLevelPermissions.UserLevelTableName.ViewCustomAttributes = ""

			' UserLevelPermission
			UserLevelPermissions.UserLevelPermission.ViewValue = UserLevelPermissions.UserLevelPermission.CurrentValue
			UserLevelPermissions.UserLevelPermission.CssStyle = ""
			UserLevelPermissions.UserLevelPermission.CssClass = ""
			UserLevelPermissions.UserLevelPermission.ViewCustomAttributes = ""

			' View refer script
			' UserLevelID

			UserLevelPermissions.UserLevelID.HrefValue = ""

			' UserLevelTableName
			UserLevelPermissions.UserLevelTableName.HrefValue = ""

			' UserLevelPermission
			UserLevelPermissions.UserLevelPermission.HrefValue = ""

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

		ElseIf UserLevelPermissions.RowType = EW_ROWTYPE_EDIT Then ' Edit row

			' UserLevelID
			UserLevelPermissions.UserLevelID.EditCustomAttributes = ""
			UserLevelPermissions.UserLevelID.EditValue = UserLevelPermissions.UserLevelID.CurrentValue
			UserLevelPermissions.UserLevelID.CssStyle = ""
			UserLevelPermissions.UserLevelID.CssClass = ""
			UserLevelPermissions.UserLevelID.ViewCustomAttributes = ""

			' UserLevelTableName
			UserLevelPermissions.UserLevelTableName.EditCustomAttributes = ""
			UserLevelPermissions.UserLevelTableName.EditValue = UserLevelPermissions.UserLevelTableName.CurrentValue
			UserLevelPermissions.UserLevelTableName.CssStyle = ""
			UserLevelPermissions.UserLevelTableName.CssClass = ""
			UserLevelPermissions.UserLevelTableName.ViewCustomAttributes = ""

			' UserLevelPermission
			UserLevelPermissions.UserLevelPermission.EditCustomAttributes = ""
			UserLevelPermissions.UserLevelPermission.EditValue = ew_HtmlEncode(UserLevelPermissions.UserLevelPermission.CurrentValue)

			' Edit refer script
			' UserLevelID

			UserLevelPermissions.UserLevelID.HrefValue = ""

			' UserLevelTableName
			UserLevelPermissions.UserLevelTableName.HrefValue = ""

			' UserLevelPermission
			UserLevelPermissions.UserLevelPermission.HrefValue = ""
		End If

		' Call Row Rendered event
		Call UserLevelPermissions.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 UserLevelPermissions.UserLevelID.FormValue&"" = "" Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & "请输入必要内容 - User Level ID"
		End If
		If Not ew_CheckInteger(UserLevelPermissions.UserLevelID.FormValue) Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & "无效的整数型 - User Level ID"
		End If
		If UserLevelPermissions.UserLevelTableName.FormValue&"" = "" Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & "请输入必要内容 - User Level Table Name"
		End If
		If UserLevelPermissions.UserLevelPermission.FormValue&"" = "" Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & "请输入必要内容 - User Level Permission"
		End If
		If Not ew_CheckInteger(UserLevelPermissions.UserLevelPermission.FormValue) Then
			If gsFormError <> "" Then gsFormError = gsFormError & "<br>"
			gsFormError = gsFormError & "无效的整数型 - User Level Permission"
		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 = UserLevelPermissions.KeyFilter
		UserLevelPermissions.CurrentFilter  = sFilter
		sSql = UserLevelPermissions.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 UserLevelID
			' Field UserLevelTableName
			' Field UserLevelPermission

			Call UserLevelPermissions.UserLevelPermission.SetDbValue(UserLevelPermissions.UserLevelPermission.CurrentValue, 0)
			Rs("UserLevelPermission") = UserLevelPermissions.UserLevelPermission.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 = UserLevelPermissions.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 UserLevelPermissions.CancelMessage <> "" Then
					Message = UserLevelPermissions.CancelMessage
					UserLevelPermissions.CancelMessage = ""
				Else
					Message = "取消更新"
				End If
				EditRow = False
			End If
		End If

		' Call Row Updated event
		If EditRow Then
			Call UserLevelPermissions.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
%>
