一个较简单的图书管理系统.rar

源代码在线查看: listbean.java~7~

软件大小: 1348 K
上传用户: archimedes88
关键词: 图书管理
下载地址: 免注册下载 普通下载 VIP

相关代码

								package thisjsp;				import java.sql.*;				import java.util.*;				import java.io.*;				import com.borland.dx.sql.dataset.*;				import java.lang.*;																public class listBean				{				  private String sample = "Start value";				  private java.sql.ResultSet listResult;				  //Access sample property				  private QueryDataSet result=null;				  private QueryDataSet queryDataSet1 = new QueryDataSet();				  private Database database1 = new Database();				  private int count=0;				  private int currentValue=0,countPage=0;				  public String getSample()				  {				    return sample;				  }				  //Access sample property				  public void setSample(String newValue)				  {				    if (newValue!=null)				    {				      sample = newValue;				    }				  }				//初始化结果集------------------------------------------------------------------				  public void getListResult(Writer out) throws Exception				  {				    try{				       queryDataSet1.close();				       queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT * FROM bk", null, true, Load.ALL));				       queryDataSet1.open();				       }				    catch(Exception e){				       e.printStackTrace();				    }				    result=queryDataSet1;				    if (result!=null)				       {				       count=result.getRowCount();				       currentValue=1;				       }				    countPage=(((count/10)*10==count)?count/10:count/10+1);//计算该数据集的页数				    out.write("当前是第"+currentValue+"/"+countPage+"页");				 }				//条件查询				 public void getListResult(String str,Writer out) throws Exception				 {				   try				   {				     queryDataSet1.close();				     queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1,"select * from bk where "+str.trim(),null,true,Load.ALL));				     queryDataSet1.open();				   }				   catch(Exception eee){}				   result=queryDataSet1;				   if (result!=null)				   {				     count=result.getRowCount();				     currentValue=1;				   }				   countPage=(((count/10)*10==count)?count/10:count/10+1);//计算该数据集的页数				   out.write("当前是第"+currentValue+"/"+countPage+"页");				 }				//首页--------------------------------------------------------------------------				  public void firstPag(Writer out) throws Exception				  {				    if (result!=null)				    {				       result.first();				       currentValue=1;				    }				    else				       currentValue=0;				    out.write("当前是第"+currentValue+"/"+countPage+"页");				  }				//下一页------------------------------------------------------------------------				  public void nextPage(Writer out) throws Exception				  {				    int i=10;				    if (currentValue				    {				       currentValue++;				       out.write("当前是第"+currentValue+"/"+countPage+"页");				    }								  }				//上一页------------------------------------------------------------------------				  public void previousPage(Writer out) throws Exception				  {				     int i=21,j=0;				     if (((count/10)*10)!=count)				          i=21;				     if ((((count/10)*10)==count)&&(currentValue==countPage))				         i=20;				     if (currentValue>=countPage&&((count/10)*10)!=count)				        {				        i=10+count%10;				        //out.write("i="+i);				        }				     if (result.atLast())				     {				       j=1;				     }				     else				        j=0;				     if (currentValue>=1)				     {				       while(i>1&&result.prior())				       {				         i--;				       }				     if (currentValue>1)				         currentValue--;				     //if (j==1)				      // result.next();				     }				     if (countPage				       result.first();				     out.write("当前是第"+currentValue+"/"+countPage+"页");				  }				//最后一页----------------------------------------------------------------------				  public void lastPage(Writer out) throws Exception				  {				       pubMovePage();				       out.write("当前是第"+currentValue+"/"+countPage+"页");								  }				//				  public void pubMovePage() throws Exception				  {				     result.last();				     int sumRecount=result.getRowCount()%10;				     currentValue=countPage;				     if (sumRecount==0)				     {				       int i=10;				         while((i--)>1&&result.prior());				     }				     else				     {				          while ((sumRecount--)>1&&result.prior());				     }				     //result.next();				     if (countPage				       result.first();				  }				//显示页面----------------------------------------------------------------------				  public void getListPage(Writer out) throws Exception				  {				    int i=10;				    if (currentValue>countPage)				        {				        pubMovePage();				        }				    if (currentValue0)				   {				    do				   {								     out.write("");				      out.write(""+result.getInt(0)+"");				      out.write("");				      out.write(" "+result.getString(1)+"");				      out.write("");				      out.write(""+result.getString(5)+"");				      out.write("");				      out.write(""+result.getBigDecimal(2)+"");				      out.write("");				      out.write(""+result.getString(3)+"");				      out.write("");								      out.write(" ");				      out.write("");				    out.write("");				    }				   while(result.next()&&i-->1);				   }				     }								public listBean()				  {				    try				    {				      jbInit();				    }				    catch(Exception e)				    {				      e.printStackTrace();				    }				  }				  private void jbInit() throws Exception				  {				  //  JOptionPane.showConfirmDialog() ;				    //LoginDialog.class.getResource("MainFrame.class");				    //JOptionPane.showConfirmDialog(this,this.getClass().getResource("listBean.class"),JOptionPane.OK_OPTION,JOptionPane.MESSAGE_PROPERTY );				    System.out.println(this.getClass().getResource("user.dir"));				    queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1, "SELECT bk.num,bk.name FROM\"D:\\book\".bk", null, true, Load.ALL));				    database1.setConnection(new com.borland.dx.sql.dataset.ConnectionDescriptor("jdbc:odbc:jbksk", "", "", false, "sun.jdbc.odbc.JdbcOdbcDriver"));				    database1.setDatabaseName("");				  }				  private Database database2 = new Database();				  private QueryDataSet queryDataSet2 = new QueryDataSet();				}			

相关资源