1 14 package org.compiere.model; 15 16 import java.util.*; 17 import java.sql.*; 18 19 import org.compiere.util.*; 20 21 27 public class MPeriod extends X_C_Period 28 { 29 public MPeriod (Properties ctx, int C_Period_ID) 30 { 31 super (ctx, C_Period_ID); 32 if (C_Period_ID == 0) 33 { 34 } 41 } 43 public MPeriod (Properties ctx, ResultSet rs) 44 { 45 super (ctx, rs); 46 } 48 private static Logger s_log = Logger.getCLogger (MPeriod.class); 49 50 51 52 53 54 55 61 public static MPeriod get (Properties ctx, Timestamp DateAcct) 62 { 63 MPeriod retValue = null; 64 int AD_Client_ID = Env.getContextAsInt(ctx, "#AD_Client_ID"); 65 String sql = "SELECT * " 66 + "FROM C_Period " 67 + "WHERE C_Year_ID IN " 68 + " (SELECT C_Year_ID FROM C_Year WHERE C_Calendar_ID =" 69 + " (SELECT C_Calendar_ID FROM AD_ClientInfo WHERE AD_Client_ID=?))" 70 + " AND ? BETWEEN StartDate AND EndDate" 71 + " AND PeriodType='S'"; 72 try 73 { 74 PreparedStatement pstmt = DB.prepareStatement(sql); 75 pstmt.setInt (1, AD_Client_ID); 76 pstmt.setTimestamp (2, DateAcct); 77 ResultSet rs = pstmt.executeQuery(); 78 if (rs.next()) 79 retValue = new MPeriod(ctx, rs); 80 rs.close(); 81 pstmt.close(); 82 } 83 catch (SQLException e) 84 { 85 s_log.error("get - DateAcct", e); 86 } 87 return retValue; 88 } 90 96 public static int getC_Period_ID (Properties ctx, Timestamp DateAcct) 97 { 98 MPeriod period = get (ctx, DateAcct); 99 if (period == null) 100 return 0; 101 return period.getC_Period_ID(); 102 } 104 } | Popular Tags |