www.gusucode.com > 云枫企业网站源代码 1 > 云枫企业网站源代码 1.0/代码打包/fin/member_dr.asp

    <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="conn.asp"-->
<!--#include file="checkuser.asp"-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title><%=site_title%></title>
<META NAME="KEYWORDS" CONTENT="<%=site_KEYWORDS%>">
<META NAME="TITLE" CONTENT="<%=site_TITLE%>">
<META NAME="DESCRIPTION" CONTENT="<%=site_DESCRIPTION%>">
<link rel="stylesheet" href="Css/exceldr.css" type="text/css" />
</head>
<body>
<%
select case request("action")
	case "exceldr"
	call exceldr()
	case "exceldrsave"
	call exceldrsave()
	case "JaExcel"
	call JaExcel()
	case "JaExceldo"
	call JaExceldo()
	case "JaAccSave"
	call JaAccSave()
	case "exceldc"
	call exceldc()
end select
%>
<%
sub exceldr()
%>
<script language="JavaScript" type="text/JavaScript">
function chk()
{
  if (document.myform.Propicb.value=="")
  {
    alert("Excel文件不能为空!");
    document.myform.Propicb.focus();
    return false;
  }
}
</script>
<form name="myform" method="post" action="?action=JaExcel" onSubmit="return chk(this)">
<table width="585" border="0" cellspacing="0" cellpadding="0" class="table">
  <tr>
    <th width="115">数据导入</th>
    <th width="208">&nbsp;</th>
    <th width="261">&nbsp;</th>
  </tr>
  <tr>
    <td>上传excel:</td>
    <td><input name="Propicb" type="text" id="Propicb" size="40">
      <br><IFRAME src="Upimageb.asp" name=head width=370 marginWidth=0 height=21 marginHeight=0 scrolling=no frameBorder=0 class="red" framespacing=0></IFRAME></td>
    <td>*必填项目,文件格式必须为*.xls<br>(标准数据导入样本. <a href="excel/excel.xls" target="_blank">点击下载</a>)</td>
  </tr>
  <tr>
    <td>业务类型:</td>
    <td><select name="order_class">
              <%
			  wheres=""
			  sql="select * from tsm_news1 where 1=1 "&wheres&" order by paixu desc"
			  rs.open sql,conn,1,1
			  do while not rs.eof
			  %>
			  <option value="<%=rs("title")%>"><%=rs("title")%></option>
			  <%
			  rs.movenext
			  loop
			  rs.close
			  %>
                        </select></td>
    <td>*必填项目,文件格式必须为*.xls<br>(标准数据导入样本. <a href="excel/excel.xls" target="_blank">点击下载</a>)</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>
	<div id="button"><input name="submit"  type="submit"value="下一步"/></div>
</td>
    <td>&nbsp;</td>
  </tr>
</table>
</form>
<%
end sub
%>
<%
sub JaExcel()
session("order_class")=request("order_class")
%>
<style>
td,input,select,textarea,body{font-size:9pt}
a{color:blue}
a:hover{color:green}
</style>
<script language="JavaScript" type="text/JavaScript">
function chk()
{
  if (document.form1.ExName.value=="")
  {
    alert("Excel文件名称不能为空!");
    document.form1.ExName.focus();
    return false;
  }
    if (document.form1.ExTname.value=="")
  {
    alert("Excel数据表文件名称不能为空!");
    document.form1.ExTname.focus();
    return false;
  }
}
</script>
<table width="600" align="center" cellpadding="5" cellspacing="1" bgcolor="#006699">
<tr bgcolor="#6699CC" style="color:white"> 
<td>
<b>导入数据注意事项</b><br>
1:请确保你清楚Excel文件内容字段与导入数据库的字段相同<p>
2:请确保你清楚Excel文件的表名正确 如 Sheet1<p>
3:请确保服务器上有该Excel文件存在于Excel文件夹里,如没有,请上传并记下文件名称<p>
4:请确保电话号码全部为文本,或全部为数字,否则导入失败.<p>
5:如有不明白请参考Excel文件夹里的[Excel.xls],如填写:[Excel地址:Excel.xls] [Excel导入数据表名:Sheet1]<p>
6:请保留一、二行,从第三行开始粘贴数据<p>
7:标准数据导入样本. <a href="excel/excel.xls" target="_blank">点击下载</a> 
</td>
</tr>
</table>
<%
Propicb=request("Propicb")
%>
<form method=post action="?action=JaExceldo" name=form1 onSubmit="return chk(this)">
  <table width="600" align=center cellpadding=5 cellspacing=1 bgcolor=#006699>
    <tr bgcolor=#6699CC style=color:white align=center> 
      <td width="183">Excel地址(如:Excel.xls)</td>
      <td width="217">Excel导入数据表名 (如:Sheet1)</td>
      <td width="64"></td>
    </tr>
    <tr bgcolor=white> 
      <td><input name="ExName" value="<%=SenFe_Cut(Propicb, "exceldr/", ".xls", 4)%>" size="30"></td>
      <td><input name="ExTname" value="Sheet1" size="30"></td> 
      <td><input type="submit" value="导入数据"> </td>
      </tr>
  </table>
</form>  
<%
end sub
%>
<%
sub JaExceldo()
%>
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<style>
td,input,select,textarea,body{font-size:9pt}
a{color:blue}
a:hover{color:green}
</style>
<%
Dim conne

Dim StrConne

Dim Rs
Dim Sql
Dim i
Dim ExName
ExName = Request.Form("ExName")
ExTName = Request.Form("ExTName")
Set conne =Server.CreateObject("ADODB.Connection")
StrConne="Driver={Microsoft Excel Driver (*.xls)};DBQ="& Server.MapPath("exceldr/"&ExName)
conne.Open StrConne
Set rs = Server.CreateObject("ADODB.Recordset") 
Sql="select * from ["&ExTName&"$]"
rs.Open Sql,conne,1,1
%>
<form method=post action="?action=JaAccSave" name=form1 onSubmit="return chk(this)">
<table width="1500" border="0" align="center" cellspacing="1" bgcolor="#CCCCCC">
<tr align="center" height="20" bgcolor="#6699CC" style="color:white"> 
      <td colspan="20">导入数据列表(请确保字段没有错误)</td>
    </tr>
  <tr>
<td align="center">
<input name=Count type=hidden value="<%=rs.Fields.Count%>">
<%
for i=0 to rs.Fields.Count-1 
%>
<input name=ExFName<%=i%> value="<%=Rs(i).Name%>" size="20">
<%
Next
Response.Write "</td></tr></table><table width=1500 border=0 align=center cellspacing=1 bgcolor=#CCCCCC>"
Response.Write "<tr bgcolor=white><td align=center>"
Dim a
a=0
do while not rs.eof
for i=0 to rs.Fields.Count-1
if i mod rs.Fields.Count = 0 then 
Response.Write "<br>"
End if
%>
<input name=ExCName<%=a%> value="<%=Rs(i)%>" size="20">

<%
a = a +1
next
rs.MoveNext
Loop
Response.Write "</td></tr><tr><td align=center><input name='A' type=hidden value="&a&"><input type=submit value=导入数据></td></tr></table>"
Response.Write "</form>"
rs.close
set rs=nothing
conne.close
set conne=nothing
Response.End
%>
<%
end sub
%>
<%
sub JaAccSave()
%>
<%
Dim a
Dim FCount
Dim Fname
Dim Cname
Dim i
Dim ccc
Dim b
a = Cint(Request.Form("A"))
Fcount = Cint(Trim(Request.Form("Count")))
for i=0 to Fcount-1
if i=Fcount-1 Then
Fname = Fname & Request.Form("ExFName"&i&"")
else
Fname = Fname & Request.Form("ExFName"&i&"") & ","
end if
next
for i=0 to a
Cname = Cname & Request.Form("ExCName"&i&"") & "|" 
next
Cname = split(Cname,"|")

for i=0 to a
if i>0 and i mod Fcount = 0  and i<a then
Response.Write "<br>"
for b=0 to Fcount-1
if b<> Fcount-1 Then
ccc = ccc & "'" & cname(i+b) & "'," 
Else
ccc = ccc & "'" & cname(i+b) & "'"
End if
next
Sql ="Insert into tsm_order("&Fname&")values("&ccc&")"
'Response.Write Sql
ccc =""
Conn.ExeCute(Sql)
set rsu=server.CreateObject("adodb.recordset")
usql="select * from tsm_order order by id desc"
rsu.open usql,conn,1,3
rsu("username")=session("username")
rsu("order_state")=1
rsu("order_time")=now()
rsu("order_class")=session("order_class")

thelastid=rsu("id")
thelastid1=rsu("id")+1234
if len(thelastid1)=4 then
thelastid1="ML"&"00"&thelastid1
elseif len(thelastid1)=5 then
thelastid1="ML"&"0"&thelastid1
elseif len(thelastid1)=6 then
thelastid1="ML"&thelastid1
end if

rsu("order_no")=thelastid1
session("order_no")=thelastid1
rsu.update
rsu.close
set rsu=nothing
Response.Write "<br>"
End If 
next 

Response.write "记录导入成功,本页将20秒后关闭。单号:"&session("order_no")&" 请牢记!"
%>
<script LANGUAGE="JavaScript">
setTimeout('window.close();', 20000);  
</script>
<%
end sub
%>
</body>
</html>