VB个人理财管理系统(流程图+论文+源程序) 第4页
Vector vector=new Vector();
AbstractTableModel tm;
JTable table;
JScrollPane scroll;
JButton btl;
public showtablec(String basename){
initTable(basename);
init();
}
public void init(){
f.setSize(500,500);
f.setLayout(new FlowLayout());
f.setVisible(true);
}
public void initTable(String basename){
//---------------------------------------------------------------------------
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);
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 信用卡收入支出表 ");
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("收入/支出"));
vector1.addElement(rs.getString("是否贷款"));
vector1.addElement(rs.getDate("还款日期"));
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.5现金收支查询模块的设计与实现
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 selectM 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 selectM(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("日");
上一页 [1] [2] [3] [4] [5] [6] [7] 下一页
VB个人理财管理系统(流程图+论文+源程序) 第4页下载如图片无法显示或论文不完整,请联系qq752018766