예제 #1
0
        private static bool IsNecessaryToUpdateTimeCards(
            PXCache appointmentCache,
            AppointmentCore.AppointmentEmployees_View appointmentEmployees,
            FSAppointment fsAppointmentRow)
        {
            DateTime?oldActualDateTimeBegin = (DateTime?)appointmentCache.GetValueOriginal <FSAppointment.actualDateTimeBegin>(fsAppointmentRow);
            DateTime?oldActualDateTimeEnd   = (DateTime?)appointmentCache.GetValueOriginal <FSAppointment.actualDateTimeEnd>(fsAppointmentRow);
            DateTime?oldExecutionDate       = (DateTime?)appointmentCache.GetValueOriginal <FSAppointment.executionDate>(fsAppointmentRow);
            string   oldDocDesc             = (string)appointmentCache.GetValueOriginal <FSAppointment.docDesc>(fsAppointmentRow);
            bool     appointmentModified    = false;

            if (fsAppointmentRow.ActualDateTimeBegin != oldActualDateTimeBegin ||
                fsAppointmentRow.ActualDateTimeEnd != oldActualDateTimeEnd ||
                fsAppointmentRow.ExecutionDate != oldExecutionDate ||
                fsAppointmentRow.DocDesc != oldDocDesc)
            {
                appointmentModified = true;
            }

            if (fsAppointmentRow.Status == ID.Status_Appointment.COMPLETED &&
                (
                    (string)appointmentCache.GetValueOriginal <FSAppointment.status>(fsAppointmentRow) != ID.Status_Appointment.COMPLETED ||
                    appointmentEmployees.Cache.IsInsertedUpdatedDeleted ||
                    appointmentModified))
            {
                return(true);
            }

            return(false);
        }
예제 #2
0
        protected virtual void DefaultRecords(Document row, Contact oldContact, Address oldAddress)
        {
            PXCache cache = Documents.Cache;

            if (row.AllowOverrideContactAddress == true && (row.LocationID != null || row.ContactID != null) &&
                !IsDefaultContactAdress() && !IsContactAddressNoChanged(oldContact, oldAddress))
            {
                WebDialogResult dialogResult = this.Documents.View.Ask((object)null, CR.Messages.Warning, CR.Messages.ReplaceContactDetails,
                                                                       MessageButtons.AbortRetryIgnore,
                                                                       new Dictionary <WebDialogResult, string>()
                {
                    { WebDialogResult.Abort, "Yes" },
                    { WebDialogResult.Retry, "No" },
                    { WebDialogResult.Ignore, "Cancel" }
                }, MessageIcon.Warning);

                if (dialogResult == WebDialogResult.Abort)
                {
                    CRAddressAttribute.DefaultRecord <Document.documentAddressID>(cache, cache.GetMain(row));
                    CRContactAttribute.DefaultRecord <Document.documentContactID>(cache, cache.GetMain(row));
                    cache.SetValue <Document.allowOverrideContactAddress>(row, false);
                }
                else if (dialogResult == WebDialogResult.Ignore)
                {
                    cache.SetValue <Document.bAccountID>(row, cache.GetValueOriginal <Document.bAccountID>(cache.GetMain(row)));
                    cache.SetValue <Document.contactID>(row, cache.GetValueOriginal <Document.contactID>(cache.GetMain(row)));
                }
            }
            else
            {
                if (row.LocationID != null || row.ContactID != null)
                {
                    CRAddressAttribute.DefaultRecord <Document.documentAddressID>(cache, cache.GetMain(row));
                    CRContactAttribute.DefaultRecord <Document.documentContactID>(cache, cache.GetMain(row));
                    cache.SetValue <Document.allowOverrideContactAddress>(row, false);
                }
            }

            if (row.LocationID == null && row.ContactID == null && row.BAccountID == null)
            {
                if (row.AllowOverrideContactAddress == false)
                {
                    CRAddressAttribute.DefaultRecord <Document.documentAddressID>(cache, cache.GetMain(row));
                    CRContactAttribute.DefaultRecord <Document.documentContactID>(cache, cache.GetMain(row));
                    cache.SetValue <Document.allowOverrideContactAddress>(row, false);
                }
            }

            if (IsDefaultContactAdress())
            {
                cache.SetValue <Document.allowOverrideContactAddress>(row, true);
            }
        }
예제 #3
0
        protected virtual void POOrder_RowPersisted(PXCache cache, PXRowPersistedEventArgs e)
        {
            if (e.TranStatus == PXTranStatus.Open && e.Operation == PXDBOperation.Update)
            {
                POOrder poOrderRow       = (POOrder)e.Row;
                string  poOrderOldStatus = (string)cache.GetValueOriginal <POOrder.status>(poOrderRow);

                PXCache poLineCache = Base.Caches[typeof(POLineUOpen)];

                bool          updateLines       = false;
                List <POLine> poLineUpdatedList = new List <POLine>();

                foreach (object row in poLineCache.Updated)
                {
                    if ((bool?)poLineCache.GetValue <POLineUOpen.completed>(row) != false)
                    {
                        updateLines = true;
                    }

                    poLineUpdatedList.Add(SharedFunctions.ConvertToPOLine((POLineUOpen)row));
                }

                if (poOrderOldStatus != poOrderRow.Status || updateLines == true)
                {
                    SharedFunctions.UpdateFSSODetReferences(cache.Graph, serviceOrderView.Cache, poOrderRow, poLineUpdatedList);
                }
            }
        }
        private void VerifyPrepaidContractRelated(PXCache cache, Customer customerRow, FSxCustomer fsxCustomerRow)
        {
            if (fsxCustomerRow.BillingCycleID == (int?)cache.GetValueOriginal <FSxCustomer.billingCycleID>(fsxCustomerRow))
            {
                return;
            }

            if (Setup.Current != null &&
                Setup.Current.CustomerMultipleBillingOptions == false)
            {
                int count = PXSelect <FSServiceOrder,
                                      Where <
                                          FSServiceOrder.billContractPeriodID, IsNotNull,
                                          And <
                                              FSServiceOrder.customerID, Equal <Required <FSServiceOrder.customerID> > > > >
                            .Select(Base, customerRow.BAccountID).Count;

                if (count > 0)
                {
                    cache.RaiseExceptionHandling <FSxCustomer.billingCycleID>(customerRow,
                                                                              fsxCustomerRow.BillingCycleID,
                                                                              new PXSetPropertyException(TX.Error.NO_UPDATE_BILLING_CYCLE_SERVICE_CONTRACT_RELATED, PXErrorLevel.Error));
                    throw new PXException(TX.Error.NO_UPDATE_BILLING_CYCLE_SERVICE_CONTRACT_RELATED);
                }
            }
        }
        private void VerifyPrepaidContractRelated(PXCache cache, FSCustomerBillingSetup fsCustomerBillingSetupRow)
        {
            if (fsCustomerBillingSetupRow.BillingCycleID == (int?)cache.GetValueOriginal <FSCustomerBillingSetup.billingCycleID>(fsCustomerBillingSetupRow))
            {
                return;
            }

            if (Setup.Current != null &&
                Setup.Current.CustomerMultipleBillingOptions == true)
            {
                int count = PXSelectJoin <FSServiceOrder,
                                          InnerJoin <FSSrvOrdType,
                                                     On <FSSrvOrdType.srvOrdType, Equal <FSServiceOrder.srvOrdType> > >,
                                          Where <
                                              FSServiceOrder.billContractPeriodID, IsNotNull,
                                              And <
                                                  FSServiceOrder.customerID, Equal <Required <FSServiceOrder.customerID> >,
                                                  And <
                                                      FSServiceOrder.srvOrdType, Equal <Required <FSServiceOrder.srvOrdType> > > > > >
                            .Select(Base, fsCustomerBillingSetupRow.CustomerID, fsCustomerBillingSetupRow.SrvOrdType).Count;

                if (count > 0)
                {
                    cache.RaiseExceptionHandling <FSCustomerBillingSetup.srvOrdType>(fsCustomerBillingSetupRow,
                                                                                     fsCustomerBillingSetupRow.SrvOrdType,
                                                                                     new PXSetPropertyException(TX.Error.NO_UPDATE_BILLING_CYCLE_SERVICE_CONTRACT_RELATED, PXErrorLevel.Error));
                    throw new PXException(TX.Error.NO_UPDATE_BILLING_CYCLE_SERVICE_CONTRACT_RELATED);
                }
            }
        }
        private static bool DatesVerifier <TExport>(PXCache cache, PXFieldVerifyingEventArgs e)
            where TExport : IBqlField
        {
            EMailSyncAccount row = e.Row as EMailSyncAccount;

            if (row == null)
            {
                return(false);
            }

            var origDate = (DateTime?)cache.GetValueOriginal <TExport>(row);
            var newDate  = (DateTime?)e.NewValue;

            if (origDate == null || newDate == null)
            {
                return(false);
            }

            if (newDate >= PXTimeZoneInfo.Now)
            {
                e.NewValue = origDate;

                cache.RaiseExceptionHandling <TExport>(row, origDate, new PXSetPropertyException(Messages.DateLessNow, PXErrorLevel.Error));

                return(false);
            }

            if (newDate >= origDate)
            {
                cache.RaiseExceptionHandling <TExport>(row, newDate, new PXSetPropertyException(Messages.DateGreaterOld, PXErrorLevel.Warning));
            }

            return(true);
        }
예제 #7
0
        protected virtual void EPActivity_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            EPActivity row = e.Row as EPActivity;

            if (row == null)
            {
                return;
            }

            string status   = ((string)cache.GetValueOriginal <EPActivity.uistatus>(row) ?? ActivityStatusListAttribute.Open);
            bool   editable = status == ActivityStatusListAttribute.Open || status == ActivityStatusListAttribute.Draft || status == ActivityStatusListAttribute.InProcess;

            PXUIFieldAttribute.SetEnabled(cache, row, editable);
            Delete.SetEnabled(editable);
            Complete.SetEnabled(editable);
            CompleteAndFollowUp.SetEnabled(editable);
            CancelActivity.SetEnabled(editable);

            PXUIFieldAttribute.SetEnabled <EPActivity.taskID>(cache, row);
            PXUIFieldAttribute.SetEnabled <EPActivity.uistatus>(cache, row);

            PXUIFieldAttribute.SetEnabled <EPActivity.timeSpent>(cache, row, false);
            PXUIFieldAttribute.SetEnabled <EPActivity.createdByID>(cache, row, false);
            PXUIFieldAttribute.SetEnabled <EPActivity.completedDateTime>(cache, row, false);
            PXUIFieldAttribute.SetEnabled <EPActivity.overtimeSpent>(cache, row, false);
            PXUIFieldAttribute.SetEnabled <EPActivity.timeBillable>(cache, row, false);
            PXUIFieldAttribute.SetEnabled <EPActivity.overtimeBillable>(cache, row, false);

            PXUIFieldAttribute.SetEnabled <EPActivity.reminderDate>(cache, row, row.IsReminderOn == true);

            GotoParentActivity.SetEnabled(row.ParentTaskID != null);

            this.ChildActivities.Cache.AllowDelete             =
                this.ReferencedTasks.Cache.AllowInsert         =
                    this.ReferencedTasks.Cache.AllowUpdate     =
                        this.ReferencedTasks.Cache.AllowDelete = editable;

            int timespent        = 0;
            int overtimespent    = 0;
            int timebillable     = 0;
            int overtimebillable = 0;

            foreach (EPActivity child in ChildActivities.Select(row.TaskID))
            {
                timespent        += (child.TimeSpent ?? 0);
                overtimespent    += (child.OvertimeSpent ?? 0);
                timebillable     += (child.TimeBillable ?? 0);
                overtimebillable += (child.OvertimeBillable ?? 0);
            }

            row.TimeSpent        = timespent;
            row.OvertimeSpent    = overtimespent;
            row.TimeBillable     = timebillable;
            row.OvertimeBillable = overtimebillable;
        }
예제 #8
0
        public static void PMTimeActivity_RowPersisting_Handler(PXCache cache, PXGraph graph, PMTimeActivity pmTimeActivityRow, PXRowPersistingEventArgs e)
        {
            FSxPMTimeActivity fsxPMTimeActivityRow = PXCache <PMTimeActivity> .GetExtension <FSxPMTimeActivity>(pmTimeActivityRow);

            if (e.Operation == PXDBOperation.Delete &&
                graph.Accessinfo.ScreenID != SharedFunctions.SetScreenIDToDotFormat(ID.ScreenID.APPOINTMENT))
            {
                if (fsxPMTimeActivityRow.AppointmentID != null &&
                    fsxPMTimeActivityRow.AppEmpID != null)
                {
                    PXUpdate <Set <FSAppointmentEmployee.trackTime, False>,
                              FSAppointmentEmployee,
                              Where <
                                  FSAppointmentEmployee.appointmentID, Equal <Required <FSAppointmentEmployee.appointmentID> >,
                                  And <FSAppointmentEmployee.lineNbr, Equal <Required <FSAppointmentEmployee.lineNbr> > > > >
                    .Update(graph, fsxPMTimeActivityRow.AppointmentID, fsxPMTimeActivityRow.AppEmpID);
                }
            }

            if ((e.Operation == PXDBOperation.Insert || e.Operation == PXDBOperation.Update) &&
                graph.Accessinfo.ScreenID != SharedFunctions.SetScreenIDToDotFormat(ID.ScreenID.APPOINTMENT))
            {
                if (fsxPMTimeActivityRow.AppointmentID != null &&
                    fsxPMTimeActivityRow.AppEmpID != null &&
                    fsxPMTimeActivityRow.ServiceID != null &&
                    (int?)cache.GetValueOriginal <EPActivityApprove.timeSpent>(pmTimeActivityRow) != pmTimeActivityRow.TimeSpent)
                {
                    AppointmentEntry graphAppointmentEntry = PXGraph.CreateInstance <AppointmentEntry>();

                    FSAppointment fsAppointmentRow = PXSelect <FSAppointment,
                                                               Where <FSAppointment.appointmentID, Equal <Required <FSAppointment.appointmentID> > > >
                                                     .Select(graph, fsxPMTimeActivityRow.AppointmentID);

                    FSAppointmentEmployee fsAppointmentEmployeeRow = PXSelect <FSAppointmentEmployee,
                                                                               Where <
                                                                                   FSAppointmentEmployee.appointmentID, Equal <Required <FSAppointmentEmployee.appointmentID> >,
                                                                                   And <FSAppointmentEmployee.lineNbr, Equal <Required <FSAppointmentEmployee.lineNbr> > > > >
                                                                     .Select(graph, fsxPMTimeActivityRow.AppointmentID, fsxPMTimeActivityRow.AppEmpID);

                    fsAppointmentRow = graphAppointmentEntry.AppointmentRecords.Current = graphAppointmentEntry.AppointmentRecords.Search <FSAppointment.appointmentID>
                                                                                              (fsAppointmentRow.AppointmentID, fsAppointmentRow.SrvOrdType);

                    graphAppointmentEntry.SkipTimeCardUpdate = true;
                    fsAppointmentEmployeeRow.ActualDuration  = pmTimeActivityRow.TimeSpent;
                    AppointmentDateTimeHelper.UpdateStaffActualDateTimeEndFromActualDuration(fsAppointmentEmployeeRow);
                    fsAppointmentEmployeeRow.EarningType = pmTimeActivityRow.EarningTypeID;
                    fsAppointmentEmployeeRow             = graphAppointmentEntry.AppointmentEmployees.Update(fsAppointmentEmployeeRow);
                    graphAppointmentEntry.Save.Press();
                }
            }
        }
예제 #9
0
        protected virtual void Contact_RowPersisted(PXCache sender, PXRowPersistedEventArgs e)
        {
            Contact row = e.Row as Contact;

            if (row == null || e.TranStatus != PXTranStatus.Open)
            {
                return;
            }
            if (CRGrammProcess.PersistGrams(this, row) &&
                Setup.Current.ValidateContactDuplicatesOnEntry == true &&
                Object.Equals(sender.GetValue <Contact.duplicateStatus>(e.Row), sender.GetValueOriginal <Contact.duplicateStatus>(e.Row)))
            {
                row.DuplicateStatus = DuplicateStatusAttribute.NotValidated;
            }
        }
예제 #10
0
        private void VerifyPrepaidContractRelated(PXCache cache, FSBillingCycle fsBillingCycleRow)
        {
            if (fsBillingCycleRow.BillingBy == (string)cache.GetValueOriginal <FSBillingCycle.billingBy>(fsBillingCycleRow))
            {
                return;
            }

            if (Setup.Current != null)
            {
                int count = 0;

                if (Setup.Current.CustomerMultipleBillingOptions == false)
                {
                    count = PXSelectJoin <Customer,
                                          InnerJoin <FSBillingCycle,
                                                     On <FSBillingCycle.billingCycleID, Equal <FSxCustomer.billingCycleID> >,
                                                     InnerJoin <FSServiceOrder,
                                                                On <FSServiceOrder.customerID, Equal <Customer.bAccountID> > > >,
                                          Where <
                                              FSServiceOrder.billContractPeriodID, IsNotNull,
                                              And <
                                                  FSBillingCycle.billingCycleID, Equal <Required <FSBillingCycle.billingCycleID> > > > >
                            .Select(this, fsBillingCycleRow.BillingCycleID).Count;
                }
                else
                {
                    count = PXSelectJoin <FSCustomerBillingSetup,
                                          InnerJoin <FSSrvOrdType,
                                                     On <FSSrvOrdType.srvOrdType, Equal <FSCustomerBillingSetup.srvOrdType> >,
                                                     InnerJoin <FSServiceOrder,
                                                                On <FSServiceOrder.srvOrdType, Equal <FSSrvOrdType.srvOrdType>,
                                                                    And <FSServiceOrder.cBID, Equal <FSCustomerBillingSetup.cBID> > > > >,
                                          Where <
                                              FSServiceOrder.billContractPeriodID, IsNotNull,
                                              And <
                                                  FSCustomerBillingSetup.billingCycleID, Equal <Required <FSCustomerBillingSetup.billingCycleID> > > > >
                            .Select(this, fsBillingCycleRow.BillingCycleID).Count;
                }

                if (count > 0)
                {
                    cache.RaiseExceptionHandling <FSBillingCycle.billingCycleCD>(fsBillingCycleRow,
                                                                                 fsBillingCycleRow.BillingCycleCD,
                                                                                 new PXSetPropertyException(TX.Error.NO_UPDATE_BILLING_CYCLE_SERVICE_CONTRACT_RELATED, PXErrorLevel.Error));
                    throw new PXException(TX.Error.NO_UPDATE_BILLING_CYCLE_SERVICE_CONTRACT_RELATED);
                }
            }
        }
예제 #11
0
        protected virtual void _(Events.RowPersisted <POOrder> e)
        {
            POOrder poOrderRow = (POOrder)e.Row;
            PXCache cache      = e.Cache;

            if (poOrderRow.OrderType != POOrderType.RegularOrder)
            {
                return;
            }

            if (e.TranStatus == PXTranStatus.Open)
            {
                if (e.Operation == PXDBOperation.Delete)
                {
                    ClearFSSODetReferences(cache.Graph, poOrderRow);
                }
                else if (e.Operation == PXDBOperation.Update)
                {
                    string poOrderOldStatus = (string)cache.GetValueOriginal <POOrder.status>(poOrderRow);

                    bool          updateLines       = false;
                    List <POLine> poLineUpdatedList = new List <POLine>();

                    foreach (object row in Base.Transactions.Cache.Updated)
                    {
                        if ((bool?)Base.Transactions.Cache.GetValue <POLine.completed>(row) != (bool?)Base.Transactions.Cache.GetValueOriginal <POLine.completed>(row))
                        {
                            updateLines = true;
                        }

                        poLineUpdatedList.Add((POLine)row);
                    }

                    if (poOrderOldStatus != poOrderRow.Status || updateLines == true)
                    {
                        if (poOrderRow.Status == POOrderStatus.Cancelled || poOrderRow.Status == POOrderStatus.Voided)
                        {
                            ClearFSSODetReferences(cache.Graph, poOrderRow);
                        }
                        else
                        {
                            SharedFunctions.UpdateFSSODetReferences(cache.Graph, serviceOrderView.Cache, poOrderRow, poLineUpdatedList);
                        }
                    }
                }
            }
        }
예제 #12
0
        protected virtual void EPTimeCard_RowPersisted(PXCache cache, PXRowPersistedEventArgs e)
        {
            if (e.Row == null ||
                !TimeCardHelper.IsTheTimeCardIntegrationEnabled(Base))
            {
                return;
            }

            EPTimeCard epTimeCardRow = (EPTimeCard)e.Row;

            if (epTimeCardRow.IsApproved == true &&
                (bool)cache.GetValueOriginal <EPTimeCard.isApproved>(epTimeCardRow) == false &&
                e.TranStatus == PXTranStatus.Open)
            {
                UpdateAppointmentFromApprovedTimeCard(cache);
            }
        }
        protected virtual void CRActivity_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            var row = e.Row as CRActivity;

            if (row == null)
            {
                return;
            }

            string status     = ((string)cache.GetValueOriginal <CRActivity.uistatus>(row) ?? ActivityStatusListAttribute.Open);
            bool   editable   = status == ActivityStatusListAttribute.Open || status == ActivityStatusListAttribute.Draft || status == ActivityStatusListAttribute.InProcess;
            bool   deleteable = ChildActivities.SelectByParentNoteID(row.NoteID).RowCast <CRPMTimeActivity>().All(o => o.IsBillable != true);

            PXUIFieldAttribute.SetEnabled(cache, row, editable);
            Delete.SetEnabled(deleteable);
            Complete.SetEnabled(editable);
            CompleteAndFollowUp.SetEnabled(editable);
            CancelActivity.SetEnabled(editable);
            AddNewRelatedTask.SetEnabled(cache.GetStatus(row) != PXEntryStatus.Inserted);

            PXUIFieldAttribute.SetEnabled <CRActivity.noteID>(cache, row);
            PXUIFieldAttribute.SetEnabled <CRActivity.uistatus>(cache, row);
            PXUIFieldAttribute.SetEnabled <CRActivity.source>(cache, row, false);
            PXUIFieldAttribute.SetEnabled <CRActivity.createdByID>(cache, row, false);
            PXUIFieldAttribute.SetEnabled <CRActivity.completedDate>(cache, row, false);

            GotoParentActivity.SetEnabled(row.ParentNoteID != null);

            ChildActivities.Cache.AllowDelete             =
                ReferencedTasks.Cache.AllowInsert         =
                    ReferencedTasks.Cache.AllowUpdate     =
                        ReferencedTasks.Cache.AllowDelete = editable;


            var tAct      = (PMTimeActivity)TimeActivity.SelectSingle();
            var tActCache = TimeActivity.Cache;

            PXUIFieldAttribute.SetEnabled <PMTimeActivity.projectID>(tActCache, tAct, editable);
            PXUIFieldAttribute.SetEnabled <PMTimeActivity.projectTaskID>(tActCache, tAct, editable);

            PXUIFieldAttribute.SetEnabled <CRReminder.isReminderOn>(Reminder.Cache, Reminder.SelectSingle(), editable);
            PXUIFieldAttribute.SetEnabled <CRActivity.parentNoteID>(cache, row, false);

            MarkAs(cache, row, Accessinfo.UserID, EPViewStatusAttribute.VIEWED);
        }
        protected virtual void CRActivity_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)
        {
            var row    = e.Row as CRActivity;
            var oldRow = (CRActivity)e.OldRow;

            if (row == null || oldRow == null)
            {
                return;
            }

            if (row.UIStatus == ActivityStatusListAttribute.Completed)
            {
                row.PercentCompletion = 100;
                if (!object.Equals(sender.GetValueOriginal <CRActivity.uistatus>(row), ActivityStatusListAttribute.Completed))
                {
                    row.CompletedDate = PXTimeZoneInfo.Now;
                }
            }
        }
예제 #15
0
        private static T GetOriginal <T>(PXCache cache, object row)
            where T : class, IBqlTable, new()
        {
            if (cache.GetStatus(row) == PXEntryStatus.Inserted || cache.GetStatus(row) == PXEntryStatus.InsertedDeleted)
            {
                return(null);
            }

            T original = new T();

            cache.Keys.ForEach(s => cache.SetValue(original, s, cache.GetValueOriginal(row, s)));

            if (cache.IsKeysFilled(original))
            {
                cache.Fields.Except(cache.Keys).ForEach(s => cache.SetValue(original, s, cache.GetValueOriginal(row, s)));
                return(original);
            }
            return(null);
        }
        /// <summary>
        /// Checks if the value of a field has been updated during the round-trip.
        /// </summary>
        public static bool IsValueUpdated <TValue, TField>(this PXCache cache, object row,
                                                           IEqualityComparer <TValue> comparer = default(IEqualityComparer <TValue>))
            where TField : IBqlField
        {
            if (cache.GetStatus(row) != PXEntryStatus.Updated)
            {
                throw new ArgumentException("Row is not in Updated status", nameof(row));
            }

            if (comparer == null)
            {
                comparer = EqualityComparer <TValue> .Default;
            }

            TValue current  = (TValue)cache.GetValue <TField>(row);
            TValue original = (TValue)cache.GetValueOriginal <TField>(row);

            return(!comparer.Equals(current, original));
        }
        public virtual void INItemSite_InvtSubID_CommandPreparing(PXCache sender, PXCommandPreparingEventArgs e)
        {
            if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Update)
            {
                if ((bool?)sender.GetValueOriginal <INItemSite.overrideInvtAcctSub>(e.Row) == true && ((INItemSite)e.Row).OverrideInvtAcctSub != true)
                {
                    sender.SetValue <INItemSite.invtSubID>(e.Row, null);
                    e.Value = null;
                    return;
                }
            }

            if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Insert || (e.Operation & PXDBOperation.Command) == PXDBOperation.Update)
            {
                if (((INItemSite)e.Row).OverrideInvtAcctSub != true)
                {
                    e.ExcludeFromInsertUpdate();
                }
            }
        }
        protected virtual void CRMarketingList_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            CRMarketingList row = e.Row as CRMarketingList;

            if (row == null || row.IsDynamic == true)
            {
                return;
            }

            var origDynamic = (bool?)sender.GetValueOriginal <CRMarketingList.isDynamic>(row);

            if (origDynamic != true)
            {
                return;
            }

            MailRecipients
            .Select()
            .Where(_ => ((CRMarketingListMember)_).IsSubscribed != true)
            .ForEach(_ => this.Caches[typeof(CRMarketingListMember)].Delete(_));
        }
예제 #19
0
        public bool GrammSourceUpdated(DuplicateDocument document)
        {
            var main = graph.Caches[typeof(DuplicateDocument)].GetMain(document);

            PXCache cache = graph.Caches[main.GetType()];

            if (cache.GetStatus(main) == PXEntryStatus.Inserted || cache.GetStatus(main) == PXEntryStatus.Notchanged)
            {
                return(false);
            }

            if (Definition.ContactRules(document.ContactType)
                .Any(rule => !String.Equals(
                         cache.GetValue(main, rule.MatchingField)?.ToString(),
                         cache.GetValueOriginal(main, rule.MatchingField)?.ToString(),
                         StringComparison.InvariantCultureIgnoreCase)))
            {
                return(false);
            }

            return(true);
        }
        public static void UpdateServiceOrderHeader(
            ServiceOrderEntry graphServiceOrderEntry,
            PXCache cache,
            CRCase crCaseRow,
            FSCreateServiceOrderOnCaseFilter fsCreateServiceOrderOnCaseFilterRow,
            FSServiceOrder fsServiceOrderRow,
            bool updatingExistingSO)
        {
            if (fsServiceOrderRow.Status == ID.Status_ServiceOrder.CLOSED)
            {
                return;
            }

            bool somethingChanged = false;

            FSSrvOrdType fsSrvOrdTypeRow = GetServiceOrderType(graphServiceOrderEntry, fsServiceOrderRow.SrvOrdType);

            if (fsSrvOrdTypeRow.Behavior != ID.Behavior_SrvOrderType.INTERNAL_APPOINTMENT)
            {
                if (fsServiceOrderRow.CustomerID != crCaseRow.CustomerID)
                {
                    graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.customerID>(fsServiceOrderRow, crCaseRow.CustomerID);
                    somethingChanged = true;
                }

                if (fsServiceOrderRow.LocationID != crCaseRow.LocationID)
                {
                    graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.locationID>(fsServiceOrderRow, crCaseRow.LocationID);
                    somethingChanged = true;
                }
            }

            if (fsServiceOrderRow.BranchLocationID != fsCreateServiceOrderOnCaseFilterRow.BranchLocationID)
            {
                graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.branchLocationID>(fsServiceOrderRow, fsCreateServiceOrderOnCaseFilterRow.BranchLocationID);
                somethingChanged = true;
            }

            if (fsServiceOrderRow.ContactID != crCaseRow.ContactID)
            {
                graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.contactID>(fsServiceOrderRow, crCaseRow.ContactID);
                somethingChanged = true;
            }

            if (fsServiceOrderRow.DocDesc != crCaseRow.Subject)
            {
                graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.docDesc>(fsServiceOrderRow, crCaseRow.Subject);
                somethingChanged = true;
            }

            if (crCaseRow.OwnerID != null)
            {
                if (crCaseRow.OwnerID != (Guid?)cache.GetValueOriginal <CROpportunity.ownerID>(crCaseRow))
                {
                    int?salesPersonID = GetSalesPersonID(graphServiceOrderEntry, crCaseRow.OwnerID);

                    if (salesPersonID != null)
                    {
                        graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.salesPersonID>(fsServiceOrderRow, salesPersonID);
                        somethingChanged = true;
                    }
                }
            }

            if (crCaseRow.CreatedDateTime.HasValue &&
                fsServiceOrderRow.OrderDate != crCaseRow.CreatedDateTime.Value.Date)
            {
                graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.orderDate>(fsServiceOrderRow, crCaseRow.CreatedDateTime.Value.Date);
                somethingChanged = true;
            }

            if (fsServiceOrderRow.SLAETA != crCaseRow.SLAETA)
            {
                graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.sLAETA>(fsServiceOrderRow, crCaseRow.SLAETA);
                somethingChanged = true;
            }

            if (fsServiceOrderRow.AssignedEmpID != fsCreateServiceOrderOnCaseFilterRow.AssignedEmpID)
            {
                graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.assignedEmpID>(fsServiceOrderRow, fsCreateServiceOrderOnCaseFilterRow.AssignedEmpID);
                somethingChanged = true;
            }

            if (fsServiceOrderRow.ProblemID != fsCreateServiceOrderOnCaseFilterRow.ProblemID)
            {
                graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.problemID>(fsServiceOrderRow, fsCreateServiceOrderOnCaseFilterRow.ProblemID);
                somethingChanged = true;
            }

            if (fsServiceOrderRow.LongDescr != crCaseRow.Description)
            {
                graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.longDescr>(fsServiceOrderRow, crCaseRow.Description);
                somethingChanged = true;
            }

            if (fsServiceOrderRow.Priority != crCaseRow.Priority)
            {
                graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.priority>(fsServiceOrderRow, crCaseRow.Priority);
                somethingChanged = true;
            }

            if (fsServiceOrderRow.PromisedDate != crCaseRow.ETA)
            {
                graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.promisedDate>(fsServiceOrderRow, crCaseRow.ETA);
                somethingChanged = true;
            }

            if (fsServiceOrderRow.Severity != crCaseRow.Severity)
            {
                graphServiceOrderEntry.ServiceOrderRecords.SetValueExt <FSServiceOrder.severity>(fsServiceOrderRow, crCaseRow.Severity);
                somethingChanged = true;
            }

            if (somethingChanged && updatingExistingSO)
            {
                graphServiceOrderEntry.ServiceOrderRecords.Update(fsServiceOrderRow);
            }
        }
        protected virtual bool IsCommitmentSyncRequired(PXCache sender, POOrder row, POOrder oldRow)
        {
            bool?originalApproved = (bool?)sender.GetValueOriginal <POOrder.approved>(row);             //This hack is required cause when the document is pre-approved by EPApprovalAutomation the RowUpdated event is not fired.

            return(row.Hold != oldRow.Hold || row.Cancelled != oldRow.Cancelled || row.Approved != oldRow.Approved || (row.Approved == true && originalApproved != true));
        }
예제 #22
0
        public static void PMTimeActivity_RowPersisting_Handler(PXCache cache, PXGraph graph, PMTimeActivity pmTimeActivityRow, PXRowPersistingEventArgs e)
        {
            FSxPMTimeActivity fsxPMTimeActivityRow = PXCache <PMTimeActivity> .GetExtension <FSxPMTimeActivity>(pmTimeActivityRow);

            if (e.Operation == PXDBOperation.Delete &&
                graph.Accessinfo.ScreenID != SharedFunctions.SetScreenIDToDotFormat(ID.ScreenID.APPOINTMENT))
            {
                if (fsxPMTimeActivityRow.AppointmentID != null &&
                    fsxPMTimeActivityRow.LogLineNbr != null)
                {
                    PXUpdate <
                        Set <FSAppointmentLog.trackTime, False>,
                        FSAppointmentLog,
                        Where <
                            FSAppointmentLog.docID, Equal <Required <FSAppointmentLog.docID> >,
                            And <FSAppointmentLog.lineNbr, Equal <Required <FSAppointmentLog.lineNbr> > > > >
                    .Update(graph, fsxPMTimeActivityRow.AppointmentID, fsxPMTimeActivityRow.LogLineNbr);
                }
            }

            if ((e.Operation == PXDBOperation.Insert || e.Operation == PXDBOperation.Update) &&
                !IsAccessedFromAppointment(graph.Accessinfo.ScreenID))
            {
                if (fsxPMTimeActivityRow.AppointmentID != null &&
                    fsxPMTimeActivityRow.LogLineNbr != null &&
                    (
                        (int?)cache.GetValueOriginal <EPActivityApprove.timeSpent>(pmTimeActivityRow) != pmTimeActivityRow.TimeSpent ||
                        (int?)cache.GetValueOriginal <EPActivityApprove.timeBillable>(pmTimeActivityRow) != pmTimeActivityRow.TimeBillable ||
                        (bool?)cache.GetValueOriginal <EPActivityApprove.isBillable>(pmTimeActivityRow) != pmTimeActivityRow.IsBillable))
                {
                    AppointmentEntry graphAppointmentEntry = PXGraph.CreateInstance <AppointmentEntry>();

                    FSAppointment fsAppointmentRow = PXSelect <FSAppointment,
                                                               Where <
                                                                   FSAppointment.appointmentID, Equal <Required <FSAppointment.appointmentID> > > >
                                                     .Select(graph, fsxPMTimeActivityRow.AppointmentID);

                    FSAppointmentLog fsAppointmentLogRow = PXSelect <FSAppointmentLog,
                                                                     Where <
                                                                         FSAppointmentLog.docID, Equal <Required <FSAppointmentLog.docID> >,
                                                                         And <FSAppointmentLog.lineNbr, Equal <Required <FSAppointmentLog.lineNbr> > > > >
                                                           .Select(graph, fsxPMTimeActivityRow.AppointmentID, fsxPMTimeActivityRow.LogLineNbr);

                    fsAppointmentRow = graphAppointmentEntry.AppointmentRecords.Current = graphAppointmentEntry.AppointmentRecords.Search <FSAppointment.appointmentID>
                                                                                              (fsAppointmentRow.AppointmentID, fsAppointmentRow.SrvOrdType);

                    graphAppointmentEntry.SkipTimeCardUpdate = true;
                    fsAppointmentLogRow.TimeDuration         = pmTimeActivityRow.TimeSpent;
                    fsAppointmentLogRow.EarningType          = pmTimeActivityRow.EarningTypeID;

                    FSSrvOrdType fsSrvOrdTypeRow = graphAppointmentEntry.ServiceOrderTypeSelected.Current;

                    if (fsSrvOrdTypeRow != null &&
                        fsSrvOrdTypeRow.PostTo == ID.SrvOrdType_PostTo.PROJECTS &&
                        fsSrvOrdTypeRow.BillingType == ID.SrvOrdType_BillingType.COST_AS_COST &&
                        fsSrvOrdTypeRow.CreateTimeActivitiesFromAppointment == true)
                    {
                        fsAppointmentLogRow.IsBillable           = pmTimeActivityRow.IsBillable;
                        fsAppointmentLogRow.BillableTimeDuration = pmTimeActivityRow.TimeBillable;
                    }

                    fsAppointmentLogRow = graphAppointmentEntry.LogRecords.Update(fsAppointmentLogRow);
                    graphAppointmentEntry.Save.Press();
                }
            }
        }
        protected virtual void FSCustomerBillingSetup_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            FSCustomerBillingSetup fsCustomerBillingSetup = (FSCustomerBillingSetup)e.Row;
            FSxCustomer            fsxCustomerRow         = PXCache <Customer> .GetExtension <FSxCustomer>(Base.BAccount.Current);

            if (cache.GetStatus(fsCustomerBillingSetup) == PXEntryStatus.Updated)
            {
                bool insertNewRow = IsCBIDRelatedToPostedDocuments(fsCustomerBillingSetup.CBID);

                if (insertNewRow)
                {
                    fsxCustomerRow.BillingOptionsChanged = true;

                    cache.SetValue <FSCustomerBillingSetup.active>(fsCustomerBillingSetup, false);

                    FSCustomerBillingSetup newCustomerBilingSetupRow = new FSCustomerBillingSetup();
                    var tempFSCustomerBillingSetupCache = new PXCache <FSCustomerBillingSetup>(Base);
                    newCustomerBilingSetupRow.CustomerID = fsCustomerBillingSetup.CustomerID;
                    newCustomerBilingSetupRow.SrvOrdType = fsCustomerBillingSetup.SrvOrdType;
                    newCustomerBilingSetupRow.Active     = true;
                    newCustomerBilingSetupRow            = (FSCustomerBillingSetup)tempFSCustomerBillingSetupCache.Insert(newCustomerBilingSetupRow);

                    foreach (var field in cache.Fields)
                    {
                        if (!cache.Keys.Contains(field) &&
                            field.ToLower() != typeof(FSCustomerBillingSetup.active).Name.ToLower())
                        {
                            tempFSCustomerBillingSetupCache.SetValue(
                                newCustomerBilingSetupRow,
                                field.ToString(),
                                cache.GetValue(
                                    fsCustomerBillingSetup, field.ToString()));
                        }
                    }

                    tempFSCustomerBillingSetupCache.Persist(PXDBOperation.Insert);

                    foreach (var field in cache.Fields)
                    {
                        if (!cache.Keys.Contains(field) &&
                            field.ToLower() != typeof(FSCustomerBillingSetup.active).Name.ToLower())
                        {
                            cache.SetValue(
                                fsCustomerBillingSetup,
                                field.ToString(),
                                cache.GetValueOriginal(
                                    fsCustomerBillingSetup,
                                    field.ToString()));
                        }
                    }

                    cache.SetValue <FSCustomerBillingSetup.active>(fsCustomerBillingSetup, false);
                }
            }

            if (e.Operation == PXDBOperation.Update)
            {
                VerifyPrepaidContractRelated(cache, fsCustomerBillingSetup);
            }
        }
예제 #24
0
 public object GetValueOriginal <T>(PXCache cache, object record)
     where T : IBqlField
 {
     return(cache.GetValueOriginal <T>(record));
 }
예제 #25
0
        public static void InsertUpdateDeleteTimeActivities(
            AppointmentEntry graphAppointmentEntry,
            PXCache appointmentCache,
            FSAppointment fsAppointmentRow,
            FSServiceOrder fsServiceOrderRow,
            AppointmentCore.AppointmentEmployees_View appointmentEmployees,
            List <FSAppointmentEmployee> deleteReleatedTimeActivity,
            List <FSAppointmentEmployee> createReleatedTimeActivity)
        {
            if (!TimeCardHelper.IsTheTimeCardIntegrationEnabled(graphAppointmentEntry) ||
                (fsAppointmentRow.Status != ID.Status_Appointment.COMPLETED &&
                 fsAppointmentRow.Status != ID.Status_Appointment.MANUAL_SCHEDULED))
            {
                return;
            }

            if (PXAccess.FeatureInstalled <FeaturesSet.timeReportingModule>() == false)
            {
                return;
            }

            EmployeeActivitiesEntry graphEmployeeActivitiesEntry = PXGraph.CreateInstance <EmployeeActivitiesEntry>();

            if (IsNecessaryToUpdateTimeCards(appointmentCache, appointmentEmployees, fsAppointmentRow))
            {
                foreach (FSAppointmentEmployee fsAppointmentEmployee in appointmentEmployees.Select().Where(y => ((FSAppointmentEmployee)y).Type == BAccountType.EmployeeType))
                {
                    EPActivityApprove epActivityApproveRow    = null;
                    EPActivityApprove oldEPActivityApproveRow = null;
                    TMEPEmployee      epEmployeeRow           = null;
                    int?oldEmployeeIDValue;

                    FindTMEmployee(graphAppointmentEntry, fsAppointmentEmployee.EmployeeID, ref epEmployeeRow);
                    FindEPActivityApprove(graphAppointmentEntry, fsAppointmentEmployee, epEmployeeRow, ref epActivityApproveRow);

                    if (fsAppointmentEmployee.TrackTime == true)
                    {
                        oldEmployeeIDValue = (int?)graphAppointmentEntry.AppointmentEmployees.Cache.GetValueOriginal <FSAppointmentEmployee.employeeID>(fsAppointmentEmployee);
                        if (oldEmployeeIDValue != fsAppointmentEmployee.EmployeeID)
                        {
                            TMEPEmployee oldEPEmployeeRow = null;
                            FindTMEmployee(graphAppointmentEntry, oldEmployeeIDValue, ref oldEPEmployeeRow);
                            FindEPActivityApprove(graphAppointmentEntry, fsAppointmentEmployee, oldEPEmployeeRow, ref oldEPActivityApproveRow);
                            DeleteEPActivityApprove(graphEmployeeActivitiesEntry, oldEPActivityApproveRow);
                        }

                        InsertUpdateEPActivityApprove(graphAppointmentEntry, graphEmployeeActivitiesEntry, fsAppointmentEmployee, fsAppointmentRow, fsServiceOrderRow, epActivityApproveRow, epEmployeeRow);
                    }
                    else
                    {
                        if (epActivityApproveRow != null)
                        {
                            DeleteEPActivityApprove(graphEmployeeActivitiesEntry, epActivityApproveRow);
                        }
                    }
                }

                foreach (FSAppointmentEmployee fsAppointmentEmployee in appointmentEmployees.Cache.Deleted)
                {
                    if (fsAppointmentEmployee.Type == BAccountType.EmployeeType)
                    {
                        SearchAndDeleteEPActivity(graphAppointmentEntry, fsAppointmentEmployee, graphEmployeeActivitiesEntry);
                    }
                }
            }
            else if ((string)appointmentCache.GetValueOriginal <FSAppointment.status>(fsAppointmentRow) == ID.Status_Appointment.COMPLETED &&
                     fsAppointmentRow.Status == ID.Status_Appointment.MANUAL_SCHEDULED)
            {
                foreach (FSAppointmentEmployee fsAppointmentEmployee in appointmentEmployees.Select().Where(y => ((FSAppointmentEmployee)y).Type == BAccountType.EmployeeType))
                {
                    SearchAndDeleteEPActivity(graphAppointmentEntry, fsAppointmentEmployee, graphEmployeeActivitiesEntry);
                }

                foreach (FSAppointmentEmployee fsAppointmentEmployee in appointmentEmployees.Cache.Deleted)
                {
                    if (fsAppointmentEmployee.Type == BAccountType.EmployeeType)
                    {
                        SearchAndDeleteEPActivity(graphAppointmentEntry, fsAppointmentEmployee, graphEmployeeActivitiesEntry);
                    }
                }
            }

            if (deleteReleatedTimeActivity != null)
            {
                //Deleting time activities related with cancelled service lines
                foreach (FSAppointmentEmployee fsAppointmentEmployee in deleteReleatedTimeActivity)
                {
                    if (fsAppointmentEmployee.Type == BAccountType.EmployeeType)
                    {
                        SearchAndDeleteEPActivity(graphAppointmentEntry, fsAppointmentEmployee, graphEmployeeActivitiesEntry);
                    }
                }
            }

            if (createReleatedTimeActivity != null)
            {
                //Creating time activities related with re-opened service lines
                foreach (FSAppointmentEmployee fsAppointmentEmployee in createReleatedTimeActivity)
                {
                    TMEPEmployee epEmployeeRow = null;
                    FindTMEmployee(graphAppointmentEntry, fsAppointmentEmployee.EmployeeID, ref epEmployeeRow);
                    InsertUpdateEPActivityApprove(graphAppointmentEntry, graphEmployeeActivitiesEntry, fsAppointmentEmployee, fsAppointmentRow, fsServiceOrderRow, null, epEmployeeRow);
                }
            }
        }
예제 #26
0
        protected virtual void DefaultRecords(Document row, ChangedData changedForContactInfo, ChangedData changedForShippingInfo)
        {
            PXCache cache = Documents.Cache;

            bool needAskFromContactAddress         = AskForConfirmationForAddress(row, changedForContactInfo);
            bool needAskFromShippingContactAddress = AskForConfirmationForShippingAddress(row, changedForShippingInfo);

            if ((needAskFromContactAddress || needAskFromShippingContactAddress) && (row.LocationID != null || row.ContactID != null))
            {
                string message = needAskFromContactAddress && needAskFromShippingContactAddress ?
                                 CR.Messages.ReplaceContactDetailsAndShippingInfo :
                                 needAskFromContactAddress ? CR.Messages.ReplaceContactDetails :
                                 CR.Messages.ReplaceShippingInfo;
                WebDialogResult dialogResult = this.Documents.View.Ask((object)null, CR.Messages.Warning, message,
                                                                       MessageButtons.AbortRetryIgnore,
                                                                       new Dictionary <WebDialogResult, string>()
                {
                    { WebDialogResult.Abort, "Yes" },
                    { WebDialogResult.Retry, "No" },
                    { WebDialogResult.Ignore, "Cancel" }
                }, MessageIcon.Warning);

                if (dialogResult == WebDialogResult.Abort)
                {
                    if (needAskFromContactAddress)
                    {
                        CRAddressAttribute.DefaultRecord <Document.documentAddressID>(cache, cache.GetMain(row));
                        CRContactAttribute.DefaultRecord <Document.documentContactID>(cache, cache.GetMain(row));
                        cache.SetValue <Document.allowOverrideContactAddress>(row, false);
                    }
                    if (needAskFromShippingContactAddress)
                    {
                        CRShippingContactAttribute.DefaultRecord <Document.shipContactID>(cache, cache.GetMain(row));
                        CRShippingAddressAttribute.DefaultRecord <Document.shipAddressID>(cache, cache.GetMain(row));
                        cache.SetValue <Document.allowOverrideShippingContactAddress>(row, false);
                    }
                }
                else if (dialogResult == WebDialogResult.Ignore)
                {
                    cache.SetValue <Document.bAccountID>(row, cache.GetValueOriginal <Document.bAccountID>(cache.GetMain(row)));
                    cache.SetValue <Document.contactID>(row, cache.GetValueOriginal <Document.contactID>(cache.GetMain(row)));
                }
                else if (dialogResult == WebDialogResult.Retry)
                {
                    if (row.AllowOverrideContactAddress == false)
                    {
                        CRAddressAttribute.DefaultRecord <Document.documentAddressID>(cache, cache.GetMain(row));
                        CRContactAttribute.DefaultRecord <Document.documentContactID>(cache, cache.GetMain(row));
                        cache.SetValue <Document.allowOverrideContactAddress>(row, false);
                    }
                    else if (row.AllowOverrideShippingContactAddress == false)
                    {
                        CRShippingContactAttribute.DefaultRecord <Document.shipContactID>(cache, cache.GetMain(row));
                        CRShippingAddressAttribute.DefaultRecord <Document.shipAddressID>(cache, cache.GetMain(row));
                        cache.SetValue <Document.allowOverrideShippingContactAddress>(row, false);
                    }
                }
            }
            else
            {
                if (IsThereSomeContactAddressSourceValue(cache, row))
                {
                    if (changedForContactInfo.CanBeReplace)
                    {
                        CRAddressAttribute.DefaultRecord <Document.documentAddressID>(cache, cache.GetMain(row));
                        CRContactAttribute.DefaultRecord <Document.documentContactID>(cache, cache.GetMain(row));
                        cache.SetValue <Document.allowOverrideContactAddress>(row, false);
                    }

                    if (changedForShippingInfo.CanBeReplace)
                    {
                        CRShippingContactAttribute.DefaultRecord <Document.shipContactID>(cache, cache.GetMain(row));
                        CRShippingAddressAttribute.DefaultRecord <Document.shipAddressID>(cache, cache.GetMain(row));
                        cache.SetValue <Document.allowOverrideShippingContactAddress>(row, false);
                    }
                }
            }

            if (row.LocationID == null && row.ContactID == null && row.BAccountID == null)
            {
                if (row.AllowOverrideContactAddress == false)
                {
                    CRAddressAttribute.DefaultRecord <Document.documentAddressID>(cache, cache.GetMain(row));
                    CRContactAttribute.DefaultRecord <Document.documentContactID>(cache, cache.GetMain(row));
                    cache.SetValue <Document.allowOverrideContactAddress>(row, false);
                }
                if (row.AllowOverrideShippingContactAddress == false)
                {
                    CRShippingContactAttribute.DefaultRecord <Document.shipContactID>(cache, cache.GetMain(row));
                    CRShippingAddressAttribute.DefaultRecord <Document.shipAddressID>(cache, cache.GetMain(row));
                    cache.SetValue <Document.allowOverrideShippingContactAddress>(row, false);
                    PXCache cacheContact = GetContactCache();
                    var     contact      = GetCurrentContact();
                    cacheContact.RaiseRowUpdated(contact, contact);
                    PXCache cacheAddress = GetAddressCache();
                    var     address      = GetCurrentAddress();
                    cacheAddress.RaiseRowUpdated(address, address);
                }
            }

            if (IsDefaultContactAdress())
            {
                cache.SetValue <Document.allowOverrideContactAddress>(row, true);
            }
        }
예제 #27
0
            public bool GrammSourceUpdated(Contact contact)
            {
                PXCache cache = graph.Caches[contact.GetType()];

                if (cache.GetStatus(contact) == PXEntryStatus.Inserted ||
                    cache.GetStatus(contact) == PXEntryStatus.Notchanged)
                {
                    return(false);
                }
                if (Definition.ContactRules(contact.ContactType).Any(rule => !object.Equals(cache.GetValue(contact, rule.MatchingField),
                                                                                            cache.GetValueOriginal(contact, rule.MatchingField))))
                {
                    return(false);
                }
                return(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);
            }
        }