Beispiel #1
0
        // End of (mostly copied) drag-drop functions

        private void InsertInOrder(TreeNode Parent, TreeNode Child)
        {
            int Idx;
            AccountNodeDetails ChildTag = (AccountNodeDetails)Child.Tag;

/*
 * Apparently it is best to always use the Reporting Order, for both Summary and Posting accounts.
 *
 *          if (ChildTag.AccountRow.PostingStatus) // Posting accounts are sorted alphabetically:
 *          {
 *              for (Idx = 0; Idx < Parent.Nodes.Count; Idx++)
 *              {
 *                  if (Parent.Nodes[Idx].Text.CompareTo(Child.Text) > 0)
 *                  {
 *                      break;
 *                  }
 *              }
 *          }
 *          else // For summary accounts I need to use the ReportOrder, then alphabetic:
 */
            {
                String ChildDescr = ChildTag.DetailRow.ReportOrder.ToString("000") + Child.Text;

                for (Idx = 0; Idx < Parent.Nodes.Count; Idx++)
                {
                    AccountNodeDetails SiblingTag = (AccountNodeDetails)Parent.Nodes[Idx].Tag;

                    if ((SiblingTag.DetailRow.ReportOrder.ToString("000") + Child.Text).CompareTo(ChildDescr) > 0)
                    {
                        break;
                    }
                }
            }

            if (Idx == Parent.Nodes.Count)
            {
                Parent.Nodes.Add(Child);
            }
            else
            {
                Parent.Nodes.Insert(Idx, Child);
            }

            if (!FDuringInitialisation)
            {
                FParentForm.SetSelectedAccount(ChildTag);
            }
        }
        void Selection_SelectionChanged(object sender, SourceGrid.RangeRegionChangedEventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            if (FParentForm.FIAmUpdating == 0)
            {
                int         previousRowId = FPrevRowChangedRow;
                int         newRowId      = grdAccounts.Selection.ActivePosition.Row;
                DataRowView rowView       = (DataRowView)grdAccounts.Rows.IndexToDataSourceRow(newRowId);

                if (rowView == null)
                {
                    FPreviouslySelectedDetailRow = null;
                    FParentForm.SetSelectedAccount(null);
                    FParentForm.PopulateControlsAfterRowSelection();
                    Console.WriteLine("Selected row is NULL");
                }
                else
                {
                    FPreviouslySelectedDetailRow = rowView.Row;
                    String SelectedAccountCode = ((GLSetupTDSAAccountRow)rowView.Row).AccountCode;

                    FSelectionMadeInList = true;
                    FParentForm.SetSelectedAccountCode(SelectedAccountCode);
                    FSelectionMadeInList = false;

                    if (previousRowId == -1)
                    {
                        FParentForm.PopulateControlsAfterRowSelection();
                    }

                    Console.WriteLine("Row is {0}", FPreviouslySelectedDetailRow.ItemArray[1]);
                }

                FPrevRowChangedRow = newRowId;
            }
            else
            {
                Console.WriteLine("Skipping selection_changed...");
            }

            this.Cursor = Cursors.Default;
        }