<!--#include file="../../Inc/Cls_Main.Asp"-->
<!--#include file="../inc/Cls_Admin.Asp"-->
<!--#include file="../inc/Cls_MapPath.Asp"-->
<!--#include file="../Admin_Check.Asp"-->
<%
Dim CmsAdmin
'=============================================================================
Set CmsAdmin = New Cls_Admin
CmsAdmin.SetAdminTitle = CmsSiteName
CmsAdmin.SetBodyCssName = "mainbody"
CmsAdmin.SetAdminPath = CmsAdminMapPath
CmsAdmin.LoadHead()
'=============================================================================
Dim Action
'=============================================================================
Action = Easp.Get("action")
Select Case Action
    Case "savemain"
        Call SaveMain()
    Case Else
        Call PageLoad()
End Select
CmsAdmin.LoadFooter()
Set CmsAdmin = Nothing

Sub PageLoad()
    Dim oRs, Id, FormName, FormTableName, IsStatus, IsUnlockTime
    Dim StartTime, EndTime, SuccessMsg, ErrorMsg, IsCode
    Id = Easp.Get("id:n:0")
    If Id = 0 Then
        CmsAdmin.JscriptMsg "参数错误！", "back", "Error", "null"
    End If
    Set oRs = Easp.db.GR(TablePrefix & "FreeForm:1", " Id = "& Id &" ", "")
    If Easp.IsN(oRs) Then
        CmsAdmin.JscriptMsg "不存在的数据！", "back", "Error", "null"
    Else
        FormName = oRs("FormName")
        FormTableName = oRs("FormTableName")
        IsStatus = oRs("IsStatus")
        IsUnlockTime = oRs("IsUnlockTime")
        StartTime = Easp.DateTime(oRs("StartTime"), "yyyy-mm-dd")
        EndTime = Easp.DateTime(oRs("EndTime"), "yyyy-mm-dd")
        SuccessMsg = oRs("SuccessMsg")
        ErrorMsg = oRs("ErrorMsg")
        IsCode = oRs("IsCode")
    End If
    Easp.C oRs
%>
<script src="<%=CmsAdminMapPath%>js/check/free.form.check.js"></script>
<form name="myform" id="myform" method="post" action="?action=savemain">
  <input type="hidden" name="id" value="<%=Id%>" />
  <input type="hidden" name="ToUrl" value="<%=CmsFun.LoadToUrl()%>" />
  <div class="navigation"><a href="Admin.Form.List.Asp" class="back">自定义表单管理</a> 控制面板 &gt; 自定义表单管理 &gt; 编辑表单</div>
  <div id="contentTab">
    <div class="content-tab">
      <ul class="tab_nav">
        <li><a onclick="tabs(this);" class="selected" href="javascript:void(0);">编辑表单</a></li>
      </ul>
    </div>
    <div class="tab_con" style="display: block;">
      <table class="form_table">
        <col width="200px">
          </col>
        
        <tbody>
          <tr>
            <th> 表单状态： </th>
            <td class="td2"><span>
              <input type="radio" name="IsStatus" id="IsStatus1" value="1" datatype="*" nullmsg="请选择表单状态！"<%=Easp.IIF(IsStatus = 1," checked=""checked""","")%> />
              <label for="IsStatus1">正常</label>
              <input type="radio" name="IsStatus" id="IsStatus0" value="0"<%=Easp.IIF(IsStatus = 0," checked=""checked""","")%> />
              <label for="IsStatus0">停用</label>
              </span> <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th> 表单名称： </th>
            <td class="td2"><input type="text" class="txtInput w250" name="FormName" id="FormName" autocomplete="off" datatype="*2-20" nullmsg="表单名称必须填写" errormsg="至少2个字符,最多20个字符!" value="<%=FormName%>" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th> 数据表： </th>
            <td class="td2"><input type="text" class="txtInput w150" name="FormTableName" id="FormTableName" autocomplete="off" datatype="en1" nullmsg="数据表必须填写" errormsg="只能是字母+数字,至少3个字符,最多10个字符!" readonly="readonly" value="<%=FormTableName%>" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th> 时间限制： </th>
            <td class="td2"><span>
              <input type="radio" name="IsUnlockTime" id="IsUnlockTime1" value="1" checked="checked" datatype="*" nullmsg="请选择时间限制！"<%=Easp.IIF(IsUnlockTime = 1," checked=""checked""","")%> />
              <label for="IsUnlockTime1">启用</label>
              <input type="radio" name="IsUnlockTime" id="IsUnlockTime0" value="0"<%=Easp.IIF(IsUnlockTime = 0," checked=""checked""","")%> />
              <label for="IsUnlockTime0">不启用</label>
              </span> <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th> 开始时间： </th>
            <td class="td2"><input type="text" class="txtInput w100" name="StartTime" id="StartTime" autocomplete="off" value="<%=StartTime%>" datatype="date1" onclick="WdatePicker();" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th> 结束时间： </th>
            <td class="td2"><input type="text" class="txtInput w100" name="EndTime" id="EndTime" autocomplete="off" value="<%=EndTime%>" datatype="date1" onclick="WdatePicker();" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th> 表单提交成功提示： </th>
            <td class="td2"><input type="text" class="txtInput w250" name="SuccessMsg" id="SuccessMsg" autocomplete="off" value="<%=SuccessMsg%>" datatype="*2-100" nullmsg="表单提交成功提示必须填写" errormsg="至少2个字符,最多100个字符!" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th> 表单提交失败提示： </th>
            <td class="td2"><input type="text" class="txtInput w250" name="ErrorMsg" id="ErrorMsg" autocomplete="off" value="<%=ErrorMsg%>" datatype="*2-100" nullmsg="表单提交失败提示必须填写" errormsg="至少2个字符,最多100个字符!" />
              <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th> 显示验证码： </th>
            <td class="td2"><span>
              <input type="radio" name="IsCode" id="IsCode1" value="1" checked="checked" datatype="*" nullmsg="请选择显示验证码！"<%=Easp.IIF(IsCode = 1," checked=""checked""","")%> />
              <label for="IsCode1">是</label>
              <input type="radio" name="IsCode" id="IsCode0" value="0"<%=Easp.IIF(IsCode = 0," checked=""checked""","")%> />
              <label for="IsCode0">否</label>
              </span> <span class="Validform_checktip">*</span></td>
          </tr>
          <tr>
            <th></th>
            <td><input type="submit" class="btnSubmit" value="提交保存" />
              <input name="重置" type="reset" class="btnSubmit" value="重 置" /></td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</form>
<%
End Sub

Sub SaveMain()
    ChkSysAdminLevel "sys_free", "edit"
    '=====================================================================
    Dim Id, FormName, FormTableName, IsStatus
    Dim IsUnlockTime, StartTime, EndTime, SuccessMsg, ErrorMsg, IsCode, TabName, ToUrl
    Id = Easp.Post("Id:n:0")
    FormName = Trim(Easp.Post("FormName:s"))
    FormTableName = Trim(Easp.Post("FormTableName:s"))
    IsStatus = Easp.Post("IsStatus:n:0")
    IsUnlockTime = Easp.Post("IsUnlockTime:n:0")
    StartTime = Easp.Post("StartTime:d")
    EndTime = Easp.Post("EndTime:d")
    SuccessMsg = Trim(Easp.Post("SuccessMsg:s"))
    ErrorMsg = Trim(Easp.Post("ErrorMsg:s"))
    IsCode = Easp.Post("IsCode:n:0")
    ToUrl = Trim(Easp.Post("ToUrl:s"))
    '=====================================================================
    If Id = 0 Then
        CmsAdmin.JscriptMsg "参数错误！", "back", "Error", "null"
    End If
    If Easp.IsN(FormName) Then
        CmsAdmin.JscriptMsg "表单名称不能为空！", "back", "Error", "null"
    End If
    If Easp.IsN(FormTableName) Then
        CmsAdmin.JscriptMsg "数据表不能为空！", "back", "Error", "null"
    End If
    If IsUnlockTime = 1 Then
        If (Easp.IsN(StartTime) Or Easp.IsN(EndTime)) Then
            CmsAdmin.JscriptMsg "开始时间与结束时间不能为空！", "back", "Error", "null"
        End If
    End If
    If Easp.IsN(SuccessMsg) Then
        CmsAdmin.JscriptMsg "表单提交成功提示必须填写！", "back", "Error", "null"
    End If
    If Easp.IsN(ErrorMsg) Then
        CmsAdmin.JscriptMsg "表单提交失败提示必须填写！", "back", "Error", "null"
    End If
    '=====================================================================
    Dim List, ResultVal
    Easp.Use "list"
    Set List = Easp.List.New
    List("FormName") = FormName
    List("FormTableName") = FormTableName
    List("IsStatus") = IsStatus
    List("IsUnlockTime") = IsUnlockTime
    List("StartTime") = StartTime
    List("EndTime") = EndTime
    List("SuccessMsg") = SuccessMsg
    List("ErrorMsg") = ErrorMsg
    List("IsCode") = IsCode
    '=====================================================================
    ResultVal = Easp.db.UR(TablePrefix & "FreeForm", " Id = "& Id &" ", List.Hash)
    '=====================================================================
    Easp.C List
    If ResultVal <> 0 Then
        CmsMain.CreateTable FormTableName
        CmsAdmin.JscriptMsg "编辑自定义表单成功！", Easp.IIf(Easp.IsN(ToUrl), "Admin.Form.List.Asp", ToUrl), "Success", "null"
    End If
    '=====================================================================
End Sub
%>
