
正文
java财务管理系统代码 java资产管理系统设计
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
这个数据库怎么建表?如何让下面这些语句在Oracle SQL Developer 中运行。这是一个java编的财务管理系统
先用root账号进默认实例,按【;】为结束一句一句运行啊。
只要注意好/*…………*/ 这个注释部分的内容,别因为换行把语句分割注释了。
另外你的insert into语句导出有问题,有乱码的,你最好查查别直接运行insert语句。
相关问答
Q1: 基于JAVA的中小企业财务管理系统设计与实现
企业财务管理系统 先跟你们导师确定需求
人员管理 固定资产管理 工资管理 入账 开支
java web实现 框架 struts2+spring+hibernate
数据库 mysql 服务器 Tomcat
Q2: 经典案例 财务管理系统(5)
; ——此文章摘自《Delphi 数据库开发经典案例解析》定价 ¥ 特价 ¥ 购买
根据实例介绍 科目表 是系统java财务管理系统代码的关键表 其他各表均与 科目表 通过 科目代码 字段进行多对一java财务管理系统代码的关联 系统共需要 张表 用途分别如表 所示
创建数据库
打开SQL Server企业管理器 新建一个数据库 名称为caiwubook 利用配书光盘中java财务管理系统代码的脚本代码 \Chap \建库脚本\ 财务管理系统实例程序 sql 文件创建数据库对象 完成数据库java财务管理系统代码的设计 也可以利用 \Chap \建库脚本\caiwubook bak 文件直接恢复数据库 这样数据库中存在初始的科目信息和系统参数数据数据
后面几小节java财务管理系统代码我们将列出几个重点的数据表的建库脚本 其他数据表的脚本请参考脚本文件
创建 科目表 数据表
创建 科目表 数据表的SQL脚本如下
CREATE TABLE [dbo] [ 科目表 ] (
[ 科目代码 ] [char] ( ) NOT NULL
[ 科目名称 ] [char] ( ) NULL
[ 助记码 ] [char] ( ) NULL
[ 科目类别 ] [char] ( ) NULL
[ 是否存货科目 ] [char] ( ) NULL
[ 余额方向 ] [char] ( ) NULL
[ 数量单位 ] [char] ( ) NULL
) ON [PRIMARY]
GO
创建 凭证表 和 分录表 数据表
创建 凭证表 数据表的SQL脚本如下
CREATE TABLE [dbo] [ 凭证表 ] (
[ 凭证编号 ] [char] ( ) NOT NULL
[ 会计期间 ] [int] NULL
[ 凭证字号 ] [char] ( ) NULL
[ 日期 ] [datetime] NULL
[ 附单据 ] [int] NULL
[ 制单 ] [char] ( ) NULL
[ 借方合计 ] [money] NULL
[ 贷方合计 ] [money] NULL
[ 过帐状态 ] [char] ( ) NULL
[ 凭证状态 ] [char] ( ) NULL
) ON [PRIMARY]
GO
创建 分录表 数据表的 SQL 脚本如下
CREATE TABLE [dbo] [ 分录表 ] (
[ 编号 ] [int] IDENTITY ( ) NOT NULL
[ 凭证编号 ] [char] ( ) NOT NULL
[ 摘要 ] [char] ( ) NULL
[ 科目代码 ] [char] ( ) NULL
[ 借方 ] [money] NULL
[ 贷方 ] [money] NULL
[ 数量 ] [int] NULL
[ 单价 ] [money] NULL
[ 结算方式 ] [char] ( ) NULL
[ 结算号 ] [int] NULL
[ 结算日期 ] [datetime] NULL
) ON [PRIMARY]
GO
创建其他关键数据表
以下是其他关键数据表的创建脚本 其他数据表可以参看配书光盘中的相关内容
CREATE TABLE [dbo] [ 科目余额表 ] (
[ 科目代码 ] [char] ( ) NULL
[ 期初借方余额 ] [money] NULL
[ 期初贷方余额 ] [money] NULL
[ 本期借方发生额 ] [money] NULL
[ 本期贷方发生额 ] [money] NULL
[ 本年借方累计发生额 ] [money] NULL
[ 本年贷方累计发生额 ] [money] NULL
[ 本期借方余额 ] [money] NULL
[ 本期贷方余额 ] [money] NULL
[ 最后结算分录 ] [int] NULL
[ 会计期间 ] [int] NULL
[ 余额方向 ] [char] ( ) NULL
[ 内部编号 ] [int] IDENTITY ( ) NOT NULL
) ON [PRIMARY]
GO
CREATE TABLE [dbo] [ 资产负债表 ] (
[ 会计期间 ] [int] NOT NULL
[ 现金及现金等价物 ] [money] NULL
[ 应收帐款 ] [money] NULL
[ 坏帐准备 ] [money] NULL
[ 应收帐款净值 ] [money] NULL
[ 流动资产总计 ] [money] NULL
[ 固定资产原值 ] [money] NULL
[ 累计折旧 ] [money] NULL
[ 固定资产总计 ] [money] NULL
[ 其他资产 ] [money] NULL
[ 资产总计 ] [money] NULL
[ 应付帐款 ] [money] NULL
[ 预收帐款 ] [money] NULL
[ 应付工资 ] [money] NULL
[ 其他负债 ] [money] NULL
[ 负债总计 ] [money] NULL
[ 实收资本 ] [money] NULL
[ 资本公积 ] [money] NULL
[ 赢余公积 ] [money] NULL
[ 未分配利润 ] [money] NULL
[ 所有者权益总计 ] [money] NULL
[ 负债及所有者权益总计 ] [money] NULL
) ON [PRIMARY]
GO
创建主键及外键等表约束
在查询分析器中通过如下代码创建数据表的主键及外键等表约束
主键 外键关联字段
ALTER TABLE [dbo] [ 科目表 ] WITH NOCHECK ADD
PRIMARY KEY CLUSTERED
(
[ 科目代码 ]
) ON [PRIMARY]
GO
ALTER TABLE [dbo] [ 凭证表 ] WITH NOCHECK ADD
CONSTRAINT [PK_ 凭证表 ] PRIMARY KEY CLUSTERED
(
[ 凭证编号 ]
) ON [PRIMARY]
GO
ALTER TABLE [dbo] [ 分录表 ] WITH NOCHECK ADD
CONSTRAINT [PK_ 分录表 ] PRIMARY KEY CLUSTERED
(
[ 编号 ]
) ON [PRIMARY]
GO
ALTER TABLE [dbo] [ 帐簿初始化表 ] WITH NOCHECK ADD
PRIMARY KEY CLUSTERED
(
[ 科目代码 ]
) ON [PRIMARY]
GO
ALTER TABLE [dbo] [ 本期汇总帐簿 ] WITH NOCHECK ADD
CONSTRAINT [PK_ 本期汇总帐簿 ] PRIMARY KEY CLUSTERED
(
[ 科目代码 ]
) ON [PRIMARY]
GO
ALTER TABLE [dbo] [ 分录表 ] ADD
CONSTRAINT [FK_ 分录表 _ 凭证表 ] FOREIGN KEY
(
[ 凭证编号 ]
) REFERENCES [dbo] [ 凭证表 ] (
[ 凭证编号 ]
)
CONSTRAINT [ 分录表 _ 科目代码 _fk] FOREIGN KEY
(
[ 科目代码 ]
) REFERENCES [dbo] [ 科目表 ] (
[ 科目代码 ]
)
GO
其他外键 主键等约束参看配书光盘脚本
lishixinzhi/Article/program/Delphi/201311/24743
Q3: 财务管理系统有i哪些功能(java)!
最重要的要有三个功能:支出、收入、转账。其他的一切操作都是这三个的子类。
最重要的报表有:资产负债表。现金流量表,利润表。
其他的都是浮云。这两项搞懂就可以横着走了。
Q4: java,在jsp中点击查询按钮后,怎么在对应的月分中算出各自的消费总额,我做的是财务管理系统
select sum(交易额),to_char(交易时间,'yyyy-mm') from table where 条件 group by to_char(交易时间,'yyyy-mm') order by to_char(交易时间,'yyyy-mm');
这样查询不可以吗
求总额的时候会用到各个类型的id 这是什么意思?
Q5: 求助:java课程设计 图书基本信息管理,越简单越好。
100分想让别人给你单独写一个程序应该是没人给你写的,还是参考一下别人类似的代码吧,我大二的时候写过一个系统:个人财务管理系统你拿去参考下吧
//登录类:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javawork.jdbc.*;
public class Login extends JFrame implements ActionListener{
public static void main(String ary[]){
new Login("home financial management system");
}
private JButton login=new JButton("登陆");
private JButton register=new JButton("注册");
private JButton cancel=new JButton("取消");
private JPanel panelsouth=new JPanel(new FlowLayout(new FlowLayout().CENTER));
private JPanel paneluser=new JPanel(new FlowLayout(new FlowLayout().CENTER));
private JPanel panelpassword=new JPanel(new FlowLayout(new FlowLayout().CENTER));
private JPanel panelcenter=new JPanel(new GridLayout(2,1));
private JLabel user=new JLabel("用户名: ");
private JLabel title=new JLabel(" 家庭财务管理系统");
private JLabel password=new JLabel("密 码: ");
private JTextField userT=new JTextField(10);
private JPasswordField passwordT=new JPasswordField(10);
public Login(String title){
super(title);
this.setResizable(false);
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){System.exit(0);}
});
this.setBounds(300,250,350,250);
frameLayout();
addListener();
this.setVisible(true);
}
public void frameLayout(){
panelsouth.add(login);
panelsouth.add(register);
panelsouth.add(cancel);
this.getContentPane().add(panelsouth,BorderLayout.SOUTH);
paneluser.add(user);
paneluser.add(userT);
panelpassword.add(password);
panelpassword.add(passwordT);
panelcenter.add(paneluser);
panelcenter.add(panelpassword);
this.getContentPane().add(panelcenter,BorderLayout.CENTER);
title.setFont(new Font("黑体",Font.BOLD,30));
this.getContentPane().add(title,BorderLayout.NORTH);
}
public void addListener(){
login.addActionListener(this);
cancel.addActionListener(this);
register.addActionListener(this);
passwordT.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==login||e.getSource()==passwordT){
String use=userT.getText();
String pass=new String(passwordT.getPassword());
Operate operate=new Operate();
if(operate.login(use, pass)){
new MainFrame(userT.getText());
this.setVisible(false);
}else{
JOptionPane.showMessageDialog(this, "用户名或密码不正确");
}
}
if(e.getSource()==register){
String info="";
String use=userT.getText();
String pass=new String(passwordT.getPassword());
Operate operate=new Operate();
if(operate.register(use, pass)){
info="注册成功";
}else{
info="注册失败";
}
JOptionPane.showMessageDialog(this, info);
}
if(e.getSource()==cancel){
System.exit(0);
}
}
}
//主柜架类:
import java.awt.event.*;
import javawork.bean.SysBean;
import javawork.jdbc.*;
import javax.swing.*;
import java.awt.*;
import java.util.Vector;
public class MainFrame extends JFrame implements ActionListener{
private boolean mode=true;
private JTable tabel=null;
private JPanel south=new JPanel(new FlowLayout(new FlowLayout().CENTER));
private JPanel north=new JPanel(new FlowLayout(new FlowLayout().CENTER));
private JLabel begin=new JLabel("从:");
private JLabel beginyear=new JLabel("年");
private JLabel beginmonth=new JLabel("月");
private JLabel beginday=new JLabel("日");
private JLabel end=new JLabel("到:");
private JLabel endyear=new JLabel("年");
private JLabel endmonth=new JLabel("月");
private JLabel endday=new JLabel("日");
private JComboBox beginyearB=new JComboBox();
private JComboBox beginmonthB=new JComboBox();
private JComboBox begindayB=new JComboBox();
private JComboBox endyearB=new JComboBox();
private JComboBox endmonthB=new JComboBox();
private JComboBox enddayB=new JComboBox();
private JButton add=new JButton("添加记录");
private JButton delete=new JButton("删除记录");
private JButton update=new JButton("更新记录");
private JButton cancel=new JButton("退出系统");
private JButton refresh=new JButton("刷新记录");
private JButton select=new JButton("查询记录");
String info[][]=null;
private String[] field={"ID","spending","epecificSpending","income","epecificIncome","total","journal","date"};
private String use=null;
public MainFrame(String name){
use=name;
this.setTitle("home financial management system");
this.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
this.setSize(700,500);
this.setResizable(false);
this.setLocationRelativeTo(null);
frameLayout();
addListener();
this.setVisible(true);
}
public void editnorth(){
for(int i=1950;i=2050;i++){
beginyearB.addItem(""+i);
endyearB.addItem(""+i);
}
for(int i=1;i=12;i++){
beginmonthB.addItem(""+i);
endmonthB.addItem(""+i);
}
north.add(begin); north.add(beginyear); north.add(beginyearB);
north.add(beginmonth);north.add(beginmonthB);
north.add(beginday); north.add(begindayB);
north.add(end); north.add(endyear); north.add(endyearB);
north.add(endmonth); north.add(endmonthB);
north.add(endday); north.add(enddayB); north.add(select);
}
VectorSysBean vector=new Operate().select(use);
public void editJTable(){
info=new String[200][8];
info[0]=new String[]{"","","","","","","",""};
for(int i=1;ivector.size()+1;i++){
info[i][0]=""+vector.get(i-1).getID();
info[i][1]=""+vector.get(i-1).getSpending();
info[i][2]=""+vector.get(i-1).getEpecificSpending();
info[i][3]=""+vector.get(i-1).getIncome();
info[i][4]=""+vector.get(i-1).getEpecificIncome();
info[i][5]=""+vector.get(i-1).getTotal();
info[i][6]=""+vector.get(i-1).getJournal();
info[i][7]=""+vector.get(i-1).getDate();
}
}
public void frameLayout(){
south.add(add);
south.add(delete);
south.add(update);
south.add(refresh);
south.add(cancel);
editnorth();
editJTable();
tabel=new JTable(info,field);
tabel.setAutoResizeMode(tabel.AUTO_RESIZE_SUBSEQUENT_COLUMNS);
this.getContentPane().add(new JScrollPane(tabel),BorderLayout.CENTER);
this.getContentPane().add(south,BorderLayout.SOUTH);
this.getContentPane().add(north,BorderLayout.NORTH);
}
public void addListener(){
add.addActionListener(this);
delete.addActionListener(this);
update.addActionListener(this);
cancel.addActionListener(this);
refresh.addActionListener(this);
select.addActionListener(this);
beginmonthB.addActionListener(this);
beginyearB.addActionListener(this);
endyearB.addActionListener(this);
endmonthB.addActionListener(this);
}
public void removeB(){
beginyearB.removeAll();
beginmonthB.removeAll();
begindayB.removeAll();
endyearB.removeAll();
endmonthB.removeAll();
enddayB.removeAll();
}
public void removeListener(){
add.removeActionListener(this);
delete.removeActionListener(this);
update.removeActionListener(this);
cancel.removeActionListener(this);
refresh.removeActionListener(this);
select.removeActionListener(this);
beginmonthB.removeActionListener(this);
endmonthB.removeActionListener(this);
beginyearB.removeActionListener(this);
endyearB.removeActionListener(this);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==add){
addSource();
}if(e.getSource()==delete){
deleteSource();
}if(e.getSource()==update){
updateSource();
}if(e.getSource()==select){
selectSource();
}if(e.getSource()==cancel){
System.exit(0);
}if(e.getSource()==refresh){
refreshSource();
}if(e.getSource()==beginmonthB||e.getSource()==beginyearB){
beginmonthBSource();
}if(e.getSource()==endmonthB||e.getSource()==endyearB){
endmonthBSource();
}
}
public void refreshSource(){
//beginyearB.removeAll();
//beginmonthB.removeAll();
//endyearB.removeAll();
//endmonthB.removeAll();
frameLayout();
this.setVisible(true);
}
public void deleteSource(){
String info="";
try{
int ID=Integer.parseInt(((String)tabel.getValueAt(0, 0)).trim());
if(new Operate().delete(ID, use)){
info="删除成功";
}else{
info="删除失败";
}
}catch(Exception e){
info="请正确输入数据";
}
JOptionPane.showMessageDialog(this,info);
}
public void selectSource(){
String byear=(String)beginyearB.getSelectedItem();
String bmonth=(String)beginmonthB.getSelectedItem();
String bday=(String)begindayB.getSelectedItem();
String eyear=(String)endyearB.getSelectedItem();
String emonth=(String)endmonthB.getSelectedItem();
String eday=(String)enddayB.getSelectedItem();
if("".equals(bday)){
bday="01";
}if("".equals(eday)){
eday="01";
}
String beginDate=byear+"-"+bmonth+"-"+bday;
String endDate=eyear+"-"+emonth+"-"+eday;
vector=new Operate().selectDay(use, java.sql.Date.valueOf(beginDate), java.sql.Date.valueOf(endDate));
refreshSource();
}
public void beginmonthBSource(){
int byear=Integer.parseInt((String)beginyearB.getSelectedItem());
int bmonth=Integer.parseInt((String)beginmonthB.getSelectedItem());
removeB();
boolean yn=false;
if((byear%4==0byear%100!=0)||(byear%100==0byear%400==0)){
yn=true;
}
for(int i=1;i=31;i++){
if(bmonth==2){
if(yn){
if(i=28){
begindayB.addItem(""+i);
}
}else{
if(i=29){
begindayB.addItem(""+i);
}
}
}else{
if(bmonth==1||bmonth==3||bmonth==5||bmonth==7||bmonth==8||bmonth==10||bmonth==12){
begindayB.addItem(""+i);
}else{
if(i=30){
begindayB.addItem(""+i);
}
}
}
}
}
public void endmonthBSource(){
int eyear=Integer.parseInt((String)endyearB.getSelectedItem());
int emonth=Integer.parseInt((String)endmonthB.getSelectedItem());
boolean yn=false;
removeB();
if((eyear%4==0eyear%100!=0)||(eyear%100==0eyear%400==0)){
yn=true;
}
for(int i=1;i=31;i++){
if(emonth==2){
if(yn){
if(i=28){
enddayB.addItem(""+i);
}
}
}else{
if(emonth==1||emonth==3||emonth==5||emonth==7||emonth==8||emonth==10||emonth==12){
enddayB.addItem(""+i);
}else{
if(i=30){
enddayB.addItem(""+i);
}
}
}
}
System.out.print("haah");
}
public void updateSource(){
String info=null;
boolean model=true;
String ID=((String)tabel.getValueAt(0,0)).trim();
String spend=((String)tabel.getValueAt(0,1)).trim();
String epecificSpending=(String)tabel.getValueAt(0, 2);
String come=((String)tabel.getValueAt(0, 3)).trim();
String epecificIncome=(String)tabel.getValueAt(0, 4);
String journal=(String)tabel.getValueAt(0, 6);
try{
int id=Integer.parseInt(ID);
float spending=Float.parseFloat(spend);
float income=Float.parseFloat(come);
tabel.setValueAt(""+(income-spending), 0, 4);
SysBean sysbean=new SysBean();
sysbean.setName(use);
sysbean.setID(id);
sysbean.setSpending(spending);
sysbean.setEpecificSpending(epecificSpending);
sysbean.setIncome(income);
sysbean.setEpecificIncome(epecificIncome);
sysbean.setJournal(journal);
model=new Operate().update(sysbean);
if(model){
info="更新成功!";
tabel.setValueAt("", 0,0);
tabel.setValueAt("", 0,1);
tabel.setValueAt("", 0,2);
tabel.setValueAt("", 0,3);
tabel.setValueAt("", 0,4);
tabel.setValueAt("", 0,5);
tabel.setValueAt("", 0,6);
}else{
info="更新失败!";
}
}catch(Exception o){
info="请正确输入数据!";
}
JOptionPane.showMessageDialog(this, info);
}
public void addSource(){
String info=null;
boolean model=true;
String spend=((String)tabel.getValueAt(0,1)).trim();
String epecificSpending=(String)tabel.getValueAt(0, 2);
String come=((String)tabel.getValueAt(0, 3)).trim();
String epecificIncome=(String)tabel.getValueAt(0, 4);
String journal=(String)tabel.getValueAt(0, 6);
try{
float spending=Float.parseFloat(spend);
float income=Float.parseFloat(come);
tabel.setValueAt(""+(income-spending), 0, 4);
SysBean sysbean=new SysBean();
sysbean.setName(use);
sysbean.setSpending(spending);
sysbean.setEpecificSpending(epecificSpending);
sysbean.setIncome(income);
sysbean.setEpecificIncome(epecificIncome);
sysbean.setJournal(journal);
model=new Operate().add(sysbean);
if(model){
info="添加成功!";
tabel.setValueAt("", 0,0);
tabel.setValueAt("", 0,1);
tabel.setValueAt("", 0,2);
tabel.setValueAt("", 0,3);
tabel.setValueAt("", 0,4);
tabel.setValueAt("", 0,5);
tabel.setValueAt("", 0,6);
}else{
info="添加失败!";
}
}catch(Exception o){
info="请正确输入数据!";
}
JOptionPane.showMessageDialog(this, info);
}
}
操作类:
import java.sql.*;
import java.util.*;
import javawork.bean.*;
public class Operate {
Connection conn=null;
PreparedStatement pstmt=null;
ResultSet rs=null;
String sql=null;
public VectorSysBean selectDay(String name,java.sql.Date beginDate,java.sql.Date endDate){
VectorSysBean vector=new VectorSysBean();
System.out.println("selectDay"+" "+beginDate+" "+endDate);
init();
sql="select * from info where name=? and date between ? and ?";
pstmt=DataBaseConnection.getpStmt(conn, sql);
try {
pstmt.setString(1, name);
pstmt.setDate(2, beginDate);
pstmt.setDate(3, endDate);
rs=pstmt.executeQuery();
while(rs.next()){
SysBean sysbean=new SysBean();
sysbean.setID(rs.getInt("ID"));
sysbean.setName(rs.getString("name"));
sysbean.setSpending(rs.getFloat("spending"));
sysbean.setEpecificSpending(rs.getString("epecificSpending"));
sysbean.setIncome(rs.getFloat("income"));
sysbean.setEpecificIncome(rs.getString("epecificIncome"));
sysbean.setTotal(rs.getFloat("total"));
sysbean.setJournal(rs.getString("journal"));
sysbean.setDate(rs.getDate("date"));
sysbean.setID(rs.getInt("ID"));
System.out.println("sysbean.getname= "+sysbean.getDate());
vector.add(sysbean);
}
} catch (SQLException e) {
e.printStackTrace();
}
close();
return vector;
}
public void init(){
conn=DataBaseConnection.getConn();
}
public void close(){
if(rs!=null){
DataBaseConnection.closeRs(rs);
}
DataBaseConnection.closePstmt(pstmt);
DataBaseConnection.closeConn(conn);
}
public boolean login(String user,String password){
init();
boolean login=false;
sql="select * from ruse where name=? and password=?";
pstmt=DataBaseConnection.getpStmt(conn, sql);
try {
pstmt.setString(1, user);
pstmt.setString(2, password);
rs=pstmt.executeQuery();
if(rs.next()){
login=true;
}
} catch (SQLException e) {
e.printStackTrace();
}
close();
return login;
}
public VectorSysBean select(String user){
VectorSysBean vector=new VectorSysBean();
init();
sql="select * from info where name=?";
pstmt=DataBaseConnection.getpStmt(conn, sql);
try {
pstmt.setString(1, user);
rs=pstmt.executeQuery();
while(rs.next()){
SysBean sysbean=new SysBean();
sysbean.setID(rs.getInt("ID"));
sysbean.setName(rs.getString("name"));
sysbean.setSpending(rs.getFloat("spending"));
sysbean.setEpecificSpending(rs.getString("epecificSpending"));
sysbean.setIncome(rs.getFloat("income"));
sysbean.setEpecificIncome(rs.getString("epecificIncome"));
sysbean.setTotal(rs.getFloat("total"));
sysbean.setJournal(rs.getString("journal"));
sysbean.setDate(rs.getDate("date"));
sysbean.setID(rs.getInt("ID"));
vector.add(sysbean);
}
} catch (SQLException e) {
e.printStackTrace();
}
close();
return vector;
}
public boolean add(SysBean sysbean){
boolean model=true;
init();
sql="insert into info(name,spending,epecificSpending,income," +
"epecificIncome,journal,date) values(?,?,?,?,?,?,?)";
pstmt=DataBaseConnection.getpStmt(conn, sql);
try {
pstmt.setString(1, sysbean.getName());
pstmt.setFloat(2, sysbean.getSpending());
pstmt.setString(3, sysbean.getEpecificSpending());
pstmt.setFloat(4, sysbean.getIncome());
pstmt.setString(5, sysbean.getEpecificIncome());
pstmt.setString(6, sysbean.getJournal());
pstmt.setDate(7, new java.sql.Date(new java.util.Date().getTime()));
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
model=false;
}
close();
return model;
}
public boolean delete(int ID,String use){
boolean model=true;
sql="delete from info where ID=? and name=?";
init();
pstmt=DataBaseConnection.getpStmt(conn, sql);
try {
pstmt.setInt(1, ID);
pstmt.setString(2, use);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
model=false;
}
close();
return model;
}
public boolean update(SysBean sysbean){
boolean model=true;
sql="update info set spending=?," +
"epecificSpending=?,income=?,epecificIncome=?,journal=? where ID=? and name=?";
init();
pstmt=DataBaseConnection.getpStmt(conn, sql);
try{
pstmt.setFloat(1, sysbean.getSpending());
pstmt.setString(2, sysbean.getEpecificSpending());
pstmt.setFloat(3, sysbean.getIncome());
pstmt.setString(4, sysbean.getEpecificIncome());
pstmt.setString(5, sysbean.getJournal());
pstmt.setInt(6, sysbean.getID());
pstmt.setString(7, sysbean.getName());
pstmt.executeUpdate();
}catch(Exception e){
model=false;
}
return model;
}
public boolean register(String wm,String password){
boolean model=true;
sql="insert into ruse values(?,?)";
init();
pstmt=DataBaseConnection.getpStmt(conn, sql);
try{
pstmt.setString(1,wm);
pstmt.setString(2,password);
pstmt.executeUpdate();
}catch(SQLException e){
model=false;
}
return model;
}
}
//数据库连接类:
import java.sql.*;
public class DataBaseConnection {
static{
//2005
//String DBDRIVER="com.microsoft.jdbc.sqlserver.SQLServerDriver";//2000
}
public static Connection getConn(){
String DBDRIVER="com.microsoft.sqlserver.jdbc.SQLServerDriver";
String DBURL="jdbc:sqlserver://localhost:1433;DatabaseName=cwgl";
Connection conn=null;
try {
Class.forName(DBDRIVER);
conn=DriverManager.getConnection(DBURL,"sa","1");
} catch (Exception e) {
e.printStackTrace();
}
return conn;
}
public static void closeConn(Connection conn){
try {
conn.close();
conn=null;
} catch (SQLException e) {
e.printStackTrace();
}
}
public static Statement getStmt(Connection conn){
Statement stmt=null;
try {
stmt=conn.createStatement();
} catch (SQLException e) {
e.printStackTrace();
}
return stmt;
}
public static void closeStmt(Statement stmt){
try {
stmt.close();
stmt=null;
} catch (SQLException e) {
e.printStackTrace();
}
}
public static PreparedStatement getpStmt(Connection conn,String sql){
PreparedStatement pStmt=null;
try {
pStmt=conn.prepareStatement(sql);
} catch (SQLException e) {
e.printStackTrace();
}
return pStmt;
}
public static void closePstmt(Statement pstmt){
try {
pstmt.close();
pstmt=null;
} catch (SQLException e) {
e.printStackTrace();
}
}
public static ResultSet getRs(Statement stmt,String sql){
ResultSet rs=null;
try {
rs=stmt.executeQuery(sql);
} catch (SQLException e) {
e.printStackTrace();
}
return rs;
}
public static void closeRs(ResultSet rs){
try {
rs.close();
rs=null;
} catch (SQLException e) {
e.printStackTrace();
}
}
}
关于java财务管理系统代码和java资产管理系统设计的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。








