public IList<Core.Business.RelativeGroup> GetAllRelativeGroup()
        {
            IList<Core.Business.RelativeGroup> relativeGrouplist = new List<Core.Business.RelativeGroup>();
            SqlServerUtility sql = new SqlServerUtility(SqlConnection);

            SqlDataReader reader = sql.ExecuteSPReader("USP_RelativeGroup_SelectAll");

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.RelativeGroup relativeGroup = new Core.Business.RelativeGroup();

                    if (!reader.IsDBNull(0)) relativeGroup.Id = reader.GetGuid(0);
                    if (!reader.IsDBNull(1)) relativeGroup.GroupId = reader.GetInt32(1);
                    if (!reader.IsDBNull(2)) relativeGroup.RelativeGroupId = reader.GetInt32(2);
                    if (!reader.IsDBNull(3)) relativeGroup.DateCreated = reader.GetDateTime(3);
                    if (!reader.IsDBNull(4)) relativeGroup.IsChecked = reader.GetBoolean(4);
                    if (!reader.IsDBNull(5)) relativeGroup.Remark = reader.GetString(5);

                    relativeGroup.MarkOld();
                    relativeGrouplist.Add(relativeGroup);
                }
                reader.Close();
            }
            return relativeGrouplist;
        }
        public IList<CY.UME.Core.Business.RelativeGroup> GetRelativeGroups(int groupId, int relativeGroupId, bool isChecked, CY.UME.Core.PagingInfo pageInfo)
        {
            IList<Core.Business.RelativeGroup> relativeGrouplist = new List<Core.Business.RelativeGroup>();

            SqlServerUtility sql = new SqlServerUtility(SqlConnection);

            #region 参数
            string tables = "RelativeGroup";
            string pK = "Id";
            string sort = "DateCreated Desc";
            int pageNum = pageInfo.CurrentPage;
            int pageSize = pageInfo.PageSize;
            string fields = "[Id], [GroupId],[RelativeGroupId],[DateCreated],[IsChecked],[Remark]";
            string filter = "1=1 ";
            if (groupId != 0)
            {
                filter += " and GroupId=" + groupId;
            }
            if (relativeGroupId != 0)
            {
                filter += " and RelativeGroupId=" + relativeGroupId;
            }

            filter += " and IsChecked=" + (isChecked ? 1 : 0);
            string group = String.Empty;
            #endregion
            sql.AddParameter("@Tables", SqlDbType.VarChar, tables);
            sql.AddParameter("@PK", SqlDbType.VarChar, pK);
            sql.AddParameter("@Sort", SqlDbType.VarChar, sort);
            sql.AddParameter("@PageNumber", SqlDbType.Int, pageNum);
            sql.AddParameter("@PageSize", SqlDbType.Int, pageSize);
            sql.AddParameter("@Fields", SqlDbType.VarChar, fields);
            sql.AddParameter("@Filter", SqlDbType.VarChar, filter);
            sql.AddParameter("@Group", SqlDbType.VarChar, group);
            SqlDataReader reader = sql.ExecuteSPReader("Paging_RowCount");

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.RelativeGroup relativeGroup = new Core.Business.RelativeGroup();

                    if (!reader.IsDBNull(0)) relativeGroup.Id = reader.GetGuid(0);
                    if (!reader.IsDBNull(1)) relativeGroup.GroupId = reader.GetInt32(1);
                    if (!reader.IsDBNull(2)) relativeGroup.RelativeGroupId = reader.GetInt32(2);
                    if (!reader.IsDBNull(3)) relativeGroup.DateCreated = reader.GetDateTime(3);
                    if (!reader.IsDBNull(4)) relativeGroup.IsChecked = reader.GetBoolean(4);
                    if (!reader.IsDBNull(5)) relativeGroup.Remark = reader.GetString(5);

                    relativeGroup.MarkOld();
                    relativeGrouplist.Add(relativeGroup);
                }
                reader.Close();
            }
            return relativeGrouplist;
        }
        public Core.Business.RelativeGroup Select(Guid id)
        {
            SqlServerUtility sql = new SqlServerUtility(SqlConnection);

            sql.AddParameter("@Id", SqlDbType.UniqueIdentifier, id);
            SqlDataReader reader = sql.ExecuteSPReader("USP_RelativeGroup_Select_By_Id");

            if (reader != null && !reader.IsClosed && reader.Read())
            {
                Core.Business.RelativeGroup relativeGroup = new Core.Business.RelativeGroup();

                if (!reader.IsDBNull(0)) relativeGroup.Id = reader.GetGuid(0);
                if (!reader.IsDBNull(1)) relativeGroup.GroupId = reader.GetInt32(1);
                if (!reader.IsDBNull(2)) relativeGroup.RelativeGroupId = reader.GetInt32(2);
                if (!reader.IsDBNull(3)) relativeGroup.DateCreated = reader.GetDateTime(3);
                if (!reader.IsDBNull(4)) relativeGroup.IsChecked = reader.GetBoolean(4);
                if (!reader.IsDBNull(5)) relativeGroup.Remark = reader.GetString(5);

                reader.Close();
                return relativeGroup;
            }
            else
            {
                if (reader != null && !reader.IsClosed)
                    reader.Close();

                return null;
            }
        }
        public CY.UME.Core.Business.RelativeGroup Load(CY.UME.Core.Business.Group group, CY.UME.Core.Business.Group rg)
        {
            if (group == null || rg == null)
            {
                return null;
            }

            SqlServerUtility sql = new SqlServerUtility(SqlConnection);

            sql.AddParameter("@GroupId", SqlDbType.Int, group.Id);
            sql.AddParameter("@RelativeGroupId", SqlDbType.Int, rg.Id);

            SqlDataReader reader = sql.ExecuteSPReader("USP_RelativeGroup_Select_By_GroupId_And_RelativeGroupId");

            if (reader != null && !reader.IsClosed && reader.Read())
            {
                Core.Business.RelativeGroup relativeGroup = new Core.Business.RelativeGroup();

                if (!reader.IsDBNull(0)) relativeGroup.Id = reader.GetGuid(0);
                if (!reader.IsDBNull(1)) relativeGroup.GroupId = reader.GetInt32(1);
                if (!reader.IsDBNull(2)) relativeGroup.RelativeGroupId = reader.GetInt32(2);
                if (!reader.IsDBNull(3)) relativeGroup.DateCreated = reader.GetDateTime(3);
                if (!reader.IsDBNull(4)) relativeGroup.IsChecked = reader.GetBoolean(4);
                if (!reader.IsDBNull(5)) relativeGroup.Remark = reader.GetString(5);

                reader.Close();
                return relativeGroup;
            }
            else
            {
                if (reader != null && !reader.IsClosed)
                    reader.Close();

                return null;
            }
        }