<%@ Register tagPrefix="bbs" tagName="AdminFooter" src="controls/admin_footer.ascx"%>
<%@ Register tagPrefix="bbs" tagName="AdminHeader" src="controls/admin_header.ascx"%>
<%@ Register tagPrefix="Dvbbs" namespace="Dvbbs.Controls" assembly="Dvbbs.Web"%>
<%@ Page Inherits="Dvbbs.bbs.UI.Admin.admin_datatranstable" %>
<bbs:adminheader id="AdminHeader1" title="帖子表间数据转换" runat="server"></bbs:adminheader>
<script language="javascript">
function checkWrap()
{
   var f=document.getElementById('wrap_num');
   if(f.value<1 || f.value.length<1)
   {
     alert('参数错误!请输入整数型 参数');
     return false;
     f.focus();
   }
}
function chkAllBox()
{
	var f = document.forms['resultform'];
	var ischecked = f.checkall.checked;
	for (var i=0; i<f.elements.length; i++)
	{
		if (f.elements[i].type.toLowerCase() == "checkbox")
		{
			f.elements[i].checked = ischecked;
		}
	}
}
</script>
<table width="100%" class="maintable" cellpadding="0" cellspacing="1" border="0" ID="Table1">
	<tr>
		<th>
			数据表间帖子转换</th>
	</tr>
	<tr>
		<td class="nf2" colspan="6">
			<div class="underline">功能说明：</div>
			<span>您可以选择下列其中之一种模式进行帖子数据在不同表之间的转换：</span><br />
			<span>1. 模式一:您可以在某个数据表中搜索帖子并将它转换到其它数据表。</span><br />
			<span>2. 模式二:您可以将某个数据表的N条记录转换到另外的数据表。</span>
		</td>
	</tr>
</table>
<br />
<!--搜索相关帖子--模式一-->
<table width="100%" class="maintable" cellpadding="0" cellspacing="1" border="0" ID="Table2">
	<form name="searchform" method="post" action="?search">
		<tr>
			<td class='title' colspan="2">模式一：搜索要转移的帖子 <input type="hidden" value="search" name="action" />
			</td>
		</tr>
		<tr>
			<td height="30" colspan="2"><b>注意：</b>这里仅搜索所在表的主题和发表用户数据，搜索后对搜索结果进行操作</td>
		</tr>
		<tr>
			<td class="left" width="20%">搜索条件</td>
			<td class="right">
				输入关键字(词): <input type="text" name="keyword" onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)"
					onMouseOver="IEvent('mouseover',this)" onMouseOut="IEvent('mouseout',this)" id="keyword" size="30">
				<br />
				请选择数据表:
				<select name="SearchTableList">
					<%
	   System.Data.DataTable dt=RepeaterTableList();
	   int rowscount=dt.Rows.Count;
	   for(int i=0;i<rowscount;i++)
	   {
	    if(Dvbbs.bbs.Kernel.Property.CurrentPostTable==dt.Rows[i]["tablename"].ToString())
	     {
	  %>
					<option value="<%=dt.Rows[i]["tablename"].ToString()%>" selected><%=dt.Rows[i]["tablename"].ToString()%></option>
					<%}else{%>
					<option value="<%=dt.Rows[i]["tablename"].ToString()%>"><%=dt.Rows[i]["tablename"].ToString()%></option>
					<%}}%>
				</select>
				<br />
				选择搜索条件: <input type="radio" class="radio" id="searchwhat1" name="searchwhat" value="username" checked><label for="searchwhat1">作 者</label>&nbsp;&nbsp;
				<input type="radio" class="radio" id="searchwhat2" name="searchwhat" value="topic"><label for="searchwhat2">主 题</label>
				<br />
			</td>
		</tr>
		<tr>
			<td class="bottom" colspan="2" align="center">
				<input type="submit" onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)" onMouseOver="IEvent('mouseover',this)"
					onMouseOut="IEvent('mouseout',this)" class="button" name="Submit" value="&nbsp;&nbsp;搜&nbsp;&nbsp;索&nbsp;&nbsp;">
			</td>
		</tr>
	</form>
</table>
<br />
<!--end 搜索相关帖子 模式一-->
<!--从一个表中转N条数据表另一条表中 --模式二--->
<table width="100%" class="maintable" cellpadding="0" cellspacing="1" border="0" ID="Table3">
	<form name="dataswapform" method="post" action="?action=dataswap">
		<tr>
			<td colspan="2" class='title'>模式二：在不同表转移数据</td>
		</tr>
		<tr>
			<td colspan="2" class="left">
				将
				<select name="source_table">
					<%
	   System.Data.DataTable sdt=RepeaterTableList();
	   int scount=sdt.Rows.Count;
	   for(int i=0;i<scount;i++)
	   {
	    if(Dvbbs.bbs.Kernel.Property.CurrentPostTable==sdt.Rows[i]["tablename"].ToString())
	     {
	  %>
					<option value="<%=sdt.Rows[i]["tablename"].ToString()%>" selected><%=sdt.Rows[i]["tablename"].ToString()%></option>
					<%}else{%>
					<option value="<%=sdt.Rows[i]["tablename"].ToString()%>"><%=sdt.Rows[i]["tablename"].ToString()%></option>
					<%}}%>
				</select>表中的 <input type="radio" class="radio" name="recordtopend" value="pre" checked>前
				<input type="radio" class="radio" name="recordtopend" value="end"> 后 <input type="text" name="wrap_num" onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)"
					onMouseOver="IEvent('mouseover',this)" onMouseOut="IEvent('mouseout',this)" id="wrap_num" size="10" value="100" onkeyup="this.value=this.value.replace(/[^\d,]+/g,'')">条&nbsp;&nbsp;记录转移到
				<select name="target_table">
					<%
	   System.Data.DataTable tdt=RepeaterTableList();
	   int tcount=tdt.Rows.Count;
	   for(int i=0;i<tcount;i++)
	   {
	    if(Dvbbs.bbs.Kernel.Property.CurrentPostTable==tdt.Rows[i]["tablename"].ToString())
	     {
	  %>
					<option value="<%=tdt.Rows[i]["tablename"].ToString()%>" selected><%=tdt.Rows[i]["tablename"].ToString()%></option>
					<%}else{%>
					<option value="<%=tdt.Rows[i]["tablename"].ToString()%>"><%=tdt.Rows[i]["tablename"].ToString()%></option>
					<%}}%>
				</select>表中
			</td>
		</tr>
		<tr>
			<td align="center" class="bottom">
				<input type="submit" class="button" onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)"
					onMouseOver="IEvent('mouseover',this)" onMouseOut="IEvent('mouseout',this)" name="Submit"
					onclick="return checkWrap()" value="&nbsp;&nbsp;转&nbsp;&nbsp;移&nbsp;&nbsp;">
			</td>
		</tr>
		<tr>
			<td height="1" colspan="2"><b>注意：</b><br />
			<span>最前N条记录指数据库中最早发表的帖子（如果平均每个帖子有5个回复，那么100个主题在这里的更新量将是500条记录），这通常要花很长的时间，更新的速度取决于您的服务器性能以及更新数据的多少。执行本步骤将消耗大量的服务器资源，建议您在访问人数较少的时候或者本地进行更新操作。</span></td>
		</tr>
	</form>
</table>
<br />
<!--end 表间转移  模式二-->
<!--搜索帖子的结果-->
<%
if(action=="search")
{
 System.Data.DataTable searchDT=GetSearchData();
%>
<table width="100%" class="maintable" cellpadding="0" cellspacing="1" border="0" ID="Table4">
	<form name="resultform" method="post" action="?action=transdata&InitalTable=<%=Post("SearchTableList")==""?Get("SearchTableList"):Post("SearchTableList")%>">
		<tr>
			<td colspan="6" class='title'>■ 搜索&nbsp;<%=Post("SearchTableList")==""?Get("SearchTableList"):Post("SearchTableList")%>&nbsp;的结果</td>
		</tr>
		<tr>
			<td height="25" width="5%" align="center"></td>
			<td height="25" width="5%" align="center">状 态</td>
			<td height="25" width="50%" align="center">主 题</td>
			<td height="25" width="15%" align="center">作 者</td>
			<td height="25" width="15%" align="center">时 间</td>
		</tr>
		<%
    for(int i=0;i<searchDT.Rows.Count;i++)
    {
  %>
		<tr>
			<td align="center">
				<input type="checkbox" class="checkbox" name="replyid" value="<%=searchDT.Rows[i]["ReplyID"].ToString()%>">
			</td>
			<td align="center">
				<%=searchDT.Rows[i]["locktopic"].ToString()=="0"?"锁定":"正常"%>
			</td>
			<td>&nbsp;&nbsp;<b><%=searchDT.Rows[i]["title"]%></b></td>
			<td align="center"><a href="admin_user_alter.aspx?name=<%=Server.UrlEncode(searchDT.Rows[i]["username"].ToString())%>"><%=searchDT.Rows[i]["username"]%></a></td>
			<td align="center"><%=searchDT.Rows[i]["posttime"].ToString()%></td>
		</tr>
		<%}%>
		<tr>
			<td colspan="5" class="title"><Dvbbs:Pager id="pager" per="30" runat="server" /></td>
		</tr>
		<tr class="forumrow1">
			<td colspan="2">&nbsp;</td>
			<td colspan="4" style="text-align:center;">全部选择<input type="checkbox" class="checkbox" name="checkall" id="checkall" onclick="chkAllBox()"
					value="Y"> &nbsp;&nbsp;请选择目标数据表:
				<select name="TargetTable">
					<%
	   System.Data.DataTable targetdt=RepeaterTableList();
	   int tdtcount=targetdt.Rows.Count;
	   for(int i=0;i<tdtcount;i++)
	   {
	  %>
					<option value="<%=targetdt.Rows[i]["tablename"]%>" <%=i==0?"selected":""%>><%=targetdt.Rows[i]["tablename"]%></option>
					<%}%>
				</select>
				<input type="submit" onFocus="IEvent('focus',this);" onBlur="IEvent('blur',this)" onMouseOver="IEvent('mouseover',this)"
					onMouseOut="IEvent('mouseout',this)" class="button" name="Submit" value="&nbsp;&nbsp;转&nbsp;&nbsp;换&nbsp;&nbsp;">
			</td>
		</tr>
	</form>
</table>
<%
}
%>
<!--end搜索帖子的结果-->
<bbs:AdminFooter runat="server" id="AdminFooter1" />
