protected void Page_Load(object sender, EventArgs e) { if (string.IsNullOrEmpty(Request.QueryString["ID"])) { Common.MessageBox.Show(this, "缺少参数", Common.MessageBox.InfoType.warning, "history.back"); return; } int sid = 0; if (!int.TryParse(Request.QueryString["ID"], out sid)) { Common.MessageBox.Show(this, "参数无效", Common.MessageBox.InfoType.warning, "history.back"); return; } Button1.Click+=new EventHandler(Button1_Click); if (IsPostBack) return; DropDownList1.DataSource = Enum.GetNames(typeof(DS_Property_Br.ControlType)); DropDownList1.DataBind(); var bl = new DS_Property_Br(); var md = bl.GetSingle(int.Parse(Request.QueryString["ID"])); cname.Value = md.ProName; DropDownList1.Items[md.ControlType].Selected = true; unit.Value = md.Unit; ViewState["MapID"] = md.MapID; ViewState["SysCatID"] = md.SysCatID; CheckBox1.Checked = md.Request; ViewState["categoryName"] = new DS_SysProductCategory_Br().GetCategoryName(md.SysCatID,false).TrimEnd('>'); }
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) { 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; }
private void BindDate(string sql, params object[] param) { ViewState["sql"] = sql; ViewState["param"] = param; int pageCount = 0; var bl = new DS_SysProductCategory_Br(); var list = bl.Query(sql,"px", (ToolBar1.AspNetPager.CurrentPageIndex - 1) * ToolBar1.AspNetPager.PageSize, ToolBar1.AspNetPager.PageSize, ref pageCount, param); ToolBar1.AspNetPager.RecordCount = pageCount; Repeater1.DataSource =list; Repeater1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; var bl = new DS_Products_Br(); var md = bl.GetSingle(int.Parse(Request.QueryString["pro_id"])); Property1.Product=md; var list = bl.Query("ShopCatID=@0","",md.ShopCatID); Repeater1.DataSource = list; Repeater1.DataBind(); var catbl = new DS_SysProductCategory_Br(); ViewState["category"] = catbl.GetCategoryName(md.SysCatID,false).TrimEnd('>').Replace(">"," > "); }
private void DropDownList2_SelectedIndexChanged(object sender, EventArgs e) { var bl = new DS_SysProductCategory_Br(); if (DropDownList2.SelectedValue.Equals("0")) { DropDownList3.Items.Clear(); } else { DropDownList3.DataSource = bl.Query("parentid=" + DropDownList2.SelectedValue, "px"); DropDownList3.DataBind(); } DropDownList3.Items.Insert(0, new ListItem("--三级类--", "0")); }
private void DropDownList2_SelectedIndexChanged(object sender, EventArgs e) { var bl = new DS_SysProductCategory_Br(); if (DropDownList2.SelectedValue.Equals("0")) { DropDownList3.Items.Clear(); } else { DropDownList3.DataSource = bl.Query("parentid=" + DropDownList2.SelectedValue, "px"); DropDownList3.DataBind(); } DropDownList3.Items.Insert(0, new ListItem("--三级类--", "0")); }
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; } } } }
private void Delete(object sender, EventArgs e) { try { string ids = Request.Form["checkboxid"]; if (string.IsNullOrEmpty(ids)) { Common.MessageBox.Show(this, "请选中要删除的记录", Common.MessageBox.InfoType.warning); return; } var bl = new DS_SysProductCategory_Br(); bl.Delete(ids); Common.MessageBox.Show(this, "删除成功", Common.MessageBox.InfoType.info); AspNetPager_PageChanged(null, null); }catch(Exception ex){ Common.WriteLog.SetErrLog(Request.Url.ToString(), "Delete", ex.Message); Common.MessageBox.Show(this, "删除发生意外,请联系管理人员解决。" + ex.Message, Common.MessageBox.InfoType.error); } }
private void Delete(object sender, EventArgs e) { try { string ids = Request.Form["checkboxid"]; if (string.IsNullOrEmpty(ids)) { Common.MessageBox.Show(this, "请选中要删除的记录", Common.MessageBox.InfoType.warning); return; } var bl = new DS_SysProductCategory_Br(); bl.Delete(ids); Common.MessageBox.Show(this, "删除成功", Common.MessageBox.InfoType.info); AspNetPager_PageChanged(null, null); }catch (Exception ex) { Common.WriteLog.SetErrLog(Request.Url.ToString(), "Delete", ex.Message); Common.MessageBox.Show(this, "删除发生意外,请联系管理人员解决。" + ex.Message, Common.MessageBox.InfoType.error); } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } var bl = new DS_Products_Br(); var md = bl.GetSingle(int.Parse(Request.QueryString["pro_id"])); Property1.Product = md; var list = bl.Query("ShopCatID=@0", "", md.ShopCatID); Repeater1.DataSource = list; Repeater1.DataBind(); var catbl = new DS_SysProductCategory_Br(); ViewState["category"] = catbl.GetCategoryName(md.SysCatID, false).TrimEnd('>').Replace(">", " > "); }
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; } } } }
private void Button1_Click(object sender, EventArgs e) { try { string cname = Request.Form["cname"]; if (string.IsNullOrEmpty(cname)) { Common.MessageBox.Show(this,"分类名称不能为空",Common.MessageBox.InfoType.warning); return; } var bl = new DS_SysProductCategory_Br(); var md = bl.CreateModel(); md.CategoryName = cname.Trim(); md.ParentID =ProCat1.CategoryID_2.Equals(0)?ProCat1.CategoryID_1:ProCat1.CategoryID_2; md.Px = 0; bl.Add(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); return; } Common.MessageBox.Show(this, "保存发生意外,请联系管理人员解决。"+ex.Message, Common.MessageBox.InfoType.error); } }
private void Button1_Click(object sender, EventArgs e) { try { var bl = new DS_SysProductCategory_Br(); string kw = Request.Form["keyword"].Trim(); string sql = ""; object[] param = new object[1]; if (!string.IsNullOrEmpty(kw)) { sql = " categoryName.Contains(@0)"; param[0] = kw; } if (!ProCat1.CurrentCategoryID.Equals(0)) { sql += " and parentID=" + ProCat1.CurrentCategoryID; } BindDate(sql, param); }catch (Exception ex) { Common.WriteLog.SetErrLog(Request.Url.ToString(), "Button1_Click", ex.Message); Common.MessageBox.Show(this, "搜索发生意外。" + ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; try { var bl = new DS_SysProductCategory_Br(); var prtbl = new DS_Property_Br(); var diybl = new DS_DiyProCategory_Br(); var probl = new DS_Products_Br(); var ud = _userData; if (string.IsNullOrEmpty(Request["action"])) { var mst = this.Master as Member_Manage_MasterPage; mst.SetMenuTitle("供应管理", "发布供应信息"); var list = bl.Query<temClass>("select id,categoryName,(select count(id) from DS_SysProductCategory where parentid=c.id) as sc from DS_SysProductCategory c where parentid=0 order by px"); Repeater1.DataSource = list; Repeater1.DataBind(); //自定义分类 Repeater2.DataSource = diybl.Query("MemberID=@0","px",ud.Member.ID); Repeater2.DataBind(); //常用系统分类 Repeater3.DataSource = probl.Query<int>("select syscatid from ds_products where memberid={0} group by syscatid",ud.Member.ID); Repeater3.DataBind(); } else {//如果存在动作 string act = Request["action"]; switch (act) { case "subcat"://获取子类目 var list = bl.Query<temClass>("select id,categoryName,(select count(id) from DS_SysProductCategory where parentid=c.id) as sc from DS_SysProductCategory c where parentid=" + Request.QueryString["pid"] + " order by px"); string str = ""; foreach (var item in list) { str += "<li cid=\"" + item.id + "\" class=\"" + (item.sc > 0 ? "hassub" : "") + "\">" + item.categoryName + "</li>"; } Response.Write(str); Response.End(); break; case "property"://获取分类属性 Response.Write(prtbl.GetControlList(int.Parse(Request["cid"]))); Response.End(); break; case "addcat": var md = diybl.CreateModel(); md.CategoryName = Request.QueryString["catname"]; md.Px = 0; md.MemberID = ud.Member.ID; diybl.Add(md); diybl.Sort(md.ID, true); Response.Write("id=" + md.ID); Response.End(); break; case "add"://发布产品 var product = probl.CreateModel(); product.MemberID = ud.Member.ID; product.SysCatID = int.Parse(Request.Form["sysCatID"]); product.ShopCatID = int.Parse(Request.Form["shopCat"]); product.Title = Request.Form["proTitle"]; product.Img1 = Request.Form["img00"]; product.Img2 = Request.Form["img01"]; product.Img3 = Request.Form["img02"]; product.Unit=Request.Form["unit"]; Type t = product.GetType(); for (int i = 1; i <=24; i++) { t.GetProperty("Property" + i).SetValue(product, Request.Form["property" + i], null); } product.Detail=Server.UrlDecode(Request.Form["detail"]); product.PriceRang=Request.Form["priceRang"]; if(!string.IsNullOrEmpty(Request.Form["maxNumber"])){ product.MaxNumber =int.Parse(Request.Form["maxNumber"]); } product.LowPrice = double.Parse(Request.Form["lowPrice"]); product.HeightPrice = double.Parse(Request.Form["heightPrice"]); product.CreateDate = DateTime.Now; product.ExpiredDate = DateTime.Now.AddDays(int.Parse(Request.Form["expiredDate"])); product.State = (byte)DS_Products_Br.State.待审中; probl.Add(product); Response.Write(true); Response.End(); break; case "edit"://修改产品 product = probl.GetSingle(int.Parse(Request.Form["id"])); product.SysCatID = int.Parse(Request.Form["sysCatID"]); product.ShopCatID = int.Parse(Request.Form["shopCat"]); product.Title = Request.Form["proTitle"]; product.Img1 = Request.Form["img00"]; product.Img2 = Request.Form["img01"]; product.Img3 = Request.Form["img02"]; product.Unit = Request.Form["unit"]; t = product.GetType(); for (int i = 1; i <= 24; i++) { t.GetProperty("Property" + i).SetValue(product, Request.Form["property" + i], null); } product.Detail = Server.UrlDecode(Request.Form["detail"]); product.PriceRang = Request.Form["priceRang"]; if (!string.IsNullOrEmpty(Request.Form["maxNumber"])) { product.MaxNumber = int.Parse(Request.Form["maxNumber"]); } product.LowPrice = double.Parse(Request.Form["lowPrice"]); product.HeightPrice = double.Parse(Request.Form["heightPrice"]); product.CreateDate = DateTime.Now; product.ExpiredDate = DateTime.Now.AddDays(int.Parse(Request.Form["expiredDate"])); product.State = (byte)DS_Products_Br.State.待审中; probl.Update(product); Response.Write(true); Response.End(); break; case "json"://返回对象的json数据 var json = new JavaScriptSerializer(); var promd = probl.GetSingle(int.Parse(Request["ID"])); string js = json.Serialize(promd); Response.ContentType = "application/json"; Response.Write(js); Response.End(); break; } } }catch(System.Threading.ThreadAbortException ex){ } catch (Exception ex) { if (ex.Message.Contains("IX_DS_DiyProCategory")) { Response.Write("已存在相同名称的分类。"); } else Response.Write("出错了。"+ex.Message); Response.End(); } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } try { var bl = new DS_SysProductCategory_Br(); var prtbl = new DS_Property_Br(); var diybl = new DS_DiyProCategory_Br(); var probl = new DS_Products_Br(); var ud = _userData; if (string.IsNullOrEmpty(Request["action"])) { var mst = this.Master as Member_Manage_MasterPage; mst.SetMenuTitle("供应管理", "发布供应信息"); var list = bl.Query <temClass>("select id,categoryName,(select count(id) from DS_SysProductCategory where parentid=c.id) as sc from DS_SysProductCategory c where parentid=0 order by px"); Repeater1.DataSource = list; Repeater1.DataBind(); //自定义分类 Repeater2.DataSource = diybl.Query("MemberID=@0", "px", ud.Member.ID); Repeater2.DataBind(); //常用系统分类 Repeater3.DataSource = probl.Query <int>("select syscatid from ds_products where memberid={0} group by syscatid", ud.Member.ID); Repeater3.DataBind(); } else {//如果存在动作 string act = Request["action"]; switch (act) { case "subcat": //获取子类目 var list = bl.Query <temClass>("select id,categoryName,(select count(id) from DS_SysProductCategory where parentid=c.id) as sc from DS_SysProductCategory c where parentid=" + Request.QueryString["pid"] + " order by px"); string str = ""; foreach (var item in list) { str += "<li cid=\"" + item.id + "\" class=\"" + (item.sc > 0 ? "hassub" : "") + "\">" + item.categoryName + "</li>"; } Response.Write(str); Response.End(); break; case "property": //获取分类属性 Response.Write(prtbl.GetControlList(int.Parse(Request["cid"]))); Response.End(); break; case "addcat": var md = diybl.CreateModel(); md.CategoryName = Request.QueryString["catname"]; md.Px = 0; md.MemberID = ud.Member.ID; diybl.Add(md); diybl.Sort(md.ID, true); Response.Write("id=" + md.ID); Response.End(); break; case "add": //发布产品 var product = probl.CreateModel(); product.MemberID = ud.Member.ID; product.SysCatID = int.Parse(Request.Form["sysCatID"]); product.ShopCatID = int.Parse(Request.Form["shopCat"]); product.Title = Request.Form["proTitle"]; product.Img1 = Request.Form["img00"]; product.Img2 = Request.Form["img01"]; product.Img3 = Request.Form["img02"]; product.Unit = Request.Form["unit"]; Type t = product.GetType(); for (int i = 1; i <= 24; i++) { t.GetProperty("Property" + i).SetValue(product, Request.Form["property" + i], null); } product.Detail = Server.UrlDecode(Request.Form["detail"]); product.PriceRang = Request.Form["priceRang"]; if (!string.IsNullOrEmpty(Request.Form["maxNumber"])) { product.MaxNumber = int.Parse(Request.Form["maxNumber"]); } product.LowPrice = double.Parse(Request.Form["lowPrice"]); product.HeightPrice = double.Parse(Request.Form["heightPrice"]); product.CreateDate = DateTime.Now; product.ExpiredDate = DateTime.Now.AddDays(int.Parse(Request.Form["expiredDate"])); product.State = (byte)DS_Products_Br.State.待审中; probl.Add(product); Response.Write(true); Response.End(); break; case "edit": //修改产品 product = probl.GetSingle(int.Parse(Request.Form["id"])); product.SysCatID = int.Parse(Request.Form["sysCatID"]); product.ShopCatID = int.Parse(Request.Form["shopCat"]); product.Title = Request.Form["proTitle"]; product.Img1 = Request.Form["img00"]; product.Img2 = Request.Form["img01"]; product.Img3 = Request.Form["img02"]; product.Unit = Request.Form["unit"]; t = product.GetType(); for (int i = 1; i <= 24; i++) { t.GetProperty("Property" + i).SetValue(product, Request.Form["property" + i], null); } product.Detail = Server.UrlDecode(Request.Form["detail"]); product.PriceRang = Request.Form["priceRang"]; if (!string.IsNullOrEmpty(Request.Form["maxNumber"])) { product.MaxNumber = int.Parse(Request.Form["maxNumber"]); } product.LowPrice = double.Parse(Request.Form["lowPrice"]); product.HeightPrice = double.Parse(Request.Form["heightPrice"]); product.CreateDate = DateTime.Now; product.ExpiredDate = DateTime.Now.AddDays(int.Parse(Request.Form["expiredDate"])); product.State = (byte)DS_Products_Br.State.待审中; probl.Update(product); Response.Write(true); Response.End(); break; case "json": //返回对象的json数据 var json = new JavaScriptSerializer(); var promd = probl.GetSingle(int.Parse(Request["ID"])); string js = json.Serialize(promd); Response.ContentType = "application/json"; Response.Write(js); Response.End(); break; } } }catch (System.Threading.ThreadAbortException ex) { } catch (Exception ex) { if (ex.Message.Contains("IX_DS_DiyProCategory")) { Response.Write("已存在相同名称的分类。"); } else { Response.Write("出错了。" + ex.Message); } Response.End(); } }
protected void LinkButtonPx_Click(object sender, EventArgs e) { var lb = (LinkButton)sender; var bl = new DS_SysProductCategory_Br(); bl.Sort(int.Parse(lb.Attributes["pid"]), bool.Parse(lb.Attributes["cn"])); AspNetPager_PageChanged(null, null); }
private void DropDownList2_SelectedIndexChanged(object sender, EventArgs e) { ToolBar1.AspNetPager.PageChanged -= new EventHandler(AspNetPager_PageChanged); ToolBar1.AspNetPager.CurrentPageIndex = 1; var bl = new DS_SysProductCategory_Br(); if (ProCat1.CategoryID_2.Equals(0)) { BindDate("parentid=" + ProCat1.CategoryID_1); } else { BindDate("parentid=" + ProCat1.CategoryID_2); } }
private void Button1_Click(object sender, EventArgs e) { try { var bl = new DS_SysProductCategory_Br(); string kw=Request.Form["keyword"].Trim(); string sql = ""; object[] param=new object[1]; if (!string.IsNullOrEmpty(kw)) { sql = " categoryName.Contains(@0)"; param[0] = kw; } if (!ProCat1.CurrentCategoryID.Equals(0)) { sql += " and parentID="+ProCat1.CurrentCategoryID; } BindDate(sql,param); }catch(Exception ex){ Common.WriteLog.SetErrLog(Request.Url.ToString(), "Button1_Click", ex.Message); Common.MessageBox.Show(this,"搜索发生意外。"+ex.Message); } }