OutPrint.java
上传用户:u_thks
上传日期:2022-07-31
资源大小:1910k
文件大小:12k
- /*
- * Created on 2005-7-6
- * Made In GamVan
- */
- package com.gamvan.html;
- import java.text.ParseException;
- import com.gamvan.tools.FormatDateTime;
- /**
- * @author GamVan by 我容易么我
- * Powered by GamVan.com
- */
- public class OutPrint {
- /**
- * 带CSS居中打印文字提示信息
- * @param txt
- * @param urls
- * @param i
- * @return
- * 2005-11-7 6:28:24 Made In GamVan
- * com.gamvan.html
- */
- public static String prtCenter(String txt, String urls, int i){
- String temp;
- temp = "<SCRIPT type=text/javascript>function doTrans(filterCode){imgObj.filters[0].apply();oImg.style.filter = filterCode;imgObj.filters[0].play();}</SCRIPT>";
- temp = temp + "<br><br><center> ";
- switch(i){
- case 1:
- temp = temp + "<a href="+ urls +">";
- break;
- case 2:
- temp = temp + "<a href=javascript:history.back()>";
- break;
- }
- temp = temp + "<span style="font-size:14px; font-family:Verdana, Arial, 宋体; line-height: 19px;" >";
- temp = temp + txt + "</span>";
- if(i > 0){
- temp = temp + "</a>";
- }
-
- temp = temp + "<br>"+
- "<span id="imgObj" onmouseleave='doTrans("gray")' style="FILTER: progid:DXImageTransform.Microsoft.Fade(Overlap=1.00); WIDTH: 100% ""+
- " onmouseenter='doTrans("")'>"+
- "<a href=# target=_blank><img id="oImg" style="FILTER: gray" alt="技术支持" src="/club/GVimgs/gamvan.gif" border=0></a>"+
- "</span></center><br><br>";
- return temp;
- }
-
- /**
- * 网页文本框
- * @param formName
- * @param cols
- * @param rows
- * @param txt
- * @return
- * 2005-11-7 6:28:10 Made In GamVan
- * com.gamvan.html
- */
- public static String textArea(String formName, int cols, int rows, String txt){
- StringBuffer sb = new StringBuffer();
- sb.append("<textarea name=""+ formName +"" id=""+ formName +"" cols=""+ cols +"" rows=""+ rows +"" onkeydown="keyForm();">");
- sb.append(txt);
- sb.append("</textarea><script language="javascript">gv_textarea(""+ formName +"","+ cols +","+ rows +");</script>");
- return sb.toString();
- }
-
-
- /**
- * 分页Html
- * @param totalCount 数据总数
- * @param pageNum 每页显示数量
- * @param iPage 当前页
- * @param url
- * @return
- */
- public static String pageJump(int totalCount, int pageNum, int iPage, String url){
- if(iPage<1){
- iPage = 1;
- }
- if(totalCount<=0){
- return "";
- }
- int iPage1=0, iPage2=0;
- int totalPage = 0; //总页数
- if(totalCount%pageNum!=0){
- totalPage = totalCount/pageNum + 1;
- }else{
- totalPage = totalCount/pageNum;
- }
- StringBuffer sb = new StringBuffer();
- sb.append("<table height="25" border="0" cellpadding="2" cellspacing="1" class="tab"><tr class="tab1">");
- sb.append("<td class="tab"> <strong>");
- sb.append(totalPage);
- sb.append("</strong> </td>");
- sb.append("<td align="center">");
- sb.append(" <a title="返回首页" href="" + url + "iPage=1"><<</a> ");
- sb.append("</td>");
- sb.append("<td align="center">");
- sb.append("<a title="返回上一页" href="" + url + "iPage=" + (iPage-1) + ""><</a> ");
- sb.append("</td>");
- if(iPage>=10){
- iPage2=iPage+8;
- iPage1=iPage-1;
- if(iPage2>totalPage){
- iPage2=totalPage;
- iPage1=totalPage-9;
- }
- }else{
- if(totalPage>10){
- iPage2=10;
- }else{
- iPage2=totalPage;
- }
- iPage1=1;
- }
- for(int i=iPage1;i<=iPage2;i++){
- if(i==iPage){
- sb.append("<td align="center" class="tab3">");
- sb.append(" <a href="" + url + "iPage=" + i + "">");
- sb.append("<span style=color:#bb0000><strong>"+ i +"</strong></span></a> ");
- sb.append("</td>");
- }else{
- sb.append("<td align="center"> ");
- sb.append(" <a href="" + url + "iPage=" + i + "">");
- sb.append("<strong>" + i + "</strong></a> ");
- sb.append("</td>");
- }
- }
- sb.append("<td align="center">");
- sb.append(" <a title="跳到下一页" href="" + url + "iPage=" + (iPage+1) + "">></a>");
- sb.append("</td>");
- sb.append("<td align="center">");
- sb.append(" <a title="跳到尾页" href="" + url + "iPage=" + totalPage + "">>></a>");
- sb.append("</td>");
- sb.append("</table>");
- return sb.toString();
- }
-
- public static String pageJump2(int totalPage, int pageNum, int iPage, String url){
-
- if(totalPage<=0){
- return "";
- }
- int iPage1=0, iPage2=0;
-
- StringBuffer sb = new StringBuffer();
- sb.append("<table height="25" border="0" cellpadding="2" cellspacing="1" class="tab"><tr class="tab1">");
- sb.append("<td class="tab"> <strong>");
- sb.append(totalPage);
- sb.append("</strong> </td>");
- sb.append("<td align="center">");
- sb.append(" <a title="返回首页" href="" + url + "iPage=1"><<</a> ");
- sb.append("</td>");
- sb.append("<td align="center">");
- sb.append("<a title="返回上一页" href="" + url + "iPage=" + (iPage-1) + ""><</a> ");
- sb.append("</td>");
- if(iPage>=10){
- iPage2=iPage+8;
- iPage1=iPage-1;
- if(iPage2>totalPage){
- iPage2=totalPage;
- iPage1=totalPage-9;
- }
- }else{
- if(totalPage>10){
- iPage2=10;
- }else{
- iPage2=totalPage;
- }
- iPage1=1;
- }
- for(int i=iPage1;i<=iPage2;i++){
- if(i==iPage){
- sb.append("<td align="center" class="tab3">");
- sb.append(" <a href="" + url + "iPage=" + i + "">");
- sb.append("<span style=color:#bb0000><strong>"+ i +"</strong></span></a> ");
- sb.append("</td>");
- }else{
- sb.append("<td align="center"> ");
- sb.append(" <a href="" + url + "iPage=" + i + "">");
- sb.append("<strong>" + i + "</strong></a> ");
- sb.append("</td>");
- }
- }
- sb.append("<td align="center">");
- sb.append(" <a title="跳到下一页" href="" + url + "iPage=" + (iPage+1) + "">></a>");
- sb.append("</td>");
- sb.append("<td align="center">");
- sb.append(" <a title="跳到尾页" href="" + url + "iPage=" + totalPage + "">>></a>");
- sb.append("</td>");
- sb.append("</table>");
- return sb.toString();
- }
-
-
- /**
- * 定制页面时间输出格式
- * @param sb
- * @return
- * 2005-11-7 5:59:25 Made In GamVan
- * com.gamvan.html
- */
- public static String isDateHtml(String sb){
- if(sb==null || sb.equals("")){
- return "";
- }
- String d = "";
- String t = "";
- sb = sb.replace(".0","");
- d = sb.substring(0, sb.indexOf(" ")); /*取年月*/
- t = sb.substring(sb.indexOf(" ")+1, sb.length()-3); /*取时间去掉秒数*/
- String ts="";
- boolean isAfter;
- try{
- String now = FormatDateTime.formatDateTime("yyyy-MM-dd");
- isAfter = FormatDateTime.dateCompare(d, now);
- if(!isAfter){ /* 今天 */
- d = d.substring(2, d.length());
- ts=("<span style="font-size: 12px; color:#cc0000;font-weight: bold;">今天</span> ");
- ts+=(" <span style="color:#990066">"+t);
- ts+=("</span>");
- }else{
- /* 计算昨天 */
- ts = FormatDateTime.dateAdd("d",-1); /* 返回间隔一天后的时候 */
- ts = ts.substring(0, 11); /* 取年月日 */
- isAfter = FormatDateTime.dateCompare(d, ts);
- if(!isAfter){
- d = d.substring(2, d.length());
- ts=("<span style="font-size: 12px; color:#006600;font-weight: bold;">昨天</span> ");
- ts+=(" <span style="color:#990066">"+t);
- ts+=("</span>");
- }else{
- /* 计算前天 */
- ts = FormatDateTime.dateAdd("d",-2); /* 返回间隔两天后的时候 */
- ts = ts.substring(0, 11); /* 取年月日 */
- isAfter = FormatDateTime.dateCompare(d, ts);
- if(!isAfter){
- d = d.substring(2, d.length());
- ts=("<span style="font-size: 12px; color:#2A00FF;font-weight: bold;">前天</span> ");
- ts+=(" <span style="color:#990066">"+t);
- ts+=("</span>");
- }else{
- d = d.substring(2, d.length());
- ts=(d+ " <span style="color:#990066">" + t);
- ts+=("</span>");
- }
- }
- }
- }catch(Exception e){
-
- }
- return ts;
- }
-
- public static String isDateHtml2(String sb, String format){
- if(sb==null || sb.equals("")){
- return "";
- }
- String d = "";
- String t = "";
- sb = sb.replace(".0","");
- d = sb.substring(0, sb.indexOf(" "));
- t = sb.substring(sb.indexOf(" ")+1, sb.length());
- String ts="";
- boolean isAfter;
- try{
- java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(format);
- String isDate = sdf.format(new java.util.Date());
- java.util.Date date1 ;
- java.util.Date date0 ;
- ts= (d);
- date1 = sdf.parse(ts);
- date0 = sdf.parse(isDate);
- isAfter = date0.after(date1);
- if(!isAfter){
- ts=("<span style="font-size: 12px; color:#cc0000;font-weight: bold;">今天</span> ");
- ts+=(" <span style=color:#990066>"+t);
- ts=(ts.substring(0,(ts.length()-3)));
- ts+=("</span>");
- }else{
- ts+=(" <span style=color:#990066>"+t);
- ts=(ts.substring(2,(ts.length()-3)));
- ts+=("</span>");
- }
- //this.isAfter = isAfter;
- }catch(ParseException e){
-
- }
- return ts;
- }
-
- /**
- * 不显示时间
- * @param sb
- * @param format
- * @return
- * 2005-11-7 6:29:48 Made In GamVan
- * com.gamvan.html
- */
- public static String isDateHtml3(String sb, String format){
- if(sb==null || sb.equals("")){
- return "";
- }
- String d = "";
- String t = "";
- sb = sb.replace(".0","");
- d = sb.substring(0, sb.indexOf(" "));
- t = sb.substring(sb.indexOf(" ")+1, sb.length());
- String ts="";
- boolean isAfter;
- try{
- java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(format);
- String isDate = sdf.format(new java.util.Date());
- java.util.Date date1 ;
- java.util.Date date0 ;
- ts= (d);
- date1 = sdf.parse(ts);
- date0 = sdf.parse(isDate);
- isAfter = date0.after(date1);
- if(!isAfter){
- ts=("<span style="font-size: 12px;color:#cc0000;font-weight: bold;">今天</span> ");
- }else{
- ts=d;
- }
- }catch(ParseException e){
-
- }
- return ts;
- }
- }