重点:
我们今天用easyui来实现增删改查
我们今天要用到的布局有datagrid,dialog,form布局,用这几个控件完成一个简单的布局
第二个重点:
1.实现前后端的分离
我们要如何实现呢,接下来
思路:
首先利用form 和dialog进行布局,然后利用datadrid进行数据的回显以及传递数据操作所需要的值,然后我们利用修改传递过来的值进行增删改查。
UserDao
package com.liuxia.dao;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
public class UserDao extends JsonBaseDao {
public List<Map<String, Object>> list(Map<String, String[]> paMap,PageBean pageBean) throws InstantiationException, IllegalAccessException, SQLException{
String sql ="select * from t_easyui_user_version2 where true ";
String uid= JsonUtils.getParamVal(paMap,"uid");
String upwd= JsonUtils.getParamVal(paMap,"upwd");
if(StringUtils.isNotBlank(uid)) {
sql +=" and uid = "+uid;
}
if(StringUtils.isNotBlank(upwd)) {
sql +=" and upwd ="+upwd;
}
return super.executeQuery(sql, pageBean);
}
/**
* 修改
* @param paMap
* @return
* @throws NoSuchFieldException
* @throws SecurityException
* @throws IllegalArgumentException
* @throws IllegalAccessException
* @throws SQLException
*/
public int edit(Map<String, String[]> paMap) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, SQLException {
String sql= "update t_easyui_user_version2 set uid=?,uname=?,upwd=? where serialno=?";
return super.executeUpdate(sql,new String[] {"uid","uname","upwd","SerialNo"}, paMap);
}
/**
* 删除
* @param paMap
* @return
* @throws NoSuchFieldException
* @throws SecurityException
* @throws IllegalArgumentException
* @throws IllegalAccessException
* @throws SQLException
*/
public int del(Map<String, String[]> paMap) throws Exception, SecurityException, IllegalArgumentException, IllegalAccessException, SQLException {
String sql ="delete from t_easyui_user_version2 where SerialNo =? ";
return super.executeUpdate(sql, new String[] {"SerialNo"} , paMap);
}
/**
* 添加
* @param paMap
* @return
* @throws Exception
* @throws SecurityException
* @throws IllegalArgumentException