Exemple #1
0
        /// <summary>
        /// 获取新闻详情
        /// </summary>
        /// <returns></returns>
        private Hashtable GetDetail(HttpContext context)
        {
            Hashtable htRet   = new Hashtable();
            Hashtable rowData = new Hashtable();

            try
            {
                string sID = CConvert.ToString(context.Request["id"]);

                DBIndex dbm = new DBIndex();
                DataSet ds  = dbm.GetNewsById(sID);
                if (ds.Tables[0].Rows.Count == 0)
                {
                    htRet["ok"]  = true;
                    htRet["cnt"] = 0;
                    htRet["msg"] = "无数据!";
                }
                else
                {
                    ArrayList lst    = new ArrayList();
                    DataRow   dr     = ds.Tables[0].Rows[0];
                    Hashtable htItem = new Hashtable();

                    htItem["category"]     = CConvert.ToString(dr["category"]);
                    htItem["categoryname"] = CConvert.ToString(dr["categoryname"]);
                    htItem["title"]        = CConvert.ToString(dr["title"]);
                    htItem["author"]       = CConvert.ToString(dr["author"]);
                    htItem["time"]         = CConvert.ToString(dr["time"]);
                    htItem["content"]      = CConvert.ToString(dr["content"]);

                    //前一条
                    DataSet   ds1    = dbm.getNewsPrev(CConvert.ToString(dr["category"]), sID);
                    Hashtable htPrev = new Hashtable();
                    htPrev["url"]   = "";
                    htPrev["title"] = "";
                    if (ds1.Tables[0].Rows.Count > 0)
                    {
                        htPrev["title"] = CConvert.ToString(ds1.Tables[0].Rows[0]["title"]);
                        htPrev["id"]    = CConvert.ToString(ds1.Tables[0].Rows[0]["id"]);
                    }

                    //后一条
                    DataSet   ds2    = dbm.getNewsNext(CConvert.ToString(dr["category"]), sID);
                    Hashtable htnext = new Hashtable();
                    htnext["url"]   = "";
                    htnext["title"] = "";
                    if (ds2.Tables[0].Rows.Count > 0)
                    {
                        htnext["title"] = CConvert.ToString(ds2.Tables[0].Rows[0]["title"]);
                        htnext["id"]    = CConvert.ToString(ds2.Tables[0].Rows[0]["id"]);
                    }


                    htRet["ok"]   = true;
                    htRet["data"] = htItem;
                    htRet["prev"] = htPrev;
                    htRet["next"] = htnext;
                }
            }
            catch (Exception ex)
            {
                htRet["err"] = true;
                htRet["msg"] = "获取新闻详情失败!" + ex.Message;
            }
            return(htRet);
        }