<%@ page contentType="text/html;charset=UTF-8" %>
<%@ page import="net.sz600.tool.SzConvert" %>
<%@ page import="net.sz600.system.*" %>
<%@ page import="java.util.*" %>
<%@ page import="net.sz600.dbforeign.*" %>
<%@ page import="net.sz600.formEngine2.*" %>
<%@ include file="/sessionInfo.jsp"%>
<html>
<body onload="load();">
<link href="<%=strSkin_SESSION%>/css2007.css" rel="stylesheet" type="text/css">
<%
    String sOPERATOR = SzConvert.toSpaceStr(request.getParameter("OPERATOR"));
    String sRelate = SzConvert.toSpaceStr(request.getParameter("relate"));
    String sObjectType = SzConvert.toSpaceStr(request.getParameter("ObjectType"));  
    SQLReadSelectXML readSelectXML = new SQLReadSelectXML();
    GetArrayList DBCONN=new GetArrayList("","");
    ArrayList list=DBCONN.getDBConn();
    //获取已经设置的详细信息
    SQLSelectDBinfo tableInfo = (SQLSelectDBinfo)readSelectXML.getTableInfoFromXML(sRelate);
    if (tableInfo == null) {
    	tableInfo = new SQLSelectDBinfo();
    	//tableInfo.setGLTJ("1=1");
    }
    if (sOPERATOR.equals("")) {
    	sOPERATOR = "set";    //share/formEngine2/index.jsp?FormID=1238 
    }
    String sFormType = (String)session.getAttribute("SzFormType");
 
%>

<form name="formUpdate" method="post" action="" >
<input type="hidden" name="OPERATOR" value="<%=sOPERATOR%>">
<input type="hidden" name="ObjectType" value="<%=sObjectType%>">
<input type="hidden" name="moduleName" value="<%=sFormType%>">
<input type="hidden" name="moduleName1" value="">
<input type="hidden" name="formName1" value="">
<input type="hidden" name="moduleName2" value="">
<input type="hidden" name="formName2" value="">
<table border="1" bordercolorlight="#C0C0C0" bordercolordark="#FFFFFF" class="tableClass"
       cellpadding="3" cellspacing="0" align="center">  
  <tr>
    <td colspan="4">
    <%
    if (sOPERATOR.equals("set")) {
      String s_name[] = readSelectXML.getTableName();
    	out.println("请选择关联信息：");
    	out.println(SzPageHelp.idSelectArrayFunc(s_name, s_name, "relate", sRelate, "txtClass1", "SelectRelate();"));
    }
    %>  
    </td>    
  </tr>  
       
  <tr>
    <td colspan="4" class="trClassTitle">==数据库连接信息设置==</td>
  </tr>         
  <tr>
  	<td>数据库连接名称</td>  
<!--    <td colspan="3"><input type="text" value="<%=tableInfo.getRelateName() %>" name="relateName" class="txtClass2"></td>  -->
		<td colspan="3"> <select name="relateName" class="txtClass2">
				<option value="===请选择===">===请选择===	
				<%
					for(int i = 0; i < list.size(); i ++){
				%>	
				<option value="<%=list.get(i) %>" <%=list.get(i).equals(tableInfo.getRelateName())? " selected ":""%> ><%=list.get(i) %>
				
				
				<%
					}
				%>
		</select></td>
  </tr>
  <tr>
  	<td>查询名称</td>
    <td colspan="3">  <input type="text" name="CX" value="<%=tableInfo.getCX() %>"  class="txtClass2"></td>
  
  </tr>
  <tr>
  	 <td>查询说明</td>
    <td colspan="3">  <input type="text" name="relateDesc" value="<%=tableInfo.getRelateDesc() %>"  class="txtClass2"></td>
  </tr>
   <tr>
  	<td>字段名称（逗号分开）</td>  
    <td colspan="3"><input type="text" value="<%=tableInfo.getCUZD() %>" name="CUZD" class="txtClass2"></td>  
  </tr>
   <tr>
  	<td>字段说明（逗号分开）</td>  
    <td colspan="3"><input type="text" value="<%=tableInfo.getZDMC() %>" name="ZDMC" class="txtClass2"></td>  
  </tr>
   <tr>
  	<td>表名</td>  
    <td colspan="3"><input type="text" value="<%=tableInfo.getBM() %>" name="BM" class="txtClass2"></td>  
  </tr>
   <tr>
  	<td>查询条件</td>  
    <td colspan="3"><input type="text" value="<%=tableInfo.getCXTJ() %>" name="CXTJ" class="txtClass2"></td>  
  </tr>
  <tr>
  	<td>排序字段</td>  
    <td><input type="text" value="<%=tableInfo.getPX() %>" name="PX" class="txtClass1"></td> 
    <td>分组字段</td>  
    <td><input type="text" value="<%=tableInfo.getFZ() %>" name="FZ" class="txtClass1"></td> 
  </tr>
  <tr>
  	<td>是否分页</td>  
    <td> <%
      	String s_id2[] = {"0","1"};
        String s_name2[] = {"是","否"};
        out.println(SzPageHelp.radio("Fenye", s_id2, s_name2,tableInfo.getFenye() ));
     	 %> 
     </td> 
    <td>分页一页大小</td>  
    <td><input type="text" value="<%=tableInfo.getSIZE() %>" name="SIZE" class="txtClass1"></td> 
  </tr>
  <tr>
  	<td>是否导出</td>  
    <td><%
        out.println(SzPageHelp.radio("Daochu", s_id2, s_name2,tableInfo.getDaochu()));
     	 %>
     </td> 
    <td>是否打印</td>  
    <td><%
        out.println(SzPageHelp.radio("Dayin", s_id2, s_name2,tableInfo.getDayin()));
     	 %>
     </td> 
  </tr>
  
  <tr>
    <td colspan="4" align="center"  class="trClassTitle">          
      <input type="button" value="保存" class="btnClass" OnClick="Save();">
      
      <input type="button" value="返回" class="btnClass" OnClick="javascript:history.go(-1);">
    </td>  
  </tr>    
</table>

</form>
<script language="javascript" src="../../share/js/commonTool.js"></script>
<script language="javascript" src="../../share/js/selectTool.js"></script>

<script language="javascript">CX
  
  //提交到控制保存的页面
  function Save() {
  	if (!notSpace(formUpdate.relateName, "数据库连接名称")) {
      return false;
    }  
    //名称只能为字母数字下划线
    if (!isLetterOrNumOrLine(formUpdate.relateName.value)) {
      alert("名称只能是字母数字下划线");
      formUpdate.relateName.focus();
      return false;
    }
    if (!notSpace(formUpdate.CX, "查询名称")) {
      return false;
    }  
    //名称只能为字母数字下划线
    if (!isLetterOrNumOrLine(formUpdate.CX.value)) {
      alert("查询名称只能是字母数字下划线");
      formUpdate.relateName.focus();
      return false;
    }
    
    if (!notSpace(formUpdate.CUZD, "查询字段")) {
      return false;
    }   
    if (!notSpace(formUpdate.ZDMC, "字段名称")) {
      return false;
    }   
    if (!notSpace(formUpdate.BM, "表名")) {
      return false;
    }   
    formUpdate.action = "foreign_sql_control.jsp";
    formUpdate.submit();
  }
  
  //选择已经存在的，显示出来。
  function SelectRelate() { 
    formUpdate.action = "../../share/foreign/formselectdb.jsp";
    formUpdate.submit();  
  }
</script>

</body>
</html>
<!-- 
<iframe name="submitName" style='display:none;'></iframe>
 -->
