/// <summary> /// 删除 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void simpleButton3_Click(object sender, EventArgs e) { var selectedNode = this.treeList1.FocusedNode; if (selectedNode == null) { DXMessage.ShowTips("请选择要删除的部门。"); return; } var department = _departmentService.GetDepartmentInfoById(int.Parse(selectedNode.GetValue(colId).ToString())); if (department != null) { // department.IsDeleted = true; var childDepts = _departmentService.GetChildDepartmentsById(department.Id); if (childDepts != null && childDepts.Count > 0) { DXMessage.ShowWarning(string.Format("部门【{0}】存在下级部门,无法删除!", department.Name)); return; } var result = DXMessage.ShowYesNoAndTips(string.Format("确定删除部门【{0}】么?", department.Name)); if (result == DialogResult.Yes) { _departmentService.DeleteDepartmentInfo(department); BindDepartment(); } } }