<%@Page Language="C#" Inherits="IWMS.Admin.GatherDbRuleAdd" EnableViewState="true" MasterPageFile="admin.master"%>
<asp:Content ContentPlaceHolderId="cphHead" runat="server">
	<script type="text/javascript">
	<!--
	function Export(){
		var id = parseInt("<%=Request.QueryString["id"]%>");
		var ifm = document.getElementById("ifm_export");
		if (id>0){
			ifm.src = "admin_export.aspx?id="+id+"&w=gdbrule";
		}
		return false;
	}
	-->
	</script>

</asp:Content>

<asp:Content ContentPlaceHolderId="cphMain" runat="server">

	<form id="MyForm" runat="server">
		<asp:ValidationSummary 
			 DisplayMode="BulletList" 
			 EnableClientScript="true"
			 ShowSummary="false"
			 ShowMessageBox="true"                        
			 HeaderText="请正确填写以下内容"
			 runat="server"/>
	
	<div class="mframe">
	<div class="tl"></div>
	<div class="rt"></div>
	<div class="tm">
		<span class="tt"><asp:Literal id="titleAct" runat="server"/>数据库采集规则</span>
	</div>
	<div class="wrapper">
	<div class="ml"></div>
	<div class="mr"></div>
	<div class="mm">
		<asp:Label id="myLabel" class="msgBar" EnableViewState="false" runat="server"/>
		<input type="hidden" id="hdStep" runat="server"/>
		 <table cellpadding="3" width="95%" align="center" style="table-layout:fixed;">
		 <asp:PlaceHolder id="step1" runat="server">
		 	<tr><th width="160">
		 		规则名：
		 	</th><td>
				<asp:TextBox Columns="20" MaxLength="100" id="name" runat="server"/>
				<asp:RequiredFieldValidator
					ControlToValidate="name"
					ErrorMessage="采集名必须填写"
					Display="None"
					runat="server"/>
			</td></tr>
			<tr><th>
		 		数据库类型：
		 	</th><td>
		 		<asp:RadioButtonList id="dbType" RepeatLayout="flow" runat="server">
		 			<asp:ListItem value="access" Selected="true">Access</asp:ListItem>
		 			<asp:ListItem value="sql">Sql Server</asp:ListItem>
		 		</asp:RadioButtonList>
	
		 	</td></tr>
			<tr><td height="30" align="center" colspan="2">
				<asp:Button text="下一步" onclick="Next_OnClick" runat="server"/> &nbsp;
			</td></tr>
		 </asp:PlaceHolder>
		 
		 <asp:PlaceHolder id="step2_1" Visible="false" runat="server">
		 	<tr><th width="160">
		 		Access数据库路径：
		 	</th><td>
		 		<asp:TextBox id="mdbPath" size="30" MaxLength="200" runat="server"/>
				<asp:RequiredFieldValidator
					ControlToValidate="mdbPath"
					ErrorMessage="数据库路径必须填写"
					Display="None"
					runat="server"/>
		 	</td></tr>
			<tr><td height="30" align="center" colspan="2">
				<asp:Button text="上一步" onclick="Prev_OnClick" CausesValidation="false" runat="server"/> &nbsp;
				<asp:Button text="下一步" onclick="Next_OnClick" runat="server"/> &nbsp;
			</td></tr>
		 </asp:PlaceHolder>
		 
		 <asp:PlaceHolder id="step2_2" Visible="false" runat="server">
		 	<tr><th width="160">
		 		sql服务器ip：
		 	</th><td>
		 		<asp:TextBox id="sqlIp" size="20" MaxLength="50" runat="server"/>
				<asp:RequiredFieldValidator
					ControlToValidate="sqlIp"
					ErrorMessage="sql服务器ip必须填写"
					Display="None"
					runat="server"/>
		 	</td></tr>
		 	<tr><th>
		 		sql数据库名：
		 	</th><td>
		 		<asp:TextBox id="sqlDb" size="20" MaxLength="50" runat="server"/>
				<asp:RequiredFieldValidator
					ControlToValidate="sqlIp"
					ErrorMessage="sql数据库名必须填写"
					Display="None"
					runat="server"/>
		 	</td></tr>
		 	<tr><th>
		 		用户名：
		 	</th><td>
		 		<asp:TextBox id="sqlUname" size="20" MaxLength="50" runat="server"/>
				<asp:RequiredFieldValidator
					ControlToValidate="sqlIp"
					ErrorMessage="sql用户名必须填写"
					Display="None"
					runat="server"/>
		 	</td></tr>
		 	<tr><th>
		 		密码：
		 	</th><td>
		 		<asp:TextBox id="sqlUpass" size="20" MaxLength="50" runat="server"/>
				<asp:RequiredFieldValidator
					ControlToValidate="sqlIp"
					ErrorMessage="sql密码必须填写"
					Display="None"
					runat="server"/>
		 	</td></tr>
			<tr><td height="30" align="center" colspan="2">
				<asp:Button text="上一步" onclick="Prev_OnClick" CausesValidation="false" runat="server"/> &nbsp;
				<asp:Button text="下一步" onclick="Next_OnClick" runat="server"/> &nbsp;
			</td></tr>
		 </asp:PlaceHolder>
		 
		 <asp:PlaceHolder id="step3" Visible="false" runat="server">
		 	<tr><th width="160">
		 		选择新闻所在表：
		 	</th><td>
		 		<asp:DropDownList id="tableName" runat="server"/>
				<asp:RequiredFieldValidator
					ControlToValidate="tableName"
					ErrorMessage="新闻所在表必须选择"
					Display="None"
					runat="server"/>
		 	</td></tr>
			<tr><td height="30" align="center" colspan="2">
				<asp:Button text="上一步" onclick="Prev_OnClick" CausesValidation="false" runat="server"/> &nbsp;
				<asp:Button text="下一步" onclick="Next_OnClick" runat="server"/> &nbsp;
			</td></tr>
		 </asp:PlaceHolder>
		 
		 <asp:PlaceHolder id="step4" Visible="false" runat="server">
		 	<tr><th width="160">
		 		新闻标题字段：
		 	</th><td>
		 		<asp:TextBox id="titleColumn" size="15" runat="server"/>
				<asp:RequiredFieldValidator
					ControlToValidate="titleColumn"
					ErrorMessage="标题字段必须填写"
					Display="None"
					runat="server"/>
				 <select id="selTitle" onchange="SelChange(this,'<%=titleColumn.ClientID%>');"><option value="">选择</option></select>
				 *
		 	</td></tr>
		 	<tr><th>
		 		新闻内容字段：
		 	</th><td>
		 		<asp:TextBox id="contentColumn" size="15" runat="server"/>
				<asp:RequiredFieldValidator
					ControlToValidate="contentColumn"
					ErrorMessage="内容字段必须填写"
					Display="None"
					runat="server"/>
				 <select id="selContent" onchange="SelChange(this,'<%=contentColumn.ClientID%>');"><option value="">选择</option></select>
				 *
		 	</td></tr>
		 	<tr><th>
		 		新闻日期字段：
		 	</th><td>
		 		<asp:TextBox id="dateColumn" size="15" runat="server"/>
				<asp:RequiredFieldValidator
					ControlToValidate="dateColumn"
					ErrorMessage="日期字段必须填写"
					Display="None"
					runat="server"/>
				 <select id="selDate" onchange="SelChange(this,'<%=dateColumn.ClientID%>');"><option value="">选择</option></select>
				 *
		 	</td></tr>
		 	<tr><th>
		 		新闻作者字段：
		 	</th><td>
		 		<asp:TextBox id="authorColumn" size="15" runat="server"/>
				 <select id="selAuthor" onchange="SelChange(this,'<%=authorColumn.ClientID%>');"><option value="">选择</option></select>
		 	</td></tr>
		 	<tr><th>
		 		新闻来源字段：
		 	</th><td>
		 		<asp:TextBox id="sourceColumn" size="15" runat="server"/>
				 <select id="selSource" onchange="SelChange(this,'<%=sourceColumn.ClientID%>');"><option value="">选择</option></select>
		 	</td></tr>
		 	<tr><th>
		 		新闻阅读数字段：
		 	</th><td>
		 		<asp:TextBox id="hitColumn" size="15" runat="server"/>
				 <select id="selHit" onchange="SelChange(this,'<%=hitColumn.ClientID%>');"><option value="">选择</option></select>
		 	</td></tr>
		 	<tr><th>
		 		新闻排序字段：
		 	</th><td>
		 		<asp:TextBox id="orderColumn" size="15" runat="server"/>
				<asp:RequiredFieldValidator
					ControlToValidate="orderColumn"
					ErrorMessage="排序字段必须填写"
					Display="None"
					runat="server"/>
				 <select id="selOrder" onchange="SelChange(this,'<%=orderColumn.ClientID%>');"><option value="">选择</option></select>
				 <asp:DropDownList id="orderAsc" runat="server">
				 	<asp:ListItem value="1">正序</asp:ListItem>
				 	<asp:ListItem value="0">倒序</asp:ListItem>
				 </asp:DropDownList><br/>
		 		<span class="explain">排序在前的先添加</span>
		 	</td></tr>
		 	<tr><th>
		 		采集新闻数：
		 	</th><td>
		 		<asp:TextBox id="gatherNum" value="0" size="7" MaxLength="7" runat="server"/>
				<asp:RequiredFieldValidator
					ControlToValidate="gatherNum"
					ErrorMessage="采集新闻数必须填写"
					Display="None"
					runat="server"/>
				<asp:RegularExpressionValidator
					runat="server"
					ControlToValidate="gatherNum"
					ValidationExpression="[1-9]\d*"
					ErrorMessage="采集新闻数只能为正整数"
					Display="None" />
		 	</td></tr>
		 	<tr><th>
		 		不经过审核：
		 	</th><td>
		 		<asp:RadioButtonList id="passed" RepeatLayout="flow" RepeatDirection="Horizontal" runat="server">
		 			<asp:ListItem value="1" Selected="true">是</asp:ListItem>
		 			<asp:ListItem value="0">否</asp:ListItem>
		 		</asp:RadioButtonList>
		 	</td></tr>
		 	<tr><th>
		 		内容经HtmlEncode过：
		 	</th><td>
		 		<asp:RadioButtonList id="htmlDecode" RepeatLayout="flow" RepeatDirection="Horizontal" runat="server">
		 			<asp:ListItem value="1">是</asp:ListItem>
		 			<asp:ListItem value="0" Selected="true">否</asp:ListItem>
		 		</asp:RadioButtonList>
		 	</td></tr>
		 	<tr><th>
		 		新闻分页标签：
		 	</th><td>
		 		<asp:TextBox id="pageTag" size="20" MaxLength="100" runat="server"/><br/>
		 		<span class="explain">新闻内容中用于分页的标签</span>
		 	</td></tr>
		 	<tr><th valign="top">
		 		sql过滤条件：<br/>
		 		<span class="explain">sql语句where后内容，不了解sql请勿填写</span>
		 	</th><td>
		 		<asp:TextBox TextMode="MultiLine" id="filter" Columns="40" Rows="4" runat="server"/>
		 	</td></tr>
			<tr><td height="30" align="center" colspan="2">
				<asp:Button text="上一步" onclick="Prev_OnClick" CausesValidation="false" runat="server"/> &nbsp;
				<asp:Button id="Submit" text="添 加" onclick="Submit_OnClick" runat="server"/> &nbsp;
				<script type="text/javascript">
					var colArr = new Array();
					<asp:Literal id="ltCols" runat="server"/>
					<!--
					function BindSel(){
						var oArr = new Array("selTitle","selContent","selDate","selAuthor","selSource","selHit","selOrder");
						var typeArr = new Array("String","String","DateTime","String","String","Int32","Int32");
						for(var i=0; i<oArr.length; i++){
							var o = document.getElementById(oArr[i]);
							for (var j=0; j<colArr.length; j++){
								if (typeArr[i].length>0 && typeArr[i]!=colArr[j][1]){
									continue;
								}
								var oOpt = document.createElement("OPTION");
								o.options.add(oOpt);
								oOpt.innerText = colArr[j][0];
								oOpt.value = colArr[j][0];
							}
						}
					}
					
					function SelChange(oSel, tbId){
						var o_tb = document.getElementById(tbId);
						o_tb.value = oSel.value;
					}
					
					BindSel();
					-->
				</script>
			</td></tr>
		 </asp:PlaceHolder>
	
		<tr><td height="30" align="center" colspan="2">
		</td></tr>
		<tr><td height="30" colspan="2">
			导入采集规则 <input type="file" id="upRule" size="15" runat="server"/>
			<asp:Button id="import" text="导入" onclick="import_Onclick" CausesValidation="false" runat="server"/>
			&nbsp; &nbsp; <asp:Button id="export" text="导出规则" CausesValidation="false" runat="server"/>
		</td></tr>
		</table>
		
	</div>
	</div>
	<div class="bl"></div>
	<div class="br"></div>
	<div class="bm"></div>
	</div>
	</form>
	
	<iframe id="ifm_export" src="about:blank" height="0" width="0" style="visibility: hidden"></iframe>

</asp:Content>