<%@ Page Language="C#" %>
<%@ Register TagPrefix="aspxform" Namespace="XFormDesigner.Framework.Web.UI" Assembly="XFormDesigner.Framework" %>
<script runat="server">

    // Insert page code here
    //

</script>
<html xmlns:xform="xmlns:xform">
<head runat="server">
    <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />
    <link href="/Oimec/Styles/CSS/StyleSheet.css" rel="Stylesheet" type="text/css" />
    <title>BPM Form</title>
    <style>
        BODY {
            FONT-SIZE: 12px;
            FONT-FAMILY: verdana;
        }

        TABLE {
            border-collapse: collapse;
            FONT-SIZE: 12px;
            FONT-FAMILY: verdana;
        }

        P {
            PADDING-RIGHT: 0px;
            PADDING-LEFT: 0px;
            PADDING-BOTTOM: 0px;
            MARGIN: 0px;
            PADDING-TOP: 0px;
            FONT-SIZE: 12px;
            FONT-FAMILY: verdana;
        }

        TD {
            padding: 1px;
        }

            TD.NoPadding {
                PADDING-RIGHT: 0px;
                PADDING-LEFT: 0px;
                PADDING-BOTTOM: 0px;
                PADDING-TOP: 0px;
            }
        /*INPUT {height: 15px}*/
        INPUT.UL {
            BORDER-RIGHT: medium none;
            BORDER-TOP: medium none;
            BORDER-LEFT: medium none;
            BORDER-BOTTOM: #33ff33 1px solid;
        }

        TEXTAREA {
            FONT-SIZE: 12px;
        }

        input {
            vertical-align: middle; /*margin-right:-3px*/
        }
    </style>
   
     <script>
         agent.on('beforeSubmit', function (actname1, actname) {
             
             var SamplingType = agent.Eles[document.getElementById("SamplingType").getAttribute("xform_xele_index")].getValue();
             if (SamplingType == "") {
                 
                 alert("请选择抽样类型");
                 return false;

             }
             var XAttachments2 = agent.Eles[document.getElementById("XAttachments2").getAttribute("xform_xele_index")].getValue();
             if (XAttachments2 == "") {
                  
                 alert("请上传模板文件");
                 return false;

             }
             var SamplingTypeValue = "";
             switch (SamplingType)
             {
                 case "1":
                     SamplingTypeValue = "收入抽样";
                     break;
                 case "2":
                     SamplingTypeValue = "采购抽样";
                     break;
                 case "3":
                     SamplingTypeValue = "租赁资产抽样";
                     break;
                 case "4":
                     SamplingTypeValue = "办公资产抽样";
                     break;
                 case "5":
                     SamplingTypeValue = "收入截止性测试抽样";
                     break;
                 default:
                     break;
             }
              
             var id = document.getElementById("XAttachments2").getElementsByTagName("div")[2].id;
             var fileid = document.getElementById(id).getAttribute("fileid");
             var filename = document.getElementById(id).getAttribute("filename");
             var name = "";
             if (filename.length>0) {
                 name= filename.split('.')[0];
             }
             
             var filetype = getType(filename);

             if (name.indexOf(SamplingTypeValue) != -1) {//true

             } else {
                 
                 alert("抽样类型为：" + SamplingTypeValue + ",上传的文件名称必须含有" + SamplingTypeValue + "字样");
                
                 return false;
             }

            
             //if (SamplingTypeValue != name) {
             //    alert("抽样类型与上传的文件名称不符");
             //    return false;
             //}
            
             YZSoft.Ajax.request({
                 async: false,
                 url: "/Oimec/EMS/Services/EMSHandler.ashx",
                 params: {
                     method: 'UpLoadFile',
                     fileid: fileid,//上传路径id
                     filetype: filetype,
                     SamplingType: SamplingType,
                     SamplingTypeValue: SamplingTypeValue
                 },
                 success: function (action) {
                     console.log(action)
                    // console.log(action.result)
                     var data = action.result;
                     if (data.Code=="1") {
                         alert(data.Message);
                         return false;
                     }
                     var v = data.Value;
                     agent.Eles[document.getElementById("FtpPath").getAttribute("xform_xele_index")].setValue(v);

                    
                     //setTimeout(function () {
                         
                     //},3000);
                 }
             });
              
             
             
         });

         //获取文件后缀
         function getType(file) {
             var filename=file;
             var index1=filename.lastIndexOf(".");
             var index2=filename.length;
             var type=filename.substring(index1,index2);
             return type;
         }
     </script>
</head>
<body>
    <form runat="server">
        <!-- Insert content here -->
        <table width="1200" align="center" class="head" border="0" cellspacing="0" cellpadding="0">
            <tbody>
                <tr>
                    <td class="logo">
                    </td>
                    <td width="1000" class="biaoti">
                        <asp:Label id="Label1" runat="server" text="抽样数据收集"></asp:Label></td>
                    <td width="400" class="formno">
                         <asp:Label id="Label2" runat="server" text="表单号："></asp:Label>
                        <aspxform:XLabel id="XLabel3" runat="server" XDataBind="DF_EMS_Sampling.FormNo" Value ValueToDisplayText BackColor="#8AB3DF" Text="--系统自动生成--"></aspxform:XLabel>
                    </td>
                </tr>
            </tbody>
        </table>
        <br />
        <table width="1200" align="center" class="table" border="0" cellspacing="0" cellpadding="0">
            <tbody>
                <tr>
                    <td height="21" class="title1" colspan="4">
                        <asp:Label id="Label3" runat="server" text="基本信息"></asp:Label></td>
                </tr>
                <tr>
                    <td width="129" height="21" class="tsbottomlabel">
                        <asp:Label id="Label4" runat="server" text="创建人"></asp:Label>
                        <aspxform:XTextBox id="txtAppAccount" runat="server" ValueToDisplayText XDataBind="DF_EMS_Sampling.CreateAccount" HiddenExpress="1" Width="20px" BorderColor="#DCDCDC" BorderWidth="1"></aspxform:XTextBox>
                    </td>
                    <td width="459" class="tsbottomtext">
                        <aspxform:XTextBox id="txtAppName" runat="server" ValueToDisplayText XDataBind="DF_EMS_Sampling.CreateName" Width="70%" BorderColor="#DCDCDC" BorderWidth="1" DisableBehavior="ReadOnly" BackColor="#E6F1F8" ReadOnly="True"></aspxform:XTextBox>
                    </td>
                    <td width="129" class="tsbottomlabel">
                        <asp:Label id="Label5" runat="server" text="创建日期"></asp:Label></td>
                    <td class="tsbottomtext">
                        <aspxform:XDateTimePicker id="dtCreateDate" runat="server" XDataBind="DF_EMS_Sampling.CreateDate" Width="50%" BorderColor="#DCDCDC" BorderWidth="1"  BackColor="#E6F1F8" DisplayOnly="True"></aspxform:XDateTimePicker>
                    </td>
                </tr>
            </tbody>
        </table>
        <br />
        <table width="1200" align="center" class="table" border="0" cellspacing="0" cellpadding="0">
            <tbody>
                <tr>
                    <td class="tsbottomlabel" style="WIDTH: 10%">
                        <asp:Label id="Label6" runat="server" text="抽样类型"></asp:Label></td>
                    <td class="tsbottomtext" style="WIDTH: 35%" colspan="3">
                       <aspxform:XDropDownList ID="SamplingType" runat="server" XDataBind="DF_EMS_Sampling.SamplingType" PromptText="--请选择--" Width="50%">
                           <asp:ListItem Value="1">收入抽样</asp:ListItem>
                             <asp:ListItem Value="2">采购抽样</asp:ListItem>
                               <asp:ListItem Value="3">租赁资产抽样</asp:ListItem>
                             <asp:ListItem Value="4">办公资产抽样</asp:ListItem>
                           <asp:ListItem Value="5">收入截止性测试抽样</asp:ListItem>
                       </aspxform:XDropDownList>
                       </td>
                 </tr>
                <tr>
                     <td class="tsbottomlabel" style="WIDTH: 10%">
                        <asp:Label id="Label8" runat="server" text="上传模板文件"></asp:Label></td>
                    <td class="tsbottomtext" style="WIDTH: 35%" colspan="3">
                     <aspxform:XAttachments id="XAttachments2"  runat="server" XDataBind="DF_EMS_Sampling.SampleAttachment" Width="100%" FileTypes=" *.xls;*.xlsx; "></aspxform:XAttachments>
                  <aspxform:XTextBox id="FtpPath" runat="server" HiddenExpress="1" XDataBind="DF_EMS_Sampling.FtpPath"></aspxform:XTextBox>
                    </td>
                </tr>
                 <tr>
                     <td class="tsbottomlabel" style="WIDTH: 10%" colspan="3">
                        <asp:Label id="Label7" runat="server" text="备注" style="color:red">
                            备注:<br />
                              &nbsp;1  上传的excel文件的名称的前缀必须和抽样类型一致<br />
                         &nbsp;2   收集的文件将传输到内控审计部的共享目录下，请联系相关人员索取
                        </asp:Label></td>
                  
                </tr>
            </tbody>
        </table>
        <br />
        <aspxform:XRequiredFieldValidator id="XRequiredFieldValidator16" runat="server"   ForeColor="Red" ControlToValidate="SamplingType" ErrorMessage="请选择抽样类型" Display="None" ValidationGroup="submit">请选择抽样类型</aspxform:XRequiredFieldValidator>
         <aspxform:XRequiredFieldValidator id="XRequiredFieldValidator1" runat="server"   ForeColor="Red" ControlToValidate="XAttachments2" ErrorMessage="上传模板文件" Display="None" ValidationGroup="submit">上传模板文件</aspxform:XRequiredFieldValidator>
    </form>
</body>
</html>
