private bool DoAdd() { try { BLL.CategoryBll bll = new BLL.CategoryBll(); Entity.Category model = new Entity.Category(); model.ChannelID = this.channel_id; model.Title = txtTitle1.Text.Trim(); //model. = int.Parse(ddlParentId.SelectedValue); model.SortID = int.Parse(txtSortId1.Text.Trim()); //model. = txtLinkUrl.Text.Trim(); //model.img_url = txtImgUrl.Text.Trim(); //model.content = txtContent.Value; if (bll.Add(model) < 1) { return false; } } catch { return false; } return true; }
//保存排序 protected void btnSave_Click(object sender, EventArgs e) { BLL.CategoryBll bll = new BLL.CategoryBll(); for (int i = 0; i < rptList.Items.Count; i++) { int id = Convert.ToInt32(((HiddenField)rptList.Items[i].FindControl("hidId")).Value); int sortId; if (!int.TryParse(((TextBox)rptList.Items[i].FindControl("txtSortId")).Text.Trim(), out sortId)) { sortId = 99; } bll.UpdateField(id, "SortID" + sortId.ToString()); } JscriptMsg("保存排序成功啦!", Utils.CombUrlTxt("list.aspx", "channel_id={0}", this.channel_id.ToString()), "Success"); }
//删除类别 protected void btnDelete_Click(object sender, EventArgs e) { ChkAdminLevel(channel_id, ActionEnum.Delete.ToString()); //检查权限 BLL.CategoryBll bll = new BLL.CategoryBll(); 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) { bll.Delete(id); } } JscriptMsg("批量删除成功啦!", Utils.CombUrlTxt("list.aspx", "channel_id={0}", this.channel_id.ToString()), "Success"); }
//数据绑定 private void RptBind() { BLL.CategoryBll bll = new BLL.CategoryBll(); DataTable dt = bll.GetList(this.channel_id); this.rptList.DataSource = dt; this.rptList.DataBind(); }
private void TreeBind(int _channel_id) { BLL.CategoryBll bll = new BLL.CategoryBll(); DataTable dt = bll.GetList(_channel_id); this.ddlParentId1.Items.Clear(); this.ddlParentId1.Items.Add(new ListItem("无父级分类", "0")); foreach (DataRow dr in dt.Rows) { string Id = dr["id"].ToString(); int ClassLayer = int.Parse(dr["class_layer"].ToString()); string Title = dr["title"].ToString().Trim(); if (ClassLayer == 1) { this.ddlParentId1.Items.Add(new ListItem(Title, Id)); } else { Title = "├ " + Title; Title = Utils.StringOfChar(ClassLayer - 1, " ") + Title; this.ddlParentId1.Items.Add(new ListItem(Title, Id)); } } }
private void ShowInfo(int _id) { BLL.CategoryBll bll = new BLL.CategoryBll(); Entity.Category model = bll.GetEntity(_id); //ddlParentId.SelectedValue = model.d.ToString(); txtTitle1.Text = model.Title; txtSortId1.Text = model.SortID.ToString(); //txtImgUrl.Text = model.ImageURL;// .img_url; //txtLinkUrl.Text = model.l;// .link_url; txtSortId1.Text = model.SortID.ToString(); //txtClick.Text = model.ClickCount.ToString(); //txtContent.Value = model.cccc; }
private bool DoEdit(int _id) { try { BLL.CategoryBll bll = new BLL.CategoryBll(); Entity.Category model = bll.GetEntity(_id); int parentId = int.Parse(ddlParentId1.SelectedValue); model.ChannelID = this.channel_id; model.Title = txtTitle1.Text.Trim(); //如果选择的父ID不是自己,则更改 //if (parentId != model.ID) //{ // model.parent_id = parentId; //} model.SortID = int.Parse(txtSortId1.Text.Trim()); //model.link_url = txtLinkUrl.Text.Trim(); //model.img_url = txtImgUrl.Text.Trim(); //model.content = txtContent.Value; if (!bll.Update(model)) { return false; } } catch { return false; } return true; }
private void TreeBind(int _channel_id) { BLL.CategoryBll bll = new BLL.CategoryBll(); DataTable dt = bll.GetList(channel_id); this.ddlCategoryId.Items.Clear(); this.ddlCategoryId.Items.Add(new ListItem("所有类别", "")); foreach (DataRow dr in dt.Rows) { string Id = dr["ID"].ToString(); string Title = dr["Title"].ToString().Trim(); this.ddlCategoryId.Items.Add(new ListItem(Title, Id)); } }