/// <summary> /// Load Invoice Line /// </summary> /// <param name="prod">production</param> /// <returns> DoaLine Array</returns> private DocLine[] LoadLines(X_M_Production prod) { List <DocLine> list = new List <DocLine>(); // Production // -- ProductionPlan // -- -- ProductionLine - the real level String sqlPP = "SELECT * FROM M_ProductionPlan pp " + "WHERE pp.M_Production_ID=@param1 " + "ORDER BY pp.Line"; IDataReader idrPP = null; String sqlPL = "SELECT * FROM M_ProductionLine pl " + "WHERE pl.M_ProductionPlan_ID=@param2 " + "ORDER BY pl.Line"; IDataReader idrPL = null; try { SqlParameter[] param = new SqlParameter[1]; param[0] = new SqlParameter("@param1", Get_ID()); idrPP = DataBase.DB.ExecuteReader(sqlPP, param, GetTrx()); //idrPP.setInt(1, get_ID()); //ResultSet rsPP = idrPP.executeQuery(); while (idrPP.Read()) { int M_Product_ID = Utility.Util.GetValueOfInt(idrPP["M_Product_ID"]); int M_ProductionPlan_ID = Utility.Util.GetValueOfInt(idrPP["M_ProductionPlan_ID"]); // try { param = new SqlParameter[1]; param[0] = new SqlParameter("@param2", M_ProductionPlan_ID); idrPL = DataBase.DB.ExecuteReader(sqlPL, param, GetTrx()); //idrPL.setInt(1, M_ProductionPlan_ID); //ResultSet rsPL = idrPL.executeQuery(); while (idrPL.Read()) { X_M_ProductionLine line = new X_M_ProductionLine(GetCtx(), idrPL, GetTrx()); if (Env.Signum(line.GetMovementQty()) == 0) { log.Info("LineQty=0 - " + line); continue; } DocLine docLine = new DocLine(line, this); docLine.SetQty(line.GetMovementQty(), false); // Identify finished BOM Product docLine.SetProductionBOM(line.GetM_Product_ID() == M_Product_ID); // log.Fine(docLine.ToString()); list.Add(docLine); } idrPL.Close(); } catch (Exception ee) { if (idrPL != null) { idrPL.Close(); idrPL = null; } log.Log(Level.SEVERE, sqlPL, ee); } } idrPP.Close(); } catch (Exception e) { if (idrPP != null) { idrPP.Close(); idrPP = null; } log.Log(Level.SEVERE, sqlPP, e); } // Return Array DocLine[] dl = new DocLine[list.Count]; dl = list.ToArray(); return(dl); }