protected virtual void _(Events.RowSelected <CROpportunity> e)
        {
            if (e.Row == null)
            {
                return;
            }

            CROpportunity crOpportunityRow = (CROpportunity)e.Row;
            PXCache       cache            = e.Cache;

            FSxCROpportunity fsxCROpportunityRow = cache.GetExtension <FSxCROpportunity>(crOpportunityRow);

            FSServiceOrder fsServiceOrderRow = CRExtensionHelper.GetRelatedServiceOrder(Base, cache, crOpportunityRow, fsxCROpportunityRow.SOID);
            FSSrvOrdType   fsSrvOrdTypeRow   = null;

            if (fsServiceOrderRow != null)
            {
                fsSrvOrdTypeRow = CRExtensionHelper.GetServiceOrderType(Base, fsServiceOrderRow.SrvOrdType);
            }

            EnableDisableExtensionFields(cache, fsxCROpportunityRow, fsServiceOrderRow);
            EnableDisableActions(cache, crOpportunityRow, fsxCROpportunityRow, fsServiceOrderRow, fsSrvOrdTypeRow);
            SetPersistingChecks(cache, crOpportunityRow, fsxCROpportunityRow, fsSrvOrdTypeRow);

            HideOrShowFieldsActionsByInventoryFeature();
        }
        protected virtual void _(Events.FieldUpdated <CROpportunity, FSxCROpportunity.sDEnabled> e)
        {
            if (e.Row == null)
            {
                return;
            }

            CROpportunity    crOpportunityRow    = (CROpportunity)e.Row;
            FSxCROpportunity fsxCROpportunityRow = e.Cache.GetExtension <FSxCROpportunity>(crOpportunityRow);

            if (fsxCROpportunityRow.SDEnabled == true)
            {
                FSSetup fsSetupRow = GetFSSetup();

                if (fsSetupRow != null &&
                    fsSetupRow.DfltOpportunitySrvOrdType != null)
                {
                    fsxCROpportunityRow.SrvOrdType = fsSetupRow.DfltOpportunitySrvOrdType;
                }

                SetBranchLocationID(Base, crOpportunityRow, fsxCROpportunityRow);
                Base.Opportunity.SetValueExt <CROpportunity.allowOverrideContactAddress>(crOpportunityRow, true);
            }
            else
            {
                fsxCROpportunityRow.BranchLocationID = null;
            }
        }
        public virtual void SetPersistingChecks(PXCache cache,
                                                CROpportunity crOpportunityRow,
                                                FSxCROpportunity fsxCROpportunityRow,
                                                FSSrvOrdType fsSrvOrdTypeRow)
        {
            if (fsxCROpportunityRow.SDEnabled == true)
            {
                PXDefaultAttribute.SetPersistingCheck <FSxCROpportunity.srvOrdType>(cache, crOpportunityRow, PXPersistingCheck.NullOrBlank);
                PXDefaultAttribute.SetPersistingCheck <FSxCROpportunity.branchLocationID>(cache, crOpportunityRow, PXPersistingCheck.NullOrBlank);

                if (fsSrvOrdTypeRow == null)
                {
                    fsSrvOrdTypeRow = CRExtensionHelper.GetServiceOrderType(Base, fsxCROpportunityRow.SrvOrdType);
                }

                if (fsSrvOrdTypeRow != null &&
                    fsSrvOrdTypeRow.Behavior != ID.Behavior_SrvOrderType.INTERNAL_APPOINTMENT)
                {
                    PXDefaultAttribute.SetPersistingCheck <CROpportunity.bAccountID>(cache, crOpportunityRow, PXPersistingCheck.NullOrBlank);
                    PXDefaultAttribute.SetPersistingCheck <CROpportunity.locationID>(cache, crOpportunityRow, PXPersistingCheck.NullOrBlank);
                }
            }
            else
            {
                PXDefaultAttribute.SetPersistingCheck <FSxCROpportunity.srvOrdType>(cache, crOpportunityRow, PXPersistingCheck.Nothing);
                PXDefaultAttribute.SetPersistingCheck <FSxCROpportunity.branchLocationID>(cache, crOpportunityRow, PXPersistingCheck.Nothing);
                PXDefaultAttribute.SetPersistingCheck <CROpportunity.bAccountID>(cache, crOpportunityRow, PXPersistingCheck.Nothing);
                PXDefaultAttribute.SetPersistingCheck <CROpportunity.locationID>(cache, crOpportunityRow, PXPersistingCheck.Nothing);
            }
        }
        public virtual void createServiceOrder()
        {
            CROpportunity    crOpportunityRow    = Base.Opportunity.Current;
            FSxCROpportunity fsxCROpportunityRow = Base.Opportunity.Cache.GetExtension <FSxCROpportunity>(crOpportunityRow);

            var products = Base.Products.View.SelectMultiBound(new object[] { crOpportunityRow }).RowCast <CROpportunityProducts>();

            if (products.Any(_ => _.InventoryID == null))
            {
                if (Base.OpportunityCurrent.Ask(TX.Messages.ASK_SALES_ORDER_HAS_NON_INVENTORY_LINES, MessageButtons.OKCancel) == WebDialogResult.Cancel)
                {
                    return;
                }
            }

            if (CreateServiceOrderFilter.AskExt() == WebDialogResult.OK)
            {
                fsxCROpportunityRow.SDEnabled        = true;
                fsxCROpportunityRow.BranchLocationID = CreateServiceOrderFilter.Current.BranchLocationID;
                fsxCROpportunityRow.SrvOrdType       = CreateServiceOrderFilter.Current.SrvOrdType;

                PXLongOperation.StartOperation(Base, delegate()
                {
                    CreateServiceOrderDocument(Base, crOpportunityRow, CreateServiceOrderFilter.Current);
                });
            }
        }
        protected virtual void _(Events.FieldUpdated <CROpportunity, CROpportunity.branchID> e)
        {
            if (e.Row == null)
            {
                return;
            }
            CROpportunity    crOpportunityRow    = (CROpportunity)e.Row;
            FSxCROpportunity fsxCROpportunityRow = e.Cache.GetExtension <FSxCROpportunity>(crOpportunityRow);

            SetBranchLocationID(Base, crOpportunityRow, fsxCROpportunityRow);
        }
        public virtual void EnableDisableCustomFields(PXCache cache,
                                                      CROpportunity crOpportunityRow,
                                                      FSxCROpportunity fsxCROpportunityRow,
                                                      FSServiceOrder fsServiceOrderRow,
                                                      FSSrvOrdType fsSrvOrdTypeRow)
        {
            bool isSMSetup = GetFSSetup() != null;

            PXUIFieldAttribute.SetEnabled <FSxCROpportunity.sDEnabled>(cache, null, isSMSetup && fsServiceOrderRow == null);
            PXUIFieldAttribute.SetEnabled <FSxCROpportunity.srvOrdType>(cache, null, isSMSetup && fsxCROpportunityRow.SDEnabled == true && fsServiceOrderRow == null);
            PXUIFieldAttribute.SetEnabled <FSxCROpportunity.branchLocationID>(cache, null, isSMSetup && fsxCROpportunityRow.SDEnabled == true);
        }
Esempio n. 7
0
        protected void CROpportunity_BranchID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e, PXFieldUpdated upd)
        {
            upd?.Invoke(cache, e);

            if (e.Row == null)
            {
                return;
            }
            CROpportunity    crOpportunityRow    = (CROpportunity)e.Row;
            FSxCROpportunity fsxCROpportunityRow = cache.GetExtension <FSxCROpportunity>(crOpportunityRow);

            SetBranchLocationID(Base, crOpportunityRow, fsxCROpportunityRow);
        }
Esempio n. 8
0
        public virtual void createServiceOrder()
        {
            CROpportunity    crOpportunityRow    = Base.Opportunity.Current;
            FSxCROpportunity fsxCROpportunityRow = Base.Opportunity.Cache.GetExtension <FSxCROpportunity>(crOpportunityRow);

            if (CreateServiceOrderFilter.AskExt() == WebDialogResult.OK)
            {
                fsxCROpportunityRow.SDEnabled        = true;
                fsxCROpportunityRow.BranchLocationID = CreateServiceOrderFilter.Current.BranchLocationID;
                fsxCROpportunityRow.SrvOrdType       = CreateServiceOrderFilter.Current.SrvOrdType;

                PXLongOperation.StartOperation(Base, delegate()
                {
                    CreateServiceOrderDocument(Base, crOpportunityRow, CreateServiceOrderFilter.Current);
                });
            }
        }
Esempio n. 9
0
        private void EnableDisableActions(
            PXCache cache,
            CROpportunity crOpportunityRow,
            FSxCROpportunity fsxCROpportunityRow,
            FSServiceOrder fsServiceOrderRow,
            FSSrvOrdType fsSrvOrdTypeRow)
        {
            bool isSMSetup      = GetFSSetup() != null;
            bool insertedStatus = Base.Opportunity.Cache.GetStatus(Base.Opportunity.Current) == PXEntryStatus.Inserted;

            CreateServiceOrder.SetEnabled(isSMSetup && crOpportunityRow != null && insertedStatus == false && fsServiceOrderRow == null);
            ViewServiceOrder.SetEnabled(isSMSetup && crOpportunityRow != null && crOpportunityRow.OpportunityID != null && fsServiceOrderRow != null);
            OpenAppointmentBoard.SetEnabled(fsServiceOrderRow != null);

            Base.createSalesOrder.SetEnabled(fsServiceOrderRow == null);
            Base.createInvoice.SetEnabled(fsServiceOrderRow == null);
        }
        public virtual void openAppointmentBoard()
        {
            if (Base.Opportunity == null || Base.Opportunity.Current == null)
            {
                return;
            }

            if (Base.IsDirty)
            {
                Base.Save.Press();
            }

            FSxCROpportunity fsxCROpportunityRow = Base.Opportunity.Cache.GetExtension <FSxCROpportunity>(Base.Opportunity.Current);

            if (fsxCROpportunityRow != null && fsxCROpportunityRow.SOID != null)
            {
                CRExtensionHelper.LaunchEmployeeBoard(Base, fsxCROpportunityRow.SOID);
            }
        }
        public virtual void viewServiceOrder()
        {
            if (Base.Opportunity == null || Base.Opportunity.Current == null)
            {
                return;
            }

            if (Base.IsDirty)
            {
                Base.Save.Press();
            }

            FSxCROpportunity fsxCROpportunityRow = Base.Opportunity.Cache.GetExtension <FSxCROpportunity>(Base.Opportunity.Current);

            if (fsxCROpportunityRow != null && fsxCROpportunityRow.SOID != null)
            {
                CRExtensionHelper.LaunchServiceOrderScreen(Base, fsxCROpportunityRow.SOID);
            }
        }
        protected virtual void GetCallerEntity(Guid?refNoteID)
        {
            if (refNoteID != null)
            {
                CRCase crCaseRow = PXSelect <CRCase,
                                             Where <
                                                 CRCase.noteID, Equal <Required <CRCase.noteID> > > >
                                   .Select(Base, refNoteID);

                if (crCaseRow != null)
                {
                    FSxCRCase fsxCRCaseRow = PXCache <CRCase> .GetExtension <FSxCRCase>(crCaseRow);

                    if (fsxCRCaseRow != null && fsxCRCaseRow.SDEnabled == false)
                    {
                        _disableServiceID = false;
                    }

                    _callerEntity = typeof(CRCase);
                }
                else
                {
                    CROpportunity crOpportuniyRow = PXSelect <CROpportunity,
                                                              Where <
                                                                  CROpportunity.noteID, Equal <Required <CROpportunity.noteID> > > >
                                                    .Select(Base, refNoteID);

                    if (crOpportuniyRow != null)
                    {
                        FSxCROpportunity fsxCROpportunityRow = PXCache <CROpportunity> .GetExtension <FSxCROpportunity>(crOpportuniyRow);

                        if (fsxCROpportunityRow != null && fsxCROpportunityRow.SDEnabled == true)
                        {
                            _disableServiceID = false;
                        }

                        _callerEntity = typeof(CROpportunity);
                    }
                }
            }
        }
Esempio n. 13
0
        protected void CROpportunity_RowSelected(PXCache cache, PXRowSelectedEventArgs e, PXRowSelected sel)
        {
            sel?.Invoke(cache, e);

            if (e.Row == null)
            {
                return;
            }

            CROpportunity    crOpportunityRow    = (CROpportunity)e.Row;
            FSxCROpportunity fsxCROpportunityRow = cache.GetExtension <FSxCROpportunity>(crOpportunityRow);

            FSServiceOrder fsServiceOrderRow = CRExtensionHelper.GetRelatedServiceOrder(Base, cache, crOpportunityRow, fsxCROpportunityRow.SOID);
            FSSrvOrdType   fsSrvOrdTypeRow   = null;

            if (fsServiceOrderRow != null)
            {
                fsSrvOrdTypeRow = CRExtensionHelper.GetServiceOrderType(Base, fsServiceOrderRow.SrvOrdType);
            }

            EnableDisableCustomFields(cache, crOpportunityRow, fsxCROpportunityRow, fsServiceOrderRow, fsSrvOrdTypeRow);
            EnableDisableActions(cache, crOpportunityRow, fsxCROpportunityRow, fsServiceOrderRow, fsSrvOrdTypeRow);
            SetPersistingChecks(cache, crOpportunityRow, fsxCROpportunityRow, fsSrvOrdTypeRow);
        }
Esempio n. 14
0
        private void EnableDisableCustomFields(
            PXCache cache,
            CROpportunity crOpportunityRow,
            FSxCROpportunity fsxCROpportunityRow,
            FSServiceOrder fsServiceOrderRow,
            FSSrvOrdType fsSrvOrdTypeRow)
        {
            bool isSMSetup = GetFSSetup() != null;

            PXUIFieldAttribute.SetEnabled <FSxCROpportunity.sDEnabled>(cache, null, isSMSetup && fsServiceOrderRow == null);
            PXUIFieldAttribute.SetEnabled <FSxCROpportunity.srvOrdType>(cache, null, isSMSetup && fsxCROpportunityRow.SDEnabled == true && fsServiceOrderRow == null);
            PXUIFieldAttribute.SetEnabled <FSxCROpportunity.branchLocationID>(cache, null, isSMSetup && fsxCROpportunityRow.SDEnabled == true);

            if (fsSrvOrdTypeRow != null)
            {
                bool isAnInternalSrvOrdType = fsSrvOrdTypeRow.Behavior == ID.Behavior_SrvOrderType.INTERNAL_APPOINTMENT;

                PXUIFieldAttribute.SetEnabled <CROpportunity.bAccountID>(cache, null, isAnInternalSrvOrdType || (!isAnInternalSrvOrdType && fsServiceOrderRow == null));
            }
            else
            {
                PXUIFieldAttribute.SetEnabled <CROpportunity.bAccountID>(cache, null, true);
            }
        }
        public virtual void SetBranchLocationID(PXGraph graph, CROpportunity crOpportunityRow, FSxCROpportunity fsxCROpportunityRow)
        {
            if (crOpportunityRow.BranchID != null)
            {
                UserPreferences userPreferencesRow =
                    PXSelect <UserPreferences,
                              Where <
                                  UserPreferences.userID, Equal <CurrentValue <AccessInfo.userID> > > > .Select(graph);

                if (userPreferencesRow != null &&
                    userPreferencesRow.DefBranchID == crOpportunityRow.BranchID)
                {
                    FSxUserPreferences fsxUserPreferencesRow = PXCache <UserPreferences> .GetExtension <FSxUserPreferences>(userPreferencesRow);

                    if (fsxUserPreferencesRow != null)
                    {
                        fsxCROpportunityRow.BranchLocationID = fsxUserPreferencesRow.DfltBranchLocationID;
                    }
                }
                else
                {
                    fsxCROpportunityRow.BranchLocationID = null;
                }
            }
            else
            {
                fsxCROpportunityRow.BranchLocationID = null;
            }
        }
        private static bool IsTheRequiredFieldsPresent(PXGraph graph, CROpportunity crOpportunityRow, FSxCROpportunity fsxCROpportunityRow)
        {
            if (crOpportunityRow == null ||
                fsxCROpportunityRow == null ||
                crOpportunityRow.ClassID == null ||
                crOpportunityRow.BranchID == null ||
                crOpportunityRow.Subject == null ||
                crOpportunityRow.ProjectID == null ||
                crOpportunityRow.CloseDate == null ||
                fsxCROpportunityRow.SrvOrdType == null ||
                fsxCROpportunityRow.BranchLocationID == null)
            {
                return(false);
            }

            if (fsxCROpportunityRow.SrvOrdType != null)
            {
                FSSrvOrdType fsSrvOrdTypeRow = GetServiceOrderType(graph, fsxCROpportunityRow.SrvOrdType);

                if (fsSrvOrdTypeRow != null &&
                    fsSrvOrdTypeRow.Behavior != ID.Behavior_SrvOrderType.INTERNAL_APPOINTMENT &&
                    (crOpportunityRow.BAccountID == null || crOpportunityRow.LocationID == null))
                {
                    return(false);
                }
            }

            return(true);
        }