コード例 #1
0
ファイル: CollegeProvider.cs プロジェクト: dalinhuang/ume-v3
        public IList<Core.Business.College> GetCollegeByUniIdAndName(int uniId, string name)
        {
            IList<Core.Business.College> collegelist = new List<Core.Business.College>();
            SqlServerUtility sql = new SqlServerUtility(SqlConnectionString);
            sql.AddParameter("@UniversityId", SqlDbType.Int, uniId);
            sql.AddParameter("@Name", SqlDbType.Int, name);
            SqlDataReader reader = sql.ExecuteSPReader("USP_College_Select_By_UniId_And_Name");

            if (reader != null)
            {
                while (reader.Read())
                {
                    Core.Business.College college = new Core.Business.College();

                    if (!reader.IsDBNull(0)) college.Id = reader.GetInt32(0);
                    if (!reader.IsDBNull(1)) college.UniversityID = reader.GetInt32(1);
                    if (!reader.IsDBNull(2)) college.DateCreated = reader.GetDateTime(2);
                    if (!reader.IsDBNull(3)) college.Name = reader.GetString(3);
                    if (!reader.IsDBNull(4)) college.Des = reader.GetString(4);

                    college.MarkOld();
                    collegelist.Add(college);
                }
                reader.Close();
            }
            return collegelist;
        }
コード例 #2
0
ファイル: CollegeProvider.cs プロジェクト: dalinhuang/ume-v3
        public IList<Core.Business.College> GetTopCollegeByUniIdAndName(int uniId, string name, Core.PagingInfo pageInfo)
        {
            IList<Core.Business.College> collegelist = new List<Core.Business.College>();
            SqlServerUtility sql = new SqlServerUtility(SqlConnectionString);

            #region ����
            string tables = "College";
            string pK = "Id";
            string sort = "Id DESC";
            int pageNum = pageInfo.CurrentPage;
            int pageSize = pageInfo.PageSize;
            string fields = "[ID], [UniversityID],[DateCreated],[Name],[Des]";
            string filter = "1=1";
            StringBuilder strFilter = new StringBuilder();
            if (uniId != 0)
            {
                strFilter.Append(" and [UniversityID] =" + uniId.ToString());
            }
            if (name.Length != 0)
            {
                strFilter.Append(" AND [Name] like '%" + name + "%'");
            }
            filter += strFilter.ToString();
            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.College college = new Core.Business.College();

                    if (!reader.IsDBNull(0)) college.Id = reader.GetInt32(0);
                    if (!reader.IsDBNull(1)) college.UniversityID = reader.GetInt32(1);
                    if (!reader.IsDBNull(2)) college.DateCreated = reader.GetDateTime(2);
                    if (!reader.IsDBNull(3)) college.Name = reader.GetString(3);
                    if (!reader.IsDBNull(4)) college.Des = reader.GetString(4);

                    college.MarkOld();
                    collegelist.Add(college);
                }
                reader.Close();
            }
            return collegelist;
        }