<%@ Page Language="C#" MasterPageFile="~/Admin/MainPage.Master" AutoEventWireup="true" ValidateRequest="false" 
    Codebehind="DeliveryAdd.aspx.cs" Inherits="PPFOR.Admin.Sys.WebConfig.DeliveryAdd" Title="添加配送方式" %>

<asp:Content ID="Content1" ContentPlaceHolderID="PPFOR_mainContent" runat="server">
<script type="text/javascript" src="/ckeditor/ckeditor.js"></script>   
<script src="../../JS/popup.js" type="text/javascript"></script>  
<script src="../../JS/delivery.js" type="text/javascript"></script> 
<script type="text/javascript">
function openAreaListForSelect(hid,sid)
{
   popup_show("配送地区选择","<iframe id='htmlFrame' src='/Admin/CustomView/selectMultiArea.aspx?hid=" + hid + "&sid=" + sid + "' scrolling='yes' width='100%' height='100%' frameborder='0'></iframe>",300,250);
}
function changeProtect(){
    var obj=$('<%=PPFOR_isProtectable.ClientID %>');
    var target=$('protectRow');   
    if(obj && target){
        var display=target.style.display;
        target.style.display=obj.checked?'':'none';
        if(display==null || display!=target.style.display){
            var target2=$('<%=PPFOR_protectRates.ClientID %>');  
            var target3=$('<%=PPFOR_protectMinPrice.ClientID %>');  
            if(target.style.display=='none'){
                if(target2){
                    target2.setAttribute('oldValue',target2.value);
                    target2.value='';
                } 
                if(target3){
                    target3.setAttribute('oldValue',target3.value);
                    target3.value='';
                }
            }else{                    
                if(target2){
                    target2.value=target2.getAttribute('oldValue');
                }
                if(target3){
                    target3.value=target3.getAttribute('oldValue');
                }
            }
        }
    }
}
function changeSetting(){    
    var obj=$('<%=PPFOR_sameSetting.ClientID %>');    
    if(obj){
        var target=$('defaultRow');  
        if(target){  
            target.style.display=obj.checked?'none':'';
        }
        var target2=$('<%=PPFOR_isDefaultable.ClientID %>'); 
        target=$('priceRow');
        if(target){        
            var display=target.style.display;
            if(obj.checked){
                target.style.display='';
            }else{
                if(target2){
                    target.style.display=target2.checked?'':'none';
                }else{
                    target.style.display='';
                }
            } 
            if(display==null || display!=target.style.display){
                var target3=$('<%=PPFOR_initialPrice.ClientID %>');  
                var target4=$('<%=PPFOR_additionalPrice.ClientID %>');  
                if(target.style.display=='none'){
                    if(target3){
                        target3.setAttribute('oldValue',target3.value);
                        target3.value='';
                    } 
                    if(target4){
                        target4.setAttribute('oldValue',target4.value);
                        target4.value='';
                    }
                }else{                    
                    if(target3){
                        target3.value=target3.getAttribute('oldValue');
                    }
                    if(target4){
                        target4.value=target4.getAttribute('oldValue');
                    }
                }
            }              
        }
        target=$('areaRow');
        if(target){
            target.style.display=obj.checked?'none':'';
        }  
        target=$('priceTitle');     
        if(target){
            target.innerHTML=obj.checked?'统一配送费用':'默认配送费用';
        }        
    }
}
function changeControls(){
    changeProtect();
    changeSetting();
    appendAreaListItem(0,null,null,null,0);
}
</script>
<form action="DeliveryAdd.aspx" method="post" id="form1" runat="server" onsubmit="return checkDeliveryAreaList();">
    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="fortable">
    <thead>   
        <tr>
            <td colspan="2" align="center">添加配送方式</td>
        </tr>    
    </thead>                   
        <tr>
            <td style="width:15%" align="right">配送方式名称：</td>
            <td align="left">
                <asp:TextBox ID="PPFOR_deliveryName" runat="server" Width="300px" MaxLength="50"></asp:TextBox>                 
                <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" SetFocusOnError="true" ValidationExpression="^[^<>\x22]{2,50}$" Display="Dynamic" ControlToValidate="PPFOR_deliveryName"><br />配送方式名称长度必须在2至50个字符之间，且不能包含以下字符之一：<，>，"</asp:RegularExpressionValidator>
              <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" SetFocusOnError="true" Display="Dynamic" ControlToValidate="PPFOR_deliveryName"><br />配送方式名称不能为空</asp:RequiredFieldValidator>              
            </td>
        </tr>
        <tr>
            <td style="width:15%" align="right">默认物流公司：</td>
            <td align="left">
                <asp:DropDownList ID="PPFOR_logisticsCompanyList" runat="server"></asp:DropDownList>
            </td>
        </tr> 
         <tr>
            <td style="width:15%" align="right">付款类型：</td>
            <td align="left">
                <asp:RadioButton ID="PPFOR_isCaseBefore" GroupName="DeliveryCase" runat="server" Text="先收款后发货" />
                <asp:RadioButton ID="PPFOR_isCashOnDeliver" GroupName="DeliveryCase" runat="server" Text="货到付款" />
                <span style="color:Gray;">选择货到付款后顾客无需再选择支付方式</span>
            </td>
        </tr>  
        <tr>
            <td align="right">重量设置：</td>
            <td align="left">
                首重重量 <asp:DropDownList ID="PPFOR_initialWeight" runat="server"></asp:DropDownList>&nbsp;&nbsp;
                续重单位 <asp:DropDownList ID="PPFOR_additionalWeight" runat="server"></asp:DropDownList>
            </td>           
        </tr>  
        <tr>
            <td align="right">物流保价：</td>
            <td><asp:CheckBox ID="PPFOR_isProtectable" runat="server" Text="支持物流保价" /></td>
        </tr>
        <tr id="protectRow">    
            <td align="right">保价设置：</td>
            <td>保价费率（千分之） <asp:TextBox ID="PPFOR_protectRates" runat="server" MaxLength="7" Width="50px"></asp:TextBox>‰ &nbsp;
                最低保价费 <asp:TextBox ID="PPFOR_protectMinPrice" runat="server" Width="50px" MaxLength="19"></asp:TextBox>
                <asp:RangeValidator ID="RangeValidator2" runat="server" ControlToValidate="PPFOR_protectRates" Display="Dynamic" SetFocusOnError="true" Type="Double" MinimumValue="0" MaximumValue="1000"><br />保价费率只能填写0至1000之间的数</asp:RangeValidator>
                <asp:RangeValidator ID="RangeValidator3" runat="server" ControlToValidate="PPFOR_protectMinPrice" Display="Dynamic" SetFocusOnError="true" Type="Double" MinimumValue="0" MaximumValue="922337203685477.5807"><br />最低保价费只能填写0至922337203685477.5807之间的数</asp:RangeValidator>
            </td>
        </tr>
        <tr>
            <td align="right">地区费用类型：</td>
            <td>
                <asp:RadioButton ID="PPFOR_sameSetting" runat="server" GroupName="setting" Text="统一设置 " />&nbsp;
                <asp:RadioButton ID="PPFOR_differentSetting" runat="server" GroupName="setting" Text="指定配送地区和费用" />
            </td>
        </tr>
        <tr id="defaultRow">
            <td align="right">&nbsp;</td>
            <td>
                <asp:CheckBox ID="PPFOR_isDefaultable" runat="server" Text="启用默认费用" /> 
                <span style="color:Gray;">注意：未启用默认费用时，不在指定配送地区的顾客不能使用本配送方式下订单</span>
            </td>
        </tr>
        <tr id="priceRow">
            <td align="right"><label id="priceTitle">配送费用</label>：</td>
            <td>首重费用 <asp:TextBox ID="PPFOR_initialPrice" runat="server" Width="50px" MaxLength="19"></asp:TextBox>&nbsp;
                续重费用 <asp:TextBox ID="PPFOR_additionalPrice" runat="server" Width="50px" MaxLength="19"></asp:TextBox>&nbsp;               
                <asp:RangeValidator ID="RangeValidator4" runat="server" ControlToValidate="PPFOR_initialPrice" Display="Dynamic" SetFocusOnError="true" Type="Double" MinimumValue="0" MaximumValue="922337203685477.5807"><br />首重费用只能填写0至922337203685477.5807之间的数</asp:RangeValidator>
                <asp:RangeValidator ID="RangeValidator5" runat="server" ControlToValidate="PPFOR_additionalPrice" Display="Dynamic" SetFocusOnError="true" Type="Double" MinimumValue="0" MaximumValue="922337203685477.5807"><br />续重费用只能填写0至922337203685477.5807之间的数</asp:RangeValidator>
            </td>
        </tr>
        <tr id="areaRow">
            <td align="right">支持的配送地区：</td>
            <td class="delivery">
                <ol id="deliveryAreaList">										
				</ol>
			    <input type="button" class="button" value="为指定的地区设置运费" onclick="appendAreaListItem(0,null,null,null,0);" />
			</td>
        </tr>       
        <tr>
            <td align="right">排序：</td>          
            <td>
                <asp:TextBox ID="PPFOR_sort" runat="server" Text="0" MaxLength="4" Width="50px" ></asp:TextBox>
                <asp:RangeValidator ID="RangeValidator1" runat="server" ControlToValidate="PPFOR_sort" Display="Dynamic" SetFocusOnError="true" Type="Integer" MinimumValue="-999" MaximumValue="9999">排序顺序只能填写-999至9999之间的整数</asp:RangeValidator>
            </td>
        </tr>    
        <tr>
            <td align="right">状态：</td>
            <td>
                <asp:RadioButton ID="PPFOR_statusOn" GroupName="status" runat="server" Text="启用" Checked="true" />&nbsp;
                <asp:RadioButton ID="PPFOR_statusOff" GroupName="status" runat="server" Text="关闭" />
            </td>
        </tr>    
        <tr>
            <td align="right">详细介绍：</td>
            <td>
                <asp:TextBox ID="PPFOR_description" runat="server" TextMode="MultiLine" Height="80px" Width="99%"></asp:TextBox>
                    <script type="text/javascript">
                      var editor = CKEDITOR.replace("<%=PPFOR_description.ClientID%>");       
                    </script>
            </td>
        </tr>                      
        <tr>
            <td colspan="2" style="width:100%; height:50px; display:none" align="center" valign="middle">
                <asp:Button ID="PPFOR_addDelivery" CssClass="inputbutton" runat="server" Text="添加" OnClick="PPFOR_addDeliveryClick"/>
                <input name="reset" type="reset" id="reset1" class="inputbutton" onmouseover="this.className='inputbutton_hover'" onmouseout="this.className='inputbutton'" value="重置" />              
                <script type="text/javascript">
                    addButtonArray("<%= PPFOR_addDelivery.ClientID %>","reset1");
                </script>
            </td>
        </tr>           
    </table>
</form>
</asp:Content>
