Exemplo n.º 1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.Settings GetModel(string name)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from [Settings] ");
            strSql.Append(" where Name=@ID ");
            MSSQLHelper h = new MSSQLHelper();

            h.CreateCommand(strSql.ToString());
            h.AddParameter("@ID", name);
            Model.Settings model = null;
            using (IDataReader dataReader = h.ExecuteReader())
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
                h.CloseConn();
            }
            return(model);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.Tools_entitys GetModel(int keyId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from [Tools_entitys] ");
            strSql.Append(" where ID=@ID ");
            MSSQLHelper h = new MSSQLHelper();

            h.CreateCommand(strSql.ToString());
            h.AddParameter("@ID", keyId);
            Model.Tools_entitys model = null;
            using (IDataReader dataReader = h.ExecuteReader())
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
                h.CloseConn();
            }
            return(model);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.Tools_Defination GetModel(string code)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from [Tools_Defination] ");
            strSql.Append(" where Code=@ID ");
            MSSQLHelper h = new MSSQLHelper();

            h.CreateCommand(strSql.ToString());
            h.AddParameter("@ID", code);
            Model.Tools_Defination model = null;
            using (IDataReader dataReader = h.ExecuteReader())
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
                h.CloseConn();
            }
            return(model);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 根据条件得到一个对象实体
        /// </summary>
        public Model.Settings GetModelByCond(string cond)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select top 1 * from [Settings] ");
            if (!string.IsNullOrEmpty(cond))
            {
                strSql.Append(" where " + cond);
            }
            MSSQLHelper h = new MSSQLHelper();

            h.CreateCommand(strSql.ToString());
            Model.Settings model = null;
            using (IDataReader dataReader = h.ExecuteReader())
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
                h.CloseConn();
            }
            return(model);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 分页获取数据列表
        /// </summary>
        public List <Model.Settings> GetListArray(string fileds, string order, string ordertype, int PageSize, int PageIndex, string strWhere)
        {
            MSSQLHelper h = new MSSQLHelper();

            h.CreateStoredCommand("[proc_SplitPage]");
            h.AddParameter("@tblName", "[Settings]");
            h.AddParameter("@strFields", fileds);
            h.AddParameter("@strOrder", order);
            h.AddParameter("@strOrderType", ordertype);
            h.AddParameter("@PageSize", PageSize);
            h.AddParameter("@PageIndex", PageIndex);
            h.AddParameter("@strWhere", strWhere);
            List <Model.Settings> list = new List <Model.Settings>();

            using (IDataReader dataReader = h.ExecuteReader())
            {
                while (dataReader.Read())
                {
                    list.Add(ReaderBind(dataReader));
                }
                h.CloseConn();
            }
            return(list);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 获得数据列表(比DataSet效率高,推荐使用)
        /// </summary>
        public List <Model.Settings> GetListArray(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * ");
            strSql.Append(" FROM [Settings] ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            List <Model.Settings> list = new List <Model.Settings>();
            MSSQLHelper           h    = new MSSQLHelper();

            h.CreateCommand(strSql.ToString());
            using (IDataReader dataReader = h.ExecuteReader())
            {
                while (dataReader.Read())
                {
                    list.Add(ReaderBind(dataReader));
                }
                h.CloseConn();
            }
            return(list);
        }