//我想用dwr做 部门,岗位,人员组合查询 可是老是不成功啊,高手帮我看看下面是那里有错误啊!
//这是数据表
用户表 userInfo
User_ID User_Name User_Sex Belong_Dept Belong_Stat 等等字段
001 张三 女 质量管理部 质量分析员
002 李四 男 财务部 会计师 部门表 departmentInfo
Dept_ID Dept_Name 等等
111 质量管理部
333 财务部 岗位表 stationInfo
Station_ID Station_Name B_Dept_ID 等等
222 质量分析员 质量管理部
0123 会计师 财务部 //这个是js文件,
function together_search(){
var deptId = document.getElementById("dept").value; //从页面得到的查询条件
var statId= document.getElementById("stat").value;//从页面得到的查询条件
var name=document.getElementById("p_Name").value;//从页面得到的查询条件 var sqlUserInfo,sqlDept,sqlStat; if(null!=deptId && ""!=deptId )
{
sqlDept="(select * from departmentInfo where Dept_ID = '"+ deptId +"')";
}else
{
sqlDept = "departmentInfo";
}
if(null!=statId && ""!=statId)
{
sqlStat="(select * from stationInfo where Station_ID = '"+ statId +"') ";
}else
{
sqlStat="stationInfo ";
}
if(null!=name && ""!=name)
{
sqlUserInfo="(select * from userInfo where User_Name= '"+ name +"') ";
}else
{
sqlUserInfo = "userInfo ";
}
UserLogic.toge_search(u_c,sqlUserInfo,sqlDept,sqlStat);//UserLogic是类名,调用java方法toge_search()
}
function u_c(data){//返回函数
if(data.length>1){
alert("ddddddd"); }
}
//这个是java文件里面UserLogic类的toge_search()方法 public Hashtable[] toge_search(String sqlUserInfo,String sqlDept,String sqlStat){
Hashtable[] station_ht = null;
String sql = "";
//我像如下写了这个组合但是不成功,从来没有写过组合,不知道这里该怎么写才对,跪求高手帮忙啊,在线狂等
sql = "select u.*,Dept_ID as Dept_Name,Station_ID as Station_Name"+ "from "+ sqlUserInfo +" u ,"+ sqlDept +" d,"+ sqlStat +" s "+ "where u.Belong_Stat = s.Station_ID and u.Belong_Dept = d.Dept_ID"; station_ht = Dao.executeQuery(sql);
System.out.print(sql);
return station_ht;
}
//这是数据表
用户表 userInfo
User_ID User_Name User_Sex Belong_Dept Belong_Stat 等等字段
001 张三 女 质量管理部 质量分析员
002 李四 男 财务部 会计师 部门表 departmentInfo
Dept_ID Dept_Name 等等
111 质量管理部
333 财务部 岗位表 stationInfo
Station_ID Station_Name B_Dept_ID 等等
222 质量分析员 质量管理部
0123 会计师 财务部 //这个是js文件,
function together_search(){
var deptId = document.getElementById("dept").value; //从页面得到的查询条件
var statId= document.getElementById("stat").value;//从页面得到的查询条件
var name=document.getElementById("p_Name").value;//从页面得到的查询条件 var sqlUserInfo,sqlDept,sqlStat; if(null!=deptId && ""!=deptId )
{
sqlDept="(select * from departmentInfo where Dept_ID = '"+ deptId +"')";
}else
{
sqlDept = "departmentInfo";
}
if(null!=statId && ""!=statId)
{
sqlStat="(select * from stationInfo where Station_ID = '"+ statId +"') ";
}else
{
sqlStat="stationInfo ";
}
if(null!=name && ""!=name)
{
sqlUserInfo="(select * from userInfo where User_Name= '"+ name +"') ";
}else
{
sqlUserInfo = "userInfo ";
}
UserLogic.toge_search(u_c,sqlUserInfo,sqlDept,sqlStat);//UserLogic是类名,调用java方法toge_search()
}
function u_c(data){//返回函数
if(data.length>1){
alert("ddddddd"); }
}
//这个是java文件里面UserLogic类的toge_search()方法 public Hashtable[] toge_search(String sqlUserInfo,String sqlDept,String sqlStat){
Hashtable[] station_ht = null;
String sql = "";
//我像如下写了这个组合但是不成功,从来没有写过组合,不知道这里该怎么写才对,跪求高手帮忙啊,在线狂等
sql = "select u.*,Dept_ID as Dept_Name,Station_ID as Station_Name"+ "from "+ sqlUserInfo +" u ,"+ sqlDept +" d,"+ sqlStat +" s "+ "where u.Belong_Stat = s.Station_ID and u.Belong_Dept = d.Dept_ID"; station_ht = Dao.executeQuery(sql);
System.out.print(sql);
return station_ht;
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货