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

' Page init processing
Call zxzx_add.Page_Init()

' Page main processing
Call zxzx_add.Page_Main()
%>
<!--#include file="header.asp"-->
<script type="text/javascript">
<!--
// Create page object
var zxzx_add = new ew_Page("zxzx_add");
// page properties
zxzx_add.PageID = "add"; // page ID
var EW_PAGE_ID = zxzx_add.PageID; // for backward compatibility
// extend page with ValidateForm function
zxzx_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) : "";
		elm = fobj.elements["x" + infix + "_zxrq"];
		if (elm && !ew_CheckDate(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
zxzx_add.Form_CustomValidate = 
 function(fobj) { // DO NOT CHANGE THIS LINE!
 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
zxzx_add.SelectAllKey = function(elem) {
	ew_SelectAll(elem);
}
<% If EW_CLIENT_VALIDATE Then %>
zxzx_add.ValidateRequired = true; // uses JavaScript validation
<% Else %>
zxzx_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="<%= zxzx.ReturnUrl %>">返回</a></span></p>
<% zxzx_add.ShowMessage %>
<form name="fzxzxadd" id="fzxzxadd" action="<%= ew_CurrentPage %>" method="post" onsubmit="return zxzx_add.ValidateForm(this);">
<p>
<input type="hidden" name="t" id="t" value="zxzx">
<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 zxzx.zt.Visible Then ' zt %>
	<tr<%= zxzx.zt.RowAttributes %>>
		<td class="ewTableHeader">主题</td>
		<td<%= zxzx.zt.CellAttributes %>><span id="el_zt">
<input type="text" name="x_zt" id="x_zt" size="30" maxlength="50" value="<%= zxzx.zt.EditValue %>"<%= zxzx.zt.EditAttributes %>>
</span><%= zxzx.zt.CustomMsg %></td>
	</tr>
<% End If %>
<% If zxzx.zxr.Visible Then ' zxr %>
	<tr<%= zxzx.zxr.RowAttributes %>>
		<td class="ewTableHeader">咨询人</td>
		<td<%= zxzx.zxr.CellAttributes %>><span id="el_zxr">
<input type="text" name="x_zxr" id="x_zxr" size="30" maxlength="50" value="<%= zxzx.zxr.EditValue %>"<%= zxzx.zxr.EditAttributes %>>
</span><%= zxzx.zxr.CustomMsg %></td>
	</tr>
<% End If %>
<% If zxzx.xb.Visible Then ' xb %>
	<tr<%= zxzx.xb.RowAttributes %>>
		<td class="ewTableHeader">性别</td>
		<td<%= zxzx.xb.CellAttributes %>><span id="el_xb">
<input type="text" name="x_xb" id="x_xb" size="30" maxlength="50" value="<%= zxzx.xb.EditValue %>"<%= zxzx.xb.EditAttributes %>>
</span><%= zxzx.xb.CustomMsg %></td>
	</tr>
<% End If %>
<% If zxzx.gsmc.Visible Then ' gsmc %>
	<tr<%= zxzx.gsmc.RowAttributes %>>
		<td class="ewTableHeader">公司名称</td>
		<td<%= zxzx.gsmc.CellAttributes %>><span id="el_gsmc">
<input type="text" name="x_gsmc" id="x_gsmc" size="30" maxlength="50" value="<%= zxzx.gsmc.EditValue %>"<%= zxzx.gsmc.EditAttributes %>>
</span><%= zxzx.gsmc.CustomMsg %></td>
	</tr>
<% End If %>
<% If zxzx.sf.Visible Then ' sf %>
	<tr<%= zxzx.sf.RowAttributes %>>
		<td class="ewTableHeader">省份</td>
		<td<%= zxzx.sf.CellAttributes %>><span id="el_sf">
<input type="text" name="x_sf" id="x_sf" size="30" maxlength="50" value="<%= zxzx.sf.EditValue %>"<%= zxzx.sf.EditAttributes %>>
</span><%= zxzx.sf.CustomMsg %></td>
	</tr>
<% End If %>
<% If zxzx.zemail.Visible Then ' email %>
	<tr<%= zxzx.zemail.RowAttributes %>>
		<td class="ewTableHeader">Email</td>
		<td<%= zxzx.zemail.CellAttributes %>><span id="el_zemail">
<input type="text" name="x_zemail" id="x_zemail" size="30" maxlength="50" value="<%= zxzx.zemail.EditValue %>"<%= zxzx.zemail.EditAttributes %>>
</span><%= zxzx.zemail.CustomMsg %></td>
	</tr>
<% End If %>
<% If zxzx.dh.Visible Then ' dh %>
	<tr<%= zxzx.dh.RowAttributes %>>
		<td class="ewTableHeader">电话</td>
		<td<%= zxzx.dh.CellAttributes %>><span id="el_dh">
<input type="text" name="x_dh" id="x_dh" size="30" maxlength="50" value="<%= zxzx.dh.EditValue %>"<%= zxzx.dh.EditAttributes %>>
</span><%= zxzx.dh.CustomMsg %></td>
	</tr>
<% End If %>
<% If zxzx.cz.Visible Then ' cz %>
	<tr<%= zxzx.cz.RowAttributes %>>
		<td class="ewTableHeader">传真</td>
		<td<%= zxzx.cz.CellAttributes %>><span id="el_cz">
<input type="text" name="x_cz" id="x_cz" size="30" maxlength="50" value="<%= zxzx.cz.EditValue %>"<%= zxzx.cz.EditAttributes %>>
</span><%= zxzx.cz.CustomMsg %></td>
	</tr>
<% End If %>
<% If zxzx.xxdz.Visible Then ' xxdz %>
	<tr<%= zxzx.xxdz.RowAttributes %>>
		<td class="ewTableHeader">详细地址</td>
		<td<%= zxzx.xxdz.CellAttributes %>><span id="el_xxdz">
<input type="text" name="x_xxdz" id="x_xxdz" size="30" maxlength="50" value="<%= zxzx.xxdz.EditValue %>"<%= zxzx.xxdz.EditAttributes %>>
</span><%= zxzx.xxdz.CustomMsg %></td>
	</tr>
<% End If %>
<% If zxzx.url.Visible Then ' url %>
	<tr<%= zxzx.url.RowAttributes %>>
		<td class="ewTableHeader">网址</td>
		<td<%= zxzx.url.CellAttributes %>><span id="el_url">
<input type="text" name="x_url" id="x_url" size="30" maxlength="50" value="<%= zxzx.url.EditValue %>"<%= zxzx.url.EditAttributes %>>
</span><%= zxzx.url.CustomMsg %></td>
	</tr>
<% End If %>
<% If zxzx.zxrq.Visible Then ' zxrq %>
	<tr<%= zxzx.zxrq.RowAttributes %>>
		<td class="ewTableHeader">咨询日期</td>
		<td<%= zxzx.zxrq.CellAttributes %>><span id="el_zxrq">
<input type="text" name="x_zxrq" id="x_zxrq" value="<%= zxzx.zxrq.EditValue %>"<%= zxzx.zxrq.EditAttributes %>>
</span><%= zxzx.zxrq.CustomMsg %></td>
	</tr>
<% End If %>
<% If zxzx.zxnr.Visible Then ' zxnr %>
	<tr<%= zxzx.zxnr.RowAttributes %>>
		<td class="ewTableHeader">咨询内容</td>
		<td<%= zxzx.zxnr.CellAttributes %>><span id="el_zxnr">
<textarea name="x_zxnr" id="x_zxnr" cols="35" rows="4"<%= zxzx.zxnr.EditAttributes %>><%= zxzx.zxnr.EditValue %></textarea>
</span><%= zxzx.zxnr.CustomMsg %></td>
	</tr>
<% End If %>
<% If zxzx.hf.Visible Then ' hf %>
	<tr<%= zxzx.hf.RowAttributes %>>
		<td class="ewTableHeader">回复</td>
		<td<%= zxzx.hf.CellAttributes %>><span id="el_hf">
<textarea name="x_hf" id="x_hf" cols="35" rows="4"<%= zxzx.hf.EditAttributes %>><%= zxzx.hf.EditValue %></textarea>
</span><%= zxzx.hf.CustomMsg %></td>
	</tr>
<% End If %>
<% If zxzx.isshow.Visible Then ' isshow %>
	<tr<%= zxzx.isshow.RowAttributes %>>
		<td class="ewTableHeader">审核</td>
		<td<%= zxzx.isshow.CellAttributes %>><span id="el_isshow">
<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" repeatcolumn="5">
<%
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><input type="radio" name="x_isshow" id="x_isshow" 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>
</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 zxzx_add = Nothing
%>
<%

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

	' Page ID
	Public Property Get PageID()
		PageID = "add"
	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)
		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 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()

		' Initialize table object
		Set zxzx = New czxzx

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

		' 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("zxzxlist.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 zxzx = 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("id").Count > 0 Then
			zxzx.id.QueryStringValue = Request.QueryString("id")
		Else
			bCopy = False
		End If

		' Create form object
		Set ObjForm = New cFormObj

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

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

		' Not post back
		Else
			If bCopy Then
				zxzx.CurrentAction = "C" ' Copy Record
			Else
				zxzx.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 zxzx.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("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() Then ' Add successful
					Message = "记录增加成功" ' 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
					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 RenderRow()
	End Sub

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

		' Get upload data
	End Function

	' -----------------------------------------------------------------
	' Load default values
	'
	Function LoadDefaultValues()
		zxzx.isshow.CurrentValue = "n"
	End Function

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

		' Load values from form
		zxzx.zt.FormValue = ObjForm.GetValue("x_zt")
		zxzx.zt.OldValue = ObjForm.GetValue("o_zt")
		zxzx.zxr.FormValue = ObjForm.GetValue("x_zxr")
		zxzx.zxr.OldValue = ObjForm.GetValue("o_zxr")
		zxzx.xb.FormValue = ObjForm.GetValue("x_xb")
		zxzx.xb.OldValue = ObjForm.GetValue("o_xb")
		zxzx.gsmc.FormValue = ObjForm.GetValue("x_gsmc")
		zxzx.gsmc.OldValue = ObjForm.GetValue("o_gsmc")
		zxzx.sf.FormValue = ObjForm.GetValue("x_sf")
		zxzx.sf.OldValue = ObjForm.GetValue("o_sf")
		zxzx.zemail.FormValue = ObjForm.GetValue("x_zemail")
		zxzx.zemail.OldValue = ObjForm.GetValue("o_zemail")
		zxzx.dh.FormValue = ObjForm.GetValue("x_dh")
		zxzx.dh.OldValue = ObjForm.GetValue("o_dh")
		zxzx.cz.FormValue = ObjForm.GetValue("x_cz")
		zxzx.cz.OldValue = ObjForm.GetValue("o_cz")
		zxzx.xxdz.FormValue = ObjForm.GetValue("x_xxdz")
		zxzx.xxdz.OldValue = ObjForm.GetValue("o_xxdz")
		zxzx.url.FormValue = ObjForm.GetValue("x_url")
		zxzx.url.OldValue = ObjForm.GetValue("o_url")
		zxzx.zxrq.FormValue = ObjForm.GetValue("x_zxrq")
		zxzx.zxrq.CurrentValue = ew_UnFormatDateTime(zxzx.zxrq.CurrentValue, 5)
		zxzx.zxrq.OldValue = ObjForm.GetValue("o_zxrq")
		zxzx.zxnr.FormValue = ObjForm.GetValue("x_zxnr")
		zxzx.zxnr.OldValue = ObjForm.GetValue("o_zxnr")
		zxzx.hf.FormValue = ObjForm.GetValue("x_hf")
		zxzx.hf.OldValue = ObjForm.GetValue("o_hf")
		zxzx.isshow.FormValue = ObjForm.GetValue("x_isshow")
		zxzx.isshow.OldValue = ObjForm.GetValue("o_isshow")
		zxzx.id.FormValue = ObjForm.GetValue("x_id")
	End Function

	' -----------------------------------------------------------------
	' Restore form values
	'
	Function RestoreFormValues()
		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
		zxzx.id.CurrentValue = zxzx.id.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
		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 zxzx.Row_Selected(RsRow)
		End If
		RsRow.Close
		Set RsRow = Nothing
	End Function

	' -----------------------------------------------------------------
	' Load row values from recordset
	'
	Sub LoadRowValues(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

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

		' Call Row Rendering event
		Call zxzx.Row_Rendering()

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

		zxzx.zt.CellCssStyle = ""
		zxzx.zt.CellCssClass = ""

		' zxr
		zxzx.zxr.CellCssStyle = ""
		zxzx.zxr.CellCssClass = ""

		' xb
		zxzx.xb.CellCssStyle = ""
		zxzx.xb.CellCssClass = ""

		' gsmc
		zxzx.gsmc.CellCssStyle = ""
		zxzx.gsmc.CellCssClass = ""

		' sf
		zxzx.sf.CellCssStyle = ""
		zxzx.sf.CellCssClass = ""

		' email
		zxzx.zemail.CellCssStyle = ""
		zxzx.zemail.CellCssClass = ""

		' dh
		zxzx.dh.CellCssStyle = ""
		zxzx.dh.CellCssClass = ""

		' cz
		zxzx.cz.CellCssStyle = ""
		zxzx.cz.CellCssClass = ""

		' xxdz
		zxzx.xxdz.CellCssStyle = ""
		zxzx.xxdz.CellCssClass = ""

		' url
		zxzx.url.CellCssStyle = ""
		zxzx.url.CellCssClass = ""

		' zxrq
		zxzx.zxrq.CellCssStyle = ""
		zxzx.zxrq.CellCssClass = ""

		' zxnr
		zxzx.zxnr.CellCssStyle = ""
		zxzx.zxnr.CellCssClass = ""

		' hf
		zxzx.hf.CellCssStyle = ""
		zxzx.hf.CellCssClass = ""

		' isshow
		zxzx.isshow.CellCssStyle = ""
		zxzx.isshow.CellCssClass = ""

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

		If zxzx.RowType = EW_ROWTYPE_VIEW Then ' View row

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

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

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

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

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

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

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

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

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

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

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

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

			' zxnr
			zxzx.zxnr.ViewValue = zxzx.zxnr.CurrentValue
			zxzx.zxnr.CssStyle = ""
			zxzx.zxnr.CssClass = ""
			zxzx.zxnr.ViewCustomAttributes = ""

			' hf
			zxzx.hf.ViewValue = zxzx.hf.CurrentValue
			zxzx.hf.CssStyle = ""
			zxzx.hf.CssClass = ""
			zxzx.hf.ViewCustomAttributes = ""

			' isshow
			If Not IsNull(zxzx.isshow.CurrentValue) Then
				Select Case zxzx.isshow.CurrentValue
					Case "0"
						zxzx.isshow.ViewValue = "否"
					Case "1"
						zxzx.isshow.ViewValue = "是"
					Case Else
						zxzx.isshow.ViewValue = zxzx.isshow.CurrentValue
				End Select
			Else
				zxzx.isshow.ViewValue = Null
			End If
			zxzx.isshow.CssStyle = ""
			zxzx.isshow.CssClass = ""
			zxzx.isshow.ViewCustomAttributes = ""

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

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

		ElseIf zxzx.RowType = EW_ROWTYPE_ADD Then ' Add row

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

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

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

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

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

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

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

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

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

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

			' zxrq
			zxzx.zxrq.EditCustomAttributes = ""
			zxzx.zxrq.EditValue = ew_FormatDateTime(zxzx.zxrq.CurrentValue, 5)

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

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

			' isshow
			zxzx.isshow.EditCustomAttributes = ""
			Redim arwrk(1, 1)
			arwrk(0, 0) = "0"
			arwrk(1, 0) = "否"
			arwrk(0, 1) = "1"
			arwrk(1, 1) = "是"
			zxzx.isshow.EditValue = arwrk
		End If

		' Call Row Rendered event
		Call zxzx.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_CheckDate(zxzx.zxrq.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

	' -----------------------------------------------------------------
	' 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)"
		zxzx.CurrentFilter = sFilter
		sSql = zxzx.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 zt
		Call zxzx.zt.SetDbValue(zxzx.zt.CurrentValue, Null)
		Rs("zt") = zxzx.zt.DbValue

		' Field zxr
		Call zxzx.zxr.SetDbValue(zxzx.zxr.CurrentValue, Null)
		Rs("zxr") = zxzx.zxr.DbValue

		' Field xb
		Call zxzx.xb.SetDbValue(zxzx.xb.CurrentValue, Null)
		Rs("xb") = zxzx.xb.DbValue

		' Field gsmc
		Call zxzx.gsmc.SetDbValue(zxzx.gsmc.CurrentValue, Null)
		Rs("gsmc") = zxzx.gsmc.DbValue

		' Field sf
		Call zxzx.sf.SetDbValue(zxzx.sf.CurrentValue, Null)
		Rs("sf") = zxzx.sf.DbValue

		' Field email
		Call zxzx.zemail.SetDbValue(zxzx.zemail.CurrentValue, Null)
		Rs("email") = zxzx.zemail.DbValue

		' Field dh
		Call zxzx.dh.SetDbValue(zxzx.dh.CurrentValue, Null)
		Rs("dh") = zxzx.dh.DbValue

		' Field cz
		Call zxzx.cz.SetDbValue(zxzx.cz.CurrentValue, Null)
		Rs("cz") = zxzx.cz.DbValue

		' Field xxdz
		Call zxzx.xxdz.SetDbValue(zxzx.xxdz.CurrentValue, Null)
		Rs("xxdz") = zxzx.xxdz.DbValue

		' Field url
		Call zxzx.url.SetDbValue(zxzx.url.CurrentValue, Null)
		Rs("url") = zxzx.url.DbValue

		' Field zxrq
		Call zxzx.zxrq.SetDbValue(ew_UnFormatDateTime(zxzx.zxrq.CurrentValue, 5), Null)
		Rs("zxrq") = zxzx.zxrq.DbValue

		' Field zxnr
		Call zxzx.zxnr.SetDbValue(zxzx.zxnr.CurrentValue, Null)
		Rs("zxnr") = zxzx.zxnr.DbValue

		' Field hf
		Call zxzx.hf.SetDbValue(zxzx.hf.CurrentValue, Null)
		Rs("hf") = zxzx.hf.DbValue

		' Field isshow
		Call zxzx.isshow.SetDbValue(zxzx.isshow.CurrentValue, Null)
		Rs("isshow") = zxzx.isshow.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 = zxzx.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 zxzx.CancelMessage <> "" Then
				Message = zxzx.CancelMessage
				zxzx.CancelMessage = ""
			Else
				Message = "插入已取消"
			End If
			AddRow = False
		End If
		Rs.Close
		Set Rs = Nothing
		If AddRow Then
			zxzx.id.DbValue = RsNew("id")

			' Call Row Inserted event
			Call zxzx.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
%>
