protected virtual void Account_COAOrder_FieldUpdating(PXCache sender, PXFieldUpdatingEventArgs e)
 {
     if (IsCOAOrderVisible == false && e.Row != null && string.IsNullOrEmpty(((Account)e.Row).Type) == false)
     {
         e.NewValue = Convert.ToInt16(AccountType.COAOrderOptions[(int)GLSetup.Current.COAOrder].Substring(AccountType.Ordinal(((Account)e.Row).Type), 1));
     }
 }
        protected virtual void GLSetup_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            GLSetup OldRow = (GLSetup)PXSelectReadonly <GLSetup> .Select(this);

            GLSetup NewRow = (GLSetup)e.Row;

            if ((OldRow == null || OldRow.COAOrder != NewRow.COAOrder) && NewRow.COAOrder < 4)
            {
                for (short i = 0; i < 4; i++)
                {
                    PXDatabase.Update <Account>(new PXDataFieldAssign("COAOrder", Convert.ToInt32(AccountType.COAOrderOptions[(int)NewRow.COAOrder].Substring((int)i, 1))),
                                                new PXDataFieldRestrict("Type", AccountType.Literal(i)));
                    PXDatabase.Update <PM.PMAccountGroup>(new PXDataFieldAssign(typeof(PM.PMAccountGroup.sortOrder).Name, Convert.ToInt32(AccountType.COAOrderOptions[(int)NewRow.COAOrder].Substring((int)i, 1))),
                                                          new PXDataFieldRestrict(typeof(PM.PMAccountGroup.type).Name, AccountType.Literal(i)));
                }
            }
        }