<%@ page language="C#" autoeventwireup="true" inherits="Admin_ProjectPayment, App_Web_qxuvifui" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>项目列表</title>
    <link href="../CSS/All.css" rel="stylesheet" type="text/css" />
    <link href="../CSS/pager.css" rel="stylesheet" type="text/css" />
    <script src="../JS/xzOper.js" type="text/javascript"></script>
    <script src="../JS/jquery.min.js" type="text/javascript"></script>
    <script src="../JS/Popup.js" type="text/javascript"></script>
    <script src="../JS/Calendar.js" type="text/javascript"></script>
    <style>
    .popupPanel{
        z-index: 101;
        left: 200px;  width: 500px; 
        position: absolute;
        top: 190px; 
        height: 450px; 
        display:none;
        background-color: whitesmoke; 
        border-right: #5d7b9d 10px solid;
        border-top: #5d7b9d 10px solid; 
        border-left: #5d7b9d 10px solid; 
        border-bottom: #5d7b9d 10px solid;
    }
     .close{
        border-right: medium none;
        border-top: medium none; float: right; border-left: medium none; border-bottom: medium none;
        background-color: darkgray
    }
    </style>
</head>
<body>
    <form id="Myform" runat="server" style="font-weight: normal;">
        <div class="title" >
            项目付款</div>
        <div >
            <br />
            &nbsp;</div>    
        <fieldset>
        <legend>未全额付款项目列表</legend>
        <div  id="view" style="overflow-x:auto; padding-left:3px">
        <asp:GridView
            ID="TableView" runat="server" AutoGenerateColumns="False"
             EmptyDataText="没有可显示的数据记录。" Width="100%" BorderStyle="Solid" DataKeyNames="CID">
             <Columns>
                 <asp:TemplateField HeaderText="付款" SortExpression="EID">
                     <ItemTemplate>
                     <button class="btn" onclick="showPayment('<%#Eval("CID") %>','<%#Eval("Amount") %>','<%#Eval("SumPayment") %>','<%#Eval("PName") %>')">付款录入</button>
                        
                     </ItemTemplate>
                     <HeaderStyle Height="30px"  Wrap="False"  />
                     <ItemStyle Height="30px"   Wrap="False" />
                 </asp:TemplateField>
                <asp:BoundField DataField="PName" HeaderText="项目名" SortExpression="PName" >
                <ItemStyle Wrap="False" />
                <HeaderStyle  Wrap="False" />
                </asp:BoundField>
                <asp:BoundField DataField="PClass" HeaderText="商品类型" SortExpression="PClass" >
                <ItemStyle Wrap="False" />
                <HeaderStyle  Wrap="False" />
                 </asp:BoundField>
                <asp:BoundField DataField="Amount" HeaderText="金额" SortExpression="Amount" DataFormatString="{0:C}" >
                <ItemStyle Wrap="False" />
                <HeaderStyle  Wrap="False" />
                 </asp:BoundField>
                 <asp:BoundField DataField="SumPayment" HeaderText="已付款" DataFormatString="{0:C}" >
                  <ItemStyle Wrap="False"  ForeColor="Maroon" Font-Bold="True" />
                    <HeaderStyle  Wrap="False" />
                 </asp:BoundField>
                <asp:BoundField DataField="CustID" HeaderText="对应客户" SortExpression="CustID" >
                <ItemStyle Wrap="False" />
                <HeaderStyle  Wrap="False" />
                 </asp:BoundField>
                <asp:BoundField DataField="beginDate" HeaderText="开发周期" SortExpression="beginDate" DataFormatString="{0:yyyy-MM-dd}" >
                <ItemStyle Wrap="False" />
                <HeaderStyle  Wrap="False" />
                 </asp:BoundField>
                <asp:BoundField DataField="endDate" HeaderText="—" SortExpression="endDate" DataFormatString="{0:yyyy-MM-dd}" >
                <ItemStyle Wrap="False" />
                <HeaderStyle  Wrap="False" />
                 </asp:BoundField>
                <asp:BoundField DataField="RebateBudget" HeaderText="回扣预算" SortExpression="RebateBudget" >
                <ItemStyle Wrap="False" />
                <HeaderStyle  Wrap="False" />
                 </asp:BoundField>
                </Columns>
                  <FooterStyle CssClass="GridViewFooterStyle" />
                 <RowStyle CssClass="GridViewRowStyle" />   
                 <SelectedRowStyle CssClass="GridViewSelectedRowStyle" />
                 <PagerStyle CssClass="GridViewPagerStyle" />
                 <AlternatingRowStyle CssClass="GridViewAlternatingRowStyle" />
                 <HeaderStyle CssClass="GridViewHeaderStyle" />
                 
        </asp:GridView>
        </div>
        <hr/> 
      </fieldset>
    <webdiyer:aspnetpager id="PagerButtom" runat="server" alwaysshow="True" cssclass="paginator"
                currentpagebuttonclass="cpb" custominfohtml="当前第%CurrentPageIndex%/%PageCount%页 共%RecordCount%条记录 每页%PageSize%条 "
                firstpagetext="首页" lastpagetext="尾页" layouttype="Table" nextpagetext="下一页" numericbuttoncount="5"
                onpagechanged="Pager_PageChanged" pagesize="25" prevpagetext="上一页" showcustominfosection="Left"
                showpageindexbox="Always"></webdiyer:aspnetpager>
        <div id="EditPanel" class="popupPanel" style=" left: 200px;  top: 190px; height: 485px;">
            <table border="0" cellspacing="5"  width="100%">
            
                <tr>
                    <td colspan="3" style="height: 33px">
                        <div id="_addCoursePanelDorp" style="width: 100%; border-bottom: gray 1px solid;
                            height: 25px; background-color: whitesmoke">
                            <input id="btnAddCourseClose" class="close" onclick='$("#EditPanel").hide();' type="button"
                                value="关闭" />
                        </div>
                    </td>
                </tr>
                <tr>
                    <td colspan="3" valign="top" style="height: 140px">
                    <div id="paymentTable" style="width:490px;height: 130px; overflow:scroll">
                    
                    
                    </div>
                    
                    </td>
                </tr>
                <tr>
                    <td colspan="3" valign="top">
                    <span id="currentProject" style="color: gray">&nbsp;</span>
                    </td>
                </tr>
                <tr>
                    <td colspan="3" valign="top">
                        付款金额：(已付：<span id="yifu"></span>)(未付：<span id="weifu"></span>)</td>
                </tr>
                <tr>
                    <td colspan="3" style="height: 45px" align="center">
                       <span style="padding-right: 5px; padding-left: 5px; padding-bottom: 5px; padding-top: 5px"> </span>
                       <asp:TextBox ID="txtPayment" runat="server" Width="176px"></asp:TextBox></td>
                </tr>
                <tr>
                    <td colspan="3" style="height: 17px">
                        付款日期：<asp:TextBox ID="txtIDate" runat="server" onclick="showDateSelect(this)"></asp:TextBox></td>
                </tr>
                <tr>
                    <td colspan="3">
                        备注：<asp:TextBox ID="txtBeizhu" runat="server" Height="78px" TextMode="MultiLine" Width="100%"></asp:TextBox></td>
                </tr>
                <tr>
                    <td align="center" colspan="3" valign="top">
                        <asp:Button ID="btnSubPayment" runat="server" CssClass="btn" Text="保存付款记录"  OnClientClick="return checkIPayment()" OnClick="btnSubPayment_Click" /></td>
                </tr>
            </table>
        </div>
        <asp:HiddenField ID="hfPaymentID" runat="server" />
        </form>
         <div  onclick="$(this).hide()" id="cuePanel" style="z-index: 101; position: absolute; 
           border:1px solid #E6594E; background-color: #FCEAE8;  padding:7px; display:none;
            color:#E6594E;">
            <span id="operCue"></span>
        </div>
    <script>
     
function isInt(sText){
      var reg =/^\d*$/;
      return sText.match(reg);
}

function showDateSelect(txt){  
            new Calendar('<%=DateTime.Now.Year-10 %>', '<%=DateTime.Now.Year+10%>', 0,'yyyy-MM-dd').show(txt);
}
function cue(obj,txt){
       var Y = obj.offset().top;
       var X = obj.offset().left;
       var p = $("#cuePanel");

       p.css("top",Y);
       p.css("left",X);
       $("#operCue").text(txt);
       p .show();
}
    function showPayment(cid,amount,sumpayment,pname){
        PaymentList(cid);
        var weifu = parseInt(amount)-parseInt(sumpayment);
        $("#weifu").text(weifu);
        $("#yifu").text(sumpayment);
        $("#currentProject").text(pname);
        $("#hfPaymentID").val(cid); 
        showPanel($("#EditPanel"));
        $("#txtIDate").val(getFormatDate());
    }
    function isEmpty(obj){
         var input= $("#"+obj+"");
         if($.trim(input.val())==""){
                input.get(0).focus();
                cue(input,"请填写！");
                return true;
         }
         return false;
    }
    function isIValid(obj){
        var input= $("#"+obj+"");
        if(!isInt($.trim(input.val()))){
            input.get(0).focus();
            cue(input,"输入无效！");return true;
        }
        return false;
    }
    function checkIPayment(){
       if(isEmpty("txtPayment"))return false;
       if(isIValid("txtPayment"))return false;
       return true;
    }
    function editPayment(cid)
    {

       location.href="ProjectEditPayment.aspx?cid=" +cid + "&where=&pageindex=<%= PagerButtom.CurrentPageIndex %>&s=payment";
    }

function PaymentList(cid){
    $.ajax({
           type: "POST",
           dataType:"text",
           processData:false,
           async:false,
           url: "ashx/PaymentList.ashx",
           data: "cid="+cid,
           success: function(msg){
              $("#paymentTable").html(msg);
           },
           error:function (XMLHttpRequest, textStatus, errorThrown) { 
            alert("加载功能项目付款记录列表失败 "+textStatus +" "+errorThrown+" "+XMLHttpRequest);
           }
        }); 
        
}
 function getFormatDate(){
   var myDate = new Date();
     return  myDate.getFullYear()+"-"+(myDate.getMonth()+1<10?"0"+(myDate.getMonth()+1):myDate.getMonth()+1)+"-"+(myDate.getDate()<10?("0"+myDate.getDate()):myDate.getDate());
   }
    </script>
</body>
</html>

