protected virtual void FARegister_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { Docs.SetProcessCaption(Messages.DeleteProc); Docs.SetProcessAllCaption(Messages.DeleteAllProc); Docs.SetProcessDelegate(delegate(List <FARegister> list) { foreach (FARegister register in list) { FARegister copy = (FARegister)Docs.Cache.CreateCopy(register); Docs.Delete(copy); } Actions.PressSave(); }); }
protected override void ClosePeriodProc(FinPeriod p) { PXSelectBase select = new PXSelect <FARegister, Where <FARegister.finPeriodID, Equal <Required <FARegister.finPeriodID> >, And <FARegister.released, Equal <False> > > >(this); FARegister doc = (FARegister)select.View.SelectSingle(p.FinPeriodID); if (doc != null) { throw new PXException(AP.Messages.PeriodHasUnreleasedDocs); } PXResult <FABookBalance, FixedAsset, FABook> res = (PXResult <FABookBalance, FixedAsset, FABook>) PXSelectJoin <FABookBalance, LeftJoin <FixedAsset, On <FixedAsset.assetID, Equal <FABookBalance.assetID> >, LeftJoin <FABook, On <FABookBalance.bookID, Equal <FABook.bookID> >, LeftJoin <FADetails, On <FADetails.assetID, Equal <FABookBalance.assetID> > > > >, Where <FABookBalance.deprFromPeriod, LessEqual <Current <FinPeriod.finPeriodID> >, And <FABookBalance.deprToPeriod, GreaterEqual <Current <FinPeriod.finPeriodID> >, And <FABookBalance.updateGL, Equal <True>, And <FABookBalance.depreciate, Equal <True>, And <FixedAsset.suspended, NotEqual <True>, And <FADetails.hold, NotEqual <True>, And <FABookBalance.initPeriod, IsNotNull, And <Where <FABookBalance.currDeprPeriod, IsNull, And <FABookBalance.status, Equal <FixedAssetStatus.active>, Or <FABookBalance.currDeprPeriod, LessEqual <Current <FinPeriod.finPeriodID> > > > > > > > > > > > > > .SelectSingleBound(this, new object[] { p }); if (res != null) { FixedAsset asset = res; FABook book = res; throw new PXException(Messages.AssetNotDepreciatedInPeriod, asset.AssetCD, book.BookCode, FinPeriodIDAttribute.FormatForError(p.FinPeriodID)); } p.FAClosed = true; Caches[typeof(FinPeriod)].Update(p); Actions.PressSave(); }
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"); } }