disppaytype.java
来自「通过jsp、mysql实现了进销存管理」· Java 代码 · 共 106 行
JAVA
106 行
/**
* Title 财务管理系统
* @author: trowa
* Company: http://www.upol.cn
* Copyright: Copyright (c) 2004
* @version 1.0
* 费用类型表中的一些查询操作
*/
package caiwu;
import java.sql.*;
import java.util.*;
public class DispPaytype extends Paytype {
public ResultSet rs;
// 得到所有的费用类型
public Vector allPaytype() {
DBConnect dbc = null;
Vector allPaytypeVector = new Vector();
try {
dbc = new DBConnect();
dbc.prepareStatement("SELECT * FROM paytype order by id");
rs = dbc.executeQuery();
while (rs.next()) {
Paytype paytype = new Paytype();
paytype.setId(rs.getInt("id"));
paytype.setName(rs.getString("name"));
paytype.setIo(rs.getInt("io"));
allPaytypeVector.add(paytype);
}
} catch (Exception e) {
System.err.println(e);
} finally {
try {
dbc.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return allPaytypeVector;
}
// 根据支出和收入获得所有的费用类型
public Vector ioPaytype() {
DBConnect dbc = null;
Vector allPaytypeVector = new Vector();
try {
dbc = new DBConnect();
dbc
.prepareStatement("SELECT * FROM paytype where io=? order by id");
dbc.setInt(1, Io);
rs = dbc.executeQuery();
while (rs.next()) {
Paytype paytype = new Paytype();
paytype.setId(rs.getInt("id"));
paytype.setName(rs.getString("name"));
paytype.setIo(rs.getInt("io"));
allPaytypeVector.add(paytype);
}
} catch (Exception e) {
System.err.println(e);
} finally {
try {
dbc.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return allPaytypeVector;
}
// 根据id得到所有的费用类型
public Paytype idToPaytype() {
DBConnect dbc = null;
Paytype paytype = new Paytype();
try {
dbc = new DBConnect();
dbc.prepareStatement("SELECT * FROM paytype where id=?");
dbc.setInt(1, Id);
rs = dbc.executeQuery();
if (rs.next()) {
paytype.setId(rs.getInt("id"));
paytype.setName(rs.getString("name"));
paytype.setIo(rs.getInt("io"));
}
} catch (Exception e) {
System.err.println(e);
} finally {
try {
dbc.close();
} catch (Exception e) {
e.printStackTrace();
}
}
return paytype;
}
public DispPaytype() {
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?