/// <summary>
/// 分页显示
/// </summary>
/// <returns></returns>
public object getShopping(string shopName,int addresName=0,int addresHome=0,int pageIndex=1,int pageSize=4)
{
Page page = new Page();
var getShoppings= Context.shops.ToList();
if (shopName != null)
{
getShoppings = getShoppings.Where(r => r.ShopName.Contains(shopName)).ToList();
}
if (addresName != 0)
{
getShoppings = getShoppings.Where(r => r.ShopSheng.Equals(addresName)).ToList();
}
if (addresHome != 0)
{
getShoppings = getShoppings.Where(r => r.ShopHome.Equals(addresHome)).ToList();
}
page.RowCount = getShoppings.Count;
page.PageCount = getShoppings.Count / pageSize + (getShoppings.Count % pageSize == 0 ? 0 : 1);
page.Data = getShoppings.Skip((pageIndex-1)*pageSize).Take(pageSize);
return page;
}
$.ajax({
url: "http://localhost:8889/OrderFormApi/getShopping",
type: "get",
data: {
shopName: $("input[name=ShopName]").val(),
addresName: $("select[name=ShopSheng]").val(),
addresHome: $("select[name=ShopHome]").val(),
pageIndex: pageIndex,
pageSize: pageSize,
},
success: function (data) {
$("#tab").children().children().not(":first").remove(); console.log(data)
pageCount = data.PageCount;
$(data.Data).each(function (index, data) {
var aaa = data.ShopPrice * data.ShopCount;
$("#tab").append("<tr><td><input name='checkbox' type='checkbox'value='" + data.ShopID + "' /></td><td>" + data.ShopID + "</td> <td><img style='50px;height:45px' src=" + data.ShopImages + "></td> <td>" + data.ShopName + "</td> <td>" + data.ShopNumber + "</td> <td>" + data.ShopPrice + "</td> <td>" + data.ShopCount + "</td> <td>" + aaa + "¥</td> <td> </td> <td>" + data.ShopSheng + "</td> <td>" + data.ShopHome + "</td> <td><a onclick=' DelShopping(" + data.ShopID + ")'>✖</a>   <a href='/OrderForm/UptShopping?ID=" + data.ShopID + "'>✎</a> </td></tr>");
})
}
})
==工厂
using System.Configuration;
using System.Reflection;//反射
public class _工厂泛型反射<T> where T:class
{
public static T getStudent(string Sname)
{
//通过Asssembly程序集的Load方法加载 命名空间,用 CreateInstance 方法加载命名空间下的一个类
return (T)Assembly.Load("DAL").CreateInstance("DAL." + Sname);
}
}