Exemplo n.º 1
0
 private void AddNews()
 {
     R_News r = new R_News();
     r.News_Tital = NewsTitle.Text.Trim();
     r.Sort_ID = Convert.ToInt32(News_Sort.SelectedValue);
     r.News_Content = NewsContent.Value;
     r.User_ID = Convert.ToInt32(Request.Cookies["user"]["ID"]);
     r.News_Reading = reading.Checked == true ? 1 : 0;
     r.News_ImageBool = imageCheck.Checked == true ? 1 : 0;
     r.News_Images = imageCheck.Checked == true ? Img_Url.Value.Trim() : "";
     B_News b = new B_News();
     if (b.addNews(r))
     {
         NewsTitle.Text = "";
         Img_Url.Value = "";
         News_Sort.SelectedIndex = 0;
         NewsContent.Value = "";
         ll_ts.Text = "添加成功!";
         //Response.Redirect("Default.aspx");
     }
     else
     {
         ll_ts.Text = "添加失败!";
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 添加新文章
 /// </summary>
 /// <param name="u">实例</param>
 /// <returns>受影响行数</returns>
 public int addNews(R_News u)
 {
     Database db = DatabaseFactory.CreateDatabase();
     DbCommand cmd = db.GetSqlStringCommand(@"insert into R_News
         ( Sort_ID,News_Tital,News_Content,User_ID, News_AddTime, News_Images,News_Count, News_Reading, News_ImageBool)
                                             values
      (@Sort_ID,@News_Tital,@News_Content,@User_ID, @News_AddTime, @News_Images,@News_Count, @News_Reading, @News_ImageBool)
     ");
     db.AddInParameter(cmd, "@Sort_ID", DbType.Int32, u.Sort_ID);
     db.AddInParameter(cmd, "@News_Tital", DbType.String, u.News_Tital);
     db.AddInParameter(cmd, "@News_Content", DbType.String, u.News_Content);
     db.AddInParameter(cmd, "@User_ID", DbType.Int32, u.User_ID);
     db.AddInParameter(cmd, "@News_AddTime", DbType.String, DateTime.Now.ToString());
     db.AddInParameter(cmd, "@News_Images", DbType.String, u.News_Images);
     db.AddInParameter(cmd, "@News_Count", DbType.Int32, 0);
     db.AddInParameter(cmd, "@News_Reading", DbType.String, u.News_Reading);
     db.AddInParameter(cmd, "@News_ImageBool", DbType.String, u.News_ImageBool);
     return db.ExecuteNonQuery(cmd);
 }
Exemplo n.º 3
0
 /// <summary>
 /// 修改文章
 /// </summary>
 /// <param name="u">实例</param>
 /// <returns>受影响行数</returns>
 public int editNews(R_News u)
 {
     Database db = DatabaseFactory.CreateDatabase();
     DbCommand cmd = db.GetSqlStringCommand(@"UPDATE  R_News
                                             SET
     Sort_ID=@Sort_ID,News_Tital=@News_Tital,News_Content=@News_Content,User_ID=@User_ID,
     News_EditTime=@News_EditTime,News_Images=@News_Images,
     News_Reading=@News_Reading, News_ImageBool=@News_ImageBool
                                             WHERE   (ID = @ID)");
     db.AddInParameter(cmd, "@Sort_ID", DbType.Int32, u.Sort_ID);
     db.AddInParameter(cmd, "@News_Tital", DbType.String, u.News_Tital);
     db.AddInParameter(cmd, "@News_Content", DbType.String, u.News_Content);
     db.AddInParameter(cmd, "@User_ID", DbType.Int32, u.User_ID);
     db.AddInParameter(cmd, "@News_EditTime", DbType.String, DateTime.Now.ToString());
     db.AddInParameter(cmd, "@News_Images", DbType.String, u.News_Images);
     db.AddInParameter(cmd, "@News_Reading", DbType.String, u.News_Reading);
     db.AddInParameter(cmd, "@News_ImageBool", DbType.String, u.News_ImageBool);
     db.AddInParameter(cmd, "@ID", DbType.Int32, u.ID);
     return db.ExecuteNonQuery(cmd);
 }
Exemplo n.º 4
0
 private void editNews()
 {
     R_News r = new R_News();
     r.News_Tital = NewsTitle.Text.Trim();
     r.Sort_ID = 8;
     r.News_Content = NewsContent.Value;
     r.User_ID = Convert.ToInt32(Request.Cookies["user"]["ID"]);
     r.ID = id;
     r.News_Reading = 0;
     r.News_ImageBool = 0;
     r.News_Images = "";
     B_News b = new B_News();
     if (b.editNews(r))
     {
         Response.Redirect("../index.aspx");
     }
     else
     {
         ll_ts.Text = "修改失败!";
     }
 }
Exemplo n.º 5
0
 private void editNews()
 {
     R_News r = new R_News();
     r.News_Tital = NewsTitle;
     r.Sort_ID = 8;
     r.News_Content = SiteContent.Value;
     r.User_ID = Convert.ToInt32(Request.Cookies["user"]["ID"]);
     r.ID = id;
     r.News_Reading = 0;
     r.News_ImageBool = 0;
     r.News_Images = "";
     B_News b = new B_News();
     if (b.editNews(r))
     {
         Response.Write("<script>alert('更新成功')</script>");
     }
     else
     {
         ll_ts.Text = "修改失败!";
     }
 }
Exemplo n.º 6
0
 /// <summary>
 /// 修改文章
 /// </summary>
 /// <param name="u"></param>
 /// <returns></returns>
 public bool editNews(R_News u)
 {
     return d.editNews(u) == 1 ? true : false;
 }
Exemplo n.º 7
0
 /// <summary>
 /// 添加新文章
 /// </summary>
 /// <param name="u"></param>
 /// <returns></returns>
 public bool addNews(R_News u)
 {
     return d.addNews(u) == 1 ? true : false;
 }