<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/User/Main.Master"
    EnableViewState="true" CodeBehind="OrderAdd.aspx.cs" Inherits="OAWeb.User.OrderAdd" ValidateRequest="false" enableEventValidation="false" %>

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<%@ Register Src="/UserControls/UserLeft.ascx" TagName="TaskNav" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlace" runat="server">
    <script>
        function OpenAddressDialog() {
            OpenRadioDialog('/User/CAddrsSelectDialog.aspx?CId=<%=UserCustomerID %>', '选择收货地址', function (text, value) {

                $('#HiddenAddressId').val(value);
                var strList = text;
                $("#<%=txtShipTo.ClientID %>").val()

            });
            return false;

        }
        function ProvinceChange(id, op, bindControlId) {
            AjaxProvinceCity('/User/Ajax.aspx?op=' + op + '&id=' + id, bindControlId);
        }

        $(document).ready(function () {
            $("#<%=ddlProvince.ClientID %>").change(function () {
                ProvinceChange(this.value, 'LoadCityJson', '<%=ddlCity.ClientID %>');
            })
        });

        function SelectAddress(cb) {
            var value = $(cb).attr("value");
            $('#HiddenAddressId').val(value);
            $("#TbAddress").hide();

        }

        function NewAddress() {
            $("#TbAddress").show();
            $('#HiddenAddressId').val("0");
        }
                  
    </script>
    <style>
        .table_form .TdRight
        {
            text-align: right;
            padding-right: 10px;
        }
    </style>
    <div class="w main">
        <div class="right">
            <div class="optiongroup mainwidth">
                <ul>
                    <li class="optionstar"><a class="optionnext" href="ProductAdd.aspx"><span>1.选择商品</span></a></li>
                    <li class="menucurrent"><a href="javascript:void(0);"><span>2.提交订单</span></a></li>
                    <li class="optionend"><a href="Pay.aspx"><span>3.在线付款</span></a></li>
                </ul>
            </div>
            <div class="dataarea mainwidth">
                <div class="list">
                    <asp:GridView ID="rptData" runat="server" AutoGenerateColumns="False" DataKeyNames="SkuId"
                        GridLines="None" CellPadding="0" CssClass="table_list" EnableModelValidation="True"
                        OnRowDataBound="rptData_RowDataBound" OnRowCommand="rptData_RowCommand">
                        <RowStyle HorizontalAlign="Left" />
                        <HeaderStyle HorizontalAlign="Center" />
                        <Columns>
                            <asp:TemplateField HeaderText="商品货号">
                                <ItemTemplate>
                                    <asp:Label ID="lblSkuId" runat="server" Text='<%# Eval("SkuId") %>' Visible="false"></asp:Label>
                                    <%# Eval("SKUCode")%>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="商品">
                                <ItemTemplate>
                                    <%#Eval("SKUName")%>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="SalePrice" HeaderText="订购价"></asp:BoundField>
                            <asp:TemplateField HeaderText="订购数">
                                <ItemTemplate>
                                    <asp:Label ID="lblNum" runat="server" Text=""></asp:Label>
                                    <%#Eval("Unit")%>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="金额">
                                <ItemTemplate>
                                    <asp:Label ID="lblAmount" runat="server" Text=""></asp:Label>
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="操作">
                                <ItemTemplate>
                                    <asp:LinkButton ID="lbtnDel" CommandName="Del" CommandArgument='<%# Eval("SkuId") %>'
                                        runat="server">删除</asp:LinkButton>
                                </ItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                    </asp:GridView>
                    <div style="margin-top: 10px; text-align: right">
                        运费：0 总金额：<asp:Label ID="lblTotal" runat="server" Text=""></asp:Label></div>
                    <div>
                        <h2 class="colorE">
                            注意：正确填写收货人地址，以便尽快收到商品！</h2>
                        <table class="table_list" cellspacing="0" cellpadding="0" border="0" style="border-collapse: collapse;
                            margin-bottom: 10px;">
                            <asp:Repeater ID="RpAddress" runat="server">
                                <ItemTemplate>
                                    <tr>
                                        <td align="center" style="width: 10px;">
                                            <input onclick="SelectAddress(this)" id='rdoItem' name='rdoItem' type='radio' value='<%#Eval("Id") %>'
                                                text='<%#Eval("Province")%>|<%#Eval("City")%>|<%#Eval("Address")%>|<%#Eval("ShipTo")%>|<%#Eval("TelePhone")%>|<%#Eval("Mobile")%>|<%#Eval("ZipCode")%>|<%#Eval("Email")%>|<%#Eval("Address")%>' />
                                        </td>
                                        <td style="text-align: left">
                                            <%#Eval("Province")%>-<%#Eval("City")%>&nbsp;<%#Eval("Address")%>(收货人:<%#Eval("ShipTo")%>电话:<%#Eval("TelePhone")%>手机:<%#Eval("Mobile")%>邮编:<%#Eval("ZipCode")%>)
                                        </td>
                                        <td>
                                            <a href="javascript:void(0);" onclick="return opAjax(this,null);" json="id:'<%#Eval("Id") %>',op:'Delete'"
                                                style="display: none;">删除</a>
                                        </td>
                                    </tr>
                                </ItemTemplate>
                            </asp:Repeater>
                            <tr>
                                <td  style="text-align: left" colspan="3">
                                    <input id='rdoItem' name='rdoItem' type='radio' onclick="NewAddress()" /> 使用新地址
                                </td>

                            </tr>
                        </table>
                        <table cellpadding="0" cellspacing="0" border="0" class="table_form" id="TbAddress" style=" display:none;">
                            <tr>
                                <td class="TdRight">
                                    <span class="red">*</span> 收货人：
                                </td>
                                <td>
                                    <asp:TextBox ID="txtShipTo" runat="server" CssClass="text" Text=""></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td class="TdRight">
                                    电话：
                                </td>
                                <td>
                                    <asp:TextBox ID="txtTelePhone" runat="server" CssClass="text" Text=""></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td class="TdRight">
                                    手机：
                                </td>
                                <td>
                                    <asp:TextBox ID="txtMobile" runat="server" CssClass="text" Text=""></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td class="TdRight">
                                    <span class="red">*</span> 地区：
                                </td>
                                <td>
                                    <asp:DropDownList ID="ddlProvince" runat="server">
                                        <asp:ListItem Value="0">省份</asp:ListItem>
                                    </asp:DropDownList>
                                    <asp:DropDownList ID="ddlCity" runat="server">
                                        <asp:ListItem Value="0">城市</asp:ListItem>
                                    </asp:DropDownList>
                                    <asp:TextBox ID="txtAddress" runat="server" CssClass="text width200" Text=""></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td class="TdRight ">
                                    邮编：
                                </td>
                                <td>
                                    <asp:TextBox ID="txtZipCode" runat="server" CssClass="text" Text=""></asp:TextBox>
                                </td>
                            </tr>
                            <tr>
                                <td class="TdRight">
                                    电子邮件：
                                </td>
                                <td>
                                    <asp:TextBox ID="txtEmail" runat="server" CssClass="text" Text=""></asp:TextBox>
                                </td>
                            </tr>
                        </table>
                        <input type="hidden" id="HiddenAddressId" value="0" />
                    </div>
                    <div style="text-align: center; margin-top: 10px">
                        <asp:Button ID="Button1" runat="server" Text="提交订单" CssClass="btn_77px" OnClick="Button1_Click" />
                        <asp:Button ID="Button2" runat="server" Text="上一步" CssClass="btn_77px" OnClick="Button2_Click" />
                    </div>
                </div>
            </div>
        </div>
        <div class="left">
            <uc1:TaskNav ID="TaskNav1" runat="server" />
        </div>
    </div>
</asp:Content>
