<%@ page language="C#" autoeventwireup="true" inherits="_ShoppingCart, WebApp_deploy" viewstateencryptionmode="Never" enableviewstatemac="false" validaterequest="false" %>

<%@ Import Namespace="HoWave.Common" %>
<!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" runat="server">
<head>
    <title>查看购物车</title>
    <script src="Skin/CommStyle/js/jquery-1.8.3.min.js" type="text/javascript"></script>
    <link href="Skin/TopStyle/Basic.css" rel="stylesheet" type="text/css" />
    <link href="Skin/Default/Customer/car.css" rel="stylesheet" type="text/css" />
    <link href="Skin/CommStyle/main.css" rel="stylesheet" type="text/css" />
    <%--商品数量加减按钮--%>
    <link href="Skin/ShowProductStyle/common_shop.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <!-- 对应模板中的 {form1/} 标签 开始-->
    <form id="form1" runat="server">
    <hl:Top ID="Top1" runat="server" />
    <div id="main" class="main">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
        <div align="center">
            <br />
            <img height="108" alt="" src="images/guc_04.gif" width="202"><img height="108" src="images/guc_07.gif"
                alt="会员登录" width="81"><img height="108" alt="" src="images/guc_08.gif" width="14"><img
                    height="108" alt="" src="images/guc_05-2.gif" alt="查看购物车" width="81"><img height="108"
                        alt="" src="images/guc_08.gif" width="14"><img height="108" src="images/guc_09.gif"
                            width="119"><img height="108" alt="" src="images/guc_08.gif" width="14"><img height="108"
                                src="images/guc_11.gif" width="81"><img height="108" alt="" src="images/guc_08.gif"
                                    width="14"><img height="108" src="images/guc_13.gif" width="81"><img height="108"
                                        alt="" src="images/guc_14.gif" width="39">
        </div>
        <br>
        <div style="text-align: center" id="shopcarcontdiv" runat="server">
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowCancelingEdit="GridView1_RowCancelingEdit"
                        OnRowEditing="GridView1_RowEditing" OnRowUpdating="GridView1_RowUpdating" CssClass="gv_table"
                        OnRowDataBound="GridView1_RowDataBound">
                        <Columns>
                            <asp:TemplateField>
                                <EditItemTemplate>
                                    &nbsp;
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <asp:CheckBox ID="cb_select" runat="server" />
                                    <asp:HiddenField ID="productID" runat="server" Value='<%# Eval("productID") %>' />
                                    <asp:HiddenField ID="hfCartID" runat="server" Value='<%# Eval("CartID") %>' />
                                </ItemTemplate>
                                <HeaderTemplate>
                                    <asp:CheckBox ID="cb_selectAll" runat="server" AutoPostBack="True" OnCheckedChanged="cb_selectAll_CheckedChanged"
                                        Text="全选" />
                                </HeaderTemplate>
                                <ItemStyle HorizontalAlign="Center" />
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="商品图片">
                                <ItemStyle HorizontalAlign="left" VerticalAlign="Middle" Width="30%" />
                                <ItemTemplate>
                                    <table cellpadding="0" cellspacing="0" class="cart-p4">
                                        <tr>
                                            <td>
                                                <a href="showProduct.aspx?productID=<%# Eval("productID") %>" title='<%# Eval("ProductName") %>'
                                                    target="_blank">
                                                    <%--<img  onerror="this.src='/images/nopicture.gif'" onload="return ResizeImage(this,120,120)"
                                                    src='<%# Eval("productpic") %>' />--%>
                                                    <img src='<%# Eval("productpic").IsNull()==""?"/images/nopicture.gif":Eval("productpic") %>'
                                                        alt="" />
                                                </a>
                                            </td>
                                            <td class="td-p4">
                                                <a href="showProduct.aspx?productID=<%# Eval("productID") %>" title='<%# Eval("ProductName") %>'
                                                    target="_blank">
                                                    <asp:Label ID="LbName" runat="server" Text='<%#Eval("ProductName") %>'></asp:Label></a>
                                            </td>
                                        </tr>
                                    </table>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="商品规格">
                                <ItemTemplate>
                                    <%# Eval("ShoppingCarGuige")%>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:HyperLinkField DataNavigateUrlFields="shopID" DataNavigateUrlFormatString="Store/ShopIndex.aspx?ShopID={0}"
                                DataTextField="shopName" HeaderText="所属店铺">
                                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                            </asp:HyperLinkField>
                            <asp:TemplateField HeaderText="商品价格">
                                <EditItemTemplate>
                                    <asp:Label ID="Label3" runat="server" Text='<%# Eval("productPrice") %>'></asp:Label>
                                </EditItemTemplate>
                                <ItemStyle HorizontalAlign="Center" />
                                <ItemTemplate>
                                    <asp:Label ID="Label3" runat="server" Text='<%# Eval("productPrice") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="商品数量">
                                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="10%" />
                                <%--<EditItemTemplate>
                                    <asp:TextBox ID="txt_productNum" runat="server" Text='<%# Eval("buyproductNum") %>'
                                        Width="58px" CssClass="text"></asp:TextBox>
                                    <asp:TextBox ID="txt_productNum" runat="server" Text='<%# Eval("buyproductNum") %>'
                                        Width="30px" CssClass="text"></asp:TextBox>
                                    <asp:HiddenField ID="hfStocks" runat="server" Value='<%# Eval("productStocks") %>' />
                                </EditItemTemplate>--%>
                                <ItemTemplate>
                                    <div class="nc-figure-input">
                                        <img id="decrease" runat="server" src="~/Skin/ShowProductStyle/images/jian2.bmp"
                                            style="width: 16px; height: 15px;" />
                                        <%--<input type="button" id="decrease" runat="server" value="-" style="background-image: Skin/ShowProductStyle/images/jian1.bmp;
                                            background-repeat: no-repeat; width: 16px; height: 15px; text-align: center;
                                            vertical-align: middle;" />--%>
                                        <asp:TextBox ID="txt_productNum" runat="server" Text='<%# Eval("buyproductNum") %>'
                                            Width="30px" CssClass="text"></asp:TextBox>
                                        <asp:HiddenField ID="hfStocks" runat="server" Value='<%# Eval("productStocks") %>' />
                                        <img id="increase" runat="server" src="~/Skin/ShowProductStyle/images/jia2.bmp" style="width: 16px;
                                            height: 15px;" />
                                        <%--<input type="button" id="increase" runat="server" value="+" style="background-image: Skin/ShowProductStyle/images/jia1.bmp;
                                            background-repeat: no-repeat; width: 16px; height: 15px; text-align: center;
                                            vertical-align: middle;" />--%>
                                    </div>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="小结">
                                <%--<EditItemTemplate>
                                    <asp:Label ID="Label2" runat="server" Text='<%# Eval("total") %>'></asp:Label>
                                </EditItemTemplate>--%>
                                <ItemStyle HorizontalAlign="Center" />
                                <ItemTemplate>
                                    <asp:Label ID="Label2" runat="server" Text='<%# Eval("total") %>'></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                        <EmptyDataTemplate>
                            <table style="width: 98%">
                                <tr>
                                    <th>
                                        <input id="Checkbox1" type="checkbox" />全选
                                    </th>
                                    <th>
                                        商品图片
                                    </th>
                                    <th>
                                        商品规格
                                    </th>
                                    <th>
                                        所属店铺
                                    </th>
                                    <th>
                                        商品价格
                                    </th>
                                    <th>
                                        商品数量
                                    </th>
                                    <th>
                                        小结
                                    </th>
                                </tr>
                                <tr>
                                    <td colspan="7" style="text-align: center">
                                        购物车内暂无商品
                                    </td>
                                </tr>
                            </table>
                        </EmptyDataTemplate>
                        <HeaderStyle HorizontalAlign="Center" />
                    </asp:GridView>
                </ContentTemplate>
            </asp:UpdatePanel>
        </div>
        <div style="margin: 5px auto; text-align: center;">
            <asp:Button ID="btn_delete" runat="server" Text="删除商品" OnClick="btn_delete_Click" />
            <asp:Button ID="btn_changeNum" runat="server" OnClick="btn_changeNum_Click" Text="修改数量" />
            <asp:Button ID="btn_buyagain" runat="server" Text="继续购物" OnClick="btn_buyagain_Click1" />
            <asp:Button ID="btn_next" runat="server" Text="下一步" OnClick="btn_next_Click1" /></div>
    </div>
    <hl:Foot ID="Foot1" runat="server" />
    </form>
    <!-- 对应模板中的 {form1/} 标签 结束-->
    <script language="javascript" type="text/javascript">
        //判断购买数量
        function ChangeBuyNumber(sen, labl, productInStock, productPrice, productTotal) {
            var shuLiang = $(sen);
            var quantityVal = shuLiang.val();
            if ((isNaN(quantityVal) == true)) {//判断输入的是否为数字
                shuLiang.attr("value", "1");
                return;
            }
            //加
            if (labl == "add") {
                if (parseInt(quantityVal) >= productInStock) {
                    alert('不能超过当前库存的数量！当前库存的数量为' + productInStock + '!');
                    shuLiang.attr("value", productInStock);
                    return;
                } else {
                    var sladd = parseInt(quantityVal) + 1;
                    shuLiang.attr("value", sladd);
                }
            }
            else if (labl == "remove") {//减                
                if (parseInt(quantityVal) <= 1) {
                    alert('购物数量不能小于1!');
                    shuLiang.attr("value", "1");
                    return;
                } else {
                    var sljian = parseInt(quantityVal) - 1;
                    shuLiang.attr("value", sljian);
                }
            }
            var zongji = document.getElementById(productTotal); //商品总价
            var proTotal = parseFloat(productPrice) * shuLiang.val();
            var parse_total = parseFloat(proTotal).toFixed(2);
            zongji.innerHTML = parseFloat(parse_total);
        }
        //判断输入的商品数量
        function WriteBuyNumber(sen, productInStock, productPrice, productTotal) {
            var shuLiang = $(sen);
            var quantityVal = shuLiang.val();
            if (quantityVal == null || quantityVal == "") {
                alert("请您输入购买的商品数量");
                shuLiang.focus();
                return;
            }
            if ((isNaN(quantityVal) == true)) {//判断输入的是否为数字
                alert("请您输入0~9之间的数字！");
                shuLiang.focus();
                return;
            }

            if (parseInt(quantityVal) < 1) {
                alert('您输入的商品数量不能小于0！');
                shuLiang.focus();
                shuLiang.attr("value", "1");
                return;
            }
            if (parseInt(shuLiang.val()) > parseInt(productInStock)) {
                alert('您输入的商品数量不能超过当前库存的数量！当前库存的数量为' + productInStock + '!');
                shuLiang.focus();
                shuLiang.attr("value", "1");
                return;
            }
            var zongji = document.getElementById(productTotal); //商品总价
            var proTotal = parseFloat(productPrice) * shuLiang.val();
            var parse_total = parseFloat(proTotal).toFixed(2);
             zongji.innerHTML = parseFloat(parse_total);
        }
    </script>
</body>
</html>
