VB个人理财管理系统(流程图+论文+源程序) 第5页
table=new JTable(tm);
table.setShowHorizontalLines(true);
table.setShowVerticalLines(true);
table.setAutoResizeMode(table.AUTO_RESIZE_ALL_COLUMNS);
table.setCellSelectionEnabled(true);
scroll=new JScrollPane(table);
scroll.setBounds(21,10,6,50);
f.add(scroll);
try{
Class.forName(driver);
con = DriverManager.getConnection(url,"sa",null);
sta = con.createStatement();
rs=sta.executeQuery("USE "+basename+"的个人理财数据库 select * from 现金收入支出表 where 日期 between '"+date1+"' and '"+date2+"'");
vector.removeAllElements();
tm.fireTableStructureChanged();
while(rs.next()){
Vector vector1=new Vector();
vector1.addElement(rs.getDate("日期"));
vector1.addElement(rs.getString("项目"));
vector1.addElement(rs.getDouble("金额"));
vector1.addElement(rs.getString("收入/支出"));
vector.addElement(vector1);
}
}catch(SQLException ex){
ex.printStackTrace();
}catch(Exception ex){
ex.printStackTrace();
}
finally{
try{
}catch(Exception ex){
ex.printStackTrace();
}
}
}
public void close(){
try{
if(con!= null)
con.close();
con=null;
}catch(Exception e){
e.printStackTrace();
}
}
}//查找日期范围 查询显示现金表
5.7信用卡收支查询模块的设计与实现:
1.流程图:
2.运行界面:
3.实现过程:
下面把此界面的主要代码作一介绍:
查找日期范围 查询信用卡表:
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.table.*;
import java.io.*;
import java.util.*;
public class selectC extends JFrame{
JFrame f=new JFrame("信用卡收入支出表查询");
Connection con;
Statement sta;
ResultSet rs;
String driver= "com.microsoft.jdbc.sqlserver.SQLServerDriver";
String url= "jdbc:microsoft:sqlserver://localhost:1433";
String title[]={"日期 "," 项目"," 金额 "," 收入/支出 "," 是否贷款 "," 还款日期 "};
Vector vector=new Vector();
AbstractTableModel tm;
JTable table;
JScrollPane scroll;
JButton btl;
TextField input1,input2,input3,input4,input5,input6;
String date1,date2;
String basename;
public selectC(String bn){
super("信用卡收入支出表");
setLayout(new FlowLayout());
basename=bn;
btl=new JButton("确定");
btl.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(ActionEvent e){sel();
dispose();}
});
JLabel l=new JLabel("查找日期范围");
input1=new TextField(2);
JLabel year=new JLabel("年-");
input2=new TextField(2);
JLabel month=new JLabel("月-");
input3=new TextField(2);
JLabel day=new JLabel("日~");
JLabel dyear=new JLabel("年-");
input4=new TextField(2);
JLabel dmonth=new JLabel("月-");
input5=new TextField(2);
JLabel dday=new JLabel("日");
input6=new TextField(2);
add(l);
add(input1);
add(year);
add(input2);
add(month);
add(input3);
add(day);
add(input4);
add(dyear);
add(input5);
add(dmonth);
add(input6);
add(dday);
add("South", btl);
pack();
setSize(650,100);
setVisible(true);
}
public void sel()
{
initTable();
init();
}
public void init(){
f.setSize(500,500);
f.setLayout(new FlowLayout());
f.setVisible(true);
}
public void initTable(){
date1=input1.getText()+"-"+input2.getText()+"-"+input3.getText();
date2=input4.getText()+"-"+input5.getText()+"-"+input6.getText();
//---------------------------------------------------------------------------
tm=new AbstractTableModel(){
public int getColumnCount(){
return title.length;
}
public int getRowCount(){
return vector.size();
}
public Object getValueAt(int row,int column){
if(!vector.isEmpty()){
return ((Vector) vector.elementAt(row)).elementAt(column);
}else{
return null;
}
}
public void setValueAt(Object value,int row,int column){
}
public String getColumnName(int column){
return title[column];
}
//public Class getColumnClass(int c){
// return getValueAt(0,c).getClass();
// }
public boolean isCellEditable(int row,int column){
return false; } };
table=new JTable(tm);
table.setShowHorizontalLines(true);
table.setShowVerticalLines(true);
上一页 [1] [2] [3] [4] [5] [6] [7] 下一页