public static void MoveSystemGroup(string srcGroupCode, string dstGroupCode, string dstClassCode) { try { if (srcGroupCode == "") { throw new Exception("未传入源结点号"); } if (dstClassCode == "") { throw new Exception("未传入大类代码"); } EntityData systemGroupByCode = SystemManageDAO.GetSystemGroupByCode(srcGroupCode); if (!systemGroupByCode.HasRecord()) { throw new Exception("源结点不存在"); } DataRow currentRow = systemGroupByCode.CurrentRow; string text = ConvertRule.ToString(currentRow["FullID"]); string text2 = ConvertRule.ToString(currentRow["ClassCode"]); string text3 = ConvertRule.ToString(currentRow["ParentCode"]); if (text2 != dstClassCode) { throw new Exception("只能在同一大类下移动"); } DataRow row2 = null; if (dstGroupCode.Length > 0) { EntityData data2 = SystemManageDAO.GetSystemGroupByCode(dstGroupCode); if (data2.HasRecord()) { row2 = data2.CurrentRow; } data2.Dispose(); } if (srcGroupCode == dstGroupCode) { throw new Exception("无法移动:源结点和目标结点相同"); } if (text3 == dstGroupCode) { throw new Exception("无法移动:目标文件夹和源文件夹相同"); } if ((row2 != null) && (ConvertRule.ToString(row2["FullID"]).IndexOf(text) == 0)) { throw new Exception("无法移动:目标文件夹是源文件夹的子文件"); } EntityData entity = SystemManageDAO.GetSystemGroupIncludeAllChildByParentFullID(text); DataTable currentTable = entity.CurrentTable; DataView view = new DataView(currentTable, "", "deep", DataViewRowState.CurrentRows); foreach (DataRow row3 in currentTable.Rows) { string text5 = ConvertRule.ToString(row3["GroupCode"]); int num = ConvertRule.ToInt(row3["Deep"]); string text6 = ConvertRule.ToString(row3["ParentCode"]); DataRow drParent = null; if (text5 == srcGroupCode) { drParent = row2; } else { DataRow[] rowArray = currentTable.Select("GroupCode='" + text6 + "'"); if (rowArray.Length > 0) { drParent = rowArray[0]; } else { drParent = currentTable.Select("GroupCode='" + srcGroupCode + "'")[0]; } } SetSystemGroupParent(row3, drParent); } SystemManageDAO.SubmitAllSystemGroup(entity); entity.Dispose(); systemGroupByCode.Dispose(); } catch (Exception exception) { throw exception; } }
public static string CheckDeleteSystemGroup(string GroupCode) { string text13; try { string text = ""; EntityData systemGroupByCode = SystemManageDAO.GetSystemGroupByCode(GroupCode); if (systemGroupByCode.HasRecord()) { string classCode = systemGroupByCode.GetString("ClassCode"); string parentFullID = systemGroupByCode.GetString("FullID"); string itemInfoByClassCode = SystemClassDescription.GetItemInfoByClassCode(classCode); if (itemInfoByClassCode != "") { EntityData systemGroupIncludeAllChildByParentFullID = SystemManageDAO.GetSystemGroupIncludeAllChildByParentFullID(parentFullID); string text5 = ""; foreach (DataRow row in systemGroupIncludeAllChildByParentFullID.CurrentTable.Rows) { string text6 = row["GroupCode"].ToString(); if (text5 != "") { text5 = text5 + ","; } text5 = text5 + "'" + text6 + "'"; } string[] textArray = itemInfoByClassCode.Split(",".ToCharArray()); foreach (string text7 in textArray) { if (text7 != "") { string[] textArray2 = text7.Split("|".ToCharArray()); string text8 = textArray2[0]; string text9 = textArray2[1]; string queryString = string.Format("select top 1 {1} from {0} where {1} in ({2})", text8, text9, text5); QueryAgent agent = new QueryAgent(); try { try { string code = ConvertRule.ToString(agent.ExecuteScalar(queryString)); if (code != "") { EntityData data3 = SystemManageDAO.GetSystemGroupByCode(code); string text12 = data3.GetString("SortID") + " " + data3.GetString("GroupName"); data3.Dispose(); return(string.Format("表 {0} 中已存在类别为 {1} 的记录,不能删除该类别", text8, text12)); } } catch { } } finally { agent.Dispose(); } } } } } systemGroupByCode.Dispose(); text13 = text; } catch (Exception exception) { throw exception; } return(text13); }
public static void DeleteSystemGroup(string GroupCode) { Exception exception; try { if (GroupCode != "") { string message = CheckDeleteSystemGroup(GroupCode); if (message != "") { throw new Exception(message); } EntityData systemGroupByCode = SystemManageDAO.GetSystemGroupByCode(GroupCode); if (systemGroupByCode.HasRecord()) { string keyvalues; string parentFullID = systemGroupByCode.GetString("FullID"); DataTable table = new DataTable(); table.Columns.Add("AccessRangeCode"); EntityData systemGroupIncludeAllChildByParentFullID = SystemManageDAO.GetSystemGroupIncludeAllChildByParentFullID(parentFullID); foreach (DataRow row in systemGroupIncludeAllChildByParentFullID.CurrentTable.Rows) { EntityData accessRangeByGroupCode = ResourceDAO.GetAccessRangeByGroupCode(row["GroupCode"].ToString()); foreach (DataRow row2 in accessRangeByGroupCode.CurrentTable.Rows) { keyvalues = row2["AccessRangeCode"].ToString(); DataRow row3 = table.NewRow(); row3["AccessRangeCode"] = keyvalues; table.Rows.Add(row3); } accessRangeByGroupCode.Dispose(); } using (StandardEntityDAO ydao = new StandardEntityDAO("SystemGroup")) { ydao.BeginTrans(); try { foreach (DataRow row3 in table.Rows) { keyvalues = row3["AccessRangeCode"].ToString(); ydao.EntityName = "AccessRange"; EntityData entitydata = new EntityData("AccessRange"); entitydata = ydao.SelectbyPrimaryKey(keyvalues); ydao.DeleteAllRow(entitydata); ydao.DeleteEntity(entitydata); entitydata.Dispose(); } foreach (DataRow row3 in systemGroupIncludeAllChildByParentFullID.CurrentTable.Rows) { string text3 = row3["GroupCode"].ToString(); ydao.EntityName = "SystemGroup"; EntityData data5 = new EntityData("SystemGroup"); data5 = ydao.SelectbyPrimaryKey(text3); ydao.DeleteAllRow(data5); ydao.DeleteEntity(data5); data5.Dispose(); } ydao.CommitTrans(); } catch (Exception exception1) { exception = exception1; try { ydao.RollBackTrans(); } catch { } throw exception; } } systemGroupIncludeAllChildByParentFullID.Dispose(); } systemGroupByCode.Dispose(); } } catch (Exception exception2) { exception = exception2; throw exception; } }