Пример #1
0
        /****
         *  Before Save.
         *  - Set Name
         *	@param newRecord new
         *	@return save
         */
        protected override bool BeforeSave(bool newRecord)
        {
            if (GetC_Location_ID() == 0)
            {
                return(false);
            }

            //	Set New Name
            if (!newRecord)
            {
                return(true);
            }
            MLocation address = GetLocation(true);

            _uniqueName = GetName();
            if (_uniqueName != null && _uniqueName.Equals(".")) //	default
            {
                _uniqueName = null;
            }
            _unique = 0;
            MakeUnique(address);

            //	Check uniqueness
            MBPartnerLocation[] locations = GetForBPartner(GetCtx(), GetC_BPartner_ID(), Get_TrxName());
            bool unique = locations.Length == 0;

            while (!unique)
            {
                unique = true;
                for (int i = 0; i < locations.Length; i++)
                {
                    MBPartnerLocation location = locations[i];
                    if (location.GetC_BPartner_Location_ID() == Get_ID())
                    {
                        continue;
                    }
                    if (_uniqueName.Equals(location.GetName()))
                    {
                        MakeUnique(address);
                        unique = false;
                        break;
                    }
                }
            }
            SetName(_uniqueName);
            return(true);
        }
Пример #2
0
        /****
         *  Before Save.
         *  - Set Name
         *	@param newRecord new
         *	@return save
         */
        protected override bool BeforeSave(bool newRecord)
        {
            if (GetC_Location_ID() == 0)
            {
                return(false);
            }

            if (VAdvantage.Utility.Env.IsModuleInstalled("VA077_"))
            {
                // Error if Customer Location No is not unique
                if (GetVA077_LocNo() != null)
                {
                    string  sql = @"SELECT C_BPartner_ID, VA077_IsMailAdd  FROM C_BPartner_Location 
                                   WHERE VA077_LocNo = '" + GetVA077_LocNo() + "' AND C_BPartner_Location_ID !=" + GetC_BPartner_Location_ID();
                    DataSet ds  = DB.ExecuteDataset(sql, null, Get_Trx());

                    if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows.Count == 1)
                        {
                            int  PartnerID = Util.GetValueOfInt(ds.Tables[0].Rows[0]["C_BPartner_ID"]);
                            bool value     = Util.GetValueOfString(ds.Tables[0].Rows[0]["VA077_IsMailAdd"]).Equals("Y") ? true : false;
                            if (value.Equals(IsVA077_IsMailAdd()) || PartnerID != GetC_BPartner_ID())
                            {
                                log.SaveError("VA077_UniqueLocNo", "");
                                return(false);
                            }
                        }
                        else
                        {
                            log.SaveError("VA077_UniqueLocNo", "");
                            return(false);
                        }
                    }
                }
            }

            // change by amit
            //	Set New Name
            //if (!newRecord)
            //    return true;


            if (Util.GetValueOfString(Get_ValueOld("Name")) == GetName() && Util.GetValueOfInt(Get_ValueOld("C_Location_ID")) == GetC_Location_ID())
            {
                return(true);
            }

            MLocation address = GetLocation(true);

            _uniqueName.Append(GetName());
            //if (_uniqueName != null && _uniqueName.Equals("."))	//	default    change by amit
            _uniqueName.Clear();
            _unique = 0;
            // Changes Done By Vivek on 10/12/2015
            //Set City Name at Name Field
            if (GetName() == ".")
            {
                MakeUnique(address);
            }
            //else Set Manually Edited Name by User at name field
            else
            {
                SetName(GetName());
                return(true);
            }

            //if (Util.GetValueOfString(Get_ValueOld("Name")) != GetName())
            //{
            //    _uniqueName = GetName();
            //    SetName(_uniqueName);
            //    return true;
            //}
            //MakeUnique(address);

            //	Check uniqueness
            MBPartnerLocation[] locations = GetForBPartner(GetCtx(), GetC_BPartner_ID(), Get_TrxName());
            bool unique = locations.Length == 0;

            while (!unique)
            {
                unique = true;
                for (int i = 0; i < locations.Length; i++)
                {
                    MBPartnerLocation location = locations[i];
                    if (location.GetC_BPartner_Location_ID() == Get_ID())
                    {
                        continue;
                    }
                    if (_uniqueName.Equals(location.GetName()))
                    {
                        MakeUnique(address);
                        unique = false;
                        break;
                    }
                }
            }
            SetName(_uniqueName.ToString());
            return(true);
        }
        /****
         *  Before Save.
         *  - Set Name
         *	@param newRecord new
         *	@return save
         */
        protected override bool BeforeSave(bool newRecord)
        {
            if (GetC_Location_ID() == 0)
            {
                return(false);
            }

            // change by amit
            //	Set New Name
            //if (!newRecord)
            //    return true;

            if (Util.GetValueOfString(Get_ValueOld("Name")) == GetName() && Util.GetValueOfInt(Get_ValueOld("C_Location_ID")) == GetC_Location_ID())
            {
                return(true);
            }

            MLocation address = GetLocation(true);

            _uniqueName = GetName();
            //if (_uniqueName != null && _uniqueName.Equals("."))	//	default    change by amit
            _uniqueName = null;
            _unique     = 0;
            // Changes Done By Vivek on 10/12/2015
            //Set City Name at Name Field
            if (GetName() == ".")
            {
                MakeUnique(address);
            }
            //else Set Manually Edited Name by User at name field
            else
            {
                SetName(GetName());
                return(true);
            }

            //if (Util.GetValueOfString(Get_ValueOld("Name")) != GetName())
            //{
            //    _uniqueName = GetName();
            //    SetName(_uniqueName);
            //    return true;
            //}
            //MakeUnique(address);

            //	Check uniqueness
            MBPartnerLocation[] locations = GetForBPartner(GetCtx(), GetC_BPartner_ID(), Get_TrxName());
            bool unique = locations.Length == 0;

            while (!unique)
            {
                unique = true;
                for (int i = 0; i < locations.Length; i++)
                {
                    MBPartnerLocation location = locations[i];
                    if (location.GetC_BPartner_Location_ID() == Get_ID())
                    {
                        continue;
                    }
                    if (_uniqueName.Equals(location.GetName()))
                    {
                        MakeUnique(address);
                        unique = false;
                        break;
                    }
                }
            }
            SetName(_uniqueName);
            return(true);
        }