protected void btnDelete_ServerClick(object sender, System.EventArgs e) { string unitCode = Request["UnitCode"] + ""; try { bool canDelete = true; // EntityData role = DAL.EntityDAO.SystemManageDAO.GetOBSRoleByUnitCode(unitCode); // if ( role.HasRecord() ) // canDelete = false; // role.Dispose(); EntityData childDepartment = DAL.EntityDAO.OBSDAO.GetOBSUnitByParent(unitCode); if (childDepartment.HasRecord()) { canDelete = false; } childDepartment.Dispose(); if (!canDelete) { Rms.Web.JavaScript.Alert(true, "这个部门下面设定有子部门和角色,不可删除 !"); return; } EntityData ds = OBSDAO.GetUnitByCode(unitCode); OBSDAO.DeleteUnit(ds); ds.Dispose(); CloseWindow(true); } catch (Exception ex) { ApplicationLog.WriteLog(this.ToString(), ex, ""); Response.Write(Rms.Web.JavaScript.Alert(true, "删除出错")); } }