oa_book_borrowbean.java
来自「java开发的办公系统 1.系统管理 (地区管理,部门管理,菜单管理,用户管理」· Java 代码 · 共 595 行 · 第 1/2 页
JAVA
595 行
return keyId; } /** * @author Administrator * @param 无 * @return (totalRecord):插入记录时当前记录的id号 * @see 获得插入记录时当前记录的id号 */ public int getTotalRecord(){ return totalRecord; } /** * @author Administrator * @param item:要添加的数据对象Oa_book_borrowItem * @return boolean:是否添加成功,如果添加成功返回true,否则返回false * @see 添加一条记录 */ public boolean addItem(Oa_book_borrowItem item){ try{ String sql="insert into "+T.OA_BOOK_BORROW+"("+ "category,"+ "book_id,"+ "borrow_departmentid,"+ "borrow_department_name,"+ "borrow_user,"+ "borrow_name,"+ "borrow_date,"+ "back_date,"+ "status,"+ "memo,"+ "approve_user,"+ "approve_name,"+ "approve_date)values("+ ""+item.getCategory()+","+ ""+item.getBook_id()+","+ ""+item.getBorrow_departmentid()+","+ "'"+item.getBorrow_department_name()+"',"+ "'"+item.getBorrow_user()+"',"+ "'"+item.getBorrow_name()+"',"+ "'"+item.getBorrow_date()+"',"+ "'"+item.getBack_date()+"',"+ ""+item.getStatus()+","+ "'"+item.getMemo()+"',"+ "'"+item.getApprove_user()+"',"+ "'"+item.getApprove_name()+"',"+ "'"+item.getApprove_date()+"')"; return executeUpdate(sql); }catch(Exception e){ System.out.println(e.toString()); return false; } finally{ DBclose(); } } /** * @author Administrator * @param item:要添加的数据对象UsersItem * @return keyId:当前添加记录的id号 否则返回 0 * @see 添加一条记录 */ public int addItemAndMaxId(Oa_book_borrowItem item){ try{ String sql="insert into "+T.OA_BOOK_BORROW+"("+ "category,"+ "book_id,"+ "borrow_departmentid,"+ "borrow_department_name,"+ "borrow_user,"+ "borrow_name,"+ "borrow_date,"+ "back_date,"+ "realback_date,"+ "status,"+ "memo,"+ "approve_user,"+ "approve_name,"+ "approve_date)values("+ ""+item.getCategory()+","+ ""+item.getBook_id()+","+ ""+item.getBorrow_departmentid()+","+ "'"+item.getBorrow_department_name()+"',"+ "'"+item.getBorrow_user()+"',"+ "'"+item.getBorrow_name()+"',"+ "'"+item.getBorrow_date()+"',"+ "'"+item.getBack_date()+"',"+ "'"+item.getRealback_date()+"',"+ ""+item.getStatus()+","+ "'"+item.getMemo()+"',"+ "'"+item.getApprove_user()+"',"+ "'"+item.getApprove_name()+"',"+ "'"+item.getApprove_date()+"')"; executeUpdate(sql); sql = "select max(id) as id from "+T.OA_BOOK_BORROW; rs = executeQuery(sql); if (rs.next()) { keyId = rs.getInt("id"); return keyId; } else return 0; }catch(SQLException e){ System.out.println(e.toString()); return 0; } finally{ DBclose(); } } /** * @author Administrator * @param item:要修改的数据对象Oa_book_borrowItem * @return boolean:如果修改成功返回true,否则返回false * @see 修改一条记录 */ public boolean updateItem(Oa_book_borrowItem item){ try{ String sql="update "+T.OA_BOOK_BORROW+" set "+ "category="+item.getCategory()+","+ "book_id="+item.getBook_id()+","+ "borrow_departmentid="+item.getBorrow_departmentid()+","+ "borrow_department_name='"+item.getBorrow_department_name()+"',"+ "borrow_user='"+item.getBorrow_user()+"',"+ "borrow_name='"+item.getBorrow_name()+"',"+ "borrow_date='"+item.getBorrow_date()+"',"+ "back_date='"+item.getBack_date()+"',"+ "realback_date='"+item.getRealback_date()+"',"+ "status="+item.getStatus()+","+ "memo='"+item.getMemo()+"' where id="+item.getId(); return executeUpdate(sql); }catch(Exception e){ System.out.println(e.toString()); return false; } finally{ DBclose(); } } /** * @author Administrator * @param item:要修改的数据对象Oa_book_borrowItem * @return boolean:如果修改成功返回true,否则返回false * @see 修改一条记录 */ public boolean updateStatus(Oa_book_borrowItem item){ try{ String sql="update "+T.OA_BOOK_BORROW+" set "+ "realback_date='"+item.getRealback_date()+"',"+ "status="+item.getStatus()+" where id in("+item.getId()+")"; return executeUpdate(sql); }catch(Exception e){ System.out.println(e.toString()); return false; } finally{ DBclose(); } } /** * @author Administrator * @param item:要修改的数据对象Oa_book_borrowItem * @return boolean:如果修改成功返回true,否则返回false * @see 修改一条记录 */ public boolean updateItemFile(Oa_book_borrowItem item){ try{ String sql="update "+T.OA_BOOK_BORROW+" set "+ "category="+item.getCategory()+","+ "book_id="+item.getBook_id()+","+ "borrow_departmentid="+item.getBorrow_departmentid()+","+ "borrow_department_name='"+item.getBorrow_department_name()+"',"+ "borrow_user='"+item.getBorrow_user()+"',"+ "borrow_name='"+item.getBorrow_name()+"',"+ "borrow_date='"+item.getBorrow_date()+"',"+ "back_date='"+item.getBack_date()+"',"+ "realback_date='"+item.getRealback_date()+"',"+ "status="+item.getStatus()+","+ "memo='"+item.getMemo()+"',"+ "approve_user='"+item.getApprove_user()+"',"+ "approve_name='"+item.getApprove_name()+"',"+ "approve_date='"+item.getApprove_date()+"' where id="+item.getId(); return executeUpdate(sql); }catch(Exception e){ System.out.println(e.toString()); return false; } finally{ DBclose(); } } /** * @author Administrator * @param item:要删除的数据对象Oa_book_borrowItem * @return boolean:如果删除成功返回true,否则返回false * @see 删除一条记录 */ public boolean removeItem(Oa_book_borrowItem item){ try{ String sql="delete from "+T.OA_BOOK_BORROW+" where id="+item.getId() ; return executeUpdate(sql); }catch(Exception e){ System.out.println(e.toString()); return false; } finally{ DBclose(); } } /** * @author Administrator * @param ids:要删除的记录的ids数组 * @return boolean:如果删除成功返回true,否则返回false * @see 批量删除条记录 */ public boolean removeItems(String[] ids) { try{ String sql="delete from "+T.OA_BOOK_BORROW+" where id in ("; String filter=""; for(int i=0;i<ids.length-1;i++){ filter+=ids[i]+","; } filter+=ids[ids.length-1]+")"; sql+=filter; return executeUpdate(sql); }catch(Exception e){ System.out.println(e.toString()); return false; } finally{ DBclose(); } } /** * @author Administrator * @param sql:要更新的sql 语句 * @return boolean:如果执行成功返回true,否则返回false * @see 执行更新一条sql 语句 */ public boolean executeUpdate(String sql){ try{ access.getConnection(); return access.executeUpdate(sql); } catch(Exception e){ System.out.println(e.toString()); return false; } } /** * @author Administrator * @param sql:要查询的sql 语句 * @return boolean:如果执行成功返回true,否则返回false * @see 执行查询一条sql 语句 */ public ResultSet executeQuery(String sql){ try { access.getConnection(); rs=access.executeQuery(sql); return rs; } catch(Exception e){ System.out.println(e.toString()); return null; } } /** * @author Administrator * @param 无 * @return 无 * @see 关闭数据库操作对象 */ public void DBclose(){ try { access.DBclose(rs); } catch(Exception e) { System.out.println(e.toString()); } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?