Exemplo n.º 1
0
        /// <summary>
        /// 获得观点列表
        /// </summary>
        /// <param name="pg"></param>
        /// <returns></returns>
        public List <ViewPointExtend> GetViewPointList(Pages pg)
        {
            List <ViewPointExtend> list = new List <ViewPointExtend>();
            string sql = "proc_ViewPoint_fenye";

            SqlParameter[] para =
            {
                new SqlParameter("@pageIndex", pg.PageIndex),
                new SqlParameter("@pageSize",  pg.PagesSize),
                new SqlParameter("@ListName",  pg.types),
                new SqlParameter("@require",   pg.Tiaojian),
                new SqlParameter("@id",        pg.id)
            };
            DataSet ds = DbHelper.GetDataSetByProc(sql, para);

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                ViewPointExtend vp = new ViewPointExtend();
                vp.ID       = Convert.ToInt32(dr["ID"]);
                vp.Title    = dr["Title"].ToString();
                vp.AddTime  = Convert.ToDateTime(dr["AddTime"]);
                vp.TypeName = dr["TpName"].ToString();
                vp.Istop    = Convert.ToInt32(dr["Istop"]);
                list.Add(vp);
            }
            return(list);
        }
Exemplo n.º 2
0
        public IList <ViewPointExtend> GetViewPointList(int topN, int tid)
        {
            IList <ViewPointExtend> list = new List <ViewPointExtend>();

            string sql = "select top ( @topN ) vp.ID,vp.Title,vp.AddTime from ViewPoint vp inner join PointType pt on pt.ID = vp.TpId where pt.ID = @Tid order by vp.AddTime desc";

            SqlParameter[] paras =
            {
                new SqlParameter("@TopN", topN),
                new SqlParameter("@Tid",  tid)
            };

            using (SqlDataReader dr = SqlHelper.ExecuteReader(sql, paras, CommandType.Text))
            {
                while (dr.Read())
                {
                    ViewPointExtend vp = new ViewPointExtend();
                    vp.ID      = Convert.IsDBNull(dr["ID"]) ? 0 : Convert.ToInt32(dr["ID"]);
                    vp.Title   = Convert.IsDBNull(dr["Title"]) ? "" : dr["Title"].ToString();
                    vp.AddTime = Convert.IsDBNull(dr["AddTime"]) ? DateTime.Now : Convert.ToDateTime(dr["AddTime"]);
                    list.Add(vp);
                }
                dr.Close();
            }
            return(list);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 根据id去获取ViewPoint
        /// </summary>
        /// <param name="id">id</param>
        /// <returns></returns>
        public ViewPointExtend GetViewPointTpName(int id)
        {
            ViewPointExtend vp  = new ViewPointExtend();
            string          sql = "select b.ID, a.AddTime, Title,TypeName,tag,Article,MetaKey,MetaDesc,vtag from ViewPoint a inner join PointType b on a.TpId=b.ID where a.ID=@id";

            SqlParameter[] para =
            {
                new SqlParameter("@id", id)
            };
            DataSet ds = DbHelper.GetDataSetBySql(sql, para);

            if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                DataRow dr = ds.Tables[0].Rows[0];
                vp.Title    = dr["Title"].ToString();
                vp.TypeName = dr["TypeName"].ToString();
                vp.Tag      = dr["tag"].ToString();
                vp.Article  = dr["Article"].ToString();
                vp.AddTime  = Convert.ToDateTime(dr["AddTime"]);
                vp.ID       = Convert.ToInt32(dr["ID"]);
                vp.MetaKey  = dr["MetaKey"].ToString();
                vp.MetaDesc = dr["MetaDesc"].ToString();
                vp.vtag     = dr["vtag"].ToString();
            }
            return(vp);
        }
Exemplo n.º 4
0
        public ViewPointExtend GetViewPointExtendByID(int id)
        {
            ViewPointExtend vp = new ViewPointExtend();

            SqlParameter[] para =
            {
                new SqlParameter("@ID", id)
            };

            using (SqlDataReader dr = SqlHelper.ExecuteReader("proc_GetViewPointByID", para, CommandType.StoredProcedure))
            {
                if (dr.Read())
                {
                    vp.ID       = id;
                    vp.Article  = dr["Article"].ToString();
                    vp.TpId     = Convert.ToInt32(dr["TpId"]);
                    vp.TypeName = Convert.IsDBNull(dr["TypeName"]) ? "" : dr["TypeName"].ToString();
                    vp.AddTime  = Convert.ToDateTime(dr["AddTime"]);
                    vp.Title    = dr["Title"].ToString();
                    vp.Istop    = Convert.ToInt32(dr["Istop"]);
                }
                dr.Close();
            }
            return(vp);
        }
Exemplo n.º 5
0
        void InitNewsInfoByID()
        {
            int id = Convert.ToInt32(Request.QueryString["id"]);

            vp = vpManager.GetViewPointExtendByID(id);
            this.Page.Title = vp.Title + "-隆恩特";
        }
Exemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// ~/FirstPage/new/ndetail_id.html
        protected void btnOK_Click(object sender, EventArgs e)
        {
            ViewPointExtend point = new ViewPointExtend();

            point.Title = this.txtTitle.Value;
            string vName = this.ddlFLInfoclass.SelectedItem.Text;

            point.Article  = this.UEditor1.Value;
            point.TpId     = Convert.ToInt32(this.ddlFLInfoclass.SelectedItem.Value);
            point.TypeName = vName.Substring(0, 2);
            if (chkIsTop.Checked == true)
            {
                point.Istop = 1;
            }
            else
            {
                point.Istop = 0;
            }
            point.MetaDesc  = txt_metadesc.Text;
            point.MetaKey   = txt_metakey.Text;
            point.vtag      = txt_tag.Text;
            point.CShortDes = txt_shortdes.Text;
            if (ViewState["isNUlls"] == null)
            {
                int id = 0;
                if (vpMang.AddViewPoint(point, out id))
                {
                    point.ID = id;//id
                    //ViewPoint vpnext = new ViewPointManager().GetViewPointNext(point.ID);
                    //ViewPoint vpUp = new ViewPointManager().GetViewPointUp(point.ID);
                    //WirteFile(point,vpnext,vpUp);
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('添加成功!');window.location.href='ViewPointMsg.aspx'</script>");
                }
            }
            else
            {
                point.ID = Convert.ToInt32(ViewState["isNUlls"]);
                if (vpMang.EditViewPoint(point))
                {
                    //string path = HttpContext.Current.Server.MapPath("~/FirstPage/viewpoint/");
                    //string hurl = "vdetail_" + point.ID.ToString() + ".html";
                    //ViewPoint vpnext = new ViewPointManager().GetViewPointNext(point.ID);
                    //ViewPoint vpUp = new ViewPointManager().GetViewPointUp(point.ID);
                    //File.Delete(path + hurl);
                    //WirteFile(point,vpnext,vpUp);
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('修改成功!');</script>");
                }
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 写入页面
        /// </summary>
        public void WirteFile(ViewPointExtend news, ViewPoint NextText, ViewPoint UpText)
        {
            string       path = HttpContext.Current.Server.MapPath("~/FirstPage/viewpoint/");
            Encoding     code = Encoding.GetEncoding("gb2312");
            string       temp = HttpContext.Current.Server.MapPath("viewdetail.html");
            StreamReader sr   = null;
            StreamWriter sw   = null;
            string       str  = "";

            try
            {
                sr  = new StreamReader(temp, code);
                str = sr.ReadToEnd();
            }
            catch (Exception ex)
            {
                HttpContext.Current.Response.Write(ex.Message);
                HttpContext.Current.Response.End();
                sr.Close();
            }
            string NextStr = "<span>下一篇:&nbsp;<a href='vdetail_" + NextText.ID + ".html'>" + NextText.Title + "</a></span>";
            string UpStr   = "<span>下一篇:&nbsp;<a href='vdetail_" + UpText.ID + ".html'>" + UpText.Title + "</a></span>";

            str = str.Replace("[title]", news.Title)
                  .Replace("[Content]", news.Article)
                  .Replace("[TypeName]", news.TypeName)
                  .Replace("[UpText]", UpStr)
                  .Replace("[NextText]", NextStr);

            string hurl = "vdetail_" + news.ID.ToString() + ".html";

            try
            {
                sw = new StreamWriter(path + hurl, false, code);
                sw.Write(str);
                sw.Flush();
            }
            catch (Exception ex)
            {
                HttpContext.Current.Response.Write(ex.Message);
                HttpContext.Current.Response.End();
                throw;
            }
            finally
            {
                sw.Close();
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 推荐观点6条(按时间排序)
        /// </summary>
        /// <returns></returns>
        public List <ViewPointExtend> GetViewPointList()
        {
            List <ViewPointExtend> list = new List <ViewPointExtend>();
            string  sql = "select top 4 a.ID,Title,TypeName from ViewPoint a inner join PointType b on a.TpId=b.ID";
            DataSet ds  = DbHelper.GetDataSetBySql(sql);

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                ViewPointExtend vpe = new ViewPointExtend();
                vpe.ID       = Convert.ToInt32(dr["ID"]);
                vpe.Title    = dr["Title"].ToString();
                vpe.TypeName = dr["TypeName"].ToString();
                list.Add(vpe);
            }
            return(list);
        }