<!--#include file="Admin_Common.asp"-->
<%
'**************************************************************
' Software name: PowerEasy SiteWeaver
' Web: http://www.powereasy.net
' Copyright (C) 2005－2009 佛山市动易网络科技有限公司 版权所有
'**************************************************************

Const NeedCheckComeUrl = True   '是否需要检查外部访问

Const PurviewLevel = 2      '0--不检查，1--超级管理员，2--普通管理员
Const PurviewLevel_Channel = 0   '0--不检查，1--频道管理员，2--栏目总编，3--栏目管理员
Const PurviewLevel_Others = "DeliverType"   '其他权限

Response.Write "<html>" & vbCrLf
Response.Write "<head>" & vbCrLf
Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=gb2312'>" & vbCrLf
Response.Write "<title>送货方式管理</title>" & vbCrLf
Response.Write "<link href='Admin_STYLE.CSS' rel='stylesheet' type='text/css'>" & vbCrLf
Response.Write "</head>" & vbCrLf
Response.Write "" & vbCrLf
Response.Write "<body>" & vbCrLf
Response.Write "<table width='100%'  border='0' cellpadding='2' cellspacing='1' class='border'>" & vbCrLf
Call ShowPageTitle("送 货 方 式 管 理", 10211)
Response.Write "  <tr>" & vbCrLf
Response.Write "    <td width='70' height='30' class='tdbg'>管理导航：</td>" & vbCrLf
Response.Write "    <td class='tdbg'><a href='Admin_DeliverType.asp'>送货方式管理首页</a> | <a href='Admin_DeliverType.asp?Action=Add'>添加送货方式</a></td>" & vbCrLf
Response.Write "  </tr>" & vbCrLf
Response.Write "</table>" & vbCrLf
Select Case Action
Case "Add"
    Call Add
Case "Modify"
    Call Modify
Case "SaveAdd", "SaveModify"
    Call SaveType
Case "Disable", "Enable"
    Call DisableType
Case "SetDefault"
    Call SetDefault
Case "Del"
    Call Del
Case "Order"
    Call Order
Case Else
    Call main
End Select
If FoundErr = True Then
    Call WriteErrMsg(ErrMsg, ComeUrl)
End If
Response.Write "</body></html>"
Call CloseConn


Sub main()
    Response.Write "<br>" & vbCrLf
    Response.Write "<table width='100%'  border='0' cellpadding='2' cellspacing='1' class='border'>" & vbCrLf
    Response.Write "  <tr align='center' class='title'>" & vbCrLf
    Response.Write "    <td width='30'>ID</td>" & vbCrLf
    Response.Write "    <td width='80'>送货方式名称</td>" & vbCrLf
    Response.Write "    <td>送货方式简介</td>" & vbCrLf
    Response.Write "    <td width='60'>是否收费</td>" & vbCrLf
    Response.Write "    <td width='60'>是否默认</td>" & vbCrLf
    Response.Write "    <td width='50'>已启用</td>" & vbCrLf
    Response.Write "    <td width='150'>常规操作</td>" & vbCrLf
    Response.Write "    <td width='100'>排序操作</td>" & vbCrLf
    Response.Write "  </tr>" & vbCrLf
    Dim rsType
    Set rsType = Conn.Execute("select * from PE_DeliverType order by OrderID asc,ChargeType asc")
    If rsType.BOF And rsType.EOF Then
        Response.Write "<tr><td colspan='10' height='50' align='center'>没有任何送货方式</td></tr>"
    Else
        Do While Not rsType.EOF
            Response.Write "  <tr class='tdbg' onmouseout=""this.className='tdbg'"" onmouseover=""this.className='tdbg2'"">" & vbCrLf
            Response.Write "    <td width='30' align='center'>" & rsType("TypeID") & "</td>" & vbCrLf
            Response.Write "    <td width='80' align='center'>" & rsType("TypeName") & "</td>" & vbCrLf
            Response.Write "    <td align='center'>" & rsType("Intro") & "</td>" & vbCrLf
            Response.Write "    <td width='60' align='center'>"
            If rsType("ChargeType") > 0 Then
                Response.Write "收费"
            Else
                Response.Write "<font color='red'>免费</font>"
            End If
            Response.Write "</td>" & vbCrLf
            Response.Write "    <td width='60' align='center'>" & vbCrLf
            If rsType("IsDefault") = True Then
                Response.Write "√"
            End If
            Response.Write "      </td>" & vbCrLf
            Response.Write "    <td width='50' align='center'>" & vbCrLf
            If rsType("IsDisabled") = False Then
                Response.Write "√"
            Else
                Response.Write "<font color='red'>×</font>"
            End If
            Response.Write "</td>" & vbCrLf
            Response.Write "    <td width='150' align='center'>" & vbCrLf
            If rsType("IsDefault") = True Then
                Response.Write "<font color='gray'>设为默认 禁用</font> "
            Else
                Response.Write "<a href='Admin_DeliverType.asp?Action=SetDefault&TypeID=" & rsType("TypeID") & "'>设为默认</a> "
                If rsType("IsDisabled") = True Then
                    Response.Write "<a href='Admin_DeliverType.asp?Action=Enable&TypeID=" & rsType("TypeID") & "'>启用</a> "
                Else
                    Response.Write "<a href='Admin_DeliverType.asp?Action=Disable&TypeID=" & rsType("TypeID") & "'>禁用</a> "
                End If
            End If
            Response.Write "<a href='Admin_DeliverType.asp?Action=Modify&TypeID=" & rsType("TypeID") & "'>修改</a> "
            If rsType("IsDefault") = True Then
                Response.Write "<font color='gray'>删除</font> "
            Else
                Response.Write "<a href='Admin_DeliverType.asp?Action=Del&TypeID=" & rsType("TypeID") & "'>删除</a>"
            End If
            Response.Write "</td>"
            Response.Write "<form name='orderform' method='post' action='Admin_DeliverType.asp'>"
            Response.Write "    <td width='100' align='center'>      <input name='OrderID' type='text' id='OrderID' value='" & rsType("OrderID") & "' size='4' maxlength='4' style='text-align:center '>"
            Response.Write "      <input name='TypeID' type='hidden' id='TypeID' value='" & rsType("TypeID") & "'>"
            Response.Write "    <input type='submit' name='Submit' value='修改'>"
            Response.Write "    <input name='Action' type='hidden' id='Action' value='Order'></td></form>"
            Response.Write "  </tr>"
            rsType.MoveNext
        Loop
    End If
    Set rsType = Nothing
    Response.Write "</table>"
    Response.Write "<br>" & vbCrLf
    Response.Write "说明：“禁用”某送货方式后，前台订购时将不再显示此送货方式，但已有订单中仍然显示。<br>" & vbCrLf
End Sub

Sub Add()
    Response.Write "<form name='myform' method='post' action='Admin_DeliverType.asp'>" & vbCrLf
    Response.Write "  <table width='100%'  border='0' cellpadding='2' cellspacing='1' class='border'>" & vbCrLf
    Response.Write "    <tr align='center'>" & vbCrLf
    Response.Write "      <td colspan='2' class='title'><b>添 加 送 货 方 式</b></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right'><b>送货方式名称：</b></td>" & vbCrLf
    Response.Write "      <td><input name='TypeName' type='text' id='TypeName' size='20' maxlength='20'> <font color='#FF0000'>*</font></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right'><b>送货方式简介：</b></td>" & vbCrLf
    Response.Write "      <td><input name='Intro' type='text' id='Intro' size='40' maxlength='50'></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right'><b>运费：</b></td>" & vbCrLf
    Response.Write "      <td><input name='ChargeType' type='radio' value='0' checked onClick=""ChargeSetting.style.display='none';ChargeSetting2.style.display='none';ChargeSetting4.style.display='none';ChargeSetting5.style.display='none'""> 免费&nbsp;&nbsp;&nbsp;&nbsp;" & vbCrLf
    Response.Write "        <input type='radio' name='ChargeType' value='1' onClick=""ChargeSetting.style.display='';ChargeSetting2.style.display='none';ChargeSetting3.style.display='';ChargeSetting4.style.display='';ChargeSetting5.style.display='none'""> 按重量计算运费&nbsp;&nbsp;&nbsp;&nbsp;" & vbCrLf
    Response.Write "        <input type='radio' name='ChargeType' value='2' onClick=""ChargeSetting2.style.display='';ChargeSetting.style.display='none';ChargeSetting3.style.display='';ChargeSetting4.style.display='none';ChargeSetting5.style.display=''""> 按订单金额的百分比计算运费</td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right'>&nbsp;</td>" & vbCrLf
    Response.Write "      <td><input name='IsDefault' type='checkbox' id='IsDefault' value='Yes'> 设为默认送货方式</td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td colspan='2'><table width='100%'  border='0' cellpadding='2' cellspacing='1' class='border' id='ChargeSetting' style='display:none'>" & vbCrLf
    Response.Write "        <tr class='title'>" & vbCrLf
    Response.Write "          <td colspan='2'><b>同一城市间运费标准：</b></td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>基本运费：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Charge_Min1' type='text' id='Charge_Min1' value='8' size='10' maxlength='10' style='text-align:center '> 元</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>基本运费的起算重量：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Weight_Min1' type='text' id='Weight_Min1' value='1' size='10' maxlength='10' style='text-align:center '> 千克（Kg）<br>" & vbCrLf
    Response.Write "      当商品重量不超过上述指定起算重量时，实际运费按基本运费计算。</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>浮动运费：</b></td>" & vbCrLf
    Response.Write "          <td>当商品总重量超过基本运费的起算重量后，除了收取基本运费外，每" & vbCrLf
    Response.Write "              <input name='WeightPerUnit1' type='text' id='WeightPerUnit1' value='1' size='6' maxlength='6' style='text-align:center '>" & vbCrLf
    Response.Write "      千克的商品增加运费" & vbCrLf
    Response.Write "      <input name='ChargePerUnit1' type='text' id='ChargePerUnit1' value='3' size='10' maxlength='10' style='text-align:center '> 元</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>最高运费：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Charge_Max1' type='text' id='Charge_Max1' value='100' size='10' maxlength='10' style='text-align:center '> 元（当基本运费＋浮动运费超过最高运费时，实际运费按最高运费计算）</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr class='title'>" & vbCrLf
    Response.Write "          <td colspan='2'><b>同一区域间（比如珠江三角州、长江三角州等特别区域）的运费标准：</b></td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>区域范围：</b></td>" & vbCrLf
    Response.Write "          <td><input name='arrArea2' type='text' id='arrArea' value='5281,5282,5283,5284,5285' size='60' maxlength='255'>" & vbCrLf
    Response.Write "              <br>" & vbCrLf
    Response.Write "      请输入同一区域的所有城市的邮政编码前4位，以英文的逗号分隔。如果没有，请保持为空。</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>基本运费：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Charge_Min2' type='text' id='Charge_Min2' value='10' size='10' maxlength='10' style='text-align:center '> 元</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>基本运费的起算重量：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Weight_Min2' type='text' id='Weight_Min2' value='1' size='10' maxlength='10' style='text-align:center '> 千克（Kg）<br>" & vbCrLf
    Response.Write "      当商品重量不超过上述指定起算重量时，实际运费按基本运费计算。</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>浮动运费：</b></td>" & vbCrLf
    Response.Write "          <td>当商品总重量超过基本运费的起算重量后，除了收取基本运费外，每" & vbCrLf
    Response.Write "              <input name='WeightPerUnit2' type='text' id='WeightPerUnit2' value='1' size='6' maxlength='6' style='text-align:center '>" & vbCrLf
    Response.Write "    千克的商品增加运费" & vbCrLf
    Response.Write "    <input name='ChargePerUnit2' type='text' id='ChargePerUnit2' value='5' size='10' maxlength='10' style='text-align:center '> 元</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>最高运费：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Charge_Max2' type='text' id='Charge_Max2' value='100' size='10' maxlength='10' style='text-align:center '> 元（当基本运费＋浮动运费超过最高运费时，实际运费按最高运费计算）</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr class='title'>" & vbCrLf
    Response.Write "          <td colspan='2'><b>同一省份间运费标准：</b></td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>基本运费：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Charge_Min3' type='text' id='Charge_Min3' value='18' size='10' maxlength='10' style='text-align:center '> 元</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>基本运费的起算重量：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Weight_Min3' type='text' id='Weight_Min3' value='1' size='10' maxlength='10' style='text-align:center '> 千克（Kg）<br>" & vbCrLf
    Response.Write "      当商品重量不超过上述指定起算重量时，实际运费按基本运费计算。</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>浮动运费：</b></td>" & vbCrLf
    Response.Write "          <td>当商品总重量超过基本运费的起算重量后，除了收取基本运费外，每" & vbCrLf
    Response.Write "              <input name='WeightPerUnit3' type='text' id='WeightPerUnit3' value='1' size='6' maxlength='6' style='text-align:center '>" & vbCrLf
    Response.Write "    千克的商品增加运费" & vbCrLf
    Response.Write "    <input name='ChargePerUnit3' type='text' id='ChargePerUnit3' value='15' size='10' maxlength='10' style='text-align:center '> 元</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>最高运费：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Charge_Max3' type='text' id='Charge_Max3' value='100' size='10' maxlength='10' style='text-align:center '> 元（当基本运费＋浮动运费超过最高运费时，实际运费按最高运费计算）</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr class='title'>" & vbCrLf
    Response.Write "          <td colspan='2'><b>外省运费标准：</b></td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td colspan='2'>外省运费标准较复杂，不同省份运费标准可能会不同，如新疆、西藏、内蒙古的运费就与其他省份不同。因此需要根据不同省份来设置不同的运费标准。<br>" & vbCrLf
    Response.Write "            <b>添加外省运费标准的步骤：</b><br>先完成当前送货方式的添加工作，再修改此送货方式，在修改时添加不同省份的运费标准。必须做此步，否则将按国际运费标准执行。</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr class='title'>" & vbCrLf
    Response.Write "          <td colspan='2'><b>国际运费标准：</b></td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>基本运费：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Charge_Min5' type='text' id='Charge_Min5' value='50' size='10' maxlength='10' style='text-align:center '> 元</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>基本运费的起算重量：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Weight_Min5' type='text' id='Weight_Min5' value='1' size='10' maxlength='10' style='text-align:center '> 千克（Kg）<br>" & vbCrLf
    Response.Write "      当商品重量不超过上述指定起算重量时，实际运费按基本运费计算。</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>浮动运费：</b></td>" & vbCrLf
    Response.Write "          <td>当商品总重量超过基本运费的起算重量后，除了收取基本运费外，每" & vbCrLf
    Response.Write "              <input name='WeightPerUnit5' type='text' id='WeightPerUnit5' value='1' size='6' maxlength='6' style='text-align:center '>" & vbCrLf
    Response.Write "    千克的商品增加运费" & vbCrLf
    Response.Write "    <input name='ChargePerUnit5' type='text' id='ChargePerUnit5' value='20' size='10' maxlength='10' style='text-align:center '> 元</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>最高运费：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Charge_Max5' type='text' id='Charge_Max5' value='100' size='10' maxlength='10' style='text-align:center '> 元（当基本运费＋浮动运费超过最高运费时，实际运费按最高运费计算）</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td colspan='2'><table width='100%'  border='0' cellpadding='2' cellspacing='1' class='border' id='ChargeSetting2' style='display:none'>" & vbCrLf
    Response.Write "        <tr class='title'>" & vbCrLf
    Response.Write "          <td colspan='2'><b>按订单金额的百分比计算运费标准：</b></td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>基本运费：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Charge_Min' type='text' id='Charge_Min' value='5' size='10' maxlength='10' style='text-align:center '> 元</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>订单金额的百分比率：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Charge_Percent' type='text' id='Weight_Min1' value='1' size='10' maxlength='10' style='text-align:center '> %<br></td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>最高运费：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Charge_Max' type='text' id='Charge_Max' value='100' size='10' maxlength='10' style='text-align:center '> 元（当订单金额*百份比率+基本运费超过最高运费时，实际运费按最高运费计算）</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td colspan='2'><table width='100%'  border='0' cellpadding='2' cellspacing='1' class='border' id='ChargeSetting3' style='display:none'>" & vbCrLf
    Response.Write "        <tr class='title'>" & vbCrLf
    Response.Write "          <td colspan='2'><b>运费优惠标准：</b></td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td colspan='2'><input type='radio' name='ReleaseType' value='0' checked>不实行任何优惠<br><input type='radio' name='ReleaseType' value='1'>实行下列优惠方式<br>"
    Response.Write "&nbsp;&nbsp;&nbsp;&nbsp;①当订单总金额达到 <input name='MinMoney1' type='text' id='MinMoney1' value='1000' size='10' maxlength='10' style='text-align:center '> 元时，免除 <input name='ReleaseCharge' type='text' id='ReleaseCharge' value='10' size='5' maxlength='10' style='text-align:center '> 元运费（如果大于运费总额，则实际免除额为运费总额）<br>"
    Response.Write "&nbsp;&nbsp;&nbsp;&nbsp;②当订单总金额达到 <input name='MinMoney2' type='text' id='MinMoney2' value='5000' size='10' maxlength='10' style='text-align:center '> 元时，并且运费总额不超过 <input name='MaxCharge' type='text' id='MaxCharge' value='100' size='5' maxlength='10' style='text-align:center '> 元时，免除全部运费<br>"
    Response.Write "&nbsp;&nbsp;&nbsp;&nbsp;③当订单总金额达到 <input name='MinMoney3' type='text' id='MinMoney3' value='10000' size='10' maxlength='10' style='text-align:center '> 元时，免除全部运费<br></td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    
    Response.Write "    <tr align='center' class='tdbg'>" & vbCrLf
    Response.Write "      <td height='50' colspan='2'><input name='Action' type='hidden' id='Action' value='SaveAdd'>" & vbCrLf
    Response.Write "          <input type='submit' name='Submit' value='保存送货方式'></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "  </table>" & vbCrLf
    Response.Write "</form>" & vbCrLf
    Call ShowTips
    Call ShowTips2
End Sub
Sub ShowTips()
    Response.Write "<Div style='display:none' id='ChargeSetting4'>"
    Response.Write "<p><b>运费计算公式(按商品重量计算)：</b><br>" & vbCrLf
    Response.Write "IF 商品总重量>起算重量 THEN<br>" & vbCrLf
    Response.Write "&nbsp;&nbsp;&nbsp;&nbsp;总运费＝基本运费+(取整((商品总重量－起算重量)/单位重量)+1)×单位运费<br>" & vbCrLf
    Response.Write "ELSE<br>" & vbCrLf
    Response.Write "&nbsp;&nbsp;&nbsp;&nbsp;总运费＝基本运费<br>" & vbCrLf
    Response.Write "END IF<br>" & vbCrLf
    Response.Write "IF 总运费>最高运费 THEN<br>" & vbCrLf
    Response.Write "&nbsp;&nbsp;&nbsp;&nbsp;总运费＝最高运费<br>" & vbCrLf
    Response.Write "END IF<br>" & vbCrLf
    Response.Write "</p>" & vbCrLf
    Response.Write "</Div>" & vbCrLf
End Sub

Sub ShowTips2()
    Response.Write "<Div style='display:none' id='ChargeSetting5'>"
    Response.Write "<p><b>运费计算公式(按订单金额百分比计算）：</b><br>" & vbCrLf
    Response.Write "总运费=订单总金额*百分比率/100+基本运费<br>" & vbCrLf
    Response.Write "IF 总运费>最高运费 THEN<br>" & vbCrLf
    Response.Write "&nbsp;&nbsp;&nbsp;&nbsp;总运费＝最高运费<br>" & vbCrLf
    Response.Write "END IF<br>" & vbCrLf
    Response.Write "</p>" & vbCrLf
    Response.Write "</Div>" & vbCrLf
End Sub

Sub Modify()
    Dim TypeID, rsType
    TypeID = Trim(Request("TypeID"))
    If TypeID = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定送货方式ID</li>"
        Exit Sub
    Else
        TypeID = PE_CLng(TypeID)
    End If
    Set rsType = Conn.Execute("select * from PE_DeliverType where TypeID=" & TypeID & "")
    If rsType.BOF And rsType.EOF Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>找不到指定的方案！</li>"
        Set rsType = Nothing
        Exit Sub
    End If
    Response.Write "<form name='myform' method='post' action='Admin_DeliverType.asp'>" & vbCrLf
    Response.Write "  <table width='100%'  border='0' cellpadding='2' cellspacing='1' class='border'>" & vbCrLf
    Response.Write "    <tr align='center'>" & vbCrLf
    Response.Write "      <td colspan='2' class='title'><b>修 改 送 货 方 式</b></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right'>送货方式名称：</td>" & vbCrLf
    Response.Write "      <td><input name='TypeName' type='text' id='TypeName' value='" & rsType("TypeName") & "' size='20' maxlength='20'>" & vbCrLf
    Response.Write "          <font color='#FF0000'>*</font></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right'>送货方式简介：</td>" & vbCrLf
    Response.Write "      <td><input name='Intro' type='text' id='Intro' value='" & rsType("Intro") & "' size='40' maxlength='50'></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right'><b>运费：</b></td>" & vbCrLf
    Response.Write "      <td><input name='ChargeType' type='radio' value='0' "
    If rsType("ChargeType") <= 0 Then Response.Write " checked"
    Response.Write " onClick=""ChargeSetting.style.display='none';ChargeSetting2.style.display='none';ChargeSetting3.style.display='none'""> 免费&nbsp;&nbsp;&nbsp;&nbsp;" & vbCrLf
    Response.Write "        <input type='radio' name='ChargeType' value='1'"
    If rsType("ChargeType") = 1 Then Response.Write " checked"
    Response.Write " onClick=""ChargeSetting.style.display='';ChargeSetting2.style.display='none';ChargeSetting3.style.display=''""> 按重量计算运费&nbsp;&nbsp;&nbsp;&nbsp;" & vbCrLf
    Response.Write "        <input type='radio' name='ChargeType' value='2'"
    If rsType("ChargeType") = 2 Then Response.Write " checked"
    Response.Write " onClick=""ChargeSetting2.style.display='';ChargeSetting.style.display='none';ChargeSetting3.style.display=''""> 按订单金额的百分比计算运费</td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td align='right'>&nbsp;</td>" & vbCrLf
    Response.Write "      <td><input name='IsDefault' type='checkbox' id='IsDefault' value='Yes'"
    If rsType("IsDefault") = True Then Response.Write " checked"
    Response.Write "> 设为默认送货方式</td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    
    Dim strNone_Charge1, strNone_Charge2, strNone_Charge3
    Select Case rsType("ChargeType")
    Case 1
        strNone_Charge1 = ""
        strNone_Charge2 = "none"
        strNone_Charge3 = ""
    Case 2
        strNone_Charge1 = "none"
        strNone_Charge2 = ""
        strNone_Charge3 = ""
    Case Else
        strNone_Charge1 = "none"
        strNone_Charge2 = "none"
        strNone_Charge3 = "none"
    End Select
    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td colspan='2'><table width='100%'  border='0' cellpadding='2' cellspacing='1' class='border' id='ChargeSetting' style='display:" & strNone_Charge1 & "'>" & vbCrLf
    
    Dim rsCharge
    Dim arrArea, Weight_Min, Charge_Min, WeightPerUnit, ChargePerUnit, Charge_Max
    Set rsCharge = Conn.Execute("select * from PE_DeliverCharge where DeliverTypeID=" & TypeID & " and AreaType=1")
    If rsCharge.BOF And rsCharge.EOF Then
        arrArea = ""
        Charge_Min = 0
        Weight_Min = 0
        WeightPerUnit = 1
        ChargePerUnit = 0
        Charge_Max = 0
    Else
        arrArea = rsCharge("arrArea")
        Charge_Min = FormatNumber(rsCharge("Charge_Min"), 2, vbTrue, vbFalse, vbTrue)
        Weight_Min = FormatNumber(rsCharge("Weight_Min"), 2, vbTrue, vbFalse, vbTrue)
        WeightPerUnit = FormatNumber(rsCharge("WeightPerUnit"), 2, vbTrue, vbFalse, vbTrue)
        ChargePerUnit = FormatNumber(rsCharge("ChargePerUnit"), 2, vbTrue, vbFalse, vbTrue)
        Charge_Max = FormatNumber(rsCharge("Charge_Max"), 2, vbTrue, vbFalse, vbTrue)
    End If
    Set rsCharge = Nothing
    
    Response.Write "        <tr class='title'>" & vbCrLf
    Response.Write "          <td colspan='2'><b>同一城市间运费标准：</b></td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>基本运费：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Charge_Min1' type='text' id='Charge_Min1' value='" & Charge_Min & "' size='10' maxlength='10' style='text-align:center '> 元</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>基本运费的起算重量：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Weight_Min1' type='text' id='Weight_Min1' value='" & Weight_Min & "' size='10' maxlength='10' style='text-align:center '> 千克（Kg）<br>" & vbCrLf
    Response.Write "      当商品重量不超过上述指定起算重量时，实际运费按基本运费计算。</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>浮动运费：</b></td>" & vbCrLf
    Response.Write "          <td>当商品总重量超过基本运费的起算重量后，除了收取基本运费外，每" & vbCrLf
    Response.Write "              <input name='WeightPerUnit1' type='text' id='WeightPerUnit1' value='" & WeightPerUnit & "' size='6' maxlength='6' style='text-align:center '>" & vbCrLf
    Response.Write "      千克的商品增加运费" & vbCrLf
    Response.Write "      <input name='ChargePerUnit1' type='text' id='ChargePerUnit1' value='" & ChargePerUnit & "' size='10' maxlength='10' style='text-align:center '> 元</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>最高运费：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Charge_Max1' type='text' id='Charge_Max1' value='" & Charge_Max & "' size='10' maxlength='10' style='text-align:center '> 元（当基本运费＋浮动运费超过最高运费时，实际运费按最高运费计算）</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    
    Set rsCharge = Conn.Execute("select * from PE_DeliverCharge where DeliverTypeID=" & TypeID & " and AreaType=2")
    If rsCharge.BOF And rsCharge.EOF Then
        arrArea = ""
        Charge_Min = 0
        Weight_Min = 0
        WeightPerUnit = 1
        ChargePerUnit = 0
        Charge_Max = 0
    Else
        arrArea = rsCharge("arrArea")
        Charge_Min = FormatNumber(rsCharge("Charge_Min"), 2, vbTrue, vbFalse, vbTrue)
        Weight_Min = FormatNumber(rsCharge("Weight_Min"), 2, vbTrue, vbFalse, vbTrue)
        WeightPerUnit = FormatNumber(rsCharge("WeightPerUnit"), 2, vbTrue, vbFalse, vbTrue)
        ChargePerUnit = FormatNumber(rsCharge("ChargePerUnit"), 2, vbTrue, vbFalse, vbTrue)
        Charge_Max = FormatNumber(rsCharge("Charge_Max"), 2, vbTrue, vbFalse, vbTrue)
    End If
    Set rsCharge = Nothing

    Response.Write "        <tr class='title'>" & vbCrLf
    Response.Write "          <td colspan='2'><b>同一区域间（比如珠江三角州、长江三角州等特别区域）的运费标准：</b></td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>区域范围：</b></td>" & vbCrLf
    Response.Write "          <td><input name='arrArea2' type='text' id='arrArea' value='" & arrArea & "' size='60' maxlength='255'>" & vbCrLf
    Response.Write "              <br>" & vbCrLf
    Response.Write "      请输入同一区域的所有城市的邮政编码前4位，以英文的逗号分隔。如果没有，请保持为空。</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>基本运费：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Charge_Min2' type='text' id='Charge_Min2' value='" & Charge_Min & "' size='10' maxlength='10' style='text-align:center '> 元</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>基本运费的起算重量：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Weight_Min2' type='text' id='Weight_Min2' value='" & Weight_Min & "' size='10' maxlength='10' style='text-align:center '> 千克（Kg）<br>" & vbCrLf
    Response.Write "      当商品重量不超过上述指定起算重量时，实际运费按基本运费计算。</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>浮动运费：</b></td>" & vbCrLf
    Response.Write "          <td>当商品总重量超过基本运费的起算重量后，除了收取基本运费外，每" & vbCrLf
    Response.Write "              <input name='WeightPerUnit2' type='text' id='WeightPerUnit2' value='" & WeightPerUnit & "' size='6' maxlength='6' style='text-align:center '>" & vbCrLf
    Response.Write "    千克的商品增加运费" & vbCrLf
    Response.Write "    <input name='ChargePerUnit2' type='text' id='ChargePerUnit2' value='" & ChargePerUnit & "' size='10' maxlength='10' style='text-align:center '> 元</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>最高运费：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Charge_Max2' type='text' id='Charge_Max2' value='" & Charge_Max & "' size='10' maxlength='10' style='text-align:center '> 元（当基本运费＋浮动运费超过最高运费时，实际运费按最高运费计算）</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    
    Set rsCharge = Conn.Execute("select * from PE_DeliverCharge where DeliverTypeID=" & TypeID & " and AreaType=3")
    If rsCharge.BOF And rsCharge.EOF Then
        arrArea = ""
        Charge_Min = 0
        Weight_Min = 0
        WeightPerUnit = 1
        ChargePerUnit = 0
        Charge_Max = 0
    Else
        arrArea = rsCharge("arrArea")
        Charge_Min = FormatNumber(rsCharge("Charge_Min"), 2, vbTrue, vbFalse, vbTrue)
        Weight_Min = FormatNumber(rsCharge("Weight_Min"), 2, vbTrue, vbFalse, vbTrue)
        WeightPerUnit = FormatNumber(rsCharge("WeightPerUnit"), 2, vbTrue, vbFalse, vbTrue)
        ChargePerUnit = FormatNumber(rsCharge("ChargePerUnit"), 2, vbTrue, vbFalse, vbTrue)
        Charge_Max = FormatNumber(rsCharge("Charge_Max"), 2, vbTrue, vbFalse, vbTrue)
    End If
    Set rsCharge = Nothing

    Response.Write "        <tr class='title'>" & vbCrLf
    Response.Write "          <td colspan='2'><b>同一省份间运费标准：</b></td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>基本运费：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Charge_Min3' type='text' id='Charge_Min3' value='" & Charge_Min & "' size='10' maxlength='10' style='text-align:center '> 元</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>基本运费的起算重量：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Weight_Min3' type='text' id='Weight_Min3' value='" & Weight_Min & "' size='10' maxlength='10' style='text-align:center '> 千克（Kg）<br>" & vbCrLf
    Response.Write "      当商品重量不超过上述指定起算重量时，实际运费按基本运费计算。</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>浮动运费：</b></td>" & vbCrLf
    Response.Write "          <td>当商品总重量超过基本运费的起算重量后，除了收取基本运费外，每" & vbCrLf
    Response.Write "              <input name='WeightPerUnit3' type='text' id='WeightPerUnit3' value='" & WeightPerUnit & "' size='6' maxlength='6' style='text-align:center '>" & vbCrLf
    Response.Write "    千克的商品增加运费" & vbCrLf
    Response.Write "    <input name='ChargePerUnit3' type='text' id='ChargePerUnit3' value='" & ChargePerUnit & "' size='10' maxlength='10' style='text-align:center '> 元</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>最高运费：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Charge_Max3' type='text' id='Charge_Max3' value='" & Charge_Max & "' size='10' maxlength='10' style='text-align:center '> 元（当基本运费＋浮动运费超过最高运费时，实际运费按最高运费计算）</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
     
    Response.Write "        <tr class='title'>" & vbCrLf
    Response.Write "          <td colspan='2'><b>外省运费标准：</b></td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td colspan='2'>外省运费标准较复杂，不同省份运费标准可能会不同，如新疆、西藏、内蒙古的运费就与其他省份不同。因此需要根据不同省份来设置不同的运费标准。" & vbCrLf
    Response.Write "<iframe src='Admin_DeliverCharge.asp?DeliverTypeID=" & TypeID & "' width='100%' height='200'></iframe></td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
        
    Set rsCharge = Conn.Execute("select * from PE_DeliverCharge where DeliverTypeID=" & TypeID & " and AreaType=5")
    If rsCharge.BOF And rsCharge.EOF Then
        arrArea = ""
        Charge_Min = 0
        Weight_Min = 0
        WeightPerUnit = 1
        ChargePerUnit = 0
        Charge_Max = 0
    Else
        arrArea = rsCharge("arrArea")
        Charge_Min = FormatNumber(rsCharge("Charge_Min"), 2, vbTrue, vbFalse, vbTrue)
        Weight_Min = FormatNumber(rsCharge("Weight_Min"), 2, vbTrue, vbFalse, vbTrue)
        WeightPerUnit = FormatNumber(rsCharge("WeightPerUnit"), 2, vbTrue, vbFalse, vbTrue)
        ChargePerUnit = FormatNumber(rsCharge("ChargePerUnit"), 2, vbTrue, vbFalse, vbTrue)
        Charge_Max = FormatNumber(rsCharge("Charge_Max"), 2, vbTrue, vbFalse, vbTrue)
    End If
    Set rsCharge = Nothing

    Response.Write "        <tr class='title'>" & vbCrLf
    Response.Write "          <td colspan='2'><b>国际运费标准：</b></td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>基本运费：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Charge_Min5' type='text' id='Charge_Min5' value='" & Charge_Min & "' size='10' maxlength='10' style='text-align:center '> 元</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>基本运费的起算重量：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Weight_Min5' type='text' id='Weight_Min5' value='" & Weight_Min & "' size='10' maxlength='10' style='text-align:center '> 千克（Kg）<br>" & vbCrLf
    Response.Write "      当商品重量不超过上述指定起算重量时，实际运费按基本运费计算。</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>浮动运费：</b></td>" & vbCrLf
    Response.Write "          <td>当商品总重量超过基本运费的起算重量后，除了收取基本运费外，每" & vbCrLf
    Response.Write "              <input name='WeightPerUnit5' type='text' id='WeightPerUnit5' value='" & WeightPerUnit & "' size='6' maxlength='6' style='text-align:center '>" & vbCrLf
    Response.Write "    千克的商品增加运费" & vbCrLf
    Response.Write "    <input name='ChargePerUnit5' type='text' id='ChargePerUnit5' value='" & ChargePerUnit & "' size='10' maxlength='10' style='text-align:center '> 元</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>最高运费：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Charge_Max5' type='text' id='Charge_Max5' value='" & Charge_Max & "' size='10' maxlength='10' style='text-align:center '> 元（当基本运费＋浮动运费超过最高运费时，实际运费按最高运费计算）</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf

    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td colspan='2'><table width='100%'  border='0' cellpadding='2' cellspacing='1' class='border' id='ChargeSetting2' style='display:" & strNone_Charge2 & "'>" & vbCrLf
    Response.Write "        <tr class='title'>" & vbCrLf
    Response.Write "          <td colspan='2'><b>按订单金额的百分比计算运费标准：</b></td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>基本运费：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Charge_Min' type='text' id='Charge_Min' value='" & rsType("Charge_Min") & "' size='10' maxlength='10' style='text-align:center '> 元</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>订单金额的百分比率：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Charge_Percent' type='text' id='Weight_Min1' value='" & rsType("Charge_Percent") & "' size='10' maxlength='10' style='text-align:center '> %<br></td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td width='150' align='right'><b>最高运费：</b></td>" & vbCrLf
    Response.Write "          <td><input name='Charge_Max' type='text' id='Charge_Max' value='" & rsType("Charge_Max") & "' size='10' maxlength='10' style='text-align:center '> 元（当订单金额*百份比率+基本运费超过最高运费时，实际运费按最高运费计算）</td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf

    Response.Write "    <tr class='tdbg'>" & vbCrLf
    Response.Write "      <td colspan='2'><table width='100%'  border='0' cellpadding='2' cellspacing='1' class='border' id='ChargeSetting3' style='display:" & strNone_Charge3 & "'>" & vbCrLf
    Response.Write "        <tr class='title'>" & vbCrLf
    Response.Write "          <td colspan='2'><b>运费优惠标准：</b></td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "        <tr>" & vbCrLf
    Response.Write "          <td colspan='2'><input type='radio' name='ReleaseType' value='0'"
    If rsType("ReleaseType") = 0 Then Response.Write " checked"
    Response.Write ">不实行任何优惠<br><input type='radio' name='ReleaseType' value='1'"
    If rsType("ReleaseType") = 1 Then Response.Write " checked"
    Response.Write ">实行下列优惠方式<br>"
    Response.Write "&nbsp;&nbsp;&nbsp;&nbsp;①当订单总金额达到 <input name='MinMoney1' type='text' id='MinMoney1' value='" & rsType("MinMoney1") & "' size='10' maxlength='10' style='text-align:center '> 元时，免除 <input name='ReleaseCharge' type='text' id='ReleaseCharge' value='" & rsType("ReleaseCharge") & "' size='5' maxlength='10' style='text-align:center '> 元运费（如果大于运费总额，则实际免除额为运费总额）<br>"
    Response.Write "&nbsp;&nbsp;&nbsp;&nbsp;②当订单总金额达到 <input name='MinMoney2' type='text' id='MinMoney2' value='" & rsType("MinMoney2") & "' size='10' maxlength='10' style='text-align:center '> 元时，并且运费总额不超过 <input name='MaxCharge' type='text' id='MaxCharge' value='" & rsType("MaxCharge") & "' size='5' maxlength='10' style='text-align:center '> 元时，免除全部运费<br>"
    Response.Write "&nbsp;&nbsp;&nbsp;&nbsp;③当订单总金额达到 <input name='MinMoney3' type='text' id='MinMoney3' value='" & rsType("MinMoney3") & "' size='10' maxlength='10' style='text-align:center '> 元时，免除全部运费<br></td>" & vbCrLf
    Response.Write "        </tr>" & vbCrLf
    Response.Write "      </table></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "    <tr align='center' class='tdbg'>" & vbCrLf
    Response.Write "      <td height='50' colspan='2'><input name='TypeID' type='hidden' id='TypeID' value='" & TypeID & "'>" & vbCrLf
    Response.Write "      <input name='Action' type='hidden' id='Action' value='SaveModify'>" & vbCrLf
    Response.Write "          <input type='submit' name='Submit' value='保存送货方式'></td>" & vbCrLf
    Response.Write "    </tr>" & vbCrLf
    Response.Write "  </table>" & vbCrLf
    Response.Write "</form>" & vbCrLf
    Response.Write "" & vbCrLf
    Set rsType = Nothing
End Sub

Sub SaveType()
    Dim TypeID, strTypeName, Intro, ChargeType, IsDefault, OrderID
    Dim ReleaseType, MinMoney1, ReleaseCharge, MinMoney2, MaxCharge, MinMoney3
    Dim rsType, sqlType
    Dim i
    Dim Charge_Min, Charge_Percent, Charge_Max
    
    TypeID = Trim(Request("TypeID"))
    strTypeName = ReplaceBadChar(Trim(Request("TypeName")))
    Intro = Trim(Request("Intro"))
    ChargeType = PE_CLng(Trim(Request("ChargeType")))
    IsDefault = Trim(Request("IsDefault"))
    ReleaseType = PE_CLng(Trim(Request("ReleaseType")))
    MinMoney1 = PE_CDbl(Trim(Request("MinMoney1")))
    ReleaseCharge = PE_CDbl(Trim(Request("ReleaseCharge")))
    MinMoney2 = PE_CDbl(Trim(Request("MinMoney2")))
    MaxCharge = PE_CDbl(Trim(Request("MaxCharge")))
    MinMoney3 = PE_CDbl(Trim(Request("MinMoney3")))
    Charge_Min = PE_CDbl(Trim(Request("Charge_Min")))
    Charge_Max = PE_CDbl(Trim(Request("Charge_Max")))
    Charge_Percent = PE_CLng(Trim(Request("Charge_Percent")))

    If strTypeName = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定送货方式名称</li>"
    End If
    If IsDefault = "Yes" Then
        IsDefault = True
        Conn.Execute ("update PE_DeliverType set IsDefault=" & PE_False & "")
    Else
        IsDefault = False
    End If
    
    If ChargeType = 1 Then
        For i = 1 To 5
            If i <> 4 Then
                If PE_CDbl(Trim(Request("WeightPerUnit" & i))) <= 0 Then
                    FoundErr = True
                    ErrMsg = ErrMsg & "<li>请输入大于0的单位重量！</li>"
                End If
                If PE_CDbl(Trim(Request("Charge_Min" & i))) > PE_CDbl(Trim(Request("Charge_Max" & i))) Then
                    FoundErr = True
                    ErrMsg = ErrMsg & "<li>最高运费不能小于基本运费！</li>"
                End If
            End If
        Next
    End If
    If ReleaseType > 0 Then
        If MinMoney1 <= 0 Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>一级优惠的订单总金额必须大于0！</li>"
        End If
        If ReleaseCharge <= 0 Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>一级优惠的免费运费金额必须大于0！</li>"
        End If
        If MinMoney2 <= MinMoney1 Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>二级优惠的订单总金额必须大于一级优惠的订单总金额！</li>"
        End If
        If MaxCharge <= 0 Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>二级优惠的运费总金额必须大于0！</li>"
        End If
        If MinMoney3 <= MinMoney2 Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>三级优惠的订单总金额必须大于二级优惠的订单总金额！</li>"
        End If
    End If
    
    
    If Action = "SaveAdd" Then
        sqlType = "select top 1 * from PE_DeliverType"
        Dim mrs
        Set mrs = Conn.Execute("select max(TypeID) from PE_DeliverType")
        If IsNull(mrs(0)) Then
            TypeID = 1
        Else
            TypeID = mrs(0) + 1
        End If
        Set mrs = Nothing
        Set mrs = Conn.Execute("select max(OrderID) from PE_DeliverType")
        If IsNull(mrs(0)) Then
            OrderID = 1
        Else
            OrderID = mrs(0) + 1
        End If
        Set mrs = Nothing
    Else
        If TypeID = "" Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>请指定TypeID！</li>"
        Else
            TypeID = PE_CLng(TypeID)
        End If
        sqlType = "select * from PE_DeliverType where TypeID=" & TypeID
    End If
    
    If FoundErr = True Then Exit Sub
    
    Set rsType = Server.CreateObject("adodb.recordset")
    rsType.Open sqlType, Conn, 1, 3
    If Action = "SaveAdd" Then
        rsType.AddNew
        rsType("TypeID") = TypeID
        rsType("OrderID") = OrderID
        rsType("IsDisabled") = False
    End If
    rsType("TypeName") = strTypeName
    rsType("Intro") = Intro
    rsType("IsDefault") = IsDefault
    rsType("ChargeType") = ChargeType
    rsType("ReleaseType") = ReleaseType
    rsType("MinMoney1") = MinMoney1
    rsType("ReleaseCharge") = ReleaseCharge
    rsType("MinMoney2") = MinMoney2
    rsType("MaxCharge") = MaxCharge
    rsType("MinMoney3") = MinMoney3
    If ChargeType = 2 Then
        rsType("Charge_Min") = Charge_Min
        rsType("Charge_Max") = Charge_Max
        rsType("Charge_Percent") = Charge_Percent
    End If
    rsType.Update
    rsType.Close
    Set rsType = Nothing

    If ChargeType = 1 Then
        If Action = "SaveModify" Then
            '先删除有关运费标准记录
            Conn.Execute ("delete from PE_DeliverCharge where DeliverTypeID=" & TypeID & " and AreaType<>4")
        End If
        
        Dim rsCharge, sqlCharge
        sqlCharge = "select top 1 * from PE_DeliverCharge"
        Set rsCharge = Server.CreateObject("adodb.recordset")
        rsCharge.Open sqlCharge, Conn, 1, 3
        For i = 1 To 5
            If i <> 4 Then
                rsCharge.AddNew
                rsCharge("DeliverTypeID") = TypeID
                rsCharge("AreaType") = i
                rsCharge("arrArea") = Trim(Request("arrArea" & i))
                rsCharge("Charge_Min") = PE_CDbl(Trim(Request("Charge_Min" & i)))
                rsCharge("Weight_Min") = PE_CDbl(Trim(Request("Weight_Min" & i)))
                rsCharge("ChargePerUnit") = PE_CDbl(Trim(Request("ChargePerUnit" & i)))
                rsCharge("WeightPerUnit") = PE_CDbl(Trim(Request("WeightPerUnit" & i)))
                rsCharge("Charge_Max") = PE_CDbl(Trim(Request("Charge_Max" & i)))
                rsCharge.Update
            End If
        Next
        rsCharge.Close
        Set rsCharge = Nothing
    End If

    Call CloseConn
    Response.Redirect "Admin_DeliverType.asp"
End Sub

Sub Del()
    Dim TypeID
    TypeID = Trim(Request("TypeID"))
    If TypeID = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定送货方式ID</li>"
        Exit Sub
    Else
        TypeID = PE_CLng(TypeID)
    End If
    
    Dim trs
    Set trs = Conn.Execute("select IsDefault from PE_DeliverType where TypeID=" & TypeID & "")
    If trs.BOF And trs.EOF Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>找不到指定的送货方式</li>"
    Else
        If trs(0) = True Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>不能删除默认的送货方式</li>"
        End If
    End If
    Set trs = Nothing
    If FoundErr = True Then Exit Sub
    
    Set trs = Conn.Execute("select top 1 OrderFormID from PE_OrderForm where DeliverType=" & TypeID & "")
    If Not (trs.BOF And trs.EOF) Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>已经有订单在使用此送货方式，所以不能删除！但你可以禁用此送货方式，以达到订购时不显示此送货方式的目的。</li>"
    End If
    Set trs = Nothing
    If FoundErr = True Then Exit Sub
    
    Conn.Execute ("delete from PE_DeliverType where TypeID=" & TypeID & "")
    Conn.Execute ("delete from PE_DeliverCharge where DeliverTypeID=" & TypeID & "")
    Call CloseConn
    Response.Redirect "Admin_DeliverType.asp"
End Sub

Sub DisableType()
    Dim TypeID
    TypeID = Trim(Request("TypeID"))
    If TypeID = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定送货方式ID</li>"
    Else
        TypeID = PE_CLng(TypeID)
    End If
    If FoundErr = True Then Exit Sub
    
    Dim trs
    Set trs = Conn.Execute("select IsDefault from PE_DeliverType where TypeID=" & TypeID & "")
    If trs.BOF And trs.EOF Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>找不到指定的送货方式</li>"
    Else
        If trs(0) = True Then
            FoundErr = True
            ErrMsg = ErrMsg & "<li>不能禁用默认的送货方式</li>"
        End If
    End If
    Set trs = Nothing
    If FoundErr = True Then Exit Sub
    
    Select Case Action
    Case "Disable"
        Conn.Execute ("update PE_DeliverType set IsDisabled=" & PE_True & " where TypeID=" & TypeID & "")
    Case "Enable"
        Conn.Execute ("update PE_DeliverType set IsDisabled=" & PE_False & " where TypeID=" & TypeID & "")
    End Select
    Call CloseConn
    Response.Redirect "Admin_DeliverType.asp"
End Sub

Sub Order()
    Dim TypeID, OrderID
    TypeID = Trim(Request("TypeID"))
    OrderID = Trim(Request("OrderID"))
    If TypeID = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定送货方式ID</li>"
    Else
        TypeID = PE_CLng(TypeID)
    End If
    If OrderID = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定OrderID</li>"
    Else
        OrderID = PE_CLng(OrderID)
    End If
    If FoundErr = True Then Exit Sub
    Conn.Execute ("update PE_DeliverType set OrderID=" & OrderID & " where TypeID=" & TypeID & "")
    Call CloseConn
    Response.Redirect "Admin_DeliverType.asp"
End Sub

Sub SetDefault()
    Dim TypeID
    TypeID = Trim(Request("TypeID"))
    If TypeID = "" Then
        FoundErr = True
        ErrMsg = ErrMsg & "<li>请指定TypeID</li>"
        Exit Sub
    Else
        TypeID = PE_CLng(TypeID)
    End If
    Conn.Execute ("update PE_DeliverType set IsDefault=" & PE_False & "")
    Conn.Execute ("update PE_DeliverType set IsDefault=" & PE_True & " where  TypeID=" & TypeID)
    Call CloseConn
    Response.Redirect "Admin_DeliverType.asp"
End Sub
%>
