protected void Page_Load(object sender, EventArgs e) { if (string.IsNullOrEmpty(Request.QueryString["SysCatID"])) { Common.MessageBox.Show(this, "缺少参数", Common.MessageBox.InfoType.warning, "history.back"); return; } int sid = 0; if (!int.TryParse(Request.QueryString["SysCatID"], 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 list = bl.Query <byte>("select mapid from DS_Property where SysCatID=" + Request.QueryString["SysCatID"]); byte[] mapid = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24 }; DropDownList2.DataSource = mapid.Where(a => !list.Contains(a)); DropDownList2.DataBind(); }
private void Button1_Click(object sender, EventArgs e) { try { string pname = cname.Value.Trim(); if (string.IsNullOrEmpty(pname)) { Common.MessageBox.Show(this, "属性名称不能为空", Common.MessageBox.InfoType.warning); return; } var bl = new DS_Property_Br(); var md = bl.GetSingle(int.Parse(Request.QueryString["ID"])); md.ProName = pname; md.ControlType = byte.Parse(DropDownList1.SelectedIndex.ToString()); md.Unit = unit.Value.Trim(); md.Request = CheckBox1.Checked; bl.Update(md); Common.MessageBox.Show(this, "保存成功", Common.MessageBox.InfoType.info, "function(){location='list.aspx?SysCatID=" + md.SysCatID + "'}"); }catch (Exception ex) { Common.WriteLog.SetErrLog(Request.Url.ToString(), "Button1_Click", ex.Message); if (ex.Message.Contains("IX_DS_Property")) { 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 { string pname = cname.Value.Trim(); if (string.IsNullOrEmpty(pname)) { Common.MessageBox.Show(this,"属性名称不能为空",Common.MessageBox.InfoType.warning); return; } if (DropDownList2.Items.Count.Equals(0)) { Common.MessageBox.Show(this, "映射序号已用完,不能继续添加", Common.MessageBox.InfoType.warning); return; } var bl = new DS_Property_Br(); var md = bl.CreateModel(); md.ProName = pname; md.SysCatID = int.Parse(Request.QueryString["SysCatID"]); md.ControlType =byte.Parse(DropDownList1.SelectedIndex.ToString()); md.Unit = unit.Value.Trim(); md.MapID =byte.Parse(DropDownList2.SelectedValue); md.Request = CheckBox1.Checked; md.Px = 0; bl.Add(md); bl.Sort(md.ID,true); Common.MessageBox.Show(this, "保存成功", Common.MessageBox.InfoType.info, "function(){location='list.aspx?SysCatID="+md.SysCatID+"'}"); }catch(Exception ex){ Common.WriteLog.SetErrLog(Request.Url.ToString(), "Button1_Click", ex.Message); if (ex.Message.Contains("IX_DS_Property")) { Common.MessageBox.Show(this, "已存在相同的分类名称", Common.MessageBox.InfoType.error); return; } Common.MessageBox.Show(this, "保存发生意外,请联系管理人员解决。"+ex.Message, Common.MessageBox.InfoType.error); } }
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; } var bl = new DS_PropertyValue_Br(); var md = bl.GetSingle(int.Parse(Request.QueryString["ID"])); proVal.Value = md.PropertyValue; var bl2 = new DS_Property_Br(); var md2 = bl2.GetSingle(md.PropertyID); ViewState["proName"] = md2.ProName; }
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('>'); }
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('>'); }
protected void LinkButtonPx_Click(object sender, EventArgs e) { var lb = (LinkButton)sender; var bl = new DS_Property_Br(); bl.Sort(int.Parse(lb.Attributes["pid"]), bool.Parse(lb.Attributes["cn"])); AspNetPager_PageChanged(null, null); }
private void BindDate(string sql, params object[] param) { ViewState["sql"] = sql; int pageCount = 0; var bl = new DS_Property_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(); }
private void BindDate(string sql, params object[] param) { ViewState["sql"] = sql; int pageCount = 0; var bl = new DS_Property_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(); }
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_Property_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 Button1_Click(object sender, EventArgs e) { try { var bl = new DS_Property_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; } 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 (string.IsNullOrEmpty(Request.QueryString["ProID"])) { Common.MessageBox.Show(this, "缺少参数", Common.MessageBox.InfoType.warning, "history.back"); return; } int sid = 0; if (!int.TryParse(Request.QueryString["ProID"], out sid)) { Common.MessageBox.Show(this, "参数无效", Common.MessageBox.InfoType.warning, "history.back"); return; } Button1.Click+=new EventHandler(Button1_Click); if (IsPostBack) return; var bl = new DS_Property_Br(); var md = bl.GetSingle(int.Parse(Request.QueryString["ProID"])); ViewState["proName"] = md.ProName; }
protected void Page_Load(object sender, EventArgs e) { if (Product != null) { var bl = new DS_Property_Br(); var list = bl.Query("SysCatID=@0", "px", Product.SysCatID); Type t = Product.GetType(); int PryCount = 0; foreach (var item in list) { object obj =t.GetProperty("Property" + item.MapID).GetValue(Product,null); if (obj != null&&!string.IsNullOrEmpty(obj.ToString().Trim())) { AddItem(item.ProName,obj.ToString()+item.Unit);//添加一项属性 PryCount++; } } if(PryCount%2>0)//如果有效属性个数为单数,则最后要多添加一个空属性 AddItem("",""); } }
protected void Page_Load(object sender, EventArgs e) { if (Product != null) { var bl = new DS_Property_Br(); var list = bl.Query("SysCatID=@0", "px", Product.SysCatID); Type t = Product.GetType(); int PryCount = 0; foreach (var item in list) { object obj = t.GetProperty("Property" + item.MapID).GetValue(Product, null); if (obj != null && !string.IsNullOrEmpty(obj.ToString().Trim())) { AddItem(item.ProName, obj.ToString() + item.Unit);//添加一项属性 PryCount++; } } if (PryCount % 2 > 0)//如果有效属性个数为单数,则最后要多添加一个空属性 { AddItem("", ""); } } }
protected void Page_Load(object sender, EventArgs e) { if (string.IsNullOrEmpty(Request.QueryString["SysCatID"])) { Common.MessageBox.Show(this, "缺少参数", Common.MessageBox.InfoType.warning, "history.back"); return; } int sid = 0; if (!int.TryParse(Request.QueryString["SysCatID"], 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 list = bl.Query<byte>("select mapid from DS_Property where SysCatID=" + Request.QueryString["SysCatID"]); byte[] mapid={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24}; DropDownList2.DataSource = mapid.Where(a => !list.Contains(a)); DropDownList2.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(); } }
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_Property_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 Button1_Click(object sender, EventArgs e) { try { var bl = new DS_Property_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; } BindDate(sql,param); }catch(Exception ex){ Common.WriteLog.SetErrLog(Request.Url.ToString(), "Button1_Click", ex.Message); Common.MessageBox.Show(this,"搜索发生意外。"+ex.Message); } }
protected void LinkButtonPx_Click(object sender, EventArgs e) { var lb = (LinkButton)sender; var bl = new DS_Property_Br(); bl.Sort(int.Parse(lb.Attributes["pid"]), bool.Parse(lb.Attributes["cn"])); AspNetPager_PageChanged(null, null); }
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(); } }