Beispiel #1
0
 public DeleteDocsProcess()
 {
     Docs.SetProcessCaption(Messages.DeleteProc);
     Docs.SetProcessAllCaption(Messages.DeleteAllProc);
     Docs.SetProcessDelegate(delegate(List <FARegister> list)
     {
         bool failed = false;
         TransactionEntry entryGraph = CreateInstance <TransactionEntry>();
         foreach (FARegister register in list)
         {
             PXProcessing.SetCurrentItem(register);
             try
             {
                 entryGraph.Clear();
                 entryGraph.Document.Current = entryGraph.Document.Search <FARegister.refNbr>(register.RefNbr);
                 entryGraph.Delete.Press();
                 PXProcessing.SetProcessed();
             }
             catch (Exception e)
             {
                 failed = true;
                 PXProcessing.SetError(e);
             }
         }
         if (failed)
         {
             throw new PXOperationCompletedWithErrorException(ErrorMessages.SeveralItemsFailed);
         }
     });
 }
        public virtual IEnumerable ViewDocument(PXAdapter adapter)
        {
            TransactionEntry graph = CreateInstance <TransactionEntry>();

            graph.Document.Current = graph.Document.Search <FARegister.refNbr>(Docs.Current.RefNbr);
            throw new PXRedirectRequiredException(graph, "FATransactions")
                  {
                      Mode = PXBaseRedirectException.WindowMode.NewWindow
                  };
        }
        protected virtual void DoTransfer(TransferFilter filter, List <FixedAsset> list)
        {
            DocumentList <FARegister> created = new DocumentList <FARegister>(this);

            foreach (FixedAsset asset in list)
            {
                FADetails det = PXSelect <FADetails, Where <FADetails.assetID, Equal <Current <FixedAsset.assetID> > > > .SelectSingleBound(this, new object[] { asset });

                FALocationHistory location = PXSelect <FALocationHistory, Where <FALocationHistory.assetID, Equal <Current <FADetails.assetID> >, And <FALocationHistory.revisionID, Equal <Current <FADetails.locationRevID> > > > > .SelectSingleBound(this, new object[] { det });

                int?   destClassID  = filter.ClassTo ?? asset.ClassID;
                int?   destBranchID = filter.BranchTo ?? location.LocationID;
                string destDeptID   = string.IsNullOrEmpty(filter.DepartmentTo) ? location.Department : filter.DepartmentTo;

                if (location.LocationID != destBranchID || location.Department != destDeptID || asset.ClassID != destClassID)
                {
                    FADetails         copy_det = (FADetails)Details.Cache.CreateCopy(det);
                    FALocationHistory copy_loc = (FALocationHistory)Lochist.Cache.CreateCopy(location);
                    copy_loc.RevisionID      = ++copy_det.LocationRevID;
                    copy_loc.LocationID      = destBranchID;
                    copy_loc.Department      = destDeptID;
                    copy_loc.PeriodID        = filter.PeriodID;
                    copy_loc.TransactionDate = filter.TransferDate;
                    copy_loc.Reason          = filter.Reason;

                    TransactionEntry.SegregateRegister(this, (int)destBranchID, FARegister.origin.Transfer, null, filter.TransferDate, "", created);

                    Details.Update(copy_det);
                    location = Lochist.Insert(copy_loc);

                    if (asset.ClassID != destClassID)
                    {
                        asset.ClassID = destClassID;
                        AssetSelect.Cache.Update(asset);
                    }

                    FARegister reg = Register.Current;
                    AssetProcess.TransferAsset(this, asset, location, ref reg);
                }
            }
            if (Register.Current != null && created.Find(Register.Current) == null)
            {
                created.Add(Register.Current);
            }
            Actions.PressSave();
            if (fasetup.Current.AutoReleaseTransfer == true)
            {
                SelectTimeStamp();
                PXLongOperation.StartOperation(this, delegate { AssetTranRelease.ReleaseDoc(created, false); });
            }
            else if (created.Count > 0)
            {
                AssetTranRelease graph = CreateInstance <AssetTranRelease>();
                AssetTranRelease.ReleaseFilter fltr = (AssetTranRelease.ReleaseFilter)graph.Filter.Cache.CreateCopy(graph.Filter.Current);
                fltr.Origin = FARegister.origin.Transfer;
                graph.Filter.Update(fltr);
                graph.SelectTimeStamp();

                Dictionary <string, string> parameters = new Dictionary <string, string>();

                for (int i = 0; i < created.Count; ++i)
                {
                    FARegister reg = created[i];
                    reg.Selected = true;
                    graph.FADocumentList.Update(reg);
                    graph.FADocumentList.Cache.SetStatus(reg, PXEntryStatus.Updated);
                    graph.FADocumentList.Cache.IsDirty = false;

                    parameters["FARegister.RefNbr" + i] = reg.RefNbr;
                }

                parameters["PeriodFrom"] = FinPeriodIDFormattingAttribute.FormatForDisplay(filter.PeriodID);
                parameters["PeriodTo"]   = FinPeriodIDFormattingAttribute.FormatForDisplay(filter.PeriodID);
                parameters["Mode"]       = "U";

                PXReportRequiredException reportex = new PXReportRequiredException(parameters, "FA642000", "Preview");
                throw new PXRedirectWithReportException(graph, reportex, "Release FA Transaction");
            }
        }