/// <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); }
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 Default Locator /// </summary> /// <returns>(first) default locator</returns> public MLocator GetDefaultLocator() { MLocator[] locators = GetLocators(false); // ordered by x,y,z MLocator loc1 = null; for (int i = 0; i < locators.Length; i++) { MLocator locIn = locators[i]; if (locIn.IsDefault() && locIn.IsActive()) { return(locIn); } if (loc1 == null || loc1.GetPriorityNo() > locIn.GetPriorityNo()) { loc1 = locIn; } } // No Default - return highest priority if (locators.Length > 0) { log.Warning("No default Locator for " + GetName()); return(loc1); } // No Locator - create one MLocator loc = new MLocator(this, "Standard"); loc.SetIsDefault(true); loc.Save(); log.Info("Created default locator for " + GetName()); return(loc); }