Esempio n. 1
0
        /// <summary>
        /// 获取条件查询的总记录数
        /// </summary>
        /// <param name="qs"></param>
        /// <returns></returns>
        public static int GetPicPageCount(PicQueryStatement qs, ref string errorInfo)
        {
            if (!Access.Connection(ref errorInfo))
            {
                return(-1);
            }
            bool   b_Conditional = false;
            string sql           = "select count(*) from RecPictureList 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.UserName != null)
            {
                sql          += " UserName='******'and";
                b_Conditional = true;
            }
            if (qs.RecStartDate != null)
            {
                sql          += " RecPictureDate>='" + qs.RecStartDate + "'and";
                b_Conditional = true;
            }
            if (qs.RecStartTime != null)
            {
                sql          += " RecPictureTime>='" + qs.RecStartTime + "'and";
                b_Conditional = true;
            }
            if (qs.RecEndDate != null)
            {
                sql          += " RecPictureDate<='" + qs.RecEndDate + "'and";
                b_Conditional = true;
            }
            if (qs.RecEndTime != null)
            {
                sql          += " RecPictureTime<='" + 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();

            return(i);
        }
Esempio n. 2
0
        /// <summary>
        /// 查询录像分页信息
        /// </summary>
        public static DataSet SelectPictureInfo(string page, string pageSize, PicQueryStatement 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 RecPictureList " +
                                   "where id>= (select max(id) from(select top " + exclude + " id from RecPictureList 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.UserName != null)
            {
                sql          += " UserName='******'and";
                b_Conditional = true;
            }
            if (qs.RecStartDate != null)
            {
                sql          += " RecPictureDate>='" + qs.RecStartDate + "'and";
                b_Conditional = true;
            }
            if (qs.RecStartTime != null)
            {
                sql          += " RecPictureTime>='" + qs.RecStartTime + "'and";
                b_Conditional = true;
            }
            if (qs.RecEndDate != null)
            {
                sql          += " RecPictureDate<='" + qs.RecEndDate + "'and";
                b_Conditional = true;
            }
            if (qs.RecEndTime != null)
            {
                sql          += " RecPictureTime<='" + 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, "RecPictureList");
            ds.Tables["RecPictureList"].Columns["ID"].ColumnName               = "序号";
            ds.Tables["RecPictureList"].Columns["CameraID"].ColumnName         = "设备编号";
            ds.Tables["RecPictureList"].Columns["RecPictureName"].ColumnName   = "截图名称";
            ds.Tables["RecPictureList"].Columns["RecPictureDate"].ColumnName   = "截图日期";
            ds.Tables["RecPictureList"].Columns["RecPictureTime"].ColumnName   = "截图时间";
            ds.Tables["RecPictureList"].Columns["RecPictureFile"].ColumnName   = "截图地址";
            ds.Tables["RecPictureList"].Columns["PictureType"].ColumnName      = "图片类型";
            ds.Tables["RecPictureList"].Columns["UserName"].ColumnName         = "操作用户";
            ds.Tables["RecPictureList"].Columns["PictureEventName"].ColumnName = "事件名称";
            ds.Tables["RecPictureList"].Columns["Description"].ColumnName      = "事件描述";
            ds.Tables["RecPictureList"].Columns["Mark"].ColumnName             = "备注";
            return(ds);
        }