/// <summary> /// 页面加载方法 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { CheckAdminPower("ReadProductBrand", PowerCheckType.Single); ProductBrandSearchInfo brandSearch = new ProductBrandSearchInfo(); brandSearch.Key = RequestHelper.GetQueryString <string>("Key"); brandSearch.IsTop = RequestHelper.GetQueryString <int>("IsTop"); Key.Text = brandSearch.Key; IsTop.Text = brandSearch.IsTop.ToString(); PageSize = Session["AdminPageSize"] == null ? 20 : Convert.ToInt32(Session["AdminPageSize"]); AdminPageSize.Text = Session["AdminPageSize"] == null ? "20" : Session["AdminPageSize"].ToString(); brandList = ProductBrandBLL.SearchList(CurrentPage, PageSize, brandSearch, ref Count); //BindControl(ProductBrandBLL.ReadList(), RecordList); BindControl(brandList, RecordList, MyPager); if (RequestHelper.GetQueryString <string>("Action") == "Delete") { int brandId = RequestHelper.GetQueryString <int>("ID"); if (brandId > 0) { CheckAdminPower("DeleteProductBrand", PowerCheckType.Single); string URL = "ProductBrand.aspx?Action=search&"; URL += "Key=" + Key.Text + "&"; URL += "IsTop=" + IsTop.Text; ProductBrandBLL.Delete(brandId); AdminLogBLL.Add(ShopLanguage.ReadLanguage("DeleteRecord"), ShopLanguage.ReadLanguage("ProductBrand"), brandId.ToString()); ScriptHelper.Alert(ShopLanguage.ReadLanguage("DeleteOK"), URL); } } } }
public List <ProductBrandInfo> SearchList(ProductBrandSearchInfo brandSearch) { using (var conn = new SqlConnection(connectString)) { string sql = "select * from ProductBrand"; string condition = PrepareCondition(brandSearch).ToString(); if (!string.IsNullOrEmpty(condition)) { sql += " where " + condition; } return(conn.Query <ProductBrandInfo>(sql).ToList()); } }
public MssqlCondition PrepareCondition(ProductBrandSearchInfo brandSearch) { MssqlCondition mssqlCondition = new MssqlCondition(); string condition = string.Empty; if (!string.IsNullOrEmpty(brandSearch.Key)) { condition = "([Name]" + " LIKE '%" + StringHelper.SearchSafe(brandSearch.Key) + "%' OR "; condition += "[Spelling]" + " LIKE '%" + StringHelper.SearchSafe(brandSearch.Key) + "%')"; mssqlCondition.Add(condition); } mssqlCondition.Add("[Name]", brandSearch.Name, ConditionType.Like); mssqlCondition.Add("[Spelling]", brandSearch.Spelling, ConditionType.Like); mssqlCondition.Add("[IsTop]", brandSearch.IsTop, ConditionType.Equal); return(mssqlCondition); }
public List <ProductBrandInfo> SearchList(int currentPage, int pageSize, ProductBrandSearchInfo searchInfo, ref int count) { using (var conn = new SqlConnection(connectString)) { ShopMssqlPagerClass pc = new ShopMssqlPagerClass(); pc.TableName = "ProductBrand"; pc.Fields = "[Id], Name,Spelling,ImageUrl,LinkUrl,Remark,OrderId,IsTop"; pc.CurrentPage = currentPage; pc.PageSize = pageSize; //如果只用一个排序字段,分页存储过程则使用top方式。否则,使用row_number方式进行分页 //pc.OrderField = "[OrderId]"; pc.OrderField = "[OrderId],[Id]"; pc.OrderType = OrderType.Desc; pc.MssqlCondition = PrepareCondition(searchInfo); count = pc.Count; return(conn.Query <ProductBrandInfo>(pc).ToList()); } }
public static List <ProductBrandInfo> SearchList(int currentPage, int pageSize, ProductBrandSearchInfo searchInfo, ref int count) { return(dal.SearchList(currentPage, pageSize, searchInfo, ref count)); }
public static List <ProductBrandInfo> SearchList(ProductBrandSearchInfo brandSearch) { return(dal.SearchList(brandSearch)); }