有事点这里!

当前位置: 首页 >> IT技术 >> 网络编程 >> ASP网站数据导入功能

ASP网站数据导入功能

[ 来自:水木忍blog 作者:水木忍 阅读:0 时间:2008-3-3 20:09:48 ]

<!--#include file="conn.asp"-->
<!--#include file="Page.asp" -->
<%
p_ID = Request("ID")
Action = Request("Action")
if Action = "Del" then
 DelID = Request("ID")
 if DelID <> "" then
  if DelID = "record" then
   Conn.Execute("Delete from D_News where type=1")
  else
   DelIDArray = Split(DelID,"***")
   for i = LBound(DelIDArray) to UBound(DelIDArray)
    if DelIDArray(i) <> "" then
     Conn.Execute("Delete from D_News where ID=" & DelIDArray(i))
    end if
   Next
  end if
 end if 
end if
if Action = "instr" then
 if NewsToSystem(p_ID) then 
  p_Delete_ID = Replace(p_ID,"***",",")
  if p_ID = "all" then
   Conn.Execute("Update D_News Set type=1 where 1=1")
  else
   Conn.Execute("Update D_News Set type=1 where ID in (" & p_Delete_ID & ")")
  end if
Response.Write("<script language=javascript>alert('导入成功!');window.location.href='Untitled-1.asp';</script>")
Response.End
 else
Response.Write("<script language=javascript>alert('导入失败!');window.location.href='Untitled-1.asp';</script>")
Response.End
 end if
end if
Function NewsToSystem(D_ID)
 D_ID = Replace(D_ID,"***",",")
 Set D_RS = Server.CreateObject ("ADODB.RecordSet")
 if D_ID = "all" then
  D_Sql = "Select * from D_News where 1=1 Order By ID Desc"
 else
  D_Sql = "Select * from D_News where ID in (" & D_ID & ") Order By ID Desc"
 end if
 D_RS.Open D_Sql,Conn,1,1
 While Not D_RS.Eof 
 StrSql="INSERT INTO brd_news([title],[key],[ty],[author],[source],[website],[html],[content],[date],[img]) VALUES ("
 StrSql=StrSql & "'"&D_RS("Title")&"'"
 StrSql=StrSql & ",'"&D_RS("key")&"'"
 StrSql=StrSql & ",'"&D_RS("ty")&"'"
 StrSql=StrSql & ",'QQCAT整理'"
 StrSql=StrSql & ",'QQCAT'"
 StrSql=StrSql & ",'http://www.qqcat.com/'"
 StrSql=StrSql & ",true"
 StrSql=StrSql & ",'"&D_RS("content")&"'"
 StrSql=StrSql & ",now()"
 StrSql=StrSql & ",'"&D_RS("img")&"'"
 StrSql=StrSql & ")"
 Conn.Execute(StrSql)
 D_RS.movenext
 Wend
 D_RS.Close
 Set D_RS = Nothing
 NewsToSystem = True
end Function
%>
<html><title>管理中心</title><head><meta http-equiv=Content-Type content="text/html; charset=gb2312"><link href="inc/admin.css" type=text/css rel=stylesheet>
<table border='1'>
<tr>
  <td colspan='6'>数据导入管理</td>
</tr>
<tr align='center'>
<td width="64" nowrap>选择</td>
<td width="64" nowrap>编号</td>
<td width="620" nowrap>标题</td>
<td width="56" nowrap>类别</td>
<td width="56" nowrap>状态</td>
<td width="69" nowrap>操作</td>
</tr>
<%
set rs=server.CreateObject("ADODB.RecordSet")
sql="select * from D_News order by id"
rs.open sql,conn,1,1
RowCount =20 '每页显示的记录条数
'incl="&kindid1="&kindid1&"&kindid2="&kindid2 '翻页时的其它参数,如果没有这些参数填incl=false
incl=false
Call TurnPage(Rs,RowCount,Incl) '调用分页
do while not rs.eof and rowcount>0
%>
<tr>
  <td align='center'><input type="checkbox" CName="<%=Rs("title")%>" value="<%=Rs("ID")%>" name="NewsID"></td>
  <td align='center'><%=Rs("ID")%></td>
  <td align='center'><%=Rs("title")%></td>
  <td align='center'><%=Rs("ty")%></td>
  <td align='center'><%if Rs("type")=1 then %>已入库<%else%>未入库<%end if%></td>
  <td align='center'><span style="cursor:hand;" onClick="if (confirm('确定要删除吗?')) location='?Action=Del&ID=<% = Rs("ID") %>';">删除</span></td>
<%
rs.movenext
rowcount=rowcount-1
loop
rs.close
set rs=nothing
conn.close
set conn=nothing
%>
</tr>
<tr>
<td colspan='2' align="center"><input type="checkbox" name="checkAll" value="" onClick="selectAll(document.all.NewsID,this.checked)">
              全选</td>
<td colspan='4' align="right">
     <input onClick="DeleteNews('record');" type="button" name="Submit" value=" 删除全部已入库新闻 ">
                  <input onClick="MoveNews('all');" type="button" name="Submit" value=" 全部入库 ">
                  <input onClick="MoveNews('');" type="button" name="Submit" value=" 入 库 "><input onClick="DeleteNews('');" type="button" name="Submit" value=" 删 除 "></td>
</tr>
</table>
<script language="JavaScript">
function MoveNews(f_All_ID)
{
 var ID_Str='',CName_Str='';
 if (f_All_ID=='')
 {
  if (document.all.NewsID.length)
  {
   for (var i=0;i<document.all.NewsID.length;i++)
   { 
    if(document.all.NewsID(i).checked)
    {
     if (ID_Str!=''){ID_Str=ID_Str+'***'+document.all.NewsID(i).value;}else{ID_Str=document.all.NewsID(i).value;}
     if (CName_Str!=''){CName_Str=CName_Str+'***'+document.all.NewsID(i).CName;}else{CName_Str=document.all.NewsID(i).CName;}
    }
   }
  }
  else{if(document.all.NewsID.checked){ID_Str=document.all.NewsID.value;CName_Str=document.all.NewsID.CName;}}
 }
 else {ID_Str='all';CName_Str='全部新闻';}
 if (ID_Str!='')
 {
  if(confirm('确定要入库吗?'))location='?Action=instr&ID='+ID_Str+'&CName='+CName_Str;
 }
 else alert('请选择要入库的新闻');
}

function DeleteNews(f_ID_Type)
{
 var ID_Str='';
 if (f_ID_Type=='')
 {
  if (document.all.NewsID.length)
  {
   for (var i=0;i<document.all.NewsID.length;i++)
   { 
    if(document.all.NewsID(i).checked)
    {
     if (ID_Str!=''){ID_Str=ID_Str+'***'+document.all.NewsID(i).value;}else{ID_Str=document.all.NewsID(i).value;}
    }
   }
  }
  else{if(document.all.NewsID.checked)ID_Str=document.all.NewsID.value;}
 }
 else
 {
  ID_Str=f_ID_Type
 }
 if (ID_Str!='')
 {
  if(confirm('确定要删除吗?')) location='?Action=Del&ID='+ID_Str;
 }
 else alert('请选择要删除的新闻');
}

function selectAll(f_OBJ,f_Flag)
{
 if (f_OBJ.length)
 {
  for (var i=0;i<f_OBJ.length;i++)
  { 
   f_OBJ(i).checked=f_Flag;
  }
 }
 else{f_OBJ.checked=f_Flag;}
}
</script>

奥运您知道

动漫情报

影视广场

IT技术

相关文章

QQCAT(www.qqcat.com),资源信息,免费观看。本站所有信息均来自网上,如损害到您的利益,请及时联系我们!
QQCAT版权所有©2007