예제 #1
0
        /// <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);
                    }
                }
            }
        }
예제 #2
0
        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());
            }
        }
예제 #3
0
        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);
        }
예제 #4
0
        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());
            }
        }
예제 #5
0
 public static List <ProductBrandInfo> SearchList(int currentPage, int pageSize, ProductBrandSearchInfo searchInfo, ref int count)
 {
     return(dal.SearchList(currentPage, pageSize, searchInfo, ref count));
 }
예제 #6
0
 public static List <ProductBrandInfo> SearchList(ProductBrandSearchInfo brandSearch)
 {
     return(dal.SearchList(brandSearch));
 }