<!--#include file="../../Inc/Cls_Main.Asp"-->
<!--#include file="../../Inc/Sys/Cls_FreeField.Asp"-->
<%
'=======================================================
Dim Action
'=======================================================
Action = LCase(Trim(Easp.Get("action:s")))
'=======================================================
Select Case Action
    Case "form"
        Call Saveform()
    Case Else
        Easp.RR "/"
End Select
Set Cms = Nothing
Set Easp = Nothing

Sub Saveform()
    Dim Id, Code, ToUrl
    Id = Easp.Get("id:n:0")
    Code = Easp.Post("Code:n:0")
    If Id = 0 Then
        Easp.Alert "缺少参数"
    End If
    ToUrl = CmsFun.LoadToUrl()
    '================================================
    Dim oRs, FormName, FormTableName, IsStatus, IsUnlockTime, StartTime, EndTime, IsCode
    Set oRs = Easp.db.GR(TablePrefix & "FreeForm:1", " Id = "& Id &" ", "")
    If Easp.IsN(oRs) Then
        Easp.Alert "错误的提交,错误代码：001"
    Else
        FormName = oRs("FormName")
        FormTableName = oRs("FormTableName")
        IsStatus = oRs("IsStatus")
        IsUnlockTime = oRs("IsUnlockTime")
        StartTime = oRs("StartTime")
        EndTime = oRs("EndTime")
        SuccessMsg = oRs("SuccessMsg")
        ErrorMsg = oRs("ErrorMsg")
        IsCode = oRs("IsCode")
    End If
    If Not CmsMain.CheckTable(FormTableName) Then
        Easp.Alert "错误的提交,错误代码：002"
    End If
    If IsStatus = 0 Then
        Easp.Alert "已关闭"
    End If
    If IsUnlockTime = 1 Then
        If DateDiff("d", EndTime, Now())>0 Then
            Easp.Alert "时间已结束"
        End If
    End If
    If IsCode = 1 Then
        '================================================
        If Code = 0 Then
            Easp.Alert "验证码必须填写!"
        End If
        If Trim(Code) <> Trim(Session("ZjjCmsFormCode")) Then
            Easp.Alert "验证码输入错误!"
            Session("ZjjCmsFormCode") = ""
        End If
    End If
    '================================================
    Dim List, ResultVal
    Easp.Use "list"
    Set List = Easp.List.New
    List("Ip") = Easp.GetIp()
    List("AddTime") = Now()
    objFreeField.GetFieldVal Id, List
    ' 开始保存
    ResultVal = Easp.db.AR(FormTableName & ":Id", List.Hash)
    Easp.C List
    If ResultVal <> 0 Then
        Easp.AlertUrl SuccessMsg, ToUrl
    Else
        Easp.Alert ErrorMsg
    End If
End Sub
%>