Exemple #1
0
        //根据地区种类得到领养宠物的信息
        public List <CVAdoptPet> GetAdoptPetListByAddressCategory(bool IsAdopt, string AddressID, string PetCategoryID, int pageNumber, int NumberPerPage, out int howmanyPages)
        {
            List <CVAdoptPet> AdoptPetList = new List <CVAdoptPet>();

            SqlParameter[] adoptPetParams = null;
            adoptPetParams = new SqlParameter[]
            {
                new SqlParameter("@IsAdopt", SqlDbType.Bit),
                new SqlParameter("@AddressID", SqlDbType.NVarChar, 20),
                new SqlParameter("@PetCategoryID", SqlDbType.NVarChar, 36),
                new SqlParameter("@DescriptionLength", SqlDbType.Int),
                new SqlParameter("@PageNumber", SqlDbType.Int),
                new SqlParameter("@AdoptInfoPerPage", SqlDbType.Int),
                new SqlParameter("@HowManyAdoptInfo", SqlDbType.Int, 65535, ParameterDirection.Output, true, 0, 0, "", DataRowVersion.Default, 0),
            };
            adoptPetParams[0].Value = IsAdopt;
            adoptPetParams[1].Value = AddressID;
            adoptPetParams[2].Value = PetCategoryID;
            adoptPetParams[3].Value = CPetCareConfiguration.ArticleBreviaryNum;
            adoptPetParams[4].Value = pageNumber;
            adoptPetParams[5].Value = NumberPerPage;

            try
            {
                using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.StoredProcedure, "proSearchAllAdoptInfo", adoptPetParams))
                {
                    while (reader.Read())
                    {
                        CVAdoptPet adoptPet = new CVAdoptPet();
                        adoptPet.AdoptID         = reader["AdoptID"].ToString();
                        adoptPet.City            = reader["City"].ToString();
                        adoptPet.Province        = reader["Province"].ToString();
                        adoptPet.AdoptInfo       = reader["AdoptInfo"].ToString();
                        adoptPet.AdoptTitle      = reader["AdoptTitle"].ToString();
                        adoptPet.PetCategoryName = reader["PetCategoryName"].ToString();
                        adoptPet.PriorityScore   = int.Parse(reader["PriorityScore"].ToString());
                        adoptPet.UserName        = reader["UserName"].ToString();
                        adoptPet.PicLocation     = reader["PicLocation"].ToString();
                        adoptPet.Portrait        = reader["Portrait"].ToString();
                        adoptPet.LinkUrl         = reader["LinkUrl"].ToString();
                        adoptPet.UserWeiBo       = reader["UserWeiBo"].ToString();
                        adoptPet.Status          = reader["Status"].ToString();
                        bool tempIsAdopt = true;
                        adoptPet.IsAdopt = bool.TryParse(reader["IsAdopt"].ToString(), out tempIsAdopt) ? tempIsAdopt : true;
                        bool tempIsRecommand = true;
                        adoptPet.IsRecommand = bool.TryParse(reader["IsRecommand"].ToString(), out tempIsRecommand) ? tempIsRecommand : true;
                        bool tempIsEssence = true;
                        adoptPet.IsEssence = bool.TryParse(reader["IsEssence"].ToString(), out tempIsEssence) ? tempIsEssence : true;

                        DateTime tempLastEditTime = DateTime.Now;
                        tempLastEditTime      = DateTime.TryParse(reader["LastEditTime"].ToString(), out tempLastEditTime) ? tempLastEditTime : DateTime.Now;
                        adoptPet.LastEditTime = tempLastEditTime.ToString("yyyy/MM/dd hh:mm:ss");

                        DateTime tempAdoptTime = DateTime.Now;
                        tempAdoptTime      = DateTime.TryParse(reader["AdoptTime"].ToString(), out tempAdoptTime) ? tempAdoptTime : DateTime.Now;
                        adoptPet.AdoptTime = tempAdoptTime.ToString("yyyy/MM/dd hh:mm:ss");


                        adoptPet.IP = reader["IP"].ToString();
                        int tempFocusNum = 0;
                        adoptPet.FocusNum = int.TryParse(reader["FocusNum"].ToString(), out tempFocusNum) ? tempFocusNum : 0;
                        int tempCommentCount = 0;
                        adoptPet.CommentCount = int.TryParse(reader["CommentCount"].ToString(), out tempCommentCount) ? tempCommentCount : 0;

                        AdoptPetList.Add(adoptPet);
                    }
                }
            }
            catch (Exception ex)
            {
            }
            howmanyPages = 1;
            return(AdoptPetList);
        }
Exemple #2
0
        //获取所有的领养宠物的文章列表,返回信息列表,分页的方式
        public List <CVAdoptPet> GetAllAdoptPetListPerPage(int pageNumber, int NumberPerPage, out int howmanyPages)
        {
            SqlParameter[] adoptPetParams = null;
            adoptPetParams    = new SqlParameter[5];
            adoptPetParams[0] = new SqlParameter("@IsAdopt", SqlDbType.Bit);
            adoptPetParams[1] = new SqlParameter("@DescriptionLength", SqlDbType.Int);
            adoptPetParams[2] = new SqlParameter("@PageNumber", SqlDbType.Int);
            adoptPetParams[3] = new SqlParameter("@AdoptInfoPerPage", SqlDbType.Int);

            adoptPetParams[0].Value = true;
            adoptPetParams[1].Value = CPetCareConfiguration.ArticleBreviaryNum;
            adoptPetParams[2].Value = pageNumber;
            adoptPetParams[3].Value = NumberPerPage;

            SqlParameter parameter = new SqlParameter();

            parameter.DbType        = DbType.Int16;
            parameter.Direction     = ParameterDirection.Output;
            parameter.ParameterName = "@HowManyAdoptInfo";
            adoptPetParams[4]       = parameter;


            List <CVAdoptPet> AdoptPetList = new List <CVAdoptPet>();

            try
            {
                using (SqlDataReader reader = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringLocalTransaction, CommandType.StoredProcedure, "proGetAdoptInfo", adoptPetParams))
                {
                    while (reader.Read())
                    {
                        CVAdoptPet adoptPet = new CVAdoptPet();
                        adoptPet.AdoptID         = reader["AdoptID"].ToString();
                        adoptPet.City            = reader["City"].ToString();
                        adoptPet.Province        = reader["Province"].ToString();
                        adoptPet.AdoptInfo       = reader["AdoptInfo"].ToString();
                        adoptPet.AdoptTitle      = reader["AdoptTitle"].ToString();
                        adoptPet.PetCategoryName = reader["PetCategoryName"].ToString();
                        adoptPet.PriorityScore   = int.Parse(reader["PriorityScore"].ToString());
                        adoptPet.UserName        = reader["UserName"].ToString();
                        adoptPet.PicLocation     = reader["PicLocation"].ToString();
                        adoptPet.Portrait        = reader["Portrait"].ToString();
                        adoptPet.LinkUrl         = reader["LinkUrl"].ToString();
                        adoptPet.UserWeiBo       = reader["UserWeiBo"].ToString();
                        adoptPet.Status          = reader["Status"].ToString();
                        bool tempIsAdopt = true;
                        adoptPet.IsAdopt = bool.TryParse(reader["IsAdopt"].ToString(), out tempIsAdopt) ? tempIsAdopt : true;
                        bool tempIsRecommand = true;
                        adoptPet.IsRecommand = bool.TryParse(reader["IsRecommand"].ToString(), out tempIsRecommand) ? tempIsRecommand : true;
                        bool tempIsEssence = true;
                        adoptPet.IsEssence = bool.TryParse(reader["IsEssence"].ToString(), out tempIsEssence) ? tempIsEssence : true;

                        DateTime tempLastEditTime = DateTime.Now;
                        tempLastEditTime      = DateTime.TryParse(reader["LastEditTime"].ToString(), out tempLastEditTime) ? tempLastEditTime : DateTime.Now;
                        adoptPet.LastEditTime = tempLastEditTime.ToString("yyyy/MM/dd hh:mm:ss");

                        DateTime tempAdoptTime = DateTime.Now;
                        tempAdoptTime      = DateTime.TryParse(reader["AdoptTime"].ToString(), out tempAdoptTime) ? tempAdoptTime : DateTime.Now;
                        adoptPet.AdoptTime = tempAdoptTime.ToString("yyyy/MM/dd hh:mm:ss");

                        adoptPet.IP = reader["IP"].ToString();
                        int tempFocusNum = 0;
                        adoptPet.FocusNum = int.TryParse(reader["FocusNum"].ToString(), out tempFocusNum) ? tempFocusNum : 0;
                        int tempCommentCount = 0;
                        adoptPet.CommentCount = int.TryParse(reader["CommentCount"].ToString(), out tempCommentCount) ? tempCommentCount : 0;
                        AdoptPetList.Add(adoptPet);
                    }
                    reader.Close();
                    reader.Dispose();
                    int tempHowmanyPages = 0;
                    howmanyPages = int.TryParse(adoptPetParams[4].Value.ToString(), out tempHowmanyPages) ? tempHowmanyPages : 0;
                }
            }
            catch (Exception ex)
            {
                throw;
            }



            return(AdoptPetList);
        }