コード例 #1
0
 public ActionResult AjaxListStore(jQueryDataTableParamModel param)
 {
     DataTables table;
     User user = (User)Session["CurrentUser"];
     user = db.Users.Find(user.UserID);
     if (db.Roles.Find(1).Users.Contains(user) || db.Roles.Find(4).Users.Contains(user))
     {
         table = new DataTables(
     ((IObjectContextAdapter)new EntityContext()).ObjectContext,
     "store",
     new string[] { "Stores.StoreName", "Stores.Address", "Stores.Region.RegionName", "Stores.StoreID" },
     "EntityContext.Stores",
     "AjaxListStore", "SalesRecord",
     new string[] { "销售点名", "详细地址", "所属片区", "操作" });
     }
     else
     {
         table = new DataTables(
     ((IObjectContextAdapter)new EntityContext()).ObjectContext,
     "store",
     new string[] { "s.StoreName", "s.Address", "s.Region.RegionName", "s.StoreID" },
     "FLATTEN(select value Users.StoresBelonged from EntityContext.Users where Users.UserID = " + user.UserID + ") as s",
     "AjaxListStore", "SalesRecord",
     new string[] { "销售点名", "详细地址", "所属片区", "操作" });
     }
     ViewBag.DataTable = table;
     return Json(table.AjaxHandler(param), JsonRequestBehavior.AllowGet);
 }
コード例 #2
0
 public ActionResult AjaxHandler(jQueryDataTableParamModel param)
 {
     return Json(table.AjaxHandler(param), JsonRequestBehavior.AllowGet);
 }
コード例 #3
0
 public ActionResult AjaxHandler1(jQueryDataTableParamModel param)
 {
     storeTable.Where = "Stores.RegionID = " + Session["ViewRegionID"].ToString();
     return Json(storeTable.AjaxHandler(param), JsonRequestBehavior.AllowGet);
 }
コード例 #4
0
 public ActionResult AjaxHandler(jQueryDataTableParamModel param)
 {
     RecordTable.Where = "SalesRecords.Store.StoreID = " + Session["ViewStoreID"].ToString();
     return Json(RecordTable.AjaxHandler(param), JsonRequestBehavior.AllowGet);
 }
コード例 #5
0
 public ActionResult AjaxHandler1(jQueryDataTableParamModel param)
 {
     CommodityTable.Where = "Commodities.CategoryID = " + Session["ViewCategoryID"].ToString();
     return Json(CommodityTable.AjaxHandler(param), JsonRequestBehavior.AllowGet);
 }
コード例 #6
0
        public object AjaxHandler(jQueryDataTableParamModel param)
        {
            var query = objContext.CreateQuery<DbDataRecord>("select count(" + select[select.Length - 1] + ") from " + this.from);
            var total = 0;
            try
            {
                foreach (var item in query)
                {
                    total = Convert.ToInt32(item[0]);
                    break;
                }
            }
            catch
            {
                total = 0;
            }
            var eSQL = sql;
            eSQL += " where " + cwhere;
            if (!string.IsNullOrEmpty(param.sSearch))
            {
                eSQL += " and " + String.Format(where, param.sSearch);
            }
            var orderBy = " order by " + select[param.iSortCol_0] + " " + param.sSortDir_0;
            if (string.IsNullOrEmpty(param.sSortDir_0))
            {
                orderBy = " order by " + select[select.Count()];
            }
            eSQL += orderBy;
            var entries = objContext.CreateQuery<DbDataRecord>(eSQL);
            var result = entries
                        .Skip(param.iDisplayStart)
                        .Take(param.iDisplayLength);
            var dataList = new List<List<string>>();
            try
            {

                foreach (var item in result)
                {
                    var newRow = new List<string>();
                    for (int i = 0; i < item.FieldCount; i++)
                    {
                        newRow.Add(item[i].ToString());
                    }
                    dataList.Add(newRow);
                }
            }
            catch
            {
                dataList.Clear();
            }
            return (new
            {
                sEcho = param.sEcho,
                iTotalRecords = total,
                iTotalDisplayRecords = entries.Count(),
                aaData = dataList
            });
        }