// Added by Mohit VAWMS 20-8-2015 protected override Boolean BeforeSave(Boolean newRecord) { if (Env.HasModulePrefix("VAWMS_", out mInfo)) { // Check Storage if (Is_ValueChanged("IsActive") && IsActive()) // now not active { if (checkStock(GetCtx(), Get_ID(), Get_TrxName())) { log.SaveError("Error", Msg.GetMsg(GetCtx(), "LocatorHasStock")); return(false); } } // storage // JID:1888 Checks for the duplicate Searchkey int count = Util.GetValueOfInt(DB.ExecuteScalar("SELECT COUNT(Value) FROM M_Locator WHERE Value= '" + GetValue() + "' AND M_Locator_ID !=" + GetM_Locator_ID())); if (count > 0) { log.SaveError("", Msg.GetMsg(GetCtx(), "SearchKeyUnique")); return(false); } if (newRecord || Is_ValueChanged("X") || Is_ValueChanged("Y") || Is_ValueChanged("Z") || Is_ValueChanged("POSITION") || Is_ValueChanged("Bin")) { MWarehouse wh = new MWarehouse(GetCtx(), GetM_Warehouse_ID(), Get_TrxName()); //if (GetBin() != null && GetPOSITION() != null || GetPOSITION()==null) //{ // log.SaveError("Error", Msg.GetMsg(GetCtx(), "PositionMandatorySegment")); // return false; //} //if (GetX() == null || GetX().Length == 0 || !Util.isAlphaNumeric(GetX()) || // GetY() == null || GetY().Length == 0 || !Util.isAlphaNumeric(GetY()) || // GetZ() == null || GetZ().Length == 0 || !Util.isAlphaNumeric(GetZ()) || // (GetBin() != null && GetBin().Length != 0 && !Util.isAlphaNumeric(GetBin())) || // (GetPOSITION() != null && GetPOSITION().Length != 0 && !Util.isAlphaNumeric(GetPOSITION()))) //if (GetX() == null || GetX().Length == 0 || // GetY() == null || GetY().Length == 0 || // GetZ() == null || GetZ().Length == 0 || // (GetBin() != null && GetBin().Length != 0) || // (GetPOSITION() != null && GetPOSITION().Length != 0)) //{ // log.SaveError("Error", Msg.GetMsg(GetCtx(), "SegmentNotAlphaNumeric")); // return false; //} //String combination = GetX().concat(wh.GetSeparator()); //combination = combination.(GetY()).concat(wh.GetSeparator()); //combination = combination.concat(GetZ()); //if (GetPOSITION() != null && GetPOSITION().Length != 0) // combination = combination.concat(wh.GetSeparator()).concat(GetPOSITION()); //if (GetBin() != null && GetBin().Length != 0) // combination = combination.concat(wh.GetSeparator()).concat(GetBin()); StringBuilder combination = new StringBuilder(); combination.Append(GetX()).Append(wh.GetSeparator()); combination = combination.Append(GetY()).Append(wh.GetSeparator()); combination = combination.Append(GetZ()); if (GetPOSITION() != null && GetPOSITION().Length != 0) { combination = combination.Append(wh.GetSeparator()).Append(GetPOSITION()); } if (GetBin() != null && GetBin().Length != 0) { combination = combination.Append(wh.GetSeparator()).Append(GetBin()); } log.Fine("Set Locator Combination :" + combination); //String sql = "SELECT count(*) FROM M_Locator WHERE M_Locator_ID<>?" + // " AND M_Warehouse_ID = ?" + // " AND UPPER(LocatorCombination) = UPPER(?)"; String sql = "SELECT count(*) FROM M_Locator WHERE M_Locator_ID<>" + GetM_Locator_ID() + " AND M_Warehouse_ID =" + GetM_Warehouse_ID() + " AND UPPER(LocatorCombination) = UPPER('" + combination + "')"; //int ii = QueryUtil.GetSQLValue(Get_TrxName(), sql, GetM_Locator_ID(), GetM_Warehouse_ID(), combination); int ii = Convert.ToInt32(DB.ExecuteScalar(sql, null, Get_TrxName())); if (ii != 0) { log.SaveError("Error", Msg.GetMsg(GetCtx(), "CombinationNotUnique")); return(false); } SetLocatorCombination(combination.ToString()); } if (newRecord || Is_ValueChanged("IsAvailableToPromise") || Is_ValueChanged("IsAvailableForAllocation")) { if (IsAvailableForAllocation() && !IsAvailableToPromise()) { log.SaveError("Error", Msg.GetMsg(GetCtx(), "InvalidCombination")); return(false); } } return(true); } return(true); }