Exemple #1
0
        public override PointLogCollection GetPointLogs(PointLogFilter filter, int pageNumber)
        {
            using (SqlQuery query = new SqlQuery())
            {
                StringBuilder sb = new StringBuilder();

                if (!string.IsNullOrEmpty(filter.Username))
                {
                    sb.Append(" AND UserID IN( SELECT UserID FROM bx_Users WHERE Username = @Username )");
                    query.CreateParameter <string>("@Username", filter.Username, SqlDbType.NVarChar, 50);
                }

                if (filter.OperateID != null)
                {
                    sb.Append(" AND OperateID = @OperateID");
                    query.CreateParameter <int>("@OperateID", filter.OperateID.Value, SqlDbType.Int);
                }

                if (filter.BeginDate != null)
                {
                    sb.Append(" AND CreateTime >= @BeginDate");
                    query.CreateParameter <DateTime>("@BeginDate", filter.BeginDate.Value, SqlDbType.DateTime);
                }

                if (filter.EndDate != null)
                {
                    sb.Append(" AND CreateTime <= @EndDate");
                    query.CreateParameter <DateTime>("@EndDate", filter.EndDate.Value, SqlDbType.DateTime);
                }

                if (sb.Length > 0)
                {
                    sb.Remove(0, 4);
                }

                query.Pager.TableName   = "bx_PointLogs";
                query.Pager.PageNumber  = pageNumber;
                query.Pager.PrimaryKey  = "LogID";
                query.Pager.SortField   = "LogID";
                query.Pager.IsDesc      = true;
                query.Pager.PageSize    = filter.PageSize;
                query.Pager.SelectCount = true;
                query.Pager.Condition   = sb.ToString();


                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    PointLogCollection logs = new PointLogCollection(reader);

                    if (reader.NextResult())
                    {
                        while (reader.Next)
                        {
                            logs.TotalRecords = reader.Get <int>(0);
                        }
                    }
                    return(logs);
                }
            }
        }
Exemple #2
0
        public override PointLogCollection GetPointLogs(PointLogFilter filter, int pageNumber)
        {
            using (SqlQuery query = new SqlQuery())
            {
                StringBuilder sb = new StringBuilder();

                if (!string.IsNullOrEmpty(filter.Username))
                {
                    sb.Append(" AND UserID IN( SELECT UserID FROM bx_Users WHERE Username = @Username )");
                    query.CreateParameter<string>("@Username", filter.Username, SqlDbType.NVarChar, 50);
                }

                if (filter.OperateID != null)
                {
                    sb.Append(" AND OperateID = @OperateID");
                    query.CreateParameter<int>("@OperateID", filter.OperateID.Value, SqlDbType.Int);
                }

                if (filter.BeginDate != null)
                {
                    sb.Append(" AND CreateTime >= @BeginDate");
                    query.CreateParameter<DateTime>("@BeginDate", filter.BeginDate.Value, SqlDbType.DateTime);
                }

                if (filter.EndDate != null)
                {
                    sb.Append(" AND CreateTime <= @EndDate");
                    query.CreateParameter<DateTime>("@EndDate", filter.EndDate.Value, SqlDbType.DateTime);
                }

                if (sb.Length > 0)
                    sb.Remove(0, 4);

                query.Pager.TableName = "bx_PointLogs";
                query.Pager.PageNumber = pageNumber;
                query.Pager.PrimaryKey = "LogID";
                query.Pager.SortField = "LogID";
                query.Pager.IsDesc = true;
                query.Pager.PageSize = filter.PageSize;
                query.Pager.SelectCount = true;
                query.Pager.Condition = sb.ToString();
                

                using (XSqlDataReader reader = query.ExecuteReader())
                {
                    PointLogCollection logs = new PointLogCollection(reader);

                    if (reader.NextResult())
                        while (reader.Next)
                            logs.TotalRecords = reader.Get<int>(0);
                    return logs;
                }
            }
        }