/// <summary> /// 递归栏目信息 /// </summary> /// <param name="n"></param> public void ListControl_Bind(int n) { Cms.BLL.C_type bllcolumn = new Cms.BLL.C_type(); Cms.Model.C_type modelcolumn = new Cms.Model.C_type(); DataSet dt = bllcolumn.GetList("parent_id=" + n + "order by sort_id asc"); dt.Tables[0].Columns.Add("Operate", typeof(string)); //操作 dt.Tables[0].Columns.Add("Colum", typeof(String)); //在dt中增加字段名为Colum的列 if (dt.Tables[0].Rows.Count > 0) { for (int i = 0; i < dt.Tables[0].Rows.Count; i++) { DataRow dr = dt.Tables[0].Rows[i]; string strchar = ""; dr["operate"] = "<a href='typeedit.aspx?action=add&id=" + dr["id"].ToString() + "&parentId=" + dr["parent_id"].ToString() + "'>[添加下级]</a> <a href='typeedit.aspx?action=edit&id=" + dr["id"].ToString() + "&parentId=" + dr["parent_id"].ToString() + "'>[编辑]</a> <a href='list.aspx??action=del&id=" + dr["id"].ToString() + "&name=" + dr["name"].ToString() + " ' onclick='return confirm(\"真的要删除该栏目以及子栏目和栏目下的新闻吗?不可恢复!\");'>[删除]</a> "; strchar += "<tr onmouseover=this.bgColor='#EBFFDC'; onmouseout=this.bgColor='#ffffff'; bgcolor='#ffffff'>"; strchar += "<td align=\"center\"><input type='checkbox'/></td> "; strchar += "<td align=\"left\">" + dr["id"].ToString() + "</td> "; strchar += "<td align=\"left\" >" + dr["name"].ToString() + "</td>"; strchar += "<td align=\"center\" >" + GetClassisShowChannel(dr["is_hot"].ToString()) + "</td>"; strchar += "<td align=\"center\" >" + GetClassisShowChannel(dr["isHidden"].ToString()) + "</td>"; strchar += "<td align=\"left\" >" + dr["sort_id"].ToString() + "</td>"; strchar += "<td align=\"center\" >" + dr["operate"].ToString() + "</td>"; strchar += "</tr>"; strchar = InitChild(dr, strchar, 2); dr["Colum"] = strchar; } } this.rptList.DataSource = dt; this.rptList.DataBind(); }
private void ShowInfo(int _id) { Cms.BLL.C_type bll = new Cms.BLL.C_type(); Cms.Model.C_type model = bll.GetModel(_id); this.parentId.SelectedValue = model.parent_id.ToString();//上级栏目ID txtCallIndex.Text = model.call_index; txtTitle.Text = model.title; txtSortId.Text = model.sort_id.ToString(); txtLinkUrl.Text = model.link_url; txtImgUrl.Value = model.img_url; txtContent.Value = model.content; this.isHidden.SelectedValue = model.isHidden.ToString();//显示状态 }
private string InitChild(DataRow dr, string strchar, int n) { Cms.BLL.C_type bllcolumn = new Cms.BLL.C_type(); Cms.Model.C_type modelcolumn = new Cms.Model.C_type(); DataSet dtt = bllcolumn.GetList("parent_id=" + dr["id"] + "order by sort_id asc"); dtt.Tables[0].Columns.Add("Operate", typeof(string)); dtt.Tables[0].Columns.Add("Colum", typeof(String)); if (dtt.Tables[0].Rows.Count > 0) { string s = " "; for (int j = 1; j <= n; j++) { s += " "; } for (int k = 0; k < dtt.Tables[0].Rows.Count; k++) { DataRow dro = dtt.Tables[0].Rows[k]; string flag = "├"; if (dtt.Tables[0].Rows.Count == 1) { flag = "├"; } else { if (k == 0) { flag = "├"; } if (k == dtt.Tables[0].Rows.Count - 1) { flag = "├"; } } dro["operate"] = "<a href='typeedit.aspx?action=add&id=" + dro["id"].ToString() + "&parentId=" + dro["parent_id"].ToString() + "'>[添加下级]</a> <a href='typeedit.aspx?action=edit&id=" + dro["id"].ToString() + "&parentId=" + dro["parent_id"].ToString() + "'>[编辑]</a> <a href='list.aspx?action=del&id=" + dro["id"].ToString() + "&name=" + dro["name"].ToString() + " ' onclick='return confirm(\"真的要删除?栏目删除之后,该栏目下的新闻也将删除,不可恢复!\");'>[删除]</a>"; strchar += "<tr onmouseover=this.bgColor='#EBFFDC'; onmouseout=this.bgColor='#ffffff'; bgcolor='#ffffff'>"; strchar += "<td align=\"center\"><input type='checkbox'/></td> "; strchar += "<td align=\"left\">" + dro["id"].ToString() + "</td> "; strchar += "<td align=\"left\" >" + s + flag + dro["name"].ToString() + "</td>"; strchar += "<td align=\"center\" >" + GetClassisShowChannel(dro["is_hot"].ToString()) + "</td>"; strchar += "<td align=\"center\" >" + GetClassisShowChannel(dro["isHidden"].ToString()) + "</td>"; strchar += "<td align=\"left\" >" + dro["sort_id"].ToString() + "</td>"; strchar += "<td align=\"center\" >" + dro["Operate"].ToString() + "</td>"; strchar += "</tr>"; strchar = InitChild(dro, strchar, n + 8); } } return(strchar); }
private void ChileNodeBind(DataRow drr, DropDownList parentId, int m) { Cms.BLL.C_type bllcolumn = new Cms.BLL.C_type(); Cms.Model.C_type modelcolumn = new Cms.Model.C_type(); DataSet dss = bllcolumn.GetList("parent_id=" + drr["id"] + ""); if (dss.Tables[0].Rows.Count > 0) { string s = System.Web.HttpContext.Current.Server.HtmlDecode(" "); for (int j = 1; j <= m; j++) { s += System.Web.HttpContext.Current.Server.HtmlDecode(" "); } for (int k = 0; k < dss.Tables[0].Rows.Count; k++) { DataRow dro = dss.Tables[0].Rows[k]; string flag = "├"; if (dss.Tables[0].Rows.Count == 1) { flag = "├"; } else { if (k == 0) { flag = "├"; } if (k == dss.Tables[0].Rows.Count - 1) { flag = "├"; } } ListItem item = new ListItem(); item.Text = s + flag + dro["title"].ToString(); item.Value = dro["id"].ToString(); parentId.Items.Add(item); ChileNodeBind(dro, parentId, m + 5); } } }
protected void btnDelete_Click(object sender, EventArgs e) { Cms.BLL.C_type bll = new Cms.BLL.C_type(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); CheckBox cb = (CheckBox)rptList.Items[i].FindControl("chkId"); if (cb.Checked) { Cms.Model.C_type model = bll.GetModel(id); if (model != null) { //int count = Cms.DBUtility.DbHelperSQL.ExecuteSql("delete from C_article where parentId=" + id);//删除文章 adminUser.AddAdminLog(DTEnums.ActionEnum.Delete.ToString(), model.title); //记录日志 bll.Delete(id); } } } JscriptMsg("删除数据成功!", "list.aspx", "Success"); }
public void DropList_Bind() { parentId.Items.Clear(); parentId.Items.Add(new ListItem("作为一级分类", "0")); Cms.BLL.C_type bllcolumn = new Cms.BLL.C_type(); Cms.Model.C_type modelcolumn = new Cms.Model.C_type(); DataSet ds = bllcolumn.GetList("parent_id=0 order by sort_id asc"); if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { DataRow dr = ds.Tables[0].Rows[i]; ListItem item = new ListItem(); item.Text = "" + dr["title"].ToString(); item.Value = dr["id"].ToString(); parentId.Items.Add(item); ChileNodeBind(dr, parentId, 2); } } }
private bool DoEdit(int _id) { try { Cms.BLL.C_type bll = new Cms.BLL.C_type(); Cms.Model.C_type model = bll.GetModel(_id); model.parent_id = Convert.ToInt32(this.parentId.SelectedValue);//上级栏目ID string class_layer = getclasslayer(Convert.ToInt32(this.parentId.SelectedValue), 1); model.class_layer = Convert.ToInt32(class_layer); model.call_index = txtCallIndex.Text.Trim(); model.title = txtTitle.Text.Trim(); //如果选择的父ID不是自己,则更改 model.sort_id = int.Parse(txtSortId.Text.Trim()); model.link_url = txtLinkUrl.Text.Trim(); model.img_url = txtImgUrl.Value.Trim(); model.content = txtContent.Value; model.isHidden = Convert.ToInt32(this.isHidden.SelectedValue); //显示状态 model.isTop = 0; //0 不置顶 model.isRecommend = 0; //0 不推荐 model.isHot = 0; //不属于热门 model.is_msg = 0; //不属于评论 model.is_slide = 0; //不属于幻灯片 if (bll.Update(model)) { adminUser.AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), model.title); //记录日志 return(true); } } catch { return(false); } return(false); }
public void Del() { if (Request.QueryString["action"] != null) { if (Request.QueryString["action"].ToString() == "del") { int id = Convert.ToInt32(Request.QueryString["id"].ToString()); string name = Request.QueryString["name"].ToString(); Cms.BLL.C_type bllcolumn = new Cms.BLL.C_type(); Cms.Model.C_type model = bllcolumn.GetModel(id); adminUser.AddAdminLog(DTEnums.ActionEnum.Delete.ToString(), model.title); //记录日志 if (model != null && bllcolumn.Delete(id)) { JscriptMsg("删除栏目信息成功!", "Column_list.aspx", "Success"); } else { JscriptMsg("删除栏目信息失败!", "Column_list.aspx", "Error"); } } } }
public void DropList_Bind() { ddlchannel_id.Items.Clear(); //ddlchannel_id.Items.Add(new ListItem("颜色分类", "0")); Cms.BLL.C_type bllcolumn = new Cms.BLL.C_type(); Cms.Model.C_type modelcolumn = new Cms.Model.C_type(); DataSet ds = bllcolumn.GetList(""); if (ds.Tables[0].Rows.Count > 0) { for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { DataRow dr = ds.Tables[0].Rows[i]; ListItem item = new ListItem(); item.Text = "" + dr["title"].ToString(); item.Value = dr["id"].ToString(); ddlchannel_id.Items.Add(item); ChileNodeBind(dr, ddlchannel_id, 2); } } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Cms.Model.C_type model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Cms.Model.C_type model) { return(dal.Add(model)); }