/// <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); }
protected override bool BeforeSave(bool newRecord) { //Arpit StringBuilder sql = new StringBuilder(); //For checking if record is without attribute //if (GetM_AttributeSetInstance_ID() == 0 || GetM_AttributeSetInstance_ID() == null) //{ // _log.SaveError("", Msg.GetMsg(GetCtx(), "NoAttributeSet")); // return false; //} ////For checking if attribute is already defined //sql.Append("SELECT M_AttributeSetInstance_ID FROM M_ProductAttributes WHERE M_Product_ID=" + GetM_Product_ID() + // " AND AD_Client_ID=" + GetAD_Client_ID() + " AND M_ProductAttributes_ID!=" + GetM_ProductAttributes_ID()); //DataSet ds = new DataSet(); //ds = DB.ExecuteDataset(sql.ToString(), null, null); //if (ds != null && ds.Tables[0].Rows.Count > 0) //{ // for (Int32 i = 0; i < ds.Tables[0].Rows.Count; i++) // { // if (Util.GetValueOfInt(ds.Tables[0].Rows[i]["M_AttributeSetInstance_ID"]) > 0) // { // if (GetM_AttributeSetInstance_ID() == Util.GetValueOfInt(ds.Tables[0].Rows[i]["M_AttributeSetInstance_ID"])) // { // _log.SaveError("", Msg.GetMsg(GetCtx(), "AttributeCodeExists")); // return false; // } // } // } //} //sql.Clear(); //Checking if UPC exists//Arpit if (!String.IsNullOrEmpty(GetUPC()) && Util.GetValueOfString(Get_ValueOld("UPC")) != GetUPC()) { //sql.Append(@"SELECT UPCUNIQUE('a','" + GetUPC() + "') as productID FROM Dual"); //manu_ID = Util.GetValueOfInt(DB.ExecuteScalar(sql.ToString(), null, null)); //if (manu_ID != 0 && manu_ID != GetM_Product_ID()) manu_ID = MProduct.UpcUniqueClientWise(GetAD_Client_ID(), GetUPC()); if (manu_ID > 0) { _log.SaveError("UPCUnique", ""); return(false); } } return(true); }
protected override bool BeforeSave(bool newRecord) { if (!String.IsNullOrEmpty(GetUPC()) && Util.GetValueOfString(Get_ValueOld("UPC")) != GetUPC()) { //sql = "SELECT UPCUNIQUE('m','" + GetUPC() + "') as productID FROM Dual"; //manu_ID = Util.GetValueOfInt(DB.ExecuteScalar(sql, null, Get_Trx())); manu_ID = MProduct.UpcUniqueClientWise(GetAD_Client_ID(), GetUPC()); if (manu_ID > 0) //if (manu_ID != 0 && manu_ID != GetM_Product_ID()) { _log.SaveError("UPCUnique", ""); return(false); } } return(true); }