archive_query_list.jsp
上传用户:jhtang88
上传日期:2014-01-27
资源大小:28528k
文件大小:7k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. <%@ page contentType="text/html; charset=utf-8"%>
  2. <%@ page import = "java.util.*"%>
  3. <%@ page import = "java.sql.*"%>
  4. <%@ page import = "cn.js.fan.db.*"%>
  5. <%@ page import = "cn.js.fan.web.*"%>
  6. <%@ page import = "cn.js.fan.util.*"%>
  7. <%@ page import = "com.redmoon.oa.archive.*"%>
  8. <%@ page import = "com.redmoon.oa.person.*"%>
  9. <jsp:useBean id="privilege" scope="page" class="com.redmoon.oa.pvg.Privilege"/>
  10. <jsp:useBean id="archivePrivilege" scope="page" class="com.redmoon.oa.archive.ArchivePrivilege"/>
  11. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  12. <html>
  13. <head>
  14. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  15. <title>人事档案管理</title>
  16. <link href="../common.css" rel="stylesheet" type="text/css">
  17. <%@ include file="../inc/nocache.jsp"%>
  18. <style type="text/css">
  19. <!--
  20. .STYLE2 {color: #0033FF}
  21. .STYLE3 {color: #FF0000}
  22. -->
  23. </style>
  24. </head>
  25. <body background="" leftmargin="0" topmargin="5" marginwidth="0" marginheight="0">
  26. <%
  27. if (!privilege.isUserPrivValid(request, "archive.query")&&!archivePrivilege.canQuery(request)) {
  28. out.print(StrUtil.Alert_Back(SkinUtil.LoadString(request, "pvg_invalid")));
  29. return;
  30. }
  31. %>
  32. <br>
  33. <table border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" width="200%">
  34. <form name="form1" action="archive_excel.jsp" method="post">
  35.   <tr> 
  36.     <td height="23" valign="middle" class="right-title"><span>&nbsp;综合查询</span></td>
  37.   </tr>
  38.   <tr align="right"> 
  39.     <td align="right" valign="top" background="images/tab-b-back.gif">
  40. <%
  41.         String op = "",sql = "",conditionFieldSql = "",conditionFieldCode = "",condition_type = "",condition_field_code = "",show_field_code = "";
  42. int id = -1;
  43. ArchiveQueryDb aqd = new ArchiveQueryDb();
  44. ArchiveQueryConditionDb aqcd = new ArchiveQueryConditionDb();
  45. id = ParamUtil.getInt(request, "id");
  46. aqd = aqd.getArchiveQueryDb(id);
  47. conditionFieldSql = ArchiveSQLBuilder.getArchiveQueryCondition(id);
  48. Vector cvt = aqcd.list(conditionFieldSql);
  49. Iterator cir = null;
  50. cir = cvt.iterator();
  51. while (cir!=null && cir.hasNext()) {
  52. aqcd = (ArchiveQueryConditionDb)cir.next();
  53. if(!aqcd.getConditionType().equals("SELECTED") && condition_type.equals("SELECTED")){
  54.    conditionFieldCode += ")";
  55. }
  56. if(!condition_type.equals("") && condition_type.equals("SELECTED") && condition_field_code.equals(aqcd.getConditionFieldCode())){
  57. conditionFieldCode += " or ";
  58. }else{
  59. if(!condition_field_code.equals(""))
  60.    conditionFieldCode += " and ";
  61. }
  62. if(aqcd.getConditionType().equals("SELECTED") && !condition_type.equals("SELECTED")){
  63. conditionFieldCode += "(";
  64. }
  65. conditionFieldCode += aqcd.getConditionFieldCode() + " " + aqcd.getConditionSign() + " " + aqcd.getConditionValue();
  66. condition_type = aqcd.getConditionType();
  67. condition_field_code = aqcd.getConditionFieldCode();
  68. }
  69. if(condition_type.equals("SELECTED")){
  70. conditionFieldCode += ")";
  71. }
  72. sql = "select AUS.USERNAME," + aqd.getShowFieldCode() + " from " + aqd.getTableCode() + " where "  + conditionFieldCode + " and AUS.DEPTCODE in (" + aqd.getDeptCode() + ")";
  73. if(!aqd.getOrderFieldCode().equals("")){
  74. sql += " order by " + aqd.getOrderFieldCode();
  75. }
  76. show_field_code = aqd.getShowFieldCode();
  77. //out.print("sql=" + sql);
  78. String querystr = "";
  79. querystr = "id=" + id;
  80. int pagesize = 10;
  81. Paginator paginator = new Paginator(request);
  82. int curpage = paginator.getCurPage();
  83. ResultIterator ri = null;
  84. try {
  85. ri = aqd.getResultIterator(sql, curpage, pagesize);
  86. }
  87. catch (ErrMsgException e) {
  88. out.print(StrUtil.Alert_Back(SkinUtil.LoadString(request,"res.module.archive", "warn_query_err_table")));
  89. }
  90. if (ri==null) {
  91. out.print(" 查询结果为空!");
  92. return;
  93. }
  94. ResultRecord rr = null;
  95. long total = ri.getTotal();
  96. paginator.init(total, pagesize);
  97. // 设置当前页数和总页数
  98. int totalpages = paginator.getTotalPages();
  99. if (totalpages==0)
  100. {
  101. curpage = 1;
  102. totalpages = 1;
  103. }
  104. %>
  105.       <table border="0" cellpadding="0" cellspacing="0">
  106.         <tr> 
  107.           <td align="right">找到符合条件的记录 <b><%=paginator.getTotal() %></b> 条 每页显示 <b><%=paginator.getPageSize() %></b> 条 页次 <b><%=curpage %>/<%=totalpages %></td>
  108.         </tr>
  109.       </table>
  110.     </td>
  111.   </tr>
  112.   <tr>
  113.     <td>    
  114.   <table border="0" align="left" cellpadding="0" cellspacing="0" >
  115.         <tr bgcolor="#C4DAFF">
  116. <%
  117.         String[] showFieldCodeArr = show_field_code.split(",");
  118. String[] showAFieldCodeArr = null;
  119. String[] showFieldType = new String[showFieldCodeArr.length];
  120. String showFieldName = "";
  121. String fieldCode = "",tableCode = "",showFieldSQL = "",temp = "";
  122. int i = 0;
  123. TableFieldInfoDb tfid = new TableFieldInfoDb(); 
  124. while(i < showFieldCodeArr.length){     
  125. showAFieldCodeArr = showFieldCodeArr[i].split("\.");
  126.     showFieldSQL = ArchiveSQLBuilder.getArchiveTableField(showAFieldCodeArr[0],showAFieldCodeArr[1]);     
  127.         Vector vt = tfid.list(showFieldSQL);
  128.         Iterator ir = null;
  129.     ir = vt.iterator();
  130.         if (ir!=null && ir.hasNext()) {
  131.        tfid = (TableFieldInfoDb)ir.next();    
  132. %>
  133.             <td height="24" align="center" width="120"><%=tfid.getFieldName()%></td>          
  134. <%               
  135.    showFieldName += tfid.getFieldName();
  136.    showFieldType[i] = tfid.getFieldType();
  137. }
  138. if(i < showFieldCodeArr.length -1)
  139. showFieldName += ",";
  140.     i++;    
  141. }
  142. %>
  143.         </tr>
  144. <%
  145. while (ri!=null && ri.hasNext()) {
  146.     rr = (ResultRecord)ri.next();
  147. int j = 1;
  148. %>
  149.        <tr>
  150. <%          
  151.             while(j <= i){ 
  152.     if(j == 1) {    
  153. %>
  154.           <td height="22" align="center" width="120"><a href="archive_user_modify.jsp?userName=<%=StrUtil.getNullStr(rr.getString(j))%>"><%=StrUtil.getNullStr(rr.getString(j+1))%></a></td> 
  155. <% 
  156.                 }else{
  157. if(showFieldType[j-1].equals("2"))
  158. temp = DateUtil.format(rr.getDate(j+1),"yyyy-MM-dd");
  159. else
  160. temp = StrUtil.getNullStr(rr.getString(j+1));
  161. %>
  162.           <td height="22" align="center" width="120"><%=temp%></td> 
  163. <%
  164.     }             
  165.             j++;         
  166.             }
  167. %>
  168.         </tr>
  169. <%}%>
  170.       </table>
  171.     </td>
  172.   </tr>
  173.   <tr> 
  174.     <td align="left"><input type="submit" name="Submit" value="输出到Excel">
  175.       <input type="hidden" name="showFieldName" value="<%=showFieldName%>">
  176.       <input type="hidden" name="sql" value="<%=sql%>"></td>
  177.   </tr>
  178. </form>
  179.   <tr> 
  180.     <td align="right">  
  181.       <table border="0" cellspacing="1" cellpadding="3" class="9black">
  182.         <tr> 
  183.           <td width="1%" height="23">&nbsp;</td>
  184.           <td height="23" valign="baseline" align="right"> 
  185.             <div>
  186.              <%
  187.    out.print(paginator.getCurPageBlock("?"+querystr));
  188.  %>
  189.             &nbsp;</div></td>
  190.         </tr>
  191.       </table>    
  192. </td>
  193.   </tr>
  194. </table>
  195. </body>
  196. </html>