📄 cardgroupownerado.java
字号:
package com.x3408.card;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import com.x3408.database.CNProvider;
import com.x3408.employees.UserInfo;
public class CardGroupOwnerADO {
public static boolean groupOwnerInsert(CardGroupOwner cardGroupOwner){
Connection conn=null;
PreparedStatement pstat=null;
if(!cardGroupOwner.isValid()){
return false;
}
conn=CNProvider.getConnection();
if(conn==null){
return false;
}
try {
pstat=conn.prepareStatement("insert cardGroupOwner(cardGroup,employeeID)values(?,?)");
pstat.setString(1, cardGroupOwner.getCardGroup());
pstat.setString(2, cardGroupOwner.getEmployeeID());
pstat.executeUpdate();
return true;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
CNProvider.release(pstat,conn);
}
return false;
}
public static boolean groupOwnerUpdate(String cardGroup,CardGroupOwner cardGroupOwner){
Connection conn=null;
PreparedStatement pstat=null;
if(!cardGroupOwner.isValid()||cardGroup==null||"".equals(cardGroup.trim())||cardGroup.trim().length()>20){
return false;
}
conn=CNProvider.getConnection();
if(conn==null){
return false;
}
try {
pstat=conn.prepareStatement("update cardGroupOwner set cardGroup=? where cardID=?,employeeID=?");
pstat.setString(1, cardGroup.trim());
pstat.setString(2, cardGroupOwner.getCardGroup());
pstat.setString(3, cardGroupOwner.getEmployeeID());
pstat.executeUpdate();
return true;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
CNProvider.release(pstat,conn);
}
return false;
}
public static boolean groupOwnerDel(CardGroupOwner cardGroupOwner){
Connection conn=null;
PreparedStatement pstat=null;
if(!cardGroupOwner.isValid()){
return false;
}
conn=CNProvider.getConnection();
if(conn==null){
return false;
}
try {
pstat=conn.prepareStatement("delete from cardGroupOwner where cardID=?,employeeID=?");
pstat.setString(1, cardGroupOwner.getCardGroup());
pstat.setString(2, cardGroupOwner.getEmployeeID());
pstat.executeUpdate();
return true;
}catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
CNProvider.release(pstat,conn);
}
return false;
}
public static Vector groupOwnerQuery(String employeeID){
Connection conn=null;
PreparedStatement pstat=null;
ResultSet rs=null;
Vector<CardGroupOwner> groupOwnerList=null;
CardGroupOwner cardGroupOwner=null;
if(!UserInfo.employeeIDVaild(employeeID)){
return null;
}
conn=CNProvider.getConnection();
if(conn==null){
return null;
}
try {
pstat=conn.prepareStatement("select * from cardGroupOwner where employeeID=?");
pstat.setString(1, employeeID.trim());
rs=pstat.executeQuery();
groupOwnerList=new Vector<CardGroupOwner>();
while(rs.next()){
cardGroupOwner=new CardGroupOwner(rs.getString("cardGroup"),rs.getString("employeeID"));
groupOwnerList.addElement(cardGroupOwner);
}
return groupOwnerList.size()<1?null:groupOwnerList;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
CNProvider.release(rs,pstat,conn);
}
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -