package download;
import java.sql.*;
public class RsToGbk {
	// 分页控制子模块
	// ShowOnePage(ResultSet, 页数, 每页记录数)
	public String ShowOnePage( ResultSet rs, int Page , int PageSize)
	{
	  String str = "";	
	  for(int i=1; i<=(Page-1) * PageSize+1; i++) {
	     try {
		 	rs.next();	
	     }catch(Exception e) {}
	  }   
	  for(int iPage=1; iPage<=PageSize; iPage++) {
		 str += RsToGbook(rs);
		 try {
		     if(!rs.next()) break;
		 }catch(Exception e) {}
	  }
	  
	  return str;
	}
	
	// 显示单行记录子模块
	public String RsToGbook( ResultSet rs ) {
		String tt = "";
		try {
			tt = "<hr color=#f0000 width='95%" + "'>";
			tt = tt + "<Center><TABLE BORDER=1 WIDTH='95%'>";
			tt = tt + "<TR><TD BGCOLOR=#00FFFF Width='15%'>软件名称:</TD><TD><a href='openfile.jsp?id=" + rs.getInt("id") + "' target='dispwin'>"+ rs.getString("showname") + "</a></TD>";
			tt = tt + "<TD BGCOLOR=#00FFFF Width='14%'>星级评定：</TD><TD Width='21%'><Font color=#ff0000>" + rs.getString("hot") + "</font></TD>";
			tt = tt + "<TR><TD BGCOLOR=#00FFFF Width='15%'>下载次数：</TD><TD><Font color=#ff0000><B>" + rs.getInt("hits") + "</B></Font></TD>";
			tt = tt + "<TD BGCOLOR=#00FFFF>加入时间：</TD><TD>" + rs.getDate("dateandtime").toString() + "</TD></TR>";
			tt = tt + "<TR><TD  BGCOLOR=#00FFFF Width='15%'>软件介绍：</TD>";
			String memo = rs.getString("softnote");
			tt = tt + "<TD COLSPAN=3>" + memo + "</TD></TR>";
			tt = tt + "</TABLE></Center>";
		}catch(SQLException e) {}
		return tt;
	}
	
	// 系统维护之显示子模块
	public String  Xtwh2 ( ResultSet  rs ) {
		String tt = "";
		int tmpid = 0;
		try {
			tmpid = rs.getInt("id");
		}catch(SQLException e) {}
		try {
			tt += "<hr color=#f0000 width='95%" + "'>";
			tt += "<form name='myform' action='oper.jsp'>";
			tt += "<Center><TABLE BORDER=1 WIDTH='95%'>";
			tt += "<TR><TD align=center><Input type=submit name=add" + tmpid + " value=增加></TD>";
			tt += "<TD align=center><Input type=submit name=cha" + tmpid + " value=修改></TD>";
			tt += "<TD colspan=2 align=center><Input type=submit name=del" + tmpid + " value=删除></TD></TR>";
			tt += "<TR><TD BGCOLOR=#00FFFF Width='15%'>软件名称:</TD><TD><A href='openfile.jsp?id=" + tmpid + "' target=newwin>"+ rs.getString("showname") +"</a></TD>";
			tt += "<TD BGCOLOR=#00FFFF Width='14%'>星级评定：</TD><TD Width='21%'><Font color=#ff0000>" + rs.getString("hot") + "</font></TD>";
			tt += "<TR><TD BGCOLOR=#00FFFF Width='15%'>下载次数：</TD><TD><Font color=#ff0000><B>" + rs.getInt("hits") + "</B></Font></TD>";
			tt += "<TD BGCOLOR=#00FFFF>加入时间：</TD><TD>" + rs.getDate("dateandtime").toString() + "</TD></TR>";
			tt += "<TR><TD  BGCOLOR=#00FFFF Width='15%'>软件介绍：</TD>";
			String memo = rs.getString("softnote");
			tt += "<TD COLSPAN=3>" + memo + "</TD></TR>";
			tt += "</TABLE></Center>";
			tt += "</form>";
		}catch(SQLException e) {}
		return  tt;
	}
	
	// ShowOnePage(ResultSet, 页数, 每页记录数)
	public String Xtwh ( ResultSet rs ,int Page, int PageSize ) {
	  String str = "";
	  for(int i=1; i<=(Page-1) * PageSize+1; i++) {
	     try {
		 	rs.next();	
	     }catch(Exception e) {}
	  }   
	  for(int iPage = 1; iPage<=PageSize; iPage++) {
		 str += Xtwh2(rs);	
		 try {
		     if(!rs.next()) break;
		 }catch(Exception e) {}
	  }
	  return str;
	}
}
