📄 paymentdco.java
字号:
/*
* 创建日期 2006-12-20
* TODO
*/
package module.bill.dco;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.List;
import module.bill.dto.PaymentDto;
import conn.ConnSky;
public class PaymentDco {
public void getBill(String vendorId, List list){
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
PaymentDto dto = null;
String sql = "select bill_id, to_char(bill_date,'yyyy-mm-dd') billdate, to_char(bill_due_date,'yyyy-mm-dd') duedate," +
" bill_amount from table_bill where bill_paid_flag = 0 and vendor_id = ?";
try{
conn = ConnSky.getConn();
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1,Integer.parseInt(vendorId));
rs = pstmt.executeQuery();
while(rs.next()){
dto = new PaymentDto();
dto.setBillId(rs.getString("bill_id"));
dto.setDate(rs.getString("billdate"));
dto.setDueDate(rs.getString("duedate"));
dto.setAmount(rs.getString("bill_amount"));
list.add(dto);
}
}catch(Exception e){
e.printStackTrace();
}finally{
try{
rs.close();
pstmt.close();
conn.close();
}catch(Exception e){
e.printStackTrace();
}
}
}
public void payment(String [] billId){
Connection conn = null;
PreparedStatement pstmt = null;
int flag = 0;
String sql = "update table_bill set bill_paid_flag=1 where bill_id = ?";
try{
conn = ConnSky.getConn();
conn.setAutoCommit(false);
for (int i = 0; i < billId.length; i++){
pstmt = conn.prepareStatement(sql);
pstmt.setLong(1,Long.parseLong(billId[i]));
pstmt.addBatch();
}
pstmt.executeBatch();
conn.commit();
}catch(Exception e){
e.printStackTrace();
}finally{
try{
conn.setAutoCommit(true);
pstmt.close();
conn.close();
}catch(Exception e){
e.printStackTrace();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -