/// <summary> /// Before Save /// </summary> /// <param name="newRecord">newRecord new</param> /// <returns>true if can be saved</returns> protected override bool BeforeSave(bool newRecord) { // From - To is the same if (GetC_UOM_ID() == GetC_UOM_To_ID()) { log.SaveError("Error", Msg.ParseTranslation(GetCtx(), "@C_UOM_ID@ = @C_UOM_ID@")); return(false); } // Nothing to convert if (GetMultiplyRate().CompareTo(Env.ZERO) <= 0) { log.SaveError("Error", Msg.ParseTranslation(GetCtx(), "@MultiplyRate@ <= 0")); return(false); } // Enforce Product UOM if (GetM_Product_ID() != 0 && (newRecord || Is_ValueChanged("M_Product_ID"))) { MProduct product = MProduct.Get(GetCtx(), GetM_Product_ID()); if (product.GetC_UOM_ID() != GetC_UOM_ID()) { MUOM uom = MUOM.Get(GetCtx(), product.GetC_UOM_ID()); log.SaveError("ProductUOMConversionUOMError", uom.GetName()); return(false); } } // The Product UoM needs to be the smallest UoM - Multiplier must be > 0 if (GetM_Product_ID() != 0 && GetDivideRate().CompareTo(Env.ONE) < 0) { log.SaveError("ProductUOMConversionRateError", ""); return(false); } return(true); }
/// <summary> /// Get Uom Name /// </summary> /// <returns>UOM</returns> public String GetUomName() { if (_uom == null) { _uom = MUOM.Get(GetCtx(), GetC_UOM_ID()); } return(_uom.GetName()); }
/// <summary> /// Before Save /// </summary> /// <param name="newRecord">newRecord new</param> /// <returns>true if can be saved</returns> protected override bool BeforeSave(bool newRecord) { // From - To is the same //Commented by arpit asked by sachin Sir 29 Jan,2018--to save records with same UOM also //if (GetC_UOM_ID() == GetC_UOM_To_ID()) //{ // log.SaveError("Error", Msg.ParseTranslation(GetCtx(), "@C_UOM_ID@ = @C_UOM_ID@")); // return false; //} // Nothing to convert //Getting the message from messagewindow for UOM conversion if (GetMultiplyRate().CompareTo(Env.ZERO) <= 0) { log.SaveError("", Msg.GetMsg(GetCtx(), "ProductUOMConversionRateError")); return(false); } // Enforce Product UOM if (GetM_Product_ID() != 0 && (newRecord || Is_ValueChanged("M_Product_ID"))) { MProduct product = MProduct.Get(GetCtx(), GetM_Product_ID()); if (product.GetC_UOM_ID() != GetC_UOM_ID()) { MUOM uom = MUOM.Get(GetCtx(), product.GetC_UOM_ID()); log.SaveError("ProductUOMConversionUOMError", uom.GetName()); return(false); } } // The Product UoM needs to be the smallest UoM - Multiplier must be > 0 if (GetM_Product_ID() != 0 && GetDivideRate().CompareTo(Env.ONE) < 0) { // JID_0239: Currenly system show message when multiple rate is less than one like below "Product UOM Coversion rate error" log.SaveError("", Msg.GetMsg(GetCtx(), "ProductUOMConversionRateError")); return(false); } if (!String.IsNullOrEmpty(GetUPC()) && Util.GetValueOfString(Get_ValueOld("UPC")) != GetUPC()) { //string sql = "SELECT UPCUNIQUE('c','" + GetUPC() + "') as productID FROM Dual"; //int manu_ID = Util.GetValueOfInt(DB.ExecuteScalar(sql, null, null)); //if (manu_ID != 0 && manu_ID != GetM_Product_ID()) int manu_ID = MProduct.UpcUniqueClientWise(GetAD_Client_ID(), GetUPC()); if (manu_ID > 0) { _log.SaveError("UPCUnique", ""); return(false); } } return(true); }