/// <summary> /// 决定首页是否显示图片 /// </summary> /// <param name="model"></param> /// <returns></returns> public int updNewsImage(YouthNews model) { StringBuilder str = new StringBuilder(); str.Append("update news set "); str.Append(" last_updater=@last_updater,"); str.Append(" last_update_time=@last_update_time,"); str.Append(" is_photoNews=@is_photoNews, "); str.Append(" photo_url=@photo_url "); str.Append(" where news_id=@news_id "); SqlParameter[] parameters = { new SqlParameter("@last_updater", SqlDbType.NVarChar, 25), new SqlParameter("@last_update_time", SqlDbType.DateTime), new SqlParameter("@is_photoNews", SqlDbType.VarChar, 10), new SqlParameter("@photo_url", SqlDbType.NVarChar, 50), new SqlParameter("@news_id", SqlDbType.Int, 8) }; parameters[0].Value = model.Last_update; parameters[1].Value = model.Last_update_time; parameters[2].Value = model.Is_photoNews; parameters[3].Value = model.Photo_url; parameters[4].Value = model.News_id; int rows = DbHelperSQL.ExecuteSql(str.ToString(), parameters); return(rows); }
protected void bindNews(int news_id) { //根据新闻id得到实体 news_model = news_bll.GetYouthNews(news_id); news_title.Text = news_model.News_title; PublishTime.Text = FormatTime(news_model.Publish_time); Publisher.Text = news_model.Publisher; Clicks.Text = news_model.Click_times.ToString(); updater.Text = news_model.Last_update; checker.Text = news_model.Checker; news_content.InnerHtml = news_model.News_content; }
/// <summary> /// 决定是否在首页显示图片 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool updNewsImage(YouthNews model) { int rows = news_dal.updNewsImage(model); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 更新编辑新闻 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool UpdYouthNews(YouthNews model) { int rows = news_dal.UpdYouthNews(model); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 在线投稿,增加新闻 /// </summary> /// <param name="model"></param> /// <returns></returns> public bool AddYouthNews(YouthNews model) { int i = news_dal.AddYouthNews(model); if (i > 0) { return(true); } else { return(false); } }
protected void bindData(int news_id) { news_model = news_bll.GetYouthNews(news_id); txtTitle.Text = news_model.News_title; txt_clickTimes.Text = news_model.Click_times.ToString(); txt_content.Text = news_model.News_content; txt_publisher.Text = news_model.Publisher; txt_publish_time.Text = news_model.Publish_time.ToString("yyyy-MM-dd"); txt_phone.Text = news_model.Publisher_phone; txt_email.Text = news_model.Publisher_mail; ddl_source.Items.FindByValue(news_model.News_source.ToString()).Selected = true; ddl_news_col.Items.FindByValue(news_model.News_father_id.ToString()).Selected = true; }
/// <summary> /// 在线投稿,添加新闻 /// </summary> /// <param name="model"></param> /// <returns></returns> public int AddYouthNews(YouthNews model) { StringBuilder str = new StringBuilder(); str.Append("insert into news ("); str.Append("news_title,news_content,news_father_id,publisher,publisher_phone, publisher_mail,publish_time,click_times,news_source,last_updater,last_update_time,first_check,is_check,checker,check_time,rechecker,recheck_time)"); str.Append(" values (@news_title,@news_content,@news_father_id,@publisher,@publisher_phone, @publisher_mail,@publish_time,@click_times,@news_source,@last_updater,@last_update_time,@first_check,@is_check,@checker,@check_time,@rechecker,@recheck_time"); str.Append(")"); SqlParameter[] parameters = { new SqlParameter("@news_title", SqlDbType.NVarChar, 50), new SqlParameter("@news_content", SqlDbType.NText), new SqlParameter("@news_father_id", SqlDbType.Int, 8), new SqlParameter("@publisher", SqlDbType.NVarChar, 25), new SqlParameter("@publisher_phone", SqlDbType.NVarChar, 50), new SqlParameter("@publisher_mail", SqlDbType.NVarChar, 50), new SqlParameter("@publish_time", SqlDbType.DateTime), new SqlParameter("@click_times", SqlDbType.Int, 8), new SqlParameter("@news_source", SqlDbType.Int, 8), new SqlParameter("@last_updater", SqlDbType.NVarChar, 25), new SqlParameter("@last_update_time", SqlDbType.DateTime), new SqlParameter("@first_check", SqlDbType.VarChar, 8), new SqlParameter("@is_check", SqlDbType.VarChar, 8), new SqlParameter("@checker", SqlDbType.NVarChar, 25), new SqlParameter("@check_time", SqlDbType.DateTime), new SqlParameter("@rechecker", SqlDbType.NVarChar, 25), new SqlParameter("@recheck_time", SqlDbType.DateTime) }; parameters[0].Value = model.News_title; parameters[1].Value = model.News_content; parameters[2].Value = model.News_father_id; parameters[3].Value = model.Publisher; parameters[4].Value = model.Publisher_phone; parameters[5].Value = model.Publisher_mail; parameters[6].Value = model.Publish_time; parameters[7].Value = model.Click_times; parameters[8].Value = model.News_source; parameters[9].Value = model.Last_update; parameters[10].Value = model.Last_update_time; parameters[11].Value = model.First_check; parameters[12].Value = model.Is_check; parameters[13].Value = model.Checker; parameters[14].Value = model.Check_time; parameters[15].Value = model.Rechecker; parameters[16].Value = model.Recheck_time; int rows = DbHelperSQL.ExecuteSql(str.ToString(), parameters); return(rows); }
protected void lbtnSave_Click(object sender, EventArgs e) { int news_id = Convert.ToInt32(ViewState["news_id"].ToString()); YouthNews originalModel = news_bll.GetYouthNews(news_id); news_model.News_id = news_id; //获取保存 news_model.News_title = txtTitle.Text.Trim().ToString(); news_model.News_content = txtContent.Text; news_model.News_revise = txt_revise.Text; news_model.News_father_id = Convert.ToInt32(ddl_news_col.SelectedValue); news_model.Publisher = txt_publisher.Text.ToString(); news_model.Publisher_phone = txt_phone.Text; news_model.Publisher_mail = txt_email.Text; news_model.Publish_time = Convert.ToDateTime(txt_publish_time.Text.ToString()); news_model.Click_times = Convert.ToInt32(txt_clickTimes.Text.ToString()); news_model.News_source = Convert.ToInt32(ddl_source.SelectedValue.ToString()); //Session.Timeout设置时长 news_model.Last_update = Session[Constant.adminName].ToString(); news_model.Last_update_time = DateTime.Now; news_model.First_check = originalModel.First_check; news_model.Is_check = originalModel.Is_check; news_model.Checker = ""; news_model.Check_time = originalModel.Check_time; news_model.Rechecker = originalModel.Rechecker; news_model.Recheck_time = originalModel.Recheck_time; news_model.Is_photoNews = originalModel.Is_photoNews; news_model.Photo_url = originalModel.Photo_url; if (news_bll.UpdYouthNews(news_model)) { aca_bll.ReUpdateRank(originalModel.News_source); aca_bll.UpdateRank(news_model.News_source); //编辑成功 MyUtil.ShowMessageRedirect(this.Page, "修改成功", "youth_newslist.aspx"); } else { //编辑失败 MyUtil.ShowMessage(this.Page, "修改失败"); } }
//决定是否在首页显示图片 protected void lbtnShow_Click(object sender, EventArgs e) { int role_id = Convert.ToInt32(Session[Constant.roleID].ToString()); if (role_id == 4 || role_id == 5 || role_id == 3) { String message = "对不起,您没有相应权限"; MyUtil.ShowMessage(this.Page, message); return; } else { LinkButton lbtn = (LinkButton)sender; int news_id = Convert.ToInt32(lbtn.CommandArgument); YouthNews news_model = news_bll.GetYouthNews(news_id); if (news_model.Is_photoNews.Trim().Equals("N") || String.IsNullOrEmpty(news_model.Is_photoNews)) { //显示 Response.Redirect("youth_addImage.aspx?news_id=" + news_id); } else { //取消显示 news_model.Photo_url = ""; news_model.Is_photoNews = "N"; news_model.Last_update = Session[Constant.adminName].ToString(); news_model.Last_update_time = DateTime.Today; news_model.News_id = news_id; if (news_bll.updNewsImage(news_model)) { //成功 MyUtil.ShowMessage(this.Page, "取消首页大图显示"); bindData(); } } } }
/// <summary> /// 更新编辑新闻 /// </summary> /// <param name="model"></param> /// <returns></returns> public int UpdYouthNews(YouthNews model) { StringBuilder str = new StringBuilder(); str.Append(" update news set "); str.Append(" news_title=@news_title,"); str.Append(" news_content=@news_content,"); str.Append(" news_revise=@news_revise,"); str.Append(" news_father_id=@news_father_id,"); str.Append(" publisher=@publisher,"); str.Append(" publisher_phone=@publisher_phone,"); str.Append(" publisher_mail=@publisher_mail,"); str.Append(" publish_time=@publish_time,"); str.Append(" click_times=@click_times,"); str.Append(" news_source=@news_source,"); str.Append(" last_updater=@last_updater,"); str.Append(" last_update_time=@last_update_time,"); str.Append(" first_check=@first_check,"); str.Append(" is_check=@is_check,"); str.Append(" checker=@checker,"); str.Append(" check_time=@check_time,"); str.Append(" rechecker=@rechecker,"); str.Append(" recheck_time=@recheck_time,"); str.Append(" is_photoNews=@is_photoNews,"); str.Append(" photo_url=@photo_url "); str.Append(" where news_id=@news_id "); SqlParameter[] parameters = { new SqlParameter("@news_title", SqlDbType.NVarChar, 50), new SqlParameter("@news_content", SqlDbType.NText), new SqlParameter("@news_revise", SqlDbType.NVarChar, 50), new SqlParameter("@news_father_id", SqlDbType.Int, 8), new SqlParameter("@publisher", SqlDbType.NVarChar, 25), new SqlParameter("@publisher_phone", SqlDbType.NVarChar, 50), new SqlParameter("@publisher_mail", SqlDbType.NVarChar, 50), new SqlParameter("@publish_time", SqlDbType.DateTime), new SqlParameter("@click_times", SqlDbType.Int, 8), new SqlParameter("@news_source", SqlDbType.Int, 8), new SqlParameter("@last_updater", SqlDbType.NVarChar, 25), new SqlParameter("@last_update_time", SqlDbType.DateTime), new SqlParameter("@first_check", SqlDbType.VarChar, 8), new SqlParameter("@is_check", SqlDbType.VarChar, 8), new SqlParameter("@checker", SqlDbType.NVarChar, 25), new SqlParameter("@check_time", SqlDbType.DateTime), new SqlParameter("@rechecker", SqlDbType.NVarChar, 25), new SqlParameter("@recheck_time", SqlDbType.DateTime), new SqlParameter("@is_photoNews", SqlDbType.VarChar, 10), new SqlParameter("@photo_url", SqlDbType.NVarChar, 50), new SqlParameter("@news_id", SqlDbType.Int, 8) }; parameters[0].Value = model.News_title; parameters[1].Value = model.News_content; parameters[2].Value = model.News_revise; parameters[3].Value = model.News_father_id; parameters[4].Value = model.Publisher; parameters[5].Value = model.Publisher_phone; parameters[6].Value = model.Publisher_mail; parameters[7].Value = model.Publish_time; parameters[8].Value = model.Click_times; parameters[9].Value = model.News_source; parameters[10].Value = model.Last_update; parameters[11].Value = model.Last_update_time; parameters[12].Value = model.First_check; parameters[13].Value = model.Is_check; parameters[14].Value = model.Checker; parameters[15].Value = model.Check_time; parameters[16].Value = model.Rechecker; parameters[17].Value = model.Recheck_time; parameters[18].Value = model.Is_photoNews; parameters[19].Value = model.Photo_url; parameters[20].Value = model.News_id; int rows = DbHelperSQL.ExecuteSql(str.ToString(), parameters); return(rows); }
//得到新闻对象实体 public YouthNews GetModel(DataRow row) { YouthNews model = new YouthNews(); if (row != null) { if (row["news_id"] != null) { model.News_id = int.Parse(row["news_id"].ToString()); } if (row["news_title"] != null) { model.News_title = row["news_title"].ToString(); } if (row["news_content"] != null) { model.News_content = row["news_content"].ToString(); } if (row["news_revise"] != null) { model.News_revise = row["news_revise"].ToString(); } if (row["news_father_id"] != null) { model.News_father_id = int.Parse(row["news_father_id"].ToString()); } else { model.News_father_id = 0; } if (row["publisher"] != null) { model.Publisher = row["publisher"].ToString(); } if (row["publisher_phone"] != null) { model.Publisher_phone = row["publisher_phone"].ToString(); } if (row["publisher_mail"] != null) { model.Publisher_mail = row["publisher_mail"].ToString(); } if (row["publish_time"] != null) { model.Publish_time = (DateTime)(row["publish_time"]); } if (row["click_times"] != null) { model.Click_times = int.Parse(row["click_times"].ToString()); } if (row["news_source"] != null) { model.News_source = int.Parse(row["news_source"].ToString()); } if (row["last_updater"] != null) { model.Last_update = row["last_updater"].ToString(); } else { model.Last_update = ""; } if (row["last_update_time"] != null) { model.Last_update_time = DateTime.Parse(row["last_update_time"].ToString()); } else { model.Last_update_time = DateTime.Today; } if (row["first_check"] != null) { model.First_check = row["first_check"].ToString(); } else { model.First_check = "N"; } if (row["is_check"] != null) { model.Is_check = row["is_check"].ToString(); } else { model.Is_check = "N"; } if (row["checker"] != null) { model.Checker = row["checker"].ToString(); } else { model.Checker = ""; } if (row["check_time"] != null) { model.Check_time = DateTime.Parse(row["check_time"].ToString()); } else { model.Check_time = DateTime.Today; } if (row["rechecker"] != null) { model.Rechecker = row["rechecker"].ToString(); } else { model.Rechecker = ""; } if (row["recheck_time"] != null && !"".Equals(row["recheck_time"].ToString())) { model.Recheck_time = DateTime.Parse(row["recheck_time"].ToString()); } else { model.Recheck_time = DateTime.Today; } if (row["is_photoNews"] != null) { model.Is_photoNews = row["is_photoNews"].ToString(); } else { model.Is_photoNews = "N"; } if (row["photo_url"] != null) { model.Photo_url = row["photo_url"].ToString(); } else { model.Photo_url = ""; } } return(model); }
//得到新闻标题 protected string GetTitle(int news_id) { news_model = news_bll.GetYouthNews(news_id); return(news_model.News_title); }