/** * Get Contact Interest * @param ctx context * @param R_InterestArea_ID interest ares * @param AD_User_ID user * @param isActive create as active * @param trxName transaction * @return Contact Interest */ public static MContactInterest Get(Ctx ctx, int R_InterestArea_ID, int AD_User_ID, Boolean isActive, Trx trxName) { MContactInterest retValue = null; String sql = "SELECT * FROM R_ContactInterest " + "WHERE R_InterestArea_ID=@R_InterestArea_ID AND AD_User_ID=@AD_User_ID"; DataTable dt = null; IDataReader idr = null; try { SqlParameter[] param = new SqlParameter[2]; param[0] = new SqlParameter("@R_InterestArea_ID", R_InterestArea_ID); param[1] = new SqlParameter("@AD_User_ID", AD_User_ID); idr = DataBase.DB.ExecuteReader(sql, param); dt = new DataTable(); dt.Load(idr); idr.Close(); foreach (DataRow dr in dt.Rows) { retValue = new MContactInterest(ctx, dr, trxName); break; } } catch (Exception e) { if (idr != null) { idr.Close(); } _log.Log(Level.SEVERE, sql, e); } finally { dt = null; } // New if (retValue == null) { retValue = new MContactInterest(ctx, R_InterestArea_ID, AD_User_ID, isActive, trxName); _log.Fine("NOT found - " + retValue); } else { _log.Fine("Found - " + retValue); } return(retValue); }
/** * After Save * @param newRecord new * @param success success * @returnsuccess */ protected override bool AfterSave(bool newRecord, bool success) { if (!success) { return(success); } // Create Contact Interest if (GetAD_User_ID() != 0 && GetR_InterestArea_ID() != 0 && (Is_ValueChanged("AD_User_ID") || Is_ValueChanged("R_InterestArea_ID"))) { MContactInterest ci = MContactInterest.Get(GetCtx(), GetR_InterestArea_ID(), GetAD_User_ID(), true, Get_TrxName()); ci.Save(); // don't subscribe or re-activate } return(true); }
/** Set Subscription info "constructor". * Create inactive Subscription * @param AD_User_ID contact */ public void SetSubscriptionInfo(int AD_User_ID) { _AD_User_ID = AD_User_ID; _ci = MContactInterest.Get(GetCtx(), GetR_InterestArea_ID(), AD_User_ID, false, Get_TrxName()); }