Ejemplo n.º 1
0
        protected virtual void LocationAPPaymentInfo_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)
        {
            LocationAPPaymentInfo record = (LocationAPPaymentInfo)e.Row;

            if (!sender.ObjectsEqual <LocationAPPaymentInfo.vCashAccountID, LocationAPPaymentInfo.vPaymentMethodID, LocationAPPaymentInfo.vPaymentLeadTime, LocationAPPaymentInfo.vPaymentByType, LocationAPPaymentInfo.vSeparateCheck, LocationAPPaymentInfo.isRemitAddressSameAsMain, LocationAPPaymentInfo.isRemitContactSameAsMain>(e.Row, e.OldRow))
            {
                Location mainloc = Location.Current;
                mainloc.VCashAccountID           = record.VCashAccountID;
                mainloc.VPaymentMethodID         = record.VPaymentMethodID;
                mainloc.VPaymentLeadTime         = record.VPaymentLeadTime;
                mainloc.VPaymentByType           = record.VPaymentByType;
                mainloc.VSeparateCheck           = record.VSeparateCheck;
                mainloc.IsRemitAddressSameAsMain = record.IsRemitAddressSameAsMain;
                mainloc.VRemitAddressID          = record.VRemitAddressID;
                mainloc.IsRemitContactSameAsMain = record.IsRemitContactSameAsMain;
                mainloc.VRemitContactID          = record.VRemitContactID;

                if (Location.Cache.GetStatus(mainloc) == PXEntryStatus.Notchanged)
                {
                    Location.Cache.SetStatus(mainloc, PXEntryStatus.Updated);
                }

                sender.Graph.Caches[typeof(Location)].IsDirty = true;
            }
        }
Ejemplo n.º 2
0
        protected virtual void LocationAPPaymentInfo_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
        {
            LocationAPPaymentInfo record = (LocationAPPaymentInfo)e.Row;

            record.IsRemitAddressSameAsMain = object.Equals(record.VDefAddressID, record.VRemitAddressID);
            record.IsRemitContactSameAsMain = object.Equals(record.VDefContactID, record.VRemitContactID);
        }
Ejemplo n.º 3
0
        protected virtual void LocationAPPaymentInfo_VPaymentMethodID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            string oldValue           = (string)e.OldValue;
            LocationAPPaymentInfo row = (LocationAPPaymentInfo)e.Row;

            if (!String.IsNullOrEmpty(oldValue))
            {
                this.ClearPaymentDetails((LocationAPPaymentInfo)e.Row, oldValue, true);
            }
            this.FillPaymentDetails((LocationAPPaymentInfo)e.Row);
            sender.SetDefaultExt <LocationAPPaymentInfo.vCashAccountID>(e.Row);
        }
Ejemplo n.º 4
0
        protected virtual void LocationAPPaymentInfo_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            LocationAPPaymentInfo row = (LocationAPPaymentInfo)e.Row;

            if (Location.Current != null)
            {
                bool enableEdit       = object.Equals(Location.Current.LocationID, Location.Current.VPaymentInfoLocationID);
                bool hasPaymentMethod = (row != null) && (String.IsNullOrEmpty(row.VPaymentMethodID) == false);
                PXUIFieldAttribute.SetEnabled(sender, e.Row, enableEdit);
                PXUIFieldAttribute.SetEnabled <LocationAPPaymentInfo.vCashAccountID>(sender, e.Row, enableEdit && hasPaymentMethod);
            }
        }
Ejemplo n.º 5
0
        protected virtual void LocationAPPaymentInfo_IsRemitContactSameAsMain_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
        {
            LocationAPPaymentInfo owner = (LocationAPPaymentInfo)e.Row;

            if (owner != null)
            {
                if (owner.IsRemitContactSameAsMain == true)
                {
                    if (owner.VRemitContactID != owner.VDefContactID)
                    {
                        Contact contact = this.FindContact(owner.VRemitContactID);
                        if (contact != null && contact.ContactID == owner.VRemitContactID)
                        {
                            this.RemitContact.Delete(contact);
                        }
                        owner.VRemitContactID = owner.VDefContactID;
                        //if (this.Location.Cache.Locate(owner) != null)
                        //  this.Location.Cache.Update(owner);
                    }
                }

                if (owner.IsRemitContactSameAsMain == false)
                {
                    if (owner.VRemitContactID != null)
                    {
                        if (owner.VRemitContactID == owner.VDefContactID)
                        {
                            Contact defContact = this.FindContact(owner.VDefContactID);
                            Contact cont       = PXCache <Contact> .CreateCopy(defContact);

                            cont.ContactID        = null;
                            cont.BAccountID       = owner.BAccountID;
                            cont.ContactType      = ContactTypesAttribute.BAccountProperty;
                            cont                  = (Contact)this.RemitContact.Cache.Insert(cont);
                            owner.VRemitContactID = cont.ContactID;
                            //if (this.Location.Cache.Locate(owner) != null)
                            //  this.Location.Cache.Update(owner);
                        }
                    }
                }
            }
        }
Ejemplo n.º 6
0
        protected virtual void LocationAPPaymentInfo_IsRemitAddressSameAsMain_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
        {
            LocationAPPaymentInfo owner = (LocationAPPaymentInfo)e.Row;

            if (owner != null)
            {
                if (owner.IsRemitAddressSameAsMain == true)
                {
                    if (owner.VRemitAddressID != owner.VDefAddressID)
                    {
                        Address extAddr = this.FindAddress(owner.VRemitAddressID);
                        if (extAddr != null && extAddr.AddressID == owner.VRemitAddressID)
                        {
                            this.RemitAddress.Delete(extAddr);
                        }
                        owner.VRemitAddressID = owner.VDefAddressID;
                        //if (this.Location.Cache.Locate(owner) != null)
                        //  this.Location.Cache.Update(owner);
                    }
                }

                if (owner.IsRemitAddressSameAsMain == false)
                {
                    if (owner.VRemitAddressID != null)
                    {
                        if (owner.VRemitAddressID == owner.VDefAddressID)
                        {
                            Address defAddress = this.FindAddress(owner.VDefAddressID);
                            Address addr       = PXCache <Address> .CreateCopy(defAddress);

                            addr.AddressID        = null;
                            addr.BAccountID       = owner.BAccountID;
                            addr                  = this.RemitAddress.Insert(addr);
                            owner.VRemitAddressID = addr.AddressID;
                            //if (this.Location.Cache.Locate(owner) != null)
                            //  this.Location.Cache.Update(owner);
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
		protected virtual void Location_IsAPPaymentInfoSameAsMain_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
		{
			CR.Location record = (CR.Location)e.Row;

			if (record.IsAPPaymentInfoSameAsMain == false)
			{
				LocationAPPaymentInfo mainloc = APPaymentInfoLocation.Select();
				record.VCashAccountID = mainloc.VCashAccountID;
				record.VPaymentMethodID = mainloc.VPaymentMethodID;
				record.VPaymentLeadTime = mainloc.VPaymentLeadTime;
				record.VPaymentByType = mainloc.VPaymentByType;				
				record.VSeparateCheck = mainloc.VSeparateCheck;
				record.IsRemitAddressSameAsMain = mainloc.IsRemitAddressSameAsMain;
				record.VRemitAddressID = mainloc.VRemitAddressID;
				record.IsRemitContactSameAsMain = mainloc.IsRemitContactSameAsMain;
				record.VRemitContactID = mainloc.VRemitContactID;
				record.VPaymentInfoLocationID = record.LocationID;

				LocationAPPaymentInfo copyloc = new LocationAPPaymentInfo();
				copyloc.BAccountID = record.BAccountID;
				copyloc.LocationID = record.LocationID;
				copyloc.VCashAccountID = record.VCashAccountID;
				copyloc.VPaymentMethodID = record.VPaymentMethodID;
				copyloc.VPaymentLeadTime = record.VPaymentLeadTime;
				copyloc.VPaymentByType = record.VPaymentByType;
				copyloc.VSeparateCheck = record.VSeparateCheck;
				copyloc.IsRemitAddressSameAsMain = record.IsRemitAddressSameAsMain;
				copyloc.VDefAddressID = record.VDefAddressID;
				copyloc.VRemitAddressID = record.VRemitAddressID;
				copyloc.IsRemitContactSameAsMain = record.IsRemitContactSameAsMain;
				copyloc.VRemitContactID = record.VRemitContactID;
				copyloc.VDefContactID = record.VDefContactID;

				if (copyloc.VDefAddressID != copyloc.VRemitAddressID)
				{
					Address copyaddr = FindAddress(copyloc.VRemitAddressID);
					copyaddr = PXCache<Address>.CreateCopy(copyaddr);
					copyaddr.AddressID = null;

					copyaddr = RemitAddress.Insert(copyaddr);
					copyloc.VRemitAddressID = copyaddr.AddressID;
				}

				if (copyloc.VDefContactID != copyloc.VRemitContactID)
				{
					Contact copycont = FindContact(copyloc.VRemitContactID);
					copycont = PXCache<Contact>.CreateCopy(copycont);
					copycont.ContactID = null;

					copycont = RemitContact.Insert(copycont);
					copyloc.VRemitContactID = copycont.ContactID;
				}

				foreach (VendorPaymentMethodDetail maindet in this.PaymentDetails.Select(mainloc.BAccountID, mainloc.LocationID, mainloc.VPaymentMethodID))
				{
					VendorPaymentMethodDetail copydet = PXCache<VendorPaymentMethodDetail>.CreateCopy(maindet);
					copydet.LocationID = copyloc.LocationID;

					this.PaymentDetails.Insert(copydet);
				}

				BusinessAccount.Cache.Current = (BAccount)PXParentAttribute.SelectParent(sender, e.Row, typeof(BAccount));
				APPaymentInfoLocation.Insert(copyloc);
			}
			if (record.IsAPPaymentInfoSameAsMain == true)
			{
				foreach (VendorPaymentMethodDetail copydet in this.PaymentDetails.Select(record.BAccountID, record.LocationID, record.VPaymentMethodID))
				{
					this.PaymentDetails.Delete(copydet);
				}

				BAccount baccount = (BAccount)PXParentAttribute.SelectParent(sender, e.Row, typeof(BAccount));
				if (baccount != null)
				{
					record.VPaymentInfoLocationID = baccount.DefLocationID;

					Location mainloc = PXSelect<CR.Location, Where<CR.Location.bAccountID, Equal<Required<CR.Location.bAccountID>>, And<CR.Location.locationID, Equal<Required<CR.Location.locationID>>>>>.Select(sender.Graph, baccount.BAccountID, baccount.DefLocationID);

					if (mainloc != null)
					{
						if (record.DefAddressID != record.VRemitAddressID && mainloc.VRemitAddressID != record.VRemitAddressID)
						{
							Address copyaddr = FindAddress(record.VRemitAddressID);
							RemitAddress.Delete(copyaddr);
						}

						if (record.DefContactID != record.VRemitContactID && mainloc.VRemitContactID != record.VRemitContactID)
						{
							Contact copycont = FindContact(record.VRemitContactID);
							RemitContact.Delete(copycont);
						}
					}
				}

				record.VCashAccountID = null;
				record.VPaymentMethodID = null;
				record.VPaymentLeadTime = 0;
				record.VSeparateCheck = false;
				record.VRemitAddressID = null;
				record.VRemitContactID = null;
			}
		}
Ejemplo n.º 8
0
        protected virtual void Location_IsAPPaymentInfoSameAsMain_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            CR.Location record = (CR.Location)e.Row;

            if (record.IsAPPaymentInfoSameAsMain == false)
            {
                LocationAPPaymentInfo mainloc = APPaymentInfoLocation.Select();
                record.VCashAccountID           = mainloc.VCashAccountID;
                record.VPaymentMethodID         = mainloc.VPaymentMethodID;
                record.VPaymentLeadTime         = mainloc.VPaymentLeadTime;
                record.VPaymentByType           = mainloc.VPaymentByType;
                record.VSeparateCheck           = mainloc.VSeparateCheck;
                record.IsRemitAddressSameAsMain = mainloc.IsRemitAddressSameAsMain;
                record.VRemitAddressID          = mainloc.VRemitAddressID;
                record.IsRemitContactSameAsMain = mainloc.IsRemitContactSameAsMain;
                record.VRemitContactID          = mainloc.VRemitContactID;
                record.VPaymentInfoLocationID   = record.LocationID;

                LocationAPPaymentInfo copyloc = new LocationAPPaymentInfo();
                copyloc.BAccountID               = record.BAccountID;
                copyloc.LocationID               = record.LocationID;
                copyloc.VCashAccountID           = record.VCashAccountID;
                copyloc.VPaymentMethodID         = record.VPaymentMethodID;
                copyloc.VPaymentLeadTime         = record.VPaymentLeadTime;
                copyloc.VPaymentByType           = record.VPaymentByType;
                copyloc.VSeparateCheck           = record.VSeparateCheck;
                copyloc.IsRemitAddressSameAsMain = record.IsRemitAddressSameAsMain;
                copyloc.VDefAddressID            = record.VDefAddressID;
                copyloc.VRemitAddressID          = record.VRemitAddressID;
                copyloc.IsRemitContactSameAsMain = record.IsRemitContactSameAsMain;
                copyloc.VRemitContactID          = record.VRemitContactID;
                copyloc.VDefContactID            = record.VDefContactID;

                if (copyloc.VDefAddressID != copyloc.VRemitAddressID)
                {
                    Address copyaddr = FindAddress(copyloc.VRemitAddressID);
                    copyaddr = PXCache <Address> .CreateCopy(copyaddr);

                    copyaddr.AddressID = null;

                    copyaddr = RemitAddress.Insert(copyaddr);
                    copyloc.VRemitAddressID = copyaddr.AddressID;
                    record.VRemitAddressID  = copyaddr.AddressID;
                }

                if (copyloc.VDefContactID != copyloc.VRemitContactID)
                {
                    Contact copycont = FindContact(copyloc.VRemitContactID);
                    copycont = PXCache <Contact> .CreateCopy(copycont);

                    copycont.ContactID = null;
                    copycont.NoteID    = null;

                    copycont = RemitContact.Insert(copycont);
                    copyloc.VRemitContactID = copycont.ContactID;
                    record.VRemitContactID  = copycont.ContactID;
                }

                foreach (VendorPaymentMethodDetail maindet in this.PaymentDetails.Select(mainloc.BAccountID, mainloc.LocationID, mainloc.VPaymentMethodID))
                {
                    VendorPaymentMethodDetail copydet = PXCache <VendorPaymentMethodDetail> .CreateCopy(maindet);

                    copydet.LocationID = copyloc.LocationID;

                    this.PaymentDetails.Insert(copydet);
                }

                BusinessAccount.Cache.Current = (BAccount)PXParentAttribute.SelectParent(sender, e.Row, typeof(BAccount));
                APPaymentInfoLocation.Insert(copyloc);
            }
            if (record.IsAPPaymentInfoSameAsMain == true)
            {
                foreach (VendorPaymentMethodDetail copydet in this.PaymentDetails.Select(record.BAccountID, record.LocationID, record.VPaymentMethodID))
                {
                    this.PaymentDetails.Delete(copydet);
                }

                BAccount baccount = (BAccount)PXParentAttribute.SelectParent(sender, e.Row, typeof(BAccount));
                if (baccount != null)
                {
                    record.VPaymentInfoLocationID = baccount.DefLocationID;

                    Location mainloc = PXSelect <CR.Location, Where <CR.Location.bAccountID, Equal <Required <CR.Location.bAccountID> >, And <CR.Location.locationID, Equal <Required <CR.Location.locationID> > > > > .Select(sender.Graph, baccount.BAccountID, baccount.DefLocationID);

                    if (mainloc != null)
                    {
                        if (record.DefAddressID != record.VRemitAddressID && mainloc.VRemitAddressID != record.VRemitAddressID)
                        {
                            Address copyaddr = FindAddress(record.VRemitAddressID);
                            RemitAddress.Delete(copyaddr);
                        }

                        if (record.DefContactID != record.VRemitContactID && mainloc.VRemitContactID != record.VRemitContactID)
                        {
                            Contact copycont = FindContact(record.VRemitContactID);
                            RemitContact.Delete(copycont);
                        }
                    }
                }

                record.VCashAccountID   = null;
                record.VPaymentMethodID = null;
                record.VPaymentLeadTime = 0;
                record.VSeparateCheck   = false;
                record.VRemitAddressID  = null;
                record.VRemitContactID  = null;
            }
        }