1 14 package org.compiere.model; 15 16 import java.sql.*; 17 import java.util.*; 18 19 import org.compiere.util.*; 20 21 27 public class MTimeExpense extends X_S_TimeExpense 28 { 29 public MTimeExpense (Properties ctx, int S_TimeExpense_ID) 30 { 31 super (ctx, S_TimeExpense_ID); 32 if (S_TimeExpense_ID == 0) 33 { 34 setC_BPartner_ID (0); 35 setDateReport (new Timestamp (System.currentTimeMillis ())); 36 setDocumentNo (null); 37 setIsApproved (false); 38 setM_PriceList_ID (0); 39 setM_Warehouse_ID (0); 40 setProcessed (false); 41 setS_TimeExpense_ID (0); 42 } 43 } 45 public MTimeExpense (Properties ctx, ResultSet rs) 46 { 47 super (ctx, rs); 48 } 50 51 private int m_M_Locator_ID = 0; 52 53 54 public MTimeExpenseLine[] getLines() 55 { 56 ArrayList list = new ArrayList(); 57 String sql = "SELECT * FROM S_TimeExpenseLine WHERE S_TimeExpense_ID=? ORDER BY Line"; 59 PreparedStatement pstmt = null; 60 try 61 { 62 pstmt = DB.prepareStatement (sql); 63 pstmt.setInt (1, getS_TimeExpense_ID()); 64 ResultSet rs = pstmt.executeQuery (); 65 while (rs.next ()) 66 list.add(new MTimeExpenseLine(getCtx(), rs)); 67 rs.close (); 68 pstmt.close (); 69 pstmt = null; 70 } 71 catch (SQLException ex) 72 { 73 log.error ("getLines", ex); 74 } 75 try 76 { 77 if (pstmt != null) 78 pstmt.close (); 79 } 80 catch (SQLException ex1) 81 { 82 } 83 pstmt = null; 84 MTimeExpenseLine[] retValue = new MTimeExpenseLine[list.size()]; 86 list.toArray(retValue); 87 return retValue; 88 } 90 94 public int getM_Locator_ID() 95 { 96 if (m_M_Locator_ID != 0) 97 return m_M_Locator_ID; 98 String sql = "SELECT M_Locator_ID FROM M_Locator " 100 + "WHERE M_Warehouse_ID=? AND IsActive='Y' ORDER BY IsDefault DESC, Created"; 101 PreparedStatement pstmt = null; 102 try 103 { 104 pstmt = DB.prepareStatement (sql); 105 pstmt.setInt (1, getM_Warehouse_ID()); 106 ResultSet rs = pstmt.executeQuery (); 107 if (rs.next ()) 108 m_M_Locator_ID = rs.getInt(1); 109 rs.close (); 110 pstmt.close (); 111 pstmt = null; 112 } 113 catch (SQLException ex) 114 { 115 log.error ("getM_Locator_ID", ex); 116 } 117 try 118 { 119 if (pstmt != null) 120 pstmt.close (); 121 } 122 catch (SQLException ex1) 123 { 124 } 125 pstmt = null; 126 return m_M_Locator_ID; 128 } 130 } | Popular Tags |