<%@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="Include/Session.asp"-->
<%
Dim KSCls
Set KSCls = New Admin_ExpressManage
KSCls.Kesion()
Set KSCls = Nothing

Class Admin_ExpressManage
        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 DoDel()		'删除任务
	Dim RSObj, ID ,Total_Point
	ID = KS.G("ID")
	IF KS.CheckOuterUrl()=False Then
		If ID <> "" Then
			Conn.Execute("Delete From Express Where ID IN("& ID & ")")
			KS.AlertHintScript("删除成功！")
		Else
			KS.AlertHintScript("提交参数有误！")
		End If
	End If
	End Sub
	
	Sub DoAdd()
	%>
    <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(){
	var form=document.myform; 
	if (form.ComName.value==''){
		alert('请输入快递公司!');
		form.ComName.focus(); 
		return false;    }
	if (form.KuaiDiNum.value==''){
		alert('请输入快递单号!');
		form.KuaiDiNum.focus(); 
		return false;    }

	   form.submit();
	   return true;
}</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 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 SHUserName: SHUserName = Trim(RS("SHUserName"))
		Dim Mobile: Mobile = Trim(RS("Mobile"))
		Dim sStatus: sStatus = Trim(RS("Status"))
	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='AddSave' name='action'>
<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='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='SHUserName' value='<%=SHUserName%>' type='text' id='SHUserName' class='textbox'></td>
</tr>
<tr class='tdbg'>
	<td width='180' height='30' align='right' class='clefttitle'><strong>收货人电话：</strong></td>
	<td><input name='Mobile' value='<%=Mobile%>' type='text' id='Mobile' 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='<%
	If ScanDate<>"" Then
		KS.Echo ScanDate
	Else
		KS.Echo DateAdd("h", 6, Now())
	End If%>' class='textbox'> <a href='#' onClick="popUpCalendar(this, $('input[name=InputDate]').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><select name="Status">
	  <option value="0"<%If KS.ChkClng(sStatus)=0 Then KS.Echo " selected"%>>未使用</option>
	  <option value="1"<%If KS.ChkClng(sStatus)=1 Then KS.Echo " selected"%>>已领取</option>
	  <option value="2"<%If KS.ChkClng(sStatus)=2 Then KS.Echo " selected"%>>停用</option>
	</select></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 DoAdds()
	%>
    <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="../ks_inc/jquery.js" type="text/javascript"></script>
<script src="../KS_Inc/common.js" language="JavaScript"></script>
<script language="javascript" src="../KS_Inc/popcalendar.js"></script>
</head>
<Script Language='javascript'>
function CheckForm(){
	var form=document.myform; 
	if (form.ComName.value==''){
		alert('请输入快递公司!');
		form.ComName.focus(); 
		return false;    }
	if (form.KuaiDiInfo.value==''){
		alert('请输入快递单号信息!');
		form.KuaiDiInfo.focus(); 
		return false;    }

	   form.submit();
	   return true;
}</Script>
<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' onsubmit='return(CheckForm())'>
<input type='hidden' value='AddsSave' name='action'>
<tr class='tdbg'>
	<td width='120' height='30' align='right' class='clefttitle'><strong>快递公司：</strong></td>
	<td><input name='ComName' value='' 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='120' height='30' align='right' class='clefttitle'><strong>快递单号信息：</strong></td>
    <td><font color="#0099FF">填写格式1：100221233|广东省广州市|广东省深圳市福田区东方1街152号|李张三|13580551122<br>
	格式解释：快递单号|发货地址|收货地址|收货人姓名|收货人电话</font><br>
    <font color="#FF6600">填写格式2：762482906878 河北省 保定市 高碑店市 云南省 玉溪市 红塔区</font><br>
    <textarea name="KuaiDiInfo" cols="50" rows="20" class="textarea" id="KuaiDiInfo" style="width:550px" title="一行一个账号信息，用半角|号隔开！"></textarea></td>
</tr>
</tr>
<tr class='tdbg'>
	<td width='120' 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='<%=DateAdd("h", 6, Now())%>' class='textbox'> <a href='#' onClick="popUpCalendar(this, $('input[name=InputDate]').get(0), dateFormat,-1,-1)"><img src='Images/date.gif'  border='0' align='absmiddle' title='选择日期'></a>日期格式：年-月-日 时：分：秒</td>
</tr>
</form>
</table>
<br>
<div id='save' style="padding-left:250px">
<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 AddSave()
	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 SHUserName: SHUserName = Trim(KS.S("SHUserName"))
		Dim Mobile: Mobile = Trim(KS.S("Mobile"))
		Dim sStatus: sStatus = Trim(KS.S("Status"))

		 If ComName = "" Then Call KS.AlertHistory("请输入快递公司!", -1): Exit Sub
		 If Not IsDate(ScanDate) Then Call KS.AlertHistory("预计扫描时间格式不对!", -1): Exit Sub
		 Set RS = Server.CreateObject("ADODB.RECORDSET")
		 If ID = "" Then
		 	 Sql = "Select Top 1 * From Express Where KuaiDiNum='" & KuaiDiNum & "'"
			 RS.Open Sql, conn, 1, 3
			 If Not RS.Eof Then
				RS.Close
			  	Set RS = Nothing
			 	Call KS.AlertHistory("抱歉！该快递单号已存在，不可重复添加!", -1)
				Exit Sub
			 End If
			 RS.AddNew
		 Else
			 Sql = "Select Top 1 * From Express 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
		 End If
		  RS("ComName") = ComName
		  RS("KuaiDiNum") = KuaiDiNum
		  RS("ScanDate") = ScanDate
		  RS("CFCity") = CFCity
		  RS("MDCity") = MDCity
		  RS("SHUserName") = SHUserName
		  RS("Mobile") = Mobile
		  RS("Status") = KS.ChkClng(sStatus)
		  RS("AddDate") = Now()
		  If KS.ChkClng(sStatus) = 0 Then RS("IP") = ""
		  RS.Update
		  RS.Close
		  Set RS = Nothing
		  If ID = "" Then
			  KS.Echo ("<Script> if (confirm('单号添加成功,还继续添加吗?')) { location.href='?Action=Add';} else{top.frames[""MainFrame""].location.reload();}</script>")
		  Else
			  KS.Echo ("<Script> alert('单号修改成功！'); top.frames[""MainFrame""].location.reload();</script>")
		  End If
	End If
End Sub


'批量添加保存单号
Sub AddsSave()
	If KS.CheckOuterUrl()=False Then
		Dim RS,Sql,KuaiDiInfo_Row,KuaiDiInfo_Col,i,n,m
		Dim ComName: ComName = Trim(KS.S("ComName"))
		Dim KuaiDiInfo: KuaiDiInfo = Trim(KS.S("KuaiDiInfo"))
		Dim ScanDate: ScanDate = Trim(KS.S("ScanDate"))
		n = 0: m = 0

		If ComName = "" Then Call KS.AlertHistory("请输入快递公司!", -1): Exit Sub
		If Not IsDate(ScanDate) Then Call KS.AlertHistory("预计扫描时间格式不对!", -1): Exit Sub
		If InStr(KuaiDiInfo ,"|") = 0 And KS.reTest(KuaiDiInfo, "\S+\s+\S+\s+\S+\s+\S+\s+\S+") = False Then Call KS.AlertHistory("请填写的单号信息格式不对，请按格式填写提交！", -1): Exit Sub
		 
		KuaiDiInfo_Row = Split(KuaiDiInfo, vbCrlf)
		Set RS = Server.CreateObject("ADODB.RECORDSET")
		For i=0 To Ubound(KuaiDiInfo_Row)
			If Not KS.IsNul(Trim(KuaiDiInfo_Row(i))) Then
				If InStr(KuaiDiInfo_Row(i) ,"|") > 1 Then	'第一种格式"|"			
					
					KuaiDiInfo_Col = Split(KuaiDiInfo_Row(i), "|")
					If Ubound(KuaiDiInfo_Col) = 4 Then					
						 Sql = "Select Top 1 * From Express Where KuaiDiNum='" & Trim(KuaiDiInfo_Col(0)) & "'"
						 RS.Open Sql, conn, 1, 3
						 If RS.Eof Then
							  RS.AddNew				 
							  RS("ComName") = ComName
							  RS("KuaiDiNum") = KuaiDiInfo_Col(0)
							  RS("CFCity") = KuaiDiInfo_Col(1)
							  RS("MDCity") = KuaiDiInfo_Col(2)
							  RS("SHUserName") = KuaiDiInfo_Col(3)
							  RS("Mobile") = KuaiDiInfo_Col(4)
							  RS("ScanDate") = ScanDate
							  RS("Status") = 0
							  RS("AddDate") = Now()
							  RS.Update
						  Else
						  	m = m +1
						  End If
						  RS.Close
					Else
						n = n + 1
					End If
					
				ElseIf KS.reTest(KuaiDiInfo_Row(i), "\S+\s+\S+\s+\S+\s+\S+\s+\S+") Then		'第二种格式，空格
					
					KuaiDiInfo_Col = Split(KS.reReplace(KuaiDiInfo_Row(i), "(\S+)", 1, ""), vbCrLf)
					If Ubound(KuaiDiInfo_Col) = 6 Then					
						 Sql = "Select Top 1 * From Express Where KuaiDiNum='" & Trim(KuaiDiInfo_Col(0)) & "'"
						 RS.Open Sql, conn, 1, 3
						 If RS.Eof Then					
						
							  RS.AddNew				 
							  RS("ComName") = ComName
							  RS("KuaiDiNum") = KuaiDiInfo_Col(0)
							  RS("CFCity") = KuaiDiInfo_Col(1) & KuaiDiInfo_Col(2) & KuaiDiInfo_Col(3)
							  RS("MDCity") = KuaiDiInfo_Col(4) & KuaiDiInfo_Col(5) & KuaiDiInfo_Col(6)
							  RS("SHUserName") = ""
							  RS("Mobile") = ""
							  RS("ScanDate") = ScanDate
							  RS("Status") = 0
							  RS("AddDate") = Now()
							  RS.Update
						  Else
							m = m +1
						  End If
						  RS.Close
					Else
						n = n + 1
					End If
					
				End If
			End If
		Next
		Set RS = Nothing
		If n = Ubound(KuaiDiInfo_Row) + 1 Then
			Call KS.AlertHistory("抱歉！添加失败，原因是格式填写不对！", -1)
		ElseIf n > 0 And m = 0 Then
			KS.Echo ("<Script> if (confirm('批量添加成功，但有" & n & "条由于格式填写不对添加失败的。\n\n还继续添加吗?')) { location.href='?Action=Adds';} else{top.frames[""MainFrame""].location.reload();}</script>")
		ElseIf n > 0 And m > 0 Then
			KS.Echo ("<Script> if (confirm('批量添加成功，但有" & n & "条由于格式填写不对添加失败，有" & m & "条是重复的。\n\n还继续添加吗?')) { location.href='?Action=Adds';} else{top.frames[""MainFrame""].location.reload();}</script>")
		ElseIf m > 0 Then
			KS.Echo ("<Script> if (confirm('批量添加成功，但有" & m & "条是重复的。\n\n还继续添加吗?')) { location.href='?Action=Adds';} else{top.frames[""MainFrame""].location.reload();}</script>")
		Else
			KS.Echo ("<Script> if (confirm('批量添加成功，还继续添加吗?')) { location.href='?Action=Adds';} else{top.frames[""MainFrame""].location.reload();}</script>")
		End If
	End If
End Sub

Sub DoMod()
	Dim ID: ID=KS.ChkClng(KS.G("ID"))
	IF KS.CheckOuterUrl()=False Then
		Dim StatusID : StatusID = KS.ChkClng(KS.S("Status"))
		If ID <> 0 Then
			Conn.Execute("Update Express Set Status=" & StatusID & " Where ID=" & ID)
			KS.AlertHintScript("设置成功！")
		End If
	End If
End Sub
	
	
		Public Sub Kesion()
	    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="Add" Then
			Call DoAdd()
			Exit Sub
		ElseIF Action="Adds" Then
			Call DoAdds()
			Exit Sub
		ElseIf Action="AddSave" Then
			Call AddSave()
			Exit Sub
		ElseIf Action="AddsSave" Then
			Call AddsSave()
			Exit Sub
		ElseIf Action="Mod" Then
			Call DoMod()
			Exit Sub
		ElseIF Action="Del" And KS.G("ID") <>"" then
			Call DoDel()
			Exit Sub
		ElseIF Action="del" 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 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/HSK.Box.js"></script>
</head>
<body leftMargin=2 topMargin=0 marginheight="0" marginwidth="0">
  <div class="topdashed" style="padding:4px;">
  <table cellpadding="0" cellspacing="0" width="100%">
    <tr>
      <td>&nbsp; <a href="javascript:;" onClick="new KesionPopup().PopupCenterIframe('添加快递单','?Action=Add',620,350,'no')"><strong style="color:red">【添加快递单】</strong></a> &nbsp; <a href="javascript:;" onClick="new KesionPopup().PopupCenterIframe('添加快递单','?Action=Adds',750,480,'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="9%">快递公司</td>
      <td width="12%">快递单号</td>
      <td width="11%">预计扫描日期</td>
      <td width="8%">是否扫描</td>
      <td width="10%">购买人用户名</td>
      <td width="10%">任务编号</td>
      <td width="11%">购买时间</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 SHUserName 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"
					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","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 Where " & SqlParam)(0)
		Call showContent()
	End If
	RS.Close:Set RS=Nothing
   %>
<br/>
	<br/>
<div class="attention">
<strong>特别建议：</strong>
过期三天以上的单号，建议停用或删除，以释放资源。
<br />

<iframe src='about:blank' style='display:none' name='_hiddenframe' id='_hiddenframe'></iframe>
<form action="?action=del" 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
     Do While Not rs.eof 
	%>
    <tr class=list 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=Add&Optype=Edit&ID=<%=rs("ID")%>',620,350,'no')"><%=rs("ID")%></a></td>
      <td  class="splittd" align=middle><a href="?SearchType=5&Field=5&KeyWord=<%=rs("ComName")%>"><%=rs("ComName")%></a></td>
      <td  class="splittd" align=middle><%=rs("KuaiDiNum")%></td>
      <td  class="splittd" align=middle><%=rs("ScanDate")%></td>
      <td  class="splittd" align=middle><%=KS.IIF(DateDiff("s", Now, rs("ScanDate")) < 0,"<span style='color:red'>是</span>","否")%></td>
      <td  class="splittd" align=middle><a href="?SearchType=5&Field=3&KeyWord=<%=Rs("BuyUserName")%>"><%=rs("BuyUserName")%></a>&nbsp;</td>
	  <td  class="splittd" align=middle><%=rs("TaskID")%>&nbsp;</td>
      <td  class="splittd" align=middle><%=rs("BuyDate")%>&nbsp;</td>
      <td  class="splittd" align=middle><%
			  Select Case KS.ChkClng(rs("Status"))
					Case 0
						KS.Echo "<span style=""color:blue"">等待领取</span>"
					Case 1
						KS.Echo "<span style=""color:green"">已领取</span>"
					Case 2
						KS.Echo "<span style=""color:#FF5500"">已停用</span>"
			  End Select
		  %></td>
      <td  class="splittd" align=center><%
	  If KS.ChkClng(rs("Status")) = 2 Then%>
      <a href="?Action=Mod&Status=0&ID=<%=rs("ID")%>" onClick="return confirm('您确定要恢复该单号吗？')">启用</a>|
      <%ElseIf KS.ChkClng(rs("Status")) = 0 Then%>
	  <a href="?Action=Mod&Status=2&ID=<%=rs("ID")%>" onClick="return confirm('您确定要停用该单号吗？')">停用</a>|
	  <%End If%><a href="javascript:;" onClick="new KesionPopup().PopupCenterIframe('编辑快递单','?Action=Add&Optype=Edit&ID=<%=rs("ID")%>',620,350,'no')">修改</a>|<a href="?Action=Del&ID=<%=rs("ID")%>" onClick="return confirm('您确定要删除吗？')" title="删除单号">删除</a></td>
    </tr>
    <tr id="C<%=rs("id")%>" bgcolor="#EEEEEE" style="display:none;">
      <td class="splittd" align=center colSpan=11>发货地：<%=rs("CFCity")%> &nbsp; 收货地：<%=rs("MDCity")%> &nbsp; 收货人：<%=rs("SHUserName")%> &nbsp; 电话：<%=rs("Mobile")%> &nbsp; 添加日期：<%=rs("AddDate")%> &nbsp; 购买人IP：<%=rs("IP")%></td>
    </tr>
	<%
	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('确定要删除选中的记录吗?')){this.document.selform.submit();return true;}return false;}"></td>
</tr>
</form>
<tr>
	<td colspan=11 align=right>
	<%
	 Call KSCLS.ShowPage(totalPut, MaxPerPage, "", True, "条", Page, KS.QueryParam("page"))
	%></td>
</tr>
</table>
		<%
		End Sub
		
End Class
%> 
