public HttpResponseBase GetBannerCateBrand() { string json = "{success:true}"; _cateBrandMgr = new ProductCategoryBrandMgr(mySqlConnectionString); _productCategoryBannerImplMgr = new ProductCategoryBannerMgr(mySqlConnectionString); _parameterMgr = new ParameterMgr(mySqlConnectionString); try { if (!string.IsNullOrEmpty(Request.Params["banner_cateid"].ToString())) { uint isTryUint = 0; if (uint.TryParse(Request.Params["banner_cateid"].ToString(), out isTryUint)) { int banner_cateid = Convert.ToInt32(Request.Params["banner_cateid"].ToString()); //獲取新館類別 uint XGCateId = _productCategoryBannerImplMgr.GetXGCate().FirstOrDefault().category_id;//獲取754 prodCateMgr = new ProductCategoryMgr(mySqlConnectionString);//實例化對象mgr List<ProductCategory> category = prodCateMgr.QueryAll(new ProductCategory { category_display = 1 });//獲取所有的類別 包括隱藏和顯示的 List<ProductCategory> cateXGlist = new List<ProductCategory>();//設定對象保存新館所有類別 GetAllCategory_idList(category, XGCateId, ref cateXGlist);//獲取所有新館類別 List<Parametersrc> pali = _parameterMgr.GetElementType("banner_cate"); List<ProductCategoryBrand> XGCateBrandResult = new List<ProductCategoryBrand>(); if (pali.Count != 0) { if (cateXGlist != null) { List<ProductCategory> query = category.FindAll(p => p.category_id == banner_cateid).ToList();//判斷是否是類別專區 List<ProductCategoryBrand> ProList = new List<ProductCategoryBrand>(); if (query.Count != 0) //新館專區類別設定 { ProList = _cateBrandMgr.GetSaledProduct(XGCateId, banner_cateid);//獲取所有有效商品 以及對應的品牌和館別 } else { ProList = _cateBrandMgr.GetProductByCondi(XGCateId, banner_cateid); } //ProList = _cateBrandMgr.GetSaledProduct(XGCateId);//獲取所有有效商品 foreach (ProductCategoryBrand itemcate in ProList) { ProductCategory querySingle = cateXGlist.Find(p => p.category_id == itemcate.category_id); if (querySingle != null) { itemcate.category_name = querySingle.category_name; XGCateBrandResult.Add(itemcate); GetFatherCateBrand(cateXGlist, XGCateId, itemcate, ref XGCateBrandResult); } } json = "{success:true,item:" + JsonConvert.SerializeObject(XGCateBrandResult, Formatting.Indented) + "}";//返回json數據 } } } } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase SaveCateBrand() { string json = "{success:false}"; _cateBrandMgr = new ProductCategoryBrandMgr(mySqlConnectionString); string insertValues = string.Empty; try { if (!string.IsNullOrEmpty(Request.Params["banner_cateid"])) { int banner_cate_id = Convert.ToInt32(Request.Params["banner_cateid"].ToString()); if (!string.IsNullOrEmpty(Request.Params["insertValues"])) { insertValues = Request.Params["insertValues"].ToString(); insertValues = Server.HtmlDecode(insertValues); string[] values = insertValues.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); if (_cateBrandMgr.InsertCateBrand(values, banner_cate_id)) { json = "{success:true}"; } else { json = "{success:false}"; } } else { bool b = _cateBrandMgr.DeleteCateBrand(banner_cate_id); if (b) { json = "{success:true}"; } } } } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:false}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }
public HttpResponseBase GetCateBrandList() { List<ProductCategoryBrandQuery> store = new List<ProductCategoryBrandQuery>(); _cateBrandMgr = new ProductCategoryBrandMgr(mySqlConnectionString); string json = string.Empty; try { ProductCategoryBrandQuery query = new ProductCategoryBrandQuery(); query.Start = Convert.ToInt32(Request["Start"] ?? "0"); if (!string.IsNullOrEmpty(Request["Limit"])) { query.Limit = Convert.ToInt32(Request["Limit"]); } if (!string.IsNullOrEmpty(Request.Params["searchCate"])) { uint cate_id = 0; if (uint.TryParse(Request.Params["searchCate"].ToString(), out cate_id)) { query.category_id = cate_id; } else { query.category_name = Request.Params["searchCate"].ToString(); } } if (!string.IsNullOrEmpty(Request.Params["searchBrand"])) { uint brand_id = 0; if (uint.TryParse(Request.Params["searchBrand"].ToString(), out brand_id)) { query.brand_id = brand_id; } else { query.brand_name = Request.Params["searchBrand"].ToString(); } } if (!string.IsNullOrEmpty(Request.Params["banner_id"])) { query.banner_cate_id = Convert.ToInt32(Request.Params["banner_id"]); } _proCategoryImplMgr = new CategoryMgr(mySqlConnectionString); int totalCount = 0; store = _cateBrandMgr.GetCateBrandList(query, out totalCount); IsoDateTimeConverter timeConverter = new IsoDateTimeConverter(); //这里使用自定义日期格式,如果不使用的话,默认是ISO8601格式 timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm:ss"; json = "{success:true,totalCount:" + totalCount + ",data:" + JsonConvert.SerializeObject(store, Formatting.Indented, timeConverter) + "}";//返回json數據 } catch (Exception ex) { Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage(); logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message); logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name; log.Error(logMessage); json = "{success:true,totalCount:0,data:[]}"; } this.Response.Clear(); this.Response.Write(json); this.Response.End(); return this.Response; }