//设置操作 protected void rptList_ItemCommand(object source, RepeaterCommandEventArgs e) { ChkAdminLevel(channel_id, ActionEnum.Edit.ToString()); //检查权限 int id = Convert.ToInt32(((HiddenField)e.Item.FindControl("hidId")).Value); BLL.contents bll = new BLL.contents(); Model.contents model = bll.GetModel(id); switch (e.CommandName.ToLower()) { case "ibtnmsg": if (model.is_msg == 1) { bll.UpdateField(id, "is_msg=0"); } else { bll.UpdateField(id, "is_msg=1"); } break; case "ibtnred": if (model.is_red == 1) { bll.UpdateField(id, "is_red=0"); } else { bll.UpdateField(id, "is_red=1"); } break; } this.RptBind("id>0" + CombSqlTxt(this.channel_id, this.category_id, this.keywords, this.property), "sort_id asc,add_time desc"); }
private void ShowInfo(int _id) { BLL.contents bll = new BLL.contents(); Model.contents model = bll.GetModel(_id); ddlCategoryId.SelectedValue = model.category_id.ToString(); txtCallIndex.Text = model.call_index; txtTitle.Text = model.title; txtImgUrl.Text = model.img_url; txtLinkUrl.Text = model.link_url; if (model.is_msg == 1) { cblItem.Items[0].Selected = true; } if (model.is_red == 1) { cblItem.Items[1].Selected = true; } if (model.is_lock == 1) { cblItem.Items[2].Selected = true; } txtSortId.Text = model.sort_id.ToString(); txtClick.Text = model.click.ToString(); txtDiggGood.Text = model.digg_good.ToString(); txtDiggAct.Text = model.digg_act.ToString(); txtContent.Value = model.content; txtSeoTitle.Text = model.seo_title; txtSeoKeywords.Text = model.seo_keywords; txtSeoDescription.Text = model.seo_description; }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.contents model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into dt_contents("); strSql.Append("channel_id,title,category_id,call_index,link_url,img_url,seo_title,seo_keywords,seo_description,content,sort_id,click,is_msg,is_red,is_lock,add_time,digg_good,digg_act)"); strSql.Append(" values ("); strSql.Append("@channel_id,@title,@category_id,@call_index,@link_url,@img_url,@seo_title,@seo_keywords,@seo_description,@content,@sort_id,@click,@is_msg,@is_red,@is_lock,@add_time,@digg_good,@digg_act)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@channel_id", SqlDbType.Int, 4), new SqlParameter("@title", SqlDbType.NVarChar, 100), new SqlParameter("@category_id", SqlDbType.Int, 4), new SqlParameter("@call_index", SqlDbType.NVarChar, 50), new SqlParameter("@link_url", SqlDbType.NVarChar, 255), new SqlParameter("@img_url", SqlDbType.NVarChar, 255), new SqlParameter("@seo_title", SqlDbType.NVarChar, 255), new SqlParameter("@seo_keywords", SqlDbType.NVarChar, 255), new SqlParameter("@seo_description", SqlDbType.NVarChar, 255), new SqlParameter("@content", SqlDbType.NText), new SqlParameter("@sort_id", SqlDbType.Int, 4), new SqlParameter("@click", SqlDbType.Int, 4), new SqlParameter("@is_msg", SqlDbType.TinyInt, 1), new SqlParameter("@is_red", SqlDbType.TinyInt, 1), new SqlParameter("@is_lock", SqlDbType.TinyInt, 1), new SqlParameter("@add_time", SqlDbType.DateTime), new SqlParameter("@digg_good", SqlDbType.Int, 4), new SqlParameter("@digg_act", SqlDbType.Int, 4) }; parameters[0].Value = model.channel_id; parameters[1].Value = model.title; parameters[2].Value = model.category_id; parameters[3].Value = model.call_index; parameters[4].Value = model.link_url; parameters[5].Value = model.img_url; parameters[6].Value = model.seo_title; parameters[7].Value = model.seo_keywords; parameters[8].Value = model.seo_description; parameters[9].Value = model.content; parameters[10].Value = model.sort_id; parameters[11].Value = model.click; parameters[12].Value = model.is_msg; parameters[13].Value = model.is_red; parameters[14].Value = model.is_lock; parameters[15].Value = model.add_time; parameters[16].Value = model.digg_good; parameters[17].Value = model.digg_act; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
//内容模块 private void digg_content_add(HttpContext context) { string channel_type = DTRequest.GetFormString("channel_type"); string digg_type = DTRequest.GetFormString("digg_type"); int id = DTRequest.GetFormInt("id"); BLL.contents bll = new BLL.contents(); if (!bll.Exists(id)) { context.Response.Write("{msg:0, msgbox:\"信息不存在或已删除!\"}"); return; } if (digg_type == "good") { bll.UpdateField(id, "digg_good=digg_good+1"); } else { bll.UpdateField(id, "digg_act=digg_act+1"); } Model.contents model = bll.GetModel(id); context.Response.Write("{msg:1, digggood:" + model.digg_good + ", diggact:" + model.digg_act + ", msgbox:\"成功顶或踩了一下!\"}"); Utils.WriteCookie(DTKeys.COOKIE_DIGG_KEY, channel_type + id.ToString(), id.ToString(), 8640); return; }
private bool DoAdd() { bool result = true; DTcms.Model.contents model = new Model.contents(); DTcms.BLL.contents bll = new BLL.contents(); model.channel_id = this.channel_id; model.title = txtTitle.Text.Trim(); model.call_index = txtCallIndex.Text.Trim(); model.category_id = int.Parse(ddlCategoryId.SelectedValue); model.link_url = txtLinkUrl.Text.Trim(); model.img_url = txtImgUrl.Text.Trim(); model.seo_title = txtSeoTitle.Text.Trim(); model.seo_keywords = txtSeoKeywords.Text.Trim(); model.seo_description = txtSeoDescription.Text.Trim(); model.sort_id = int.Parse(txtSortId.Text.Trim()); model.click = int.Parse(txtClick.Text.Trim()); model.content = txtContent.Value; model.is_msg = 0; model.is_red = 0; model.is_lock = 0; if (cblItem.Items[0].Selected == true) { model.is_msg = 1; } if (cblItem.Items[1].Selected == true) { model.is_red = 1; } if (cblItem.Items[2].Selected == true) { model.is_lock = 1; } if (bll.Add(model) < 1) { result = false; } return(result); }
/// <summary> /// 重写虚方法,此方法将在Init事件前执行 /// </summary> protected override void ShowPage() { id = DTRequest.GetQueryInt("id"); page = DTRequest.GetQueryString("page"); BLL.contents bll = new BLL.contents(); if (id > 0) { if (!bll.Exists(id)) { HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!")); return; } model = bll.GetModel(id); } else if (!string.IsNullOrEmpty(page)) { if (!bll.Exists(page)) { HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!")); return; } model = bll.GetModel(page); } else { Server.Transfer("error.aspx"); return; } //浏览数+1 bll.UpdateField(model.id, "click=click+1"); //跳转URL if (model.link_url != null) { model.link_url = model.link_url.Trim(); } if (!string.IsNullOrEmpty(model.link_url)) { HttpContext.Current.Response.Redirect(model.link_url); } }
/// <summary> /// 重写虚方法,此方法将在Init事件前执行 /// </summary> protected override void ShowPage() { id = DTRequest.GetQueryInt("id"); page = DTRequest.GetQueryString("page"); BLL.contents bll = new BLL.contents(); if (id > 0) { if (!bll.Exists(id)) { HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!")); return; } model = bll.GetModel(id); } else if (!string.IsNullOrEmpty(page)) { if (!bll.Exists(page)) { HttpContext.Current.Response.Redirect(config.webpath + "error.aspx?msg=" + Utils.UrlEncode("出错啦,您要浏览的页面不存在或已删除啦!")); return; } model = bll.GetModel(page); } else { Server.Transfer("error.aspx"); return; } //浏览数+1 bll.UpdateField(model.id, "click=click+1"); //跳转URL if (model.link_url != null) model.link_url = model.link_url.Trim(); if (!string.IsNullOrEmpty(model.link_url)) { HttpContext.Current.Response.Redirect(model.link_url); } }
private bool DoAdd() { bool result = true; DTcms.Model.contents model = new Model.contents(); DTcms.BLL.contents bll = new BLL.contents(); model.channel_id = this.channel_id; model.title = txtTitle.Text.Trim(); model.call_index = txtCallIndex.Text.Trim(); model.category_id = int.Parse(ddlCategoryId.SelectedValue); model.link_url = txtLinkUrl.Text.Trim(); model.img_url = txtImgUrl.Text.Trim(); model.seo_title = txtSeoTitle.Text.Trim(); model.seo_keywords = txtSeoKeywords.Text.Trim(); model.seo_description = txtSeoDescription.Text.Trim(); model.sort_id = int.Parse(txtSortId.Text.Trim()); model.click = int.Parse(txtClick.Text.Trim()); model.content = txtContent.Value; model.is_msg = 0; model.is_red = 0; model.is_lock = 0; if (cblItem.Items[0].Selected == true) { model.is_msg = 1; } if (cblItem.Items[1].Selected == true) { model.is_red = 1; } if (cblItem.Items[2].Selected == true) { model.is_lock = 1; } if (bll.Add(model) < 1) { result = false; } return result; }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.contents model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.contents model) { return(dal.Add(model)); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.contents model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update dt_contents set "); strSql.Append("channel_id=@channel_id,"); strSql.Append("title=@title,"); strSql.Append("category_id=@category_id,"); strSql.Append("call_index=@call_index,"); strSql.Append("link_url=@link_url,"); strSql.Append("img_url=@img_url,"); strSql.Append("seo_title=@seo_title,"); strSql.Append("seo_keywords=@seo_keywords,"); strSql.Append("seo_description=@seo_description,"); strSql.Append("content=@content,"); strSql.Append("sort_id=@sort_id,"); strSql.Append("click=@click,"); strSql.Append("is_msg=@is_msg,"); strSql.Append("is_red=@is_red,"); strSql.Append("is_lock=@is_lock,"); strSql.Append("add_time=@add_time,"); strSql.Append("digg_good=@digg_good,"); strSql.Append("digg_act=@digg_act"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@channel_id", SqlDbType.Int, 4), new SqlParameter("@title", SqlDbType.NVarChar, 100), new SqlParameter("@category_id", SqlDbType.Int, 4), new SqlParameter("@call_index", SqlDbType.NVarChar, 50), new SqlParameter("@link_url", SqlDbType.NVarChar, 255), new SqlParameter("@img_url", SqlDbType.NVarChar, 255), new SqlParameter("@seo_title", SqlDbType.NVarChar, 255), new SqlParameter("@seo_keywords", SqlDbType.NVarChar, 255), new SqlParameter("@seo_description", SqlDbType.NVarChar, 255), new SqlParameter("@content", SqlDbType.NText), new SqlParameter("@sort_id", SqlDbType.Int, 4), new SqlParameter("@click", SqlDbType.Int, 4), new SqlParameter("@is_msg", SqlDbType.TinyInt, 1), new SqlParameter("@is_red", SqlDbType.TinyInt, 1), new SqlParameter("@is_lock", SqlDbType.TinyInt, 1), new SqlParameter("@add_time", SqlDbType.DateTime), new SqlParameter("@digg_good", SqlDbType.Int, 4), new SqlParameter("@digg_act", SqlDbType.Int, 4), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.channel_id; parameters[1].Value = model.title; parameters[2].Value = model.category_id; parameters[3].Value = model.call_index; parameters[4].Value = model.link_url; parameters[5].Value = model.img_url; parameters[6].Value = model.seo_title; parameters[7].Value = model.seo_keywords; parameters[8].Value = model.seo_description; parameters[9].Value = model.content; parameters[10].Value = model.sort_id; parameters[11].Value = model.click; parameters[12].Value = model.is_msg; parameters[13].Value = model.is_red; parameters[14].Value = model.is_lock; parameters[15].Value = model.add_time; parameters[16].Value = model.digg_good; parameters[17].Value = model.digg_act; parameters[18].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }