Exemplo n.º 1
0
 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;
     }
 }
Exemplo n.º 2
0
 public static void CopySystemGroup(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 drSrc        = systemGroupByCode.CurrentRow;
         string  parentFullID = ConvertRule.ToString(drSrc["FullID"]);
         DataRow drDst        = null;
         if (dstGroupCode.Length > 0)
         {
             EntityData data2 = SystemManageDAO.GetSystemGroupByCode(dstGroupCode);
             if (data2.HasRecord())
             {
                 drDst = data2.CurrentRow;
             }
             data2.Dispose();
         }
         EntityData entity = new EntityData("SystemGroup");
         DataTable  tb     = entity.CurrentTable;
         DataRow    row3   = CopySystemGroupNewRow(tb, drSrc, drDst, dstClassCode);
         EntityData systemGroupAllChildByParentFullID = SystemManageDAO.GetSystemGroupAllChildByParentFullID(parentFullID);
         systemGroupAllChildByParentFullID.CurrentTable.Columns.Add("DstGroupCode");
         DataView view = new DataView(systemGroupAllChildByParentFullID.CurrentTable, "", "deep", DataViewRowState.CurrentRows);
         foreach (DataRowView view2 in view)
         {
             DataRow   row      = view2.Row;
             string    text2    = row["ParentCode"].ToString();
             DataRow[] rowArray = systemGroupAllChildByParentFullID.CurrentTable.Select("GroupCode='" + text2 + "'");
             DataRow   row5     = null;
             if (rowArray.Length > 0)
             {
                 string text3 = ConvertRule.ToString(rowArray[0]["DstGroupCode"]);
                 row5 = tb.Select("GroupCode='" + text3 + "'")[0];
             }
             else
             {
                 row5 = row3;
             }
             DataRow row6 = CopySystemGroupNewRow(tb, row, row5, dstClassCode);
             row["DstGroupCode"] = row6["GroupCode"];
         }
         systemGroupAllChildByParentFullID.Dispose();
         SystemManageDAO.SubmitAllSystemGroup(entity);
         entity.Dispose();
         systemGroupByCode.Dispose();
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }