package com.qxglxt.DAO;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
import com.qxglxt.VO.Company_VO;
import com.qxglxt.VO.Groupmanager_VO;
import com.qxglxt.VO.Master_VO;
import com.qxglxt.VO.SectorVO;
import com.qxglxt.struts.form.MasterForm;
import com.qxglxt.util.LinkDB;
import org.apache.struts.util.LabelValueBean;
public class Master_daoImp {
public String selectCompanyName_Company(int id){
String name = null;
PreparedStatement ps = null;
ResultSet rs = null;
Connection con = null;
con = LinkDB.getConnection();
String sql = "select companyName from company where companyId = ?";
try{
ps = con.prepareStatement(sql);
ps.setInt(1, id);
rs = ps.executeQuery();
while(rs.next()){
name = rs.getString("companyName");
}
}catch(SQLException e){
e.printStackTrace();
}finally{
try{
rs.close();
ps.close();
con.close();
}catch(SQLException e){}
}
return name;
}
//根据人员ID查询其所在部门
public String selectsectorName_Sector(int id){
String name = null;
PreparedStatement ps = null;
ResultSet rs = null;
Connection con = null;
con = LinkDB.getConnection();
String sql = "select sectorName from sector where masterId = ?";
try{
ps = con.prepareStatement(sql);
ps.setInt(1, id);
rs = ps.executeQuery();
while(rs.next()){
name = rs.getString("sectorName");
}
}catch(SQLException e){
e.printStackTrace();
}finally{
try{
rs.close();
ps.close();
con.close();
}catch(SQLException e){}
}
return name;
}
public Vector selectMaster(){
Vector V = new Vector();
PreparedStatement ps = null;
ResultSet rs = null;
Connection con = null;
con = LinkDB.getConnection();
String sql ="select * from master";
try{
ps = con.prepareStatement(sql);
rs = ps.executeQuery();
while(rs.next()){
Master_VO vo = new Master_VO();
vo.setMasterId(rs.getInt("masterId"));
vo.setUserName(rs.getString("userName"));
vo.setPassword(rs.getString("password"));
vo.setTrueName(rs.getString("trueName"));
vo.setSex(rs.getInt("sex"));
vo.setCompanyId(rs.getInt("companyId"));
vo.setSectorId(rs.getInt("sectorId"));
vo.setPost(rs.getString("post"));
vo.setEmail(rs.getString("email"));
vo.setType(rs.getInt("type"));
V.add(vo);
}
}catch(SQLException e){
e.printStackTrace();
}finally{
try{
rs.close();
ps.close();
con.close();
}catch(SQLException e){}
}
return V;
}
public Vector<LabelValueBean> selectCompany(){
Vector<LabelValueBean> V = new Vector<LabelValueBean>();
PreparedStatement ps = null;
ResultSet rs = null;
Connection con = null;
con = LinkDB.getConnection();
String sql ="select companyId,companyName from company";
try{
ps = con.prepareStatement(sql);
rs = ps.executeQuery();
while(rs.next()){
// Company_VO vo = new Company_VO();
// vo.setCompanyId(rs.getInt("companyId"));
// vo.setCompanyName(rs.getString("companyName"));
V.add(new LabelValueBean(rs.getString("companyName"),rs.getString("companyId")));
}
}catch(SQLException e){
e.printStackTrace();
}finally{
try{
rs.close();
ps.close();
con.close();
}catch(SQLException e){}
}
return V;
}
//查询所有部门
public ResultSet selectSector(){
PreparedStatement ps = null;
ResultSet rs = null;
Connection con = null;
con = LinkDB.getConnection();
String sql ="select sectorId,sectorName,companyId from sector";
try{
ps = con.prepareStatement(sql);
//ps.setInt(1, id);
rs = ps.executeQuery();
}catch(SQLException e){
e.printStackTrace();
}
return rs;
}
//查询角色表,获得角色ID和角色名称
public List<LabelValueBean> selectGroupmanager(){
List<LabelValueBean> actionList=new ArrayList<LabelValueBean>();
PreparedStatement ps = null;
ResultSet rs = null;
Connection con = null;
con = LinkDB.getConnection();
String sql ="select groupId,groupName from groupmanager";
try{
ps = con.prepareStatement(sql);
rs = ps.executeQuery();
while(rs.next()){
actionList.add(new LabelValueBean(rs.getString("groupId"),rs.getString("groupName")));
}
}catch(SQLException e){
e.printStackTrace();
}finally{
try{
rs.close();
ps.close();
con.close();
}catch(SQLException e){}
}
return actionList;
}
//根据公司ID查询他所有的部门名称和ID
public Vector selectSectorNew(int id){
Vector V = new Vector();
PreparedStatement ps = null;
ResultSet rs = null;
Connection con = null;
con = LinkDB.getConnection();
String sql ="select sectorId,sectorName from sector where companyId = ?";
try{
ps = con.prepareStatement(sql);
ps.setInt(1, id);
rs = ps.executeQuery();
while(rs.next()){
SectorVO vo = new SectorVO();
vo.setSectorId(rs.getInt("sectorId"));
vo.setSectorName(rs.getString("sectorName"));
V.add(vo);
}
}catch(SQLException e){
e.printStackTrace();
}finally{
try{
rs.close();
ps.close();
con.close();
}catch(SQLException e){}
}
return V;
}
//根据公司ID查询公司名称
public String selectCompanyName_id(int id){
String name = null;
PreparedStatement ps = null;
ResultSet rs = null;
Connection con = null;
con = LinkDB.getConnection();
String sql ="select companyName from company where companyId =?";
try{
ps = con.prepareStatement(sql);
ps.setInt(1, id);
rs = ps.executeQuery();
while(rs.next()){
name = rs.getString("companyName");
}
}catch(SQLException e){
e.printStackTrace();
}finally{
try{
rs.close();
ps.close();
con.close();
}catch(SQLException e){}
}
return name;
}
//条件查询人员表
public Vector select(int id1,int id2){
Vector V= new Vector();
PreparedStatement ps = null;
ResultSet rs = null;
Connection con = null;
con = LinkDB.getConnection();
String sql ="select masterId,trueName,companyId,sectorId,sex,post,type from master where companyId=? and sectorId=?";
try{
ps = con.prepareStatement(sql);
ps.setInt(1, id1);
ps.setInt(2, id2);
rs = ps.executeQuery();
while(rs.next()){
Master_VO vo = new Master_VO();
vo.setMasterId(rs.getInt("masterId"));
vo.setTrueName(rs.getString("trueName"));
vo.setSex(rs.getInt("sex"));
vo.setCompanyId(rs.getInt("companyId"));
vo.setSectorId(rs.getInt("sectorId"));
vo.setPost(rs.getString("post"));
vo.setType(rs.getInt("type"));
V.add(vo);
}
}catch(SQLException e){
e.printStackTrace();
}finally{
try{
rs.close();
ps.close();
con.close();
}catch(SQLException e){}
}
return V;
}
//根据ID删除方法
public void deleteMaster(int id)throws SQLException{
PreparedStatement ps = null;
Connection con = null;
con = LinkDB.getConnection();
String sql = "delete master where masterId =?";
ps = con.prepareStatement(sql);
ps.setInt(1,id);
int count = ps.executeUpdate();
if (count > 0) {
//System.out.println("删除成功!");
} else {
//System.out.println("删除失败!");
}
con = LinkDB.getConnection();
String sql1 ="delete mastergroup where masterId =?";
ps=con.prepareStatement(sql1);
ps.setInt(1, id);
ps.execute();
}
public ResultSet queryMasterId(String userName)throws SQLException{
ResultSet rs = null;
Connection con = null;
PreparedStatement ps = null;
con = LinkDB.getConnection();
String sql ="select masterId,userName from master where userName='"+userName+"'";
ps = con.prepareStatement(sql);
rs = ps.executeQuery();
retu
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
权限管理系统(源码+数据库) (226个子文件)
Master_daoImp.class 12KB
Company_DAO.class 9KB
Group_daoImp.class 9KB
SectorDAO.class 9KB
SectorAction.class 8KB
Login_daoImp.class 7KB
AccessControllerFilter.class 7KB
MasterAction.class 7KB
CompanyAction.class 7KB
SectorVO.class 6KB
OperationLog_daoImp.class 6KB
GroupAction.class 5KB
ProclaimAction.class 4KB
SectorForm.class 4KB
MasterForm.class 4KB
LoginAction.class 4KB
Group_VO.class 3KB
CompanyFilter.class 3KB
Proclaim_daoImp.class 3KB
CompanyForm.class 3KB
Add_MasterFilter.class 3KB
Company_VO.class 3KB
ProclaimForm.class 2KB
MasterFilter.class 2KB
Master_VO.class 2KB
GroupForm.class 2KB
AddCompanyFilter.class 2KB
OperatorLogForm.class 2KB
OperatorLogAction.class 2KB
LoginFilter.class 2KB
Mastergroup_daoImp.class 2KB
OperationLog_VO.class 2KB
MyFilter.class 1KB
Proclaim_VO.class 1KB
test.class 1KB
LoginForm.class 1KB
TextForm.class 1KB
Groupmanager_VO.class 974B
LinkDB.class 944B
.classpath 1KB
style.css 2KB
style.css 2KB
css.css 2KB
css.css 2KB
css1.css 1KB
css1.css 1KB
css2.css 660B
css2.css 660B
Thumbs.db 77KB
Thumbs.db 77KB
Thumbs.db 12KB
Thumbs.db 12KB
topbg.gif 30KB
topbg.gif 30KB
toptbbg.gif 23KB
toptbbg.gif 23KB
toptdbg.gif 10KB
toptdbg.gif 10KB
out.gif 5KB
out.gif 5KB
daohang1.gif 2KB
daohang1.gif 2KB
daohang2.gif 2KB
daohang2.gif 2KB
dengluanniu.gif 935B
dengluanniu.gif 935B
chaxun.gif 871B
chaxun.gif 871B
edit.gif 540B
edit.gif 540B
look.gif 523B
look.gif 523B
dengluleft.gif 312B
dengluleft.gif 312B
dengluright.gif 310B
dengluright.gif 310B
add.gif 308B
add.gif 308B
bg11.gif 268B
bg11.gif 268B
admin_bg_2.gif 221B
admin_bg_2.gif 221B
denglubg.gif 163B
denglubg.gif 163B
daohangbg.gif 149B
daohangbg.gif 149B
del.gif 138B
del.gif 138B
left.html 12KB
right.html 2KB
err.html 1KB
successUpdate.html 1015B
success.html 992B
successDeltet.html 990B
top.html 872B
index.html 764B
struts.jar 531KB
antlr.jar 350KB
msbase.jar 280KB
commons-beanutils.jar 184KB
共 226 条
- 1
- 2
- 3
chongganq
- 粉丝: 0
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论1