<%@ Page language="c#" Codebehind="MyAgent.aspx.cs" AutoEventWireup="true" Inherits="XpShop.WebUI.MyAgent" %>
<%@ Register TagPrefix="uc1" TagName="MemberMenu" Src="Modules/MemberMenu.ascx" %>
<%@ Register TagPrefix="uc1" TagName="Header" Src="Modules/Header.ascx" %>
<%@ Register TagPrefix="uc1" TagName="Helper" Src="Modules/Helper.ascx" %>
<%@ Register TagPrefix="uc1" TagName="Footer" Src="Modules/Footer.ascx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML>
	<HEAD>
		<!--#include file="../../inc/encoding.inc"-->
		<title><%=GetResourceString("MyAgent")%>,<%=config.SiteTitle%></title>
		<!--#include file="../../inc/head.inc"-->
		<script src="inc/ui.datepicker.cn.js" type="text/javascript"></script>
		<link type="text/css" rel="stylesheet" href="inc/ui.datepicker.css" />
		<link href="<%=webSite %>Template/<%=config.TemplateFolder%>/style/member.css" rel="stylesheet" type="text/css"/>
        <script type="text/javascript">
			$(document).ready(function(){
				$("#txtDateFrom").datepicker();
				$("#txtDateTo").datepicker();	   
			});
		</script>
	</HEAD>
	<body>
        <uc1:Header id="Header1" runat="server"></uc1:Header>
        <div class="xp-w clear">
            <!--位置导航开始-->
            <div class="path">
                <a href="<%=webSite %><%if(config.html==""){%>default.aspx<%}else{%>Index.<%=config.html%><%}%>"> <%=GetResourceString("Home")%></a> &nbsp;&gt;&nbsp;<a href="<%=webSite %>Center.<%=config.html %>"><%=GetResourceString("MemberCenter")%></a>&nbsp;&gt;&nbsp;<%=GetResourceString("MyAgent")%>
            </div>
            <!--位置导航结束-->
            <div class="member_left">
                <!--会员中心导航开始-->
                <uc1:MemberMenu id="MemberMenu1" runat="server"></uc1:MemberMenu>
                <!--会员中心导航结束-->
            </div>
            <div class="member_middle_right">
                <!--内容开始-->
                <div class="mframe">
	                <div class="tl"></div>
	                <div class="tr"></div>
	                <div class="tm"><%=GetResourceString("MyAgent")%></div>
	                <div class="ml"></div>
	                <div class="mr"></div>
	                <div class="mm">
                        <form id="Form1" method="post" runat="server">
                        <table width="100%">
                            <tr>
                                <td>
							    推广链接地址：
							    <input type="text" value="<%=GetMyAgentLink() %>" id="txtLink" size="50" /><input type="button" id="btnCopy" value="复制" onclick="copyToClipboard('txtLink')" /><br />如果点击复制没有用，请全选后"ctrl+c"复制此链接
                               </td>
                           </tr>
<%--                            <tr>
                                <td>推广号：<%=agentID %></td>
                            </tr>--%>
                            <tr>
                                <td>访问推广链接跳转到：<%=jumpUrl %>（默认跳转到首页）</td>
                            </tr>
							<tr>
								<td align="left">
								    <table>
								        <tr>
								            <td>上月订单总数：</td>
								            <td><%=dtPreMonth.Rows[0]["totalorders"]%>个</td>
								            <td>已付款订单个数：</td>
								            <td><%=dtPreMonth.Rows[0]["paiedorders"]%> 个</td>
								            <td>已完成订单个数：</td>
								            <td><%=dtPreMonth.Rows[0]["finishOrders"]%></td>
								            <td style="color:red">已完成订单总金额：</td>
                                            <td style="color:red"><%=dtPreMonth.Rows[0]["TotalPrices"]%></td>
                                        </tr>
								        <tr>
								            <td>本月订单总数：</td>
								            <td><%=dtThisMonth.Rows[0]["totalorders"]%>个</td>
								            <td>已付款订单个数：</td>
								            <td><%=dtThisMonth.Rows[0]["paiedorders"]%> 个</td>
								            <td>已完成订单个数：</td>
								            <td><%=dtThisMonth.Rows[0]["finishOrders"]%></td>
								            <td style="color:red">已完成订单总金额：</td>
                                            <td style="color:red"><%=dtThisMonth.Rows[0]["TotalPrices"]%></td>
                                        </tr>
								        <tr>
								            <td>订   单   总   数：</td>
								            <td><%=dtAll.Rows[0]["totalorders"]%>个</td>
								            <td>已付款订单个数：</td>
								            <td><%=dtAll.Rows[0]["paiedorders"]%> 个</td>
								            <td>已完成订单个数：</td>
								            <td><%=dtAll.Rows[0]["finishOrders"]%></td>
								            <td style="color:red">已完成订单总金额：</td>
                                            <td style="color:red"><%=dtAll.Rows[0]["TotalPrices"]%></td>
                                        </tr> 
                                        <tr>
                                            <td colspan=4>已发展会员：<%=totalMembers %>个<a href="MyMember.aspx">[查看]</a></td>
                                        </tr>                                      
								    </table>
<%--								    <span>上月订单总数：<%=dtPreMonth.Rows[0]["totalorders"]%>个    已付款订单个数：<%=dtPreMonth.Rows[0]["paiedorders"]%>个    已完成订单个数：<%=dtPreMonth.Rows[0]["finishOrders"]%></span>
								    <span>已付款订单总金额：<%=dtPreMonth.Rows[0]["TotalPrices"]%><br />本月订单总数：<%=dtThisMonth.Rows[0]["totalorders"]%>个    已付款订单个数：<%=dtThisMonth.Rows[0]["paiedorders"]%>个    已完成订单个数：<%=dtThisMonth.Rows[0]["finishOrders"]%></span>
								    <span>已付款订单总金额：<%=dtThisMonth.Rows[0]["TotalPrices"]%><br />订 单 总 数 ：<%=dtAll.Rows[0]["totalorders"]%>个</span>    已付款订单个数：<%=dtAll.Rows[0]["paiedorders"]%> 个    已完成订单个数：<%=dtAll.Rows[0]["finishOrders"]%></span>
								    <span>已付款订单总金额：<%=dtAll.Rows[0]["TotalPrices"]%><br /></span>
--%>								    
								</td>
								<td align="right">
<%--									<%=GetResourceString("ExtLink")%>：
									<input type="text" value="<%=GetMyAgentLink() %>" id="txtLink" size="50" /><input type="button" id="btnCopy" value="复制" onclick="copyToClipboard('txtLink')" /><br />如果点击复制没有用，请全选后"ctrl+c"复制此链接
									<br /><%=GetResourceString("SubMembers")%>：<span style="color: Blue;"><a href="<%=webSite %>MyMember.aspx" style="color: Blue;"><%=GetTotalMemberSum()%></a></span>
--%>								</td>
							</tr>
							<tr>
							    <td colspan="2">
							    查询下属会员订单<br />
							    时间：<%=GetResourceString("From")%> <asp:TextBox ID="txtDateFrom" runat="server" Width="100px"></asp:TextBox> <%=GetResourceString("To")%> <asp:TextBox ID="txtDateTo" runat="server" Width="100px"></asp:TextBox>
							    &nbsp购物会员:<asp:TextBox ID="txtMemberName" runat="server"></asp:TextBox>&nbsp<asp:Button ID="btnSearch" OnClick="btnSearch_Click" runat="server" Text="查看"></asp:Button>
							    </td>
							</tr>
						</table>
                        
                        <asp:DataGrid ID="dgOrderList" CssClass="dgborder" runat="server" AutoGenerateColumns="False" DataKeyField="OrderID" Width="100%" HorizontalAlign="Center" BorderWidth="1" 
                        BorderColor="#d6d6d6" AllowPaging="false" >
			                <ItemStyle BackColor="White"></ItemStyle>
			                <HeaderStyle BackColor="#fff7d3" Height="20px"></HeaderStyle>
                            <Columns>
                                <asp:TemplateColumn HeaderText="订单编号">
                                    <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                    <ItemStyle HorizontalAlign="center" Height="20px" Width="15%"></ItemStyle>
                                    <ItemTemplate>
                                        <a href="#" onclick='printOrder(<%# DataBinder.Eval(Container.DataItem, "OrderID") %>)'>
                                            <%# DataBinder.Eval(Container.DataItem, "OrderNo")%>
                                        </a>
                                    </ItemTemplate>
                                </asp:TemplateColumn>
                                <asp:BoundColumn DataField="OrderTime" HeaderText="下订时间" DataFormatString="{0:yyyy-MM-dd hh:mm}">
                                    <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                    <ItemStyle HorizontalAlign="Center" Width="15%"></ItemStyle>
                                </asp:BoundColumn>
								<asp:TemplateColumn HeaderText="商品金额">
                                    <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                    <ItemStyle HorizontalAlign="Center" Width="10%"></ItemStyle>
                                    <ItemTemplate>
                                        <%# DataBinder.Eval(Container.DataItem, "Productprice")%>
                                    </ItemTemplate>
                                </asp:TemplateColumn>
	<%--							<asp:TemplateColumn HeaderText="应付金额商品金额">
                                    <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                    <ItemStyle HorizontalAlign="Center" Width="10%"></ItemStyle>
                                    <ItemTemplate>
                                        <%# DataBinder.Eval(Container.DataItem, "Productprice", "{0:f}")%>
                                    </ItemTemplate>
                                </asp:TemplateColumn>
                                <asp:TemplateColumn HeaderText="总金额">
                                    <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                    <ItemStyle HorizontalAlign="Center" Width="10%"></ItemStyle>
                                    <ItemTemplate>
                                        <%# DataBinder.Eval(Container.DataItem, "Productprice", "{0:f}")%>
                                    </ItemTemplate>
                                </asp:TemplateColumn>--%>
                                <asp:TemplateColumn HeaderText="订单状态">
                                    <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                    <ItemStyle HorizontalAlign="Center" Width="10%"></ItemStyle>
                                    <ItemTemplate>
                                        <%# DataBinder.Eval(Container.DataItem, "OrderStatus")%>
                                    </ItemTemplate>
                                </asp:TemplateColumn>
                                <asp:TemplateColumn HeaderText="会员账号">
                                    <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                    <ItemStyle HorizontalAlign="Center" Width="10%"></ItemStyle>
                                    <ItemTemplate>
                                        <%# DataBinder.Eval(Container.DataItem, "MemberName")%>
                                    </ItemTemplate>
                                </asp:TemplateColumn>
<%--                                <asp:TemplateColumn HeaderText="操作">
                                    <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
                                    <ItemStyle HorizontalAlign="Center" Width="10%"></ItemStyle>
                                    <ItemTemplate>
                                        <a href="#" onclick='printOrder(<%# DataBinder.Eval(Container.DataItem, "OrderID") %>)'>
                                            <%=GetResourceString("ViewOrder")%>
                                        </a>
                                    </ItemTemplate>
                                </asp:TemplateColumn>--%>
                            </Columns>
                        </asp:DataGrid>
					    
				        <asp:panel id="plPage" visible="true" runat="server">
				        <!-- 翻页开始-->
				        <div class="page clear">
                            <div class="fpage">
                                <asp:Label ID="lbPage" class="lb-page" runat="server"></asp:Label>
                            </div>                                
				        </div>
				        <!-- 翻页结束-->
				        </asp:panel>
				        <asp:panel id="plNoProduct" visible="false" runat="server">
					        <div style="margin:20px;">
						        <h3>暂无订单纪录</h3>
					        </div>
				        </asp:panel>
                        </form>
                    </div>
		            <div class="bl"></div>
		            <div class="br"></div>
		            <div class="bm"></div>
		        </div>
                <!--内容结束-->
            </div>
        </div>
	    <uc1:Helper id="Helper1" runat="server"></uc1:Helper>
	    <uc1:Footer id="Footer1" runat="server"></uc1:Footer>
		
		<script type="text/javascript">
			function copyToClipboard(txtID) {
				if(window.clipboardData) {
					window.clipboardData.clearData();
					var txtValue=document.getElementById(txtID).value;
					window.clipboardData.setData("Text",txtValue);
				} else if(navigator.userAgent.indexOf("Opera") != -1) {
					window.location = txtValue;
					} else if (window.netscape) {
					try {
					netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
					} catch (e) {
					alert("您的firefox安全限制限制您进行剪贴板操作，请打开'about:config'将signed.applets.codebase_principal_support'设置为true'之后重试");
					return false;
					}
					var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
					if (!clip)
					return;
					var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
					if (!trans)
					return;
					trans.addDataFlavor('text/unicode');
					var str = new Object();
					var len = new Object();
					var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
					var copytext = txtValue;
					str.data = copytext;
					trans.setTransferData("text/unicode",str,copytext.length*2);
					var clipid = Components.interfaces.nsIClipboard;
					if (!clip)
					return false;
					clip.setData(trans,null,clipid.kGlobalClipboard);
				}				
				alert('复制成功!');
			}
		</script>
	</body>
</HTML>
