Exemplo n.º 1
0
        public List <NsyNews> GetNsyNewList(Pages pg)
        {
            List <NsyNews> list = new List <NsyNews>();
            string         sql  = "proc_NsyNews_fenye";

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

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                NsyNews news = new NsyNews();
                news.ID       = Convert.ToInt32(dr["ID"]);
                news.Title    = dr["Title"].ToString();
                news.Contents = dr["Contents"].ToString();
                news.AddTime  = Convert.ToDateTime(dr["AddTime"]);
                list.Add(news);
            }
            return(list);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// ~/FirstPage/new/ndetail_id.html
        protected void btnOK_Click(object sender, EventArgs e)
        {
            NsyNews news = new NsyNews();

            news.Title    = this.txtTitle.Value;
            news.Contents = this.UEditor1.Value;
            news.AddTime  = DateTime.Now;
            int id = 0;

            if (ViewState["isNUlls"] == null)
            {
                if (newMang.AddNsyNews(news, out id))
                {
                    news.ID = id;
                    WirteFile(news);
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('添加成功!');window.location.href='NewMsg.aspx'</script>");
                }
            }
            else
            {
                news.ID = Convert.ToInt32(ViewState["isNUlls"]);
                if (newMang.EditNsyNews(news))
                {
                    string path = HttpContext.Current.Server.MapPath("~/FirstPage/new/");
                    string hurl = "ndetail_" + news.ID.ToString() + ".html";
                    File.Delete(path + hurl);
                    WirteFile(news);
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script language='javascript'>alert('修改成功!');</script>");
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 加载信息
        /// </summary>
        private void LoadInfo(int d)
        {
            NsyNews fir = newMang.GetNsyNews(d);

            if (fir != null)
            {
                ViewState["isNUlls"] = d;
                this.txtTitle.Value  = fir.Title;
                this.UEditor1.Value  = fir.Contents;
                this.txAddTime.Text  = fir.AddTime.ToString("yyyy-MM-dd");
            }
        }
Exemplo n.º 4
0
        public bool EditNsyNews(NsyNews news)
        {
            string sql = "proc_Edit_NsyNews";

            SqlParameter[] para =
            {
                new SqlParameter("@title",    news.Title),
                new SqlParameter("@contents", news.Contents),
                new  SqlParameter("@id",      news.ID)
            };
            if (DbHelper.ExecuteCommandByProc(sql, para) > 0)
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 前台分页显示新闻列表
        /// </summary>
        /// <param name="fldNamet"></param>
        /// <param name="PageSize"></param>
        /// <param name="PageCurren"></param>
        /// <param name="fldSort"></param>
        /// <param name="Sort"></param>
        /// <param name="strWhere"></param>
        /// <param name="pageCount"></param>
        /// <param name="Counts"></param>
        /// <returns></returns>
        public List <NsyNews> GetNsyNewListById(string fldNamet, int PageSize, int PageCurren, string fldSort, string Sort, string strWhere, out int pageCount, out int Counts)
        {
            Counts = 0;
            SqlParameter outPageCount = new SqlParameter("@pageCount", 4);

            outPageCount.Direction = ParameterDirection.Output;
            SqlParameter outCounts = new SqlParameter("@Counts", 4);

            outCounts.Direction = ParameterDirection.Output;
            SqlParameter[] para =
            {
                new SqlParameter("@tblName",  "NsyNews"),
                new SqlParameter("@fldName",  fldNamet),
                new SqlParameter("@pageSize", PageSize),
                new SqlParameter("@page",     PageCurren),
                new SqlParameter("@fldSort",  fldSort),
                new SqlParameter("@Sort",     Sort),
                new SqlParameter("@strWhere", strWhere),

                new SqlParameter("@ID",       "ID"),
                new SqlParameter("@Dist",              0),
                //new SqlParameter("@pageCount",4),
                outPageCount,
                outCounts
                //new SqlParameter("@Counts",4)
            };
            List <NsyNews> list = new List <NsyNews>();

            using (SqlDataReader dr = DbHelper.ExecuteReader("Proc_ListPage", para, CommandType.StoredProcedure))
            {
                while (dr.Read())
                {
                    NsyNews vp = new NsyNews();
                    vp.ID      = Convert.ToInt32(dr["ID"]);
                    vp.Title   = dr["Title"].ToString();
                    vp.AddTime = Convert.ToDateTime(dr["AddTime"]);
                    list.Add(vp);
                }
                dr.Close();
            }
            pageCount = Convert.ToInt32(outPageCount.Value);
            Counts    = Convert.ToInt32(outCounts.Value);
            return(list);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 写入页面
        /// </summary>
        public void WirteFile(NsyNews news)
        {
            string       path = HttpContext.Current.Server.MapPath("~/FirstPage/new/");
            Encoding     code = Encoding.GetEncoding("gb2312");
            string       temp = HttpContext.Current.Server.MapPath("newdlt.htm");
            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();
            }
            str = str.Replace("[title]", news.Title)
                  .Replace("[time]", news.AddTime.ToString("yyyy-MM-dd"))
                  .Replace("[content]", news.Contents);
            string hurl = "ndetail_" + 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.º 7
0
        /// <summary>
        /// 获取一个
        /// </summary>
        /// <param name="d"></param>
        /// <returns></returns>
        public NsyNews GetNsyNews(int d)
        {
            NsyNews news = new NsyNews();
            string  sql  = "select * from NsyNews where ID=@id";

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

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                news.ID       = Convert.ToInt32(dr["ID"]);
                news.Title    = dr["Title"].ToString();
                news.Contents = dr["Contents"].ToString();
                news.AddTime  = Convert.ToDateTime(dr["AddTime"]);
            }
            return(news);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="news"></param>
        /// <returns></returns>
        public bool AddNsyNews(NsyNews news, out int id)
        {
            string       sql    = "proc_Add_NsyNews";
            SqlParameter thisID = new SqlParameter("@thisID", 0);

            thisID.Direction = ParameterDirection.Output;
            SqlParameter[] para =
            {
                new SqlParameter("@title",    news.Title),
                new SqlParameter("@contents", news.Contents),
                thisID
            };
            id = 0;
            if (DbHelper.ExecuteCommandByProc(sql, para) > 0)
            {
                id = Convert.ToInt32(thisID.Value);
                return(true);
            }
            return(false);
        }
Exemplo n.º 9
0
 /// <summary>
 /// 修改
 /// </summary>
 /// <param name="news"></param>
 public bool EditNsyNews(NsyNews news)
 {
     return(NewSv.EditNsyNews(news));
 }
Exemplo n.º 10
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="news"></param>
 public bool AddNsyNews(NsyNews news, out int id)
 {
     return(NewSv.AddNsyNews(news, out id));
 }