// API to add component transaction lines in M_WorkOrderTransactionLine. Called from MWarehouseTask for WMS integration. /** * Api to add component transaction lines. * @param ctx * @param VAMFG_M_WorkOrder_ID Work Order * @param M_WorkOrderComponent_ID Work Order Component * @param Qty Number of components to be issued * @param M_Locator_ID Supply Locator for the component * @param trx * @return int M_WorkOrderTransactionLine_ID */ public int AddComponentTxnLine(Ctx ctx, int M_WorkOrderComponent_ID, Decimal Qty, int M_Locator_ID, Trx trx) { ViennaAdvantage.Model.MVAMFGMWorkOrderComponent woc = new ViennaAdvantage.Model.MVAMFGMWorkOrderComponent(ctx, M_WorkOrderComponent_ID, trx); MVAMFGMWorkOrderOperation woo = new MVAMFGMWorkOrderOperation(ctx, woc.GetVAMFG_M_WorkOrderOperation_ID(), trx); ViennaAdvantage.Model.MVAMFGMWrkOdrTransaction wot = RetrieveWOTxn(ctx, woo.GetVAMFG_M_WorkOrder_ID(), X_VAMFG_M_WrkOdrTransaction.VAMFG_WORKORDERTXNTYPE_1_ComponentIssueToWorkOrder, trx); if (wot == null) { log.Severe("Cannot create or retrieve WO Txn."); return(0); } ViennaAdvantage.Model.MVAMFGMWrkOdrTrnsctionLine wotLine = new ViennaAdvantage.Model.MVAMFGMWrkOdrTrnsctionLine(ctx, 0, trx); wotLine.SetRequiredColumns(wot.GetVAMFG_M_WrkOdrTransaction_ID(), woc.GetM_Product_ID(), woc.GetM_AttributeSetInstance_ID(), woc.GetC_UOM_ID(), Qty, woc.GetVAMFG_M_WorkOrderOperation_ID(), woc.GetBasisType()); wotLine.SetC_BPartner_ID(wot.GetC_BPartner_ID()); wotLine.SetC_BPartner_Location_ID(wot.GetC_BPartner_Location_ID()); wotLine.SetM_Locator_ID(M_Locator_ID); if (save) { if (!wotLine.Save(trx)) { log.Severe("Could not save component transaction line."); return(0); } } return(wotLine.GetVAMFG_M_WrkOdrTrnsctionLine_ID()); }
} // getOfWorkOrder /// <summary> /// Get Components of a Work Order Operation /// </summary> /// <param name="workorderoperation"></param> /// <param name="whereClause"></param> /// <param name="orderClause"></param> /// <returns></returns> public static MVAMFGMWorkOrderComponent[] GetOfWorkOrderOperation(MVAMFGMWorkOrderOperation workorderoperation, String whereClause, String orderClause) { StringBuilder sqlstmt = new StringBuilder("SELECT * FROM VAMFG_M_WorkOrderComponent WHERE VAMFG_M_WorkOrderOperation_ID=@param1 "); if (whereClause != null) { sqlstmt.Append("AND ").Append(whereClause); } if (orderClause != null) { sqlstmt.Append(" ORDER BY ").Append(orderClause); } String sql = sqlstmt.ToString(); //ArrayList<MWorkOrderComponent> list = new ArrayList<MWorkOrderComponent>(); List <MVAMFGMWorkOrderComponent> list = new List <MVAMFGMWorkOrderComponent>(); SqlParameter[] param = null; IDataReader idr = null; DataTable dt = new DataTable(); //PreparedStatement pstmt = DB.prepareStatement (sql, workorderoperation.get_Trx()); //ResultSet rs = null; try { param = new SqlParameter[1]; param[0] = new SqlParameter("@param1", workorderoperation.GetVAMFG_M_WorkOrderOperation_ID()); idr = DB.ExecuteReader(sql, param, workorderoperation.Get_TrxName()); dt.Load(idr); if (idr != null) { idr.Close(); idr = null; } for (int i = 0; i < dt.Rows.Count; i++) { list.Add(new MVAMFGMWorkOrderComponent(workorderoperation.GetCtx(), dt.Rows[i], workorderoperation.Get_TrxName())); } } catch { if (idr != null) { idr.Close(); idr = null; } log.Log(Level.SEVERE, sql); return(null); } MVAMFGMWorkOrderComponent[] retValue = new MVAMFGMWorkOrderComponent[list.Count]; retValue = list.ToArray(); return(retValue); } // getOfWorkOrderOperation