<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%option explicit%>
<!--#include file="../Conn.asp"-->
<!--#include file="../Task/TaskConfig.asp"-->
<!--#include file="../HSK_Cls/HSK.CommonCls.asp"-->
<!--#include file="../HSK_Cls/HSK.AdministratorCls.asp"-->
<!--#include file="../HSK_Cls/HSK.Label.CommonCls.asp"-->
<!--#include file="../HSK_Cls/HSK.EscapeCls.asp"-->
<%
Dim mini_UserName: mini_UserName = "express"			'用户名，可自行修改
Dim mini_UserPass: mini_UserPass = "a123456"		'用户密码，可自行修改

If Request("Action") = "logout" Then Response.Cookies("mini_express_buy")("UserName") = ""
If Lcase(Request.Form("eUserName")) = mini_UserName And Lcase(Request.Form("ePassWord")) = mini_UserPass Then
	Response.Cookies("mini_express_buy")("UserName") = Lcase(Request.Form("eUserName"))
	Response.Write("<script>location.href='?';</script>")
	Response.End
ElseIf Request.Cookies("mini_express_buy")("UserName") <> mini_UserName Then
	If Request("eUserName") <> "" Then Response.Write("<center>账号或密码有误！</center>")
%>
<table align="center" width="100%" border="0">
<form action="?" method=post name="myform">   
   <tr>
     <td width="50%" align="right"><strong>用户名：</strong></td>
     <td width="50%" align="left"><input name="eUserName" type="text" size="15"></td>
   </tr>
   <tr>
     <td width="50%" align="right"><strong>密码：</strong></td>
     <td width="50%" align="left"><input name="ePassWord" type="password" size="15"></td>
   </tr>
   <tr>
     <td colspan="2" align="center"><input name="BT" value="登录" type="submit"></td>
   </tr>
</form>
</table>
<%
	Response.End
End If

Dim KSCls
Set KSCls = New Admin_ExpressManage_Buy
KSCls.Run()
Set KSCls = Nothing

Class Admin_ExpressManage_Buy
        Private KS,KSCls
		Private totalPut,rs, Page, MaxPerPage,DomainStr,SearchType,SQLParam
		Private Sub Class_Initialize()
		  Set KS=New PublicCls
		  Set KSCls=New ManageCls
		End Sub
        Private Sub Class_Terminate()
		 Call CloseConn()
		 Set KS=Nothing
		 Set KSCls=Nothing
		End Sub


	
	Sub Export_Show()
	%>
    <html>
<head><title>导出订购信息</title>
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
<link href="include/Admin_Style.css" type=text/css rel=stylesheet>
<script src="../HSK_Js/jquery.js" type="text/javascript"></script>
<script src="../HSK_Js/common.js" language="JavaScript"></script>
<script language="javascript" src="../HSK_Js/popcalendar.js"></script>
</head>

<body leftMargin=2 topMargin=0 marginheight="0" marginwidth="0">
<table width='100%' border='0' align='center' cellpadding='1' cellspacing='1' class='ctable' style='margin-top:5px;border-collapse: collapse'>
<form action='?page=<%=KS.S("p")%>' method='post' name='myform' id='myform'>
<input type='hidden' value='Export' name='action'>
<%
Dim ID: ID = KS.G("ID")
If Not KS.IsNul(ID) Then
	KS.Echo "<input type='hidden' value='" & ID & "' name='ID'>"
End If
%>
<tr class='tdbg'>
	<td width='150' height='30' align='right' class='clefttitle'><strong>快递单类型：</strong></td>
	<td><input name='Express_Com' type='text' id='Express_Com' class='textbox' title="留空表示所有"<%If Not KS.IsNul(ID) Then KS.Echo " disabled"%>> <select name="expressid" id="expressid" onChange="myform.Express_Com.value=this.options[this.selectedIndex].value">
        <option selected="selected" value="">点这选择快递公司</option>
        <option value="不限">不限</option>
        <option value="顺丰快递">顺丰快递</option>
        <option value="韵达快递">韵达快递</option>
        <option value="圆通快递">圆通快递</option>
        <option value="EMS快递">EMS快递</option>
        <option value="中通快递">中通快递</option>
        <option value="天天快递">天天快递</option>
        <option value="汇通快递">汇通快递</option>
        <option value="申通快递">申通快递</option>
        <option value="宅急送快递">宅急送快递</option>
      </select></td>
</tr>
<tr class='tdbg'>
	<td width='150' height='30' align='right' class='clefttitle'><strong>是否有单号：</strong></td>
	<td>
	  <label><input name="IsExpress_Num" type="radio" id="IsExpress_Num" value="1" checked<%If Not KS.IsNul(ID) Then KS.Echo " disabled"%>>有单号</label>
	  <label><input name="IsExpress_Num" type="radio" id="IsExpress_Num" value="2"<%If Not KS.IsNul(ID) Then KS.Echo " disabled"%>>没单号</label>
	  <label><input name="IsExpress_Num" type="radio" id="IsExpress_Num" value="3"<%If Not KS.IsNul(ID) Then KS.Echo " disabled"%>>不限</label>
	</td>
</tr>
<tr class='tdbg'>
	<td width='150' height='30' align='right' class='clefttitle'><strong>订购时间：</strong></td>
	<td>
	  <label><input name="buyDateType" type="radio" id="addDate" value="1" checked<%If Not KS.IsNul(ID) Then KS.Echo " disabled"%>>今天</label>
	  <label><input name="buyDateType" type="radio" id="addDate" value="2"<%If Not KS.IsNul(ID) Then KS.Echo " disabled"%>>昨天</label>
	  <label><br>
	  <input name="buyDateType" type="radio" id="addDate" value="3"<%If Not KS.IsNul(ID) Then KS.Echo " disabled"%>>自定义时间</label>
	  <input name='BeginDate' type='text' onClick="popUpCalendar(this, this, dateFormat,-1,-1)" id='BeginDate' value='<%=Date()%> 00:00:00' class='textbox'> 至 <input name='EndDate' type='text' onClick="popUpCalendar(this, this, dateFormat,-1,-1)" id='EndDate' value='<%=Date()%> 23:59:59' class='textbox'>
	</td>
</tr>
<tr class='tdbg'>
	<td width='150' height='30' align='right' class='clefttitle'><strong>导出项目：</strong></td>
	<td><p>
	  <label title="表中所有字段（包含没列出来的项目）"><input type="checkbox" name="FliedTitle" value="all" id="FliedTitle" disabled>全部</label>
      <label><input name="FliedTitle" type="checkbox" id="FliedTitle" value="ComName" checked>快递公司</label>
      <label><input name="FliedTitle" type="checkbox" id="FliedTitle" value="KuaiDiNum" checked>快递单号</label>
      <label><input name="FliedTitle" type="checkbox" id="FliedTitle" value="BuyUserName">订购人</label>
      <label><input name="FliedTitle" type="checkbox" id="FliedTitle" value="AddDate">订购时间</label>
      <label><input name="FliedTitle" type="checkbox" id="FliedTitle" value="BuyPayDate">买家付款时间</label>
      <br>
      <label><input name="FliedTitle" type="checkbox" id="FliedTitle" value="CFCity" checked>发货省市区</label>
      <label><input type="checkbox" name="FliedTitle" id="FliedTitle" value="FHUserName">发件人姓名</label>
      <label><input type="checkbox" name="FliedTitle" value="FHMobile" id="FliedTitle">发货人电话</label>
      <br>
      <label><input name="FliedTitle" type="checkbox" id="FliedTitle" value="MDCity_3x" checked>收货省市区</label>
      <label><input name="FliedTitle" type="checkbox" id="FliedTitle" value="MDCity_UserName" checked>收件人姓名</label>
      <label><input name="FliedTitle" type="checkbox" id="FliedTitle" value="MDCity_Mobile" checked>收货人电话</label>
      <label><input name="FliedTitle" type="checkbox" id="FliedTitle" value="MDCity" checked>收货详细地址</label>
	  <br>
	  </p></td>
</tr>
</form>
</table>
<br>
<div id='save'>
<li class='parent' onClick="myform.submit()">
	<span class=child onMouseOver="this.parentNode.className='parent_border'" onMouseOut="this.parentNode.className='parent'"><img src='images/ico/save.gif' border='0' align='absmiddle'>导出Excel</span>
</li>
<li class='parent' onClick="parent.closeWindow()">
    <span class=child onMouseOver="this.parentNode.className='parent_border'" onMouseOut="this.parentNode.className='parent'"><img src='images/ico/back.gif' border='0' align='absmiddle'>关闭取消</span>
</li>
</div>

  </body>
  </html>
	<%
	End Sub
	
Sub DoExport()
	If KS.CheckOuterUrl()=False Then
		Dim RS, Sql, Param, Flied, i
		Dim ID: ID = KS.G("ID")
		Dim Express_Com: Express_Com = Trim(KS.S("Express_Com"))
		Dim IsExpress_Num: IsExpress_Num = KS.ChkClng(KS.S("IsExpress_Num"))
		Dim buyDateType: buyDateType = KS.ChkClng(KS.S("buyDateType"))
		Dim BeginDate: BeginDate = Trim(KS.S("BeginDate"))
		Dim EndDate: EndDate = Trim(KS.S("EndDate"))
		Dim FliedTitle: FliedTitle = KS.S("FliedTitle")

		If buyDateType = 3 And (Not IsDate(BeginDate) Or Not IsDate(EndDate)) Then Call KS.AlertHistory("自定义的时间格式不对，请返回核查!", -1): Exit Sub
		Param = "1=1"
		If Not KS.IsNul(Express_Com) And Express_Com <> "不限" Then
			Param = Param & " And ComName = '" & Express_Com & "'"
		End If
		If IsExpress_Num = 1 Then
			Param = Param & " And (KuaiDiNum IS NOT NULL)"
		ElseIf IsExpress_Num = 2 Then
			Param = Param & " And (KuaiDiNum IS NULL)"
		End If
		If buyDateType = 1 Then
			Param = Param & " And DateDIff(" & DataPart_D & ", AddDate, " & SqlNowString & ") = 0"
		ElseIf buyDateType = 2 Then
			Param = Param & " And DateDIff(" & DataPart_D & ", AddDate, " & SqlNowString & ") = 1"
		ElseIf buyDateType = 3 Then
			Param = Param & " And AddDate >= '" & BeginDate & "'"
			EndDate = DateAdd("d", 1, EndDate)
			Param = Param & " And AddDate <= '" & EndDate & "'"
		End If
		If InStr(FliedTitle, "all") > 0 Then
			Flied = "*"
		Else
			Flied = FliedTitle
			Flied = Replace(Flied, "MDCity_3x", "")
			Flied = Replace(Flied, "MDCity_UserName", "")
			Flied = Replace(Flied, "MDCity_Mobile", "")
			Flied = Replace(Flied, ", , ,", ",")
			Flied = Replace(Flied, ", ,", ",")
		End If
		Dim ExcelTitle
		ExcelTitle = FliedTitle
		ExcelTitle = Replace(ExcelTitle, "ComName", "快递公司")
		ExcelTitle = Replace(ExcelTitle, "KuaiDiNum", "快递单号")
		ExcelTitle = Replace(ExcelTitle, "BuyUserName", "订购人")
		ExcelTitle = Replace(ExcelTitle, "AddDate", "订购时间")
		ExcelTitle = Replace(ExcelTitle, "BuyPayDate", "买家付款时间")
		ExcelTitle = Replace(ExcelTitle, "CFCity", "发货省,发货城市,发货区/县")
		ExcelTitle = Replace(ExcelTitle, "FHUserName", "发件人姓名")
		ExcelTitle = Replace(ExcelTitle, "FHMobile", "发货人电话")
		ExcelTitle = Replace(ExcelTitle, "MDCity_3x", "收货省,收货城市,收货区/县")
		ExcelTitle = Replace(ExcelTitle, "MDCity_UserName", "收件人姓名")
		ExcelTitle = Replace(ExcelTitle, "MDCity_Mobile", "收货人电话")
		ExcelTitle = Replace(ExcelTitle, "MDCity", "收货详细地址")
	'KS.echo  ExcelTitle &	Flied & " " & Param & vbcrlf
		ExcelTitle = Split(ExcelTitle,",")

		Sql = "Select " & Flied & " From [Express_Buy] Where " & Param
		Set RS = Server.CreateObject("ADODB.RECORDSET")
		RS.Open Sql, Conn, 1, 1
		If Not RS.EOF Then
		
			Response.Buffer = true
			Response.AddHeader "Content-Disposition","attachment; filename=" & Date() & "-" & Time & ".csv" 
			Response.CharSet = "GB2312" 
			Response.ContentType = "application/octet-stream" 
		
			KS.Echo Trim(ExcelTitle(0))
			For i = 1 To UBound(ExcelTitle)
				KS.Echo "," & Trim(ExcelTitle(i))
			Next
			KS.Echo vbCrlf

			Dim temArr, tmpsplit
		
			Do Until RS.EOF
				For i = 0 To UBound(ExcelTitle)
					tmpsplit = Split(RS("MDCity"), "，")
					If Ubound(tmpsplit) = 3 Then
						temArr = Split(Trim(tmpsplit(2)), " ")
					ElseIf Ubound(tmpsplit) = 4 Then
						temArr = Split(Trim(tmpsplit(3)), " ")
					End If
					
					Select Case Trim(ExcelTitle(i))
					Case "发货省"
						KS.Echo Trim(Split(RS("CFCity"), " ")(0)) & ","
					Case "发货城市"
						KS.Echo Trim(Split(RS("CFCity"), " ")(1)) & ","
					Case "发货区/县"
						KS.Echo Trim(Split(RS("CFCity"), " ")(2)) & ","
					Case "发件人姓名"
						KS.Echo RS("FHUserName") & ","
					Case "发货人电话"
						KS.Echo RS("FHMobile") & ","
					Case "收货省"
						KS.Echo temArr(0) & ","
					Case "收货城市"
						KS.Echo temArr(1) & ","
					Case "收货区/县"
						KS.Echo temArr(2) & ","
					Case "收件人姓名"
						KS.Echo Trim(tmpsplit(0)) & ","
					Case "收货人电话"
						If Not KS.IsNul(Trim(tmpsplit(1))) Then
							KS.Echo Trim(tmpsplit(1)) & ","
						Else
							KS.Echo Trim(tmpsplit(2)) & ","
						End If
					Case "收货详细地址"
						KS.Echo RS("MDCity") & ","
					Case Else
					'ks.echo i & " = " & ExcelTitle(i) & "= " &  RS(i) &"<br>"
						KS.Echo RS(i) & ","
					End Select
				Next
				KS.Echo vbCrlf
				Response.Flush()		
				RS.MoveNext
			Loop
		Else
			KS.Echo "当前没记录"
		End If
		
		RS.Close
		Set RS=Nothing
		
		Response.Flush()
		Response.End
	End If
End Sub	
	
	'==========================================================================================================
	'==========================================================================================================
		Public Sub Run()
	    'If Not (KS.ReturnPowerResult(0, "KMUA10007") or KS.ReturnPowerResult(5,"M510014"))Then
	'		  Call KS.ReturnErr(1, "")
	'	End If
		SearchType=KS.ChkClng(KS.G("SearchType"))
		Dim begindate:begindate=request("begindate")
		Dim enddate:enddate=request("enddate")

		Dim ID,Action : Action=KS.S("Action")
		IF Action="Show" Then
			Call Export_Show()
			Exit Sub
		ElseIF Action="Export" Then
			Call DoExport()
			Exit Sub
		ElseIF Action="Mod" Then
			Call DoMod()
			Exit Sub
		ElseIf Action="ModSave" Then
			Call ModSave()
			Exit Sub
		ElseIf Action="Write" Then
			Call DoWriteKD()
			Exit Sub
		ElseIF Action="Del" And KS.G("ID") <>"" then
			Call DoDel()
			Exit Sub
		ElseIF Action="delDate" then
			Dim Param
			Select Case KS.ChkClng(KS.G("DelType"))
				Case 1 Param="datediff(" & DataPart_D & ",adddate," & SqlNowString & ")>3"
				Case 2 Param="datediff(" & DataPart_D & ",adddate," & SqlNowString & ")>5"
				Case 3 Param="datediff(" & DataPart_D & ",adddate," & SqlNowString & ")>10"
				Case 4 Param="datediff(" & DataPart_D & ",adddate," & SqlNowString & ")>30"
			End Select
			If Param<>"" Then
				Conn.Execute("Delete From Express_Buy Where 1=1 and " & Param)
				KS.AlertHintScript "已按所选的条件，删除了相关记录！"
			End IF
			Exit Sub
		End If
		%>
<html>
<head><title>迷你——订购快递管理</title>
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
<link href="include/Admin_Style.css" type=text/css rel=stylesheet>
<script src="../HSK_Js/jquery.js" type="text/javascript"></script>
<script src="../HSK_Js/common.js" language="JavaScript"></script>
<script language="javascript" src="../HSK_Js/popcalendar.js"></script>
<script language="JavaScript" src="../HSK_Js/HSK.Box.js"></script>
<style type="text/css">
.red{background-color:#F63;}
</style>
</head>
<body leftMargin=2 topMargin=0 marginheight="0" marginwidth="0">
<script language="javascript">
//复制内容进剪贴板
function copyToClipboard(txt,msg) {
	  if(window.clipboardData) {
			  window.clipboardData.clearData();		
			  window.clipboardData.setData("Text", txt);		
	  } else if (window.netscape) {		
		   try {		
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");		
		   } catch (e) {		
				alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将 'signed.applets.codebase_principal_support'设置为'true'");		
		   }		
		   var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);		
		   if (!clip)		
				return;		
		   var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);		
		   if (!trans)		
				return;		
		   trans.addDataFlavor('text/unicode');		
		   var str = new Object();		
		   var len = new Object();		
		   var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);		
		   var copytext = txt;		
		   str.data = copytext;		
		   trans.setTransferData("text/unicode",str,copytext.length*2);		
		   var clipid = Components.interfaces.nsIClipboard;		
		   if (!clip)		
				return false;		
		   clip.setData(trans,null,clipid.kGlobalClipboard);
	  } else {	
			alert('抱歉！该浏览器(非IE内核)不支持复制，请用鼠标选中账号右键复制！');
			return;	
	  }			  
	  msg = (typeof(msg)=="undefined")?'复制成功！':msg;		
	  alert(msg);	
 }
 
function WriteKD(ID)
{
new KesionPopup().popupTips(" 填写快递单号","<div style='display:block;padding:15px;height:100px;line-height:22px;text-align:center;'><form name='KDform' id='KDform' action='?Action=Write' method='post'><strong>请填写快递单号：</strong><input type='text' value='' name='wKuaidi' id='wKuaidi'><br><br><strong>发快递时间：</strong><input name='ScanDate' type='text' onClick='popUpCalendar(this, this, dateFormat,-1,-1)' id='ScanDate' title='留空默认为当前系统时间' class='textbox'><br><br><input name='isSendSMS' type='checkbox' value='1' checked><strong>是否发送手机短信通知</strong><br><br><input name='isSendMsg' type='checkbox' value='1' checked><strong>是否发送站内短信通知</strong><input type='hidden' value='"+ ID +"' name='ID'><br /><br /><input type='submit' onclick='return ChkWriteKD()' value=' 确 定 ' class='button'> <input type='button' value=' 取 消 ' onclick='closeWindow()' class='button'></form></div>",354,350)
}
function ChkWriteKD(){
if($('#wKuaidi').val()==''){
	alert('请先填写单号再提交。');
	 $('#wKuaidi').focus();
	 return false;
}else{
	return confirm('确定要提交了吗？');
	}
}
function SendSMS(ID,Mobile,Content){
        var ajaxchk;
        var ajaxstr;
        if(!confirm('您确定要发送手机短信通知吗？')) return false;
        document.selform.Send_bt.disabled=true;
        $.ajax({type:"post",url:"/Plus/Ajax_SMS.asp",data:"Action=SendSMS&Mobile="+ Mobile +"&Content="+ escape(Content) +"&Flag=BuyExpress_"+ ID +"&anticache=" + Math.floor(Math.random()*1000),cache:false,dataType:"html",success:function(d){
        var s=unescape(d);
        ajaxchk=s.split('|')[0];
        ajaxstr=s.split('|')[1];
        if (ajaxstr!=null){
            if (ajaxchk=='ok'){alert(ajaxstr);}
            else{alert(ajaxstr);document.selform.Send_bt.disabled=false;}
        }
    } });
}
</script>
  <div class="topdashed" style="padding:4px;">
  <table cellpadding="0" cellspacing="0" width="100%">
    <tr>
      <td>&nbsp; &nbsp; <a href="?Action=logout"><strong style="color:red">【退出】</strong></a>&nbsp; <a href="javascript:;" onClick="new KesionPopup().PopupCenterIframe('导出订购信息','?Action=Show',640,260,'no')"><strong style="color:red">【导出订购信息】</strong></a></td>
<FORM name="form2" action="?" method="post">
      <td style="border:1px #cccccc dashed">高级查询： 
<Select id=Field name=Field class='textbox'> 
  <Option value=1<%=KS.IIF(KS.ChkClng(KS.G("Field"))=1," selected","")%>>快递单号</Option> 
  <Option value=2<%=KS.IIF(KS.ChkClng(KS.G("Field"))=2," selected","")%>>任务编号</Option>
  <Option value=3<%=KS.IIF(KS.ChkClng(KS.G("Field"))=3," selected","")%>>购买人用户名</Option> 
  <Option value=4<%=KS.IIF(KS.ChkClng(KS.G("Field"))=4," selected","")%>>收货人姓名</Option> 
</Select> 关键字：
  <Input id=Keyword class='textbox' maxLength=30 name=Keyword value="<%=KS.G("KeyWord")%>"> 
  <Input class='button' type=submit value=" 查 询 " name=Submit2> 
        <Input id=SearchType type=hidden value=5 name=SearchType> </td></FORM>
    </tr>
  </table>
  </div>

  <div style="border:1px #cccccc dashed;overflow:hidden"></div>
  
   <table width="100%" border="0">
<form action="?action=search&SearchType=100&Field=3" method=post name="myform">
   
   <tr>
     <td width="12%"><strong>按时间段查询</strong></td>
     <td width="48%">
       
       <table width="100%"  align="center" border=0 cellPadding=0 cellSpacing=0>
         <tr>
           <td nowrap="nowrap" class=form-left>起始日期：
             <%if isdate(begindate) then%>
             <input type="text" name="begindate" value="<%=begindate%>" size="12" class="form-input">
             <%else%>
             <input type="text" name="begindate" value="<%=year(now)&"-"&month(now)&"-1"%>" size="12" class="form-input">
             <%end if%>
            </td>    
		    <td  class=form-left>终止日期：  
		      <%if isdate(enddate) then%>            
		      <input type="text" name="enddate" value="<%=enddate%>" size="12" class="form-input">
		      <%else%>
		      <input type="text" name="enddate" value="<%=formatdatetime(now,2)%>" size="12" class="form-input">
		      <%end if%>
		      </td>    
			</tr>
        </table>	 </td>
     <td width="40%">购买人用户名：
      <input type="text" class='textbox' name="keyword" size="10" value="<%If KS.ChkClng(KS.G("Field"))=3 Then KS.Echo Request("keyword")%>" /> &nbsp;
      <input name="submit2" type="submit" value="按日期查找" class='button' />
      </td>
    </tr>
</form>
 </table>
<table width="100%">
    <tr>
      <td align=left>
	  <%
	  if begindate<>"" and enddate<>"" then
	   response.write "<br><div align=center style='font-size:14px'>"
	 response.write "查询时间段 <font color=red>" & begindate & "</font> 至 <font color=red>" & enddate & "</font><br></div>"
	  end if
	  %></td>
    </tr>
  </table>
  
  <table width="100%">
    <tr>
      <td align=left>您现在的位置：快递单管理&nbsp;&gt;&gt;&nbsp;
	  <%Dim SearchTypeStr,SQLStr,TotalPages
	    Dim KeyWord:KeyWord=Trim(KS.G("KeyWord"))
	  Select Case SearchType
		 Case 5 
		    Select Case KS.ChkClng(KS.G("Field"))
			  Case 1:SearchTypeStr="快递单号含有<font color=red>""" & KeyWord & """</font>"
			  Case 2:SearchTypeStr="任务编号含有<font color=red>""" & KeyWord & """</font>"
			  Case 3:SearchTypeStr="购买人名含有<font color=red>""" & KeyWord & """</font>"
			  Case 4:SearchTypeStr="收货人名含有<font color=red>""" & KeyWord & """</font>"
			End Select
		Case 100:SearchTypeStr="时间段查询结果"
	  End Select
	  Response.Write SearchTypeStr%></td>
    </tr>
  </table>
  <div style="border:1px #cccccc dashed;overflow:hidden"></div>

  <table cellSpacing=0 cellPadding=0 width="100%" border=0>
  <form name="selform" method="post" action="?action=Del">
    <tr class=sort align=middle>
	  <td width="4%" nowrap>选择</td>
      <td width="7%" height="25">ID号</td>
      <td width="10%">任务编号</td>
      <td width="10%">买家付款时间</td>
      <td width="9%">快递公司</td>
      <td width="10%">快递单号</td>
      <td width="10%">发快递时间</td>
      <td width="10%">订购人用户名</td>
      <td width="10%">订购时间</td>
      <td width="7%">价格/点</td>
      <td width="">操作</td>
    </tr>
	<%
			MaxPerPage=20
			Page = KS.ChkClng(KS.G("page"))
			If Page<=0 Then  Page = 1
			SqlParam="1=1"
            If SearchType<>"0" Then
			  Select Case SearchType

			  Case 5
			      Select Case KS.ChkClng(KS.G("Field"))
				   Case 1
				   	 If KS.IsNul(Keyword) Then Keyword = 0
				     SqlParam=SqlParam &" And KuaiDiNum Like '%" & Keyword & "%'"
				   Case 2
				     SqlParam=SqlParam &" And TaskID Like '%" & Keyword & "%'"
				   Case 3
				     SqlParam=SqlParam &" And BuyUserName Like '%" & Keyword & "%'"
				   Case 4
				     SqlParam=SqlParam &" And FHUserName Like '%" & Keyword & "%'"
				   Case 5
				     SqlParam=SqlParam &" And ComName Like '%" & Keyword & "%'"
				  End Select
			  Case 100
			  		If Keyword <> "" Then
				  		SqlParam=SqlParam &" And BuyUserName Like '%" & Keyword & "%'"
					End If
			  End Select
			End If
			If CInt(DataBaseType) = 1 Then         'Sql
				if isdate(begindate) then SqlParam=SqlParam & " and AddDate>='" & begindate & "'"
				if isdate(enddate) then enddate=DateAdd("d", 1,EndDate):SqlParam=SqlParam & " and AddDate<='" & enddate & "'"
			else
				if isdate(begindate) then SqlParam=SqlParam & " and AddDate>=#" & begindate & "#"
				if isdate(enddate) then enddate=DateAdd("d", 1,EndDate):SqlParam=SqlParam & " and AddDate<=#" & enddate & "#"
			end if


    If DataBaseType=1 Then
			Dim Cmd : Set Cmd = Server.CreateObject("ADODB.Command")
			Set Cmd.ActiveConnection=conn
			Cmd.CommandText="KS_GetPageRecords"
			Cmd.CommandType=4	
			CMD.Prepared = true 
			Cmd.Parameters.Append cmd.CreateParameter("@tblName",202,1,200)
			Cmd.Parameters.Append cmd.CreateParameter("@fldName",202,1,200)
			Cmd.Parameters.Append cmd.CreateParameter("@pagesize",3)
			Cmd.Parameters.Append cmd.CreateParameter("@pageindex",3)
			Cmd.Parameters.Append cmd.CreateParameter("@ordertype",3)
			Cmd.Parameters.Append cmd.CreateParameter("@strWhere",202,1,1000)
			Cmd.Parameters.Append cmd.CreateParameter("@fieldIds",202,1,1000)
			Cmd("@tblName")="Express_Buy"
			Cmd("@fldName")= "ID"
			Cmd("@pagesize")=MaxPerPage
			Cmd("@pageindex")=page
			Cmd("@ordertype")=1
			Cmd("@strWhere")=SqlParam
			Cmd("@fieldIds")="*"
			Set Rs=Cmd.Execute
			Set Cmd = Nothing
	 Else
			SQLStr=KS.GetPageSQL("Express_Buy","ID",MaxPerPage,Page,1,SqlParam,"*")
			Set RS = Server.CreateObject("AdoDb.RecordSet")
			RS.Open SQLStr, conn, 1, 1
	 End If
	If RS.Eof AND RS.Bof Then
		Response.WRITE "<tr class=list onmouseover=""this.className='listmouseover'"" onmouseout=""this.className='list'""><td colspan=11 align=center height='25'>当前没记录或找不到" & SearchTypeStr & "!</td></tr></table></form>"
	Else
		totalPut = Conn.Execute("Select Count(0) From Express_Buy Where " & SqlParam)(0)
		Call showContent()
	End If
	RS.Close:Set RS=Nothing
   %>
<br/>
	<br/>
<div class="attention">
<strong>特别建议：</strong>过期三天以上的单号，建议停用或选择下面方式删除，以释放资源。<strong style="color:#F00">【注：下面的删除不会返还订购人的订购资金】</strong><br>
<iframe src='about:blank' style='display:none' name='_hiddenframe' id='_hiddenframe'></iframe>
<form action="?action=delDate" target="_hiddenframe" method=post onSubmit="return confirm('确实要删除有关记录吗？【此处删除的记录不会返还资金的】')">
删除范围：<input name="deltype" type="radio" value=1>
3天前 
    <input name="deltype" type="radio" value="2" checked="checked" />
    5天前
    <input name="deltype" type="radio" value="3" />
    10天前
    <input name="deltype" type="radio" value="4" />
    1个月前
    <input type="submit" value="执行删除" class="button">
	</form>
	<br/>
</body>
</html>
   <%
   End Sub
  
  Sub ShowContent()
     on error resume next
     Dim I, CurrMoney, CurrPoint
	 CurrMoney = 0: CurrPoint = 0
     Do While Not rs.eof 
	%>
    <tr<%If rs("KuaiDiNum")<>"" Then KS.Echo " class=list" Else KS.Echo " class='red'"%> onMouseOver="this.className='listmouseover'" onMouseOut="this.className='list'" onClick="$('#C<%=rs("id")%>').toggle()">
	  <td align="center" class="splittd"><input type="checkbox" name="ID" value="<%=rs("id")%>"></td>
      <td  class="splittd" align=middle><a href="javascript:;" onClick="new KesionPopup().PopupCenterIframe('编辑查看快递单','?Action=Mod&Optype=Edit&ID=<%=rs("ID")%>',620,400,'no')"><%=rs("ID")%></a></td>
      <td  class="splittd" align=middle><a href="TaskManage.asp?keyword=<%=rs("TaskID")%>&condition=1" title="查看该任务详情"><%=rs("TaskID")%></a>&nbsp;</td>
      <td  class="splittd" align=middle><%=rs("BuyPayDate")%></td>
      <td  class="splittd" align=middle><a href="?SearchType=5&Field=5&KeyWord=<%=rs("ComName")%>"><%=rs("ComName")%></a></td>
      <td  class="splittd" align=middle><%If rs("KuaiDiNum")<>"" Then%><span style="cursor:pointer; color:#F00" onClick="copyToClipboard('<%=rs("KuaiDiNum")%>','快递单号已复制成功！')" title="点击复制"><%=rs("KuaiDiNum")%></span><%Else%><input name="WriteKDNum" type="button" value="填写单号" class="button" onClick="WriteKD(<%=rs("id")%>)"><%End If%></td>
      <td  class="splittd" align=middle><%=rs("ScanDate")%>&nbsp;</td>
	  <td  class="splittd" align=middle><a href="?SearchType=5&Field=3&KeyWord=<%=Rs("BuyUserName")%>"><%=rs("BuyUserName")%></a></td>
      <td  class="splittd" align=middle><%=rs("AddDate")%>&nbsp;</td>
      <td  class="splittd" align=middle><%If KS.ChkClng(rs("PayType"))=1 Then KS.Echo "<font color=red title='扣账户余额" & rs("Money") & "元'>" & rs("Money") & " 元</font>" Else KS.Echo "<font color=blue title='扣账户发布点" & rs("Money") & "点'>" & rs("Money") & " 点</font>"%></td>
      <td  class="splittd" align=center><%If rs("KuaiDiNum")<>"" And DATEDIFF("d",RS("ScanDate"),Now) = 0 Then%><input name="Send_bt" type="button" value="通知" class="button" onClick="SendSMS(<%=rs("id")%>,'<%=Conn.Execute("SELECT Top 1 Mobile FROM KS_User WHERE UserName = '" & RS("BuyUserName") & "'")(0)%>','您<%=Day(RS("AddDate"))%>号<%=Hour(RS("AddDate"))%>点订购的快递单已寄出，快递单号是：<%=RS("KuaiDiNum")%> 请尽快去淘宝(拍拍)发货！')" title="发送手机短信通知，注:填写单号后本按钮只显示一天"> | <%End If%><a href="javascript:;" onClick="new KesionPopup().PopupCenterIframe('编辑查看快递单','?Action=Mod&Optype=Edit&ID=<%=rs("ID")%>',620,400,'no')">修改</a> | <a href="?Action=Del&ID=<%=rs("ID")%>" onClick="return confirm('您确定要删除吗？\n\n【注：还没发快递单号的记录会返还订购资金】')" title="删除单号">删除</a></td>
    </tr>
    <tr id="C<%=rs("id")%>" bgcolor="#EEEEEE" style="display:none;">
      <td class="splittd" align=center colSpan=11><strong>发货地：</strong><%=rs("CFCity")%> &nbsp; <strong>发货人：</strong><%=rs("FHUserName")%> &nbsp; <strong>发货人电话：</strong><%=rs("FHMobile")%> &nbsp; <strong>收货地：</strong><%=rs("MDCity")%> &nbsp; <strong>订购人IP：</strong><%=rs("IP")%></td>
    </tr>
	<%
	If KS.ChkClng(rs("PayType"))=1 Then
		CurrMoney = CurrMoney + rs("Money")
	Else
		CurrPoint = CurrPoint + rs("Money")
	End If
	I = I + 1
	RS.MoveNext
	If I >= MaxPerPage Then Exit Do
	loop
	%>
<tr>
	<td class='list' onMouseOver="this.className='listmouseover'" onMouseOut="this.className='list'" height='25' colspan=11>
	&nbsp;&nbsp;<input id="chkAll" onClick="CheckAll(this.form)" type="checkbox" value="checkbox"  name="chkAll">全选
    <input class="button" type="submit" name="Submit2" value=" 删除选中的任务 " onClick="{if(confirm('你确定要删除选中的记录吗？\n\n【注：还没发快递单号的记录会返还订购资金】')){this.document.selform.submit();return true;}return false;}"></td>
</tr>
</form>
<tr>
	<td colspan=6 align=right>本页订购金额：<font color="#FF3300"><%=CurrMoney%></font> 元 &nbsp; 本页快递发布点：<font color="#FF3300"><%=CurrPoint%></font> 点 &nbsp; 总金额：<font color="#0000FF"><%=KS.ChkClng(Conn.Execute("Select Sum(Money) From Express_Buy Where PayType=1")(0))%></font> 元 &nbsp; 总发布点：<font color="#0000FF"><%=KS.ChkClng(Conn.Execute("Select Sum(Money) From Express_Buy Where PayType=2")(0))%></font> 点 &nbsp; 总单数量：<font color="#FF00FF"><%=KS.ChkClng(Conn.Execute("Select Count(0) From Express_Buy")(0))%></font> &nbsp; 今天数量：<font color="#FF00FF"><%=KS.ChkClng(Conn.Execute("Select Count(0) From Express_Buy Where DATEDIFF(d, AddDate, GetDate())=0")(0))%></font> &nbsp; 已填数量：<font color="#FF00FF"><%=KS.ChkClng(Conn.Execute("Select Count(0) From Express_Buy Where (KuaiDiNum IS NOT NULL) And KuaiDiNum <> ''")(0))%></font></td>
	<td colspan=5 align=right>
	<%
	 Call KSCLS.ShowPage(totalPut, MaxPerPage, "", True, "条", Page, KS.QueryParam("page"))
	%></td>
</tr>
</table>
		<%
		End Sub


	Sub DoMod()
	%>
    <html>
<head><title>编辑查看快递单</title>
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
<link href="include/Admin_Style.css" type=text/css rel=stylesheet>
<script src="../HSK_Js/jquery.js" type="text/javascript"></script>
<script src="../HSK_Js/common.js" language="JavaScript"></script>
<script language="javascript" src="../HSK_Js/popcalendar.js"></script>
</head>
<Script Language='javascript'>
function CheckForm(){
	if ($('#BuyPayDate').val()==''){
		alert('请输入淘宝(拍拍)买家付款时间!');
		$('#BuyPayDate').focus(); 
		return false;
    }
	if ($('#ComName').val()==''){
		alert('请输入快递公司!');
		$('#ComName').focus(); 
		return false;
    }
	if ($('#CFCity').val()==''){
		alert('请输入发货地!');
		$('#CFCity').focus(); 
		return false;
	}
	if ($('#MDCity').val()==''){
		alert('请输入收货地!');
		$('#MDCity').focus(); 
		return false;
	}
	if ($('#FHUserName').val()==''){
		alert('请输入发货人!');
		$('#FHUserName').focus(); 
		return false;
	}
	if(confirm('您确定要修改吗？')){
		document.myform.submit();
		return true;
	}
	return false;
}
</script>
<body leftMargin=2 topMargin=0 marginheight="0" marginwidth="0">
<%
Dim ID: ID = KS.S("ID")
If KS.S("Optype") = "Edit" Then
	 Set RS = Server.CreateObject("ADODB.RECORDSET")
	 Dim Sql: Sql = "Select * From Express_Buy Where ID='" & ID & "'"
	 RS.Open Sql, conn, 1, 1
	If Not RS.EOF Then
		Dim ComName: ComName = Trim(RS("ComName"))
		Dim KuaiDiNum: KuaiDiNum = Trim(RS("KuaiDiNum"))
		Dim ScanDate: ScanDate = Trim(RS("ScanDate"))
		Dim CFCity: CFCity = Trim(RS("CFCity"))
		Dim MDCity: MDCity = Trim(RS("MDCity"))
		Dim FHUserName: FHUserName = Trim(RS("FHUserName"))
		Dim FHMobile: FHMobile = Trim(RS("FHMobile"))
		Dim BuyPayDate: BuyPayDate = RS("BuyPayDate")
		Dim TaskID: TaskID=Trim(RS("TaskID"))
		Dim	PayType: PayType = KS.ChkClng(RS("PayType"))
		Dim Money: Money= KS.ChkClng(RS("Money"))
		Dim AddDate: AddDate = RS("AddDate")
	End If
	RS.Close
	Set RS=Nothing
End If
%>
<table width='100%' border='0' align='center' cellpadding='1' cellspacing='1' class='ctable' style='margin-top:5px;border-collapse: collapse'>
<form action='?ID=<%=ID%>&page=<%=KS.S("p")%>' method='post' name='myform' onsubmit='return(CheckForm())'>
<input type='hidden' value='ModSave' name='action'>
<%If TaskID<>"" Then%>
<tr class='tdbg'>
	<td width='180' height='30' align='right' class='clefttitle'><strong>任务编号：</strong></td>
	<td><%=TaskID%></td>
</tr>
<%End If%>
<tr class='tdbg'>
	<td width='180' height='30' align='right' class='clefttitle'><strong>淘宝(拍拍)买家付款时间：</strong></td>
	<td><%=BuyPayDate%></td>
</tr>
<tr class='tdbg'>
	<td width='180' height='30' align='right' class='clefttitle'><strong>选购的快递公司：</strong></td>
	<td><input name='ComName' value='<%=ComName%>' type='text' id='ComName' class='textbox'> <select name="expressid" id="expressid" onChange="myform.ComName.value=this.options[this.selectedIndex].value">
        <option selected="selected" value="">点这选择快递公司</option>
        <option value="顺丰快递">顺丰快递</option>
        <option value="韵达快递">韵达快递</option>
        <option value="圆通快递">圆通快递</option>
        <option value="EMS快递">EMS快递</option>
        <option value="中通快递">中通快递</option>
        <option value="天天快递">天天快递</option>
        <option value="汇通快递">汇通快递</option>
        <option value="申通快递">申通快递</option>
        <option value="宅急送快递">宅急送快递</option>
        </select></td>
</tr>
<tr class='tdbg'>
	<td width='180' height='30' align='right' class='clefttitle'><strong>快递单号：</strong></td>
	<td><input name='KuaiDiNum' value='<%=KuaiDiNum%>' type='text' id='KuaiDiNum' class='textbox'> 注：如果已发快递了，可填上单号</td>
</tr>
<tr class='tdbg'>
	<td width='180' height='30' align='right' class='clefttitle'><strong>发快递时间：</strong></td>
	<td><input name='ScanDate' type='text' onClick="popUpCalendar(this, this, dateFormat,-1,-1)" id='ScanDate' value='<%=ScanDate%>' class='textbox'> <a href='#' onClick="popUpCalendar(this, $('input[name=ScanDate]').get(0), dateFormat,-1,-1)"><img src='Images/date.gif'  border='0' align='absmiddle' title='选择日期'></a>日期格式：年-月-日 时：分：秒</td>
</tr>
<tr class='tdbg'>
	<td width='180' height='30' align='right' class='clefttitle'><strong>发货地：</strong></td>
	<td><input name='CFCity' type='text' class='textbox' id='CFCity' value='<%=CFCity%>' size="42"></td>
</tr>
<tr class='tdbg'>
	<td width='180' height='30' align='right' class='clefttitle'><strong>收货地：</strong></td>
	<td><input name='MDCity' value='<%=MDCity%>' type='text' id='MDCity' class='textbox' size="42"></td>
</tr>
<tr class='tdbg'>
	<td width='180' height='30' align='right' class='clefttitle'><strong>收货人：</strong></td>
	<td><input name='FHUserName' value='<%=FHUserName%>' type='text' id='FHUserName' class='textbox'></td>
</tr>
<tr class='tdbg'>
	<td width='180' height='30' align='right' class='clefttitle'><strong>收货人电话：</strong></td>
	<td><input name='FHMobile' value='<%=FHMobile%>' type='text' id='FHMobile' class='textbox'></td>
</tr>

<tr class='tdbg'>
	<td width='180' height='30' align='right' class='clefttitle'><strong>本次订购价格/点：</strong></td>
	<td><%=Money%>&nbsp;<%If PayType=1 Then KS.Echo "元" Else KS.Echo "点"%></td>
</tr>
<tr class='tdbg'>
	<td width='180' height='30' align='right' class='clefttitle'><strong>订购时间：</strong></td>
	<td><%=AddDate%></td>
</tr>
</form>
</table>
<br>
<div id='save'>
<li class='parent' onClick="return(CheckForm())">
	<span class=child onMouseOver="this.parentNode.className='parent_border'" onMouseOut="this.parentNode.className='parent'"><img src='images/ico/save.gif' border='0' align='absmiddle'>确定修改</span>
</li>
<li class='parent' onClick="parent.closeWindow()">
    <span class=child onMouseOver="this.parentNode.className='parent_border'" onMouseOut="this.parentNode.className='parent'"><img src='images/ico/back.gif' border='0' align='absmiddle'>关闭取消</span>
</li>
</div>

  </body>
  </html>
	<%
	End Sub
	
	
'编辑保存单号
Sub ModSave()
	If KS.CheckOuterUrl()=False Then
		Dim RS,Sql
		Dim ID: ID = KS.S("ID")
		Dim ComName: ComName = Trim(KS.S("ComName"))
		Dim KuaiDiNum: KuaiDiNum = Trim(KS.S("KuaiDiNum"))
		Dim ScanDate: ScanDate = Trim(KS.S("ScanDate"))
		Dim CFCity: CFCity = Trim(KS.S("CFCity"))
		Dim MDCity: MDCity = Trim(KS.S("MDCity"))
		Dim FHUserName: FHUserName = Trim(KS.S("FHUserName"))
		Dim FHMobile: FHMobile = Trim(KS.S("FHMobile"))

		 If ComName = "" Then Call KS.AlertHistory("请输入快递公司!", -1): Exit Sub
		 If ScanDate <>"" And Not IsDate(ScanDate) Then Call KS.AlertHistory("发快递时间格式不对!", -1): Exit Sub
		 If KuaiDiNum<>"" Then
			 If Not Conn.Execute("Select Top 1 ID From Express_Buy Where KuaiDiNum = '" & KuaiDiNum & "' And ID<>" & ID).Eof Then KS.AlertHintScript("抱歉！您提交的快递单号已存在，不可重复提交！")
		 End If
		 Set RS = Server.CreateObject("ADODB.RECORDSET")
		 Sql = "Select Top 1 * From Express_Buy Where ID=" & ID
		 RS.Open Sql, conn, 1, 3
		 If RS.EOF Then
			RS.Close
			Set RS = Nothing
			Call KS.AlertHistory("数据库中不存在该单号!", -1)
			Exit Sub
		 End If

		  RS("ComName") = ComName
		  If KuaiDiNum<>"" Then
		  	RS("KuaiDiNum") = KuaiDiNum
		  Else
		  	RS("KuaiDiNum") = Null
		  End If
		  If ScanDate<>"" Then RS("ScanDate") = ScanDate
		  RS("CFCity") = CFCity
		  RS("MDCity") = MDCity
		  RS("FHUserName") = FHUserName
		  RS("FHMobile") = FHMobile
		  RS("InputerDate") = Now()
		  RS.Update
		  RS.Close
		  Set RS = Nothing
		  KS.Echo ("<Script> alert('单号修改成功！'); parent.location.reload();</script>")
	End If
End Sub


Sub DoDel()
Dim RSObj, ID
ID=KS.G("ID")
IF KS.CheckOuterUrl()=False Then
	If ID <> "" Then
		Set RSObj = Server.CreateObject("Adodb.Recordset")
		RSObj.Open "Select * From Express_Buy Where ID IN("& ID & ")", Conn, 1, 3
		If Not RSObj.Eof Then
			Do While Not(RSObj.Eof)
				If KS.IsNul(RSObj("KuaiDiNum")) Then
					If KS.ChkClng(RSObj("PayType")) = 1 Then
						Call KS.MoneyInOrOut(RSObj("BuyUserName"),Conn.Execute("SELECT Top 1 RealName FROM KS_User WHERE UserName = '" & RSObj("BuyUserName") & "'")(0),RSObj("Money"),4,1,Now,0,"系统","撤消快递单订购退回金额！",22222,RSObj("ID"),0)
					Else
						Call KS.PointInOrOut(22222,RSObj("ID"),RSObj("BuyUserName"),1,RSObj("Money"),"系统","撤消快递单订购退回发布点！",1)
					End If
				End If
				RSObj.Delete
				RSObj.MoveNext
			Loop
		End If
		RSObj.Close
		Set RSObj = Nothing		
		KS.AlertHintScript("删除成功！")
	Else
		KS.AlertHintScript("提交参数有误！")
	End If
End If
End Sub



'函数名：Sending()
'作用：发送手机短信
'参数：手机号，短信内容
'返回值：数字代码
Function Sending(Mobile, Content)
    Dim sUserName    '短信接口的用户名
    Dim sKey         '短信接口的密码(或密钥)
    Dim sMobile      '接收短信的手机号。可以同时向多人发送短信。可使用逗号分隔多个信息
    Dim sContent     '短信内容
    Dim Url          '短信接口API地址
    Dim Http         '访问返回的HTTP对象
    
    sUserName = SMS_UserName
    sKey = SMS_Key
    sMobile = Mobile
    sContent = Content & "【" & KS.Setting(0) & "】"		'短信尾加上平台名称或公司签名，默认调用后台设置的网站名称
    If sMobile = "" Or Len(sMobile) < 11 Then
        Sending = -1: Exit Function
    End If
    If SMS_ServicePro = 1 Then  '吉信通公司 API接口
        Url = "http://service.winic.org:8009/sys_port/gateway/?id=" & sUserName & "&pwd=" & sKey & "&to=" & sMobile & "&content=" & Left(sContent, 70) & "&time="
    ElseIf SMS_ServicePro = 2 Then  '深圳市优信通达科技有限公司 API接口
        Url = "http://service.youxinda.net/user/InterFace_Sand.aspx?UName=" & sUserName & "&Pwd=" & sKey & "&SmsMsg=" & Escape(Left(sContent, 70)) & "&MobileList=" & sMobile
    ElseIf SMS_ServicePro = 3 Then  '广州志晴网络科技有限公司 API接口
        Url = "http://124.172.250.160/WebService.asmx/mt?Sn=" & sUserName & "&Pwd=" & sKey & "&mobile=" & sMobile & "&content=" & Escape(Left(sContent, 70))
    Else
        Sending = -2: Exit Function
    End If

    'On Error Resume Next
    Err.Clear
    Set Http = Server.CreateObject("Msxml2.XMLHTTP")
    With Http
        .Open "GET", Url, False
        .setRequestHeader "Content-type:", "text/xml;charset=GB2312"
        .Send
        If Err.Number <> 0 Then
            Err.Clear
            Sending = -3: Exit Function
        ElseIf .Readystate = 4 And .Status <> 200 Then
            Sending = -4: Exit Function
        Else
            If SMS_ServicePro = 1 Then  '处理吉信通返回代码
                If Left(.ResponseText, 3) <> "000" Then
                    Sending = -5: Exit Function
                Else
                    Sending = 0
                End If
            ElseIf SMS_ServicePro = 2 Then  '处理优信通达返回代码
                If Left(.ResponseText, 2) <> "OK" Then
                    Sending = -5: Exit Function
                Else
                    Sending = 0
                End If
            ElseIf SMS_ServicePro = 3 Then  '处理志晴网络返回代码
                If InStr(.ResponseText, ">0<") = 0 Then
                    Sending = -5: Exit Function
                Else
                    Sending = 0
                End If
            End If
        End If
    End With
    Set Http = Nothing
End Function


Sub DoWriteKD()
Dim RSObj,ID,V,sMsg,sSMS,ScanDate,Title,Msg
ID=KS.S("ID")
V=Trim(KS.S("wKuaidi"))
sMsg=KS.ChkClng(KS.S("isSendMsg"))
sSMS=KS.ChkClng(KS.S("isSendSMS"))
ScanDate=Trim(KS.S("ScanDate"))
IF KS.CheckOuterUrl()=False Then
	If ID <> "" And  V <> "" Then
		If Not Conn.Execute("Select Top 1 ID From Express_Buy Where KuaiDiNum = '" & V & "'").Eof Then KS.AlertHintScript("抱歉！您提交的快递单号已存在，不可重复提交！")
		Set RSObj = Server.CreateObject("Adodb.Recordset")
		RSObj.Open "Select Top 1 * From Express_Buy Where ID="& ID, Conn, 1, 3
		If Not RSObj.Eof Then
			RSObj("KuaiDiNum")=V
			RSObj("InputerDate")=Now
			If ScanDate<>"" And IsDate(ScanDate) Then RSObj("ScanDate")=ScanDate Else RSObj("ScanDate")=Now
			RSObj.Update
			Title = "您"& Day(RSObj("AddDate")) & "号" & Hour(RSObj("AddDate")) & "点订购的" & RSObj("ComName") & "已寄出，单号是：" & RSObj("KuaiDiNum") &" 请尽快去淘宝(拍拍)发货！"
			If sMsg = 1 Then
				Call KS.SendInfo(RSObj("BuyUserName"),"系统",Title,"系统通知，无需回复！")
			End If
			If sSMS = 1 Then
				If Sending(Conn.Execute("SELECT Top 1 Mobile FROM KS_User WHERE UserName = '" & RSObj("BuyUserName") & "'")(0), "尊敬的客户您好！" & Title) = 0 Then
					Msg = " \n\n且手机短信通知已发送成功！"
				Else
					Msg = " \n\n但手机短信通知发送失败！"
				End If
			End If
		End If
		RSObj.Close
		Set RSObj = Nothing
		KS.AlertHintScript("单号填写成功！" & Msg)
	Else
		KS.AlertHintScript("提交参数有误！")
	End If
End If
End Sub


End Class
%> 
