示例#1
0
        public ActionResult GetNightBanInfo(NightBanSearchModel model, int searchPage)
        {
            SearchDataWithPagedDatas <NightBanSearchModel, NightBanListModel> result =
                new SearchDataWithPagedDatas <NightBanSearchModel, NightBanListModel>();

            result.SearchModel = model;
            result.PagedDatas  = NightBanBLL.GetPagedNightBan(model, searchPage, this.PageSize);
            return(PartialView("_NightBanPagedGrid", result));
        }
示例#2
0
        public static AsiatekPagedList <NightBanListModel> GetPagedNightBan(NightBanSearchModel model, int searchPage, int pageSize)
        {
            List <SqlParameter> paras = new List <SqlParameter>()
            {
                new SqlParameter("@tableName", "[dbo].[NightBan]"),
                new SqlParameter("@pageSize", pageSize),
                new SqlParameter("@currentPage", searchPage),
                new SqlParameter("@orderBy", "ID DESC"),
                new SqlParameter("@showColumns", @"[ID],[NightBanName],[NightBanAddress] ,[StartTime]
                                                                                ,[EndTime],[IsEnabled]"),
            };

            string conditionStr = " Status = 0 ";

            if (!string.IsNullOrWhiteSpace(model.NightBanName))
            {
                conditionStr += " AND NightBanName LIKE '%" + model.NightBanName + "%'";
            }

            if (!string.IsNullOrWhiteSpace(model.NightBanAddress))
            {
                conditionStr += " AND NightBanAddress LIKE '%" + model.NightBanAddress + "%'";
            }

            if (model.IsEnabled != -1)
            {
                conditionStr += " AND IsEnabled =" + model.IsEnabled;
            }

            if (!string.IsNullOrWhiteSpace(conditionStr))
            {
                paras.Add(new SqlParameter("@conditionStr", conditionStr));
            }

            paras.Add(new SqlParameter()
            {
                ParameterName = "@totalItemCount",
                Direction     = ParameterDirection.Output,
                SqlDbType     = SqlDbType.Int
            });
            paras.Add(new SqlParameter()
            {
                ParameterName = "@newCurrentPage",
                Direction     = ParameterDirection.Output,
                SqlDbType     = SqlDbType.Int
            });
            List <NightBanListModel> list = ConvertToList <NightBanListModel> .
                                            Convert(MSSQLHelper.ExecuteDataTable(CommandType.StoredProcedure, "Proc_GetPagedDatas", paras.ToArray()));

            int totalItemCount = Convert.ToInt32(paras[paras.Count - 2].Value);
            int newCurrentPage = Convert.ToInt32(paras[paras.Count - 1].Value);

            return(list.ToPagedList(newCurrentPage, pageSize, totalItemCount));
        }