<%
Response.Buffer = EW_RESPONSE_BUFFER
%>
<!--#include file="ewcfg11.asp"-->
<!--#include file="zxzxinfo.asp"-->
<!--#include file="zlogininfo.asp"-->
<!--#include file="aspfn11.asp"-->
<!--#include file="md5.asp"-->
<!--#include file="userfn11.asp"-->
<% Session.Timeout = 900 %>
<% Call ew_Header(False, EW_CHARSET) %>
<%

' Define page object
Dim zxzx_add
Set zxzx_add = New czxzx_add
Set Page = zxzx_add

' Page init processing
zxzx_add.Page_Init()

' Page main processing
zxzx_add.Page_Main()

' Global Page Rendering event (in userfn*.asp)
Page_Rendering()

' Page Rendering event
zxzx_add.Page_Render()
%>
<!--#include file="header.asp"-->
<script type="text/javascript">
// Page object
var zxzx_add = new ew_Page("zxzx_add");
zxzx_add.PageID = "add"; // Page ID
var EW_PAGE_ID = zxzx_add.PageID; // For backward compatibility
// Form object
var fzxzxadd = new ew_Form("fzxzxadd");
// Validate form
fzxzxadd.Validate = function() {
	if (!this.ValidateRequired)
		return true; // Ignore validation
	var $ = jQuery, fobj = this.GetForm(), $fobj = $(fobj);
	this.PostAutoSuggest();
	if ($fobj.find("#a_confirm").val() == "F")
		return true;
	var elm, felm, uelm, addcnt = 0;
	var $k = $fobj.find("#" + this.FormKeyCountName); // Get key_count
	var rowcnt = ($k[0]) ? parseInt($k.val(), 10) : 1;
	var startcnt = (rowcnt == 0) ? 0 : 1; // Check rowcnt == 0 => Inline-Add
	var gridinsert = $fobj.find("#a_list").val() == "gridinsert";
	for (var i = startcnt; i <= rowcnt; i++) {
		var infix = ($k[0]) ? String(i) : "";
		$fobj.data("rowindex", infix);
			elm = this.GetElements("x" + infix + "_zxrq");
			if (elm && !ew_CheckDate(elm.value))
				return this.OnError(elm, "<%= ew_JsEncode2(zxzx.zxrq.FldErrMsg) %>");
			// Set up row object
			ew_ElementsToRow(fobj);
			// Fire Form_CustomValidate event
			if (!this.Form_CustomValidate(fobj))
				return false;
	}
	// Process detail forms
	var dfs = $fobj.find("input[name='detailpage']").get();
	for (var i = 0; i < dfs.length; i++) {
		var df = dfs[i], val = df.value;
		if (val && ewForms[val])
			if (!ewForms[val].Validate())
				return false;
	}
	return true;
}
// Form_CustomValidate event
fzxzxadd.Form_CustomValidate = 
 function(fobj) { // DO NOT CHANGE THIS LINE!
 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
// Use JavaScript validation or not
<% If EW_CLIENT_VALIDATE Then %>
fzxzxadd.ValidateRequired = true; // Use JavaScript validation
<% Else %>
fzxzxadd.ValidateRequired = false; // No JavaScript validation
<% End If %>
// Dynamic selection lists
// Form object for search
</script>
<script type="text/javascript">
// Write your client script here, no need to add script tags.
</script>
<% If zxzx.Export = "" Then %>
<% Breadcrumb.Render() %>
<% End If %>
<% zxzx_add.ShowPageHeader() %>
<% zxzx_add.ShowMessage %>
<form name="fzxzxadd" id="fzxzxadd" class="ewForm form-inline" action="<%= ew_CurrentPage() %>" method="post">
<input type="hidden" name="t" value="zxzx">
<input type="hidden" name="a_add" id="a_add" value="A">
<table class="ewGrid"><tr><td>
<table id="tbl_zxzxadd" class="table table-bordered table-striped">
<% If zxzx.zt.Visible Then ' zt %>
	<tr id="r_zt">
		<td><span id="elh_zxzx_zt"><%= zxzx.zt.FldCaption %></span></td>
		<td<%= zxzx.zt.CellAttributes %>>
<span id="el_zxzx_zt" class="control-group">
<input type="text" data-field="x_zt" name="x_zt" id="x_zt" size="30" maxlength="50" placeholder="<%= zxzx.zt.PlaceHolder %>" value="<%= zxzx.zt.EditValue %>"<%= zxzx.zt.EditAttributes %>>
</span>
<%= zxzx.zt.CustomMsg %></td>
	</tr>
<% End If %>
<% If zxzx.zxr.Visible Then ' zxr %>
	<tr id="r_zxr">
		<td><span id="elh_zxzx_zxr"><%= zxzx.zxr.FldCaption %></span></td>
		<td<%= zxzx.zxr.CellAttributes %>>
<span id="el_zxzx_zxr" class="control-group">
<input type="text" data-field="x_zxr" name="x_zxr" id="x_zxr" size="30" maxlength="50" placeholder="<%= zxzx.zxr.PlaceHolder %>" value="<%= zxzx.zxr.EditValue %>"<%= zxzx.zxr.EditAttributes %>>
</span>
<%= zxzx.zxr.CustomMsg %></td>
	</tr>
<% End If %>
<% If zxzx.xb.Visible Then ' xb %>
	<tr id="r_xb">
		<td><span id="elh_zxzx_xb"><%= zxzx.xb.FldCaption %></span></td>
		<td<%= zxzx.xb.CellAttributes %>>
<span id="el_zxzx_xb" class="control-group">
<input type="text" data-field="x_xb" name="x_xb" id="x_xb" size="30" maxlength="50" placeholder="<%= zxzx.xb.PlaceHolder %>" value="<%= zxzx.xb.EditValue %>"<%= zxzx.xb.EditAttributes %>>
</span>
<%= zxzx.xb.CustomMsg %></td>
	</tr>
<% End If %>
<% If zxzx.gsmc.Visible Then ' gsmc %>
	<tr id="r_gsmc">
		<td><span id="elh_zxzx_gsmc"><%= zxzx.gsmc.FldCaption %></span></td>
		<td<%= zxzx.gsmc.CellAttributes %>>
<span id="el_zxzx_gsmc" class="control-group">
<input type="text" data-field="x_gsmc" name="x_gsmc" id="x_gsmc" size="30" maxlength="50" placeholder="<%= zxzx.gsmc.PlaceHolder %>" value="<%= zxzx.gsmc.EditValue %>"<%= zxzx.gsmc.EditAttributes %>>
</span>
<%= zxzx.gsmc.CustomMsg %></td>
	</tr>
<% End If %>
<% If zxzx.sf.Visible Then ' sf %>
	<tr id="r_sf">
		<td><span id="elh_zxzx_sf"><%= zxzx.sf.FldCaption %></span></td>
		<td<%= zxzx.sf.CellAttributes %>>
<span id="el_zxzx_sf" class="control-group">
<input type="text" data-field="x_sf" name="x_sf" id="x_sf" size="30" maxlength="50" placeholder="<%= zxzx.sf.PlaceHolder %>" value="<%= zxzx.sf.EditValue %>"<%= zxzx.sf.EditAttributes %>>
</span>
<%= zxzx.sf.CustomMsg %></td>
	</tr>
<% End If %>
<% If zxzx.zemail.Visible Then ' email %>
	<tr id="r_zemail">
		<td><span id="elh_zxzx_zemail"><%= zxzx.zemail.FldCaption %></span></td>
		<td<%= zxzx.zemail.CellAttributes %>>
<span id="el_zxzx_zemail" class="control-group">
<input type="text" data-field="x_zemail" name="x_zemail" id="x_zemail" size="30" maxlength="50" placeholder="<%= zxzx.zemail.PlaceHolder %>" value="<%= zxzx.zemail.EditValue %>"<%= zxzx.zemail.EditAttributes %>>
</span>
<%= zxzx.zemail.CustomMsg %></td>
	</tr>
<% End If %>
<% If zxzx.dh.Visible Then ' dh %>
	<tr id="r_dh">
		<td><span id="elh_zxzx_dh"><%= zxzx.dh.FldCaption %></span></td>
		<td<%= zxzx.dh.CellAttributes %>>
<span id="el_zxzx_dh" class="control-group">
<input type="text" data-field="x_dh" name="x_dh" id="x_dh" size="30" maxlength="50" placeholder="<%= zxzx.dh.PlaceHolder %>" value="<%= zxzx.dh.EditValue %>"<%= zxzx.dh.EditAttributes %>>
</span>
<%= zxzx.dh.CustomMsg %></td>
	</tr>
<% End If %>
<% If zxzx.cz.Visible Then ' cz %>
	<tr id="r_cz">
		<td><span id="elh_zxzx_cz"><%= zxzx.cz.FldCaption %></span></td>
		<td<%= zxzx.cz.CellAttributes %>>
<span id="el_zxzx_cz" class="control-group">
<input type="text" data-field="x_cz" name="x_cz" id="x_cz" size="30" maxlength="50" placeholder="<%= zxzx.cz.PlaceHolder %>" value="<%= zxzx.cz.EditValue %>"<%= zxzx.cz.EditAttributes %>>
</span>
<%= zxzx.cz.CustomMsg %></td>
	</tr>
<% End If %>
<% If zxzx.xxdz.Visible Then ' xxdz %>
	<tr id="r_xxdz">
		<td><span id="elh_zxzx_xxdz"><%= zxzx.xxdz.FldCaption %></span></td>
		<td<%= zxzx.xxdz.CellAttributes %>>
<span id="el_zxzx_xxdz" class="control-group">
<input type="text" data-field="x_xxdz" name="x_xxdz" id="x_xxdz" size="30" maxlength="50" placeholder="<%= zxzx.xxdz.PlaceHolder %>" value="<%= zxzx.xxdz.EditValue %>"<%= zxzx.xxdz.EditAttributes %>>
</span>
<%= zxzx.xxdz.CustomMsg %></td>
	</tr>
<% End If %>
<% If zxzx.url.Visible Then ' url %>
	<tr id="r_url">
		<td><span id="elh_zxzx_url"><%= zxzx.url.FldCaption %></span></td>
		<td<%= zxzx.url.CellAttributes %>>
<span id="el_zxzx_url" class="control-group">
<input type="text" data-field="x_url" name="x_url" id="x_url" size="30" maxlength="50" placeholder="<%= zxzx.url.PlaceHolder %>" value="<%= zxzx.url.EditValue %>"<%= zxzx.url.EditAttributes %>>
</span>
<%= zxzx.url.CustomMsg %></td>
	</tr>
<% End If %>
<% If zxzx.zxrq.Visible Then ' zxrq %>
	<tr id="r_zxrq">
		<td><span id="elh_zxzx_zxrq"><%= zxzx.zxrq.FldCaption %></span></td>
		<td<%= zxzx.zxrq.CellAttributes %>>
<span id="el_zxzx_zxrq" class="control-group">
<input type="text" data-field="x_zxrq" name="x_zxrq" id="x_zxrq" placeholder="<%= zxzx.zxrq.PlaceHolder %>" value="<%= zxzx.zxrq.EditValue %>"<%= zxzx.zxrq.EditAttributes %>>
</span>
<%= zxzx.zxrq.CustomMsg %></td>
	</tr>
<% End If %>
<% If zxzx.zxnr.Visible Then ' zxnr %>
	<tr id="r_zxnr">
		<td><span id="elh_zxzx_zxnr"><%= zxzx.zxnr.FldCaption %></span></td>
		<td<%= zxzx.zxnr.CellAttributes %>>
<span id="el_zxzx_zxnr" class="control-group">
<textarea data-field="x_zxnr" name="x_zxnr" id="x_zxnr" cols="35" rows="4" placeholder="<%= zxzx.zxnr.PlaceHolder %>"<%= zxzx.zxnr.EditAttributes %>><%= zxzx.zxnr.EditValue %></textarea>
</span>
<%= zxzx.zxnr.CustomMsg %></td>
	</tr>
<% End If %>
<% If zxzx.hf.Visible Then ' hf %>
	<tr id="r_hf">
		<td><span id="elh_zxzx_hf"><%= zxzx.hf.FldCaption %></span></td>
		<td<%= zxzx.hf.CellAttributes %>>
<span id="el_zxzx_hf" class="control-group">
<textarea data-field="x_hf" name="x_hf" id="x_hf" cols="35" rows="4" placeholder="<%= zxzx.hf.PlaceHolder %>"<%= zxzx.hf.EditAttributes %>><%= zxzx.hf.EditValue %></textarea>
</span>
<%= zxzx.hf.CustomMsg %></td>
	</tr>
<% End If %>
<% If zxzx.isshow.Visible Then ' isshow %>
	<tr id="r_isshow">
		<td><span id="elh_zxzx_isshow"><%= zxzx.isshow.FldCaption %></span></td>
		<td<%= zxzx.isshow.CellAttributes %>>
<span id="el_zxzx_isshow" class="control-group">
<div id="tp_x_isshow" class="<%= EW_ITEM_TEMPLATE_CLASSNAME %>"><input type="radio" name="x_isshow" id="x_isshow" value="{value}"<%= zxzx.isshow.EditAttributes %>></div>
<div id="dsl_x_isshow" data-repeatcolumn="5" class="ewItemList">
<%
emptywrk = True
arwrk = zxzx.isshow.EditValue
If IsArray(arwrk) Then
	rowswrk = UBound(arwrk, 2)	
	For rowcntwrk = 0 To rowswrk
		If zxzx.isshow.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 class="radio"><input type="radio" data-field="x_isshow" name="x_isshow" id="x_isshow_<%= rowcntwrk %>" value="<%= Server.HtmlEncode(arwrk(0, rowcntwrk)&"") %>"<%= selwrk %><%= zxzx.isshow.EditAttributes %>><%= arwrk(1, rowcntwrk) %></label>
<%= ew_RepeatColumnTable(rowswrk, rowcntwrk, 5, 2) %>
<%
	Next
End If
%>
</div>
</span>
<%= zxzx.isshow.CustomMsg %></td>
	</tr>
<% End If %>
</table>
</td></tr></table>
<button class="btn btn-primary ewButton" name="btnAction" id="btnAction" type="submit"><%= Language.Phrase("AddBtn") %></button>
</form>
<script type="text/javascript">
fzxzxadd.Init();
<% If EW_MOBILE_REFLOW And ew_IsMobile() Then %>
ew_Reflow();
<% End If %>
</script>
<%
zxzx_add.ShowPageFooter()
If EW_DEBUG_ENABLED Then Response.Write ew_DebugMsg()
%>
<script type="text/javascript">
// Write your table-specific startup script here
// document.write("page loaded");
</script>
<!--#include file="footer.asp"-->
<%

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

' -----------------------------------------------------------------
' Page Class
'
Class czxzx_add

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

	' Project ID
	Public Property Get ProjectID()
		ProjectID = "{9AC218D3-4571-402E-9408-D679EC504540}"
	End Property

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

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

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

	' Page Url
	Public Property Get PageUrl()
		PageUrl = ew_CurrentPage() & "?"
		If zxzx.UseTokenInUrl Then PageUrl = PageUrl & "t=" & zxzx.TableVar & "&" ' add page token
	End Property

	' Message
	Public Property Get Message()
		Message = Session(EW_SESSION_MESSAGE)
	End Property

	Public Property Let Message(v)
		Dim msg
		msg = Session(EW_SESSION_MESSAGE)
		Call ew_AddMessage(msg, v)
		Session(EW_SESSION_MESSAGE) = msg
	End Property

	Public Property Get FailureMessage()
		FailureMessage = Session(EW_SESSION_FAILURE_MESSAGE)
	End Property

	Public Property Let FailureMessage(v)
		Dim msg
		msg = Session(EW_SESSION_FAILURE_MESSAGE)
		Call ew_AddMessage(msg, v)
		Session(EW_SESSION_FAILURE_MESSAGE) = msg
	End Property

	Public Property Get SuccessMessage()
		SuccessMessage = Session(EW_SESSION_SUCCESS_MESSAGE)
	End Property

	Public Property Let SuccessMessage(v)
		Dim msg
		msg = Session(EW_SESSION_SUCCESS_MESSAGE)
		Call ew_AddMessage(msg, v)
		Session(EW_SESSION_SUCCESS_MESSAGE) = msg
	End Property

	Public Property Get WarningMessage()
		WarningMessage = Session(EW_SESSION_WARNING_MESSAGE)
	End Property

	Public Property Let WarningMessage(v)
		Dim msg
		msg = Session(EW_SESSION_WARNING_MESSAGE)
		Call ew_AddMessage(msg, v)
		Session(EW_SESSION_WARNING_MESSAGE) = msg
	End Property

	' Show Message
	Public Sub ShowMessage()
		Dim hidden, html, sMessage
		hidden = False
		html = ""

		' Message
		sMessage = Message
		Call Message_Showing(sMessage, "")
		If sMessage <> "" Then ' Message in Session, display
			If Not hidden Then sMessage = "<button type=""button"" class=""close"" data-dismiss=""alert"">&times;</button>" & sMessage
			html = html & "<div class=""alert alert-success ewSuccess"">" & sMessage & "</div>"
			Session(EW_SESSION_MESSAGE) = "" ' Clear message in Session
		End If

		' Warning message
		Dim sWarningMessage
		sWarningMessage = WarningMessage
		Call Message_Showing(sWarningMessage, "warning")
		If sWarningMessage <> "" Then ' Message in Session, display
			If Not hidden Then sWarningMessage = "<button type=""button"" class=""close"" data-dismiss=""alert"">&times;</button>" & sWarningMessage
			html = html & "<div class=""alert alert-warning ewWarning"">" & sWarningMessage & "</div>"
			Session(EW_SESSION_WARNING_MESSAGE) = "" ' Clear message in Session
		End If

		' Success message
		Dim sSuccessMessage
		sSuccessMessage = SuccessMessage
		Call Message_Showing(sSuccessMessage, "success")
		If sSuccessMessage <> "" Then ' Message in Session, display
			If Not hidden Then sSuccessMessage = "<button type=""button"" class=""close"" data-dismiss=""alert"">&times;</button>" & sSuccessMessage
			html = html & "<div class=""alert alert-success ewSuccess"">" & sSuccessMessage & "</div>"
			Session(EW_SESSION_SUCCESS_MESSAGE) = "" ' Clear message in Session
		End If

		' Failure message
		Dim sErrorMessage
		sErrorMessage = FailureMessage
		Call Message_Showing(sErrorMessage, "failure")
		If sErrorMessage <> "" Then ' Message in Session, display
			If Not hidden Then sErrorMessage = "<button type=""button"" class=""close"" data-dismiss=""alert"">&times;</button>" & sErrorMessage
			html = html & "<div class=""alert alert-error ewError"">" & sErrorMessage & "</div>"
			Session(EW_SESSION_FAILURE_MESSAGE) = "" ' Clear message in Session
		End If
		Response.Write "<table class=""ewStdTable""><tr><td><div class=""ewMessageDialog""" & ew_IIf(hidden, " style=""display: none;""", "") & ">" & html & "</div></td></tr></table>"
	End Sub
	Dim PageHeader
	Dim PageFooter

	' Show Page Header
	Public Sub ShowPageHeader()
		Dim sHeader
		sHeader = PageHeader
		Call Page_DataRendering(sHeader)
		If sHeader <> "" Then ' Header exists, display
			Response.Write "<p>" & sHeader & "</p>"
		End If
	End Sub

	' Show Page Footer
	Public Sub ShowPageFooter()
		Dim sFooter
		sFooter = PageFooter
		Call Page_DataRendered(sFooter)
		If sFooter <> "" Then ' Footer exists, display
			Response.Write "<p>" & sFooter & "</p>"
		End If
	End Sub

	' -----------------------
	'  Validate Page request
	'
	Public Function IsPageRequest()
		If zxzx.UseTokenInUrl Then
			IsPageRequest = False
			If Not (ObjForm Is Nothing) Then
				IsPageRequest = (zxzx.TableVar = ObjForm.GetValue("t"))
			End If
			If Request.QueryString("t").Count > 0 Then
				IsPageRequest = (zxzx.TableVar = Request.QueryString("t"))
			End If
		Else
			IsPageRequest = True
		End If
	End Function

	' -----------------------------------------------------------------
	'  Class initialize
	'  - init objects
	'  - open ADO connection
	'
	Private Sub Class_Initialize()
		If IsEmpty(StartTimer) Then StartTimer = Timer ' Init start time

		' Initialize language object
		If IsEmpty(Language) Then
			Set Language = New cLanguage
			Call Language.LoadPhrases()
		End If

		' Initialize table object
		If IsEmpty(zxzx) Then Set zxzx = New czxzx
		Set Table = zxzx

		' Initialize urls
		' Initialize other table object

		If IsEmpty(zlogin) Then 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 = "zxzx"

		' Open connection to the database
		If IsEmpty(Conn) Then Call ew_Connect()
	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(ProjectID & TableName)

		' Table Permission loaded event
		Call Security.TablePermission_Loaded()
		If Not Security.IsLoggedIn() Then
			Call Security.SaveLastUrl()
			Call Page_Terminate("login.asp")
		End If
		If Not Security.CanAdd Then
			Call Security.SaveLastUrl()
			Call Page_Terminate("zxzxlist.asp")
		End If

		' Create form object
		'If Request.ServerVariables("HTTP_CONTENT_TYPE") = "application/x-www-form-urlencoded" Then

			Set ObjForm = New cFormObj

		'Else
		'	Set ObjForm = ew_GetUploadObj()
		'End If

		zxzx.CurrentAction = ew_IIf(Request.QueryString("a").Count > 0, Request.QueryString("a") & "", ObjForm.GetValue("a_list") & "") ' Set up current action

		' Global page loading event (in userfn7.asp)
		Page_Loading()

		' Page load event, used in current page
		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()
		Dim sRedirectUrl
		sReDirectUrl = url
		Call Page_Redirecting(sReDirectUrl)
		If Not (Conn Is Nothing) Then Conn.Close ' Close Connection
		Set Conn = Nothing
		Set Security = Nothing
		Set zxzx = Nothing
		Set ObjForm = Nothing

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

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

	Dim DbMasterFilter, DbDetailFilter
	Dim Priv
	Dim OldRecordset
	Dim CopyRecord

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

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

		' Not post back
		Else

			' Load key values from QueryString
			CopyRecord = True
			If Request.QueryString("id").Count > 0 Then
				zxzx.id.QueryStringValue = Request.QueryString("id")
				Call zxzx.SetKey("id", zxzx.id.CurrentValue) ' Set up key
			Else
				Call zxzx.SetKey("id", "") ' Clear key
				CopyRecord = False
			End If
			If CopyRecord Then
				zxzx.CurrentAction = "C" ' Copy Record
			Else
				zxzx.CurrentAction = "I" ' Display Blank Record
				Call LoadDefaultValues() ' Load default values
			End If
		End If

		' Set up Breadcrumb
		SetupBreadcrumb()

		' Validate form if post back
		If ObjForm.GetValue("a_add")&"" <> "" Then
			If Not ValidateForm() Then
				zxzx.CurrentAction = "I" ' Form error, reset action
				zxzx.EventCancelled = True ' Event cancelled
				Call RestoreFormValues() ' Restore form values
				FailureMessage = gsFormError
			End If
		End If

		' Perform action based on action code
		Select Case zxzx.CurrentAction
			Case "I" ' Blank record, no action required
			Case "C" ' Copy an existing record
				If Not LoadRow() Then ' Load record based on key
					If FailureMessage = "" Then FailureMessage = Language.Phrase("NoRecord") ' No record found
					Call Page_Terminate("zxzxlist.asp") ' No matching record, return to list
				End If
			Case "A" ' Add new record
				zxzx.SendEmail = True ' Send email on add success
				If AddRow(OldRecordset) Then ' Add successful
					SuccessMessage = Language.Phrase("AddSuccess") ' Set up success message
					Dim sReturnUrl
					sReturnUrl = zxzx.ReturnUrl
					If ew_GetPageName(sReturnUrl) = "zxzxview.asp" Then sReturnUrl = zxzx.ViewUrl("") ' View paging, return to view page with keyurl directly
					Call Page_Terminate(sReturnUrl) ' Clean up and return
				Else
					zxzx.EventCancelled = True ' Event cancelled
					Call RestoreFormValues() ' Add failed, restore form values
				End If
		End Select

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

		' Render row
		Call zxzx.ResetAttrs()
		Call RenderRow()
	End Sub

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

		' Get upload data
	End Function

	' -----------------------------------------------------------------
	' Load default values
	'
	Function LoadDefaultValues()
		zxzx.zt.CurrentValue = Null
		zxzx.zt.OldValue = zxzx.zt.CurrentValue
		zxzx.zxr.CurrentValue = Null
		zxzx.zxr.OldValue = zxzx.zxr.CurrentValue
		zxzx.xb.CurrentValue = Null
		zxzx.xb.OldValue = zxzx.xb.CurrentValue
		zxzx.gsmc.CurrentValue = Null
		zxzx.gsmc.OldValue = zxzx.gsmc.CurrentValue
		zxzx.sf.CurrentValue = Null
		zxzx.sf.OldValue = zxzx.sf.CurrentValue
		zxzx.zemail.CurrentValue = Null
		zxzx.zemail.OldValue = zxzx.zemail.CurrentValue
		zxzx.dh.CurrentValue = Null
		zxzx.dh.OldValue = zxzx.dh.CurrentValue
		zxzx.cz.CurrentValue = Null
		zxzx.cz.OldValue = zxzx.cz.CurrentValue
		zxzx.xxdz.CurrentValue = Null
		zxzx.xxdz.OldValue = zxzx.xxdz.CurrentValue
		zxzx.url.CurrentValue = Null
		zxzx.url.OldValue = zxzx.url.CurrentValue
		zxzx.zxrq.CurrentValue = Null
		zxzx.zxrq.OldValue = zxzx.zxrq.CurrentValue
		zxzx.zxnr.CurrentValue = Null
		zxzx.zxnr.OldValue = zxzx.zxnr.CurrentValue
		zxzx.hf.CurrentValue = Null
		zxzx.hf.OldValue = zxzx.hf.CurrentValue
		zxzx.isshow.CurrentValue = "n"
	End Function

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

		' Load values from form
		If Not zxzx.zt.FldIsDetailKey Then zxzx.zt.FormValue = ObjForm.GetValue("x_zt")
		If Not zxzx.zxr.FldIsDetailKey Then zxzx.zxr.FormValue = ObjForm.GetValue("x_zxr")
		If Not zxzx.xb.FldIsDetailKey Then zxzx.xb.FormValue = ObjForm.GetValue("x_xb")
		If Not zxzx.gsmc.FldIsDetailKey Then zxzx.gsmc.FormValue = ObjForm.GetValue("x_gsmc")
		If Not zxzx.sf.FldIsDetailKey Then zxzx.sf.FormValue = ObjForm.GetValue("x_sf")
		If Not zxzx.zemail.FldIsDetailKey Then zxzx.zemail.FormValue = ObjForm.GetValue("x_zemail")
		If Not zxzx.dh.FldIsDetailKey Then zxzx.dh.FormValue = ObjForm.GetValue("x_dh")
		If Not zxzx.cz.FldIsDetailKey Then zxzx.cz.FormValue = ObjForm.GetValue("x_cz")
		If Not zxzx.xxdz.FldIsDetailKey Then zxzx.xxdz.FormValue = ObjForm.GetValue("x_xxdz")
		If Not zxzx.url.FldIsDetailKey Then zxzx.url.FormValue = ObjForm.GetValue("x_url")
		If Not zxzx.zxrq.FldIsDetailKey Then zxzx.zxrq.FormValue = ObjForm.GetValue("x_zxrq")
		If Not zxzx.zxrq.FldIsDetailKey Then zxzx.zxrq.CurrentValue = ew_UnFormatDateTime(zxzx.zxrq.CurrentValue, 5)
		If Not zxzx.zxnr.FldIsDetailKey Then zxzx.zxnr.FormValue = ObjForm.GetValue("x_zxnr")
		If Not zxzx.hf.FldIsDetailKey Then zxzx.hf.FormValue = ObjForm.GetValue("x_hf")
		If Not zxzx.isshow.FldIsDetailKey Then zxzx.isshow.FormValue = ObjForm.GetValue("x_isshow")
	End Function

	' -----------------------------------------------------------------
	' Restore form values
	'
	Function RestoreFormValues()
		Call LoadOldRecord()
		zxzx.zt.CurrentValue = zxzx.zt.FormValue
		zxzx.zxr.CurrentValue = zxzx.zxr.FormValue
		zxzx.xb.CurrentValue = zxzx.xb.FormValue
		zxzx.gsmc.CurrentValue = zxzx.gsmc.FormValue
		zxzx.sf.CurrentValue = zxzx.sf.FormValue
		zxzx.zemail.CurrentValue = zxzx.zemail.FormValue
		zxzx.dh.CurrentValue = zxzx.dh.FormValue
		zxzx.cz.CurrentValue = zxzx.cz.FormValue
		zxzx.xxdz.CurrentValue = zxzx.xxdz.FormValue
		zxzx.url.CurrentValue = zxzx.url.FormValue
		zxzx.zxrq.CurrentValue = zxzx.zxrq.FormValue
		zxzx.zxrq.CurrentValue = ew_UnFormatDateTime(zxzx.zxrq.CurrentValue, 5)
		zxzx.zxnr.CurrentValue = zxzx.zxnr.FormValue
		zxzx.hf.CurrentValue = zxzx.hf.FormValue
		zxzx.isshow.CurrentValue = zxzx.isshow.FormValue
	End Function

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

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

		' Load sql based on filter
		zxzx.CurrentFilter = sFilter
		sSql = zxzx.SQL
		Call ew_SetDebugMsg("LoadRow: " & sSql) ' Show SQL for debugging
		Set RsRow = ew_LoadRow(sSql)
		If RsRow.Eof Then
			LoadRow = False
		Else
			LoadRow = True
			RsRow.MoveFirst
			Call LoadRowValues(RsRow) ' Load row values
		End If
		RsRow.Close
		Set RsRow = Nothing
	End Function

	' -----------------------------------------------------------------
	' Load row values from recordset
	'
	Sub LoadRowValues(RsRow)
		Dim sDetailFilter
		If Not EW_DEBUG_ENABLED Then On Error Resume Next
		If RsRow.Eof Then Exit Sub

		' Call Row Selected event
		Call zxzx.Row_Selected(RsRow)
		zxzx.id.DbValue = RsRow("id")
		zxzx.zt.DbValue = RsRow("zt")
		zxzx.zxr.DbValue = RsRow("zxr")
		zxzx.xb.DbValue = RsRow("xb")
		zxzx.gsmc.DbValue = RsRow("gsmc")
		zxzx.sf.DbValue = RsRow("sf")
		zxzx.zemail.DbValue = RsRow("email")
		zxzx.dh.DbValue = RsRow("dh")
		zxzx.cz.DbValue = RsRow("cz")
		zxzx.xxdz.DbValue = RsRow("xxdz")
		zxzx.url.DbValue = RsRow("url")
		zxzx.zxrq.DbValue = RsRow("zxrq")
		zxzx.zxnr.DbValue = RsRow("zxnr")
		zxzx.hf.DbValue = RsRow("hf")
		zxzx.isshow.DbValue = RsRow("isshow")
	End Sub

	' Load DbValue from recordset
	Sub LoadDbValues(Rs)
		If Not EW_DEBUG_ENABLED Then On Error Resume Next
		If Rs.Eof Then Exit Sub
		zxzx.id.m_DbValue = Rs("id")
		zxzx.zt.m_DbValue = Rs("zt")
		zxzx.zxr.m_DbValue = Rs("zxr")
		zxzx.xb.m_DbValue = Rs("xb")
		zxzx.gsmc.m_DbValue = Rs("gsmc")
		zxzx.sf.m_DbValue = Rs("sf")
		zxzx.zemail.m_DbValue = Rs("email")
		zxzx.dh.m_DbValue = Rs("dh")
		zxzx.cz.m_DbValue = Rs("cz")
		zxzx.xxdz.m_DbValue = Rs("xxdz")
		zxzx.url.m_DbValue = Rs("url")
		zxzx.zxrq.m_DbValue = Rs("zxrq")
		zxzx.zxnr.m_DbValue = Rs("zxnr")
		zxzx.hf.m_DbValue = Rs("hf")
		zxzx.isshow.m_DbValue = Rs("isshow")
	End Sub

	' Load old record
	Function LoadOldRecord()

		' Load key values from Session
		Dim bValidKey
		bValidKey = True
		If zxzx.GetKey("id")&"" <> "" Then
			zxzx.id.CurrentValue = zxzx.GetKey("id") ' id
		Else
			bValidKey = False
		End If

		' Load old recordset
		If bValidKey Then
			zxzx.CurrentFilter = zxzx.KeyFilter
			Dim sSql
			sSql = zxzx.SQL
			Set OldRecordset = ew_LoadRecordset(sSql)
			Call LoadRowValues(OldRecordset) ' Load row values
		Else
			OldRecordset = Null
		End If
		LoadOldRecord = bValidKey
	End Function

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

		' Initialize urls
		' Call Row Rendering event

		Call zxzx.Row_Rendering()

		' ---------------------------------------
		'  Common render codes for all row types
		' ---------------------------------------
		' id
		' zt
		' zxr
		' xb
		' gsmc
		' sf
		' email
		' dh
		' cz
		' xxdz
		' url
		' zxrq
		' zxnr
		' hf
		' isshow
		' -----------
		'  View  Row
		' -----------

		If zxzx.RowType = EW_ROWTYPE_VIEW Then ' View row

			' id
			zxzx.id.ViewValue = zxzx.id.CurrentValue
			zxzx.id.ViewCustomAttributes = ""

			' zt
			zxzx.zt.ViewValue = zxzx.zt.CurrentValue
			zxzx.zt.ViewCustomAttributes = ""

			' zxr
			zxzx.zxr.ViewValue = zxzx.zxr.CurrentValue
			zxzx.zxr.ViewCustomAttributes = ""

			' xb
			zxzx.xb.ViewValue = zxzx.xb.CurrentValue
			zxzx.xb.ViewCustomAttributes = ""

			' gsmc
			zxzx.gsmc.ViewValue = zxzx.gsmc.CurrentValue
			zxzx.gsmc.ViewCustomAttributes = ""

			' sf
			zxzx.sf.ViewValue = zxzx.sf.CurrentValue
			zxzx.sf.ViewCustomAttributes = ""

			' email
			zxzx.zemail.ViewValue = zxzx.zemail.CurrentValue
			zxzx.zemail.ViewCustomAttributes = ""

			' dh
			zxzx.dh.ViewValue = zxzx.dh.CurrentValue
			zxzx.dh.ViewCustomAttributes = ""

			' cz
			zxzx.cz.ViewValue = zxzx.cz.CurrentValue
			zxzx.cz.ViewCustomAttributes = ""

			' xxdz
			zxzx.xxdz.ViewValue = zxzx.xxdz.CurrentValue
			zxzx.xxdz.ViewCustomAttributes = ""

			' url
			zxzx.url.ViewValue = zxzx.url.CurrentValue
			zxzx.url.ViewCustomAttributes = ""

			' zxrq
			zxzx.zxrq.ViewValue = zxzx.zxrq.CurrentValue
			zxzx.zxrq.ViewValue = ew_FormatDateTime(zxzx.zxrq.ViewValue, 5)
			zxzx.zxrq.ViewCustomAttributes = ""

			' zxnr
			zxzx.zxnr.ViewValue = zxzx.zxnr.CurrentValue
			If Not IsNull(zxzx.zxnr.ViewValue) Then
				zxzx.zxnr.ViewValue = Replace(zxzx.zxnr.ViewValue, vbLf, "<br>")
			End If
			zxzx.zxnr.ViewCustomAttributes = ""

			' hf
			zxzx.hf.ViewValue = zxzx.hf.CurrentValue
			If Not IsNull(zxzx.hf.ViewValue) Then
				zxzx.hf.ViewValue = Replace(zxzx.hf.ViewValue, vbLf, "<br>")
			End If
			zxzx.hf.ViewCustomAttributes = ""

			' isshow
			If Not IsNull(zxzx.isshow.CurrentValue) Then
				Select Case zxzx.isshow.CurrentValue & ""
					Case zxzx.isshow.FldTagValue(1)
						zxzx.isshow.ViewValue = ew_IIf(zxzx.isshow.FldTagCaption(1) <> "", zxzx.isshow.FldTagCaption(1), zxzx.isshow.CurrentValue)
					Case zxzx.isshow.FldTagValue(2)
						zxzx.isshow.ViewValue = ew_IIf(zxzx.isshow.FldTagCaption(2) <> "", zxzx.isshow.FldTagCaption(2), zxzx.isshow.CurrentValue)
					Case Else
						zxzx.isshow.ViewValue = zxzx.isshow.CurrentValue
				End Select
			Else
				zxzx.isshow.ViewValue = Null
			End If
			zxzx.isshow.ViewCustomAttributes = ""

			' View refer script
			' zt

			zxzx.zt.LinkCustomAttributes = ""
			zxzx.zt.HrefValue = ""
			zxzx.zt.TooltipValue = ""

			' zxr
			zxzx.zxr.LinkCustomAttributes = ""
			zxzx.zxr.HrefValue = ""
			zxzx.zxr.TooltipValue = ""

			' xb
			zxzx.xb.LinkCustomAttributes = ""
			zxzx.xb.HrefValue = ""
			zxzx.xb.TooltipValue = ""

			' gsmc
			zxzx.gsmc.LinkCustomAttributes = ""
			zxzx.gsmc.HrefValue = ""
			zxzx.gsmc.TooltipValue = ""

			' sf
			zxzx.sf.LinkCustomAttributes = ""
			zxzx.sf.HrefValue = ""
			zxzx.sf.TooltipValue = ""

			' email
			zxzx.zemail.LinkCustomAttributes = ""
			zxzx.zemail.HrefValue = ""
			zxzx.zemail.TooltipValue = ""

			' dh
			zxzx.dh.LinkCustomAttributes = ""
			zxzx.dh.HrefValue = ""
			zxzx.dh.TooltipValue = ""

			' cz
			zxzx.cz.LinkCustomAttributes = ""
			zxzx.cz.HrefValue = ""
			zxzx.cz.TooltipValue = ""

			' xxdz
			zxzx.xxdz.LinkCustomAttributes = ""
			zxzx.xxdz.HrefValue = ""
			zxzx.xxdz.TooltipValue = ""

			' url
			zxzx.url.LinkCustomAttributes = ""
			zxzx.url.HrefValue = ""
			zxzx.url.TooltipValue = ""

			' zxrq
			zxzx.zxrq.LinkCustomAttributes = ""
			zxzx.zxrq.HrefValue = ""
			zxzx.zxrq.TooltipValue = ""

			' zxnr
			zxzx.zxnr.LinkCustomAttributes = ""
			zxzx.zxnr.HrefValue = ""
			zxzx.zxnr.TooltipValue = ""

			' hf
			zxzx.hf.LinkCustomAttributes = ""
			zxzx.hf.HrefValue = ""
			zxzx.hf.TooltipValue = ""

			' isshow
			zxzx.isshow.LinkCustomAttributes = ""
			zxzx.isshow.HrefValue = ""
			zxzx.isshow.TooltipValue = ""

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

		ElseIf zxzx.RowType = EW_ROWTYPE_ADD Then ' Add row

			' zt
			zxzx.zt.EditCustomAttributes = ""
			zxzx.zt.EditValue = ew_HtmlEncode(zxzx.zt.CurrentValue)
			zxzx.zt.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(zxzx.zt.FldCaption))

			' zxr
			zxzx.zxr.EditCustomAttributes = ""
			zxzx.zxr.EditValue = ew_HtmlEncode(zxzx.zxr.CurrentValue)
			zxzx.zxr.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(zxzx.zxr.FldCaption))

			' xb
			zxzx.xb.EditCustomAttributes = ""
			zxzx.xb.EditValue = ew_HtmlEncode(zxzx.xb.CurrentValue)
			zxzx.xb.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(zxzx.xb.FldCaption))

			' gsmc
			zxzx.gsmc.EditCustomAttributes = ""
			zxzx.gsmc.EditValue = ew_HtmlEncode(zxzx.gsmc.CurrentValue)
			zxzx.gsmc.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(zxzx.gsmc.FldCaption))

			' sf
			zxzx.sf.EditCustomAttributes = ""
			zxzx.sf.EditValue = ew_HtmlEncode(zxzx.sf.CurrentValue)
			zxzx.sf.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(zxzx.sf.FldCaption))

			' email
			zxzx.zemail.EditCustomAttributes = ""
			zxzx.zemail.EditValue = ew_HtmlEncode(zxzx.zemail.CurrentValue)
			zxzx.zemail.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(zxzx.zemail.FldCaption))

			' dh
			zxzx.dh.EditCustomAttributes = ""
			zxzx.dh.EditValue = ew_HtmlEncode(zxzx.dh.CurrentValue)
			zxzx.dh.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(zxzx.dh.FldCaption))

			' cz
			zxzx.cz.EditCustomAttributes = ""
			zxzx.cz.EditValue = ew_HtmlEncode(zxzx.cz.CurrentValue)
			zxzx.cz.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(zxzx.cz.FldCaption))

			' xxdz
			zxzx.xxdz.EditCustomAttributes = ""
			zxzx.xxdz.EditValue = ew_HtmlEncode(zxzx.xxdz.CurrentValue)
			zxzx.xxdz.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(zxzx.xxdz.FldCaption))

			' url
			zxzx.url.EditCustomAttributes = ""
			zxzx.url.EditValue = ew_HtmlEncode(zxzx.url.CurrentValue)
			zxzx.url.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(zxzx.url.FldCaption))

			' zxrq
			zxzx.zxrq.EditCustomAttributes = ""
			zxzx.zxrq.EditValue = ew_FormatDateTime(zxzx.zxrq.CurrentValue, 5)
			zxzx.zxrq.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(zxzx.zxrq.FldCaption))

			' zxnr
			zxzx.zxnr.EditCustomAttributes = ""
			zxzx.zxnr.EditValue = zxzx.zxnr.CurrentValue
			zxzx.zxnr.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(zxzx.zxnr.FldCaption))

			' hf
			zxzx.hf.EditCustomAttributes = ""
			zxzx.hf.EditValue = zxzx.hf.CurrentValue
			zxzx.hf.PlaceHolder = ew_HtmlEncode(ew_RemoveHtml(zxzx.hf.FldCaption))

			' isshow
			zxzx.isshow.EditCustomAttributes = ""
			Redim arwrk(1, 1)
			arwrk(0, 0) = zxzx.isshow.FldTagValue(1)
			arwrk(1, 0) = ew_IIf(zxzx.isshow.FldTagCaption(1) <> "", zxzx.isshow.FldTagCaption(1), zxzx.isshow.FldTagValue(1))
			arwrk(0, 1) = zxzx.isshow.FldTagValue(2)
			arwrk(1, 1) = ew_IIf(zxzx.isshow.FldTagCaption(2) <> "", zxzx.isshow.FldTagCaption(2), zxzx.isshow.FldTagValue(2))
			zxzx.isshow.EditValue = arwrk

			' Edit refer script
			' zt

			zxzx.zt.HrefValue = ""

			' zxr
			zxzx.zxr.HrefValue = ""

			' xb
			zxzx.xb.HrefValue = ""

			' gsmc
			zxzx.gsmc.HrefValue = ""

			' sf
			zxzx.sf.HrefValue = ""

			' email
			zxzx.zemail.HrefValue = ""

			' dh
			zxzx.dh.HrefValue = ""

			' cz
			zxzx.cz.HrefValue = ""

			' xxdz
			zxzx.xxdz.HrefValue = ""

			' url
			zxzx.url.HrefValue = ""

			' zxrq
			zxzx.zxrq.HrefValue = ""

			' zxnr
			zxzx.zxnr.HrefValue = ""

			' hf
			zxzx.hf.HrefValue = ""

			' isshow
			zxzx.isshow.HrefValue = ""
		End If
		If zxzx.RowType = EW_ROWTYPE_ADD Or zxzx.RowType = EW_ROWTYPE_EDIT Or zxzx.RowType = EW_ROWTYPE_SEARCH Then ' Add / Edit / Search row
			Call zxzx.SetupFieldTitles()
		End If

		' Call Row Rendered event
		If zxzx.RowType <> EW_ROWTYPE_AGGREGATEINIT Then
			Call zxzx.Row_Rendered()
		End If
	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_CheckDate(zxzx.zxrq.FormValue) Then
			Call ew_AddMessage(gsFormError, zxzx.zxrq.FldErrMsg)
		End If

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

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

	' -----------------------------------------------------------------
	' Add record
	'
	Function AddRow(RsOld)
		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
		Dim RsMaster, sMasterUserIdMsg, sMasterFilter, bCheckMasterRecord

		' Load db values from rsold
		If Not IsNull(RsOld) Then
			Call LoadDbValues(RsOld)
		End If

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

		' Field zt
		Call zxzx.zt.SetDbValue(Rs, zxzx.zt.CurrentValue, Null, False)

		' Field zxr
		Call zxzx.zxr.SetDbValue(Rs, zxzx.zxr.CurrentValue, Null, False)

		' Field xb
		Call zxzx.xb.SetDbValue(Rs, zxzx.xb.CurrentValue, Null, False)

		' Field gsmc
		Call zxzx.gsmc.SetDbValue(Rs, zxzx.gsmc.CurrentValue, Null, False)

		' Field sf
		Call zxzx.sf.SetDbValue(Rs, zxzx.sf.CurrentValue, Null, False)

		' Field email
		Call zxzx.zemail.SetDbValue(Rs, zxzx.zemail.CurrentValue, Null, False)

		' Field dh
		Call zxzx.dh.SetDbValue(Rs, zxzx.dh.CurrentValue, Null, False)

		' Field cz
		Call zxzx.cz.SetDbValue(Rs, zxzx.cz.CurrentValue, Null, False)

		' Field xxdz
		Call zxzx.xxdz.SetDbValue(Rs, zxzx.xxdz.CurrentValue, Null, False)

		' Field url
		Call zxzx.url.SetDbValue(Rs, zxzx.url.CurrentValue, Null, False)

		' Field zxrq
		Call zxzx.zxrq.SetDbValue(Rs, ew_UnFormatDateTime(zxzx.zxrq.CurrentValue, 5), Null, False)

		' Field zxnr
		Call zxzx.zxnr.SetDbValue(Rs, zxzx.zxnr.CurrentValue, Null, False)

		' Field hf
		Call zxzx.hf.SetDbValue(Rs, zxzx.hf.CurrentValue, Null, False)

		' Field isshow
		Call zxzx.isshow.SetDbValue(Rs, zxzx.isshow.CurrentValue, Null, (zxzx.isshow.CurrentValue&"" = ""))

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

		' Call Row Inserting event
		bInsertRow = zxzx.Row_Inserting(RsOld, Rs)
		If bInsertRow Then

			' Clone new recordset object
			Set RsNew = ew_CloneRs(Rs)
			Rs.Update
			If Err.Number <> 0 Then
				FailureMessage = Err.Description
				AddRow = False
			Else
				AddRow = True
			End If
			If AddRow Then
			End If
		Else
			Rs.CancelUpdate

			' Set up error message
			If SuccessMessage <> "" Or FailureMessage <> "" Then

				' Use the message, do nothing
			ElseIf zxzx.CancelMessage <> "" Then
				FailureMessage = zxzx.CancelMessage
				zxzx.CancelMessage = ""
			Else
				FailureMessage = Language.Phrase("InsertCancelled")
			End If
			AddRow = False
		End If
		Rs.Close
		Set Rs = Nothing
		If AddRow Then
			zxzx.id.DbValue = RsNew("id")
		End If
		If AddRow Then

			' Call Row Inserted event
			Call zxzx.Row_Inserted(RsOld, RsNew)
		End If
		If IsObject(RsNew) Then
			RsNew.Close
			Set RsNew = Nothing
		End If
	End Function

	' Set up Breadcrumb
	Sub SetupBreadcrumb()
		Dim PageId, url
		Set Breadcrumb = New cBreadcrumb
		Call Breadcrumb.Add("list", zxzx.TableVar, "zxzxlist.asp", zxzx.TableVar, True)
		PageId = ew_IIf(zxzx.CurrentAction = "C", "Copy", "Add")
		Call Breadcrumb.Add("add", PageId, ew_CurrentUrl, "", False)
	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

	' Page Redirecting event
	Sub Page_Redirecting(url)

		'url = newurl
	End Sub

	' Message Showing event
	' typ = ""|"success"|"failure"|"warning"
	Sub Message_Showing(msg, typ)

		' Example:
		'If typ = "success" Then
		'	msg = "your success message"
		'ElseIf typ = "failure" Then
		'	msg = "your failure message"
		'ElseIf typ = "warning" Then
		'	msg = "your warning message"
		'Else
		'	msg = "your message"
		'End If

	End Sub

	' Page Render event
	Sub Page_Render()

		'Response.Write "Page Render"
	End Sub

	' Page Data Rendering event
	Sub Page_DataRendering(header)

		' Example:
		'header = "your header"

	End Sub

	' Page Data Rendered event
	Sub Page_DataRendered(footer)

		' Example:
		'footer = "your footer"

	End Sub

	' Form Custom Validate event
	Function Form_CustomValidate(CustomError)

		'Return error message in CustomError
		Form_CustomValidate = True
	End Function
End Class
%>
