protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) return; BasePage =this.Page as ShopBasePage; var bl = new DS_DiyProCategory_Br(); int rc = 0; Repeater1.DataSource = bl.Query("memberid=@0", "px", 0, 10, ref rc, BasePage._vMember.ID); Repeater1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } BasePage = this.Page as ShopBasePage; var bl = new DS_DiyProCategory_Br(); int rc = 0; Repeater1.DataSource = bl.Query("memberid=@0", "px", 0, 10, ref rc, BasePage._vMember.ID); Repeater1.DataBind(); }
protected void Page_Load(object sender, EventArgs e) { AspNetPager4.PageChanged += new EventHandler(AspNetPager4_PageChanged); if (IsPostBack) { return; } //分类 var bl = new DS_DiyProCategory_Br(); var list = bl.Query <temClass>("select id,categoryname,(select count(id) from ds_products where shopcatid=ds_DiyProCategory.id) as pcount from ds_DiyProCategory where memberid={0}", _vMember.ID); Repeater1.DataSource = list; Repeater1.DataBind(); //产品 string cat_id = Request.QueryString["cat_id"], proname = Request.QueryString["pro_name"], low_price = Request.QueryString["low_price"], height_price = Request.QueryString["height_price"]; if (!string.IsNullOrEmpty(cat_id)) { BindDate("ShopCatID=@0", int.Parse(cat_id)); } else if (!string.IsNullOrEmpty(proname) || !string.IsNullOrEmpty(low_price) || !string.IsNullOrEmpty(height_price)) { object[] param = { _vMember.ID, 0.0, 0.0, "" }; string sql = "memberid=@0"; if (!string.IsNullOrEmpty(low_price)) { sql += " and lowprice>@1"; param[1] = double.Parse(low_price) - 0.01; } if (!string.IsNullOrEmpty(height_price)) { sql += " and heightprice<@2"; param[2] = double.Parse(height_price) + 0.01; } if (!string.IsNullOrEmpty(proname)) { sql += " and Title.Contains(@3)"; param[3] = proname; } sql = sql.Trim().TrimStart('a', 'n', 'd'); BindDate(sql, param); } else { BindDate("memberid=@0", _vMember.ID); } }
protected void Page_Load(object sender, EventArgs e) { AspNetPager4.PageChanged+=new EventHandler(AspNetPager4_PageChanged); if (IsPostBack) return; //分类 var bl = new DS_DiyProCategory_Br(); var list = bl.Query<temClass>("select id,categoryname,(select count(id) from ds_products where shopcatid=ds_DiyProCategory.id) as pcount from ds_DiyProCategory where memberid={0}", _vMember.ID); Repeater1.DataSource = list; Repeater1.DataBind(); //产品 string cat_id=Request.QueryString["cat_id"],proname=Request.QueryString["pro_name"],low_price=Request.QueryString["low_price"],height_price=Request.QueryString["height_price"]; if (!string.IsNullOrEmpty(cat_id)) { BindDate("ShopCatID=@0", int.Parse(cat_id)); } else if (!string.IsNullOrEmpty(proname) || !string.IsNullOrEmpty(low_price) || !string.IsNullOrEmpty(height_price)) { object[] param = { _vMember.ID, 0.0, 0.0, "" }; string sql = "memberid=@0"; if (!string.IsNullOrEmpty(low_price)) { sql += " and lowprice>@1"; param[1] = double.Parse(low_price) - 0.01; } if (!string.IsNullOrEmpty(height_price)) { sql += " and heightprice<@2"; param[2] = double.Parse(height_price) + 0.01; } if (!string.IsNullOrEmpty(proname)) { sql += " and Title.Contains(@3)"; param[3] = proname; } sql = sql.Trim().TrimStart('a','n','d'); BindDate(sql,param); } else { BindDate("memberid=@0", _vMember.ID); } }
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) { var ud = Session["UserData"] as UserData; var bl = new DS_DiyProCategory_Br(); //处理ajax事件 if (!string.IsNullOrEmpty(Request.Form["action"])) { string act = Request.Form["action"]; switch (act) { case "add": try { var md = bl.CreateModel(); md.CategoryName = Request.Form["catname"]; md.MemberID = ud.Member.ID; md.Px = 0; bl.Add(md); bl.Sort(md.ID, true); } catch (System.Threading.ThreadAbortException ae) { } catch (Exception ex) { if (ex.Message.Contains("IX_DS_DiyProCategory")) { throw new Exception("已存在相同分类。"); } else { throw new Exception("添加分类出错。"); } } break; case "update": try { var md = bl.GetSingle(int.Parse(Request.Form["cid"])); md.CategoryName = Request.Form["catname"]; bl.Update(md); } catch (System.Threading.ThreadAbortException ae) { } catch (Exception ex) { if (ex.Message.Contains("IX_DS_DiyProCategory")) { throw new Exception("已存在相同分类。"); } else { throw new Exception("修改分类出错。"); } } break; case "del": try { bl.Delete(int.Parse(Request.Form["cid"])); } catch (System.Threading.ThreadAbortException ae) { } catch (Exception ex) { if (ex.Message.Contains("FK_DS_Products_DS_DiyProCategory")) { throw new Exception("存在与当前分类相关的产品,必须先删除该分类的产品才能删除此分类。"); } else { throw new Exception("删除分类出错。"); } } break; } } if (IsPostBack) { return; } var mst = this.Master as Member_Manage_MasterPage; mst.SetMenuTitle("供应管理", "产品自定义分类"); Repeater1.DataSource = bl.Query("memberid=@0", "px", ud.Member.ID); Repeater1.DataBind(); }
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(); } }