Example #1
0
        public static DataRow CopySystemGroupNewRow(DataTable tb, DataRow drSrc, DataRow drDst, string dstClassCode)
        {
            DataRow row3;

            try
            {
                string text  = "";
                int    num   = 0;
                string text2 = "";
                if (drDst != null)
                {
                    text  = ConvertRule.ToString(drDst["GroupCode"]);
                    num   = ConvertRule.ToInt(drDst["Deep"]);
                    text2 = ConvertRule.ToString(drDst["FullID"]);
                }
                DataRow row       = tb.NewRow();
                int     num2      = num + 1;
                string  groupCode = SystemManageDAO.GetNewSysCode("SystemGroupCode");
                string  text4     = text2;
                if (text4.Length > 0)
                {
                    text4 = text4 + "-" + groupCode;
                }
                else
                {
                    text4 = groupCode;
                }
                row["GroupCode"]  = groupCode;
                row["GroupName"]  = drSrc["GroupName"];
                row["SortID"]     = drSrc["SortID"];
                row["ClassCode"]  = dstClassCode;
                row["deep"]       = num2;
                row["FullID"]     = text4;
                row["ParentCode"] = text;
                tb.Rows.Add(row);
                EntityData entity = ResourceDAO.GetAccessRangeByGroupCode(drSrc[0].ToString());
                DataTable  table  = entity.Tables["AccessRange"];
                for (int i = table.Rows.Count - 1; i >= 0; i--)
                {
                    DataRow row2 = table.Rows[i];
                    AccessRangeNewRow(table, row2["AccessRangeType"].ToString(), row2["RelationCode"].ToString(), row2["OperationCode"].ToString(), groupCode, row2["RoleLevel"].ToString(), row2["ResourceCode"].ToString());
                }
                ResourceDAO.SubmitAllAccessRange(entity);
                row3 = row;
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return(row3);
        }
Example #2
0
        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;
            }
        }