<html xmlns="http://www.w3.org/1999/xhtml">
<!--#include file="../Inc/Conn.asp" -->
<!--#include file="../Inc/SK.Session.asp" -->
<!--#include file="../Inc/SK.Funtion.asp" -->
<%if Not (Getconfig("SK_Client")="0" AND (Session("Manager")="1" OR (JudgePopedomTF(Session("UserName"),"SK200000000") AND JudgePopedomTF(Session("UserName"),"SK200000400") AND JudgePopedomTF(Session("UserName"),"SK200000401")))) then Call ReturnError()%>
<%
if RQ("Action")="Add" and F("fj1")<>"" then
Call ChkIsOuter()
Dim ConnXls,strsource,BookXls,SheetXls,i,GetNewID
Dim myConn_Xls,RsXls,objCmd,SrcXls
Set ConnXls = server.CreateObject("adodb.connection") 
Set RsXls = Server.CreateObject("Adodb.RecordSet")
file2="Client"
SrcXls=Server.mappath(""&F("fj1")&"")
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312" />
<title>导入客户信息</title>
<META http-equiv=Page-Enter content=SKCRM>
<META http-equiv=Page-Exit content=SKCRM>
<META content="MSHTML 6.00.3790.2858" name=GENERATOR>
<LINK href="../images/style.css" type=text/css rel=stylesheet>
<script language="javascript" src="../Inc/Check.js"></script>
<style type="text/css">
<!--
body {
margin: 5px 0px 5px 0px;
overflow-x: hidden;
}
-->
</style>
</head>
<body>
<table width="99%" border="0" align="center" cellpadding="0" cellspacing="0">
<TBODY>
<tr>
<td class="SK_Td_Top"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="12" height="25"><img src="../images/tab_03.gif" width="12" height="25" /></td>
<td><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="46%" valign="middle">导入客户信息</td>
<td width="54%"></td>
</tr>
</table></td>
<td width="16"><img src="../images/tab_07.gif" width="16" height="25" /></td>
</tr>
</table></td>
</tr>
<tr>
<td>

<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="8" background="../images/tab_12.gif"></td>
<td>

<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="b5d6e6">
<tr>
<td width="100%" class="SK_Text1">
<%
myConn_Xls="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&SrcXls&";Extended Properties=Excel 8.0"
ConnXls.open myConn_Xls
SqlXls = "Select * from ["&file2&"$]"
RsXls.open SqlXls,ConnXls,1,1 
If RsXls.eof Then
else
response.write "<TABLE border='0' cellpadding='0' cellspacing='1' bgcolor='b5d6e6' width='98%'>"
i=1
Do While not RsXls.eof 
DC1=RsXls("客户类型")
DC2=RsXls("客户编号")
DC3=RsXls("客户名称")
DC4=RsXls("其他名称")
DC5=RsXls("备注")
DC6=RsXls("联系人员")
DC7=RsXls("座机")
DC8=RsXls("手机")
DC9=RsXls("业务人员")
DC10=RsXls("地址")
DC11=RsXls("性别")
DC12=RsXls("部门")
DC13=RsXls("职务")
DC14=RsXls("传真")
DC15=RsXls("邮箱")

DC16=RsXls("客户性质")
DC17=RsXls("客户规模")
DC18=RsXls("客户行业")
DC19=RsXls("主营产品")
DC20=RsXls("重要程度")
DC21=RsXls("客户类别")
DC22=RsXls("客户状态")
DC23=RsXls("客户来源")

response.write "<tr>"
response.write "<td class='SK_Text1'>"&DC2&"</td>"
response.write "<td class='SK_Text1'>"&DC3&"</td>"
response.write "<td class='SK_Text1'>"&DC4&"</td>"
response.write "</tr>"

if DC3<>"" then
set RsClient=server.createobject("adodb.recordset")
SqlClient="select * from SK_Client where SK_Wname='"&DC3&"'"
RsClient.open SqlClient,conn,3,3
if not RsClient.eof or not RsClient.bof then
RsClient("SK_Di")=DC1
RsClient("SK_No")=DC2
RsClient("SK_Wname")=DC3
RsClient("SK_Jname")=DC4
RsClient("SK_Content")=DC5
RsClient("SK_SalesID")=DC9

RsClient("CU_Address")=DC10
RsClient("OP_Property")=DC16
RsClient("OP_Scale")=DC17
RsClient("OP_Trade")=DC18
RsClient("OP_Product")=DC19
RsClient("OP_Importance")=DC20
RsClient("OP_Exchang")=DC21
RsClient("OP_Fettle")=DC22
RsClient("OP_Origin")=DC23

else
RsClient.AddNew 
'--------------------------------------------------------
RsClient("SK_Di")=DC1
RsClient("SK_No")=DC2
RsClient("SK_Wname")=DC3
RsClient("SK_Jname")=DC4
RsClient("SK_Content")=DC5
RsClient("SK_SalesID")=DC9

RsClient("CU_Address")=DC10
RsClient("OP_Property")=DC16
RsClient("OP_Scale")=DC17
RsClient("OP_Trade")=DC18
RsClient("OP_Product")=DC19
RsClient("OP_Importance")=DC20
RsClient("OP_Exchang")=DC21
RsClient("OP_Fettle")=DC22
RsClient("OP_Origin")=DC23

RsClient("SK_Ftime")=Now()
RsClient("SK_UserID")=Session("UID")
RsClient("SK_Addor")=Session("UserName")
'--------------------------------------------------------
end if

RsClient("SK_Addor")=Session("Oname")
RsClient("SK_ATime")=Now()
RsClient("SK_Del")="0"
RsClient("SK_Click")="0"
RsClient("SK_Locked")="0"
RsClient.Update

set RsNewID=conn.execute("select @@IDENTITY")
GetNewID=RsNewID(0)

'Response.Write GetNewID
'Response.End()

if DC6<>"" then
set RsLinkMan=server.createobject("adodb.recordset")
SqlLinkMan="select * from SK_LinkMan"
RsLinkMan.open SqlLinkMan,conn,1,3
RsLinkMan.AddNew
RsLinkMan("SK_ClientID")=GetNewID
RsLinkMan("SK_LName")=DC6
RsLinkMan("Sex")=DC11
RsLinkMan("SK_Mobile")=DC8
RsLinkMan("SK_Tel")=DC7
RsLinkMan("SK_LDept")=DC12
RsLinkMan("SK_LJob")=DC13
RsLinkMan("SK_Fax")=DC14
RsLinkMan("SK_Email")=DC15

RsLinkMan("SK_SalesID")=DC9
RsLinkMan("SK_Addor")=Session("UserName")
RsLinkMan("SK_ATime")=Now()
RsLinkMan("SK_Del")="0"
RsLinkMan.Update
RsLinkMan.Close 
set RsLinkMan=Nothing
end if

RsClient.Close
set RsClient=Nothing
end if
i=i+1
RsXls.MoveNext
Loop
response.write "</table>"
Response.write "共更新了<font color='red'>" & i-1 & "</font>条记录" & vbCrLf
End If

RsXls.close
set ConnXls=Nothing
set objCmd=Nothing
'response.Write ""&SrcXls&""
'response.end
set objfilesys=server.createobject("scripting.filesystemobject")
if objfilesys.FILEExists(SrcXls) then
objfilesys.deleteFILE FilesPat
end if
%>
</td>
</tr>
</table>

</td>
<td width="8" background="../images/tab_15.gif"></td>
</tr>
</table></td>
</tr>
<tr>
<td class="SK_Td_Foot">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="1%" height="20"><img src="../images/tab_18.gif" width="12" height="20" /></td>
<td width="98%" class="SK_Td_Page"></td>
<td width="1%"><img src="../images/tab_20.gif" width="16" height="20" /></td>
</tr>
</table>

</td>
</tr>
</TBODY>
</table>
</body>
<%
end if
Call CloseDB()
%>
</html>