/// <summary>
        /// Check the ManageRooms value on Setup to check/hide the Rooms Values options.
        /// </summary>
        private void HideRooms()
        {
            bool isRoomManagementActive = ServiceManagementSetup.IsRoomManagementActive(this, SetupRecord?.Current);

            FSServiceOrder fsServiceOrderRow = ServiceOrderRelated.SelectSingle();

            PXUIFieldAttribute.SetVisible <FSServiceOrder.roomID>(this.ServiceOrderRelated.Cache, fsServiceOrderRow, isRoomManagementActive);
        }
        private void EnableDisableFields(PXCache cache, FSSrvOrdType fsSrvOrdTypeRow)
        {
            bool enabledPostToOption = SrvOrdAppointmentsPosted.Current != null && SrvOrdAppointmentsPosted.Current.AppointmentID != null;
            bool postToIsNone        = fsSrvOrdTypeRow.PostTo != ID.SrvOrdType_PostTo.NONE;

            fsSrvOrdTypeRow.BAccountRequired = fsSrvOrdTypeRow.Behavior != ID.Behavior_SrvOrderType.INTERNAL_APPOINTMENT;
            fsSrvOrdTypeRow.RequireRoute     = fsSrvOrdTypeRow.Behavior == ID.Behavior_SrvOrderType.ROUTE_APPOINTMENT;

            if (fsSrvOrdTypeRow.BAccountRequired == false)
            {
                fsSrvOrdTypeRow.RequireContact = false;
            }

            bool isRoomManagementActive = ServiceManagementSetup.IsRoomManagementActive(cache.Graph, SetupRecord?.Current);

            PXUIFieldAttribute.SetEnabled <FSSrvOrdType.requireRoom>(cache, fsSrvOrdTypeRow, isRoomManagementActive);
            PXUIFieldAttribute.SetVisible <FSSrvOrdType.requireRoom>(cache, fsSrvOrdTypeRow, isRoomManagementActive);

            PXUIFieldAttribute.SetEnabled <FSSrvOrdType.salesAcctSource>(cache, fsSrvOrdTypeRow, postToIsNone);
            PXUIFieldAttribute.SetEnabled <FSSrvOrdType.combineSubFrom>(cache, fsSrvOrdTypeRow, postToIsNone);
            PXUIFieldAttribute.SetEnabled <FSSrvOrdType.dfltTermIDARSO>(cache, fsSrvOrdTypeRow, postToIsNone);
            PXUIFieldAttribute.SetEnabled <FSSrvOrdType.postOrderType>(cache, fsSrvOrdTypeRow, postToIsNone);
            PXUIFieldAttribute.SetEnabled <FSSrvOrdType.dfltTermIDAP>(cache, fsSrvOrdTypeRow, postToIsNone && fsSrvOrdTypeRow.PostNegBalanceToAP == true);
            PXUIFieldAttribute.SetEnabled <FSSrvOrdType.postOrderTypeNegativeBalance>(cache, fsSrvOrdTypeRow, postToIsNone);
            PXUIFieldAttribute.SetEnabled <FSSrvOrdType.subID>(cache, fsSrvOrdTypeRow, postToIsNone);
            PXUIFieldAttribute.SetEnabled <FSSrvOrdType.allowInvoiceOnlyClosedAppointment>(cache, fsSrvOrdTypeRow, postToIsNone);

            PXUIFieldAttribute.SetEnabled <FSSrvOrdType.postNegBalanceToAP>(cache, fsSrvOrdTypeRow, fsSrvOrdTypeRow.PostTo == ID.SrvOrdType_PostTo.ACCOUNTS_RECEIVABLE_MODULE);
            PXUIFieldAttribute.SetEnabled <FSSrvOrdType.enableINPosting>(
                cache,
                fsSrvOrdTypeRow,
                postToIsNone &&
                PXAccess.FeatureInstalled <FeaturesSet.distributionModule>() &&
                fsSrvOrdTypeRow.Behavior == ID.Behavior_SrvOrderType.ROUTE_APPOINTMENT);
            PXUIFieldAttribute.SetEnabled <FSSrvOrdType.requireContact>(cache, fsSrvOrdTypeRow, fsSrvOrdTypeRow.BAccountRequired == true);
            PXUIFieldAttribute.SetEnabled <FSSrvOrdType.postTo>(cache, fsSrvOrdTypeRow, !enabledPostToOption);

            EnableDisableEmployeeTimeCardIntegrationFields(cache, fsSrvOrdTypeRow);

            switch (fsSrvOrdTypeRow.Behavior)
            {
            case ID.Behavior_SrvOrderType.INTERNAL_APPOINTMENT:
                fsSrvOrdTypeRow.AppAddressSource = ID.Source_Info.BRANCH_LOCATION;
                PXUIFieldAttribute.SetEnabled <FSSrvOrdType.appAddressSource>(cache, fsSrvOrdTypeRow, false);
                PXUIFieldAttribute.SetEnabled <FSSrvOrdType.requireCustomerSignature>(cache, fsSrvOrdTypeRow, true);
                SetPostingSettingVisibility(cache, fsSrvOrdTypeRow, false);
                break;

            case ID.Behavior_SrvOrderType.ROUTE_APPOINTMENT:
                PXUIFieldAttribute.SetEnabled <FSSrvOrdType.appAddressSource>(cache, fsSrvOrdTypeRow, true);
                PXUIFieldAttribute.SetEnabled <FSSrvOrdType.requireCustomerSignature>(cache, fsSrvOrdTypeRow, true);
                SetPostingSettingVisibility(cache, fsSrvOrdTypeRow, true);
                break;

            case ID.Behavior_SrvOrderType.QUOTE:
            default:

                if (fsSrvOrdTypeRow.Behavior == ID.Behavior_SrvOrderType.REGULAR_APPOINTMENT)
                {
                    PXUIFieldAttribute.SetEnabled <FSSrvOrdType.requireCustomerSignature>(cache, fsSrvOrdTypeRow, true);
                }
                else
                {
                    PXUIFieldAttribute.SetEnabled <FSSrvOrdType.requireCustomerSignature>(cache, fsSrvOrdTypeRow, false);
                }

                PXUIFieldAttribute.SetEnabled <FSSrvOrdType.appAddressSource>(cache, fsSrvOrdTypeRow, true);

                if (fsSrvOrdTypeRow.RequireContact == false &&
                    fsSrvOrdTypeRow.AppAddressSource == ID.Source_Info.CUSTOMER_CONTACT)
                {
                    fsSrvOrdTypeRow.AppAddressSource = ID.Source_Info.BUSINESS_ACCOUNT;
                }

                SetPostingSettingVisibility(cache, fsSrvOrdTypeRow, fsSrvOrdTypeRow.Behavior != ID.Behavior_SrvOrderType.QUOTE);
                break;
            }
        }