public override void Record_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Insert && ((FSAddress)e.Row).IsDefaultAddress == true)
            {
                PXView view = sender.Graph.TypedViews.GetView(_DuplicateSelect, true);
                view.Clear();

                FSAddress previousAddress = (FSAddress)view.SelectSingle(((FSAddress)e.Row).BAccountID, ((FSAddress)e.Row).BAccountAddressID, ((FSAddress)e.Row).RevisionID);

                if (previousAddress != null)
                {
                    _KeyToAbort = sender.GetValue(e.Row, _RecordID);
                    object newKey = sender.Graph.Caches[typeof(FSAddress)].GetValue(previousAddress, _RecordID);

                    PXCache cache = sender.Graph.Caches[_ItemType];

                    foreach (object data in cache.Updated)
                    {
                        object dataKey = cache.GetValue(data, _FieldOrdinal);

                        if (Equals(_KeyToAbort, dataKey))
                        {
                            cache.SetValue(data, _FieldOrdinal, newKey);
                        }
                    }

                    _KeyToAbort = null;
                    e.Cancel    = true;
                    return;
                }
            }

            base.Record_RowPersisting(sender, e);
        }
예제 #2
0
        protected virtual IEnumerable fixedDemand()
        {
            PXView select = new PXView(Base, false, Base.FixedDemand.View.BqlSelect);

            Int32         totalrow = 0;
            Int32         startrow = PXView.StartRow;
            List <object> result   = select.Select(PXView.Currents, PXView.Parameters, PXView.Searches,
                                                   PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startrow, PXView.MaximumRows, ref totalrow);

            PXView.StartRow = 0;

            foreach (PXResult <POFixedDemand, InventoryItem, Vendor, POVendorInventory, CRLocation, SOOrder, SOLineSplit, SOLine, INItemClass, FSServiceOrder> rec in result)
            {
                var demand = (POFixedDemand)rec;
                var item   = (InventoryItem)rec;
                var vendor = (Vendor)rec;
                var price  = (POVendorInventory)rec;
                Base.EnumerateAndPrepareFixedDemandRow(demand, item, vendor, price);

                FSServiceOrder fsServiceOrderRow = (FSServiceOrder)rec;
                SOOrder        soOrderRow        = (SOOrder)rec;

                if (fsServiceOrderRow.CustomerID != null)
                {
                    soOrderRow.CustomerID = fsServiceOrderRow.CustomerID;
                }

                FSxPOFixedDemand fSxPOFixedDemandRow = Base.FixedDemand.Cache.GetExtension <FSxPOFixedDemand>(demand);
                fSxPOFixedDemandRow.FSRefNbr = fsServiceOrderRow.RefNbr;
            }

            return(result);
        }
예제 #3
0
        protected virtual IEnumerable activities()
        {
            var command = Activities.View.BqlSelect;
            var filter  = Filter.Current;

            if (filter.OwnerID != null)
            {
                command = command.WhereOr(typeof(Where <EPActivity.owner, Equal <CurrentValue <OwnedFilter.ownerID> > >));
            }
            if (filter.WorkGroupID != null)
            {
                command = command.WhereAnd(typeof(Where <EPActivity.groupID, Equal <CurrentValue <OwnedFilter.workGroupID> > >));
            }
            if (filter.MyWorkGroup == true)
            {
                command = command.WhereAnd(typeof(Where <EPActivity.groupID, InMember <CurrentValue <OwnedFilter.currentOwnerID> > >));
            }
            command = command.WhereAnd(typeof(Where <EPActivity.classID, Equal <CRActivityClass.activity>,
                                                     Or <EPActivity.classID, Equal <CRActivityClass.email> > >));

            var view      = new PXView(this, true, command);
            var startRow  = PXView.StartRow;
            int totalRows = 0;
            var list      = view.Select(PXView.Currents, PXView.Parameters, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters,
                                        ref startRow, PXView.MaximumRows, ref totalRows);

            PXView.StartRow = 0;
            return(list);
        }
예제 #4
0
        //TODO: need implementation

        /*public PXAction<CR.OwnedFilter> ExportCalendar;
         * [PXUIField(DisplayName = Messages.ExportCalendar)]
         * [PXButton(Tooltip = Messages.ExportCalendarTooltip)]
         * public IEnumerable exportCalendar(PXAdapter adapter)
         * {
         *      var events = Events.Select().RowCast<EPActivity>();
         *      var calendar = (vCalendarIcs)VCalendarProcessor.CreateVCalendar(events);
         *      throw new EPIcsExportRedirectException(calendar);
         * }
         *
         * public PXAction<CR.OwnedFilter> ExportCard;
         * [PXUIField(DisplayName = Messages.ExportCard)]
         * [PXButton(Tooltip = Messages.ExportCardTooltip)]
         * public IEnumerable exportCard(PXAdapter adapter)
         * {
         *      if (Events.Current == null) return adapter.Get();
         *      var card = VCalendarProcessor.CreateVEvent(Events.Current);
         *      throw new EPIcsExportRedirectException(card);
         * }*/

        #endregion

        #region Data Handlers
        protected virtual IEnumerable events()
        {
            BqlCommand command = new Select2 <EPActivity,
                                              LeftJoin <EPAttendee, On <EPAttendee.userID, Equal <Current <AccessInfo.userID> >,
                                                                        And <EPAttendee.eventID, Equal <EPActivity.taskID> > >,
                                                        LeftJoin <EPView,
                                                                  On <EPView.noteID, Equal <EPActivity.noteID>,
                                                                      And <EPView.userID, Equal <Current <AccessInfo.userID> > > > > >,
                                              Where <EPActivity.classID, Equal <CRActivityClass.events> >,
                                              OrderBy <Desc <EPActivity.priority, Asc <EPActivity.startDate, Asc <EPActivity.endDate> > > > >();

            var filter = Filter.Current;

            if (filter.OwnerID != null)
            {
                command = new Select2 <EPActivity,
                                       LeftJoin <EPAttendee, On <EPAttendee.userID, Equal <CurrentValue <CR.OwnedFilter.ownerID> >,
                                                                 And <EPAttendee.eventID, Equal <EPActivity.taskID> > >,
                                                 LeftJoin <EPView,
                                                           On <EPView.noteID, Equal <EPActivity.noteID>,
                                                               And <EPView.userID, Equal <Current <AccessInfo.userID> > > > > >,
                                       Where2 <Where <EPActivity.createdByID, Equal <CurrentValue <CR.OwnedFilter.ownerID> >, Or <EPAttendee.userID, IsNotNull> >,
                                               And <Where <EPActivity.classID, Equal <CRActivityClass.events> > > >,
                                       OrderBy <Desc <EPActivity.priority, Asc <EPActivity.startDate, Asc <EPActivity.endDate> > > > >();
            }

            var view      = new PXView(this, true, command);
            var startRow  = PXView.StartRow;
            int totalRows = 0;
            var list      = view.Select(PXView.Currents, PXView.Parameters, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters,
                                        ref startRow, PXView.MaximumRows, ref totalRows);

            PXView.StartRow = 0;
            return(list);
        }
예제 #5
0
        protected virtual IEnumerable viewHandler()
        {
            if (intView == null)
            {
                intView = CreateIntView(View.Graph);
            }
            int startRow = PXView.StartRow;
            int num      = 0;
            PXDelegateResult pXDelegateResult = new PXDelegateResult();

            foreach (object obj in intView.Select(null, null, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startRow, PXView.MaximumRows, ref num))
            {
                var statu  = PXResult.Unwrap <RowToSelect>(obj);
                var statu1 = statu;
                var statu2 = (Cache.Locate(statu) as RowToSelect);
                if (statu2 != null)
                {
                    bool?value = (Cache.GetValue(statu2, Selected) as bool?);
                    if (value.GetValueOrDefault() & value.HasValue)
                    {
                        Cache.RestoreCopy(statu2, statu);
                        Cache.SetValue(statu2, Selected, true);
                        statu1 = statu2;
                    }
                }
                pXDelegateResult.Add(statu1);
            }
            PXView.StartRow = 0;
            if (PXView.ReverseOrder)
            {
                pXDelegateResult.Reverse();
            }
            pXDelegateResult.IsResultSorted = true;
            return(pXDelegateResult);
        }
예제 #6
0
        public static IEnumerable SelectExternal(this PXView view, ref int startRow, ref int totalRows, object[] pars = null)
        {
            IEnumerable list = SelectWithExternalParameters(view, ref startRow, ref totalRows, pars);

            PXView.StartRow = 0;
            return(list);
        }
예제 #7
0
        public IEnumerable items()
        {
            int startRow  = PXView.StartRow;
            int totalRows = 0;

            startRow = PXView.StartRow;

            // Acuminator disable once PX1010 StartRowResetForPaging [Justification]
            IEnumerable <ListEntryPoint> rows = new PXView(this, false, new Select <ListEntryPoint>())
                                                .Select(PXView.Currents, PXView.Parameters, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters,
                                                        ref startRow, PXView.MaximumRows, ref totalRows).Cast <ListEntryPoint>();

            switch (totalRows)
            {
            case 3:
                return(rows);
            }

            if (totalRows < 5)
            {
                return(rows);
            }
            else
            {
                return(rows);
            }

            return(rows);
        }
            public IEnumerable transactions()
            {
                if (!IsCartRequired)
                {
                    return(null);
                }
                PXDelegateResult sorted = new PXDelegateResult
                {
                    IsResultSorted    = true,
                    IsResultFiltered  = true,
                    IsResultTruncated = true
                };
                var view     = new PXView(Base, false, Base.transactions.View.BqlSelect);
                int startRow = PXView.StartRow;
                int totalRow = 0;
                var lines    = view.Select(
                    PXView.Currents, PXView.Parameters, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters,
                    ref startRow, PXView.MaximumRows, ref totalRow)
                               .OfType <INTran>()
                               .Select(x => new { Line = x, IsInCart = (GetCartQty(x) ?? 0) > 0 })
                               .OrderByDescending(x => x.IsInCart)
                               .Select(x => x.Line)
                               .ToList();

                sorted.AddRange(lines);
                return(sorted);
            }
예제 #9
0
        public static void VerifyFinPeriod <fieldPeriod, fieldClosed>(PXGraph graph, PXCache cache, object row, PXSelectBase <FinPeriod> finperiod)
            where fieldPeriod : class, IBqlField
            where fieldClosed : class, IBqlField
        {
            if (finperiod.Current != null)
            {
                GLSetup glsetup = PXSetup <GLSetup> .Select(graph);

                object isClosed = finperiod.Cache.GetValue <fieldClosed>(finperiod.Current);

                if (finperiod.Current.Active != true || isClosed.Equals(true) && glsetup != null && glsetup.PostClosedPeriods != true)
                {
                    BqlCommand select = BqlCommand.CreateInstance(typeof(Select <FinPeriod,
                                                                                 Where <FinPeriod.active, Equal <True>,
                                                                                        And <FinPeriod.finPeriodID, Greater <Required <FinPeriod.finPeriodID> > > >,
                                                                                 OrderBy <Asc <FinPeriod.finPeriodID> > >))
                                        .WhereAnd(BqlCommand.Compose(typeof(Where <,>), typeof(fieldClosed), typeof(NotEqual <True>)));

                    object    docPeriod = cache.GetValue <fieldPeriod>(row);
                    FinPeriod firstopen = new PXView(graph, false, select).SelectSingle(docPeriod) as FinPeriod;

                    if (firstopen == null)
                    {
                        string userPeriod = Mask.Format("##-####", finperiod.Cache.GetValueExt <FinPeriod.finPeriodID>(finperiod.Current).ToString());
                        throw new PXSetPropertyException(GL.Messages.NoActivePeriodAfter, userPeriod);
                    }

                    cache.SetValue <fieldPeriod>(row, firstopen.FinPeriodID);
                }
            }
        }
예제 #10
0
        public virtual IEnumerable records(PXAdapter adapter)
        {
            Type where = PX.TM.OwnedFilter.ProjectionAttribute.ComposeWhere(
                typeof(POPrintOrderFilter),
                typeof(POPrintOrderOwned.workgroupID),
                typeof(POPrintOrderOwned.ownerID));

            Type printWhere =
                typeof(Where <POPrintOrderOwned.hold, Equal <False>,
                              And <POPrintOrderOwned.dontPrint, Equal <False>,
                                   And <POPrintOrderOwned.printed, NotEqual <True> > > >);
            Type emailWhere =
                typeof(Where <POPrintOrderOwned.hold, Equal <False>,
                              And <POPrintOrderOwned.dontEmail, Equal <False>,
                                   And <POPrintOrderOwned.emailed, NotEqual <True> > > >);

            Type action =
                Filter.Current.Action == "<SELECT>"
                                ? typeof(Where <CS.boolTrue, Equal <CS.boolFalse> >)
                                : Filter.Current.Action.Contains("Email")
                                ? emailWhere :
                printWhere;

            Type select =
                BqlCommand.Compose(
                    typeof(Select2 <, ,>), typeof(POPrintOrderOwned),
                    typeof(InnerJoin <Vendor, On <Vendor.bAccountID, Equal <POPrintOrderOwned.vendorID> > >),
                    typeof(Where <>), action);

            PXView view = new PXView(this, false, BqlCommand.CreateInstance(select));

            return(view.SelectMulti());
        }
예제 #11
0
        protected virtual IEnumerable GetRecords()
        {
            PXCache cache = _Graph.Caches[_CacheType];

            object extCurrentRow = PXView.Currents.FirstOrDefault(c => _CacheType.IsAssignableFrom(c.GetType()));

            int?calendarOrganizationID = TakeBranchForSelectorFromQueryParams || TakeOrganizationForSelectorFromQueryParams
                                ? SourceOrganizationIDProvider.GetCalendarOrganizationID(PXView.Parameters, TakeBranchForSelectorFromQueryParams, TakeOrganizationForSelectorFromQueryParams)
                                : SourceOrganizationIDProvider.GetCalendarOrganizationID(cache.Graph, cache, extCurrentRow);

            calendarOrganizationID = calendarOrganizationID ?? FinPeriod.organizationID.MasterValue;

            int startRow  = PXView.StartRow;
            int totalRows = 0;

            List <object> parameters = new List <object>();

            BqlCommand cmd = GetCommand(cache, extCurrentRow, parameters, calendarOrganizationID);

            PXView view = new PXView(_Graph, PXView.View?.IsReadOnly ?? true, cmd);

            try
            {
                IEnumerable <object> data = view.Select(PXView.Currents, parameters.ToArray(), PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows);

                var r = data.Select(record => BuildFinPeriod(calendarOrganizationID, record)).ToArray();

                return(r);
            }
            finally
            {
                PXView.StartRow = 0;
            }
        }
        public PXOrderedSelect(PXGraph graph, Delegate handler)
        {
            _Graph = graph;
            Initialize();

            View = new PXView(graph, false, new Select <Table, Where, OrderBy>(), handler);
        }
예제 #13
0
        private IEnumerable getTemplates <TTemplate>(PXSelectBase <TTemplate> select)
            where TTemplate : CRFilterTemplate, new()
        {
            Hashtable hashTable = new Hashtable();

            foreach (TTemplate item in select.Cache.Updated)
            {
                hashTable.Add(item.FilterTemplateID, item);
                yield return(item);
            }
            foreach (TTemplate item in select.Cache.Inserted)
            {
                hashTable.Add(item.FilterTemplateID, item);
                yield return(item);
            }
            PXView view = new PXView(this, true, select.View.BqlSelect);

            foreach (TTemplate item in view.SelectMulti(graphTypeName, PXAccess.GetUserID()))
            {
                if (!hashTable.Contains(item.FilterTemplateID))
                {
                    yield return(item);
                }
            }
            if (hashTable.Count < 1)
            {
                select.Cache.IsDirty = false;
            }
        }
        protected virtual IEnumerable GetRecords()
        {
            PXCache cache = _Graph.Caches[_CacheType];

            object extCurrentRow = PXView.Currents.FirstOrDefault(c => _CacheType.IsAssignableFrom(c.GetType()));

            FABookPeriod.Key periodKey =
                ReportParametersMask != ReportParametersFlag.None
                ? BookPeriodKeyProvider.GetKeyFromReportParameters(_Graph, PXView.Parameters, ReportParametersMask)
                : BookPeriodKeyProvider.GetKey(_Graph, cache, extCurrentRow);

            int startRow  = PXView.StartRow;
            int totalRows = 0;

            List <object> parameters = new List <object>();

            BqlCommand cmd = GetCommand(cache, extCurrentRow, parameters, periodKey);

            PXView view = new PXView(_Graph, PXView.View?.IsReadOnly ?? true, cmd);

            try
            {
                return(view.Select(PXView.Currents, parameters.ToArray(), PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows));
            }
            finally
            {
                PXView.StartRow = 0;
            }
        }
예제 #15
0
        private void FieldSelectingOwnerOrWorkgroup <TField>(Events.FieldSelecting <TField> e) where TField : class, IBqlField
        {
            if (e.Row == null)
            {
                return;
            }

            bool isEnabled = true;

            PXView view = null;

            foreach (PXSelectorAttribute attribute in e.Cache.GetAttributesOfType <PXSelectorAttribute>(e.Row, typeof(FClassID).Name))
            {
                view = new PXView(Base, true, attribute.PrimarySelect);
            }
            if (view == null)
            {
                return;
            }

            string      classID = e.Cache.GetValue <FClassID>(e.Row) as string;
            CRBaseClass cls     = view.SelectSingle(classID) as CRBaseClass;

            if (cls == null)
            {
                return;
            }

            isEnabled = cls.DefaultOwner != CRDefaultOwnerAttribute.AssignmentMap ||
                        Object.Equals(e.Cache.GetValue <FClassID>(e.Row), e.Cache.GetValueOriginal <FClassID>(e.Row));

            e.ReturnState = PXFieldState.CreateInstance(e.ReturnState, null, null, null, null, null, null, null, null, null, null, null, PXErrorLevel.Undefined,
                                                        isEnabled,
                                                        null, null, PXUIVisibility.Undefined, null, null, null);
        }
예제 #16
0
        protected virtual IEnumerable filter()
        {
            ApproveBillsFilter filter = Filter.Current;

            if (filter != null && filter.SelectionDate != null && filter.PendingRefresh == true)
            {
                DateTime PayInLessThan             = ((DateTime)filter.SelectionDate).AddDays(filter.PayInLessThan.GetValueOrDefault());
                DateTime DueInLessThan             = ((DateTime)filter.SelectionDate).AddDays(filter.DueInLessThan.GetValueOrDefault());
                DateTime DiscountExpiresInLessThan = ((DateTime)filter.SelectionDate).AddDays(filter.DiscountExpiresInLessThan.GetValueOrDefault());

                decimal approvedTotal = 0m;
                decimal docsTotal     = 0m;

                PXView view = new PXView(this, true, BqlCommand.CreateInstance(getAPDocumentSelect(true)));

                foreach (PXResult <APInvoice> temp in view.SelectMulti(PayInLessThan, DueInLessThan, DiscountExpiresInLessThan))
                {
                    APInvoice res = temp;
                    approvedTotal += res.PaySel == true ? (Accessinfo.CuryViewState ? (res.DocBal ?? 0m) : (res.CuryDocBal ?? 0m)) : 0m;
                    docsTotal     += Accessinfo.CuryViewState ? (res.DocBal ?? 0m) : (res.CuryDocBal ?? 0m);
                }

                Filter.Current.CuryApprovedTotal = approvedTotal;
                Filter.Current.CuryDocsTotal     = docsTotal;
                Filter.Current.PendingRefresh    = false;
            }

            yield return(Filter.Current);

            Filter.Cache.IsDirty = false;
        }
예제 #17
0
        public IEnumerable items()
        {
            int startRow  = PXView.StartRow;
            int totalRows = 0;

            startRow = PXView.StartRow;

            IEnumerable <ListEntryPoint> rows = new PXView(this, false, new Select <ListEntryPoint>())
                                                .Select(PXView.Currents, PXView.Parameters, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters,
                                                        ref startRow, PXView.MaximumRows, ref totalRows).Cast <ListEntryPoint>();

            switch (totalRows)
            {
            case 3:
                return(rows);
            }

            if (totalRows < 5)
            {
                return(rows);
            }
            else
            {
                return(rows);
            }

            return(rows);
        }
        public virtual IEnumerable <PX.Data.EP.ActivityService.Total> GetCounts()
        {
            TasksAndEventsReminder Reminder;

            if (_viewShared == null || _viewCountShared == null)
            {
                Reminder = (TasksAndEventsReminder)View.Graph;
            }
            else
            {
                Reminder = (TasksAndEventsReminder)_viewShared.Graph;
            }
            List <PX.Data.EP.ActivityService.Total> ret = new List <Data.EP.ActivityService.Total>();

            foreach (PX.Data.EP.ActivityService.Total total in Reminder.Counters.Select())
            {
                ret.Add(total);
            }
            if (_viewShared == null || _viewCountShared == null)
            {
                _viewShared      = _view;
                _viewCountShared = _viewCount;
                _view            = null;
                _viewCount       = null;
            }
            return(ret);
        }
예제 #19
0
        public override void ProccessItem(PXGraph graph, TPrimary item)
        {
            PXCache  cache   = graph.Caches[typeof(TPrimary)];
            TPrimary newItem = (TPrimary)cache.CreateInstance();

            PXCache <TPrimary> .RestoreCopy(newItem, item);

            string entityType = CSAnswerType.GetAnswerType(cache.GetItemType());
            string entityID   = CSAnswerType.GetEntityID(cache.GetItemType());

            PXView primaryView = graph.Views[graph.PrimaryView];

            object[] searches    = new object[primaryView.Cache.BqlKeys.Count];
            string[] sortcolumns = new string[primaryView.Cache.BqlKeys.Count];
            for (int i = 0; i < cache.BqlKeys.Count(); i++)
            {
                sortcolumns[i] = cache.BqlKeys[i].Name;
                searches[i]    = cache.GetValue(newItem, sortcolumns[i]);
            }
            int startRow = 0, totalRows = 0;

            List <object> result = primaryView.Select(null, null, searches, sortcolumns, null, null, ref startRow, 1, ref totalRows);

            newItem = (TPrimary)cache.CreateCopy(PXResult.Unwrap <TPrimary>(result[0]));

            foreach (FieldValue fieldValue in Fields.Cache.Cached.Cast <FieldValue>().Where(o => o.AttributeID == null && o.Selected == true))
            {
                PXFieldState  state    = cache.GetStateExt(newItem, fieldValue.Name) as PXFieldState;
                PXIntState    intState = state as PXIntState;
                PXStringState strState = state as PXStringState;
                if ((intState != null && intState.AllowedValues != null && intState.AllowedValues.Length > 0 &&
                     intState.AllowedValues.All(v => v != int.Parse(fieldValue.Value)))
                    ||
                    (strState != null && strState.AllowedValues != null && strState.AllowedValues.Length > 0 &&
                     strState.AllowedValues.All(v => v != fieldValue.Value)))
                {
                    throw new PXSetPropertyException(ErrorMessages.UnallowedListValue, fieldValue.Value, fieldValue.Name);
                }
                if (state != null && !Equals(state.Value, fieldValue.Value))
                {
                    cache.SetValueExt(newItem, fieldValue.Name, fieldValue.Value);
                    cache.Update(newItem);
                }

                result  = primaryView.Select(null, null, searches, sortcolumns, null, null, ref startRow, 1, ref totalRows);
                newItem = (TPrimary)cache.CreateCopy(PXResult.Unwrap <TPrimary>(result[0]));
            }

            PXCache attrCache = cache.Graph.Caches[typeof(CSAnswers)];

            foreach (FieldValue attrValue in Attributes.Cache.Cached.Cast <FieldValue>().Where(o => o.AttributeID != null && o.Selected == true))
            {
                CSAnswers attr = (CSAnswers)attrCache.CreateInstance();
                attr.AttributeID = attrValue.AttributeID;
                attr.EntityID    = cache.GetValue(newItem, entityID) as int?;
                attr.EntityType  = entityType;
                attr.Value       = attrValue.Value;
                attrCache.Update(attr);
            }
        }
            protected override List <PXResult <CSAnswers, CSAttributeGroup, InventoryItem> > SelectInventoryWithAttributes()
            {
                Type sumDecimalFields = BqlCommand.Compose(BqlHelper.GetDecimalFieldsAggregate <INSiteStatus>(Base, true).ToArray());

                Type select = BqlTemplate.OfCommand <
                    Select5 <CSAnswers,
                             InnerJoin <CSAttributeGroup, On <CSAnswers.attributeID, Equal <CSAttributeGroup.attributeID> >,
                                        InnerJoin <InventoryItem, On <CSAnswers.refNoteID, Equal <InventoryItem.noteID>,
                                                                      And <CSAttributeGroup.entityClassID, Equal <InventoryItem.itemClassID> > >,
                                                   LeftJoin <INSiteStatus, On <INSiteStatus.inventoryID, Equal <InventoryItem.inventoryID>,
                                                                               And <INSiteStatus.subItemID, Equal <InventoryItem.defaultSubItemID>,
                                                                                    And <Where <INSiteStatus.siteID, Equal <Current <EntryHeader.siteID> >, Or <Current <EntryHeader.siteID>, IsNull> > > > >,
                                                             LeftJoin <INLocationStatus, On <INLocationStatus.inventoryID, Equal <InventoryItem.inventoryID>,
                                                                                             And <INLocationStatus.subItemID, Equal <InventoryItem.defaultSubItemID>,
                                                                                                  And <INLocationStatus.siteID, Equal <Current <EntryHeader.siteID> >,
                                                                                                       And <INLocationStatus.locationID, Equal <Current <EntryHeader.locationID> > > > > > > > > >,
                             Where <CSAttributeGroup.isActive, Equal <True>,
                                    And <CSAttributeGroup.entityType, Equal <Constants.DACName <InventoryItem> >,
                                         And <CSAttributeGroup.attributeCategory, Equal <CSAttributeGroup.attributeCategory.variant>,
                                              And <InventoryItem.templateItemID, Equal <Current <EntryHeader.templateItemID> > > > > >,
                             Aggregate <GroupBy <InventoryItem.inventoryID, GroupBy <CSAnswers.refNoteID, GroupBy <CSAnswers.attributeID, BqlPlaceholder.A> > > >,
                             OrderBy <Asc <InventoryItem.inventoryID, Asc <CSAnswers.refNoteID, Asc <CSAnswers.attributeID> > > > > >
                              .Replace <BqlPlaceholder.A>(sumDecimalFields)
                              .ToType();

                var view = new PXView(Base, true, BqlCommand.CreateInstance(select));

                using (new PXFieldScope(view,
                                        typeof(InventoryItem.inventoryID), typeof(CSAnswers.attributeID), typeof(CSAnswers.value),
                                        typeof(INSiteStatus), typeof(INLocationStatus)))
                {
                    return(view.SelectMulti().Cast <PXResult <CSAnswers, CSAttributeGroup, InventoryItem> >().ToList());
                }
            }
예제 #21
0
        public IEnumerable detailsView()
        {
            List <object> result = new List <object>();

            var currentSearchPeriod = ((LumINItemCostFilter)this.Caches[typeof(LumINItemCostFilter)].Current)?.FinPeriodID;

            if (currentSearchPeriod != null)
            {
                var           pars      = new List <PXSPParameter>();
                PXSPParameter period    = new PXSPInParameter("@period", PXDbType.Int, currentSearchPeriod);
                PXSPParameter companyID = new PXSPInParameter("@companyID", PXDbType.Int, PX.Data.Update.PXInstanceHelper.CurrentCompany);
                pars.Add(period);
                pars.Add(companyID);

                using (new PXConnectionScope())
                {
                    using (PXTransactionScope ts = new PXTransactionScope())
                    {
                        PXDatabase.Execute("SP_GenerateLumINItemCostHist", pars.ToArray());
                        ts.Complete();
                    }
                }

                PXView select   = new PXView(this, true, DetailsView.View.BqlSelect);
                int    totalrow = 0;
                int    startrow = PXView.StartRow;
                result          = select.Select(PXView.Currents, PXView.Parameters, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startrow, PXView.MaximumRows, ref totalrow);
                PXView.StartRow = 0;
                return(result);
            }

            return(result);
        }
예제 #22
0
        protected virtual void CreateView()
        {
            var graph = PXGraph.CreateInstance <TasksAndEventsReminder>();

            _view      = graph.ActivityList.View;
            _viewCount = graph.ActivityCount.View;
        }
예제 #23
0
        private bool IsItemRuleTrue(IBqlTable item, EPAssignmentRule rule)
        {
            if (item is EPEmployee && rule.FieldName.Equals(typeof(EPEmployee.workgroupID).Name, StringComparison.InvariantCultureIgnoreCase))
            {
                return(IsEmployeeInWorkgroup((EPEmployee)item, rule));
            }

            currentItem = item;
            Type   viewType = BqlCommand.Compose(typeof(Select <>), item.GetType());
            PXView itemView = new PXView(this, false, BqlCommand.CreateInstance(viewType),
                                         (PXSelectDelegate)getItemRecord);

            if (rule.Condition == null)
            {
                return(false);
            }

            PXFilterRow filter = new PXFilterRow(
                rule.FieldName,
                (PXCondition)rule.Condition.Value,
                GetFieldValue(item, rule.FieldName, rule.FieldValue),
                null);
            int startRow  = 0;
            int totalRows = 0;

            List <object> result = itemView.Select(null, null, null, null, null, new PXFilterRow[] { filter }, ref startRow, 1, ref totalRows);

            return(result.Count > 0);
        }
        protected virtual IEnumerable selectedItems()
        {
            EMailAccountSyncFilter filter = Filter.Current;

            BqlCommand cmd = SelectedItems.View.BqlSelect;

            if (filter != null && filter.ServerID != null)
            {
                cmd = cmd.WhereAnd <Where <EMailSyncAccount.serverID, Equal <Current <EMailAccountSyncFilter.serverID> > > >();
            }
            if (filter != null && !String.IsNullOrEmpty(filter.PolicyName))
            {
                cmd = cmd.WhereAnd <Where <EMailSyncAccount.policyName, Equal <Current <EMailAccountSyncFilter.policyName> > > >();
            }

            int    totalRows = 0;
            int    startRow  = PXView.StartRow;
            PXView view      = new PXView(this, false, cmd); view.Clear( );

            foreach (PXResult <EMailSyncAccount, EMailSyncServer, EPEmployee, Contact> item in
                     view.Select(PXView.Currents, PXView.Parameters, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows))
            {
                Contact          contact = item;
                EMailSyncAccount account = item;
                account.Address = (contact != null ? contact.EMail : null) ?? account.Address;

                //SelectedItems.Cache.SetStatus(account, PXEntryStatus.Notchanged);

                yield return(item);
            }
        }
            public override void CacheAttached(PXCache sender)
            {
                base.CacheAttached(sender);
                PXView outerview = new PXView(sender.Graph, true, _Select);
                PXView view      = sender.Graph.Views[_ViewName] = new PXView(sender.Graph, true, _Select, (PXSelectDelegate) delegate()
                {
                    int startRow  = PXView.StartRow;
                    int totalRows = 0;
                    List <object> res;

                    using (new PXReadBranchRestrictedScope())
                    {
                        res             = outerview.Select(PXView.Currents, PXView.Parameters, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows);
                        PXView.StartRow = 0;
                    }

                    PXCache cache = outerview.Graph.Caches[typeof(INSite)];

                    return(res.FindAll((item) =>
                    {
                        return _RestrictedSelect.Meet(cache, item is PXResult ? PXResult.Unwrap <INSite>(item) : item);
                    }));
                });

                if (_DirtyRead)
                {
                    view.IsReadOnly = false;
                }
            }
예제 #26
0
        //Refactor - Generalize if possible!!!
        private IBqlTable GetItemRecord(EPAssignmentRule rule, IBqlTable item)
        {
            PXGraph graph    = this.processGraph;
            Type    itemType = item.GetType();
            Type    ruleType = GraphHelper.GetType(rule.Entity);

            if (ruleType.IsAssignableFrom(itemType))
            {
                return(item);
            }
            if (processMapType.IsAssignableFrom(ruleType) && graph != null)
            {
                return(graph.Caches[processMapType].Current as IBqlTable);
            }

            if (graph != null)
            {
                foreach (CacheEntityItem entry in EMailSourceHelper.TemplateEntity(this, null, item.GetType().FullName, graph.GetType().FullName))
                {
                    Type entityType = GraphHelper.GetType(entry.SubKey);
                    if (ruleType.IsAssignableFrom(entityType) && graph.Views.ContainsKey(entry.Key))
                    {
                        PXView view   = graph.Views[entry.Key];
                        object result = view.SelectSingleBound(new object[] { item });
                        return((result is PXResult ? ((PXResult)result)[0] : result) as IBqlTable);
                    }
                }
            }
            return(item);
        }
        protected virtual bool AskProcess(List <Contact> list)
        {
            if (Operations.Current.CampaignID == null)
            {
                return(false);
            }
            CRCampaign campaign = PXSelect <CRCampaign,
                                            Where <CRCampaign.campaignID, Equal <Current <CampaignOperationParam.campaignID> > > >
                                  .Select(this);

            if (Operations.Current.Action == CampaignOperationParam.ActionList.Update)
            {
                return(PXView.AskExt(this, "UpdateMembers", null, (s, e) =>
                {
                    Operations.Current.Status = campaign != null ? campaign.DefaultMemberStatus : null;
                }) == WebDialogResult.OK && Operations.Current.Status != null);
            }

            if (Operations.Current.Action == CampaignOperationParam.ActionList.Remove)
            {
                return(Operations.Current.CampaignID != null &&
                       Operations.Ask(Messages.AskConfirmation,
                                      string.Format(Messages.ConfirmRemoving, list.Count),
                                      MessageButtons.YesNoCancel) == WebDialogResult.Yes);
            }

            return(PXView.AskExt(this, "AddMembers", null, (s, e) =>
            {
                Operations.Current.Status = campaign != null ? campaign.DefaultMemberStatus : null;
            }) == WebDialogResult.OK && Operations.Current.Status != null);
        }
        public override void FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            if (e.NewValue == null || !ValidateValue)
            {
                return;
            }

            PXView view = GetView(sender, _PrimarySelect, !_DirtyRead);

            if (sender.Keys.Count == 0 || _FieldName != sender.Keys[sender.Keys.Count - 1])
            {
                object[] pars = new object[_ParsCount + 1];
                pars[pars.Length - 1] = e.NewValue;
                object item = null;
                try
                {
                    item = SelectSingleBound(view, new object[] { e.Row }, pars);
                }
                catch (FormatException) { }                 // thrown by SqlServer
                catch (InvalidCastException) { }            // thrown by MySql

                if (item == null)
                {
                    throwNoItem(hasRestrictedAccess(sender, _PrimarySelect, e.Row), e.ExternalCall, e.NewValue);
                }
            }
        }
예제 #29
0
        public virtual void NavigateToItem(EPActivity current)
        {
            if (current != null)
            {
                var graphType = EPActivityPrimaryGraphAttribute.GetGraphType(current);
                if (!PXAccess.VerifyRights(graphType))
                {
                    ReminderList.Ask(CR.Messages.AccessDenied, CR.Messages.FormNoAccessRightsMessage(graphType), MessageButtons.OK, MessageIcon.Error);
                }
                else
                {
                    var graph      = (PXGraph)PXGraph.CreateInstance(graphType);
                    var cache      = graph.Caches[current.GetType()];
                    var searchView = new PXView(
                        graph,
                        false,
                        BqlCommand.CreateInstance(typeof(Select <>), cache.GetItemType()));
                    var startRow  = 0;
                    var totalRows = 0;
                    var acts      = searchView.
                                    Select(null, null,
                                           new object[] { current.TaskID },
                                           new string[] { typeof(EPActivity.taskID).Name },
                                           null, null, ref startRow, 1, ref totalRows);

                    if (acts != null && acts.Count > 0)
                    {
                        var act = acts[0];
                        cache.Current = act;
                        PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.NewWindow);
                    }
                }
            }
        }
        protected IEnumerable <TRefItem> RefItemsForAction(TInstance leaveInstance, ICollection <TInstance> deletingInstances, bool forDeleting)
        {
            // Constraint
            if (deletingInstances.Count < 1)
            {
                yield break;
            }

            // Compose command
            BqlCommand command = GetCommand(leaveInstance, deletingInstances, forDeleting);

            if (command == null)
            {
                yield break;
            }

            // Compose parameters
            object[] deletingIDs = GetInstancesKeys(leaveInstance, deletingInstances, forDeleting);

            // Select
            PXView view = new PXView(Graph, false, command);

            foreach (object item in view.SelectMulti(deletingIDs))
            {
                PXResult record = item as PXResult;
                if (record != null)
                {
                    yield return(record[typeof(TRefItem)] as TRefItem);
                }
                else
                {
                    yield return(item as TRefItem);
                }
            }
        }
		private void RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)
		{
			var val = (PropertyValue)e.Row;
			var oldValue = (PropertyValue)e.OldRow;
			if (Equals(val.Value, oldValue.Value)) return;

			var itemsCache = View.Cache;
			foreach (PropertyValue item in sender.Cached.
				Cast<PropertyValue>().
				Where(_ => _.Order > val.Order).
				OrderBy(_ => _.Order))
			{
				if (string.IsNullOrWhiteSpace(item.Name)) continue;

				var propertyInfo = itemsCache.GetType().GetProperty(item.Name);
				if (propertyInfo == null) continue;

				var verifier = Attribute.GetCustomAttribute(propertyInfo, PropertyMarkAttribute) as PXMassProcessFieldAttribute;
				if (verifier == null || verifier.SearchCommand == null) continue;

				var searchCommand = (BqlCommand)Activator.CreateInstance(verifier.SearchCommand);
				var verifingParams = new List<object>();
				var itemOrder = item.Order;
				foreach(IBqlParameter param in searchCommand.GetParameters())
				{
					var refType = param.GetReferencedType();
					if (refType == null) continue;

					var propVal = sender.Cached.Cast<PropertyValue>().FirstOrDefault(_ => _.Order < itemOrder && Equals(refType.Name, _.Name));
					verifingParams.Add(propVal.With(_ => _.Value));
				}

				int startRow = 0;
				int totalRows = 0;
				var searchResult = new PXView(Graph, true, searchCommand).
									Select(null, verifingParams.ToArray(),
										new object[] { item.Value },
										new string[] { ((IBqlSearch)searchCommand).GetField().Name },
										new bool[] { false },
										null, ref startRow, 1, ref totalRows);
				if (searchResult == null || searchResult.Count == 0)
				{
					item.Value = null;
				}
			}
		}