public ActionResult GetEFPropertys(ElectricFencePropertySearchModel model, int searchPage)
        {
            SearchDataWithPagedDatas <ElectricFencePropertySearchModel, ElectricFencePropertyListModel> result = new SearchDataWithPagedDatas <ElectricFencePropertySearchModel, ElectricFencePropertyListModel>();

            result.SearchModel = model;
            result.PagedDatas  = ElectricFencePropertyBLL.GetPagedEFPropertys(result.SearchModel, searchPage, this.PageSize, base.CurrentStrucID);
            return(PartialView("_ElectricFencePropertyPagedGrid", result));
        }
Пример #2
0
        public static AsiatekPagedList <ElectricFencePropertyListModel> GetPagedEFPropertys(ElectricFencePropertySearchModel model, int searchPage, int pageSize, int strucID)
        {
            #region 是否属于单位亚士德,是则查所有,否则查询前用户所属单位的非亚士德上级以及所有其子单位
            string isSql = @" SELECT ParentID FROM dbo.Structures WHERE ID =@StrucID ";
            List <SqlParameter> isParas = new List <SqlParameter>()
            {
                new SqlParameter("@StrucID", SqlDbType.Int),
            };
            isParas[0].Value = strucID;
            var isResult = MSSQLHelper.ExecuteScalar(CommandType.Text, isSql, isParas.ToArray());
            #endregion

            List <SqlParameter> paras = new List <SqlParameter>()
            {
                new SqlParameter("@tableName", "dbo.ElectricFenceProperty efp "),
                new SqlParameter("@joinStr", @" INNER JOIN dbo.Users AS us ON us.ID = efp.CreateUser "),
                new SqlParameter("@pageSize", pageSize),
                new SqlParameter("@currentPage", searchPage),
                new SqlParameter("@orderBy", "efp.CreateTime DESC"),
                new SqlParameter("@showColumns", @"efp.ID,efp.PropertyName,efp.FenceState,efp.ValidStartTime,efp.ValidEndTime,
                                                                             efp.AlarmType,efp.IsSpeed,efp.MaxSpeed,efp.IsPeriod "),
            };

            string conditionStr = " ";
            if (isResult != DBNull.Value)
            {
                conditionStr = "efp.Status<>9 AND us.StrucID IN (SELECT ID FROM Func_GetAllSubStructsAndParentStructsByStrucID(" + strucID + ") WHERE ParentID IS NOT NULL) ";
            }
            else
            {
                conditionStr = "efp.Status<>9 ";
            }
            if (!string.IsNullOrWhiteSpace(model.PropertyName))
            {
                conditionStr += " AND efp.PropertyName LIKE '%" + model.PropertyName + "%'";
            }

            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
            });
            var rs = MSSQLHelper.ExecuteDataTable(CommandType.StoredProcedure, "Proc_GetPagedDatas", paras.ToArray());
            List <ElectricFencePropertyListModel> list = ConvertToList <ElectricFencePropertyListModel> .Convert(rs);

            int totalItemCount = Convert.ToInt32(paras[paras.Count - 2].Value);
            int newCurrentPage = Convert.ToInt32(paras[paras.Count - 1].Value);
            return(list.ToPagedList(newCurrentPage, pageSize, totalItemCount));
        }