/// <summary> /// 获取条件查询的总记录数 /// </summary> /// <param name="qs"></param> /// <returns></returns> public static int GetUserLogPageCount(UserLogQueryStatement qs, ref string errorInfo) { if (!Access.Connection(ref errorInfo)) { return(-1); } bool b_Conditional = false; string sql = "select count(*) from UserLog where"; if (qs.Operation != null) { sql += " Operation='" + qs.Operation + "'and"; b_Conditional = true; } if (qs.Name != null) { sql += " OperationName='" + qs.Name + "'and"; b_Conditional = true; } if (qs.StartDate != null) { sql += " OperationDate>='" + qs.StartDate + "'and"; b_Conditional = true; } if (qs.StartTime != null) { sql += " OperationTime>='" + qs.StartTime + "'and"; b_Conditional = true; } if (qs.EndDate != null) { sql += " OperationDate<='" + qs.EndDate + "'and"; b_Conditional = true; } if (qs.EndTime != null) { sql += " OperationTime<='" + qs.EndTime + "'and"; b_Conditional = true; } if (!b_Conditional) { sql = sql.Substring(0, sql.Length - 5); } else { sql = sql.Substring(0, sql.Length - 3); } OleDbCommand oleDbCommand = new OleDbCommand(sql, Access.oleDb); int i = (int)oleDbCommand.ExecuteScalar(); Access.CloseConn(); return(i); }
/// <summary> /// 查询录像分页信息 /// </summary> public static DataSet SelectUserLogInfo(string page, string pageSize, UserLogQueryStatement qs, ref string errorInfo) { if (!Access.Connection(ref errorInfo)) { return(null); } int i_page = int.Parse(page); int i_pageSize = int.Parse(pageSize); int exclude = (i_pageSize * (i_page - 1)) + 1; bool b_Conditional = false; string sql = "select top " + pageSize + " * from UserLog " + "where id>= (select max(id) from(select top " + exclude + " id from UserLog order by id)a where"; if (qs.Operation != null) { sql += " Operation='" + qs.Operation + "'and"; b_Conditional = true; } if (qs.Name != null) { sql += " UserName='******'and"; b_Conditional = true; } if (qs.StartDate != null) { sql += " OperationDate>='" + qs.StartDate + "'and"; b_Conditional = true; } if (qs.StartTime != null) { sql += " OperationTime>='" + qs.StartTime + "'and"; b_Conditional = true; } if (qs.EndDate != null) { sql += " OperationDate<='" + qs.EndDate + "'and"; b_Conditional = true; } if (qs.EndTime != null) { sql += " OperationTime<='" + qs.EndTime + "'and"; b_Conditional = true; } if (!b_Conditional) { sql = sql.Substring(0, sql.Length - 5); } else { sql = sql.Substring(0, sql.Length - 3); } sql += ")order by id"; OleDbDataAdapter oleDbDataAdapter = new OleDbDataAdapter(sql, Access.oleDb); DataSet ds = new DataSet(); oleDbDataAdapter.Fill(ds, "UserLog"); ds.Tables["UserLog"].Columns["ID"].ColumnName = "序号"; ds.Tables["UserLog"].Columns["UserLogID"].ColumnName = "日志编号"; ds.Tables["UserLog"].Columns["UserName"].ColumnName = "用户名"; ds.Tables["UserLog"].Columns["OperationDate"].ColumnName = "日期"; ds.Tables["UserLog"].Columns["OperationTime"].ColumnName = "时间"; ds.Tables["UserLog"].Columns["Operation"].ColumnName = "信息"; ds.Tables["UserLog"].Columns["Description"].ColumnName = "描述"; ds.Tables["UserLog"].Columns["Mark"].ColumnName = "备注"; Access.CloseConn(); return(ds); }