Exemplo n.º 1
0
        /// <summary>
        /// 查询录像分页信息
        /// </summary>
        public static DataSet SelectRecInfo(string page, string pageSize, RecQueryStatement 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 RecFileList " +
                                   "where id>= (select max(id) from(select top " + exclude + " id from RecFileList order by id)a where";

            if (qs.CameraID != null)
            {
                if (qs.CameraID.Count != 0)
                {
                    for (int j = 0; j < qs.CameraID.Count; j++)
                    {
                        sql += " CameraID='" + qs.CameraID[j] + "'or";
                    }
                    b_Conditional = true;
                    sql           = sql.Substring(0, sql.Length - 2) + "and";
                }
            }
            if (qs.RecType != null)
            {
                sql          += " RecType='" + qs.RecType + "'and";
                b_Conditional = true;
            }
            if (qs.UserName != null)
            {
                sql          += " UserName='******'and";
                b_Conditional = true;
            }
            if (qs.RecStartDate != null)
            {
                sql          += " RecStartDate>='" + qs.RecStartDate + "'and";
                b_Conditional = true;
            }
            if (qs.RecStartTime != null)
            {
                sql          += " RecStartTime>='" + qs.RecStartTime + "'and";
                b_Conditional = true;
            }
            if (qs.RecEndDate != null)
            {
                sql          += " RecEndDate<='" + qs.RecEndDate + "'and";
                b_Conditional = true;
            }
            if (qs.RecEndTime != null)
            {
                sql          += " RecEndTime<='" + qs.RecEndTime + "'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, "RecFileList");
            ds.Tables["RecFileList"].Columns["ID"].ColumnName             = "序号";
            ds.Tables["RecFileList"].Columns["CameraID"].ColumnName       = "设备编号";
            ds.Tables["RecFileList"].Columns["LocationFlag"].ColumnName   = "标识";
            ds.Tables["RecFileList"].Columns["RecName"].ColumnName        = "录像名称";
            ds.Tables["RecFileList"].Columns["RecType"].ColumnName        = "录像类型";
            ds.Tables["RecFileList"].Columns["RecStartDate"].ColumnName   = "开始日期";
            ds.Tables["RecFileList"].Columns["RecStartTime"].ColumnName   = "开始时间";
            ds.Tables["RecFileList"].Columns["RecEndDate"].ColumnName     = "结束日期";
            ds.Tables["RecFileList"].Columns["RecEndTime"].ColumnName     = "结束时间";
            ds.Tables["RecFileList"].Columns["RecRecFile"].ColumnName     = "录像地址";
            ds.Tables["RecFileList"].Columns["UserName"].ColumnName       = "操作用户";
            ds.Tables["RecFileList"].Columns["RecEventName"].ColumnName   = "事件名称";
            ds.Tables["RecFileList"].Columns["RecDescription"].ColumnName = "事件描述";
            ds.Tables["RecFileList"].Columns["Mark"].ColumnName           = "备注";
            Access.CloseConn();
            return(ds);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取条件查询的总记录数
        /// </summary>
        /// <param name="qs"></param>
        /// <returns></returns>
        public static int GetRecPageCount(RecQueryStatement qs, ref string errorInfo)
        {
            if (!Access.Connection(ref errorInfo))
            {
                return(-1);
            }
            bool   b_Conditional = false;
            string sql           = "select count(*) from RecFileList where";

            if (qs.CameraID != null)
            {
                if (qs.CameraID.Count != 0)
                {
                    for (int j = 0; j < qs.CameraID.Count; j++)
                    {
                        sql += " CameraID='" + qs.CameraID[j] + "'or";
                    }
                    b_Conditional = true;
                    sql           = sql.Substring(0, sql.Length - 2) + "and";
                }
            }
            if (qs.RecType != null)
            {
                sql          += " RecType='" + qs.RecType + "'and";
                b_Conditional = true;
            }
            if (qs.UserName != null)
            {
                sql          += " UserName='******'and";
                b_Conditional = true;
            }
            if (qs.RecStartDate != null)
            {
                sql          += " RecStartDate>='" + qs.RecStartDate + "'and";
                b_Conditional = true;
            }
            if (qs.RecStartTime != null)
            {
                sql          += " RecStartTime>='" + qs.RecStartTime + "'and";
                b_Conditional = true;
            }
            if (qs.RecEndDate != null)
            {
                sql          += " RecStartDate<='" + qs.RecEndDate + "'and";
                b_Conditional = true;
            }
            if (qs.RecEndTime != null)
            {
                sql          += " RecStartTime<='" + qs.RecEndTime + "'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);
        }