protected void btnSave_Click(object sender, EventArgs e) { try { M_LbCategory m_LbCategory = new M_LbCategory(); m_LbCategory.Name = txtLabelTypeName.Text.Trim(); m_LbCategory.ParentID = int.Parse(dropLabelType.SelectedValue.ToString()); m_LbCategory.Desc = txtExplain.Text.Trim(); B_LbCategory b_Lbcategory = new B_LbCategory(); B_KyCommon bllCom = new B_KyCommon(); bool flag = false; flag = bllCom.CheckHas(m_LbCategory.Name, "Name", "KyLbCategory"); if (btnSave.Text == "修改类别") { m_LbCategory.LbCategoryID=int.Parse(Request.QueryString["lbCategoryId"].ToString()); B_LbCategory bll = new B_LbCategory(); bll.Update(m_LbCategory); Response.Redirect(SkipPageUrl); } else { if (!flag) { b_Lbcategory.Add(m_LbCategory); Response.Redirect(SkipPageUrl); } else Response.Write("<script>alert('己存在此标签名称')</script>"); } } catch { Response.Write("<script>alert('操作有误')</script>"); } }
private void BindStyleCategory() { dllLbCategory.Items.Clear(); dllLbCategory.Items.Add(new ListItem("请选择类别", "0")); B_LbCategory bll = new B_LbCategory(); DataTable dt = bll.GetListItemByLabelId(); foreach (DataRow dr in dt.Rows) { string colname = dr["Name"].ToString(); int colid = Convert.ToInt32(dr["LbCategoryID"].ToString()); int depth = int.Parse(dr["Depth"].ToString()); for (int i = 0; i < depth; i++) { colname = "├┄" + colname; } dllLbCategory.Items.Add(new ListItem(colname, colid.ToString())); } }
private void StyleBind() { int lbCategoryId; B_LbCategory bll = new B_LbCategory(); if (Request.QueryString["parentId"] == null) { parentId = 0; lbCategoryId = 0; } else { parentId = int.Parse(Request.QueryString["parentId"].ToString()); lbCategoryId = int.Parse(Request.QueryString["lbCategoryId"].ToString()); } repStyle.DataSource = bll.GetLabelCategoryList(parentId); repStyle.DataBind(); int recordCount = 0; LabelContentBind(lbCategoryId, AspNetPager1.CurrentPageIndex, AspNetPager1.PageSize, ref recordCount); AspNetPager1.RecordCount = recordCount; AspNetPager1.CustomInfoHTML = string.Format("当前第{0}/{1}页 共{2}条记录 每页{3}条", AspNetPager1.CurrentPageIndex, AspNetPager1.PageCount, AspNetPager1.RecordCount, AspNetPager1.PageSize); }
protected void repStyle_ItemCommand(object sender, RepeaterCommandEventArgs e) { HiddenField hddenLbCategoryId = e.Item.FindControl("hiddenLbCategoryId") as HiddenField; B_LbCategory bll = new B_LbCategory(); if (hddenLbCategoryId.Value.ToString() != "1") { bll.Delete(int.Parse(hddenLbCategoryId.Value.ToString())); StyleBind(); } else { Response.Write("<script>alert('不能删除系统定义的标签类别')</script>"); } }
protected void Page_Load(object sender, EventArgs e) { AdminGroupBll.Power_Judge(6); if(!IsPostBack) { SkipPageUrl = Request.ServerVariables["HTTP_REFERER"].ToString(); if (Request.QueryString["lbCategoryId"] == null) { BindStyleCategory(); } else { BindStyleCategory(); btnSave.Text = "修改类别"; btnReset.Visible = false; B_LbCategory bll = new B_LbCategory(); if (Request.QueryString["lbCategoryId"].ToString() == "1") { dropLabelType.Enabled = false; } for (int i = 0; i < dropLabelType.Items.Count;i++ ) { if(dropLabelType.Items[i].Value==Request.QueryString["parentId"].ToString()) { dropLabelType.Items[i].Selected = true; } if (dropLabelType.Items[i].Value == Request.QueryString["lbCategoryId"].ToString()) { dropLabelType.Items[i].Enabled = false; } DataTable dt = bll.GetListItemByLabelId(); DataView dv = dt.DefaultView; dv.RowFilter = "ParentID=" + Request.QueryString["lbCategoryId"].ToString() + ""; for (int j = 0; j < dropLabelType.Items.Count; j++) { for (int j1 = 0; j1 < dv.Count; j1++) { if (dropLabelType.Items[j].Value == dv[j1]["lbCategoryId"].ToString()) { dropLabelType.Items[j].Enabled = false; } } } } M_LbCategory model = bll.GetLabeCategoryIdData(int.Parse(Request.QueryString["lbCategoryId"].ToString())); txtLabelTypeName.Text = model.Name; txtExplain.Text = model.Desc; } } }