<%@ page contentType="text/html;charset=gb2312" %>
<%@ page import="java.util.*" %>
<%@ page import="com.gx.webpage.framework.util.inoutformat.DataBean" %>
<%@ page import="com.gx.webpage.engine.pagedesigndbengine.factory.PageDesignDbEngineFactory"%>
<%@ page import="com.gx.webpage.engine.pagedesigndbengine.valueobject.*"%>
<%
    String table = "";
    boolean isError = false;
    String infStr = "";
    try{
        Collection col = PageDesignDbEngineFactory.getInstance().getPageDbEngineApi().findAllFormsByType(FormsModel.TYPE_VIEW,request);
        Iterator it = col.iterator();
        while(it.hasNext()){
            FormsModel fm = (FormsModel)it.next();
            table += "<tr onclick='itemClick(this)' style='cursor : hand'>\r\n";
            table += "<td><input type=radio name=uuid value='" + fm.getUuid() + "'></td>\r\n";
            table += "<td>" + DataBean.getStr(fm.getTblName()) + "&nbsp;</td>\r\n";
            table += "<td>" + DataBean.getStr(fm.getTblId()) + "&nbsp;</td>\r\n";
            table += "<td>" + DataBean.getStr(fm.getDescription()) + "&nbsp;</td>\r\n";
            table += "</tr>";
        }
    }catch(Exception err){
        isError = true;
        infStr = DataBean.getErrStr(err);
    }
%>
<html>
<head>
    <meta http-equiv="Content-Language" content="zh-cn">
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link href="./../../../webpage/common/css/common.css" rel="StyleSheet"  type="text/css" />
<script language="javascript" src="./../../../webpage/common/engine/constant.js"></script>
<script language="JScript.Encode" src="./../../../webpage/common/engine/common.js"></script>
<script language="javascript">
<!--
    function btn_add(){
        window.navigate("searchAdd.jsp");
    }
    function btn_modify(){
        Navigate("searchModify.jsp");
    }
    function btn_delete(){
        Navigate("searchDelete.jsp");
    }
    function btn_InputList(){
        Navigate("./input/inputList.jsp");
    }
    function btn_ListList(){
        Navigate("./list/listList.jsp");
    }
    function btn_GroupList(){
    }
    function Navigate(url)
    {
        var chk = getOnlyOneItem();
        if(chk == null)
        {
            return;
        }
        window.navigate(url + "?uuid=" + chk.value );
    }
    function getOnlyOneItem()
    {
        var col = document.getElementsByName('uuid');
        for(var i=0; i < col.length; i++)
        {
            var chk = col(i);
            if(chk.checked == true)
            {
                return chk;
            }
        }
        MSG.show('请选择一个查询业务');
        return null;
    }
    function getTablId(chk)
    {
        var tr = chk.parentElement.parentElement;
        var td = tr.cells(2);
        return td.innerText;
    }
    var oldIndex = -1;
    function itemClick(tr)
    {
        var i = tr.rowIndex - 1;
        var col = document.getElementsByName('uuid');
        col(i).click();
        switchColor(oldIndex, false);
        oldIndex = i + 1;
        switchColor(oldIndex, true);
    }
    function switchColor(index, set)
    {
        if(index < 0) return;
        var tr = listTable.rows(index);
        if(set == true)
        {
            tr.style.backgroundColor = '#cccccc';
        }
        else
        {
            tr.style.backgroundColor = '';
        }
    }
//-->
</script>
    <title>自定义查询</title>
</head>
<body class="main">
<div align="center">
<h3 align="center">自定义查询列表</h3>
<%if(!isError){%>
<table class="content" id="listTable">
    <tr><td>&nbsp</td>
        <td>查询业务名称</td>
        <td>查询业务标识</td>
        <td>查询描述</td>
<%= table%>
</table>
<table class="buttable1">
<tr>
<td align=center><input class="butAction" type="button" name="but_add"        value="　增　　加　" onclick="btn_add();">
<td align=center><input class="butAction" type="button" name="but_modify"     value="　修　　改　" onclick="btn_modify();">
<td align=center><input class="butAction" type="button" name="but_delete"     value="　删　　除　" onclick="btn_delete();">
<td align=center><input class="butAction" type="button" name="but_inputCon"   value="查询输入设置" onclick="btn_InputList();">
<td align=center><input class="butAction" type="button" name="but_listCon"    value="查询列表设置" onclick="btn_ListList();">
</table>
<%}else{%>
<p align=center>生成列表失败．
<p align=center><%= infStr%>
<p align=center><input class="butAction" type="button" value="后退" onclick="window.history.back();">
<%}%>
</div>
</body>
</html>
