public List<ProductCategoryBrandQuery> GetCateBrandList(ProductCategoryBrandQuery cateBeandQuery, out int totalCount) { try { return cateBrandDao.GetCateBrandList(cateBeandQuery, out totalCount); } catch (Exception ex) { throw new Exception("ProductCategoryBrandMgr-->GetCateBrandList" + ex.Message, ex); } }
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; }
public List<ProductCategoryBrandQuery> GetCateBrandList(ProductCategoryBrandQuery cateBrandQuery, out int totalCount) { StringBuilder sql = new StringBuilder(); StringBuilder sqlTotal = new StringBuilder(); StringBuilder sqlCondition = new StringBuilder(); totalCount = 0; try { sqlTotal.Append(" SELECT DISTINCT row_id,banner_cate_id, et.parameterName 'banner_catename',category_id,category_name,category_father_id,category_father_name,depth,pcb.brand_id,vb.brand_name,createdate "); sql.Append(" from product_category_brand pcb "); sql.Append("LEFT JOIN vendor_brand vb on vb.brand_id=pcb.brand_id"); sql.Append(" LEFT JOIN (select parameterCode,parameterName,parameterType,parameterProperty from t_parametersrc where parameterType='banner_cate' and used=1 ) et on et.parameterCode=pcb.banner_cate_id"); if (cateBrandQuery.brand_id != 0) { if (string.IsNullOrEmpty(sqlCondition.ToString())) { sqlCondition.AppendFormat(" where vb.brand_id='{0}' ", cateBrandQuery.brand_id); } else { sqlCondition.AppendFormat(" and vb.brand_id='{0}' ", cateBrandQuery.brand_id); } } if (!string.IsNullOrEmpty(cateBrandQuery.brand_name)) { if (string.IsNullOrEmpty(sqlCondition.ToString())) { sqlCondition.AppendFormat(" where vb.brand_name like N'%{0}%' ", cateBrandQuery.brand_name); } else { sqlCondition.AppendFormat(" and vb.brand_name like N'%{0}%' ", cateBrandQuery.brand_name); } } if (cateBrandQuery.category_id != 0) { if (string.IsNullOrEmpty(sqlCondition.ToString())) { sqlCondition.AppendFormat(" where category_id='{0}' ", cateBrandQuery.category_id); } else { sqlCondition.AppendFormat(" and category_id='{0}' ", cateBrandQuery.category_id); } } if (!string.IsNullOrEmpty(cateBrandQuery.category_name)) { if (string.IsNullOrEmpty(sqlCondition.ToString())) { sqlCondition.AppendFormat(" where category_name like N'%{0}%' ", cateBrandQuery.category_name); } else { sqlCondition.AppendFormat(" and category_name like N'%{0}%' ", cateBrandQuery.category_name); } } if (cateBrandQuery.banner_cate_id != 0) { if (string.IsNullOrEmpty(sqlCondition.ToString())) { sqlCondition.AppendFormat(" where banner_cate_id='{0}' ", cateBrandQuery.banner_cate_id); } else { sqlCondition.AppendFormat(" and banner_cate_id='{0}' ", cateBrandQuery.banner_cate_id); } } if (cateBrandQuery.IsPage) { DataTable dt = _access.getDataTable(" SELECT count(row_id) as totalCount" + sql.ToString() + sqlCondition.ToString()); if (dt != null && dt.Rows.Count > 0) { totalCount = Convert.ToInt32(dt.Rows[0]["totalCount"]); } sqlCondition.AppendFormat(@" LIMIT {0},{1} ", cateBrandQuery.Start, cateBrandQuery.Limit); } return _access.getDataTableForObj<ProductCategoryBrandQuery>(sqlTotal.ToString() + sql.ToString() + sqlCondition.ToString()); } catch (Exception ex) { throw new Exception("ProductCategoryBrandDao-->GetCateBrandList" + ex.Message + sqlTotal.ToString() + sql.ToString() + sqlCondition.ToString(), ex); } }