示例#1
0
        /// <summary>
        /// 搜索
        /// </summary>
        /// <param name="collection"></param>
        /// <returns></returns>
        public ActionResult SeachProductInfo(FormCollection collection)
        {
            String Name = collection.Get("ProductName").Trim().ToString();
            //严格判断空值
            String Id = collection.Get("typeId").ToString();
            int typeId = Convert.ToInt32(String.IsNullOrEmpty(Id) ? "0" : Id); //$("#typeId").combobox("getValue"); 通过这个获取的

            String sid = collection.Get("ProductId").ToString();
            int ProductId = Convert.ToInt32(String.IsNullOrEmpty(sid) ? "0" : sid);

            String NewPrice = collection.Get("RealPrice").ToString();
            int RealPrice = Convert.ToInt32(String.IsNullOrEmpty(NewPrice) ? "0" : NewPrice);

            String en = collection.Get("en").ToString();
            bool? enable = String.IsNullOrEmpty(en) ? null : AdminController.Enable(en);
            //上下两种方法都可以获取数据Request[""]和collection.Get("")

            int row = int.Parse(Request["rows"].ToString());
            int pageindex = int.Parse(Request["page"].ToString());
            ProductData Productjson = new ProductData();
            int total;
            Productjson.rows = productBLL.GetProductsBySerach(pageindex, row, out total, typeId, ProductId, Name, RealPrice, enable);
            Productjson.total = total;
            string Str = JsonConvert.SerializeObject(Productjson);
            return Content(Str, "text/html;charset=UTF-8");
        }
示例#2
0
 /// <summary>
 /// 加载json数组对象
 /// </summary>
 /// <returns></returns>
 public ActionResult LoadProductjson()
 {
     //string sort = Request["sort"].ToString();暂时实现不了动态的字段倒/正排序 除非是sql语句 用Switch显得很臃肿
     //sort = (!string.IsNullOrEmpty(sort) ? sort : "ProductId");
     //string order = Request["order"].ToString();
     //order = (!string.IsNullOrEmpty(order) ? order : "ascending");
     int row = int.Parse(Request["rows"].ToString());
     int pageindex = int.Parse(Request["page"].ToString());
     ProductData Productjson = new ProductData();
     int total;
     Productjson.rows = productBLL.GetProductList(pageindex, row, out total);
     Productjson.total = total;
     string Str = JsonConvert.SerializeObject(Productjson);
     return Content(Str, "text/html;charset=UTF-8");
 }