最基本的增删改查功能的实现
因为这几个功能的实现不难,所有就Po个图,还有函数的实现,以及Button的监听事件处理。图书类别、图书都会实现这增删改查功能所以就放其中一个的吧。
UI
图书类别实体
private int id;
private String bookTypeName;
private String bookTypeDesc;
字符串工具类
/**
* 字符串工具类
* @author Amos0602
*
*/
public class StringUtil {
public static boolean isEmpty(String string) {
if (string==null||"".equals(string.trim())) {
return true;
}else {
return false;
}
}
public static boolean isNotEmpty(String string) {
if (string!=null && !"".equals(string.trim())) {
return true;
} else {
return false;
}
}
}
Dao层代码
/**
* 图书类别Dao类
* @author Amos0602
*
*/
public class BookTypeDao {
/**
* 图书类别增加
* @param connection
* @param bookType
* @return
* @throws Exception
*/
public int add(Connection connection,BookType bookType)throws Exception {
String sql="insert into t_bookType values(null,?,?)";
PreparedStatement pstmt=connection.prepareStatement(sql);
pstmt.setString(1, bookType.getBookTypeName());
pstmt.setString(2, bookType.getBookTypeDesc());
return pstmt.executeUpdate();
}
/**
* 删除图书类别
* @param connection
* @param id
* @return
* @throws Exception
*/
public int delete(Connection connection,String id)throws Exception {
String sql="delete from t_booktype where id=?";
PreparedStatement pstmt=connection.prepareStatement(sql);
pstmt.setString(1, id);
return pstmt.executeUpdate(