protected virtual void _(Events.FieldUpdated <Document, Document.allowOverrideContactAddress> e) { var row = e.Row as Document; if (row == null) { return; } DocumentAddress address = Addresses.SelectSingle(); DocumentContact contact = Contacts.SelectSingle(); if (contact != null) { Contacts.Cache.SetValue <DocumentContact.overrideContact>(contact, row.AllowOverrideContactAddress); PXCache cache = GetContactCache(); if (cache != null) { CRContact crContact = GetCurrentContact(); if (crContact != null) { cache.SetValue <CRContact.isDefaultContact>(crContact, row.AllowOverrideContactAddress != true); } } } if (address != null) { Addresses.Cache.SetValue <DocumentAddress.overrideAddress>(address, row.AllowOverrideContactAddress); PXCache cache = GetAddressCache(); if (cache != null) { CRAddress crAddress = GetCurrentAddress(); if (crAddress != null) { cache.SetValue <CRAddress.isDefaultAddress>(crAddress, row.AllowOverrideContactAddress != true); } } } Addresses.Cache.Update(address); Contacts.Cache.Update(contact); }
protected IAddressBase GetToAddress(FSServiceOrder order) { CRAddress crShipAddress = null; if (crShipAddress != null) { return(crShipAddress); } Address shipAddress = null; Location loc = (Location)PXSelect <Location, Where <Location.bAccountID, Equal <Required <Location.bAccountID> >, And <Location.locationID, Equal <Required <Location.locationID> > > > > . Select(Base, order.BillCustomerID, order.BillLocationID); if (loc != null) { shipAddress = PXSelect <Address, Where <Address.addressID, Equal <Required <Address.addressID> > > > .Select(Base, loc.DefAddressID); } return(shipAddress); }
protected IAddressBase GetToAddress(PMQuote quote) { CRAddress crShipAddress = PXSelect <CRAddress, Where <CRAddress.addressID, Equal <Required <CRAddress.addressID> > > > .Select(Base, quote.OpportunityAddressID); if (crShipAddress != null) { return(crShipAddress); } Address shipAddress = null; CR.Location loc = (CR.Location) PXSelect <CR.Location, Where <CR.Location.bAccountID, Equal <Required <CR.Location.bAccountID> >, And <CR.Location.locationID, Equal <Required <CR.Location.locationID> > > > > . Select(Base, quote.BAccountID, quote.LocationID); if (loc != null) { shipAddress = PXSelect <Address, Where <Address.addressID, Equal <Required <Address.addressID> > > > .Select(Base, loc.DefAddressID); } return(shipAddress); }
public static IAddress GetIAddress(Address source) { if (source == null) { return(null); } var dest = new CRAddress(); dest.BAccountID = source.BAccountID; dest.RevisionID = source.RevisionID; dest.IsDefaultAddress = false; dest.AddressLine1 = source.AddressLine1; dest.AddressLine2 = source.AddressLine2; dest.AddressLine3 = source.AddressLine3; dest.City = source.City; dest.CountryID = source.CountryID; dest.State = source.State; dest.PostalCode = source.PostalCode; dest.IsValidated = source.IsValidated; return(dest); }
private static void ApplyChangesfromAddressInfo(ServiceOrderEntry graphServiceOrderEntry, CRAddress crAddressRow, FSServiceOrder fsServiceOrderRow, ref bool somethingChanged) { if (crAddressRow == null) { return; } if (fsServiceOrderRow.AddressLine1 != crAddressRow.AddressLine1) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.addressLine1>(fsServiceOrderRow, crAddressRow.AddressLine1); somethingChanged = true; } if (fsServiceOrderRow.AddressLine2 != crAddressRow.AddressLine2) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.addressLine2>(fsServiceOrderRow, crAddressRow.AddressLine2); somethingChanged = true; } if (fsServiceOrderRow.AddressLine3 != crAddressRow.AddressLine3) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.addressLine3>(fsServiceOrderRow, crAddressRow.AddressLine3); somethingChanged = true; } if (fsServiceOrderRow.City != crAddressRow.City) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.city>(fsServiceOrderRow, crAddressRow.City); somethingChanged = true; } if (fsServiceOrderRow.CountryID != crAddressRow.CountryID) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.countryID>(fsServiceOrderRow, crAddressRow.CountryID); somethingChanged = true; } if (fsServiceOrderRow.State != crAddressRow.State) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.state>(fsServiceOrderRow, crAddressRow.State); somethingChanged = true; } if (fsServiceOrderRow.PostalCode != crAddressRow.PostalCode) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.postalCode>(fsServiceOrderRow, crAddressRow.PostalCode); somethingChanged = true; } }
public static void UpdateServiceOrderHeader( ServiceOrderEntry graphServiceOrderEntry, PXCache cache, CROpportunity crOpportunityRow, FSCreateServiceOrderOnOpportunityFilter fsCreateServiceOrderOnOpportunityFilterRow, FSServiceOrder fsServiceOrderRow, CRContact crContactRow, CRAddress crAddressRow, bool updatingExistingSO) { bool somethingChanged = false; FSSrvOrdType fsSrvOrdTypeRow = GetServiceOrderType(graphServiceOrderEntry, fsServiceOrderRow.SrvOrdType); if (fsSrvOrdTypeRow.Behavior != ID.Behavior_SrvOrderType.INTERNAL_APPOINTMENT) { if (fsServiceOrderRow.CustomerID != crOpportunityRow.BAccountID) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.customerID>(fsServiceOrderRow, crOpportunityRow.BAccountID); somethingChanged = true; } if (fsServiceOrderRow.LocationID != crOpportunityRow.LocationID) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.locationID>(fsServiceOrderRow, crOpportunityRow.LocationID); somethingChanged = true; } } if (fsServiceOrderRow.BranchID != crOpportunityRow.BranchID) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.branchID>(fsServiceOrderRow, crOpportunityRow.BranchID); somethingChanged = true; } if (fsServiceOrderRow.BranchLocationID != fsCreateServiceOrderOnOpportunityFilterRow.BranchLocationID) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.branchLocationID>(fsServiceOrderRow, fsCreateServiceOrderOnOpportunityFilterRow.BranchLocationID); somethingChanged = true; } if (fsServiceOrderRow.ContactID != crOpportunityRow.ContactID) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.contactID>(fsServiceOrderRow, crOpportunityRow.ContactID); somethingChanged = true; } if (fsServiceOrderRow.DocDesc != crOpportunityRow.Subject) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.docDesc>(fsServiceOrderRow, crOpportunityRow.Subject); somethingChanged = true; } if (fsServiceOrderRow.ProjectID != crOpportunityRow.ProjectID) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.projectID>(fsServiceOrderRow, crOpportunityRow.ProjectID); somethingChanged = true; } if (crOpportunityRow.OwnerID != null) { if (crOpportunityRow.OwnerID != (Guid?)cache.GetValueOriginal <CROpportunity.ownerID>(crOpportunityRow)) { int?salesPersonID = GetSalesPersonID(graphServiceOrderEntry, crOpportunityRow.OwnerID); if (salesPersonID != null) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.salesPersonID>(fsServiceOrderRow, salesPersonID); somethingChanged = true; } } } if (fsServiceOrderRow.OrderDate != crOpportunityRow.CloseDate) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.orderDate>(fsServiceOrderRow, crOpportunityRow.CloseDate); somethingChanged = true; } ApplyChangesfromContactInfo(graphServiceOrderEntry, crContactRow, fsServiceOrderRow, ref somethingChanged); ApplyChangesfromAddressInfo(graphServiceOrderEntry, crAddressRow, fsServiceOrderRow, ref somethingChanged); if (fsServiceOrderRow.TaxZoneID != crOpportunityRow.TaxZoneID) { graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.taxZoneID>(fsServiceOrderRow, crOpportunityRow.TaxZoneID); somethingChanged = true; } if (somethingChanged && updatingExistingSO) { graphServiceOrderEntry.ServiceOrderRecords.Update(fsServiceOrderRow); } }