📄 pxxx.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.PeiXun;
import com.zhang.form.*;
/**
* @author Administrator
*
* TODO 要更改此生成的类型注释的模板,请转至 窗口 - 首选项 - Java - 代码样式 - 代码模板
*/
public class Pxxx {
private Connection conn = null;
private ResultSet rs = null;
private PreparedStatement pst = null;
private Statement st = null;
private ArrayList al = null;
private PeiXun peixun = null;
private String sql = "";
private NewpxForm newpxform = null;
public ArrayList getPxxx() {
conn = new getDBconn().getDbConn();
sql = "select a.*,b.ygname from peixun a,yginfo b where a.ygid=b.ygid";
try {
st = conn.createStatement();
rs = st.executeQuery(sql);
al = new ArrayList();
while (rs.next()) {
peixun = new PeiXun();
peixun.setYgid(rs.getInt(1));
peixun.setPxdate(rs.getString(2));
peixun.setNeirong(rs.getString(3));
peixun.setYgname(rs.getString(4));
al.add(peixun);
}
rs.close();
st.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
return al;
}
public boolean addPx(String name, String date, String nr) {
System.out.println("调用addpx()");
boolean b = false;
newpxform = new NewpxForm();
conn = new getDBconn().getDbConn();
sql = "select ygid from yginfo where ygname='" + name + "'";
int ygid = 0;
try {
st = conn.createStatement();
rs = st.executeQuery(sql);
if (rs.next()) {
ygid = rs.getInt(1);
}
rs.close();
st.close();
sql = "insert into peixun values(" + ygid + ",?,?)";
pst = conn.prepareStatement(sql);
pst.setString(1, date);
pst.setString(2, nr);
pst.executeUpdate();
System.out.println("sql:" + sql);
b = true;
rs.close();
st.close();
pst.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
return b;
}
public boolean updatePx(UpdatepxForm updatepxform) {
boolean b = false;
conn = new getDBconn().getDbConn();
sql = "update peixun set qxdate=? ,neirong=? where ygid=?";
try {
pst = conn.prepareStatement(sql);
pst.setString(1, updatepxform.getDate());
pst.setString(2, updatepxform.getNr());
pst.executeUpdate();
b = true;
System.out.println("sql:" + sql);
pst.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
return b;
}
public boolean deletePx(int ygid) {
boolean b = false;
conn = new getDBconn().getDbConn();
sql = "delete from peixun where ygid=" + ygid;
try {
st = conn.createStatement();
st.executeUpdate(sql);
b = true;
st.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
return b;
}
public PeiXun getPxxxOne(int ygid) {
boolean b = false;
conn = new getDBconn().getDbConn();
peixun = new PeiXun();
sql = "select a.*,b.ygname from peixun a,yginfo b where a.ygid=b.ygid and a.ygid="
+ ygid;
try {
st = conn.createStatement();
rs = st.executeQuery(sql);
rs.next();
peixun.setYgid(rs.getInt(1));
peixun.setPxdate(rs.getString(2));
peixun.setNeirong(rs.getString(3));
peixun.setYgname(rs.getString(4));
System.out.println("sql:" + sql);
rs.close();
st.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
return peixun;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -