<%@ page contentType="text/html; charset=gb2312"%>
<%@ page import="com.hnisi.wlrk.query.database.*,java.util.*,com.hnisi.wlrk.query.*"%>
<%
// Java代码我就忽略了。。。。。。
%>
<html>
<head>
<title>
高级查询
</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="../default.css" rel="stylesheet" type="text/css">
<SCRIPT language=JavaScript src="calendar.script"></SCRIPT>
<SCRIPT language=JavaScript src="Popup.js"></SCRIPT>
<script language="javascript" DEFER>
function tab_change(Obj){
//取得表中第几行的表名被改变
var no = 0;
for(var i=0;i<document.all.tab_name.length;i++){
if(Obj==document.all.tab_name[i]) no = i;
}
//根据相应行数的表,修改该行的列
var selObj = document.all.col_name[no];
removeoption(selObj);
var str = document.all.item(Obj.value).value.split("&");
for(var s=0;s<str.length;s++){
//alert(str[s].substring(str[s].indexOf("%")+1));
//alert(str[s].substring(0,str[s].indexOf("%")));
selObj.add(new Option(str[s].substring(0,str[s].indexOf("%")),str[s].substring(str[s].indexOf("%")+1)));
}
selObj.fireEvent("onchange");
}
function col_change(Obj){
//判断第几行的列名被改变
var no = 0;
for(var i=0;i<document.all.col_name.length;i++){
if(Obj==document.all.col_name[i]) no = i;
}
//修改改变列所在行的比较关系选择框
var selObj = document.all.comp[no];
removeoption(selObj);
//Obj.value 的格式:colid(列名)+"@"+datatype(列数据类型)+"@"+inputtype(该列对应输入框类型)
var str = Obj.value.split("@");
selObj.add(new Option("等于","="));
if(str[2].indexOf("select")!=-1&&(str[1]== "string"||str[1]== "include")){
} else if(str[2].indexOf("select")!=-1&&(str[1]== "multiselect"||str[1]== "multiinclude")){
selObj.add(new Option("包含"," like "));
selObj.add(new Option("不包含 "," not like "));
} else if(str[1]== "integer"||str[1]== "float"||str[1]== "long"){
selObj.add(new Option("大于",">"));
selObj.add(new Option("大于等于",">="));
selObj.add(new Option("小于","<"));
selObj.add(new Option("小于等于","<="));
} else if(str[1]== "date"||str[1]=="datetime"){
selObj.add(new Option("大于",">"));
selObj.add(new Option("大于等于",">="));
selObj.add(new Option("小于","<"));
selObj.add(new Option("小于等于","<="));
} else if(str[1]== "string"){
selObj.add(new Option("包含"," like "));
selObj.add(new Option("不包含 "," not like "));
} else {
selObj.add(new Option("大于",">"));
selObj.add(new Option("大于等于",">="));
selObj.add(new Option("小于","<"));
selObj.add(new Option("小于等于","<="));
selObj.add(new Option("包含"," like "));
selObj.add(new Option("不包含"," not like "));
}
selObj.add(new Option("不等于 ","<>"));
//修改改变列所在行的隐藏域datatype,column的值
document.all.datatype[no].value=str[1];
document.all.column[no].value=str[0];
//根据该列的数据类型修改输入框的性质:text;dict;date等
if(str[2].indexOf("select")!=-1 && (str[1]!="date" || str[1]!="datetime")){//字典类型;非日期类型
var temp = "<input type='text' name='input"+no+"' value='0000' class='dictitem' kind='"+str[2].substring(str[2].indexOf("/")+1)+"' src='dictionary' multiselect='false' maxnumber='10' readonly='true' size='30' defer = 'true'>";
//document.getElementById("input"+no).innerHTML = "<input type='text' name="+'input'+no+" class='dictitem' kind='"+str[2].substring(str[2].indexOf("/")+1)+"' src='dictionary' multiselect='false' maxnumber='10' readonly='true' size='30'>";
//alert(document.getElementById("input"+no).innerHTML);
document.getElementById("input"+no).innerHTML = temp;
//alert();
} else if(str[1]=="date" || str[1]=="datetime"){//日期类型
//document.all.item("input"+no).innerHTML="<input type='hidden' name='input' class='mychk' datatype ='"+str[1]+"' size='30'>";
document.getElementById("input"+no).innerHTML="<input type='text' value='' size='25' name="+'input'+no+" id='"+str[0].replace('.','_')+"' onclick='fPopUpCalendarDlg("+str[0].replace('.','_')+");return false' readonly> <img style='CURSOR: hand' onClick='fPopUpCalendarDlg("+str[0].replace('.','_')+");return false' alt=弹出日历下拉菜单 src='<%=request.getContextPath()%>/images/datetime.gif'>";
} else {//
document.getElementById("input"+no).innerHTML="<input type='text' name='"+'input'+no +"' size='30'>";
}
//alert(document.getElementById("input"+no).innerHTML);
}
function removeoption(obj){
var len=obj.options.length;
var i=len-1;
for(i;i>=0;i--){
obj.options[i]=null;
}
}
function savequery(){
form1.action="<%=request.getContextPath()%>/servlet/QueryConditionManager?queryid=<%=queryid%>&action=add";
form1.submit();
}
function showTitle (){
var div = document.all.item("SQLDIV");
if(div.style.display=="none"){
div.style.display ="";
//var title = document.all.item("conditionTitle");
//title.value="";
//if(document.form.defaultFlag.checked){
// document.form.defaultFlag.click();
//}
}else{
div.style.display="none";
}
}
</script>
<script language="jscript" src="./htc/global.js">
</script>
<script language="jscript" src="./htc/dictionary.js">
</script>
</head>
<body bgcolor="F5F5F5" leftmargin="0" topmargin="0" style="overflow-x:auto;overflow-y:auto">
<table width="100%" border="0" cellpadding="0" cellspacing="0" background="images/main_titlebg.gif">
<tr>
<td width="15" height="38" valign="top">
<img src="images/main_dot01.gif" width="15" height="14">
</td>
<td>
请构造查询条件
</td>
</tr>
</table>
<br>
<!--input type='text' name='input' class='dictitem' kind='46' src='dictionary' multiselect='true' maxnumber='10' readonly='true' size='30'-->
<form action="ListResultForQuery.jsp" name="form1" method="post">
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="9AC2C6">
<tr>
<td>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#ffffff">
<tr bgcolor="e5e5e5">
<!--td height="25">
<div align="center">
<font color="#339900">
选择
</font>
</div>
</td-->
<td>
<div align="center"><font color="#339900">左括号</font></div>
</td>
<td>
<div align="center"><font color="#339900">表</font></div>
</td>
<td>
<div align="center"><font color="#339900">项目</font></div>
</td>
<td>
<div align="center"><font color="#339900">运算符</font></div>
</td>
<td>
<div align="center"><font color="#339900">条件</font></div>
</td>
<td>
<div align="center"><font color="#339900">右括号</font></div>
</td>
<td>
<div align="center"><font color="#339900">逻辑关系</font></div>
</td>
</tr>
<%
//输出要构造子查询的字段
for(int s1=0;s1<q_row_num;s1++){
%>
<tr bgcolor="efefef">
<!--td>
<div align="center">
<input type="checkbox" name="checkbox" value="checkbox">
</div>
</td-->
<td>
<div align="center">
<select name="(">
<option value=''> </option>
<option value='('>(</option>
<option value='(('>((</option>
<option value='((('>(((</option>
</select>
</div>
</td>
<td>
<div align="center">
<select name="tab_name" onchange="tab_change(this)">
<option value="">==请选择表名==</option>
<%
for(int s3=0;s3<tabNames.length;s3++){
%>
<option value="<%=tabNames[s3][0]%>">
<%=tabNames[s3][1]%>
</option>
<%}%>
</select>
</div>
</td>
<td>
<div align="center">
<select name="col_name" onchange="col_change(this)">
<option value="">==请选择列名==</option>
<%
//页面初始化时,默认按第一个表来存放该表的列名
String datatype = null;
String column = null;
String[] cols = outputCols[0].split("&");
for(int s3=0;s3<cols.length;s3++){
datatype = cols[s3].substring(cols[s3].indexOf("@")+1,cols[s3].lastIndexOf("@"));
column = cols[s3].substring(cols[s3].indexOf("%")+1,cols[s3].indexOf("@"));
%>
<option value="<%=cols[s3].substring(cols[s3].indexOf("%")+1)%>"><%=cols[s3].substring(0,cols[s3].indexOf("%"))%></option>
<%}%>
</select> <input type="hidden" name="datatype" value="">
<input type="hidden" name="column" value="">
</div>
</td>
<td>
<div align="center">
<select name="comp">
<option value="">选择关系</option>
<option value="=">等于</option>
<option value=">">大于</option>
<option value=">=">大于等于</option>
<option value="<">小于</option>
<option value="<=">小于等于</option>
<option value="<>">不等于</option>
<option value=" like ">包含</option>
<option value=" not like ">不包含</option>
</select>
</div>
</td>
<td id="input<%=s1%>" align="center">
<input type="text" name="input<%out.print(s1);%>" size="30">
</td>
<input type="hidden" name="_input<%out.print(s1);%>" size="30">
<td>
<div align="center">
<select name=")">
<option value=''> </option>
<option value=')'>)</option>
<option value='))'>))</option>
<option value=')))'>)))</option>
</select>
</div>
</td>
<td>
<div align="center">
<select name="relation">
<option value=""> </option>
<option value=" and ">且</option>
<option value=" or ">或</option>
</select>
</div>
</td>
</tr>
<%}%>
</table>
</td>
<td width="5" valign="top"><img src="images/blank.gif" width="5" height="5"></td>
</tr>
<tr>
<td valign="top"><img src="images/blank.gif" width="5" height="5"></td>
<td></td>
</tr>
</table>
<!--input type="hidden" name="resultTab" value="T_ZX_RYJBXXB"-->
<input type="hidden" name="queryid" value="<%=queryid%>">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td valign="top">
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="F5F5F5">
<tr>
<td> </td>
</tr>
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td height="2" background="images/main_line01.gif"></td></tr>
</table>
</td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="40" align="center">
<table width="60%" border="0" cellspacing="0" cellpadding="2">
<tr>
<td><input type="button" name="btn1" value="查询" onclick="javascript:mysubmit1()"></td>
<td><input type="button" name="savebtn" value="保存查询条件" onclick="javascript:showTitle()"></td>
<td><input type="button" name="rbtn" value="刷新" onclick="javascript:window.location.reload()"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="4" background="../images/main_blueline.gif"></td>
</tr>
</table>
<div id="SQLDIV" style="font-size:9pt;display:none" align="center">
<br>
请输入查询条件的名称:
<input type="input" name="querytitle" value="" size="30"><br>
请输入查询条件的备注:
<input type="input" name="description" value="" size="23">
<!--input id=flag name="defaultFlag" type="checkbox" value="1" >缺省查询条件-->
<input type="button" value="保存" class="button" onclick="javascript:savequery()">
</div>
<br>
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td bgcolor="f5f5f5"><div align="center"><font color="#0000FF">已经保存的查询条件</font></div></td>
</tr>
</table>
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="88A6B7">
<tr>
<td>
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="1" bgcolor="#ffffff">
<tr bgcolor="e5e5e5">
<td width="50" height="25"><div align="center"><font color="#336699">序号</font></div></td>
<td width="200"><div align="center"><font color="#336699">名称</font></div></td>
<td width="100"><div align="center"><font color="#336699">载入查询条件</font></div></td>
<td width="100"><div align="center"><font color="#336699">删除查询条件</font></div></td>
<td><div align="center"><font color="#336699">备注</font></div></td>
</tr>
<%
Vector condV = ConditionController.getConditionByUser("12345",queryid);
for(int q1=0;q1<condV.size();q1++){
String tmp = (String)condV.get(q1);
%>
<tr bgcolor="efefef">
<td><div align="center"><%=(q1+1)%></div></td>
<td><div align="center"><%=tmp.substring(tmp.indexOf("@")+1,tmp.indexOf("#"))%></div></td>
<td><div align="center"><a href="<%=request.getContextPath()%>/servlet/QueryConditionManager?id=<%=tmp.substring(0,tmp.indexOf("@"))%>&action=load&queryid=<%=queryid%>&userid=12345"><font color='blue'><u>载入</u></font></a></div></td>
<td><div align="center"><a href="<%=request.getContextPath()%>/servlet/QueryConditionManager?id=<%=tmp.substring(0,tmp.indexOf("@"))%>&action=delete&queryid=<%=queryid%>"><font color='blue'><u>删除</u></font></a></div></td>
<td><div align="center"><%=tmp.substring(tmp.indexOf("#")+1)%></div></td>
</tr>
<%}%>
</table>
</td>
<!--td width="5" valign="top">
<img src="../images/blank.gif" width="1" height="5">
</td-->
</tr>
</table>
</td>
</tr>
</table>
</form></body>
</html>