コード例 #1
0
ファイル: SensorController.cs プロジェクト: SweetieXu/lhzw
        public ActionResult GetSensorInfo(SensorSearchModel model, int searchPage)
        {
            SearchDataWithPagedDatas <SensorSearchModel, SensorListModels> result =
                new SearchDataWithPagedDatas <SensorSearchModel, SensorListModels>();

            result.SearchModel = model;
            result.PagedDatas  = SensorBLL.GetPagedSensor(model, searchPage, this.PageSize);
            return(PartialView("_SensorPagedGrid", result));
        }
コード例 #2
0
ファイル: SensorBLL.cs プロジェクト: SweetieXu/lhzw
        public static AsiatekPagedList <SensorListModels> GetPagedSensor(SensorSearchModel model, int searchPage, int pageSize)
        {
            List <SqlParameter> paras = new List <SqlParameter>()
            {
                new SqlParameter("@tableName", "SensorList s"),
                new SqlParameter("@pageSize", pageSize),
                new SqlParameter("@currentPage", searchPage),
                new SqlParameter("@orderBy", "s.TypeID"),
                new SqlParameter("@showColumns", @"s.TypeID ,s.SensorCode,
        s.SensorName,
        s.Value1,
        s.Value2,
        s.Remark,
        s.Status,s.TypeCode"),
            };

            string conditionStr = " Status<>9 ";//不查询删除和报废的

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

            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 <SensorListModels> list = ConvertToList <SensorListModels> .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));
        }