protected virtual void GLBudgetTree_RowSelected(PXCache cache, PXRowSelectedEventArgs e) { GLBudgetTree row = (GLBudgetTree)e.Row; if (row == null) { return; } if (row.IsGroup != null) { PXUIFieldAttribute.SetEnabled <GLBudgetTree.accountID>(cache, row, !(bool)row.IsGroup); PXUIFieldAttribute.SetEnabled <GLBudgetTree.subID>(cache, row, !(bool)row.IsGroup); if ((row.Rollup != null && (bool)row.Rollup && !(bool)row.IsGroup && row.AccountID != null && row.SubID != null)) { PXUIFieldAttribute.SetEnabled <GLBudgetTree.isGroup>(cache, row, false); PXUIFieldAttribute.SetEnabled <GLBudgetTree.accountMask>(cache, row, false); PXUIFieldAttribute.SetEnabled <GLBudgetTree.subMask>(cache, row, false); } if ((bool)row.IsGroup) { //Disable Account and Subaccount mask fields if node has child node if ((PXSelect <GLBudgetTree, Where <GLBudgetTree.parentGroupID, Equal <Required <GLBudgetTree.parentGroupID> > > > .Select(this, row.GroupID).Count > 0)) { PXUIFieldAttribute.SetEnabled <GLBudgetTree.accountMask>(cache, row, false); PXUIFieldAttribute.SetEnabled <GLBudgetTree.subMask>(cache, row, false); } else { PXUIFieldAttribute.SetEnabled <GLBudgetTree.accountMask>(cache, row, true); PXUIFieldAttribute.SetEnabled <GLBudgetTree.subMask>(cache, row, true); } } } PXUIFieldAttribute.SetEnabled <GLBudgetTree.isGroup>(cache, row, !((row.AccountID != null || row.SubID != null) && SubEnabled) || ((row.AccountID != null) && !SubEnabled)); }
public virtual IEnumerable Down(PXAdapter adapter) { GLBudgetTree currentItem = ((GLBudgetTree)PXSelect <GLBudgetTree, Where <GLBudgetTree.groupID, Equal <Required <GLBudgetTree.groupID> > > > .Select(this, this.CurrentSelected.Group)); if (currentItem != null) { GLBudgetTree nextItem = PXSelect <GLBudgetTree, Where <GLBudgetTree.isGroup, Equal <True>, And <GLBudgetTree.parentGroupID, Equal <Required <GLBudgetTree.parentGroupID> >, And <GLBudgetTree.sortOrder, Greater <Required <GLBudgetTree.sortOrder> > > > >, OrderBy <Asc <GLBudgetTree.sortOrder> > > .SelectWindowed(this, 0, 1, currentItem.ParentGroupID, currentItem.SortOrder); if (nextItem != null) { int orderNbr = currentItem.SortOrder.Value; currentItem.SortOrder = nextItem.SortOrder; Tree.Update(currentItem); nextItem.SortOrder = orderNbr; Tree.Update(nextItem); } } return(adapter.Get()); }
protected virtual void GLBudgetTree_RowInserting(PXCache cache, PXRowInsertingEventArgs e) { GLBudgetTree row = e.Row as GLBudgetTree; if (row == null) { return; } if (CurrentSelected.AccountID != null && CurrentSelected.SubID != null && CurrentSelected.AccountID > 0 && CurrentSelected.SubID > 0) { row.Rollup = true; } row.GroupMask = CurrentSelected.GroupMask; if (row.SortOrder == 0) { GLBudgetTree LastItem = PXSelect <GLBudgetTree, Where <GLBudgetTree.parentGroupID, Equal <Required <GLBudgetTree.parentGroupID> > >, OrderBy <Desc <GLBudgetTree.sortOrder> > > .SelectWindowed(this, 0, 1, this.CurrentSelected.Group); row.SortOrder = LastItem == null ? 1 : LastItem.SortOrder.Value + 1; } if ((row.Rollup != null && (bool)row.Rollup && !(bool)row.IsGroup)) { PXUIFieldAttribute.SetEnabled <GLBudgetTree.isGroup>(cache, row, false); PXUIFieldAttribute.SetEnabled <GLBudgetTree.accountMask>(cache, row, false); PXUIFieldAttribute.SetEnabled <GLBudgetTree.subMask>(cache, row, false); } }
public virtual IEnumerable Left(PXAdapter adapter) { GLBudgetTree currentItem = ((GLBudgetTree)PXSelect <GLBudgetTree, Where <GLBudgetTree.groupID, Equal <Required <GLBudgetTree.groupID> > > > .Select(this, this.CurrentSelected.Group)); if (currentItem != null) { GLBudgetTree parentItem = PXSelect <GLBudgetTree, Where <GLBudgetTree.isGroup, Equal <True>, And <GLBudgetTree.groupID, Equal <Required <GLBudgetTree.groupID> > > >, OrderBy <Desc <GLBudgetTree.sortOrder> > > .SelectWindowed(this, 0, 1, currentItem.ParentGroupID); if (parentItem != null) { GLBudgetTree lastItem = PXSelect <GLBudgetTree, Where <GLBudgetTree.parentGroupID, Equal <Required <GLBudgetTree.parentGroupID> > >, OrderBy <Desc <GLBudgetTree.sortOrder> > > .SelectWindowed(this, 0, 1, parentItem.ParentGroupID); if (lastItem != null) { currentItem.ParentGroupID = lastItem.ParentGroupID; currentItem.SortOrder = lastItem.SortOrder + 1; Tree.Update(currentItem); } } } return(adapter.Get()); }
protected virtual void GLBudgetTree_GroupID_FieldDefaulting(PXCache cache, PXFieldDefaultingEventArgs e) { GLBudgetTree row = e.Row as GLBudgetTree; if (row == null) { return; } row.GroupID = Guid.NewGuid(); row.ParentGroupID = this.CurrentSelected.Group == null ? Guid.Empty : this.CurrentSelected.Group; }
public virtual IEnumerable showPreload(PXAdapter adapter) { GLBudgetTree parentNode = PXSelect <GLBudgetTree, Where <GLBudgetTree.groupID, Equal <Required <GLBudgetTree.groupID> > > > .Select(this, this.CurrentSelected.Group); PXStringState subStrState = (PXStringState)Details.Cache.GetStateExt(null, typeof(GLBudgetTree.subID).Name); string subWildCard = new String('?', subStrState.InputMask.Length - 1); if (parentNode != null) { PreloadFilter.Current.AccountCDWildcard = SubCDUtils.CreateSubCDWildcard(parentNode != null ? parentNode.AccountMask : string.Empty, AccountAttribute.DimensionName); if (parentNode.AccountMask != null) { Account AcctFrom = PXSelect <Account, Where <Account.active, Equal <True>, And <Account.accountCD, Like <Required <SelectedNode.accountMaskWildcard> > > >, OrderBy <Asc <Account.accountCD> > > .SelectWindowed(this, 0, 1, PreloadFilter.Current.AccountCDWildcard); Account AcctTo = PXSelect <Account, Where <Account.active, Equal <True>, And <Account.accountCD, Like <Required <AccountsPreloadFilter.accountCDWildcard> > > >, OrderBy <Desc <Account.accountCD> > > .SelectWindowed(this, 0, 1, PreloadFilter.Current.AccountCDWildcard); PreloadFilter.Current.FromAccount = AcctFrom != null ? AcctFrom.AccountID : null; PreloadFilter.Current.ToAccount = AcctTo != null ? AcctTo.AccountID : null; } else { PreloadFilter.Current.FromAccount = null; PreloadFilter.Current.ToAccount = null; } PreloadFilter.Current.SubIDFilter = parentNode.SubMask ?? subWildCard; } else { PreloadFilter.Current.FromAccount = null; PreloadFilter.Current.ToAccount = null; PreloadFilter.Current.SubIDFilter = subWildCard; } if (PreloadFilter.Current != null) { if (parentNode != null) { if (parentNode.AccountMask != null && PreloadFilter.Current.FromAccount == null) { if (Details.Ask(Messages.BudgetTreePreloadArticlesTitle, String.Format(PXMessages.LocalizeNoPrefix(Messages.BudgetTreePreloadArticlesMessage), parentNode.AccountMask), MessageButtons.OK) == WebDialogResult.OK) { return(adapter.Get()); } } } } Details.AskExt(); return(adapter.Get()); }
protected virtual void GLBudgetTree_AccountID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { GLBudgetTree row = e.Row as GLBudgetTree; object defaultValue; sender.RaiseFieldDefaulting("Description", e.Row, out defaultValue); if (defaultValue != null) { row.Description = defaultValue.ToString(); } row.IsGroup = false; }
protected virtual void GLBudgetTree_SubID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e) { GLBudgetTree row = e.Row as GLBudgetTree; if (row == null) { return; } if (row.SubMask == null) { row.SubMask = ((Sub)PXSelect <Sub, Where <Sub.subID, Equal <Required <Sub.subID> > > > .Select(this, row.SubID)).SubCD; } row.IsGroup = false; }
public virtual IEnumerable configureSecurity(PXAdapter adapter) { GLBudgetTree group = PXSelect <GLBudgetTree, Where <GLBudgetTree.groupID, Equal <Current <GLBudgetTree.groupID> > > > .SelectSingleBound(this, new object[] { Details.Current }); if (group != null) { GLAccessByBudgetNode graph = CreateInstance <GLAccessByBudgetNode>(); graph.BudgetTree.Current = group; throw new PXRedirectRequiredException(graph, false, "Restricted Groups"); } else { throw new PXException(Messages.BudgetTreeNodeNotFound); } }
protected virtual void GLBudgetTree_RowPersisting(PXCache cache, PXRowPersistingEventArgs e) { GLBudgetTree row = e.Row as GLBudgetTree; if (row == null) { return; } /// Never persist the root node - it is always provided by the <see cref=tree /> delegate. /// if (row.GroupID == Guid.Empty) { e.Cancel = true; return; } bool isGroup = (bool)row.IsGroup || row.GroupID == row.ParentGroupID; if ((row.AccountID == null || row.SubID == null) && !isGroup) { Details.Cache.RaiseExceptionHandling <GLBudgetTree.accountID>(e.Row, row.AccountID, new PXSetPropertyException(PXMessages.LocalizeNoPrefix(Messages.AcctSubMayNotBeEmptyForNonGroup), PXErrorLevel.RowError)); return; } if (((row.AccountMask == null || row.SubMask == null) && !isGroup && SubEnabled) || (row.AccountMask == null && !isGroup && !SubEnabled)) { Details.Cache.RaiseExceptionHandling <GLBudgetTree.accountID>(e.Row, row.AccountMask, new PXSetPropertyException(PXMessages.LocalizeNoPrefix(Messages.AcctSubMaskNotBeEmptyForNonGroup), PXErrorLevel.RowError)); return; } if (SubEnabled && isGroup && row.AccountMask == null && row.SubMask != null) { Details.Cache.RaiseExceptionHandling <GLBudgetTree.accountID>(e.Row, row.AccountMask, new PXSetPropertyException(PXMessages.LocalizeNoPrefix(Messages.AcctMaskMayNotBeEmptyForGroup), PXErrorLevel.RowError)); return; } if (SubEnabled && isGroup && row.AccountMask != null && row.SubMask == null) { Details.Cache.RaiseExceptionHandling <GLBudgetTree.accountID>(e.Row, row.AccountMask, new PXSetPropertyException(PXMessages.LocalizeNoPrefix(Messages.SubMaskMayNotBeEmptyForGroup), PXErrorLevel.RowError)); return; } }
private void VerifyParentChildMask(GLBudgetTree child, GLBudgetTree parent) { if (child.ParentGroupID == parent.GroupID && parent.AccountMask != null && parent.SubMask != null) { if (!MatchMask(child.AccountMask, parent.AccountMask ?? string.Empty, false)) { Details.Cache.RaiseExceptionHandling <GLBudgetTree.accountMask>(child, child.AccountMask, new PXSetPropertyException(String.Format(PXMessages.LocalizeNoPrefix(Messages.BudgetTreeIncorrectAccountMask), parent.AccountMask), PXErrorLevel.Error)); } else { if (!MatchMask(child.SubMask, parent.SubMask ?? string.Empty, false)) { Details.Cache.RaiseExceptionHandling <GLBudgetTree.subMask>(child, child.SubMask, new PXSetPropertyException(String.Format(PXMessages.LocalizeNoPrefix(Messages.BudgetTreeIncorrectSubMask), parent.SubMask), PXErrorLevel.Error)); } } } }
protected virtual void GLBudgetTree_IsGroup_FieldUpdating(PXCache sender, PXFieldUpdatingEventArgs e) { GLBudgetTree row = e.Row as GLBudgetTree; if (e.NewValue != null && row.IsGroup != null && (bool)row.IsGroup && !(bool)e.NewValue) { if (Details.Ask(Messages.BudgetTreeDeleteGroupTitle, Messages.BudgetTreeDeleteGroupMessage, MessageButtons.YesNo) == WebDialogResult.Yes) { deleteRecords(row.GroupID); } else { e.NewValue = true; e.Cancel = true; } } }
public virtual IEnumerable Delete(PXAdapter adapter) { GLBudgetTree lineCopy = PXCache <GLBudgetTree> .CreateCopy(Details.Current); if (Details.Current.IsGroup == true && Details.Current.GroupID != Details.Current.ParentGroupID) { if (Details.Ask(Messages.BudgetTreeDeleteGroupTitle, Messages.BudgetTreeDeleteGroupMessage, MessageButtons.YesNo) == WebDialogResult.Yes) { deleteRecords(Details.Current.GroupID); Details.Cache.Delete(lineCopy); } } else { Details.Cache.Delete(lineCopy); } return(adapter.Get()); }
public virtual IEnumerable Right(PXAdapter adapter) { GLBudgetTree currentItem = ((GLBudgetTree)PXSelect <GLBudgetTree, Where <GLBudgetTree.groupID, Equal <Required <GLBudgetTree.groupID> > > > .Select(this, this.CurrentSelected.Group)); if (currentItem != null) { GLBudgetTree nextItem = PXSelect <GLBudgetTree, Where <GLBudgetTree.isGroup, Equal <True>, And <GLBudgetTree.parentGroupID, Equal <Required <GLBudgetTree.parentGroupID> >, And <GLBudgetTree.sortOrder, Less <Required <GLBudgetTree.sortOrder> > > > >, OrderBy <Desc <GLBudgetTree.sortOrder> > > .SelectWindowed(this, 0, 1, currentItem.ParentGroupID, currentItem.SortOrder); if (nextItem != null) { if ((bool)nextItem.IsGroup && nextItem.AccountMask != null && nextItem.SubMask != null) { if (Details.Ask(Messages.BudgetTreeCannotMoveGroupTitle, Messages.BudgetTreeCannotMoveGroupAggregatingArticle, MessageButtons.OK) == WebDialogResult.OK) { return(adapter.Get()); } } GLBudgetTree lastChildItem = PXSelect <GLBudgetTree, Where <GLBudgetTree.parentGroupID, Equal <Required <GLBudgetTree.parentGroupID> > >, OrderBy <Desc <GLBudgetTree.sortOrder> > > .SelectWindowed(this, 0, 1, nextItem.GroupID); if (lastChildItem != null) { currentItem.ParentGroupID = lastChildItem.ParentGroupID; currentItem.SortOrder = lastChildItem.SortOrder + 1; Tree.Update(currentItem); } else { currentItem.ParentGroupID = nextItem.GroupID; currentItem.SortOrder = 1; Tree.Update(currentItem); } } } return(adapter.Get()); }
protected virtual void GLBudgetTree_RowPersisting(PXCache cache, PXRowPersistingEventArgs e) { GLBudgetTree row = e.Row as GLBudgetTree; if (row == null) { return; } if ((row.AccountID == null || row.SubID == null) && !(bool)row.IsGroup) { Details.Cache.RaiseExceptionHandling <GLBudgetTree.accountID>(e.Row, row.AccountID, new PXSetPropertyException(PXMessages.LocalizeNoPrefix(Messages.AcctSubMayNotBeEmptyForNonGroup), PXErrorLevel.RowError)); return; } if (((row.AccountMask == null || row.SubMask == null) && !(bool)row.IsGroup && SubEnabled) || (row.AccountMask == null && !(bool)row.IsGroup && !SubEnabled)) { Details.Cache.RaiseExceptionHandling <GLBudgetTree.accountID>(e.Row, row.AccountMask, new PXSetPropertyException(PXMessages.LocalizeNoPrefix(Messages.AcctSubMaskNotBeEmptyForNonGroup), PXErrorLevel.RowError)); return; } if (SubEnabled && (bool)row.IsGroup && row.AccountMask == null && row.SubMask != null) { Details.Cache.RaiseExceptionHandling <GLBudgetTree.accountID>(e.Row, row.AccountMask, new PXSetPropertyException(PXMessages.LocalizeNoPrefix(Messages.AcctMaskMayNotBeEmptyForGroup), PXErrorLevel.RowError)); return; } if (SubEnabled && (bool)row.IsGroup && row.AccountMask != null && row.SubMask == null) { Details.Cache.RaiseExceptionHandling <GLBudgetTree.accountID>(e.Row, row.AccountMask, new PXSetPropertyException(PXMessages.LocalizeNoPrefix(Messages.SubMaskMayNotBeEmptyForGroup), PXErrorLevel.RowError)); return; } }
public virtual IEnumerable preload(PXAdapter adapter) { if (PreloadFilter.Current.FromAccount == null) { PreloadFilter.Cache.RaiseExceptionHandling <AccountsPreloadFilter.fromAccount>(PreloadFilter.Current, PreloadFilter.Current.FromAccount, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, PXErrorLevel.RowError)); PreloadFilter.Cache.RaiseExceptionHandling <AccountsPreloadFilter.toAccount>(PreloadFilter.Current, PreloadFilter.Current.ToAccount, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, PXErrorLevel.RowError)); return(adapter.Get()); } GLBudgetTree currentItem = ((GLBudgetTree)PXSelect <GLBudgetTree, Where <GLBudgetTree.groupID, Equal <Required <GLBudgetTree.groupID> > > > .Select(this, this.CurrentSelected.Group)); PreloadFilter.Current.AccountCDWildcard = SubCDUtils.CreateSubCDWildcard(currentItem != null ? currentItem.AccountMask : string.Empty, AccountAttribute.DimensionName); GLBudgetTree LastItem = PXSelect <GLBudgetTree, Where <GLBudgetTree.parentGroupID, Equal <Required <GLBudgetTree.parentGroupID> > >, OrderBy <Desc <GLBudgetTree.sortOrder> > > .SelectWindowed(this, 0, 1, this.CurrentSelected.Group); int LastSortNum = LastItem == null ? 1 : LastItem.SortOrder.Value + 1; bool noLinesPreloaded = true; List <GLBudgetTree> nodesToInsert = new List <GLBudgetTree>(); foreach (PXResult <Account> account in PXSelect <Account, Where <Account.accountCD, GreaterEqual <Required <Account.accountCD> >, And <Account.active, Equal <True>, And <Account.accountCD, LessEqual <Required <Account.accountCD> >, And <Account.accountID, NotEqual <Current <GL.GLSetup.ytdNetIncAccountID> > > > > > > .Select(this, PreloadFilter.Current.FromAccount != null ? ((Account)PXSelect <Account, Where <Account.accountID, Equal <Current <AccountsPreloadFilter.fromAccount> > > > .Select(this)).AccountCD : ((Account)PXSelect <Account> .Select(this).First()).AccountCD, PreloadFilter.Current.ToAccount != null ? ((Account)PXSelect <Account, Where <Account.accountID, Equal <Current <AccountsPreloadFilter.toAccount> > > > .Select(this)).AccountCD : ((Account)PXSelect <Account> .Select(this).Last()).AccountCD)) { foreach (PXResult <Sub> sub in PXSelect <Sub, Where <Sub.active, Equal <True>, And <Sub.subCD, Like <Current <AccountsPreloadFilter.subCDWildcard> > > > > .Select(this)) { Account acct = account; Sub subAcct = sub; GLBudgetTree group = new GLBudgetTree(); if (currentItem == null || acct.AccountID != currentItem.AccountID || subAcct.SubID != currentItem.SubID) { group.AccountID = acct.AccountID; group.SubID = subAcct.SubID; group.SortOrder = LastSortNum++; group.GroupMask = CurrentSelected.GroupMask; nodesToInsert.Add(group); noLinesPreloaded = false; } } } if (noLinesPreloaded) { if (Details.Ask(Messages.BudgetTreePreloadArticlesTitle, Messages.BudgetTreePreloadArticlesNothingToPreload, MessageButtons.OK) == WebDialogResult.OK) { return(adapter.Get()); } } if (nodesToInsert.Count > 500) { if (Details.Ask(Messages.Confirmation, String.Format(PXMessages.LocalizeNoPrefix(Messages.BudgetTreePreloadArticlesTooManyMessage), nodesToInsert.Count), MessageButtons.OKCancel) == WebDialogResult.OK) { InsertPreloadedNodes(nodesToInsert); } } else { InsertPreloadedNodes(nodesToInsert); } return(adapter.Get()); }
protected virtual IEnumerable details( [PXGuid] Guid?groupID ) { if (groupID == null) { groupID = this.Tree.Current != null ? this.Tree.Current.GroupID : Guid.Empty; } this.CurrentSelected.Group = groupID; GLBudgetTree parentNode = PXSelect <GLBudgetTree, Where <GLBudgetTree.groupID, Equal <Required <GLBudgetTree.groupID> > > > .Select(this, this.CurrentSelected.Group); if (parentNode != null) { this.CurrentSelected.AccountID = parentNode.AccountID != null ? parentNode.AccountID : Int32.MinValue; this.CurrentSelected.SubID = parentNode.SubID != null ? parentNode.SubID : Int32.MinValue; this.CurrentSelected.GroupMask = parentNode.GroupMask; } else { this.CurrentSelected.AccountID = Int32.MinValue; this.CurrentSelected.SubID = Int32.MinValue; this.CurrentSelected.GroupMask = null; } this.CurrentSelected.AccountMaskWildcard = SubCDUtils.CreateSubCDWildcard(parentNode != null ? parentNode.AccountMask : string.Empty, AccountAttribute.DimensionName); this.CurrentSelected.SubMaskWildcard = parentNode != null ? parentNode.SubMask : string.Empty; List <GLBudgetTree> nodes = new List <GLBudgetTree>(); foreach (GLBudgetTree node in PXSelect <GLBudgetTree, Where <GLBudgetTree.parentGroupID, Equal <Required <GLBudgetTree.parentGroupID> >, And <GLBudgetTree.parentGroupID, NotEqual <GLBudgetTree.groupID>, And <Match <Current <AccessInfo.userName> > > > > > .Select(this, groupID)) { if (node.GroupMask != null) { foreach (byte b in node.GroupMask) { if (b != 0x00) { node.Secured = true; } } } nodes.Add(node); } if (PXSelect <GLBudgetTree, Where <GLBudgetTree.groupID, Equal <Required <GLBudgetTree.groupID> >, And <Match <Current <AccessInfo.userName> > > > > .Select(this, groupID).Count == 0 && groupID != Guid.Empty) { Details.Cache.AllowInsert = false; Details.Cache.AllowDelete = false; Details.Cache.AllowUpdate = false; } else { Details.Cache.AllowInsert = true; Details.Cache.AllowDelete = true; Details.Cache.AllowUpdate = true; } return(nodes); }