@Override public int addBill(Bill bill) throws Exception { int rowAffect = 0; con = BaseDao.getConnection(); String sql = "insert into t_bill(productname,amount,price,pay,suppliername,billtime,saleworker) values(?,?,?,?,?,?,?)"; pstmt = con.prepareStatement(sql); pstmt.setString(1, bill.getproductName()); pstmt.setInt(2, bill.getAmount()); pstmt.setFloat(3, bill.getPrice()); pstmt.setFloat(4, bill.getPay()); pstmt.setString(5, bill.getsupplierName()); pstmt.setString(6, bill.getBilltime()); pstmt.setString(7, bill.getsaleworker()); rowAffect = pstmt.executeUpdate(); BaseDao.closeAll(null, pstmt, con); return rowAffect; }
@Override public int updateBill(Bill bill) throws Exception { int rowAffects = 0; con = BaseDao.getConnection(); String sql = "update t_bill set productname = ?,suppliername=?,amount=?,price=?,pay=?,billtime=?,saleworker=? where bill_id=?"; pstmt = con.prepareStatement(sql); pstmt.setString(1, bill.getproductName()); pstmt.setString(2, bill.getsupplierName()); pstmt.setInt(3, bill.getAmount()); pstmt.setFloat(4, bill.getPrice()); pstmt.setFloat(5, bill.getPay()); pstmt.setString(6, bill.getBilltime()); pstmt.setString(7, bill.getsaleworker()); pstmt.setInt(8, bill.getBill_id()); rowAffects = pstmt.executeUpdate(); BaseDao.closeAll(null, pstmt, con); return rowAffects; }