<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="MyCart.aspx.cs" Inherits="XpShop.WebUI.MyCart" %>
<%@ Register TagPrefix="uc1" TagName="Header" Src="Modules/CartHeader.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 xmlns="http://www.w3.org/1999/xhtml" >
<head>
	<!--#include file="../../inc/encoding.inc"-->
    <title>我的购物车</title>
    <!--#include file="../../inc/head.inc"-->
	<style type="text/css">
		.productno { text-align:center; width:100px; height:20px;}
		.productname { text-align:left;}
		.marketprice { width:50px; text-align:center;}
		.mbprice { width:50px; text-align:center;}
		.rulename { text-align:center;}
		.quantity { text-align:center; width:100px;}
		.giftremark { text-align:center; width:150px;}
		.score { text-align:center;}
		.submoney { text-align:center; width:50px;}
		.cancel { text-align:center; width:100px}
		.listbg { background:#F6F6F6;}
	</style>
	<script type="text/javascript" src="/<%=ShopFolder %>Template/<%=config.TemplateFolder%>/inc/Cart.js"></script>
	<link href="<%=webSite %>Template/<%=config.TemplateFolder%>/style/mycart.css" rel="stylesheet" />
	<script type="text/javascript">
		var markUnit = '<%=config.MarkUnit %>';
		var cartID = '<%=CartID%>';
		var couponsCode = '<%=couponsCode%>';
		var ShopFolder = '<%=ShopFolder %>';
	</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 id="CartInfo">
			<div id="dgShoppingCart">
				<table class="cart_product" cellspacing="0">
                <tbody>
                    <tr class="title">
                        <td width="10%">商品编号</td>
                        <td>商品名称</td>
                        <td width="10%">价格</td>
                        <td width="10%">优惠</td>
                        <td width="10%">赠送积分</td>
                        <td width="10%">购买数量</td>
                        <td width="10%">删除商品</td>
                    </tr>
                </tbody>
            <%--商家开始--%>
            <%for(int q=0;q<dtSupplier.Rows.Count;q++){%>
                <tbody>
                    <tr class="item">
                        <td class="storename" colspan="7">
                            <%if(dtSupplier.Rows[q]["SupplierID"].ToString()=="0"){%>
                            <span class="otherstore">：<%=config.SiteName %> </span>
				            <%}else{%>
				            <span class="otherstore">：<%=dtSupplier.Rows[q]["SupplierName"]%></span>
				            <%}%>
                        </td>
                    </tr>
                </tbody>
                <%--套装商品开始--%>
                <%System.Data.DataRow[] drSuit = dtSuit.Select("supplierid=" + dtSupplier.Rows[q]["SupplierID"].ToString());%>
                <%for (int i = 0; i < drSuit.Length; i++){%>
                <tbody id="suitd_<%=drSuit[i]["SuitID"] %>">
                    <tr class="item">
			            <td>-</td>
			            <td class="pname"><img id="suitimg_<%=drSuit[i]["SuitID"] %>" class="showsuit hand" src="images/open.gif" /><font color="red">[套装]</font><%=drSuit[i]["SuitName"]%><a id="suita_<%=drSuit[i]["SuitID"] %>" class="showsuit" href="javascript:void(0);">[查看套装商品]</a></td>
			            <td class="RedWeight">￥<%=string.Format("{0:f2}", drSuit[i]["MemberPrice"])%></td>
			            <td>￥<%=string.Format("{0:f2}", drSuit[i]["LessMoney"])%></td>
			            <td><%=drSuit[i]["Score"]%></td>
			            <td>
			                <img src='images/close.gif' class="hand" id="reduce_<%=drSuit[i]["RecordID"]%>" />
			                <input type="text" dlvunit="1" isdlvunit="1" maxlength="5" size="5" value="<%=drSuit[i]["Quantity"]%>" id="quantity_<%=drSuit[i]["RecordID"]%>" name="quantity" style="text-align: center; width:30px;"/>
			                <img src='/images/open.gif' class="hand" id="add_<%=drSuit[i]["RecordID"]%>" />
			                <input type="hidden" name="pid" value='<%=drSuit[i]["SuitID"]%>' />
			                <input type="hidden" name="gid" value='0' />
			                <input type="hidden" name="ptype" value='3' />
			            </td>
			            <td><a class="delpdt" href='javascript:void(0);'>取消此套装</a></td>
		            </tr>
                </tbody>
                <tbody id="suit_<%=drSuit[i]["SuitID"] %>" class="hide">
                    <%--遍历套装商品明细开始--%>
                    <%System.Data.DataRow[] drSuitPdt = dtPdt.Select("suitid=" + drSuit[i]["SuitID"].ToString());%>
                    <%for (int j = 0; j < drSuitPdt.Length; j++){%>
                    <tr class="item">
			            <td><%=drSuitPdt[j]["ProductNo"]%></td>
			            <td class="pname"><div class="pimg"><a href='<%=webSite %>products/product-<%=drSuitPdt[j]["ProductID"]%>.<%=config.html%>' target="_blank"><img src="<%=webSite %>upload/productimg/<%=drSuitPdt[j]["ImgFolder"]%><%=drSuitPdt[j]["ProductImg"]%>" /></a></div><a href='<%=webSite %>products/product-<%=drSuitPdt[j]["ProductID"]%>.<%=config.html %>' target="_blank"><%=drSuitPdt[j]["ProductName"]%><span style="color:Red;"><%=drSuitPdt[j]["RuleName"].ToString() != "" ? ("(" + drSuitPdt[j]["RuleName"] + ")") : ""%></span><span style="color:Red;"><%=drSuitPdt[j]["remark"]%></span></a></td>
			            <td class="RedWeight">￥<%=string.Format("{0:f2}", drSuitPdt[j]["pmtprice"])%></td>
			            <td>￥<%=string.Format("{0:f2}", drSuitPdt[j]["LessMoney"])%></td>
			            <td>-</td>
			            <td><%=(int)drSuitPdt[j]["Quantity"]/(int)drSuit[i]["Quantity"]%>×<%=drSuit[i]["Quantity"]%></td>
			            <td>-</td>
		            </tr>
                    <%} %>
                    <%--遍历套装商品明细结束--%>
                </tbody>
                <%} %>
                <%--套装商品结束--%>
                <%--普通商品开始--%>
                <%System.Data.DataRow[] drPdt = dtPdt.Select("supplierid=" + dtSupplier.Rows[q]["SupplierID"].ToString()+"and suitid=0");%>
                <%if (drPdt.Length > 0){ %>
                <tbody>
                <%for (int i = 0; i < drPdt.Length; i++){%>
                    <tr class="item">
			            <td><%=drPdt[i]["ProductNo"]%></td>
			            <td class="pname">
			                <div class="pimg"><a href='<%=webSite %>products/product-<%=drPdt[i]["ProductID"]%>.<%=config.html%>' target="_blank"><img src="<%=webSite %>upload/productimg/<%=drPdt[i]["ImgFolder"]%><%=drPdt[i]["ProductImg"]%>" /></a></div>
			                <a href='<%=webSite %>products/product-<%=drPdt[i]["ProductID"]%>.<%=config.html %>' target="_blank"><%=drPdt[i]["ProductName"]%><span style="color:Red;"><%=drPdt[i]["RuleName"].ToString() != "" ? ("(" + drPdt[i]["RuleName"] + ")") : ""%></span><span style="color:Red;"><%=drPdt[i]["remark"]%></span></a>
			                <%System.Data.DataRow[] drCoupon = dtSendCoupon.Select("supplierid=" + dtSupplier.Rows[q]["SupplierID"].ToString()+" and productid="+drPdt[i]["ProductID"].ToString());%>
			                <%for (int j = 0; j < drCoupon.Length; j++){%>
			                <div><font color="red">[赠品]</font><%=drCoupon[j]["CouponName"]%><font color="red">× <%=drCoupon[j]["Number"]%>(订单完成后自动发放)</font></div>
			                <%} %>
			            </td>
			            <td class="RedWeight">￥<%=string.Format("{0:f2}", drPdt[i]["pmtprice"])%></td>
			            <td>￥<%=string.Format("{0:f2}", drPdt[i]["LessMoney"])%></td>
			            <td><%=drPdt[i]["Score"]%></td>
			            <td>
			                <img src='images/close.gif' class="hand" id="reduce_<%=drPdt[i]["RecordID"]%>" />
				            <input name="quantity" type="text" style="text-align: center; width:30px;" id="quantity_<%=drPdt[i]["RecordID"]%>" value='<%=(int)drPdt[i]["Quantity"] / ((int)drPdt[i]["IsDlvUnit"] == 0 ? 1 : (int)drPdt[i]["DlvUnit"]) %>' size="5" maxlength="5" IsDlvUnit='<%=drPdt[i]["IsDlvUnit"]%>' DlvUnit='<%=drPdt[i]["DlvUnit"]%>' /><%=((int)drPdt[i]["IsDlvUnit"] == 0 || (int)drPdt[i]["DlvUnit"] == 1) ? "" : ("×" + drPdt[i]["DlvUnit"]) %>
				            <img src='/images/open.gif' class="hand" id="add_<%=drPdt[i]["RecordID"]%>" />
				            <input type="hidden" name="recordID" value='<%=drPdt[i]["RecordID"]%>' />
				            <input type="hidden" name="score_<%=drPdt[i]["RecordID"]%>" value='<%=drPdt[i]["Score"]%>' />
				            <input type="hidden" name="pid" value='<%=drPdt[i]["ProductID"]%>' />
				            <input type="hidden" name="gid" value='<%=drPdt[i]["GoodsID"]%>' />
				            <input type="hidden" name="min" id="min_<%=drPdt[i]["RecordID"]%>" value='<%=(int)drPdt[i]["IsDlvUnit"] == 0 ? (int)drPdt[i]["MiniBuyNum"] : ((int)drPdt[i]["MiniBuyNum"] / (int)drPdt[i]["DlvUnit"]) %>' />							        
                            <input type="hidden" name="ptype" value='1' />
                        </td>
                        <td><a class="delpdt" href='javascript:void(0);'>取消此商品</a></td>
		            </tr>
                <%} %>
                </tbody>
                <%} %>
                <%--普通商品结束--%>
                <%--礼品开始--%>
                <%System.Data.DataRow[] drGift = dtGift.Select("supplierid=" + dtSupplier.Rows[q]["SupplierID"].ToString());%>
                <%if (drGift.Length > 0){%>
                <tbody>
		        <%for (int i = 0; i < drGift.Length; i++){%>
		        <tr class="item">
			        <td><%=drGift[i]["ProductNo"]%></td>
			        <td class="pname"><a href='<%=webSite %>products/product-<%=drGift[i]["ProductID"]%>.<%=config.html %>' target="_blank"><%=drGift[i]["ProductName"]%><span style="color:Red;"><%=drGift[i]["RuleName"].ToString() != "" ? ("(" + drGift[i]["RuleName"] + ")") : ""%></span><span style="color:Red;"><%=drGift[i]["giftremark"]%></span></a></td>
			        <td class="RedWeight">￥<%=string.Format("{0:f2}", drGift[i]["pmtprice"])%></td>
			        <td>￥<%=string.Format("{0:f2}", drGift[i]["LessMoney"])%></td>
			        <td>0</td>
			        <td><%=drGift[i]["giftnumber"]%></td>
			        <td><%=(int)drGift[i]["isSystemAdd"] == 0 ? ("<a class='delpdt' href='javascript:void(0);'>取消此礼品</a>") : "-"%></td>
		        </tr>
		        <%}%>
		        </tbody>
		        <%}%>
		        <%--礼品结束--%>
		    <%}%>
		    <%--商家结束--%>
            </table>
			</div>
			<div class="total-xq clear">
			    <div style="float:left; margin-top:20px;">
					<a href='<%=webSite %>index.<%=config.html%>'><img src='Images/<%=GetResourceString("ButtonCartContinue")%>' border="0"></a>&nbsp;
					<a href="Actions.aspx?Action=EmptyCart"><img src='Images/<%=GetResourceString("ButtonCartClear")%>' border="0"></a>&nbsp;
				</div>
				<div style=" float:right; text-align:right;margin:10px;">
					重量总计：<span id="totalweight"><%=string.Format("{0:f2}",totalweight)%></span>
					商品数量：<span id="total_quantity"><%=totalnumber%></span>&nbsp;&nbsp;
					<% if(config.MarkUnit == 1) {%>
					赠送积分：<span id="totalScore"><%=totalscore%></span>&nbsp;&nbsp;
					<% }%>
					原始金额：￥<span id="oldtotalprice"><%=string.Format("{0:f}",totalmoney+promotionprice) %></span>元&nbsp;&nbsp;
					优惠：￥<span id="promotionprice"><%=string.Format("{0:f}",promotionprice) %></span>元
					<br/>
					商品总金额(不含运费)：<em style="font-size:24px;">￥<span id="totalprice"><%=string.Format("{0:f}",totalmoney) %></span></em>
				</div>
			</div>
			</div>
			<div class="clear" style="padding-top:30px;">
				
				<%if(dtSupplier.Rows.Count==1){%>
				<div style="float:right;"><a href='<%=webSite %>CheckOut-<%=dtSupplier.Rows[0]["SupplierID"] %>.<%=config.html%>'><img src='Images/<%=GetResourceString("ButtonCartNext")%>' border="0"></a></div>
				<%}else{%>
				<div style="float:right;"><a href='<%=webSite %>DispartOrder.<%=config.html%>'><img src='Images/<%=GetResourceString("ButtonCartNext")%>' border="0"></a></div>
				<%}%>
			</div>
            <div class="clear">
            <%--
            可选礼品<%=CurrentUser == null ? "<font color='Red'>(登录后显示)</font>" : "" %>
			<asp:datagrid id="dgGiftGoods" runat="server"
	            AutoGenerateColumns="False" DataKeyField="uid" Width="100%" HorizontalAlign="Center" BorderWidth="1"
	            BorderColor="#dbdbdb">
	            <ItemStyle BackColor="White"></ItemStyle>
	            <HeaderStyle BackColor="#f6f6f6" Height="20px"></HeaderStyle>
	            <Columns>
		            <asp:TemplateColumn HeaderText="礼品编号">
			            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
			            <ItemStyle  CssClass="productno"></ItemStyle>
			            <ItemTemplate>
				            <%# DataBinder.Eval(Container.DataItem, "ProductNo") %>
			            </ItemTemplate>
		            </asp:TemplateColumn>
		            <asp:TemplateColumn HeaderText="礼品名称">
			            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
			            <ItemStyle CssClass="productname"></ItemStyle>
			            <ItemTemplate>
				            <a href='/<%=ShopFolder %>products/product-<%#DataBinder.Eval(Container.DataItem,"ProductID")%>.<%=config.html%>' target="_blank">
				            <%# DataBinder.Eval(Container.DataItem, "ProductName") %>　<span style="color:Red;">(<%# DataBinder.Eval(Container.DataItem, "RuleName") %>)</span>
				                <span style="color:Red;"><%# DataBinder.Eval(Container.DataItem, "giftremark") %></span>
				            </a>
			            </ItemTemplate>
		            </asp:TemplateColumn>
		            <asp:TemplateColumn HeaderText="市场价">
			            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
			            <ItemStyle CssClass="marketprice"></ItemStyle>
			            <ItemTemplate>
				            <%# DataBinder.Eval(Container.DataItem, "MarketPrice","{0:f2}") %>
			            </ItemTemplate>
		            </asp:TemplateColumn>
		            <asp:TemplateColumn HeaderText="换购价">
			            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
			            <ItemStyle CssClass="mbprice"></ItemStyle>
			            <ItemTemplate>
				            <%# DataBinder.Eval(Container.DataItem, "promotionprice","{0:f2}") %>
			            </ItemTemplate>
		            </asp:TemplateColumn>
		            <asp:TemplateColumn HeaderText="礼品数量">
			            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
			            <ItemStyle  CssClass="quantity"></ItemStyle>
			            <ItemTemplate>
				            <%# DataBinder.Eval(Container.DataItem, "giftnumber") %>
			            </ItemTemplate>
		            </asp:TemplateColumn>
		            <asp:TemplateColumn HeaderText="选择礼品">
			            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
			            <ItemStyle CssClass="cancel"></ItemStyle>
			            <ItemTemplate>
							<a href='/<%=ShopFolder %>Actions.aspx?action=AddGiftCart&ruleuid=<%# DataBinder.Eval(Container.DataItem, "ruleuid") %>&productid=<%# DataBinder.Eval(Container.DataItem, "productid") %>&gnum=<%# DataBinder.Eval(Container.DataItem, "giftnumber") %>'>添加到购物车</a>
			            </ItemTemplate>
		            </asp:TemplateColumn>
	            </Columns>
            </asp:datagrid>
            --%>
            </div>
            
		<!--内容结束-->
	</div>				
	</form>
	<uc1:Footer id="Footer1" runat="server"></uc1:Footer>
</body>
</html>
