<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="allOrderList.aspx.cs" Inherits="ZYDN.Web.webUser.allOrderList" %>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
   <title>所有订单列表</title>
   <link href="../../system/skins/CSS/main.css" rel="stylesheet" type="text/css" />
   <link href="../../system/skins/CSS/Sys.css" rel="stylesheet" type="text/css" />
   <link href="../../webUser/style/userMain.css" rel="stylesheet" type="text/css" />
   <script src="../JS/JFramework.js" language="javascript" type="text/javascript"></script>
   <script src="../JS/Sys.js" language="javascript" type="text/javascript"></script>
   <script type="text/javascript" language="javascript">
        var objAjax = new JAjax();
        function updatePrice(obj){
            if(isWxVersion()){
                return;
            }
            var tid = obj.tID;
            var newPrice = obj.value;
            if(isNaN(newPrice)){
                alert("价格只能是数字！");
                return;
            }
            var num = obj.tnum;
            var total = parseInt(num)*parseFloat(newPrice)*1.00;
            var objResponse=new JHttpResponse();
            objResponse.write("tid",tid);
		    objResponse.write("newPrice",newPrice);
		    objResponse.write("total",total);
		    var out=objAjax.getText("post","?type=updatePrice",objResponse,null);
            document.getElementById(tid).innerText = total.toFixed(2);
        }
        function PutExcel(obj){
            var fileName = "";
            var objResponse=new JHttpResponse();
		    objResponse.write("fileName",fileName);
		    var out = objAjax.getText("post","?type=excel",objResponse,null);
		    if(out!=""&&out!=null){
		        var v = out.substring(out.length-3,out.length);
		        if(v=="xls"){
		            obj.href = out;
		            obj.click();
		        }else{
		            document.write(out);
		        }
		    }
        }
        function ShowOrderLog(obj){
             if(isWxVersion()){
			    showModalDialog("../shop/orderAddress.aspx?oid="+obj.innerText+"&t="+create_id(), window, "dialogWidth:300px; dialogHeight:165px; toolbar=no;location=no;directories=no;status=no;menubar=no;scroll=auto;resizable=0;help=0");
             }else{
                if(parseInt(obj.id)<2){
			        showModalDialog("../shop/orderLog.aspx?oid="+obj.innerText+"&t="+create_id(), window, "dialogWidth:900px; dialogHeight:560px; toolbar=no;location=no;directories=no;status=no;menubar=no;scroll=auto;resizable=0;help=0");
	            }
	        }
        }
        function DelOrder(id){
            if(confirm("确认删除？")){
                var objResponse=new JHttpResponse();
		        objResponse.write("ID",id);
		        var out = objAjax.getText("post","?type=DelOrder",objResponse,null);
		        if(out>0){
		            window.location.reload();
		        }
		    }
        }
    </script>
   <style type="text/css">
        .ddbtClall{border-bottom:solid 1px #cccccc; border-right:solid 1px #cccccc; text-align:center;font-size:12px;}
        .ddbtClallf{border-bottom:solid 1px #cccccc; border-right:solid 1px #cccccc;font-size:12px;}
        .ddbtClall input{border:solid 1px #cad6ea;text-align:center;font-size:12px;}
    </style>
</head>
<body>
    <%wJs(); %>
    <form id="form1" runat="server">
    <asp:Repeater ID="Repeater1" runat="server">     
        <HeaderTemplate>
        <table cellpadding="0" cellspacing="0" width="100%">
            <tr class="titleRow" >
                <td class="ddbtClallf" style="border-top:solid 1px #cccccc;">订单号</td>
                <td class="ddbtClallf" style="border-top:solid 1px #cccccc;">订单类型</td>
                <td class="ddbtClallf" style="border-top:solid 1px #cccccc;">商家</td>
                <td class="ddbtClallf" style="border-top:solid 1px #cccccc;">买家</td>
                <td class="ddbtClallf" style="border-top:solid 1px #cccccc;">商品名</td>
                <td class="ddbtClallf" style="border-top:solid 1px #cccccc;">备注</td>
                <td class="ddbtClallf" style="border-top:solid 1px #cccccc;">单价</td>
                <td class="ddbtClallf" style="border-top:solid 1px #cccccc;">数量</td>
                <td class="ddbtClallf" style="border-top:solid 1px #cccccc;">总价</td>
                <td class="ddbtClallf" style="border-top:solid 1px #cccccc;">订购时间</td>
                <td class="ddbtClallf" style="border-top:solid 1px #cccccc;">修改时间</td>
                <td class="ddbtClallf" style="border-top:solid 1px #cccccc;">状态</td>
            </tr>
    </HeaderTemplate>
    <AlternatingItemTemplate>
        <tr style="background-color:#F4F9FD">
                <td class="ddbtClall"><%# "<a style='color:#ff0000;cursor:hand;' id='"+ Eval("OrderState")+"' onclick='ShowOrderLog(this)'>" + Eval("OrderID") + "</a>"%></td>
                <td class="ddbtClall"><%# Eval("TypeName").ToString() == "" ? "&nbsp;" : Eval("TypeName")%></td>
                <td class="ddbtClall"><%# Eval("SellerName").ToString() == "" ? "&nbsp;" : Eval("SellerName")%></td>
                <td class="ddbtClall"><%# Eval("userName").ToString() == "" ? "&nbsp;" : Eval("userName")%></td>
                <td class="ddbtClall"><%# Eval("CommodityName").ToString() == "" ? "&nbsp;" : Eval("CommodityName")%></td>
                <td class="ddbtClall"><%# Eval("Mark").ToString() == "" ? "&nbsp;" : Eval("Mark")%></td>
                <td class="ddbtClall"><%# Eval("OrderState").ToString() == "0" ? "<input name=\"changeName\" style='width:60px;'  tID=" + Eval("ID") + " type='text' tnum=" + Eval("CommodityNum") + " value=" + Eval("Price") + " onchange='updatePrice(this)' />" : Eval("OrderState").ToString() == "1" ? "<input style='width:60px;' name=\"changeName\" tID=" + Eval("ID") + " type='text' tnum=" + Eval("CommodityNum") + " value=" + Eval("Price") + " onchange='updatePrice(this)' />" : Eval("Price")%></td>
                <td class="ddbtClall"><%# Eval("CommodityNum").ToString() == "" ? "&nbsp;" : Eval("CommodityNum")%></td>
                <td class="ddbtClall"><span id='<%# Eval("ID")%>'><%# Eval("Total")%></span></td>
                <td class="ddbtClall"><%# Eval("CreateTime","{0:d}")%></td>
                <td class="ddbtClall"><%# Eval("UpdateStateTime", "{0:d}")%></td>
                <td class="ddbtClall" id="orderState"><%# Eval("OrderState")%></td>
            </tr>
    </AlternatingItemTemplate>
    <ItemTemplate>
           <tr>
                <td class="ddbtClall"><%# "<a style='color:#ff0000;cursor:hand;' id='" + Eval("OrderState") + "' onclick='ShowOrderLog(this)'>" + Eval("OrderID") + "</a>"%></td>
                <td class="ddbtClall"><%# Eval("TypeName").ToString() == "" ? "&nbsp;" : Eval("TypeName")%></td>
                <td class="ddbtClall"><%# Eval("SellerName").ToString() == "" ? "&nbsp;" : Eval("SellerName")%></td>
                <td class="ddbtClall"><%# Eval("userName").ToString() == "" ? "&nbsp;" : Eval("userName")%></td>
                <td class="ddbtClall"><%# Eval("CommodityName").ToString() == "" ? "&nbsp;" : Eval("CommodityName")%></td>
                <td class="ddbtClall"><%# Eval("Mark").ToString() == "" ? "&nbsp;" : Eval("Mark")%></td>
                <td class="ddbtClall"><%# Eval("OrderState").ToString() == "0" ? "<input name=\"changeName\" style='width:60px;'  tID=" + Eval("ID") + " type='text' tnum=" + Eval("CommodityNum") + " value=" + Eval("Price") + " onchange='updatePrice(this)' />" : Eval("OrderState").ToString() == "1" ? "<input style='width:60px;' name=\"changeName\" tID=" + Eval("ID") + " type='text' tnum=" + Eval("CommodityNum") + " value=" + Eval("Price") + " onchange='updatePrice(this)' />" : Eval("Price")%></td>
                <td class="ddbtClall"><%# Eval("CommodityNum").ToString() == "" ? "&nbsp;" : Eval("CommodityNum")%></td>
                <td class="ddbtClall"><span id='<%# Eval("ID")%>'><%# Eval("Total")%></span></td>
                <td class="ddbtClall"><%# Eval("CreateTime","{0:d}")%></td>
                <td class="ddbtClall"><%# Eval("UpdateStateTime", "{0:d}")%></td>
                <td class="ddbtClall" id="orderState"><%# Eval("OrderState")%></td>
            </tr>
    </ItemTemplate>
    <FooterTemplate>
        </table>
    </FooterTemplate>
    </asp:Repeater>
        <div style="width: 100%; clear: both; height: 5px;"> </div>
        <asp:Button ID="pageUp" runat="server" Text="上一页" CausesValidation="False" Enabled="False"  UseSubmitBehavior="False" />
        <asp:Button ID="pageDown" runat="server" Text="下一页" CausesValidation="False" UseSubmitBehavior="False" />
        <asp:Label ID="pageLabel" runat="server" Text=""></asp:Label>
    &nbsp;&nbsp;&nbsp;
           <a id="putExcel" href="" onclick="PutExcel(this)" style="color:Blue">导出EXCEL</a>            
        <div>
        <div style="text-align:center;"></div>
        <div style="text-align:center;" class="msgBottom">
            <span>类型：</span>
            <asp:DropDownList ID="serchOrderType" runat="server" Width="90px" ToolTip="订单类型">
                <asp:ListItem Value="0">--请选择--</asp:ListItem>
            </asp:DropDownList>   
            <span>状态：</span>
            <asp:DropDownList ID="serchOrderState" runat="server" Width="90px" ToolTip="订单状态">
                <asp:ListItem Value="0">未处理</asp:ListItem>
                <asp:ListItem Value="1">已查看</asp:ListItem>
                <asp:ListItem Value="2">已到款</asp:ListItem>
                <asp:ListItem Value="3">已发货</asp:ListItem>
                <asp:ListItem Value="4" Selected="True">---请选择---</asp:ListItem>
            </asp:DropDownList>           
            <span>名称：</span>
            <asp:TextBox ID="serchOrderName" runat="server" Width="90px" ToolTip="商品名称" Text="请输入商品名"></asp:TextBox>
             <span>卖家：</span>
            <asp:TextBox ID="serchSellName" runat="server" Width="90px" ToolTip="卖家名称" ></asp:TextBox>
            <span>买家：</span>
            <asp:TextBox ID="serchUserName" runat="server" Width="90px" ToolTip="买家名称" ></asp:TextBox>
        <br />
            <span> 起始时间：</span>
            <asp:TextBox ID="serchStartTime" runat="server" Width="90px" ToolTip="订购订单的时间"></asp:TextBox><input type="button" value="选择" onclick="selectDate(this)"/>       
            <span> 结束时间：</span>
            <asp:TextBox ID="serchEndTime" runat="server" Width="90px" ToolTip="订购订单的时间"></asp:TextBox><input type="button" value="选择" onclick="selectDate(this)"/>               
        <span>
            <asp:TextBox ID="serchOrderID" runat="server" Width="200px" Text="请输入订单编号精确搜索"></asp:TextBox>
            <asp:Button ID="Button1" runat="server" Text="搜索" onclick="Button1_Click" />
            </span>
        </div>
    </div>
    </form>
    <% changeOrderState(); %>
    <script language="javascript" type="text/javascript">
        function selectDate(thisObj){
            var d=openSelectDate(sysPath);
            var obj=thisObj.previousSibling;
            if(d!="" & d!=null)
            obj.value=d; 
        }
        if(isWxVersion()){           
            var nidx=document.getElementsByTagName("input");             
            for(var i=0;i<nidx.length;i++){
                if(nidx[i].name=="changeName"){
                    nidx[i].readOnly="readonly";
                }
            }
        }
</script>
</body>
</html>
