public static MLocator Get(Ctx ctx, int M_Warehouse_ID, String value, String X, String Y, String Z, String Position, String Bin) { MLocator retValue = null; String sql = "SELECT * FROM M_Locator WHERE M_Warehouse_ID=" + M_Warehouse_ID + " AND " + "X='" + X + "' AND Y='" + Y + "' AND Z='" + Z + "'"; DataSet ds = null; try { ds = DB.ExecuteDataset(sql, null, null); if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { DataRow idr = ds.Tables[0].Rows[0]; retValue = new MLocator(ctx, idr, null); } } catch (Exception ex) { _log.Log(Level.SEVERE, "get", ex); } // if (retValue == null) { MWarehouse wh = MWarehouse.Get(ctx, M_Warehouse_ID); retValue = new MLocator(wh, value); retValue.SetXYZ(X, Y, Z, Position, Bin); if (!retValue.Save()) { retValue = null; } } return(retValue); }
/// <summary> /// Get the Locator with the combination or create new one /// </summary> /// <param name="ctx">context</param> /// <param name="M_Warehouse_ID">id</param> /// <param name="value">value</param> /// <param name="X">x</param> /// <param name="Y">y</param> /// <param name="Z">z</param> /// <returns>locator</returns> public static MLocator Get(Ctx ctx, int M_Warehouse_ID, String value, String X, String Y, String Z) { MLocator retValue = null; String sql = "SELECT * FROM M_Locator WHERE M_Warehouse_ID=" + M_Warehouse_ID + " AND " + "X='" + X + "' AND Y='" + Y + "' AND Z='" + Z + "'"; DataSet ds = null; try { ds = DataBase.DB.ExecuteDataset(sql, null, null); if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0) { DataRow rs = ds.Tables[0].Rows[0]; retValue = new MLocator(ctx, rs, null); } } catch (Exception ex) { _log.Log(Level.SEVERE, "get", ex); } // if (retValue == null) { MWarehouse wh = MWarehouse.Get(ctx, M_Warehouse_ID); retValue = new MLocator(wh, HttpUtility.HtmlEncode(value)); retValue.SetXYZ(HttpUtility.HtmlEncode(X), HttpUtility.HtmlEncode(Y), HttpUtility.HtmlEncode(Z)); if (!retValue.Save()) { retValue = null; } } return(retValue); }