package hejian04010209;
import java.awt.*;
import com.borland.dbswing.*;
import java.sql.*;
import javax.swing.table.*;
import javax.swing.*;
/**
* <p> Title: </p>
* <p> Description: </p>
* <p> Copyright: Copyright (c) 2005 </p>
* <p> Company: </p>
* @author not attributable
* @version 1.0
*/
public class SearchEvent extends JPanel {
private Connection cn;
JLabel jLabel1 = new JLabel();
TableScrollPane tableScrollPane1 = new TableScrollPane();
JTable jTable1 = new JTable();
void search(String askh){
String[]lsname={ "日期 ", "操作 ", "取款(-)或存入(+) "};
String[][]lsdata=new String[10][3];
String[]lsdata2=new String[3];
int i=0;
try{
PreparedStatement ps=cn.prepareStatement( "select 存取日期,case when 存取金额 <0 then '取款 ' else '存入 ' end,存取金额 from 存取款事件 where rtrim(卡号)=? ");
ps.setString(1,askh);
ResultSet rs=ps.executeQuery();
while(rs.next())
{
lsdata[i][0]=rs.getString(1);
lsdata[i][1]=rs.getString(2);
lsdata[i][2]=String.valueOf(rs.getDouble(3));
i++;
if (i> 9)
break;
}
DefaultTableModel dtm=new DefaultTableModel(lsdata,lsname);
jTable1.setModel(dtm);
while(rs.next())
{
lsdata2[0]=rs.getString(1);
lsdata2[1]=rs.getString(2);
lsdata2[2]=String.valueOf(rs.getDouble(3));
dtm.addRow(lsdata2);
}
}catch(Exception e2)
{
JOptionPane.showMessageDialog(this, "查询数据失败! ");
return;
}
}
public SearchEvent() {
try {
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver ");