protected virtual void AP1099Year_RowSelected(PXCache sender, PXRowSelectedEventArgs e) { AP1099Year year1099 = (AP1099Year)e.Row; if (year1099 == null) { return; } close1099Year.SetEnabled(!string.IsNullOrEmpty(year1099.FinYear) && year1099.Status == AP1099Year.status.Open); int?[] childBranches = BranchMaint.GetChildBranches(this, Year_Header.Current.BranchID) .Select(branch => branch.BranchID) .ToArray(); if (childBranches.Length == 0) { return; } bool hasUnappliedPrepayments = PXSelectJoin <APRegister, InnerJoin <Vendor, On <APRegister.vendorID, Equal <Vendor.bAccountID> >, InnerJoin <FinPeriod, On <APRegister.finPeriodID, Equal <FinPeriod.finPeriodID> > > >, Where <Vendor.vendor1099, Equal <True>, And <APRegister.docType, Equal <APDocType.prepayment>, And <APRegister.status, NotEqual <APDocStatus.closed>, And <FinPeriod.finYear, Equal <Current <AP1099Year.finYear> >, And <APRegister.branchID, In <Required <APRegister.branchID> > > > > > > > .SelectWindowed(this, 0, 1, childBranches) .Any(); PXSetPropertyException finYearExeption = hasUnappliedPrepayments ? new PXSetPropertyException(Messages.ExistsUnappliedPayments, PXErrorLevel.Warning, year1099.FinYear) : null; sender.RaiseExceptionHandling <AP1099Year.finYear>( year1099, year1099.FinYear, finYearExeption); }
public virtual IEnumerable Close1099Year(PXAdapter adapter) { int?[] childBranches = BranchMaint.GetChildBranches(this, Year_Header.Current.BranchID) .Select(branch => branch.BranchID) .ToArray(); PXCache cache = Year_Header.Cache; List <AP1099Year> list = adapter.Get().Cast <AP1099Year>().ToList(); foreach (AP1099Year year in list .Where(year => !string.IsNullOrEmpty(year.FinYear) && year.Status == AP1099Year.status.Open && childBranches.Contains(year.BranchID))) { year.Status = AP1099Year.status.Closed; cache.Update(year); } if (cache.IsInsertedUpdatedDeleted) { Actions.PressSave(); PXLongOperation.StartOperation(this, delegate {}); } return(list); }