  <% 
	data_path="../../" 'ACC连接数据库路径，对SQL无效
	numid="101"
	dir="../err.asp" 
  %>
  <!--#include file="../../conn/conn.asp"-->
<!--#include file="../../inc/filesystem.asp"--> 
<!--#include file="../../inc/safe.asp"-->
   <!--#include file="../rolecheck.asp"-->
  
<html>
<head>
<title>标签导入导出管理</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="../css/style.css">
</head>
<SCRIPT language=javascript>
function unselectall()
{
    if(document.form.chkAll.checked){
	document.form.chkAll.checked = document.form.chkAll.checked&0;
    } 	
}

function CheckAll(form)
{
  for (var i=0;i<form.elements.length;i++)
    {
    var e = form.elements[i];
    if (e.Name != "chkAll")
       e.checked = form.chkAll.checked;
    }
}
</SCRIPT>
<%
dim action
Action=replace_text(request("Action"))

select case Action
	case "outuser" 
		call outuser()
	case "outuserok"
		call outuserok()
	case "inuser1"
		call inuser1()
	case "inuser2"
		call inuser2()
	case "inuserok"
		call inuserok()
end select

sub outuserok()
	dim mdbname,rs,connskin,fso
	dim skinid,i,rsout
	mdbname=trim(request("mdbname"))	
	set fso=YXFSO
    if fso.FileExists(Server.MapPath(mdbname))=False then
	databasever="2000"
	databasepath=server.mappath(mdbname)
	Createdfile databasepath,databasever '创建数据库 
	
	
	mdbname1=Trim(Request("mdbname"))
	Mbsql="Create table websen_cuslabel(id counter primary key,lname nvarchar(50),ldes nvarchar(100),lcontent ntext,lkind int,lidate smalldatetime)"
	Call Createtable(mdbname1,Mbsql)

    end if
	Set connskin = Server.CreateObject("ADODB.Connection")
	connskin.open "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(mdbname)
	set rsout=server.createobject("adodb.recordset")
	rsout.open "select * from websen_cuslabel",connskin,1,3
	
	if Trim(request("id"))="" then 
		call HOPE_err("操作错误","ID的值不能为空!","返回","javascript:history.go(-1)")
		Response.end 
	end if
		connskin.execute("Delete From websen_cuslabel")
	
	skinid=split(request("id"))
	
	for i=0 to ubound(skinid)
		set rs=conn.execute("select * from websen_cuslabel where id="&clng(skinid(i)))
		
		rsout.addnew
		rsout("lname")=rs("lname")
		rsout("ldes")=rs("ldes")
		rsout("lcontent")=rs("lcontent")
		rsout("lkind")=rs("lkind")
		rsout("lidate")=rs("lidate")
		rsout.update
	next
	rsout.close
	set rsout=nothing
	set rs=nothing
	response.Write("<script language=javascript>alert('导出成功!');history.back();</script>")
	response.end
end sub

sub inuserok()
	dim mdbname,rs,connskin
	dim skinid,i,rsin
	mdbname=trim(request("mdbname"))	
	Set connskin = Server.CreateObject("ADODB.Connection")
	connskin.open "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(mdbname)
	set rsin=server.createobject("adodb.recordset")
	if not IsObject(conn) then link_database
	rsin.open "select top 1 * from websen_cuslabel",conn,2,3
	skinid=split(request("id"))
	for i=0 to ubound(skinid)
		set rs=connskin.execute("select * from websen_cuslabel where id="&clng(skinid(i)))
		rsin.addnew
		rsin("lname")=rs("lname")
		rsin("ldes")=rs("ldes")
		rsin("lcontent")=rs("lcontent")
		rsin("lkind")=rs("lkind")
		rsin("lidate")=rs("lidate")
		rsin.update
	next
	rsin.close
	set rsin=nothing
	set rs=nothing
	response.Write("<script language=javascript>alert('导入成功!');history.back();</script>")
	response.end
end sub



'=================================创建数据库Begin=====================================================
Function Createdfile(FilePath,Ver) 
Dim Ca,dbver 
select case ver 
case "97" 
dbver = "3.51" 
case "2000" 
dbver = "4.0" 
end select 
if dbver <> "" then 
Set Ca = Server.CreateObject("ADOX.Catalog") 
call Ca.Create("Provider=Microsoft.Jet.OLEDB." & dbver & ";Data Source=" & filepath) 
end if 
End Function 
'=================================创建数据库End=====================================================
'=================================创建表Begin=====================================================
Function Createtable(mdbname,Mbsql)
Set connskin = Server.CreateObject("ADODB.Connection")
			connskin.open "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(mdbname)	
	
		connskin.execute(Mbsql)
End Function						
'=================================创建表End=====================================================

%>
<body leftmargin="2" topmargin="0" marginwidth="0" marginheight="0" class="bgcolor">
<br>
<%
sub outuser()
dim rs
set rs=conn.execute("select * from websen_cuslabel ")
%>
<table cellpadding="2" cellspacing="1" border="0" width="98%" class="tableBorder" align=center>
  <tr align="center">
    <th width="300" height=25 class="topbg"><div align="left"><strong>系统标签导出</strong></div>
  </tr>
</table>
<form name="form" method="post" action="admin_skin.asp?action=outuserok">
  <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="tableBorder">
    <tr>
      <td width="63" height="31" align="center" class="bodytitle">选中</td>
      <td width="120" class="bodytitle"> <div align="center">ID</div></td>
      <td width="288"  class="bodytitle"> <div align="center">名称</div></td>
      <td width="292" class="bodytitle"> <div align="center">备注</div></td>
    </tr>
    <% 
while not rs.eof	  
%>
    <tr class="tdbg" >
      <td width="63" align="center" class=forumRow><input name='ID' type='checkbox' onClick="unselectall()" id="ID" value='<%=cstr(rs("id"))%>'></td>
      <td width="120" class=forumRow> <div align="center"><%= rs("id") %>&nbsp;</div></td>
      <td width="288" class=forumRow> <div align="center"><%= rs("lname") %></div></td>
      <td class=forumRow> <div align="center"><%= rs("ldes") %></div></td>
    </tr>
    <%
rs.movenext
wend
%>
    <tr> 
      <td height="40" colspan="4" align="center" class="tdbg"> <div align="left"> 
          <input name="chkAll" type="checkbox" id="chkAll" onclick=CheckAll(this.form) value="checkbox">
          选中所有模版　导出数据库名：
          <input name="mdbname" type="text" id="mdbname" value="<%=HOPE_InstallDir%>Databackup/sys_lable.mdb" size="25" maxlength="50" readonly>
          <input type="submit" name="Submit" value=" 导出模版 ">
        </div></td>
    </tr>
  </table>
</form>
<%end sub

sub inuser1()
%>
<table cellpadding="2" cellspacing="1" border="0" width="98%" class="tableBorder" align=center>
  <tr align="center">
    <th width="300" height=25 class="topbg"><div align="left"><strong>系统标签导入</strong></div>
  </tr>
</table>
<form name="form" method="post" action="admin_skin.asp?action=inuser2">
  <table width="98%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="tableBorder">
     <tr> 
      <td width="763" height="40" align="center" class="tdbg"> <div align="left"> 
          　导入数据库名： 
          <input name="mdbname" type="text" id="mdbname" value="<%=HOPE_InstallDir%>Databackup/sys_lable.mdb" size="45" maxlength="50" readonly>
          <input type="submit" name="Submit" value=" 下一步 ">
        </div></td>
    </tr>
  </table>
</form>
<%end sub

sub inuser2()

dim connskin,rs,mdbname,fso
mdbname=trim(request("mdbname"))


	set fso=YXFSO
    if fso.FileExists(Server.MapPath(mdbname))=False then
    Response.Write("<script language=javascript>alert('“"&mdbname&"”不存在！');history.back();</script>")
    Response.End
    end if
Set connskin = Server.CreateObject("ADODB.Connection")
connskin.open "Provider = Microsoft.Jet.OLEDB.4.0;Data Source = " & Server.MapPath(mdbname)
set rs=connskin.execute("select * from websen_cuslabel")
%>
<table cellpadding="2" cellspacing="1" border="0" width="98%" class="tableBorder" align=center>
  <tr align="center">
    <th width="300" height=25 class="topbg"><div align="left"><strong>系统标签导入</strong></div>
  </tr>
</table>
<form name="form" method="post" action="admin_skin.asp?action=inuserok">
  <table width="98%" border="1" align="center" cellpadding="2" cellspacing="1" bgcolor="#FFFFFF" class="tableBorder" bordercolordark="#FFFFFF" bordercolorlight="#CCCCCC">
    <tr class="topbg">
      <td width="63" align="center" >选中</td>
      <td width="120"> <div align="center">ID</div></td>
      <td > <div align="center">名称</div></td>
    </tr>
    <% 
while not rs.eof	  
%>
    <tr class="tdbg" onMouseOut="this.style.backgroundColor=''" onMouseOver="this.style.backgroundColor='#BFDFFF'">
      <td width="63" align="center"><input name='ID' type='checkbox' onClick="unselectall()" id="ID" value='<%=cstr(rs("id"))%>'></td>
      <td width="120"> <div align="center"><%= rs("id") %>&nbsp;</div></td>
      <td > <div align="center"><%= rs("lname") %></div></td>
    </tr>
    <%
rs.movenext
wend
%>
    <tr> 
      <td height="40" colspan="3" align="center" class="tdbg"> <div align="left"> 
          <input name="chkAll" type="checkbox" id="chkAll" onclick=CheckAll(this.form) value="checkbox">
          选中所有模版　 
          <input type="submit" name="Submit" value=" 导入模版 ">
          <input type="hidden" name="mdbname" value="<%=mdbname%>">
        </div></td>
    </tr>
  </table>
</form>
<%end sub%>
</body>
</html>
