コード例 #1
0
ファイル: DMTreeGroup.cs プロジェクト: khanhdtn/my-fw-win
        private void TreeList_1_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        {
            if (focus == _FOCUS.DELETE || focus == _FOCUS.ADD)
            {
                focus = _FOCUS.NONE;
                return;
            }
            else if (focus == _FOCUS.EDIT)
            {
                this.DeleteEmptyNode();
                focus = _FOCUS.NONE;
                return;
            }

            ShowReadOnlyTreeList(true);
            if (e.Node != null && e.Node.ParentNode == null)
            {
                addSameLevel.Enabled = false;
                btnUpdate.Enabled = false;
                btnDel.Enabled = false;
            }
        }
コード例 #2
0
ファイル: DMTreeGroup.cs プロジェクト: khanhdtn/my-fw-win
        private void btnDel_Click(object sender, EventArgs e)
        {
            if (_BeforeDelEvent != null) _BeforeDelEvent(this);
            if (IsFilterRow()) return;

            if (TreeList_1.FocusedNode != null)
            {
                if (TreeList_1.FocusedNode.ParentNode == null)
                {
                    HelpMsgBox.ShowNotificationMessage("Không thể xóa dữ liệu này.");
                    return;
                }
                if (DeleteEmptyNode()) return;

                if (PLMessageBox.ShowConfirmMessage("Bạn có chắc chắn muốn xóa dữ liệu này không ?") == DialogResult.Yes)
                {
                    long id = HelpNumber.ParseInt64(TreeList_1.FocusedNode[this.IDField]);
                    List<long> listID = this.nodeHasParentID(id);
                    listID.Add(id);
                    if (!this.removeListNode(listID))
                    {
                        HelpMsgBox.ShowNotificationMessage("Xóa không thành công vì dữ liệu đang được sử dụng.");
                        if (_AfterDelFailEvent != null) _AfterDelFailEvent(this);
                    }
                    else
                    {
                        focus = _FOCUS.DELETE;
                        this.TreeList_1.BeginUpdate();
                        TreeList_1.DeleteNode(TreeList_1.FocusedNode);
                        ((DataTable)this.TreeList_1.DataSource).AcceptChanges();
                        this.TreeList_1.EndUpdate();
                        if (_AfterDelSuccEvent != null) _AfterDelSuccEvent(this);
                    }
                }
            }
        }
コード例 #3
0
ファイル: DMTreeGroup.cs プロジェクト: khanhdtn/my-fw-win
 private bool DeleteEmptyNode()
 {
     try
     {
         TreeListNode NewNode = TreeList_1.FindNodeByFieldValue(IDField, "-2");
         if (NewNode != null)
         {
             focus = _FOCUS.DELETE;
             TreeList_1.DeleteNode(NewNode);
             TreeList_1.InvalidateNode(NewNode);
             return true;
         }
         if (TempNewNode != null && !TreeList_1.FocusedNode.Equals(TempNewNode))
         {
             focus = _FOCUS.DELETE;
             TreeList_1.DeleteNode(TempNewNode);
             TreeList_1.InvalidateNode(TempNewNode);
             return true;
         }
         if (TempNewNode != null && TempNewNode.GetValue(IDField).ToString() == "-2")
         {
             focus = _FOCUS.DELETE;
             TreeList_1.DeleteNode(TempNewNode);
             TreeList_1.InvalidateNode(TempNewNode);
             return true;
         }
         return false;
     }
     catch (Exception ex){
         PLException.AddException(ex);
         return true;
     }
 }
コード例 #4
0
ファイル: DMTreeGroup.cs プロジェクト: khanhdtn/my-fw-win
        private void addClickEvent(EventArgs e, bool AddChild)
        {
            if (IsFilterRow()) return;
            TreeListNode FocusedNode = TreeList_1.FocusedNode;
            long idParent = -1;
            try
            {
                if (FocusedNode != null)
                {
                    //Xóa nút mới chưa thêm xong
                    DeleteEmptyNode();

                    DataRow row = ((DataTable)TreeList_1.DataSource).NewRow();

                    row[IDField] = "-2";
                    try { row["VISIBLE_BIT"] = "Y"; }
                    catch { }
                    if (AddChild)//Thêm con
                    {
                        idParent = HelpNumber.ParseInt64(FocusedNode[this.IDField]);
                        row[ParentIDField] = idParent;
                        row[GlobalConst.ID_ROOT] = FocusedNode[GlobalConst.ID_ROOT];

                        focus = _FOCUS.ADD;
                        TreeList_1.FocusedNode = TreeList_1.AppendNode(row.ItemArray, FocusedNode);

                    }
                    else//Thêm cùng cấp
                    {
                        if (TreeList_1.FocusedNode.ParentNode != null)
                        {
                            idParent = HelpNumber.ParseInt64(FocusedNode.ParentNode[this.IDField]);
                            row[ParentIDField] = idParent;
                            row[GlobalConst.ID_ROOT] = FocusedNode.ParentNode[GlobalConst.ID_ROOT];

                            focus = _FOCUS.ADD;
                            TreeList_1.FocusedNode = TreeList_1.AppendNode(row.ItemArray, FocusedNode.ParentNode);
                        }
                        else
                        {
                            //Thông báo không cho phép thêm
                            return;
                        }
                    }
                    TempNewNode = TreeList_1.FocusedNode;
                    this.ShowReadOnlyTreeList(false);
                    TreeList_1.Select();
                }
            }
            catch (Exception ex)
            {
                PLException.AddException(ex);
            }
        }