Ejemplo n.º 1
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            if (this.LastControl == dgvInfo)
            {
                switch (this.dgvInfo.Rows.Count)
                {
                case 0:
                    this.LastControl = tvOrganize;
                    return;
                }

                //var frmEditOrganize = new FrmEditOrganize(this.EntityId);
                string tmpId = BasePageLogic.GetDataGridViewEntityId(dgvInfo, PiOrganizeTable.FieldId);
                if (string.IsNullOrEmpty(tmpId))
                {
                    return;
                }
                var frmEditOrganize = new FrmEditOrganize(tmpId);
                if (frmEditOrganize.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }
                BasePageLogic.FindTreeNode(this.tvOrganize, tmpId);
                var selectedNode = BasePageLogic.TargetNode;
                selectedNode.Text = frmEditOrganize.FullName;
                var oldParentNode = selectedNode.Parent;
                BasePageLogic.FindTreeNode(this.tvOrganize, frmEditOrganize.ParentId);
                var parentNode = BasePageLogic.TargetNode;

                BasePageLogic.EditTreeNode(this.tvOrganize, selectedNode, parentNode);

                this.GetOrganizeList();
                if (this.DTOrganizeList.Rows.Count > 0)
                {
                    this.dgvInfo.FirstDisplayedScrollingRowIndex = this.DTOrganizeList.Rows.Count - 1;
                }
            }
            else
            {
                if (tvOrganize.SelectedNode == null)
                {
                    return;
                }

                var frmEditOrganize = new FrmEditOrganize(this.ParentEntityId);
                if (frmEditOrganize.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
                {
                    this.tvOrganize.SelectedNode.Text = frmEditOrganize.FullName;
                    this.GetOrganizeList();
                    if (this.DTOrganizeList.Rows.Count <= 0)
                    {
                        return;
                    }
                    this.dgvInfo.FirstDisplayedScrollingRowIndex = this.DTOrganizeList.Rows.Count - 1;
                }
            }
        }
Ejemplo n.º 2
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string          returnValue  = string.Empty;
            FrmEditOrganize editOrgznize = null;

            if (this.LastControl == this.tvOrganize)
            {
                editOrgznize = this.ParentEntityId.Length == 0 || this.tvOrganize.SelectedNode == null
                    ? new FrmEditOrganize()
                    : new FrmEditOrganize(this.ParentEntityId, this.tvOrganize.SelectedNode.Text);
            }
            else
            {
                var dataRow = BasePageLogic.GetDataGridViewEntity(this.dgvInfo);
                editOrgznize = dataRow == null ? new FrmEditOrganize() : new FrmEditOrganize(dataRow[PiOrganizeTable.FieldId].ToString(), dataRow[PiOrganizeTable.FieldFullName].ToString());
            }

            if (editOrgznize.ShowDialog(this) != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }
            returnValue = editOrgznize.EntityId;
            var fullName = editOrgznize.FullName;
            var parentId = editOrgznize.ParentId;
            // tvOrganize 中增加结点
            var newNode = new TreeNode();

            newNode.Text = fullName;
            newNode.Tag  = RDIFrameworkService.Instance.OrganizeService.GetDTByIds(UserInfo, new string[] { returnValue }).Rows[0];
            TreeNode parentNode = null;

            if (!string.IsNullOrEmpty(parentId))
            {
                BasePageLogic.FindTreeNode(this.tvOrganize, parentId);
                parentNode = BasePageLogic.TargetNode;
            }
            BasePageLogic.AddTreeNode(this.tvOrganize, newNode, parentNode);
            // 绑定数据
            this.GetOrganizeList();
            this.FormLoaded = false;
            this.BindData(true);
            this.FormLoaded = true;

            if (SystemInfo.ClientCache)
            {
                ClientCache.Instance.DTOrganize = null;
            }

            // 使新增加的数据可见
            if (this.DTOrganizeList.Rows.Count > 0)
            {
                this.dgvInfo.FirstDisplayedScrollingRowIndex = this.DTOrganizeList.Rows.Count - 1;
            }
        }