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

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        { //首次加载
            string format = Request.QueryString["formstate"];
            this.XTextBox4.Text = format;
            string PO = Request.QueryString["PO"];
            string POROW = Request.QueryString["POROW"];
            string VCONTRACTDATE = Request.QueryString["VCONTRACTDATE"];
            string CUSCONTRACTDATE = Request.QueryString["CUSCONTRACTDATE"];
            string CUSACCEPTDATE = Request.QueryString["CUSACCEPTDATE"];
            string CUSEXPECTDATE = Request.QueryString["CUSEXPECTDATE"];
            string CUSDATE = Request.QueryString["CUSDATE"];
            string payment = Request.QueryString["payment"];
            this.txtPayment.Text = payment;
            this.txtPO.Text = PO;
            this.txtPORow.Text = POROW;
            this.xCusAcceptDate.Text = CUSACCEPTDATE;
            this.xCusContractDate.Text = CUSCONTRACTDATE;
            this.xCusExceptDate.Text = CUSEXPECTDATE;
            this.xVContractDate.Text = VCONTRACTDATE;
            this.txtCusDate.Text = CUSDATE;
            this.xCusDate.Text = CUSDATE;
        }
    
    }

</script>
<html xmlns:xform="xmlns:xform">
<head runat="server">
    <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-RIGHT: 0px; PADDING-LEFT: 2px; PADDING-BOTTOM: 0px}
    TD.NoPadding {PADDING-RIGHT: 0px; PADDING-LEFT: 0px; PADDING-BOTTOM: 0px; PADDING-TOP: 0px}
    INPUT {HEIGHT: 20px}
    INPUT.UL {BORDER-RIGHT: medium none; BORDER-TOP: medium none; BORDER-LEFT: medium none; BORDER-BOTTOM: #33ff33 1px solid}
    TEXTAREA {FONT-SIZE:12px}
    </style>
    <script type="text/javascript">
        function getXValue(id) {
            return agent.Eles[document.getElementById(id).getAttribute("xform_xele_index")].getValue();
        }

        agent.on('beforeSubmit', function () {
            var formstate = agent.Eles[document.getElementById("XTextBox4").getAttribute("xform_xele_index")].getValue();

            if (formstate == "Edit") {

                //更新客户调整日期
                var cusdate = getXValue("xCusDate");
                var olddate = getXValue("txtCusDate");                
                var reason = getXValue("txtReason");
                //日期变更，填写客户调整原因
                if (cusdate != olddate && reason == "") {
                    Ext.MessageBox.alert('提示', '请输入客户调整原因！');
                    return false;

                }
                var oper = getXValue("XTextBox1");
                var operid = getXValue("XTextBox5");
                var po = getXValue("txtPO");
                var porow = getXValue("txtPORow");
                var url = YZSoft.$url('Oimec/ApiServices/SRMAPIHandler.ashx');
                var parm = {
                    method: "UpdateCusDate",
                    cusdate: cusdate,
                    reason: reason,
                    oper: oper,
                    operid: operid,
                    po: po,
                    porow: porow,

                }
                YZSoft.Ajax.request({
                    async: false,
                    url: url,
                    method: 'POST',
                    params: parm,
                    dataType: "json",
                    contentType: "application/json",
                    success: function (ac) {
                        console.log(ac.responseText);
                        //alert(ac.responseText);
                        var res = ac.responseText;
                    }
                });

            }

            if (formstate == "New") {

                //插入PO数据                                
                var CusContractDate = getXValue("xCusContractDate");                
                var CusExceptDate = getXValue("xCusExceptDate");                
                var po = getXValue("txtPO");
                var porow = getXValue("txtPORow");
                var CusAcceptDate = getXValue("xCusAcceptDate");
                var VContractDate = getXValue("xVContractDate");
                var trackdate = getXValue("xTrackDate");
                var payment = getXValue("txtPayment");
                var cusdate = getXValue("xCusDate");
                var reason = getXValue("txtReason");
                if (po == "")
                {
                    Ext.MessageBox.alert('提示', '请输入PO！');
                    return false;
                }
                if (porow == "") {
                    Ext.MessageBox.alert('提示', '请输入PO行号！');
                    return false;
                }
                if (CusContractDate == "") {
                    Ext.MessageBox.alert('提示', '请输入客户纸面合同日期！');
                    return false;
                }
                if (CusExceptDate == "") {
                    Ext.MessageBox.alert('提示', '请输入客户期望交货日期！');
                    return false;
                }
                if (CusAcceptDate == "") {
                    Ext.MessageBox.alert('提示', '请输入客户可接受日期！');
                    return false;
                }
                if (VContractDate == "") {
                    Ext.MessageBox.alert('提示', '请输入供应商纸面合同日期！');
                    return false;
                }
                var url = YZSoft.$url('Oimec/ApiServices/SRMAPIHandler.ashx');
                var parm = {
                    method: "InsertPOInfo",
                    CUSCONTRACTDATE: CusContractDate,
                    CUSEXPECTDATE: CusExceptDate,
                    CUSACCEPTDATE: CusAcceptDate,
                    VCONTRACTDATE: VContractDate,
                    po: po,
                    porow: porow,
                    payment: payment,
                    trackdate: trackdate,
                    cusdate: cusdate,
                    reason: reason
                }

                YZSoft.Ajax.request({
                    async: false,
                    url: url,
                    method: 'POST',
                    params: parm,
                    dataType: "json",
                    contentType: "application/json",
                    success: function (ac) {
                        console.log(ac.responseText);
                        //alert(ac.responseText);
                        var res = ac.responseText;
                    }
                });

            }
        });

    </script>
</head>
<body>
    <form runat="server">
        <table width="1200" align="center" class="head" border="0" cellspacing="0" cellpadding="0">
            <tbody>
                <tr>
                    <td class="logo">
                    </td>
                    <td class="biaoti">
                        <asp:Label id="XLabel2" runat="server" text="PO信息" valuetodisplaytext value></asp:Label></td>
                    <td class="formno">
                    </td>
                </tr>
            </tbody>
        </table>
        <br />
        <table width="1200" align="center" class="table">
            <tbody>
                <tr>
                    <td height="24" class="title1" colspan="4">
                        <asp:Label id="XLabel1" runat="server" text="基本信息" valuetodisplaytext value></asp:Label>
                        <aspxform:XTextBox id="XTextBox4" runat="server" HiddenInput="True" XDataBind="varState" BorderColor="#DCDCDC" BorderWidth="1"></aspxform:XTextBox>
                    </td>
                </tr>
                <tr>
                    <td class="basiclblfirst" style="WIDTH: 10%">
                        <asp:Label id="XLabel12" runat="server" text="操作人" valuetodisplaytext value></asp:Label>
                        <aspxform:XTextBox id="XTextBox5" runat="server" HiddenInput="True" XDataBind="DF_MM_PODateInfo.CreateAccount" BorderColor="#DCDCDC" BorderWidth="1" Width="10px"></aspxform:XTextBox>
                    </td>
                    <td class="basiclblfirst" style="WIDTH: 35%">
                        <aspxform:XTextBox id="XTextBox1" runat="server" XDataBind="DF_MM_PODateInfo.CreateName" BorderColor="#DCDCDC" BorderWidth="1" DisableBehavior="ReadOnly" Width="150px" DisableExpress="1" CssClass="text" ReadOnly="True" BackColor="#E6F1F8"></aspxform:XTextBox>
                    </td>
                    <td class="basiclblfirst" style="WIDTH: 10%">
                        <asp:Label id="XLabel5" runat="server" text="操作时间" valuetodisplaytext value forecolor="Black"></asp:Label></td>
                    <td class="basiclblfirst" style="WIDTH: 35%">
                        <aspxform:XDateTimePicker id="XDateTimePicker2" runat="server" XDataBind="DF_MM_PODateInfo.CreateDate" BorderColor="#DCDCDC" BorderWidth="1" BackColor="#E6F1F8" DisplayOnly="True"></aspxform:XDateTimePicker>
                    </td>
                </tr>
            </tbody>
        </table>
        <table width="1200" align="center" class="table">
            <tbody>
                <tr>
                    <td height="26" class="title1" colspan="4">
                        <asp:Label id="Label5" runat="server" text="PO信息" valuetodisplaytext value></asp:Label></td>
                </tr>
                <tr>
                    <td class="basiclblfirst" style="WIDTH: 10%">
                        <asp:Label id="Label6" runat="server" text="PO号" valuetodisplaytext value></asp:Label></td>
                    <td class="basiclblfirst" style="WIDTH: 35%">
                        <aspxform:XTextBox id="txtPO" runat="server" XDataBind="DF_MM_PODateInfo.PO" BorderColor="#DCDCDC" BorderWidth="1" Width="200px" DisableExpress="varState=='Edit'" CssClass="text"></aspxform:XTextBox>
                    </td>
                    <td class="basiclblfirst" style="WIDTH: 10%">
                        <asp:Label id="Label7" runat="server" text="PO行号" valuetodisplaytext value forecolor="Black"></asp:Label></td>
                    <td class="basiclblfirst" style="WIDTH: 35%">
                        <aspxform:XTextBox id="txtPORow" runat="server" XDataBind="DF_MM_PODateInfo.PORow" BorderColor="#DCDCDC" BorderWidth="1" Width="200px" DisableExpress="varState=='Edit'" CssClass="text"></aspxform:XTextBox>
                    </td>
                </tr>
                <tr>
                    <td height="20" class="basiclblfirst" style="WIDTH: 10%">
                        <asp:Label id="Label2" runat="server" text="实际付款条件" valuetodisplaytext value></asp:Label></td>
                    <td class="basiclblfirst" style="WIDTH: 35%">
                        <aspxform:XTextBox id="txtPayment" runat="server" XDataBind="txtPayment" BorderColor="#DCDCDC" BorderWidth="1" Width="200px" DisableExpress="varState=='Edit'" CssClass="text"></aspxform:XTextBox>
                    </td>
                    <td class="basiclblfirst" style="WIDTH: 10%">
                        <asp:Label id="Label3" runat="server" text="首次跟单日期" valuetodisplaytext value forecolor="Black"></asp:Label></td>
                    <td class="basiclblfirst" style="WIDTH: 35%">
                        <aspxform:XDateTimePicker id="xTrackDate" runat="server" BorderColor="#DCDCDC" BorderWidth="1" DisableExpress="varState=='Edit'"></aspxform:XDateTimePicker>
                    </td>
                </tr>
                <tr>
                    <td height="20" class="basiclblfirst" style="WIDTH: 10%">
                        <asp:Label id="Label10" runat="server" text="客户纸面合同日期" valuetodisplaytext value></asp:Label></td>
                    <td class="basiclblfirst" style="WIDTH: 35%">
                        <aspxform:XDateTimePicker id="xCusContractDate" style="HEIGHT: 20px; WIDTH: 100px" runat="server" XDataBind="DF_MM_PODateInfo.CusContractDate" BorderColor="#DCDCDC" BorderWidth="1" DisableExpress="varState=='Edit'"></aspxform:XDateTimePicker>
                    </td>
                    <td class="basiclblfirst" style="WIDTH: 10%">
                        <asp:Label id="Label11" runat="server" text="客户期望交货日期" valuetodisplaytext value forecolor="Black"></asp:Label></td>
                    <td class="basiclblfirst" style="WIDTH: 35%">
                        <aspxform:XDateTimePicker id="xCusExceptDate" runat="server" BorderColor="#DCDCDC" BorderWidth="1" DisableExpress="varState=='Edit'"></aspxform:XDateTimePicker>
                    </td>
                </tr>
                <tr>
                    <td class="basiclblfirst" style="WIDTH: 10%">
                        <asp:Label id="Label1" runat="server" text="客户可接受日期" valuetodisplaytext value></asp:Label></td>
                    <td class="basiclblfirst" style="WIDTH: 35%">
                        <aspxform:XDateTimePicker id="xCusAcceptDate" runat="server" BorderColor="#DCDCDC" BorderWidth="1" DisableExpress="varState=='Edit'"></aspxform:XDateTimePicker>
                    </td>
                    <td class="basiclblfirst" style="WIDTH: 10%">
                        <asp:Label id="Label8" runat="server" text="供应商纸面合同日期" valuetodisplaytext value forecolor="Black"></asp:Label></td>
                    <td class="basiclblfirst" style="WIDTH: 35%">
                        <aspxform:XDateTimePicker id="xVContractDate" runat="server" BorderColor="#DCDCDC" BorderWidth="1" DisableExpress="varState=='Edit'"></aspxform:XDateTimePicker>
                    </td>
                </tr>
                <tr>
                    <td class="basiclblfirst" style="WIDTH: 10%">
                        <asp:Label id="Label9" runat="server" text="客户调整日期" valuetodisplaytext value></asp:Label>
                        <aspxform:XTextBox id="txtCusDate" runat="server" HiddenInput="true" XDataBind="varOldDate" BorderColor="#DCDCDC" BorderWidth="1" DisableBehavior="ReadOnly" Width="200px" CssClass="text"></aspxform:XTextBox>
                    </td>
                    <td class="basiclblfirst" style="WIDTH: 35%">
                        <aspxform:XDateTimePicker id="xCusDate" runat="server" XDataBind="DF_MM_PODateInfo.CusDate" BorderColor="#DCDCDC" BorderWidth="1"></aspxform:XDateTimePicker>
                    </td>
                    <td class="basiclblfirst" style="WIDTH: 10%">
                        <asp:Label id="Label12" runat="server" text="调整原因" valuetodisplaytext value forecolor="Black"></asp:Label></td>
                    <td class="basiclblfirst" style="WIDTH: 35%">
                        <aspxform:XTextBox id="txtReason" runat="server" XDataBind="DF_MM_PODateInfo.Reason" BorderColor="#DCDCDC" BorderWidth="1" DisableBehavior="ReadOnly" Width="200px" CssClass="text"></aspxform:XTextBox>
                    </td>
                </tr>
            </tbody>
        </table>
        <aspxform:XRequiredFieldValidator id="XRequiredFieldValidator1" runat="server" ForeColor="Red" ErrorMessage="请输入PO" ControlToValidate="txtPO" ValidationGroup="new"></aspxform:XRequiredFieldValidator>
        &nbsp;&nbsp;<aspxform:XRequiredFieldValidator id="XRequiredFieldValidator2" runat="server" ForeColor="Red" ErrorMessage="请输入PO行号" ControlToValidate="txtPORow" ValidationGroup="new"></aspxform:XRequiredFieldValidator>
        &nbsp;&nbsp;<aspxform:XRequiredFieldValidator id="XRequiredFieldValidator3" runat="server" ForeColor="Red" ErrorMessage="请输入客户纸面合同日期" ControlToValidate="xCusContractDate" ValidationGroup="new"></aspxform:XRequiredFieldValidator>
        &nbsp;&nbsp;<aspxform:XRequiredFieldValidator id="XRequiredFieldValidator4" runat="server" ForeColor="Red" ErrorMessage="请输入客户期望交货日期" ControlToValidate="xCusExceptDate" ValidationGroup="new"></aspxform:XRequiredFieldValidator>
        &nbsp;<aspxform:XRequiredFieldValidator id="XRequiredFieldValidator5" runat="server" ForeColor="Red" ErrorMessage="请输入客户可接受日期" ControlToValidate="txtPO" ValidationGroup="new"></aspxform:XRequiredFieldValidator>
        &nbsp;&nbsp;&nbsp;&nbsp;<aspxform:XRequiredFieldValidator id="XRequiredFieldValidator7" runat="server" ForeColor="Red" ErrorMessage="请输入供应商纸面合同日期" ControlToValidate="xVContractDate" ValidationGroup="new"></aspxform:XRequiredFieldValidator>
    </form>
</body>
</html>
