private void Button1_Click(object sender, EventArgs e) { try { var bl = new DS_SysProductCategory_Br(); var md = bl.GetSingle(int.Parse(Request.QueryString["id"])); string cname = Request.Form["cname"]; if (string.IsNullOrEmpty(cname)) { Common.MessageBox.Show(this, "分类名称不能为空", Common.MessageBox.InfoType.warning, "history.back"); return; } if (md.ID.Equals(ProCat1.CurrentCategoryID)) { Common.MessageBox.Show(this, "不能选择自己作为父类", Common.MessageBox.InfoType.warning, "history.back"); return; } md.CategoryName = cname.Trim(); md.ParentID = ProCat1.CurrentCategoryID; bl.Update(md); Common.MessageBox.Show(this, "保存成功", Common.MessageBox.InfoType.info, "function(){location='list.aspx'}"); }catch (Exception ex) { Common.WriteLog.SetErrLog(Request.Url.ToString(), "Button1_Click", ex.Message); if (ex.Message.Contains("IX_DS_SysProductCategory")) { Common.MessageBox.Show(this, "已存在相同的分类名称", Common.MessageBox.InfoType.error, "history.back"); return; } Common.MessageBox.Show(this, "保存发生意外,请联系管理人员解决。" + ex.Message, Common.MessageBox.InfoType.error, "history.back"); } }
private void Button1_Click(object sender, EventArgs e) { try { var bl = new DS_SysProductCategory_Br(); var md = bl.GetSingle(int.Parse(Request.QueryString["id"])); string cname = Request.Form["cname"]; if (string.IsNullOrEmpty(cname)) { Common.MessageBox.Show(this,"分类名称不能为空",Common.MessageBox.InfoType.warning,"history.back"); return; } if (md.ID.Equals(ProCat1.CurrentCategoryID)) { Common.MessageBox.Show(this, "不能选择自己作为父类", Common.MessageBox.InfoType.warning, "history.back"); return; } md.CategoryName = cname.Trim(); md.ParentID = ProCat1.CurrentCategoryID; bl.Update(md); Common.MessageBox.Show(this, "保存成功", Common.MessageBox.InfoType.info,"function(){location='list.aspx'}"); }catch(Exception ex){ Common.WriteLog.SetErrLog(Request.Url.ToString(), "Button1_Click", ex.Message); if (ex.Message.Contains("IX_DS_SysProductCategory")) { Common.MessageBox.Show(this, "已存在相同的分类名称", Common.MessageBox.InfoType.error, "history.back"); return; } Common.MessageBox.Show(this, "保存发生意外,请联系管理人员解决。" + ex.Message, Common.MessageBox.InfoType.error, "history.back"); } }
protected void Page_Load(object sender, EventArgs e) { DropDownList1.SelectedIndexChanged += new EventHandler(DropDownList1_SelectedIndexChanged); DropDownList2.SelectedIndexChanged += new EventHandler(DropDownList2_SelectedIndexChanged); if (IsPostBack) { return; } var bl = new DS_SysProductCategory_Br(); DropDownList1.DataSource = bl.Query("parentid=0", "px"); DropDownList1.DataBind(); DropDownList1.Items.Insert(0, new ListItem("--一级类--", "0")); for (int i = 1; i <= ShowLevel; i++) { this.FindControl("DropDownList" + i).Visible = true; } //还原类别状态 if (ViewState["CurrentCategoryID"] != null && !ViewState["CurrentCategoryID"].ToString().Equals("0")) { int ccatid = (int)ViewState["CurrentCategoryID"]; var md = bl.GetSingle(ccatid); if (!md.ParentID.Equals(0)) { var md2 = bl.GetSingle(md.ParentID); if (md2.ParentID.Equals(0)) { var item = Dropdown_1.Items.FindByValue(md.ParentID.ToString()); Dropdown_1.SelectedItem.Selected = false; item.Selected = true; DropDownList1_SelectedIndexChanged(null, null); } else { var item = Dropdown_1.Items.FindByValue(md2.ParentID.ToString()); Dropdown_1.SelectedItem.Selected = false; item.Selected = true; DropDownList1_SelectedIndexChanged(null, null); item = Dropdown_2.Items.FindByValue(md.ParentID.ToString()); Dropdown_2.SelectedItem.Selected = false; item.Selected = true; } } } }
protected void Page_Load(object sender, EventArgs e) { DropDownList1.SelectedIndexChanged+=new EventHandler(DropDownList1_SelectedIndexChanged); DropDownList2.SelectedIndexChanged += new EventHandler(DropDownList2_SelectedIndexChanged); if (IsPostBack) return; var bl = new DS_SysProductCategory_Br(); DropDownList1.DataSource = bl.Query("parentid=0","px"); DropDownList1.DataBind(); DropDownList1.Items.Insert(0, new ListItem("--一级类--", "0")); for (int i = 1; i <= ShowLevel; i++) { this.FindControl("DropDownList"+i).Visible=true; } //还原类别状态 if (ViewState["CurrentCategoryID"]!=null && !ViewState["CurrentCategoryID"].ToString().Equals("0")) { int ccatid = (int)ViewState["CurrentCategoryID"]; var md = bl.GetSingle(ccatid); if (!md.ParentID.Equals(0)) { var md2 = bl.GetSingle(md.ParentID); if (md2.ParentID.Equals(0)) { var item = Dropdown_1.Items.FindByValue(md.ParentID.ToString()); Dropdown_1.SelectedItem.Selected = false; item.Selected = true; DropDownList1_SelectedIndexChanged(null, null); } else { var item = Dropdown_1.Items.FindByValue(md2.ParentID.ToString()); Dropdown_1.SelectedItem.Selected = false; item.Selected = true; DropDownList1_SelectedIndexChanged(null, null); item = Dropdown_2.Items.FindByValue(md.ParentID.ToString()); Dropdown_2.SelectedItem.Selected = false; item.Selected = true; } } } }
protected void Page_Load(object sender, EventArgs e) { Button1.Click+=new EventHandler(Button1_Click); if (IsPostBack) return; var bl = new DS_SysProductCategory_Br(); var md = bl.GetSingle(int.Parse(Request.QueryString["id"])); cname.Value = md.CategoryName; ProCat1.CurrentCategoryID = md.ID; ProCat1.ShowLevel = 2; ProCat1.Dropdown_2.AutoPostBack = false; }
protected void Page_Load(object sender, EventArgs e) { Button1.Click += new EventHandler(Button1_Click); if (IsPostBack) { return; } var bl = new DS_SysProductCategory_Br(); var md = bl.GetSingle(int.Parse(Request.QueryString["id"])); cname.Value = md.CategoryName; ProCat1.CurrentCategoryID = md.ID; ProCat1.ShowLevel = 2; ProCat1.Dropdown_2.AutoPostBack = false; }