Beispiel #1
0
        /**
         *  Is R_Status_ID Valid
         *	@param R_Status_ID id
         *	@return true if valid
         */
        public bool IsR_Status_IDValid(int R_Status_ID)
        {
            if (R_Status_ID == 0)
            {
                return(true);
            }

            _Status = MStatus.Get(GetCtx(), R_Status_ID);
            int R_StatusCategory_ID = _Status.GetR_StatusCategory_ID();
            //
            int R_RequestType_ID = GetR_RequestType_ID();

            if (R_RequestType_ID == 0)
            {
                log.Warning("No Client Request Type");
                return(false);
            }
            MRequestType rt = MRequestType.Get(GetCtx(), R_RequestType_ID);

            if (rt.GetR_StatusCategory_ID() != R_StatusCategory_ID)
            {
                log.Warning("Status Category different - Status("
                            + R_StatusCategory_ID + ") <> RequestType("
                            + rt.GetR_StatusCategory_ID() + ")");
                return(false);
            }
            return(true);
        }
Beispiel #2
0
        }       //	Get

        /**
         *  Get Default Request Status
         *	@param ctx context
         *	@param R_RequestType_ID request type
         *	@return Request Type
         */
        public static MStatus GetDefault(Ctx ctx, int R_RequestType_ID)
        {
            int     key      = R_RequestType_ID;
            MStatus retValue = (MStatus)_cacheDefault[key];

            if (retValue != null)
            {
                return(retValue);
            }
            //	Get New
            String sql = "SELECT * FROM R_Status s "
                         + "WHERE EXISTS (SELECT * FROM R_RequestType rt "
                         + "WHERE rt.R_StatusCategory_ID=s.R_StatusCategory_ID"
                         + " AND rt.R_RequestType_ID=@R_RequestType_ID)"
                         + " AND IsDefault='Y' "
                         + "ORDER BY SeqNo";
            //PreparedStatement pstmt = null;
            DataTable   dt  = null;
            IDataReader idr = null;

            try
            {
                //	pstmt = DataBase.prepareStatement (sql, null);
                //	pstmt.SetInt(1, R_RequestType_ID);
                SqlParameter[] param = new SqlParameter[1];
                param[0] = new SqlParameter("@R_RequestType_ID", R_RequestType_ID);
                idr      = DataBase.DB.ExecuteReader(sql, param);
                dt       = new DataTable();
                dt.Load(idr);
                idr.Close();
                //ResultSet dr = pstmt.executeQuery ();
                foreach (DataRow dr in dt.Rows)
                {
                    retValue = new MStatus(ctx, dr, null);
                }
            }
            catch (Exception ex)
            {
                if (idr != null)
                {
                    idr.Close();
                }
                _log.Log(Level.SEVERE, sql, ex);
            }
            finally
            {
                if (idr != null)
                {
                    idr.Close();
                }
                dt = null;
            }
            if (retValue != null)
            {
                _cacheDefault.Add(key, retValue);
            }
            return(retValue);
        }       //	GetDefault
Beispiel #3
0
 /**
  *  Get Status
  *	@return status or null
  */
 public new MStatus GetStatus()
 {
     if (GetR_Status_ID() == 0)
     {
         _Status = null;
     }
     else if (_Status == null ||
              _Status.GetR_Status_ID() != GetR_Status_ID())
     {
         _Status = MStatus.Get(GetCtx(), GetR_Status_ID());
     }
     return(_Status);
 }
Beispiel #4
0
        /**
         *  Get Request Status (cached)
         *	@param ctx context
         *	@param R_Status_ID id
         *	@return Request Status or null
         */
        public static MStatus Get(Ctx ctx, int R_Status_ID)
        {
            if (R_Status_ID == 0)
            {
                return(null);
            }
            int     key      = R_Status_ID;
            MStatus retValue = (MStatus)_cache[key];

            if (retValue == null)
            {
                retValue = new MStatus(ctx, R_Status_ID, null);
                _cache.Add(key, retValue);
            }
            return(retValue);
        }       //	Get
Beispiel #5
0
        }       //	GetDefault

        /**
         *  Get Closed Status
         *	@param ctx context
         *	@return Request Type
         */
        public static MStatus[] GetClosed(Ctx ctx)
        {
            int    AD_Client_ID = ctx.GetAD_Client_ID();
            String sql          = "SELECT * FROM R_Status "
                                  + "WHERE AD_Client_ID=" + AD_Client_ID + " AND IsActive='Y' AND IsClosed='Y' "
                                  + "ORDER BY Value";
            List <MStatus> list = new List <MStatus>();
            IDataReader    idr  = null;
            DataTable      dt   = null;

            try
            {
                idr = DataBase.DB.ExecuteReader(sql, null, null);
                dt  = new DataTable();
                dt.Load(idr);
                idr.Close();
                foreach (DataRow dr in dt.Rows)
                {
                    list.Add(new MStatus(ctx, dr, null));
                }
            }
            catch (Exception ex)
            {
                if (idr != null)
                {
                    idr.Close();
                }
                _log.Severe(ex.ToString());
            }
            finally {
                if (idr != null)
                {
                    idr.Close();
                }
                dt = null;
            }

            MStatus[] retValue = new MStatus[list.Count];
            retValue = list.ToArray();
            return(retValue);
        }