//根据配送地址II类型ID得到配送地址II类型信息 public static categoryinfo getdeliveryIIinfo(int id) { SqlParameter[] parms = new SqlParameter[2]; parms[0] = new SqlParameter("@id", SqlDbType.Int); parms[0].Value = id; string sql = "select a.deliveryIIid,a.deliveryII,b.deliveryI,b.deliveryIid from deliveryII a,deliveryI b where a.deliveryIid=b.deliveryIid and a.deliveryIIid=@id"; categoryinfo item = new categoryinfo(); SqlDataReader dr = null; try { dr = SqlHelper.ExecuteReader(SqlHelper.connectionstring, CommandType.Text, sql, parms); if (dr.Read()) { item.deliveryIIid = TypeParse.DbObjToInt(dr["deliveryIIid"].ToString(), 0); item.deliveryII = TypeParse.DbObjToString(dr["deliveryII"].ToString(), ""); item.deliveryIid = TypeParse.DbObjToInt(dr["deliveryIid"].ToString(), 0); item.deliveryI = TypeParse.DbObjToString(dr["deliveryI"].ToString(), ""); dr.Close(); dr.Dispose(); } } catch (Exception ex) { throw new Exception(ex.Message); } finally { } return(item); }
//根据大类别ID得到大类别信息 public static categoryinfo getbigcategoryinfo(int id) { SqlParameter[] parms = new SqlParameter[1]; parms[0] = new SqlParameter("@id", SqlDbType.Int); parms[0].Value = id; string sql = "select bigcategoryid,bigcategory,bigcategoryimg from bigcategory where bigcategoryid=@id"; categoryinfo item = new categoryinfo(); SqlDataReader dr = null; try { dr = SqlHelper.ExecuteReader(SqlHelper.connectionstring, CommandType.Text, sql, parms); if (dr.Read()) { item.bigcategoryid = TypeParse.DbObjToInt(dr["bigcategoryid"].ToString(), 0); item.bigcategory = TypeParse.DbObjToString(dr["bigcategory"].ToString(), ""); item.bigcategoryimg = TypeParse.DbObjToString(dr["bigcategoryimg"].ToString(), ""); dr.Close(); dr.Dispose(); } } catch (Exception ex) { throw new Exception(ex.Message); } finally { } return(item); }
//得到配送地址II类型列表通过Iid public static List <categoryinfo> getdeliveryIIbyID(int id) { SqlParameter[] parms = new SqlParameter[1]; parms[0] = new SqlParameter("@id", SqlDbType.Int); parms[0].Value = id; string sql = "select a.deliveryIIid,a.deliveryII,b.deliveryI,b.deliveryIid from deliveryII a,deliveryI b where a.deliveryIid=b.deliveryIid and a.deliveryIid=@id"; List <categoryinfo> itlist = new List <categoryinfo>(); try { DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.connectionstring, CommandType.Text, sql, parms); foreach (DataRow dr in ds.Tables[0].Rows) { categoryinfo item = new categoryinfo(); item.deliveryIIid = TypeParse.DbObjToInt(dr["deliveryIIid"].ToString(), 0); item.deliveryII = TypeParse.DbObjToString(dr["deliveryII"].ToString(), ""); item.deliveryIid = TypeParse.DbObjToInt(dr["deliveryIid"].ToString(), 0); item.deliveryI = TypeParse.DbObjToString(dr["deliveryI"].ToString(), ""); itlist.Add(item); } } catch (Exception ex) { throw new Exception(ex.Message); } finally { } return(itlist); }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["scid"] != null) { int iscid = TypeParse.DbObjToInt(Request.QueryString["scid"].ToString(), 0); categoryinfo data = category.getsmallcategoryinfo(iscid); if (!Page.IsPostBack) { List <categoryinfo> gylist = category.getbigcategory(); bcID.DataSource = gylist; bcID.DataValueField = "bigcategoryid"; bcID.DataTextField = "bigcategory"; bcID.DataBind(); for (int i = 0; i < bcID.Items.Count; i++) { if (bcID.Items[i].Value == data.bigcategoryid.ToString()) { bcID.SelectedIndex = i; } } smallcategory.Value = data.smallcategory; smallcategoryid.Value = data.smallcategoryid.ToString(); } } }
//通过大分类得到产品小类别 public static List <categoryinfo> getsmallcategorybyid(int bigcategoryid) { SqlParameter[] parms = new SqlParameter[1]; parms[0] = new SqlParameter("@bigcategoryid", SqlDbType.Int); parms[0].Value = bigcategoryid; string sql = "select a.smallcategoryid,a.smallcategory,a.bigcategoryid,b.bigcategory from smallcategory a,bigcategory b where a.bigcategoryid=b.bigcategoryid and b.bigcategoryid=@bigcategoryid"; List <categoryinfo> itlist = new List <categoryinfo>(); try { DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.connectionstring, CommandType.Text, sql, parms); foreach (DataRow dr in ds.Tables[0].Rows) { categoryinfo item = new categoryinfo(); item.smallcategoryid = TypeParse.DbObjToInt(dr["smallcategoryid"].ToString(), 0); item.smallcategory = TypeParse.DbObjToString(dr["smallcategory"].ToString(), ""); item.bigcategoryid = TypeParse.DbObjToInt(dr["bigcategoryid"].ToString(), 0); item.bigcategory = TypeParse.DbObjToString(dr["bigcategory"].ToString(), ""); itlist.Add(item); } } catch (Exception ex) { throw new Exception(ex.Message); } finally { } return(itlist); }
//编辑产品小类别 public static bool editsmallcategory(categoryinfo data) { SqlParameter[] parms = new SqlParameter[3]; parms[0] = new SqlParameter("@smallcategory", SqlDbType.VarChar, 20); parms[0].Value = data.smallcategory; parms[1] = new SqlParameter("@bigcategoryid", SqlDbType.Int); parms[1].Value = data.bigcategoryid; parms[2] = new SqlParameter("@smallcategoryid", SqlDbType.Int); parms[2].Value = data.smallcategoryid; string sql = "update smallcategory set smallcategory=@smallcategory,bigcategoryid=@bigcategoryid where smallcategoryid=@smallcategoryid"; int result = 0; try { result = SqlHelper.ExecuteNonQuery(SqlHelper.connectionstring, CommandType.Text, sql, parms); } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { } return(result > 0); }
//编辑配送地址II类型 public static bool editdeliveryII(categoryinfo data) { SqlParameter[] parms = new SqlParameter[3]; parms[0] = new SqlParameter("@deliveryII", SqlDbType.NVarChar, 20); parms[0].Value = data.deliveryII; parms[1] = new SqlParameter("@deliveryIIid", SqlDbType.Int); parms[1].Value = data.deliveryIIid; parms[2] = new SqlParameter("@deliveryIid", SqlDbType.Int); parms[2].Value = data.deliveryIid; string sql = "update deliveryII set deliveryII=@deliveryII,deliveryIid=@deliveryIid where deliveryIIid=@deliveryIIid"; int result = 0; try { result = SqlHelper.ExecuteNonQuery(SqlHelper.connectionstring, CommandType.Text, sql, parms); } catch (Exception ex) { Console.WriteLine(ex.Message); } finally { } return(result > 0); }
//得到配送地址I类型列表 public static List <categoryinfo> getdeliveryI() { string sql = "select deliveryIid,deliveryI from deliveryI"; List <categoryinfo> itlist = new List <categoryinfo>(); try { DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.connectionstring, CommandType.Text, sql); foreach (DataRow dr in ds.Tables[0].Rows) { categoryinfo item = new categoryinfo(); item.deliveryIid = TypeParse.DbObjToInt(dr["deliveryIid"].ToString(), 0); item.deliveryI = TypeParse.DbObjToString(dr["deliveryI"].ToString(), ""); itlist.Add(item); } } catch (Exception ex) { throw new Exception(ex.Message); } finally { } return(itlist); }
protected void Page_Load(object sender, EventArgs e) { if (Request.QueryString["bigcategoryid"] != null) { int bcid = TypeParse.DbObjToInt(Request.QueryString["bigcategoryid"].ToString(), 0); categoryinfo data = category.getbigcategoryinfo(bcid); bigcategoryimgHTML = data.bigcategoryimg; if (!Page.IsPostBack) { bigcategoryid.Value = data.bigcategoryid.ToString(); bigcategoryname.Value = data.bigcategory; oimgname.Value = data.bigcategoryimg; } } }
public string editbigcategory(string bcid, string sbigcategory) { categoryinfo data = new categoryinfo(); data.bigcategory = HttpUtility.UrlDecode(TypeParse.DbObjToString(sbigcategory, "")); data.bigcategoryid = TypeParse.DbObjToInt(bcid, 0); bool result = category.editbigcategory(data); if (result) { return("t"); } else { return("f"); } }
public string editdeliveryI(string deliveryIid, string deliveryI) { categoryinfo data = new categoryinfo(); data.deliveryI = HttpUtility.UrlDecode(TypeParse.DbObjToString(deliveryI, "")); data.deliveryIid = TypeParse.DbObjToInt(deliveryIid, 0); bool result = category.editdeliveryI(data); if (result) { return("t"); } else { return("f"); } }
public string adddeliveryI(string deliveryI) { string strbc = HttpUtility.UrlDecode(TypeParse.DbObjToString(deliveryI, "")); categoryinfo data = new categoryinfo(); data.deliveryI = strbc; bool result = category.adddeliveryI(data); if (result) { return("t"); } else { return("f"); } }
public string editplace(string placeid, string place) { categoryinfo data = new categoryinfo(); data.place = HttpUtility.UrlDecode(TypeParse.DbObjToString(place, "")); data.placeid = TypeParse.DbObjToInt(placeid, 0); bool result = category.editplace(data); if (result) { return("t"); } else { return("f"); } }
public string addplace(string place) { string strbc = HttpUtility.UrlDecode(TypeParse.DbObjToString(place, "")); categoryinfo data = new categoryinfo(); data.place = strbc; bool result = category.addplace(data); if (result) { return("t"); } else { return("f"); } }
public string addbigcategory(string sbigcategory) { string strbc = HttpUtility.UrlDecode(TypeParse.DbObjToString(sbigcategory, "")); categoryinfo data = new categoryinfo(); data.bigcategory = strbc; bool result = category.addbigcategory(data); if (result) { return("t"); } else { return("f"); } }
protected void EditBigcategory(object sender, EventArgs e) { string uploadName = imgfile.Value; //获取待上传图片的完整路径,包括文件名 //string uploadName = InputFile.PostedFile.FileName; string pictureName = oimgname.Value.Trim(); //上传后的图片名,以当前时间为文件名,确保文件名没有重复 if (imgfile.Value != "") { int idx = uploadName.LastIndexOf("."); string suffix = uploadName.Substring(idx);//获得上传的图片的后缀名 if (suffix.ToLower() != ".bmp" && suffix.ToLower() != ".jpg" && suffix.ToLower() != ".jpeg" && suffix.ToLower() != ".png" && suffix.ToLower() != ".gif") { imgnote.InnerHtml = "<span style=\"color:red\">上传文件必须是图片格式!</span>"; return; } pictureName = DateTime.Now.Ticks.ToString() + suffix; } try { if (uploadName != "") { string path = Server.MapPath("/Files/WebImages/"); imgfile.PostedFile.SaveAs(path + pictureName); } categoryinfo data = new categoryinfo(); data.bigcategoryimg = pictureName; data.bigcategory = bigcategoryname.Value.Trim(); data.bigcategoryid = TypeParse.DbObjToInt(bigcategoryid.Value, 0); bool result = category.editbigcategory(data); if (result) { Response.Write("<script>alert('修改大目录成功!');location.href='/Manager/BigCategory.aspx';</script>"); return; } else { Response.Write("<script>alert('修改大目录失败!');location.href='/Manager/BigCategory.aspx';</script>"); return; } } catch (Exception ex) { throw new Exception(ex.Message); } }
protected void AddSmallCategory(object sender, EventArgs e) { categoryinfo data = new categoryinfo(); data.smallcategory = smallcategory.Value.Trim(); data.bigcategoryid = TypeParse.DbObjToInt(bcID.SelectedValue, 0); bool result = category.addsmallcategory(data); if (result) { Response.Write("<script>alert('添加产品小类成功!');location.href='/Manager/SmallCategory.aspx';</script>"); return; } else { Response.Write("<script>alert('添加产品小类失败!');location.href='/Manager/SmallCategory.aspx';</script>"); return; } }
//添加配送地址I public static bool adddeliveryI(categoryinfo data) { SqlParameter[] parms = new SqlParameter[2]; parms[0] = new SqlParameter("@deliveryI", SqlDbType.NVarChar, 20); parms[0].Value = data.deliveryI; string sql = "insert into deliveryI (deliveryI) values(@deliveryI)"; int result = 0; try { result = SqlHelper.ExecuteNonQuery(SqlHelper.connectionstring, CommandType.Text, sql, parms); } catch (Exception ex) { throw new Exception(ex.Message); } finally { } return(result > 0); }
//添加产品小类别 public static bool addsmallcategory(categoryinfo data) { SqlParameter[] parms = new SqlParameter[2]; parms[0] = new SqlParameter("@smallcategory", SqlDbType.VarChar, 20); parms[0].Value = data.smallcategory; parms[1] = new SqlParameter("@bigcategoryid", SqlDbType.Int); parms[1].Value = data.bigcategoryid; string sql = "insert into smallcategory (smallcategory,bigcategoryid) values(@smallcategory,@bigcategoryid)"; int result = 0; try { result = SqlHelper.ExecuteNonQuery(SqlHelper.connectionstring, CommandType.Text, sql, parms); } catch (Exception ex) { throw new Exception(ex.Message); } finally { } return(result > 0); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { int page = 1; if (Request.QueryString["page"] != null) { page = TypeParse.DbObjToInt(Request.QueryString["page"].ToString(), 1); } pageinfo pdata = new pageinfo(); pdata.curpageindex = page; pdata.pagesize = 20; if (RouteData.Values["bcid"] != null && RouteData.Values["bcid"].ToString() != "0") { pdata.where = "smallcategory.smallcategoryid=product.smallcategoryid and bigcategory.bigcategoryid=smallcategory.bigcategoryid and place.placeid=product.placeid and product.bigcategoryid=" + RouteData.Values["bcid"].ToString(); pdata.recordcount = product.getproductcountbycondition("product.bigcategoryid=" + RouteData.Values["bcid"].ToString()); categoryinfo data = category.getbigcategoryinfo(TypeParse.DbObjToInt(RouteData.Values["bcid"].ToString(), 0)); ptypeHTML = data.bigcategory; } else if (RouteData.Values["scid"] != null && RouteData.Values["scid"].ToString() != "0") { pdata.where = "smallcategory.smallcategoryid=product.smallcategoryid and bigcategory.bigcategoryid=smallcategory.bigcategoryid and place.placeid=product.placeid and product.smallcategoryid=" + RouteData.Values["scid"].ToString(); pdata.recordcount = product.getproductcountbycondition("product.smallcategoryid=" + RouteData.Values["scid"].ToString()); categoryinfo data = category.getsmallcategoryinfo(TypeParse.DbObjToInt(RouteData.Values["scid"].ToString(), 0)); ptypeHTML = data.smallcategory; } else if (RouteData.Values["placeid"] != null && RouteData.Values["placeid"].ToString() != "0") { pdata.where = "smallcategory.smallcategoryid=product.smallcategoryid and bigcategory.bigcategoryid=smallcategory.bigcategoryid and place.placeid=product.placeid and product.placeid=" + RouteData.Values["placeid"].ToString(); pdata.recordcount = product.getproductcountbycondition("product.placeid=" + RouteData.Values["placeid"].ToString()); categoryinfo data = category.getplaceinfo(TypeParse.DbObjToInt(RouteData.Values["placeid"].ToString(), 0)); ptypeHTML = "水果产地:" + data.place; } else if (RouteData.Values["price"] != null && RouteData.Values["price"].ToString() != "0") { switch (RouteData.Values["price"].ToString()) { case "1": pdata.where = "smallcategory.smallcategoryid=product.smallcategoryid and bigcategory.bigcategoryid=smallcategory.bigcategoryid and place.placeid=product.placeid and product.vipprice>0 and product.vipprice<=50"; pdata.recordcount = product.getproductcountbycondition("product.vipprice>0 and product.vipprice<=50"); ptypeHTML = "价格0到50元水果"; break; case "2": pdata.where = "smallcategory.smallcategoryid=product.smallcategoryid and bigcategory.bigcategoryid=smallcategory.bigcategoryid and place.placeid=product.placeid and product.vipprice>50 and product.vipprice<=100"; pdata.recordcount = product.getproductcountbycondition("product.vipprice>50 and product.vipprice<=100"); ptypeHTML = "价格50到100元水果"; break; case "3": pdata.where = "smallcategory.smallcategoryid=product.smallcategoryid and bigcategory.bigcategoryid=smallcategory.bigcategoryid and place.placeid=product.placeid and product.vipprice>100 and product.vipprice<=200"; pdata.recordcount = product.getproductcountbycondition("product.vipprice>100 and product.vipprice<=200"); ptypeHTML = "价格100到200元水果"; break; case "4": pdata.where = "smallcategory.smallcategoryid=product.smallcategoryid and bigcategory.bigcategoryid=smallcategory.bigcategoryid and place.placeid=product.placeid and product.vipprice>200 and product.vipprice<=500"; pdata.recordcount = product.getproductcountbycondition("product.vipprice>200 and product.vipprice<=500"); ptypeHTML = "价格200到500元水果"; break; case "5": pdata.where = "smallcategory.smallcategoryid=product.smallcategoryid and bigcategory.bigcategoryid=smallcategory.bigcategoryid and place.placeid=product.placeid and product.vipprice>500"; pdata.recordcount = product.getproductcountbycondition("product.vipprice>500"); ptypeHTML = "价格500元以上水果"; break; default: pdata.where = "smallcategory.smallcategoryid=product.smallcategoryid and bigcategory.bigcategoryid=smallcategory.bigcategoryid and place.placeid=product.placeid"; pdata.recordcount = product.getproductcount(); break; } } else if (RouteData.Values["pname"] != null && RouteData.Values["pname"].ToString() != "") { string pname = RouteData.Values["pname"].ToString(); pdata.where = "smallcategory.smallcategoryid=product.smallcategoryid and bigcategory.bigcategoryid=smallcategory.bigcategoryid and place.placeid=product.placeid and product.productname like'%" + RouteData.Values["pname"].ToString() + "%'"; pdata.recordcount = product.getproductcountbycondition("product.productname like '%" + RouteData.Values["pname"].ToString() + "%'"); categoryinfo data = category.getplaceinfo(TypeParse.DbObjToInt(RouteData.Values["placeid"].ToString(), 0)); ptypeHTML = "商品名称:" + pname; } else { pdata.where = "smallcategory.smallcategoryid=product.smallcategoryid and bigcategory.bigcategoryid=smallcategory.bigcategoryid and place.placeid=product.placeid"; pdata.recordcount = product.getproductcount(); } pdata.tablename = "smallcategory,product,bigcategory,place"; pdata.fieldlist = "product.productid,product.productname,product.productprice,product.productcode,product.productbrief,product.productintroduce,product.vipprice,product.productimg,product.smallcategoryid,product.bigcategoryid,product.brand,product.punit,product.adddate,product.editdate,product.salestate,product.placeid,smallcategory.smallcategory,bigcategory.bigcategory,place.place"; pdata.sorttype = 2; pdata.primarykey = "productid"; pdata.totalpagecount = (pdata.recordcount % pdata.pagesize == 0 ? pdata.recordcount / pdata.pagesize : pdata.recordcount / pdata.pagesize + 1); if (pdata.totalpagecount == 0) { pdata.totalpagecount = 1; } List <productinfo> list = product.getproduct(pdata); StringBuilder sb = new StringBuilder(); foreach (productinfo item in list) { string template = "<div class=\"productlistli\"><a href=\"/PInfo/{0}.html\" class=\"plistimg\" title=\"{1}\" target=\"_blank\"><img src=\"/Files/Product/{2}\" /></a> <a href=\"/PInfo/{3}.html\" class=\"plisttitle\" title=\"{4}\" target=\"_blank\">{5}</a> <a href=\"/PInfo/{6}.html\" class=\"plistsite\" target=\"_blank\">规格:{7}</a> <a href=\"/PInfo/{8}.html\" class=\"plistprice\" target=\"_blank\"><span class=\"pricecss1\">¥{9}</span><span class=\"pricecss2\">¥{10}</span>{11}</a></div>"; sb.AppendFormat(template, item.productid, item.productname, item.productimg, item.productid, item.productname, comm.SubStr(item.productname, 15), item.productid, item.punit, item.productid, item.productprice, item.vipprice, item.salestate == 1 ? "<span class=\"sstate\">已售完</span>" : ""); } productlistHTML = sb.ToString(); pageHTML = pagehelper.Pager(pdata.curpageindex, pdata.pagesize, pdata.recordcount, PageMode.Numeric, 5); } }