Example #1
0
        /// <summary>
        /// 获取条件查询的总记录数
        /// </summary>
        /// <param name="qs"></param>
        /// <returns></returns>
        public static int GetRunLogPageCount(RunLogQueryStatement qs, ref string errorInfo)
        {
            if (!Access.Connection(ref errorInfo))
            {
                return(-1);
            }
            bool   b_Conditional = false;
            string sql           = "select count(*) from RunLog where";

            if (qs.Operation != null)
            {
                sql          += " Operation='" + qs.Operation + "'and";
                b_Conditional = true;
            }
            if (qs.IsAbnormal != null)
            {
                sql          += " IsAbnormal='" + qs.IsAbnormal + "'and";
                b_Conditional = true;
            }
            if (qs.StartDate != null)
            {
                sql          += " Date>='" + qs.StartDate + "'and";
                b_Conditional = true;
            }
            if (qs.StartTime != null)
            {
                sql          += " Time>='" + qs.StartTime + "'and";
                b_Conditional = true;
            }
            if (qs.EndDate != null)
            {
                sql          += " Date<='" + qs.EndDate + "'and";
                b_Conditional = true;
            }
            if (qs.EndTime != null)
            {
                sql          += " Time<='" + 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);
        }
Example #2
0
        /// <summary>
        /// 查询录像分页信息
        /// </summary>
        public static DataSet SelectRunLogInfo(string page, string pageSize, RunLogQueryStatement 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 RunLog " +
                                   "where id>= (select max(id) from(select top " + exclude + " id from RunLog order by id)a where";

            if (qs.Operation != null)
            {
                sql          += " Operation='" + qs.Operation + "'and";
                b_Conditional = true;
            }
            if (qs.IsAbnormal != null)
            {
                sql          += " IsAbnormal='" + qs.IsAbnormal + "'and";
                b_Conditional = true;
            }
            if (qs.StartDate != null)
            {
                sql          += " Date>='" + qs.StartDate + "'and";
                b_Conditional = true;
            }
            if (qs.StartTime != null)
            {
                sql          += " Time>='" + qs.StartTime + "'and";
                b_Conditional = true;
            }
            if (qs.EndDate != null)
            {
                sql          += " Date<='" + qs.EndDate + "'and";
                b_Conditional = true;
            }
            if (qs.EndTime != null)
            {
                sql          += " Time<='" + 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, "RunLog");
            ds.Tables["RunLog"].Columns["ID"].ColumnName          = "序号";
            ds.Tables["RunLog"].Columns["LogType"].ColumnName     = "运行类型";
            ds.Tables["RunLog"].Columns["IsAbnormal"].ColumnName  = "是否异常";
            ds.Tables["RunLog"].Columns["Date"].ColumnName        = "日期";
            ds.Tables["RunLog"].Columns["Time"].ColumnName        = "时间";
            ds.Tables["RunLog"].Columns["Operation"].ColumnName   = "信息";
            ds.Tables["RunLog"].Columns["Description"].ColumnName = "描述";
            ds.Tables["RunLog"].Columns["Mark"].ColumnName        = "备注";
            Access.CloseConn();
            return(ds);
        }