예제 #1
0
        /// <summary>
        /// 获得数据List
        /// <summary>
        public List <Dic_UnitInfo> GetDataList(UnitInfoQueryCondition QueryCondition)
        {
            SqlParameter[] sqlParams;
            StringBuilder  strSqlOption = new StringBuilder();

            QueryCondition.OutPut(out strSqlOption, out sqlParams);
            StringBuilder strSql = new StringBuilder();

            if (QueryCondition.page == 0)
            {
                strSql.Append("select * ");
                strSql.Append(" FROM TAB_Dic_UnitInfo where 1=1 " + strSqlOption.ToString());
            }
            else
            {
                strSql.Append(@"select top " + QueryCondition.rows.ToString() + " * from TAB_Dic_UnitInfo where 1 = 1 " +
                              strSqlOption.ToString() + " and nID not in ( select top " + (QueryCondition.page - 1) * QueryCondition.rows +
                              " nID from TAB_Dic_UnitInfo where  1=1 " + strSqlOption.ToString() + " order by nID desc) order by nID desc");
            }
            DataTable           dt   = SqlHelper.ExecuteDataset(ConnectionString, CommandType.Text, strSql.ToString(), sqlParams).Tables[0];
            List <Dic_UnitInfo> list = new List <Dic_UnitInfo>();

            foreach (DataRow dr in dt.Rows)
            {
                Dic_UnitInfo _UnitInfo = new Dic_UnitInfo();
                DataRowToModel(_UnitInfo, dr);
                list.Add(_UnitInfo);
            }
            return(list);
        }
예제 #2
0
        /// <summary>
        /// 获得记录总数
        /// <summary>
        public int GetDataCount(UnitInfoQueryCondition QueryCondition)
        {
            SqlParameter[] sqlParams;
            StringBuilder  strSqlOption = new StringBuilder();

            QueryCondition.OutPut(out strSqlOption, out sqlParams);
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select count(*) ");
            strSql.Append(" FROM TAB_Dic_UnitInfo where 1=1" + strSqlOption.ToString());
            return(ObjectConvertClass.static_ext_int(SqlHelper.ExecuteScalar(ConnectionString, CommandType.Text, strSql.ToString(), sqlParams)));
        }
예제 #3
0
        /// <summary>
        /// 获得一个实体对象
        /// <summary>
        public Dic_UnitInfo GetModel(UnitInfoQueryCondition QueryCondition)
        {
            SqlParameter[] sqlParams;
            StringBuilder  strSqlOption = new StringBuilder();

            QueryCondition.OutPut(out strSqlOption, out sqlParams);
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select top 1 * ");
            strSql.Append(" FROM TAB_Dic_UnitInfo where 1=1 " + strSqlOption.ToString());
            DataTable    dt        = SqlHelper.ExecuteDataset(ConnectionString, CommandType.Text, strSql.ToString(), sqlParams).Tables[0];
            Dic_UnitInfo _UnitInfo = null;

            if (dt.Rows.Count > 0)
            {
                _UnitInfo = new Dic_UnitInfo();
                DataRowToModel(_UnitInfo, dt.Rows[0]);
            }
            return(_UnitInfo);
        }
예제 #4
0
        /// <summary>
        /// 获得数据DataTable
        /// <summary>
        public DataTable GetDataTable(UnitInfoQueryCondition QueryCondition)
        {
            SqlParameter[] sqlParams;
            StringBuilder  strSqlOption = new StringBuilder();

            QueryCondition.OutPut(out strSqlOption, out sqlParams);
            StringBuilder strSql = new StringBuilder();

            if (QueryCondition.page == 0)
            {
                strSql.Append("select * ");
                strSql.Append(" FROM TAB_Dic_UnitInfo where 1=1 " + strSqlOption.ToString());
            }
            else
            {
                strSql.Append(@"select top " + QueryCondition.rows.ToString() + " * from TAB_Dic_UnitInfo where 1 = 1 " +
                              strSqlOption.ToString() + " and nID not in ( select top " + (QueryCondition.page - 1) * QueryCondition.rows +
                              " nID from TAB_Dic_UnitInfo where  1=1 " + strSqlOption.ToString() + " order by nID desc) order by nID desc");
            }
            return(SqlHelper.ExecuteDataset(ConnectionString, CommandType.Text, strSql.ToString(), sqlParams).Tables[0]);
        }