<%@ Page language="c#" Codebehind="Cart.aspx.cs" AutoEventWireup="true" Inherits="XpShop.WebUI.Cart" %>
<%@ Register TagPrefix="uc1" TagName="Footer" Src="Modules/Footer.ascx" %>
<%@ Register TagPrefix="uc1" TagName="Helper" Src="Modules/Helper.ascx" %>
<%@ Register TagPrefix="uc1" TagName="Header" Src="Modules/CartHeader.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("ShoppingCart")%>
		</title>
		<!--#include file="../../inc/head.inc"-->
		<script type="text/javascript" src="<%=webSite %>Template/<%=config.TemplateFolder%>/inc/Cart.js"></script>
		<script type="text/javascript">
		    var markUnit = '<%=config.MarkUnit %>';
			var cartID = '<%=CartID%>';
			var couponsCode = '<%=couponsCode%>';
			var ShopFolder = '<%=ShopFolder %>';
			var scoreRate = <%=config.ScoreRate %>;
		</script>
		<script type="text/javascript">
            $(document).ready(function(){
                 $('#dgShoppingCart').attr('rules','none')
            });
        </script> 
	</HEAD>
	<body>
	    <uc1:Header id="Header1" runat="server"></uc1:Header>
		<form id="Form1" method="post" runat="server">
		<div class="xp-w clear">
			<div class="cart_step clear">
			    <div style="float:left; margin-right:20px;"><%=config.SiteLogo %></div>
	            <ul>
	                <li class="onc">
	                    1.我的购物车
	                </li>
	                <li class="outco">
	                    2.选择订单
	                </li>
	                <li class="outco">
	                   <%-- 3.填写核对订单信息--%>
	                   3.确认订单信息
	                </li>
	                <li class="outcs">
	                    4.成功提交订单
	                </li>
	            </ul>
	        </div>
			<!--内容开始-->
			<div class="cartframe">
				<div class="tl"></div>
				<div class="tr"></div>
				<div class="tm">
				    <div class="frmtitle">
    				    <%if(pnum > 0) {%>
					        我已挑选的商品
					    <%} %>
					    <% if(giftNum > 0) {%>
					        要兑换的礼品
					    <%} %>
				    </div>
				</div>
				<div class="mm">
				    <%if(pnum > 0) {%>
					
					<asp:datagrid id="dgShoppingCart" runat="server"
		                AutoGenerateColumns="False" DataKeyField="RecordID" Width="100%" HorizontalAlign="Center" BorderWidth="0">
		                <ItemStyle BackColor="White" CssClass="xp-cart-tab-css"></ItemStyle>
		                <HeaderStyle CssClass="xp-cart-tabth-css" ></HeaderStyle>
		                <Columns>
			                <asp:TemplateColumn HeaderText="商品编号" Visible="false">
				                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
				                <ItemStyle HorizontalAlign="Center" Height="20px"></ItemStyle>
				                <ItemTemplate>
                                    <%--20110108 modify by liwenhai--%>
                                    <%--<%# DataBinder.Eval(Container.DataItem, "ProductNo") %>--%>
					                <%# DataBinder.Eval(Container.DataItem, "GoodsNo") %>
				                </ItemTemplate>
			                </asp:TemplateColumn>
			                <asp:TemplateColumn HeaderText="商品名称">
				                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
				                <ItemStyle></ItemStyle>
				                <ItemTemplate>
				                    <div style="float:left; width:100px; height:100px; overflow:hidden; margin:10px 10px 10px 26px; display:inline;">
			                            <img width="100px" height="100" src="<%=webSite %>upload/ProductImg/<%# DataBinder.Eval(Container.DataItem,"ImgFolder")%><%#DataBinder.Eval(Container.DataItem,"Img5")%>">
			                        </div>
			                        <span style="display:block; height:8px; overflow:hidden;"></span>
					                <%# DataBinder.Eval(Container.DataItem, "ProductName") %>
					                <br />
					                <asp:Repeater ID="rptPrePdts" runat="server" DataSource='<%# BindPrePdts((int)DataBinder.Eval(Container.DataItem,"ProductID")) %>'>
						                <ItemTemplate>
						                    <span style="color:Red;">[赠品]</span><%# DataBinder.Eval(Container.DataItem,"ProductName") %>  <span style="color:Red;">×<%# DataBinder.Eval(Container.DataItem,"PresentNum") %></span><br />
						                </ItemTemplate>
						            </asp:Repeater>
						            
						            <asp:Repeater ID="rptPreGifts" runat="server" DataSource='<%# BindPreGifts((int)DataBinder.Eval(Container.DataItem,"ProductID")) %>'>
						                <ItemTemplate>
						                    <span style="color:Red;">[赠品]</span><%# DataBinder.Eval(Container.DataItem, "GiftName")%>  <span style="color:Red;">×<%# DataBinder.Eval(Container.DataItem,"PresentNum") %></span><br />
						                </ItemTemplate>
						            </asp:Repeater>
				                </ItemTemplate>
			                </asp:TemplateColumn>
			                <asp:TemplateColumn HeaderText="规格">
				                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
				                <ItemStyle HorizontalAlign="left"></ItemStyle>
				                <ItemTemplate>
									<%# DataBinder.Eval(Container.DataItem, "ProductSpecs") %>
				                </ItemTemplate>
			                </asp:TemplateColumn>
			                <asp:TemplateColumn HeaderText="会员价">
				                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
				                <ItemStyle HorizontalAlign="Center"></ItemStyle>
				                <ItemTemplate>
									<%# DataBinder.Eval(Container.DataItem, "MemberPrice","{0:f2}") %>
									<%#DataBinder.Eval(Container.DataItem, "IsBuyLimited").ToString() == "1" ? "<br><font color=red>（抢购价）</font>" : ""%>
				                </ItemTemplate>
			                </asp:TemplateColumn>
			                <asp:TemplateColumn HeaderText="商品数量">
				                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
				                <ItemStyle HorizontalAlign="Center"></ItemStyle>
				                <ItemTemplate>
									<img src='<%=webSite %>Template/<%=config.TemplateFolder %>/images/cart_reduce.gif' alt='减少' class="hand" id="reduce_<%#DataBinder.Eval(Container.DataItem, "RecordID")%>" />
									<input name="quantity" type="text" style="text-align: center;" id="quantity<%#DataBinder.Eval(Container.DataItem, "RecordID")%>" value='<%# DataBinder.Eval(Container.DataItem, "Quantity") %>' size="5" maxlength="10" />
									<img src='<%=webSite %>Template/<%=config.TemplateFolder %>/images/cart_add.gif' alt='增加' class="hand" id="add_<%#DataBinder.Eval(Container.DataItem, "RecordID")%>" />
									<input type="hidden" name="memberPrice" value='<%#DataBinder.Eval(Container.DataItem, "MemberPrice")%>' /><%--单价--%>
									<input type="hidden" name="weight" value='<%#DataBinder.Eval(Container.DataItem, "Weight")%>' /><%--重量--%>
								    <input type="hidden" id='pid_<%# DataBinder.Eval(Container.DataItem, "RecordID") %>' value='<%# DataBinder.Eval(Container.DataItem, "ProductID") %>' /><%--ProductID--%>
								    <input type="hidden" id="gid_<%#DataBinder.Eval(Container.DataItem, "RecordID")%>" value='<%# DataBinder.Eval(Container.DataItem, "GoodsID") %>' /><%--GoodsID--%>
								    <input type="hidden" id="min_<%#DataBinder.Eval(Container.DataItem, "RecordID")%>" value='<%# DataBinder.Eval(Container.DataItem, "MiniBuyNum") %>' /><%--最少购买数量--%>										
				                </ItemTemplate>
			                </asp:TemplateColumn>
			                <asp:TemplateColumn HeaderText="积分支付">
				                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
				                <ItemStyle HorizontalAlign="Center"></ItemStyle>
				                <ItemTemplate>
									<div style="<%# (int)DataBinder.Eval(Container.DataItem, "UseScore") == 0 ? "display:none" : "" %>">
									每件最多接受积分：<%# DataBinder.Eval(Container.DataItem, "UseScore") %><input type="hidden" id='maxscore_<%# DataBinder.Eval(Container.DataItem, "RecordID") %>' value='<%# DataBinder.Eval(Container.DataItem, "UseScore") %>' />
									<br />
									<span id='use_<%# DataBinder.Eval(Container.DataItem, "RecordID") %>' recID='<%# DataBinder.Eval(Container.DataItem, "RecordID") %>' style="text-decoration:underline; cursor:pointer;<%# (int)DataBinder.Eval(Container.DataItem, "UsedScore") != 0 ? "display:none" : "" %>">使用积分</span>
									<span id='score_<%# DataBinder.Eval(Container.DataItem, "RecordID") %>' recID='<%# DataBinder.Eval(Container.DataItem, "RecordID") %>' style="<%# (int)DataBinder.Eval(Container.DataItem, "UsedScore") != 0 ? "" : "display:none" %>">
									    <input type="text" id="usedscore_<%# DataBinder.Eval(Container.DataItem, "RecordID") %>" recID='<%# DataBinder.Eval(Container.DataItem, "RecordID") %>' oldvalue='<%# DataBinder.Eval(Container.DataItem, "UsedScore") %>' value='<%# DataBinder.Eval(Container.DataItem, "UsedScore") %>' size="5" style="text-align:center; display:none;" />
									    <span id='save_<%# DataBinder.Eval(Container.DataItem, "RecordID") %>' recID='<%# DataBinder.Eval(Container.DataItem, "RecordID") %>' style="cursor:pointer; text-decoration:underline; display:none;">确定</span>
									    <span id="scoreinfo_<%# DataBinder.Eval(Container.DataItem, "RecordID") %>" style="color:Red;">您已使用积分抵扣<%# (int)DataBinder.Eval(Container.DataItem, "UsedScore") * config.ScoreRate %>元</span>&nbsp;
									    <span id='cancel_<%# DataBinder.Eval(Container.DataItem, "RecordID") %>' recID='<%# DataBinder.Eval(Container.DataItem, "RecordID") %>' style="cursor:pointer; text-decoration:underline">取消</span>
									</span>
									</div>
				                </ItemTemplate>
			                </asp:TemplateColumn>
			                <asp:TemplateColumn HeaderText="删除商品">
				                <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
				                <ItemStyle HorizontalAlign="Center"></ItemStyle>
				                <ItemTemplate>
									<a id='a_<%# DataBinder.Eval(Container.DataItem, "ProductID") %>' href='Actions.aspx?Action=DeleteCartItem&pid=<%# DataBinder.Eval(Container.DataItem, "ProductID") %>&GID=<%# DataBinder.Eval(Container.DataItem, "GoodsID") %>&ptype=1'>
										<img height="16" src="images/delete.gif" width="16" border="0"></a>
				                </ItemTemplate>
			                </asp:TemplateColumn>
		                </Columns>
	                </asp:datagrid>
					<%} %>
					<br />
					<% if(giftNum > 0) {%>
					    
					    <asp:datagrid id="dgGifts" runat="server"
		                    AutoGenerateColumns="False" DataKeyField="RecordID" Width="100%" HorizontalAlign="Center" BorderWidth="0">
		                    <ItemStyle BackColor="White" CssClass="xp-cart-tab-css"></ItemStyle>
		                    <HeaderStyle CssClass="xp-cart-tabth-css" ></HeaderStyle>
		                    <Columns>
			                    <asp:TemplateColumn HeaderText="礼品名称">
				                    <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
				                    <ItemStyle></ItemStyle>
				                    <ItemTemplate>
					                    <%# DataBinder.Eval(Container.DataItem, "GiftName") %>
				                    </ItemTemplate>
			                    </asp:TemplateColumn>
			                    <asp:TemplateColumn HeaderText="积分">
				                    <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
				                    <ItemStyle HorizontalAlign="Center"></ItemStyle>
				                    <ItemTemplate>
									    <%# DataBinder.Eval(Container.DataItem, "Integral") %>
				                    </ItemTemplate>
			                    </asp:TemplateColumn>
			                    <asp:TemplateColumn HeaderText="兑换数量">
				                    <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
				                    <ItemStyle HorizontalAlign="Center"></ItemStyle>
				                    <ItemTemplate>
									    <img src='<%=webSite %>Template/<%=config.TemplateFolder %>/images/cart_reduce.gif' alt='减少' class="hand" id="reduce_<%#DataBinder.Eval(Container.DataItem, "RecordID")%>" />
									    <input name="quantity" type="text" style="text-align: center;" id="quantity<%#DataBinder.Eval(Container.DataItem, "RecordID")%>" value='<%# DataBinder.Eval(Container.DataItem, "Quantity") %>' size="9" maxlength="10" />
									    <img src='<%=webSite %>Template/<%=config.TemplateFolder %>/images/cart_add.gif' alt='增加' class="hand" id="add_<%#DataBinder.Eval(Container.DataItem, "RecordID")%>" />
									    <input type="hidden" name="memberPrice" value='0' />
									    <input type="hidden" name="weight" value='0' /><%--重量--%>
									    <input type="hidden" id='pid_<%# DataBinder.Eval(Container.DataItem, "RecordID") %>' value='<%# DataBinder.Eval(Container.DataItem, "GiftID") %>' /><%--ProductID--%>
								        <input type="hidden" id="gid_<%# DataBinder.Eval(Container.DataItem, "RecordID") %>" value='0' /><%--GoodsID--%>
								        <input type="hidden" id='min_<%# DataBinder.Eval(Container.DataItem, "RecordID") %>' value='1' /><%--最少购买数量--%>
				                    </ItemTemplate>
			                    </asp:TemplateColumn>
			                    <asp:TemplateColumn HeaderText="删除">
				                    <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
				                    <ItemStyle HorizontalAlign="Center" Width="100"></ItemStyle>
				                    <ItemTemplate>
									    <a id='a_<%# DataBinder.Eval(Container.DataItem, "GiftID") %>' href='Actions.aspx?Action=DeleteCartItem&pid=<%# DataBinder.Eval(Container.DataItem, "GiftID") %>&ptype=2&GID=0'>
										    <img height="16" src="images/delete.gif" width="16" border="0"></a>
				                    </ItemTemplate>
			                    </asp:TemplateColumn>
		                    </Columns>
	                    </asp:datagrid>
					<%} %>
					<div class="clear" style=" background-color:#f5f5f5; color:#484848; text-align:right; zoom:1; padding:10px 10px 10px 0px;">
						<div style="text-align:right;">
						    <%--重量总计： <span id="totalWeight"><%=GetTotalWeight()%></span>Kg&nbsp;&nbsp; --%>
						    商品数量：<span id="total_quantity"><%=GetTotalQuantity()%></span>&nbsp;&nbsp;
						    <% if(config.MarkUnit == 1) {%>
						    赠送积分：<span id="totalScore"><%=GetScore()%></span>&nbsp;&nbsp;
						    消费积分：<span id="usedscore"><%=usedScore%></span>
						    <% }%>
						</div>
					    <div style="float:right;">
					        <%--<table class="subdesc" cellpadding="0" cellspacing="0" border="0">
					            <tr>
					                <th>商品总金额(不含运费)：</th>
					                <td>
					                    <span class="RedWeight" style="font-size:14px;"><%=GetCurrencySign() %><span id="total"><%=NewTotal%></span></span>元
					                </td>
					            </tr>
					            <tr>
					                <th>当前享受的订单优惠：</th>
					                <td><div id="favourable"></div></td>
					            </tr>
					        </table>--%>
					        <div id="favourable"><%=favourable%></div>
					    </div>
					</div>
					
					
				</div>
				<div style=" padding-top:30px; zoom:1;">
					<div style="float:left;">
					    <a href='<%=webSite %>index.<%=config.html%>'><img src='Images/<%=GetResourceString("ButtonCartContinue")%>' border="0"></a>&nbsp;
					    <asp:ImageButton id="ibtUpdate" runat="server" ImageUrl="Images/cart_change.gif" BorderWidth="0" Visible="False"></asp:ImageButton>
					    <a href="Actions.aspx?Action=EmptyCart"><img src='Images/<%=GetResourceString("ButtonCartClear")%>' border="0"></a>&nbsp;
					</div>
					<div style="float:right;"><asp:ImageButton id="ibtNextStep" onclick="ibtNextStep_Click" runat="server" ImageUrl="Images/cart_to_check.jpg" BorderWidth="0"></asp:ImageButton></div>
				</div>
				<div class="clear"></div>
				<%--输入优惠券--%>
				<div class="clear" style="BORDER-RIGHT:#b5b5b5 1px solid; BORDER-TOP:#b5b5b5 1px solid; BORDER-LEFT:#b5b5b5 1px solid; BORDER-BOTTOM:#b5b5b5 1px solid; HEIGHT:80px; BACKGROUND-COLOR:#e4f0ff; display:none;"
					id="coupons"><br>
					<span style="FONT-WEIGHT:bold; FONT-SIZE:15px; MARGIN:10px">使用优惠券</span>
					<div style="BORDER-RIGHT:#b5b5b5 1px solid; BORDER-TOP:#b5b5b5 1px solid; MARGIN:10px; BORDER-LEFT:#b5b5b5 1px solid; LINE-HEIGHT:30px; BORDER-BOTTOM:#b5b5b5 1px solid; HEIGHT:30px; BACKGROUND-COLOR:white"><FONT face="宋体"></FONT>
						<br style="LINE-HEIGHT:3px">
						<input type="text" id="txtCoupons" name="txtCoupons" size="40">&nbsp; <input type="button" id="btnCoupons" name="btnCoupons" value="输入优惠券号码">
						<span id="spanCoupons" style="DISPLAY:none">使用的优惠券：<span id="usedCoupons"></span>&nbsp;&nbsp;&nbsp;&nbsp;<span id="cancelCoupons" style="CURSOR:pointer">
								<u>取消优惠券</u></span></span>
					</div>
				</div>
			</div>	
			
			<div class="cartfrm2 clear">
	            <div class="tl"></div>
		        <div class="tr"></div>
		        <div class="tm"><div class="frmtitle">购买该商品的用户还购买了</div></div>
		        <div class="ml"></div>
		        <div class="mr"></div>
		        <div class="mm" style="zoom:1;">
		            
				    <%BindAlsoBuyPdts(6); %>
				    <ul id="cartalsobuy">
				    <asp:Repeater ID="rptAlsoBuy" runat="server">
				        <ItemTemplate>
				         <li>
				            <table>
				                <tr>
				                    <td>
				                        <img width="100px" height="100" src="<%=webSite %>upload/ProductImg/<%# DataBinder.Eval(Container.DataItem,"ImgFolder")%><%#DataBinder.Eval(Container.DataItem,"Img5")%>" alt='<%# DataBinder.Eval(Container.DataItem,"ProductName") %>'>
				                    </td>
				                    <td>
				                        <a href='<%=webSite %>products/product-<%# DataBinder.Eval(Container.DataItem,"ProductID") %>.<%=config.html %>'><%# DataBinder.Eval(Container.DataItem,"ProductName") %></a>
				                        <div style="line-height:25px;">
				                        <span class="RedWeight"><%=GetCurrencySign() %><%# DataBinder.Eval(Container.DataItem,"MemberPrice") %></span>
				                        <%--<span style="text-decoration:line-through; font-size:11px; margin-left:30px; font-family:Arial Baltic"><%# DataBinder.Eval(Container.DataItem,"MarketPrice") %></span>--%>
				                        </div>
				                        <a href='<%=webSite %>Cart-<%# DataBinder.Eval(Container.DataItem,"ProductID") %>.<%=config.html %>'><div class="cartbuy">　　加入购物车</div></a>
				                    </td>
				                </tr>
				            </table>
				         </li>
				        </ItemTemplate>
				    </asp:Repeater>
				    </ul>
				    <div class="clear"></div>
		        </div>
		        <div class="bl"></div>
		        <div class="br"></div>
		        <div class="bm"></div>
	        </div>
			<!--内容结束-->
		</div>				
		</form>
		<uc1:Helper id="Helper1" runat="server"></uc1:Helper>
		<uc1:Footer id="Footer1" runat="server"></uc1:Footer>
	</body>
</HTML>
