/// <summary> /// Get Lots for Product /// </summary> /// <param name="ctx">context</param> /// <param name="M_Product_ID">id</param> /// <param name="trxName">transaction</param> /// <returns>Array of Lots for Product</returns> public static MLot[] GetProductLots(Ctx ctx, int M_Product_ID, Trx trxName) { String sql = "SELECT * FROM M_Lot WHERE M_Product_ID=" + M_Product_ID; List <MLot> list = new List <MLot>(); try { DataSet ds = DataBase.DB.ExecuteDataset(sql, null, trxName); if (ds.Tables.Count > 0) { foreach (DataRow rs in ds.Tables[0].Rows) { list.Add(new MLot(ctx, rs, trxName)); } } } catch (Exception ex) { _log.Log(Level.SEVERE, sql, ex); } // MLot[] retValue = new MLot[list.Count]; retValue = list.ToArray(); return(retValue); }
/// <summary> /// Create new Lot. /// Increments Current Next and Commits /// </summary> /// <param name="M_Product_ID">product</param> /// <returns>saved Lot</returns> public MLot CreateLot(int M_Product_ID) { StringBuilder name = new StringBuilder(); if (GetPrefix() != null) { name.Append(GetPrefix()); } int no = GetCurrentNext(); name.Append(no); if (GetSuffix() != null) { name.Append(GetSuffix()); } // no += GetIncrementNo(); SetCurrentNext(no); Save(); // MLot retValue = new MLot(this, M_Product_ID, name.ToString()); retValue.Save(); return(retValue); }
/** * To to find lot and set Lot/ID * @param Lot lot * @param M_Product_ID product */ public void SetLot(String Lot, int M_Product_ID) { // Try to find it MLot mLot = MLot.GetProductLot(GetCtx(), M_Product_ID, Lot, Get_TrxName()); if (mLot != null) { SetM_Lot_ID(mLot.GetM_Lot_ID()); } SetLot(Lot); }
/** * Create Lot * @param M_Product_ID product used if new * @return lot info */ public KeyNamePair CreateLot(int M_Product_ID) { KeyNamePair retValue = null; int M_LotCtl_ID = GetMAttributeSet().GetM_LotCtl_ID(); if (M_LotCtl_ID != 0) { MLotCtl ctl = new MLotCtl(GetCtx(), M_LotCtl_ID, null); MLot lot = ctl.CreateLot(M_Product_ID); SetM_Lot_ID(lot.GetM_Lot_ID()); SetLot(lot.GetName()); retValue = new KeyNamePair(lot.GetM_Lot_ID(), lot.GetName()); } return(retValue); }
/// <summary> /// Get Lot for Product /// </summary> /// <param name="ctx">context</param> /// <param name="M_Product_ID">product</param> /// <param name="lot">lot</param> /// <param name="trxName">transaction</param> /// <returns>Array of Lots for Product</returns> public static MLot GetProductLot(Ctx ctx, int M_Product_ID, String lot, Trx trxName) { String sql = "SELECT * FROM M_Lot WHERE M_Product_ID=" + M_Product_ID + " AND Name='" + lot + "'"; MLot retValue = null; try { DataSet ds = DataBase.DB.ExecuteDataset(sql, null, trxName); if (ds.Tables.Count > 0) { foreach (DataRow rs in ds.Tables[0].Rows) { retValue = new MLot(ctx, rs, trxName); } } } catch (Exception ex) { _log.Log(Level.SEVERE, sql, ex); } return(retValue); }