コード例 #1
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if (this.LastControl == dgvInfo)
            {
                var returnValue = 0;
                if (this.CheckInputBatchDelete() &&
                    MessageBoxHelper.Show(RDIFrameworkMessage.MSG0015) == System.Windows.Forms.DialogResult.Yes)
                {
                    if (!SystemInfo.ClientCache)
                    {
                        ClientCache.Instance.DTOrganize = null;
                    }

                    this.FormLoaded = false;
                    // 绑定数据
                    var tags = BasePageLogic.GetSelecteIds(this.dgvInfo, PiOrganizeTable.FieldId, "colSelected", true);
                    returnValue = organizationService.SetDeleted(UserInfo, tags);
                    if (SystemInfo.ClientCache)
                    {
                        ClientCache.Instance.DTOrganize = null;
                    }
                    // 获取列表
                    this.DTOrganize = organizationService.GetDT(UserInfo);
                    // 在tree删除相应的节点
                    BasePageLogic.BatchRemoveNode(this.tvOrganize, tags);
                    // 绑定grdModule
                    this.GetOrganizeList();
                    this.FormLoaded = true;
                }
            }
            else
            {
                var returnValue = 0;
                if (this.tvOrganize.SelectedNode == null)
                {
                    returnValue = 0;
                    return;
                }
                // 设置鼠标繁忙状态,并保留原先的状态
                var holdCursor = this.Cursor;
                this.Cursor     = Cursors.WaitCursor;
                this.FormLoaded = false;
                try
                {
                    if (!BasePageLogic.NodeAllowDelete(this.tvOrganize.SelectedNode))
                    {
                        MessageBoxHelper.ShowWarningMsg(string.Format(RDIFrameworkMessage.MSG0035, BasePageLogic.TargetNode.Text));
                    }
                    else
                    {
                        if (MessageBoxHelper.Show(RDIFrameworkMessage.MSG0015) != System.Windows.Forms.DialogResult.Yes)
                        {
                            return;
                        }
                        returnValue = organizationService.SetDeleted(UserInfo, new String[] { this.ParentEntityId });
                        if (SystemInfo.ClientCache)
                        {
                            ClientCache.Instance.DTOrganize = null;
                        }
                        if (returnValue <= 0)
                        {
                            return;
                        }
                        string[] tags = { ((DataRow)this.tvOrganize.SelectedNode.Tag)[PiOrganizeTable.FieldId].ToString() };
                        BasePageLogic.BatchRemoveNode(this.tvOrganize, tags);
                        // 绑定grdOrganize
                        this.GetOrganizeList();
                    }
                }
                catch (Exception ex)
                {
                    this.ProcessException(ex);
                }
                finally
                {
                    // 设置鼠标默认状态,原来的光标状态
                    this.FormLoaded = true;
                    this.Cursor     = holdCursor;
                }
            }
        }