claimCustomer.asp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <!--#include file="Conn.asp"--><%Checklogin()%>
  2. <%
  3. cid=Request.QueryString("cid")
  4. If cid="" or not isNumeric(cid) Then cid=0 End If
  5. sqlstr="select count(id) as claimcount from customer where cs_belong="&Session("employee_id")&" and cs_claimdate>'"&date()&"'"
  6. Set Rs=Server.CreateObject("ADODB.Recordset")
  7. Rs.open sqlstr,conn,1,1
  8. If Rs("claimcount")>10 Then
  9. Reachedlimit=True
  10. Else
  11. Reachedlimit=False
  12. End If
  13. Rs.close
  14. Rs.open "select em_code from employee where id="&Session("employee_id"),conn,1,1
  15. em_code=Rs("em_code")
  16. Rs.close
  17. If Reachedlimit=True Then
  18. Response.write "-1"
  19. Else
  20. Rs.open "select employee.id as originalId,cs_code,em_user,cs_belong,cs_updatetime,cs_claimdate,cs_claimFrom,cs_chain,is_silent from customer left join employee on customer.cs_belong=employee.id where customer.id="&cid,conn,1,3
  21. If Not Rs.bof and Not Rs.eof Then
  22. Rs("cs_belong")=Session("employee_id")
  23. Rs("cs_claimdate")=now()
  24. oldCode=Rs("cs_code")
  25. Rs("cs_code")=Replace(Rs("cs_code"),"-","/0"&mid(em_code,2)&"-")
  26. Rs("cs_updatetime")=now()
  27. originalEmp=Rs("em_user")
  28. Rs("cs_claimFrom")=Rs("originalId")
  29. Rs("cs_chain")=Rs("cs_chain")&","&Session("employee_id") '更新流转记录
  30. Circulation=len(Rs("cs_chain"))-len(replace(Rs("cs_chain"),",",""))
  31. if Circulation>3 Then Rs("is_silent")=1 Else Rs("is_silent")=0 End If '是否作为沉默客户
  32. End If
  33. Rs.update
  34. Rs.close
  35. conn.execute("Insert into claimRecord (oldCode,originalEmp,newEmp,cs_id,claimTime,isread) values('"&oldCode&"','"&originalEmp&"','"&Session("employee_name")&"',"&cid&",'"&now()&"',0)")
  36. conn.execute("Delete from tagTable where customerId="&cid&"")
  37. Response.write "1"
  38. End If
  39. Set Rs=Nothing
  40. conn.close
  41. Set conn=Nothing
  42. %>