Exemplo n.º 1
0
        /**
         *  Get Default Status Categpru for Client
         *	@param ctx context
         *	@return status category or null
         */
        public static MStatusCategory GetDefault(Ctx ctx)
        {
            int    AD_Client_ID = ctx.GetAD_Client_ID();
            String sql          = "SELECT * FROM R_StatusCategory "
                                  + "WHERE AD_Client_ID in (0,@AD_Client_ID) AND IsDefault='Y' "
                                  + "ORDER BY AD_Client_ID DESC";
            MStatusCategory retValue = null;
            //PreparedStatement pstmt = null;
            DataTable   dt  = null;
            IDataReader idr = null;

            try
            {
                SqlParameter[] param = new SqlParameter[1];
                param[0] = new SqlParameter("@AD_Client_ID", AD_Client_ID);

                //pstmt = DataBase.prepareStatement (sql, null);
                //pstmt.SetInt (1, AD_Client_ID);
                idr = DataBase.DB.ExecuteReader(sql, param);
                dt  = new DataTable();
                dt.Load(idr);
                idr.Close();
                foreach (DataRow dr in dt.Rows)
                {
                    retValue = new MStatusCategory(ctx, dr, null);
                }

                //pstmt.close ();
                //pstmt = null;
            }
            catch (Exception e)
            {
                if (idr != null)
                {
                    idr.Close();
                }
                _log.Log(Level.SEVERE, sql, e);
            }
            finally
            {
                dt = null;
                if (idr != null)
                {
                    idr.Close();
                }
            }
            //try
            //{
            //    if (pstmt != null)
            //        pstmt.close ();
            //    pstmt = null;
            //}
            //catch (Exception e)
            //{
            //    pstmt = null;
            //}
            return(retValue);
        }       //	GetDefault
Exemplo n.º 2
0
 /**
  *  Before Save
  *	@param newRecord new
  *	@return true
  */
 protected override Boolean BeforeSave(Boolean newRecord)
 {
     if (GetR_StatusCategory_ID() == 0)
     {
         MStatusCategory sc = MStatusCategory.GetDefault(GetCtx());
         if (sc != null && sc.GetR_StatusCategory_ID() != 0)
         {
             SetR_StatusCategory_ID(sc.GetR_StatusCategory_ID());
         }
     }
     return(true);
 }
Exemplo n.º 3
0
        /**
         *  Get Request Status Category from Cache
         *	@param ctx context
         *	@param R_StatusCategory_ID id
         *	@return RStatusCategory
         */
        public static MStatusCategory Get(Ctx ctx, int R_StatusCategory_ID)
        {
            int             key      = R_StatusCategory_ID;
            MStatusCategory retValue = (MStatusCategory)_cache[key];

            if (retValue != null)
            {
                return(retValue);
            }
            retValue = new MStatusCategory(ctx, R_StatusCategory_ID, null);
            if (retValue.Get_ID() != 0)
            {
                _cache.Add(key, retValue);
            }
            return(retValue);
        }       //	Get
Exemplo n.º 4
0
        }       //	GetDefault

        /**
         *  Get Default Status Categpru for Client
         *	@param ctx context
         *	@return status category or null
         */
        public static MStatusCategory CreateDefault(Ctx ctx)
        {
            int             AD_Client_ID = ctx.GetAD_Client_ID();
            MStatusCategory retValue     = new MStatusCategory(ctx, 0, null);

            retValue.SetClientOrg(AD_Client_ID, 0);
            retValue.SetName(Msg.GetMsg(ctx, "Standard", true));
            retValue.SetIsDefault(true);
            if (!retValue.Save())
            {
                return(null);
            }
            String sql = "UPDATE R_Status SET R_StatusCategory_ID=" + retValue.GetR_StatusCategory_ID()
                         + " WHERE R_StatusCategory_ID IS NULL AND AD_Client_ID=" + AD_Client_ID;
            int no = DataBase.DB.ExecuteQuery(sql, null, null);

            _log.Info("Default for AD_Client_ID=" + AD_Client_ID + " - Status #" + no);
            return(retValue);
        }
Exemplo n.º 5
0
 /**
  *  Get Default R_Status_ID for Type
  *	@return status or 0
  */
 public int GetDefaultR_Status_ID()
 {
     if (GetR_StatusCategory_ID() == 0)
     {
         MStatusCategory sc = MStatusCategory.GetDefault(GetCtx());
         if (sc == null)
         {
             sc = MStatusCategory.CreateDefault(GetCtx());
         }
         if (sc != null && sc.GetR_StatusCategory_ID() != 0)
         {
             SetR_StatusCategory_ID(sc.GetR_StatusCategory_ID());
         }
     }
     if (GetR_StatusCategory_ID() != 0)
     {
         MStatusCategory sc = MStatusCategory.Get(GetCtx(), GetR_StatusCategory_ID());
         return(sc.GetDefaultR_Status_ID());
     }
     return(0);
 }