/// <summary> /// Get all Storages for Product /// </summary> /// <param name="ctx"></param> /// <param name="M_Product_ID"></param> /// <param name="M_Locator_ID"></param> /// <param name="qtyType"></param> /// <param name="isFIFO"></param> /// <param name="withASI"></param> /// <param name="trx"></param> /// <returns></returns> public static List <MStorageDetail> GetAll(Ctx ctx, int M_Product_ID, int M_Locator_ID, X_Ref_Quantity_Type qtyType, Boolean isFIFO, Boolean withASI, Trx trx) { List <MStorageDetail> list = new List <MStorageDetail>(); String sql = "select s.* " + "from M_STORAGEDETAIL s INNER JOIN M_STORAGEDETAIL t " + "on ( s.AD_CLIENT_ID = t.AD_CLIENT_ID " + "and s.AD_ORG_ID = t.AD_ORG_ID " + "and s.M_PRODUCT_ID = t.M_PRODUCT_ID " + "and s.M_LOCATOR_ID = t.M_LOCATOR_ID) " + "where s.QTYTYPE ='" + qtyType.GetValue() + "' " + "and s.M_PRODUCT_ID =" + M_Product_ID + "and s.M_LOCATOR_ID =" + M_Locator_ID + " and t.QTYTYPE = 'H' "; if (withASI) { sql += "and t.QTY > 0 " + "and s.M_ATTRIBUTESETINSTANCE_ID > 0 "; } else { sql += "and t.QTY <> 0 "; } sql += " order by s.M_ATTRIBUTESETINSTANCE_ID "; if (!isFIFO) { sql += " DESC"; } IDataReader idr = null; try { idr = DB.ExecuteReader(sql, null, trx); DataTable dt = new DataTable(); dt.Load(idr); idr.Close(); foreach (DataRow dr in dt.Rows) { list.Add(new MStorageDetail(ctx, dr, trx)); } } catch (Exception ex) { s_log.Log(Level.SEVERE, sql, ex); } finally { if (idr != null) { idr.Close(); idr = null; } } return(list); }
public MStorageDetail(Ctx ctx, int M_Locator_ID, int M_Product_ID, int M_AttributeSetInstance_ID, X_Ref_Quantity_Type type, Trx trx) : this(ctx, 0, trx) { SetM_Locator_ID(M_Locator_ID); SetM_Product_ID(M_Product_ID); SetM_AttributeSetInstance_ID(M_AttributeSetInstance_ID); SetQtyType(type.GetValue()); SetQty(Env.ZERO); }
public static Decimal GetProductQty(Ctx ctx, int M_Product_ID, X_Ref_Quantity_Type qtyType, Trx trx) { String sql = "SELECT COALESCE(SUM(QTY),0) FROM M_STORAGE " + " WHERE M_Product_ID=" + M_Product_ID + " AND QtyType='" + qtyType.GetValue() + "'"; Decimal qty = Decimal.Zero; IDataReader idr = null; try { idr = DB.ExecuteReader(sql, null, trx); if (idr.Read()) { qty = Util.GetValueOfDecimal(idr[0]); } } catch (Exception ex) { _log.Log(Level.SEVERE, sql, ex); } finally { if (idr != null) { idr.Close(); idr = null; } } return(qty); }