Esempio n. 1
0
        public virtual void ProFormaFilter_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            ProFormaFilter filter = e.Row as ProFormaFilter;

            string actionID = Filter.Current.Action;

            Items.SetProcessDelegate <ProformaEntry>(
                delegate(ProformaEntry engine, PMProforma item)
            {
                if (actionID == "Release")
                {
                    try
                    {
                        engine.Document.Current = item;
                        engine.ReleaseDocument(item);
                    }
                    catch (Exception ex)
                    {
                        throw new PXSetPropertyException(ex.Message, PXErrorLevel.RowError);
                    }
                }
            });
        }
        public virtual IEnumerable items()
        {
            if (Filter.Current.Action == "<SELECT>")
            {
                yield break;
            }

            ProFormaFilter filter = Filter.Current;

            string actionID = Filter.Current.Action;

            if (_ActionChanged)
            {
                Items.Cache.Clear();
            }

            PXSelectBase <PMProforma> cmd;

            switch (actionID)
            {
            case "Release":
                cmd = new PXSelectJoin <PMProforma,
                                        InnerJoinSingleTable <Customer, On <PMProforma.customerID, Equal <Customer.bAccountID> > >,
                                        Where <PMProforma.hold, Equal <False>, And <PMProforma.released, Equal <False>, And <PMProforma.status, Equal <ProformaStatus.open>, And <Match <Customer, Current <AccessInfo.userName> > > > > > >(this);
                break;

            default:
                cmd = new PXSelectJoin <PMProforma,
                                        InnerJoinSingleTable <Customer, On <PMProforma.customerID, Equal <Customer.bAccountID> > >,
                                        Where <Match <Customer, Current <AccessInfo.userName> > > >(this);
                break;
            }

            cmd.WhereAnd <Where <PMProforma.invoiceDate, LessEqual <Current <ProFormaFilter.endDate> > > >();

            if (filter.BeginDate != null)
            {
                cmd.WhereAnd <Where <PMProforma.invoiceDate, GreaterEqual <Current <ProFormaFilter.beginDate> > > >();
            }

            if (filter.OwnerID != null)
            {
                cmd.WhereAnd <Where <PMProforma.ownerID, Equal <Current <ProFormaFilter.currentOwnerID> > > >();
            }

            if (filter.WorkGroupID != null)
            {
                cmd.WhereAnd <Where <PMProforma.workgroupID, Equal <Current <ProFormaFilter.workGroupID> > > >();
            }

            if (Filter.Current.ShowAll == true)
            {
                cmd.WhereAnd <Where <PMProforma.hold, Equal <False> > > ();
            }

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

            foreach (PXResult <PMProforma> res in cmd.View.Select(PXView.Currents, null, PXView.Searches, PXView.SortColumns, PXView.Descendings, PXView.Filters, ref startRow, PXView.MaximumRows, ref totalRows))
            {
                PMProforma item = res;

                PMProforma cached = (PMProforma)Items.Cache.Locate(item);
                if (cached != null)
                {
                    item.Selected = cached.Selected;
                }
                yield return(item);

                PXView.StartRow = 0;
            }
        }