📄 gzxx.java
字号:
/*
* 创建日期 2006-2-22
*
* TODO 要更改此生成的文件的模板,请转至
* 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/
package com.zhang.operation;
import java.sql.*;
import com.zhang.common.getDBconn;
import java.util.*;
import com.zhang.bean.GongZi;
import com.zhang.form.*;
/**
* @author Administrator
*
* TODO 要更改此生成的类型注释的模板,请转至 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/
public class Gzxx {
private Connection conn = null;
private ResultSet rs = null;
private PreparedStatement pst = null;
private Statement st = null;
private ArrayList al = null;
private GongZi gongzi = null;
private String sql = "";
//private NewgzForm newgzform=null;
public ArrayList getGzxx() {
System.out.println("调用getgzxx()");
conn = new getDBconn().getDbConn();
sql = "select a.*,b.ygname from gongzi a,yginfo b where a.ygid=b.ygid";
try {
st = conn.createStatement();
rs = st.executeQuery(sql);
al = new ArrayList();
while (rs.next()) {
gongzi = new GongZi();
gongzi.setYgid(rs.getInt(1));
gongzi.setGongzi(rs.getInt(2));
gongzi.setJiangjin(rs.getInt(3));
gongzi.setYuefen(rs.getInt(4));
gongzi.setYgname(rs.getString(5));
al.add(gongzi);
}
rs.close();
st.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
return al;
}
public boolean addGz(NewgzForm newgzform) {
boolean b = false;
try {
conn = new getDBconn().getDbConn();
sql = "insert into gongzi values(?,?,?,?)";
pst = conn.prepareStatement(sql);
pst.setInt(1, newgzform.getYgid());
pst.setInt(2, newgzform.getGz());
pst.setInt(3, newgzform.getJj());
pst.setInt(4, newgzform.getYf());
pst.executeUpdate();
System.out.println("sql:" + sql);
b = true;
pst.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
return b;
}
public boolean updateGz(UpdategzForm updategzform) {
boolean b = false;
conn = new getDBconn().getDbConn();
sql = "update gongzi set gongzi=?,jiangjin=?,yuefen=? where ygid=?";
try {
pst = conn.prepareStatement(sql);
pst.setInt(1, updategzform.getGz());
pst.setInt(2, updategzform.getJj());
pst.setInt(3, updategzform.getYf());
pst.setInt(4, updategzform.getYgid());
pst.executeUpdate();
b = true;
System.out.println("sql:" + sql);
pst.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
return b;
}
public boolean deleteGz(int ygid) {
boolean b = false;
conn = new getDBconn().getDbConn();
sql = "delete from gongzi where ygid=" + ygid;
try {
st = conn.createStatement();
st.executeUpdate(sql);
b = true;
st.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
return b;
}
public GongZi getGzxxOne(int ygid) {
boolean b = false;
conn = new getDBconn().getDbConn();
gongzi = new GongZi();
sql = "select a.*,b.ygname from gongzi a,yginfo b where a.ygid=b.ygid and a.ygid="
+ ygid;
try {
st = conn.createStatement();
rs = st.executeQuery(sql);
rs.next();
gongzi.setYgid(rs.getInt(1));
gongzi.setGongzi(rs.getInt(2));
gongzi.setJiangjin(rs.getInt(3));
gongzi.setYuefen(rs.getInt(4));
gongzi.setYgname(rs.getString(5));
System.out.println("sql:" + sql);
System.out.println("name=" + gongzi.getYgname());
rs.close();
st.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
return gongzi;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -