예제 #1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //下载于www.51aspx.com
        Model.News mn = new Model.News();
        BLL.News   bn = new BLL.News();
        mn.ID = Convert.ToInt32(Request.QueryString["uid"]);
        SqlDataReader sdr = bn.datareader(mn);

        if (sdr.Read())
        {
            Label1.Text = sdr["_origin"].ToString();
            Label2.Text = sdr["_news_author"].ToString();
            Label3.Text = sdr["_post_time"].ToString();
            Label4.Text = sdr["_news_content"].ToString();
            Label5.Text = sdr["_news_title"].ToString();
            Page.Title  = Label5.Text + "新闻";
            int sum = Convert.ToInt32(sdr["_hits"]);
            sdr.Close();
            sum = sum + 1;
            string str    = "update news set _hits=" + sum + " where _id=" + mn.ID + "";
            int    result = DB.ExecuteSql(str);
            if (result > 0)
            {
                Label6.Text = sum.ToString();
                //Label6.Text = dr["_click"].ToString();
            }
        }
        repeat();

        //下载于www.51aspx.com
    }
예제 #2
0
    protected void Button3_Click(object sender, EventArgs e)
    {
        Model.News mn = new Model.News();
        BLL.News bn = new BLL.News();
        int result = 0;
        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            CheckBox cb = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");
            if (cb.Checked)
            {
                mn.ID = Convert.ToInt32(GridView1.DataKeys[i].Value);
                Response.Write(mn.ID);
                result = bn._delete(mn);
            }
        }

        if (result > 0)
        {
            Response.Write("<script>alert('删除成功'),location.href='newslist.aspx'</script>");
        }
        else
        {
            Response.Write("<script>alert('删除失败'),location.href='newslist.aspx'</script>");
        }
    }
예제 #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public static int Add(Model.News model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into News(");
            strSql.Append("title,pageName,newsType,newImg,newsContent,keyword,newsDesc,linkurl,is_tj,is_hot,ordernum,addTime,add_userid,res_views,areaid,sid,releaseTime,author)");
            strSql.Append(" values (");
            strSql.Append("@title,@pageName,@newsType,@newImg,@newsContent,@keyword,@newsDesc,@linkurl,@is_tj,@is_hot,@ordernum,@addTime,@add_userid,@res_views,@areaid,@sid,@releaseTime,@author)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@title",       SqlDbType.VarChar,   200),
                new SqlParameter("@pageName",    SqlDbType.NText),
                new SqlParameter("@newsType",    SqlDbType.Int,         4),
                new SqlParameter("@newImg",      SqlDbType.VarChar,   500),
                new SqlParameter("@newsContent", SqlDbType.NText),
                new SqlParameter("@keyword",     SqlDbType.VarChar,   250),
                new SqlParameter("@newsDesc",    SqlDbType.NText),
                new SqlParameter("@linkurl",     SqlDbType.VarChar,   250),
                new SqlParameter("@is_tj",       SqlDbType.Int,         1),
                new SqlParameter("@is_hot",      SqlDbType.Int,         4),
                new SqlParameter("@ordernum",    SqlDbType.Int,         4),
                new SqlParameter("@addTime",     SqlDbType.DateTime),
                new SqlParameter("@add_userid",  SqlDbType.Int,         4),
                new SqlParameter("@res_views",   SqlDbType.Int,         4),
                new SqlParameter("@areaid",      SqlDbType.Int,         4),
                new SqlParameter("@sid",         SqlDbType.VarChar,   500),
                new SqlParameter("@releaseTime", SqlDbType.DateTime),
                new SqlParameter("@author",      SqlDbType.VarChar, 50)
            };
            parameters[0].Value  = model.title;
            parameters[1].Value  = model.pageName;
            parameters[2].Value  = model.newsType;
            parameters[3].Value  = model.newImg;
            parameters[4].Value  = model.newsContent;
            parameters[5].Value  = model.keyword;
            parameters[6].Value  = model.newsDesc;
            parameters[7].Value  = model.linkurl;
            parameters[8].Value  = model.is_tj;
            parameters[9].Value  = model.is_hot;
            parameters[10].Value = model.ordernum;
            parameters[11].Value = model.addTime;
            parameters[12].Value = model.add_userid;
            parameters[13].Value = model.res_views;
            parameters[14].Value = model.areaid;
            parameters[15].Value = model.sid;
            parameters[16].Value = model.releaseTime;
            parameters[17].Value = model.author;

            object obj = DBHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
예제 #4
0
        public ActionResult EditCase(string id, HttpPostedFileBase image, FormCollection collection)
        {
            string fileName = "";
            try {

                if (image != null && image.ContentLength > 0) {
                    fileName = DateTime.Now.ToString("yyyyMMdd") + "-" + Path.GetFileName(image.FileName);
                    string filePath = Path.Combine(Server.MapPath("~/Images"), fileName);
                    image.SaveAs(filePath);
                }
            }
            catch {
                return View();
            }

            News news = new News();
            TryUpdateModel(news);
            news.NewsType = NewsType.案例;
            news.PicUrl = Path.Combine("../Images", fileName);
            if (!String.IsNullOrEmpty(id)) {
                news.LastModifyTime = DateTime.Now;
                newsService.Edit<News>(news);
            }
            else {
                news._id = new ObjectId();
                news.CreateTime = DateTime.Now;
                news.LastModifyTime = DateTime.Now;
                newsService.Add<News>(news);
            }

            return RedirectToAction("Index");
        }
예제 #5
0
        /// <summary>
        /// 得到一个对象实体,资讯详细页上一篇
        /// </summary>
        public static Model.News GetLastModel(News item)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 title,linkurl from News ");
            strSql.Append(" where id<@id and newsType=@newsType order by id desc");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4), new SqlParameter("@newsType", SqlDbType.Int, 4)
            };
            parameters[0].Value = item.id;
            parameters[1].Value = item.newsType;
            Model.News model = new Model.News();
            DataSet    ds    = DBHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                model.title   = ds.Tables[0].Rows[0]["title"].ToString();
                model.linkurl = ds.Tables[0].Rows[0]["linkurl"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
예제 #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Model.News mn = new Model.News();
        BLL.News bn = new BLL.News();
        mn.ID = Convert.ToInt32(Request.QueryString["uid"]);
        MySqlDataReader sdr = bn.datareader(mn);
        if (sdr.Read())
        {
            Label1.Text = sdr["_from"].ToString();
            Label2.Text = sdr["_author"].ToString();
            Label3.Text = sdr["_posttime"].ToString();
            Label4.Text = sdr["_content"].ToString();
            Label5.Text = sdr["_title"].ToString();
            Page.Title = Label5.Text + "新闻";
            int sum = Convert.ToInt32(sdr["_click"]);
            sdr.Close();
            sum = sum + 1;
            string str = "update news set _click=" + sum + " where _id=" + mn.ID + "";
            int result = DB.ExecuteSql(str);
            if (result > 0)
            {
                Label6.Text = sum.ToString();
                //Label6.Text = dr["_click"].ToString();
            }

        }
        repeat();
    }
예제 #7
0
    protected void Button3_Click(object sender, EventArgs e)
    {
        Model.News mn     = new Model.News();
        BLL.News   bn     = new BLL.News();
        int        result = 0;

        for (int i = 0; i < GridView1.Rows.Count; i++)
        {
            CheckBox cb = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1");
            if (cb.Checked)
            {
                mn.ID = Convert.ToInt32(GridView1.DataKeys[i].Value);
                Response.Write(mn.ID);
                result = bn._delete(mn);
            }
        }

        if (result > 0)
        {
            Response.Write("<script>alert('删除成功'),location.href='newslist.aspx'</script>");
        }
        else
        {
            Response.Write("<script>alert('删除失败'),location.href='newslist.aspx'</script>");
        }
    }
예제 #8
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            Model.News u = new Model.News
            {
                News_Title   = this.txtTitle.Text.Trim(),
                News_Image   = upFileName(this.FileUpload1, "../../upload/News/"),
                News_Intro   = this.textIntro.Text.Trim(),
                News_Content = this.txtContent.Text,
            };
            var       res = NewsSvc.Add(u);
            ReturnMsg rm  = res > 0
                ? new ReturnMsg()
            {
                Code    = StatusCode.OK,
                Message = "新增用户信息成功",
                Data    = null
            }
                : new ReturnMsg()
            {
                Code    = StatusCode.Error,
                Message = "新增用户信息失败",
                Data    = null
            };

            Session["Msg"] = rm; //用于传递执行信息的
            Response.Redirect("News_List.aspx");
        }
예제 #9
0
        public ActionResult Details(string id)
        {
            //var result = newsService.GetByID<News>(id);
            //return View(result);

            News result = new News() { _id = new ObjectId("55913a0fb0345113a41d2058"), Title = "测试标题", Contant = "测试内容", CreateTime = DateTime.Now, KeyWord = "测试关键字,测试关键字" };
            return View(result);
        }
예제 #10
0
 public ActionResult EditCase(string id)
 {
     News news = new News();
     if (!String.IsNullOrEmpty(id)) {
         news = newsService.GetByID<News>(id);
     }
     else {
     }
     return View(news);
 }
예제 #11
0
        // POST api/news
        public IHttpActionResult Post(News news)
        {

            if (ModelState.IsValid && !string.IsNullOrWhiteSpace(news.Title))
            {
                
                this.data.News.Add(news);
                this.data.SaveChanges();

                return this.CreatedAtRoute("DefaultApi", new { id = news.Id}, news);
                // return this.Created(Request.RequestUri + news.Id.ToString(CultureInfo.InvariantCulture), news);
            }

            return this.BadRequest();
        }
예제 #12
0
파일: News.cs 프로젝트: FineLqy/CQ
        /// <summary>
        /// 添加一条新闻到数据库中
        /// </summary>
        /// <returns></returns>
        public static bool Add(Model.News news)
        {
            string       strSql = "insert into News(Title,Time,Author,Pageview,Details) values(@Title,@Time,@Author,@Pageview,@Details)";
            SqlParameter Title  = new SqlParameter("@Title", SqlDbType.NVarChar, 500); Title.Value = news.Title;
            SqlParameter Time   = new SqlParameter("@Time", SqlDbType.DateTime);

            Time.Value = news.Time;
            SqlParameter Author   = new SqlParameter("@Author", SqlDbType.NVarChar, 50); Author.Value = news.Author;
            SqlParameter Pageview = new SqlParameter("@Pageview", SqlDbType.Int);

            Pageview.Value = news.Pageview;
            SqlParameter Details = new SqlParameter("@Details", SqlDbType.NVarChar);

            Details.Value = news.Details;
            return(DBHelperSQL.GetNums(strSql, new SqlParameter[] { Title, Time, Author, Pageview, Details }, connectionString) == 1 ? true : false);
        }
예제 #13
0
        /// <summary>
        /// 前台新闻列表
        /// </summary>
        public ActionResult CaseList()
        {
            //string keyWord = Request["keyWord"];
            //if (String.IsNullOrEmpty(keyWord)) {
            //    var result = newsService.GetList<News>().Where(o => o.NewsType == NewsType.案例);
            //    return View(result);
            //}
            //else {
            //    var result = newsService.GetListByKeyWord(keyWord);
            //    return View(result);
            //}

            List<News> result = new List<News>();
            News a = new News() { _id = new ObjectId("55913a0fb0345113a41d2058"), Title = "测试标题", Contant = "测试内容", CreateTime = DateTime.Now };
            result.Add(a);
            return View(result);
        }
예제 #14
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            string photo = upFileName(this.FileUpload1, "../../upload/users/");

            Model.News p = NewsSvc.GetNewsById(Guid.Parse(this.hfId.Value));
            if (photo == "")
            {
                p = new Model.News
                {
                    News_Title      = this.txtName.Text,
                    News_Intro      = this.textIntro.Text,
                    News_Content    = this.txtContent.Text,
                    News_UpdateTime = DateTime.Now
                };
            }
            else
            {
                p = new Model.News
                {
                    News_Title      = this.txtName.Text,
                    News_Intro      = this.textIntro.Text,
                    News_Content    = this.txtContent.Text,
                    News_Image      = photo,
                    News_UpdateTime = DateTime.Now
                };
            }

            var       res = NewsSvc.Edit(p);
            ReturnMsg rm  = res > 0
                ? new ReturnMsg()
            {
                Code    = StatusCode.OK,
                Message = "编辑用户信息成功",
                Data    = null
            }
                : new ReturnMsg()
            {
                Code    = StatusCode.Error,
                Message = "编辑用户信息失败",
                Data    = null
            };

            Session["Msg"] = rm; //用于传递执行信息的
            Response.Redirect("News_List.aspx");
        }
예제 #15
0
        // PUT api/news/{id}
        public IHttpActionResult Put(News news)
        {
            if (news != null && news.Id > 0)
            {
                var entity = this.data.News.Find(news.Id);
                if (entity != null && entity.Id == news.Id)
                {
                    entity.Title = news.Title;
                    entity.Content = news.Content;
                    entity.PublishDate = news.PublishDate;
                    this.data.News.Update(entity);
                    this.data.SaveChanges();

                    return Content(HttpStatusCode.Accepted, entity);
                }
            }

            return this.BadRequest();
        }
예제 #16
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public static int Update(Model.News model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update News set ");
            strSql.Append("title=@title,");
            strSql.Append("newsType=@newsType,");
            strSql.Append("newImg=@newImg,");
            strSql.Append("newsContent=@newsContent,");

            strSql.Append("keyword=@keyword,");
            strSql.Append("newsDesc=@newsDesc,");
            strSql.Append("pageName=@pageName,");
            strSql.Append("sid=@sid,author=@author");
            strSql.Append(" where id=@id ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@id",          SqlDbType.Int,       4),
                new SqlParameter("@title",       SqlDbType.VarChar, 200),
                new SqlParameter("@newsType",    SqlDbType.Int,       4),
                new SqlParameter("@newImg",      SqlDbType.VarChar, 500),
                new SqlParameter("@newsContent", SqlDbType.NText),

                new SqlParameter("@keyword",     SqlDbType.VarChar, 250),
                new SqlParameter("@newsDesc",    SqlDbType.NText),
                new SqlParameter("@pageName",    SqlDbType.NText),
                new SqlParameter("@sid",         SqlDbType.VarChar, 250),new SqlParameter("@author",SqlDbType.VarChar, 50)
            };
            parameters[0].Value = model.id;
            parameters[1].Value = model.title;
            parameters[2].Value = model.newsType;
            parameters[3].Value = model.newImg;
            parameters[4].Value = model.newsContent;

            parameters[5].Value = model.keyword;
            parameters[6].Value = model.newsDesc;
            parameters[7].Value = model.pageName;
            parameters[8].Value = model.sid;
            parameters[9].Value = model.author;
            return(DBHelperSQL.ExecuteSql(strSql.ToString(), parameters));
        }
예제 #17
0
파일: News.cs 프로젝트: FineLqy/CQ
        /// <summary>
        /// 得到一个实体对象
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public static Model.News GetModel(int ID)
        {
            string strSql = "select * from News where ID = " + ID.ToString();

            Model.News model = new Model.News();
            DataSet    ds    = DBHelperSQL.GetDataSet(strSql, connectionString);

            model.ID = ID;
            if (ds.Tables[0].Rows.Count > 0)
            {
                model.Title   = Convert.ToString(ds.Tables[0].Rows[0]["Title"]);
                model.Author  = Convert.ToString(ds.Tables[0].Rows[0]["Author"]);
                model.Time    = (DateTime)ds.Tables[0].Rows[0]["Time"];
                model.Details = Convert.ToString(ds.Tables[0].Rows[0]["Details"]);
                return(model);
            }
            else
            {
                return(null);
            }
        }
예제 #18
0
    public void BinData()
    {
        Model.News news       = new Model.News();
        NewsSystem newsSystem = new NewsSystem();

        news = newsSystem.Get_SintNews(nID);
        if (news.ID == nID)
        {
            ClassName.Text  = "&gt;" + news.NewClass.ClassName;
            Title_1.Text    = "&gt;" + news.Title;
            Title_2.Text    = news.Title;
            Updatatime.Text = news.Updatatime.ToString();
            Author.Text     = news.Author;
            Source.Text     = news.Source;
            Content.Text    = news.Content;
        }
        else
        {
            Response.Write("<script>alert('数据不存在');history.back(1);</script>");
            Response.End();
        }
    }
예제 #19
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         _source.Text = "秋哈网";
         datablind();
         Model.News mn = new Model.News();
         mn.ID = Convert.ToInt32(Request.QueryString["uid"]);
         BLL.News bn = new BLL.News();
         MySqlDataReader sdr = bn.datareader(mn);
         if (sdr.Read())
         {
             _title.Text = sdr["_title"].ToString();
             _source.Text=sdr["_from"].ToString();
             author.Text = sdr["_author"].ToString();
             DropDownList1.SelectedValue = sdr["_top"].ToString();
             DropDownList2.SelectedValue = sdr["_cateid"].ToString();
             DropDownList3.SelectedValue = sdr["_ispic"].ToString();
             FCKeditor1.Value = sdr["_content"].ToString();
         }
         sdr.Close();
     }
 }
예제 #20
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         _source.Text = "秋哈网";
         datablind();
         Model.News mn = new Model.News();
         mn.ID = Convert.ToInt32(Request.QueryString["uid"]);
         BLL.News      bn  = new BLL.News();
         SqlDataReader sdr = bn.datareader(mn);
         if (sdr.Read())
         {
             _title.Text  = sdr["_news_title"].ToString();
             _source.Text = sdr["_origin"].ToString();
             author.Text  = sdr["_news_author"].ToString();
             DropDownList1.SelectedValue = sdr["_top_state"].ToString();
             DropDownList2.SelectedValue = sdr["_news_cateid"].ToString();
             DropDownList3.SelectedValue = sdr["_pic_state"].ToString();
             FCKeditor1.Value            = sdr["_news_content"].ToString();
         }
         sdr.Close();
     }
 }
예제 #21
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     Model.News mn = new Model.News();
     BLL.News bn = new BLL.News();
     mn.Title = _title.Text;
     mn.From = _source.Text;
     mn.Author = author.Text;
     mn.Content = FCKeditor1.Value;
     mn.Top = Convert.ToInt32( DropDownList1.SelectedValue);
     mn.Ispic = Convert.ToInt32(DropDownList2.SelectedValue);
     mn.Cateid = Convert.ToInt32(DropDownList3.SelectedValue);
     int result = bn.add(mn);
     //Response.Write(_title.Text);
     //Response.Write(author.Text);
     if (result > 0)
     {
         Response.Write("<script>alert('添加成功'),location.href='newsadd.aspx'</script>");
     }
     else
     {
         Response.Write("<script>alert('添加失败'),location.href='newsadd.aspx'</script>");
     }
 }
예제 #22
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        Model.News mn = new Model.News();
        mn.ID = Convert.ToInt32(Request.QueryString["uid"]);

        mn.Title   = _title.Text;
        mn.From    = _source.Text;
        mn.Author  = author.Text;
        mn.Content = FCKeditor1.Value;
        mn.Top     = Convert.ToInt32(DropDownList1.SelectedValue);
        mn.Ispic   = Convert.ToInt32(DropDownList2.SelectedValue);
        mn.Cateid  = Convert.ToInt32(DropDownList3.SelectedValue);
        BLL.News bn     = new BLL.News();
        int      result = bn.update(mn);

        if (result > 0)
        {
            Response.Write("<script>alert('添加成功'),location.href='newslist.aspx'</script>");
        }
        else
        {
            Response.Write("<script>alert('添加失败'),location.href=''newslist.aspx'</script>");
        }
    }
예제 #23
0
        public ActionResult EditNotice(string id, string cl, FormCollection collection)
        {
            News news = new News();
            TryUpdateModel(news);
            news.NewsType = NewsType.招投标信息;
            news.Contant = cl;

            if (!String.IsNullOrEmpty(id)) {
                news.LastModifyTime = DateTime.Now;
                newsService.Edit<News>(news);
            }
            else {
                news._id = new ObjectId();
                news.CreateTime = DateTime.Now;
                news.LastModifyTime = DateTime.Now;
                newsService.Add<News>(news);
            }

            return RedirectToAction("Index");
        }
예제 #24
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public static Model.News GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,title,pageName,newsType,newImg,newsContent,keyword,newsDesc,linkurl,is_tj,is_hot,ordernum,addTime,add_userid,res_views,areaid,sid,releaseTime,author from News ");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            Model.News model = new Model.News();
            DataSet    ds    = DBHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                model.title    = ds.Tables[0].Rows[0]["title"].ToString();
                model.pageName = ds.Tables[0].Rows[0]["pageName"].ToString();
                if (ds.Tables[0].Rows[0]["newsType"].ToString() != "")
                {
                    model.newsType = int.Parse(ds.Tables[0].Rows[0]["newsType"].ToString());
                }
                model.newImg      = ds.Tables[0].Rows[0]["newImg"].ToString();
                model.newsContent = ds.Tables[0].Rows[0]["newsContent"].ToString();
                model.keyword     = ds.Tables[0].Rows[0]["keyword"].ToString();
                model.newsDesc    = ds.Tables[0].Rows[0]["newsDesc"].ToString();
                model.linkurl     = ds.Tables[0].Rows[0]["linkurl"].ToString();
                if (ds.Tables[0].Rows[0]["is_tj"].ToString() != "")
                {
                    model.is_tj = Convert.ToInt32(ds.Tables[0].Rows[0]["is_tj"].ToString());
                }
                if (ds.Tables[0].Rows[0]["is_hot"].ToString() != "")
                {
                    model.is_hot = Convert.ToInt32(ds.Tables[0].Rows[0]["is_hot"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ordernum"].ToString() != "")
                {
                    model.ordernum = int.Parse(ds.Tables[0].Rows[0]["ordernum"].ToString());
                }
                if (ds.Tables[0].Rows[0]["addTime"].ToString() != "")
                {
                    model.addTime = DateTime.Parse(ds.Tables[0].Rows[0]["addTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["add_userid"].ToString() != "")
                {
                    model.add_userid = int.Parse(ds.Tables[0].Rows[0]["add_userid"].ToString());
                }
                if (ds.Tables[0].Rows[0]["res_views"].ToString() != "")
                {
                    model.res_views = int.Parse(ds.Tables[0].Rows[0]["res_views"].ToString());
                }
                if (ds.Tables[0].Rows[0]["areaid"].ToString() != "")
                {
                    model.areaid = int.Parse(ds.Tables[0].Rows[0]["areaid"].ToString());
                }
                model.sid = ds.Tables[0].Rows[0]["sid"].ToString();
                if (ds.Tables[0].Rows[0]["releaseTime"].ToString() != "")
                {
                    model.releaseTime = DateTime.Parse(ds.Tables[0].Rows[0]["releaseTime"].ToString());
                }
                model.author = ds.Tables[0].Rows[0]["author"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
예제 #25
0
        /// <summary>
        /// 前台新闻列表
        /// </summary>
        public ActionResult NewsList()
        {
            //var result = newsService.GetList<News>().Where(o => o.NewsType == NewsType.新闻);
            //return View(result);

            List<News> result = new List<News>();
            News a = new News() { _id = new ObjectId("55913a0fb0345113a41d2058"), Title = "测试标题", Contant = "测试内容", CreateTime = DateTime.Now };
            result.Add(a);
            return View(result);
        }
예제 #26
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public static Model.News GetModel_ZhuanTi()
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 * from News ");
            strSql.Append(" where newImg <> '' and newsType = 3 order by id desc");
            Model.News model = new Model.News();
            DataSet    ds    = DBHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                model.title    = ds.Tables[0].Rows[0]["title"].ToString();
                model.pageName = ds.Tables[0].Rows[0]["pageName"].ToString();
                if (ds.Tables[0].Rows[0]["newsType"].ToString() != "")
                {
                    model.newsType = int.Parse(ds.Tables[0].Rows[0]["newsType"].ToString());
                }
                model.newImg      = ds.Tables[0].Rows[0]["newImg"].ToString();
                model.newsContent = ds.Tables[0].Rows[0]["newsContent"].ToString();
                model.keyword     = ds.Tables[0].Rows[0]["keyword"].ToString();
                model.newsDesc    = ds.Tables[0].Rows[0]["newsDesc"].ToString();
                model.linkurl     = ds.Tables[0].Rows[0]["linkurl"].ToString();
                if (ds.Tables[0].Rows[0]["is_tj"].ToString() != "")
                {
                    model.is_tj = Convert.ToInt32(ds.Tables[0].Rows[0]["is_tj"].ToString());
                }
                if (ds.Tables[0].Rows[0]["is_hot"].ToString() != "")
                {
                    model.is_hot = Convert.ToInt32(ds.Tables[0].Rows[0]["is_hot"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ordernum"].ToString() != "")
                {
                    model.ordernum = int.Parse(ds.Tables[0].Rows[0]["ordernum"].ToString());
                }
                if (ds.Tables[0].Rows[0]["addTime"].ToString() != "")
                {
                    model.addTime = DateTime.Parse(ds.Tables[0].Rows[0]["addTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["add_userid"].ToString() != "")
                {
                    model.add_userid = int.Parse(ds.Tables[0].Rows[0]["add_userid"].ToString());
                }
                if (ds.Tables[0].Rows[0]["res_views"].ToString() != "")
                {
                    model.res_views = int.Parse(ds.Tables[0].Rows[0]["res_views"].ToString());
                }
                if (ds.Tables[0].Rows[0]["areaid"].ToString() != "")
                {
                    model.areaid = int.Parse(ds.Tables[0].Rows[0]["areaid"].ToString());
                }
                model.sid = ds.Tables[0].Rows[0]["sid"].ToString();
                if (ds.Tables[0].Rows[0]["releaseTime"].ToString() != "")
                {
                    model.releaseTime = DateTime.Parse(ds.Tables[0].Rows[0]["releaseTime"].ToString());
                }
                model.author = ds.Tables[0].Rows[0]["author"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
예제 #27
0
        public ActionResult NewsList(string keyWord)
        {
            //var result = newsService.GetListByKeyWord(keyWord);
            //return View(result);

            List<News> result = new List<News>();
            News a = new News() { _id = new ObjectId("55913a0fb0345113a41d2058"), Title = "测试标题", Contant = "测试内容", CreateTime = DateTime.Now };
            result.Add(a);
            return View(result);
        }
예제 #28
0
        /// <summary>
        /// 首页常见问答    得到一个对象实体
        /// </summary>
        public static Model.News GetModel(int id, int typeId)
        {
            string sql = "";

            if (typeId == 1)     //图片问答
            {
                if (id == 1)     //第一条
                {
                    sql = "select top 1 id,title,linkurl,newImg,pageName from news where newsType = 4 and newImg <> '' and is_tj = 1 and is_hot = 1 order by releaseTime desc";
                }
                else if (id == 2)
                {
                    sql = "select top 1 id,title,linkurl,newImg,pageName from news where newsType = 4 and newImg <> '' and is_tj = 1 and is_hot = 1 and id not in (select top 1 id from news where newsType = 4 and newImg <> '' and is_tj = 1 and is_hot = 1 order by releaseTime desc) order by releaseTime desc";
                }
                else if (id == 8)
                {
                    sql = "select top 1 id,title,linkurl,newImg,pageName from news where newsType = 4 and newImg <> '' and is_tj = 1 and is_hot = 1 and id not in (select top 2 id from news where newsType = 4 and newImg <> '' and is_tj = 1 and is_hot = 1 order by releaseTime desc) order by releaseTime desc";
                }
                else if (id == 9)
                {
                    sql = "select top 1 id,title,linkurl,newImg,pageName from news where newsType = 4 and newImg <> '' and is_tj = 1 and is_hot = 1 and id not in (select top 2 id from news where newsType = 4 and newImg <> '' and is_tj = 1 and is_hot = 1 order by releaseTime desc) order by releaseTime desc";
                }
            }
            else
            {
                if (id == 3)
                {
                    sql = "select top 1 id,title,linkurl,newImg,pageName from news where newsType = 4 and newImg = '' order by id desc";
                }
                else if (id == 4)
                {
                    sql = "select top 1 id,title,linkurl,newImg,pageName from news where newsType = 4 and newImg = '' and id not in (select top 1 id from news where newsType = 4 and newImg = '' order by id desc) order by id desc";
                }
                else if (id == 5)
                {
                    sql = "select top 1 id,title,linkurl,newImg,pageName from news where newsType = 4 and newImg = '' and id not in (select top 2 id from news where newsType = 4 and newImg = '' order by id desc) order by id desc";
                }
                else if (id == 6)
                {
                    sql = "select top 1 id,title,linkurl,newImg,pageName from news where newsType = 4 and newImg = '' and id not in (select top 3 id from news where newsType = 4 and newImg = '' order by id desc) order by id desc";
                }
                else if (id == 7)
                {
                    sql = "select top 1 id,title,linkurl,newImg,pageName from news where newsType = 4 and newImg = '' and id not in (select top 4 id from news where newsType = 4 and newImg = '' order by id desc) order by id desc";
                }
                else if (id == 10)
                {
                    sql = "select top 1 id,title,linkurl,newImg,pageName from news where newsType = 4 and newImg = '' and id not in (select top 5 id from news where newsType = 4 and newImg = '' order by id desc) order by id desc";
                }
            }
            DataSet ds = DBHelperSQL.Query(sql);

            Model.News model = new Model.News();

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                model.title    = ds.Tables[0].Rows[0]["title"].ToString();
                model.pageName = ds.Tables[0].Rows[0]["pageName"].ToString();

                model.newImg = ds.Tables[0].Rows[0]["newImg"].ToString();

                model.linkurl = ds.Tables[0].Rows[0]["linkurl"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
예제 #29
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     Model.News news = new Model.News();
     if (txtTitle.Text == "")
     {
         MessageBox.Alert("标题不能为空!", Page);
         txtTitle.Focus();
     }
     else
     {
         if (dropType.SelectedItem.Text == "--请选择新闻类型--")
         {
             MessageBox.Alert("请选择新闻类型!", Page);
             dropType.Focus();
         }
         else
         {
             news.NewsTypeId = Convert.ToInt32(dropType.SelectedValue);
             if (txtTimer.Value == "")
             {
                 news.CreateTime = DateTime.Now.ToString("yyyy-MM-dd");
             }
             else
             {
                 news.CreateTime = txtTimer.Value;
             }
             if (hfImgUrl.Value == "")
             {
                 news.ImgUrl = txtImgUrl.Text.Trim();
             }
             else
             {
                 news.ImgUrl = hfImgUrl.Value;
             }
             news.Title     = txtTitle.Text;
             news.Intro     = fck_intro.Value;
             news.Details   = fck_detail.Value;
             news.IsShow    = Convert.ToInt32(chkShow.Checked);
             news.IsTop     = Convert.ToInt32(chkTop.Checked);
             news.IndexShow = Convert.ToInt32(chkIndex.Checked);
             if (hfId.Value == "" || hfId.Value == null)
             {
                 try
                 {
                     NewsBll.AddNews(news);
                     MessageBox.AlertAndRedirect("添加成功!", "News.aspx", Page);
                 }
                 catch (Exception)
                 {
                     MessageBox.Alert("添加失败!", Page);
                     /*throw;*/
                 }
             }
             else
             {
                 news.NewsId = Convert.ToInt32(hfId.Value);
                 try
                 {
                     NewsBll.UpdateNews(news);
                     MessageBox.AlertAndRedirect("修改成功!", "News.aspx", Page);
                 }
                 catch (Exception)
                 {
                     MessageBox.Alert("修改失败!", Page);
                     /*throw;*/
                 }
             }
         }
     }
 }