Beispiel #1
0
 /// <summary>
 /// Standard Constructors
 /// </summary>
 /// <param name="locator"></param>
 /// <param name="M_Product_ID"></param>
 /// <param name="M_AttributeSetInstance_ID"></param>
 /// <param name="type"></param>
 public MStorageDetail(MLocator locator, int M_Product_ID,
                       int M_AttributeSetInstance_ID, String type)
     : this(locator.GetCtx(), 0, locator.Get_TrxName())
 {
     SetClientOrg(locator);
     SetM_Locator_ID(locator.GetM_Locator_ID());
     SetM_Product_ID(M_Product_ID);
     SetM_AttributeSetInstance_ID(M_AttributeSetInstance_ID);
     SetQtyType(type);//type.GetValue()
     SetQty(Env.ZERO);
 }
        /// <summary>
        /// Get Data Direct from Table
        /// </summary>
        /// <param name="keyValue">integer key value</param>
        /// <param name="saveInCache">saveInCache save in cache</param>
        /// <param name="trxName"></param>
        /// <returns></returns>
        public NamePair GetDirect(Object keyValue, bool saveInCache, Trx trxName)
        {
            MLocator loc = GetMLocator(keyValue, trxName);

            if (loc == null)
            {
                return(null);
            }
            //
            int         key      = loc.GetM_Locator_ID();
            KeyNamePair retValue = new KeyNamePair(key, loc.ToString());

            if (saveInCache)
            {
                _lookup.Add(key, retValue);
            }
            return(retValue);
        }
Beispiel #3
0
        /// <summary>
        /// Constructor called from BOM Drop
        /// </summary>
        /// <param name="workorder"></param>
        /// <param name="workorderoperation"></param>
        /// <param name="product"></param>
        /// <param name="QtyRequired"></param>
        /// <param name="SupplyType"></param>
        /// <param name="locator"></param>
        public MVAMFGMWorkOrderComponent(ViennaAdvantage.Model.MVAMFGMWorkOrder workorder, MVAMFGMWorkOrderOperation workorderoperation, ViennaAdvantage.Model.MProduct product, Decimal QtyRequired,
                                         String SupplyType, int M_AttributeSetInstance_ID, VAdvantage.Model.MLocator locator)
            : this(workorderoperation.GetCtx(), 0, workorderoperation.Get_TrxName())
        {
            if (workorderoperation.Get_ID() == 0)
            {
                throw new Exception("Header not saved");
            }
            SetVAMFG_M_WorkOrderOperation_ID(workorderoperation.GetVAMFG_M_WorkOrderOperation_ID());    //	parent
            SetM_Product_ID(product.GetM_Product_ID());
            SetC_UOM_ID(product.GetC_UOM_ID());
            SetVAMFG_QtyRequired(QtyRequired);
            SetVAMFG_SupplyType(SupplyType);
            // Changes done b y Vivek Kumar assigned by Mukesh on 16/11/2017
            // Changes done to save AttributesetInstance at Work Order component
            SetM_AttributeSetInstance_ID(M_AttributeSetInstance_ID);
            if (locator != null)
            {
                SetM_Locator_ID(locator.GetM_Locator_ID());
            }

            SetWorkOrder(workorder);
        }
        /// <summary>
        ///Load Lookup
        /// </summary>
        private void Load()
        {
            //	log.config("MLocatorLookup Loader.run " + m_AD_Column_ID);
            //	Set Info	- see VLocator.actionText

            int  only_Warehouse_ID = GetOnly_Warehouse_ID();
            int  only_Product_ID   = GetOnly_Product_ID();
            bool?only_IsSOTrx      = IsOnly_Outgoing();
            //int sqlParaCount = 0;
            StringBuilder sql = new StringBuilder("SELECT * FROM M_Locator ")
                                .Append(" WHERE IsActive='Y'");

            if (only_Warehouse_ID != 0)
            {
                sql.Append(" AND M_Warehouse_ID=@w");
            }
            if (only_Product_ID != 0)
            {
                sql.Append(" AND (IsDefault='Y' ");                 //	Default Locator
                //	Something already stored
                sql.Append("OR EXISTS (SELECT * FROM M_Storage s ") //	Storage Locator
                .Append("WHERE s.M_Locator_ID=M_Locator.M_Locator_ID AND s.M_Product_ID=@p)");

                if (only_IsSOTrx == null || !only_IsSOTrx.Value)
                {
                    //	Default Product
                    sql.Append("OR EXISTS (SELECT * FROM M_Product p ") //	Default Product Locator
                    .Append("WHERE p.M_Locator_ID=M_Locator.M_Locator_ID AND p.M_Product_ID=@p)");
                    //	Product Locators
                    sql.Append("OR EXISTS (SELECT * FROM M_ProductLocator pl ") //	Product Locator
                    .Append("WHERE pl.M_Locator_ID=M_Locator.M_Locator_ID AND pl.M_Product_ID=@p)");
                    // No locators defined for the warehouse
                    sql.Append("OR 0 = (SELECT COUNT(*) ");
                    sql.Append("FROM M_ProductLocator pl");
                    sql.Append(" INNER JOIN M_Locator l2 ON (pl.M_Locator_ID=l2.M_Locator_ID) ");
                    sql.Append("WHERE pl.M_Product_ID=@p AND l2.M_Warehouse_ID=M_Locator.M_Warehouse_ID )");
                }
                sql.Append(" ) ");
            }
            String finalSql = MRole.GetDefault((Context)GetCtx(), false).AddAccessSQL(
                sql.ToString(), "M_Locator", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);

            //if (_loader.ThreadState == ThreadState.Suspended)
            //{
            //    log.log(Level.SEVERE, "Interrupted");
            //    return;
            //}
            //	Reset
            _lookup.Clear();
            int rows = 0;

            try
            {
                List <System.Data.SqlClient.SqlParameter> para = new List <System.Data.SqlClient.SqlParameter>();

                // int index = 1;
                if (only_Warehouse_ID != 0)
                {
                    //	pstmt.setInt(index++, only_Warehouse_ID);
                    para.Add(new System.Data.SqlClient.SqlParameter("@w", only_Warehouse_ID));
                }
                if (only_Product_ID != 0)
                {
                    para.Add(new System.Data.SqlClient.SqlParameter("@p", only_Product_ID));
                }
                DataSet ds = DataBase.DB.ExecuteDataset(finalSql, para.ToArray(), null);
                //
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    //	Max out
                    if (rows++ > _maxRows)
                    {
                        log.Warning("Over Max Rows - " + rows);
                        break;
                    }
                    MLocator    loc          = new MLocator((Context)GetCtx(), dr, null);
                    int         M_Locator_ID = loc.GetM_Locator_ID();
                    KeyNamePair pp           = new KeyNamePair(M_Locator_ID, loc.ToString());
                    _lookup.Add(M_Locator_ID, pp);
                }
                ds.Dispose();
                ds = null;
            }
            catch (Exception e)
            {
                log.Log(Level.SEVERE, finalSql, e);
            }
            log.Fine("Complete #" + _lookup.Count);
            if (_lookup.Count == 0)
            {
                log.Finer(finalSql);
            }
        }