<%@ Page Language="C#" MasterPageFile="~/Admin/MainPage.Master" AutoEventWireup="true" CodeBehind="form_add.aspx.cs" Inherits="PPFOR.Admin.DesignCenter.Console.form_add" Title="添加自定义表单" %>
<asp:Content ID="Content1" ContentPlaceHolderID="PPFOR_mainContent" runat="server">
<script src="../../JS/public.js" type="text/javascript"></script>   
<script src="../../JS/popup.js" type="text/javascript"></script>   
<script language="javascript" type="text/javascript">
    function displayOptions(ids,cobj)
    {
        var oids=ids.split(",");
        if(oids.length>0)
        {
            for(var i=0;i<oids.length;i++)
            {
                var obj=document.getElementById(oids[i]);
                if((cobj.type=="radio" && cobj.value==1) || (cobj.type=="checkbox" && cobj.checked==true))
                {
                    obj.style.display="";
                }
                else
                {
                    obj.style.display="none";
                }
            }    
        }
    }
    function validateFormMailAddress(source,args)
    {
        var obj=document.getElementById("displayFormMailAddress");
        if(obj.style.display=="none")
        {
            args.IsValid=true;
        }
        else
        {
            var obj2=document.getElementById('<%=PPFOR_formMailAddress.ClientID %>');
            if(obj2.value!=null && obj2.value.length>0)
            {
                args.IsValid=true;
            }
            else
            {
                args.IsValid=false;
            }
        }
    }
    function validateFormPrompt(source,args)
    {
        var obj=document.getElementById('<%= PPFOR_formPrompt.ClientID %>');
        if(obj.value.length>255)
        {
            args.IsValid=false;
        }
        else
        {
            args.IsValid=true;
        }
    }
    function validateFormTimeEnd(source,args)
    {
        var obj=document.getElementById("displayTimeStart");
        if(obj.style.display=="none")
        {
            args.IsValid=true;
        }
        else
        {
            var timeStart=toDateTime(document.getElementById('<%=PPFOR_formTimeStart.ClientID %>').value);
            var timeEnd=toDateTime(document.getElementById('<%=PPFOR_formTimeEnd.ClientID %>').value);
            if(timeStart!=0 && timeEnd!=0)
            {
                if (timeEnd>timeStart)
                {
                    args.IsValid=true;
                }
                else
                {
                    args.IsValid=false;
                }
            }
            else
            {
                args.IsValid=false;
            }
        }
    }
    function openFolderForSelect()
    {
        popup_show("选择存放位置","<iframe id='folderFrame' src='/Admin/CustomView/pathmanager.aspx?rid=" + document.getElementById('<%=PPFOR_formFileSaveAddress.ClientID %>').getAttribute("rid") + "' scrolling='yes' width='100%' height='100%' frameborder='0' ></iframe>",400,300);
    }
    function openTimeStartForSelect()
    {
       popup_show("选择开始时间","<iframe id='dtFrame' src='/Admin/CustomView/datetime.aspx?rid=" + document.getElementById('<%=PPFOR_formTimeStart.ClientID %>').getAttribute("rid") + "' scrolling='yes' width='100%' height='100%' frameborder='0' ></iframe>",400,285);
    }
    function openTimeEndForSelect()
    {
       popup_show("选择终止时间","<iframe id='dtFrame' src='/Admin/CustomView/datetime.aspx?rid=" + document.getElementById('<%=PPFOR_formTimeEnd.ClientID %>').getAttribute("rid") + "' scrolling='yes' width='100%' height='100%' frameborder='0' ></iframe>",400,285);
    }    
</script>
<div>
<form action="form_add.aspx" method="post" id="form1" runat="server">
    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="fortable">
        <thead>
            <tr>
              <td colspan="2" align="center">添加自定义表单</td>
            </tr>
        </thead>
        <tr>
            <td style="width:15%" align="right">表单名称：</td>
            <td><asp:TextBox ID="PPFOR_formName" runat="server" TextMode="SingleLine" Maxlength="20" Width="150px" Text=""></asp:TextBox><br />
              <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" SetFocusOnError="true" Display="Dynamic" ControlToValidate="PPFOR_formName">表单名称不能为空</asp:RequiredFieldValidator>
          </td>
        </tr>
        <tr>
          <td align="right">表名称：</td>
          <td>PPFOR_Form_<asp:TextBox ID="PPFOR_formTableName" runat="server" TextMode="SingleLine" Maxlength="21" Width="150px"></asp:TextBox><br />
            <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" SetFocusOnError="true" ValidationExpression="^[A-Za-z0-9_]{1,21}$" Display="Dynamic" ControlToValidate="PPFOR_formTableName">自定义表单的表名称必须以“PPFOR_Form_”开头，后接英文字母、数字或者下划线，并且长度在12到32个字符在之间</asp:RegularExpressionValidator>
            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" SetFocusOnError="true" Display="Dynamic" ControlToValidate="PPFOR_formTableName">表名称不能为空</asp:RequiredFieldValidator>
          </td>
        </tr>
        <tr>
           <td align="right">提交成功跳转地址：</td>
            <td valign="middle"><asp:TextBox ID="PPFOR_formGoNextUrl" runat="server" Text="" MaxLength="255"></asp:TextBox>
            </td>
        </tr>        
        <tr>
           <td align="right">上传附件保存地址：</td>
            <td valign="middle"><asp:TextBox ID="PPFOR_formFileSaveAddress" runat="server" Text="/" MaxLength="255"></asp:TextBox><img src="../../Images/s.gif" alt="选择存放位置" border="0" style="cursor:pointer;" onclick="openFolderForSelect();" />
            </td>
        </tr>
        <tr id="displayFormFileSize">
          <td align="right">上传文件大小：</td>
          <td>最大值<asp:TextBox ID="PPFOR_formFileSize" runat="server" TextMode="SingleLine" Maxlength="10" Width="90px" Text=""></asp:TextBox>KB<br />
            <asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="PPFOR_formFileSize" Display="Dynamic" ErrorMessage="文件大小必须是1至2048之间的正整数" MaximumValue="2048" MinimumValue="1" SetFocusOnError="True" Type="Integer"></asp:RangeValidator>
          </td>
        </tr>
         <tr>
          <td align="right">状态：</td>
          <td align="left"><asp:RadioButtonList CssClass="innertable" ID="PPFOR_formState" runat="server" RepeatDirection="Horizontal">
            <asp:ListItem Text="正常" Value="1" Selected="True"></asp:ListItem>
            <asp:ListItem Text="锁定" Value="0" Selected="False"></asp:ListItem>
          </asp:RadioButtonList>
          </td>
        </tr>
        <tr>
          <td align="right">启用时间限制：</td>
          <td><asp:RadioButtonList ID="PPFOR_formTimeLimit" CssClass="innertable" runat="server" RepeatDirection="Horizontal">
            <asp:ListItem Text="启用" Value="1"></asp:ListItem>
            <asp:ListItem Text="不启用" Value="0" Selected="True"></asp:ListItem>
          </asp:RadioButtonList>
          </td>
        </tr>
        <tr id="displayTimeStart" style="display:none;">
            <td align="right">起始时间：</td>
            <td><asp:TextBox ID="PPFOR_formTimeStart" runat="server"></asp:TextBox><img src="../../Images/s.gif" alt="选择开始时间" border="0" style="cursor:pointer;" onclick="openTimeStartForSelect();" /></td>
        </tr>
        <tr id="displayTimeEnd" style="display:none;">
            <td align="right">终止时间：</td>
            <td><asp:TextBox ID="PPFOR_formTimeEnd" runat="server"></asp:TextBox><img src="../../Images/s.gif" alt="选择终止时间" border="0" style="cursor:pointer;" onclick="openTimeEndForSelect();" /><br /> 
                <asp:CustomValidator ID="CustomValidator2" runat="server" Display="Dynamic" SetFocusOnError="true" ControlToValidate="PPFOR_formTimeEnd" ClientValidationFunction="validateFormTimeEnd" ValidateEmptyText="true">起始时间和终止时间均不能为空，且终止时间必须大于起始时间</asp:CustomValidator></td>
        </tr>
        <tr>
          <td align="right">提交次数限制：</td>
          <td><asp:CheckBox ID="PPFOR_formOnlyOnce" runat="server" />每个用户只能提交一次
          </td>
        </tr>           
        <tr>
          <td align="right">验证码设置：</td>
          <td><asp:CheckBox ID="PPFOR_formShowCheckCode" runat="server" Checked="true" />显示验证码
          </td>
        </tr>   
        <tr id="">
          <td align="right">邮件发送：</td>
          <td><asp:CheckBox ID="PPFOR_formSendMail" runat="server" />表单提交后是否需要发送邮件
          </td>
        </tr>  
        <tr id="displayFormMailAddress" style="display:none;">
          <td align="right">邮箱地址：</td>
          <td><asp:TextBox ID="PPFOR_formMailAddress" runat="server" MaxLength="50" /><br />
              <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" Display="Dynamic" SetFocusOnError="true" ControlToValidate="PPFOR_formMailAddress" ValidationExpression="^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$">邮箱地址格式不对</asp:RegularExpressionValidator>
              <asp:CustomValidator ID="CustomValidator3" runat="server" Display="Dynamic" SetFocusOnError="true" ControlToValidate="PPFOR_formMailAddress" ClientValidationFunction="validateFormMailAddress" ValidateEmptyText="true">邮箱地址不能为空</asp:CustomValidator>              
          </td>
        </tr>          
        <tr>
          <td align="right">表单说明：</td>
          <td><asp:TextBox TextMode="MultiLine" MaxLength="255" ID="PPFOR_formPrompt" runat="server" Height="80px" Width="300px"></asp:TextBox>
          <asp:CustomValidator ID="CustomValidator1" runat="server" Display="Dynamic" SetFocusOnError="true" ControlToValidate="PPFOR_formPrompt" ClientValidationFunction="validateFormPrompt">表单说明的长度不能大于255个字符</asp:CustomValidator>
          </td>
        </tr>                  
        <tr>
            <td colspan="2" align="center" valign="middle" style="height:50px; display:none">
                <asp:Button ID="PPFOR_addCustomForm" CssClass="inputbutton" runat="server" Text="添加" OnClick="PPFOR_createCustomForm"/>
                <input id="reset1" name="reset" type="reset" class="inputbutton" onmouseover="this.className='inputbutton_hover'" onmouseout="this.className='inputbutton'" value="重置" />
                <script type="text/javascript">
                    addButtonArray("<%= PPFOR_addCustomForm.ClientID %>","reset1");
                </script>
            </td>
        </tr>
      </table>
      <br />
</form>
</div>
</asp:Content>