Esempio n. 1
0
        private void TreeViewAfterSelect(object sender, TreeViewEventArgs treeViewEventArgs)
        {
            // System.Console.WriteLine("TreeViewAfterSelect: " + treeViewEventArgs.Node.Text);

            // store current detail values
            if ((FSelectedCostCentre != null) && (FSelectedCostCentre.linkedTreeNode != treeViewEventArgs.Node))
            {
                SetNodeLabel(FSelectedCostCentre.CostCentreRow);
            }

            FParentForm.SetSelectedCostCentre((CostCentreNodeDetails)treeViewEventArgs.Node.Tag); // This will change my FSelectedCostCentre
            FPetraUtilsObject.SuppressChangeDetection = true;

            FSelectedCostCentre.GetAttrributes();
            FParentForm.PopulateControlsAfterRowSelection();
        }
Esempio n. 2
0
        private void treeView_DragOver(object sender, DragEventArgs e)
        {
            Point pt = trvCostCentres.PointToClient(new Point(e.X, e.Y));

            FDragTarget = trvCostCentres.GetNodeAt(pt);

            if (FDragTarget == null)
            {
                return;
            }

            ScrollIntoView(FDragTarget);

            // Is the referenced node a valid drop target?
            bool CantDropHere = (FDragTarget == FDragNode) || IsDescendantOf(FDragTarget, FDragNode);

            if (!CantDropHere)
            {
                CostCentreNodeDetails NodeDetails = (CostCentreNodeDetails)FDragTarget.Tag;
                NodeDetails.GetAttrributes();

                if (!NodeDetails.CanHaveChildren.Value)
                {
                    CantDropHere = true;
                }
            }

            if (CantDropHere)
            {
                e.Effect    = DragDropEffects.Scroll;
                FDragTarget = null;
            }
            else
            {
                e.Effect = DragDropEffects.Move | DragDropEffects.Scroll;
                ShowNodeSelected(FDragTarget);
            }
        }
        private void AddNewCostCentre(Object sender, EventArgs e)
        {
            if (FCurrentCostCentre == null)
            {
                MessageBox.Show(Catalog.GetString("You can only add a new cost centre after selecting a parent cost centre"));
                return;
            }

            if (ValidateAllData(true, true))
            {
                FCurrentCostCentre.GetAttrributes();
                ACostCentreRow ParentRow = FCurrentCostCentre.CostCentreRow;

                if (!FCurrentCostCentre.CanHaveChildren.Value)
                {
                    MessageBox.Show(
                        String.Format(Catalog.GetString("Cost Centre {0} is in use and cannot become a summary Cost Centre."),
                            ParentRow.CostCentreCode), Catalog.GetString("NewCostCentre"));
                    return;
                }

                Int32 countNewCostCentre = 0;
                string newCostCentreName = FnameForNewCostCentre;

                if (FMainDS.ACostCentre.Rows.Find(new object[] { FLedgerNumber, newCostCentreName }) != null)
                {
                    while (FMainDS.ACostCentre.Rows.Find(new object[] { FLedgerNumber, newCostCentreName + countNewCostCentre.ToString() }) != null)
                    {
                        countNewCostCentre++;
                    }

                    newCostCentreName += countNewCostCentre.ToString();
                }

                ParentRow.PostingCostCentreFlag = false;
                FCurrentCostCentre.CanDelete = false;

                ACostCentreRow newCostCentreRow = FMainDS.ACostCentre.NewRowTyped();
                newCostCentreRow.CostCentreCode = newCostCentreName;
                newCostCentreRow.LedgerNumber = FLedgerNumber;
                newCostCentreRow.CostCentreActiveFlag = true;

                //
                // OM - specific code ahead!
                if (ParentRow.CostCentreCode == "ILT")
                {
                    newCostCentreRow.CostCentreType = "Foreign";
                }
                else
                {
                    newCostCentreRow.CostCentreType = ParentRow.CostCentreType;
                }

                newCostCentreRow.PostingCostCentreFlag = true;
                newCostCentreRow.CostCentreToReportTo = ParentRow.CostCentreCode;
                FMainDS.ACostCentre.Rows.Add(newCostCentreRow);

                FRecentlyUpdatedDetailCostCentreCode = INTERNAL_UNASSIGNED_DETAIL_COSTCENTRE_CODE;

                FIAmUpdating++;
                ShowDetails(newCostCentreRow);
                FIAmUpdating--;

                ucoCostCentreTree.AddNewCostCentre(newCostCentreRow);
                txtDetailCostCentreCode.Focus();
                txtDetailCostCentreCode.SelectAll();
                FPetraUtilsObject.SetChangedFlag();
            }
        }