public ActionResult time(DateTime time1, DateTime time2)
{
var time1=
//new SqlParameter("@begin",begin.ToString("yyyy-MM-dd 00:00:00")),
//new SqlParameter("@end",end.ToString("yyyy-MM-dd 23:59:59")),
return View();
}
public ActionResult Moneydetail(int pageIndex = 1, int pageSize = 15)
{
if (!Request.IsAuthenticated)
{
return Content("<script>alert('親,你還沒有登錄登錄!');location='/account/login?returnUrl=" + Request.RawUrl + "';</script>");
}
var monerdetail = db.JifenList.Where(p => p.UserID == Wz.Core.WebContext.Current.User.Id && p.Time > time1 && p.Time < time2).ToList();
return View();
}
}
後台那個時間方法怎麼寫
<div class="clearfix">
<form action="" method="post">
<input type="hidden" value="ok" name="search">
<div class="page_info">
/// 動態搜索類new
/// {?int UserID=0 用戶ID
/// ?DateTime BeginDate=DateTime.Now 開始時間
/// ?DateTime EndDate=DateTime.Now 結束時間
/// ?int AccountID=0 賬號類型
/// ?string OrderFeild="Order Desc" 排序字段和方式
/// }
///
/// 頁碼
/// 每頁顯示條數
///
public PagedList GetWithdrawalDetail(dynamic dySearch, int iPageIndex, int iPageSize)
{
try
{
var queryBuilder = QueryBuilder.Create();
ExpandoObject doSearch = dySearch;
var Keys = ((IDictionary)doSearch).Keys;
if (Keys.Contains("UserID")) //用戶ID
{
queryBuilder.Equals(n => n.UserID, (int)dySearch.UserID);
}
if (Keys.Contains("BeginDate")) //開始時間
{
queryBuilder.Between(n => n.AddTime, (DateTime)dySearch.BeginDate, DateTime.MaxValue);
}
if (Keys.Contains("EndDate")) //結束時間
{
queryBuilder.Between(n => n.AddTime, DateTime.MinValue, (DateTime)dySearch.EndDate);
}
string strOrder = string.Empty;
if (Keys.Contains("OrderFeild") && !string.IsNullOrEmpty(dySearch.OrderFeild)) //排序字段和方式
{
strOrder = dySearch.OrderFeild;
}
else
{
strOrder = "ID Desc";
}
var list = db.Finance_WithdrawalDetail.Where(queryBuilder.Expression).myorder(strOrder);
return new PagedList<Finance_WithdrawalDetail>(list, iPageIndex, iPageSize);
}
catch (Exception ex)
{
return null;
}
}
c 層 調用
viewdata["data"]= PagedList GetWithdrawalDetail(....);
return view();
v層
@{var data = viewdata["data"] as PagedList;
@ foreach(var d in data) { ........@d....... }}