当前位置: 代码迷 >> Web前端 >> 关于批量剔除
  详细解决方案

关于批量剔除

热度:130   发布时间:2012-09-06 10:37:01.0
关于批量删除
Dao层:
public void delmany(String ids) throws Exception {
String hql="";
PreparedStatement pstmt = null;
Connection con = SessionFactoryUtils.getDataSource(getHibernateTemplate().getSessionFactory()).getConnection();
String empIds= ids.substring(0,ids.length()-1);
hql = "delete from Employee where Employee_ID in ("+empIds+")";
pstmt = con.prepareStatement(hql);
pstmt.execute();
pstmt.close();
con.close();

}

对应数据库的表名
页面上全选框:
$("#all").click(function(){
if($(this).attr("checked")==true)
{
$(".check").attr("checked",true);

}
else{
$(".check").attr("checked",false);
}
});
$("#delmany").click(function(){
var ids="";
$(".check").each(function(){
if($(this).attr("checked")){
ids=ids+$(this).val()+",";
}

});
alert(ids);
if(ids==""){
alert("choose data");
return false;
}
if(confirm("sure delete?")){
alert(ids);
$.ajax({
url:"empjson!delmany.action",
type:"POST",
dataType:"json",
data:{"ids":ids},
success:function(){
alert("success");
window.location.href="emp!query.action";
},
error:function(){alert("error");}


});
}
});
  相关解决方案