Exemplo n.º 1
0
        /// <summary>删除一条数据
        ///
        /// </summary>
        public bool Delete(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("delete from BseUrl2 ");
            strSql.Append(" where Id=@Id ");
            IDbHelper h = GlobalHelp.GetDataAccessHelper();

            h.CreateCommand(strSql.ToString());
            h.AddParameter("@Id", Id);
            return(h.ExecuteNonQuery());
        }
Exemplo n.º 2
0
        /// <summary>计算记录数
        ///
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        public int CalcCount(string cond)
        {
            string sql = "select count(1) from BseUrl2";

            if (!string.IsNullOrEmpty(cond))
            {
                sql += " where " + cond;
            }
            IDbHelper h = GlobalHelp.GetDataAccessHelper();

            h.CreateCommand(sql);
            return(int.Parse(h.ExecuteScalar()));
        }
Exemplo n.º 3
0
        /// <summary>根据条件删除数据
        ///
        /// </summary>
        public bool DeleteByCond(string cond)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("delete from BseUrl2 ");
            if (!string.IsNullOrEmpty(cond))
            {
                strSql.Append(" where " + cond);
            }
            IDbHelper h = GlobalHelp.GetDataAccessHelper();

            h.CreateCommand(strSql.ToString());
            return(h.ExecuteNonQuery());
        }
Exemplo n.º 4
0
        /// <summary>根据条件更新字段
        ///
        /// </summary>
        public bool Update(string strFieldWithValue, string strCond)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update BseUrl2 set ");
            strSql.Append(strFieldWithValue);
            if (!string.IsNullOrEmpty(strCond))
            {
                strSql.Append(" where " + strCond);
            }
            IDbHelper h = GlobalHelp.GetDataAccessHelper();

            h.CreateCommand(strSql.ToString());
            return(h.ExecuteNonQuery());
        }
Exemplo n.º 5
0
        /// <summary>分页获取数据列表
        ///
        /// </summary>
        public DataSet GetList(string strFileds, string strOrder, string strOrderType, int intPageSize, int intPageIndex, string strWhere)
        {
            IDbHelper h = GlobalHelp.GetDataAccessHelper();

            h.CreateStoredCommand("[proc_SplitPage]");
            h.AddParameter("@tblName", "BseUrl2");
            h.AddParameter("@strFields", strFileds);
            h.AddParameter("@strOrder", strOrder);
            h.AddParameter("@strOrderType", strOrderType);
            h.AddParameter("@PageSize", intPageSize);
            h.AddParameter("@PageIndex", intPageIndex);
            h.AddParameter("@strWhere", strWhere);
            DataTable dt = h.ExecuteQuery();
            DataSet   ds = new DataSet();

            ds.Tables.Add(dt);
            return(ds);
        }
Exemplo n.º 6
0
        /// <summary>获得数据列表
        ///
        /// </summary>
        public DataSet GetList(string strWhere, string strFields)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select " + strFields + " ");
            strSql.Append(" FROM BseUrl2 ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            IDbHelper h = GlobalHelp.GetDataAccessHelper();

            h.CreateCommand(strSql.ToString());
            DataTable dt = h.ExecuteQuery();
            DataSet   ds = new DataSet();

            ds.Tables.Add(dt);
            return(ds);
        }
Exemplo n.º 7
0
        /// <summary>得到一个对象实体
        ///
        /// </summary>
        public Nikita.Assist.Note.Model.BseUrl2 GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select * from BseUrl2 ");
            strSql.Append(" where Id=@Id ");
            IDbHelper h = GlobalHelp.GetDataAccessHelper();

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

            strSql.Append("select top 1 * from BseUrl2 ");
            if (!string.IsNullOrEmpty(strCond))
            {
                strSql.Append(" where " + strCond);
            }
            IDbHelper h = GlobalHelp.GetDataAccessHelper();

            h.CreateCommand(strSql.ToString());
            Nikita.Assist.Note.Model.BseUrl2 model = null;
            using (IDataReader dataReader = h.ExecuteReader())
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
                h.CloseConn();
            }
            return(model);
        }
Exemplo n.º 9
0
        /// <summary>分页获取数据列表
        ///
        /// </summary>
        public List <Nikita.Assist.Note.Model.BseUrl2> GetListArray(string strFileds, string strOrder, string strOrderType, int intPageSize, int intPageIndex, string strWhere)
        {
            IDbHelper h = GlobalHelp.GetDataAccessHelper();

            h.CreateStoredCommand("[proc_SplitPage]");
            h.AddParameter("@tblName", "BseUrl2");
            h.AddParameter("@strFields", strFileds);
            h.AddParameter("@strOrder", strOrder);
            h.AddParameter("@strOrderType", strOrderType);
            h.AddParameter("@PageSize", intPageSize);
            h.AddParameter("@PageIndex", intPageIndex);
            h.AddParameter("@strWhere", strWhere);
            List <Nikita.Assist.Note.Model.BseUrl2> list = new List <Nikita.Assist.Note.Model.BseUrl2>();

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

            strSql.Append("select * ");
            strSql.Append(" FROM BseUrl2 ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            List <Nikita.Assist.Note.Model.BseUrl2> list = new List <Nikita.Assist.Note.Model.BseUrl2>();
            IDbHelper h = GlobalHelp.GetDataAccessHelper();

            h.CreateCommand(strSql.ToString());
            using (IDataReader dataReader = h.ExecuteReader())
            {
                while (dataReader.Read())
                {
                    list.Add(ReaderBind(dataReader));
                }
                h.CloseConn();
            }
            return(list);
        }
Exemplo n.º 11
0
        /// <summary>增加一条数据
        ///
        /// </summary>
        public int Add(Nikita.Assist.Note.Model.BseUrl2 model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into BseUrl2(");
            strSql.Append("Type, UrlTitle, Url, UrlContent, Remark, Status, CreateDate  )");
            strSql.Append(" values (");
            strSql.Append("@Type, @UrlTitle, @Url, @UrlContent, @Remark, @Status, @CreateDate  )");
            strSql.Append(";select @@IDENTITY");
            IDbHelper h = GlobalHelp.GetDataAccessHelper();

            h.CreateCommand(strSql.ToString());
            if (model.Type == null)
            {
                h.AddParameter("@Type", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Type", model.Type);
            }
            if (model.UrlTitle == null)
            {
                h.AddParameter("@UrlTitle", DBNull.Value);
            }
            else
            {
                h.AddParameter("@UrlTitle", model.UrlTitle);
            }
            if (model.Url == null)
            {
                h.AddParameter("@Url", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Url", model.Url);
            }
            if (model.UrlContent == null)
            {
                h.AddParameter("@UrlContent", DBNull.Value);
            }
            else
            {
                h.AddParameter("@UrlContent", model.UrlContent);
            }
            if (model.Remark == null)
            {
                h.AddParameter("@Remark", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Remark", model.Remark);
            }
            if (model.Status == null)
            {
                h.AddParameter("@Status", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Status", model.Status);
            }
            if (model.CreateDate == null)
            {
                h.AddParameter("@CreateDate", DBNull.Value);
            }
            else
            {
                h.AddParameter("@CreateDate", model.CreateDate);
            }

            int    intResult;
            string obj = h.ExecuteScalar();

            if (!int.TryParse(obj, out intResult))
            {
                return(0);
            }
            return(intResult);
        }
Exemplo n.º 12
0
        /// <summary>更新一条数据
        ///
        /// </summary>
        public bool Update(Nikita.Assist.Note.Model.BseUrl2 model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update BseUrl2 set ");
            strSql.Append("Type=@Type, UrlTitle=@UrlTitle, Url=@Url, UrlContent=@UrlContent, Remark=@Remark, Status=@Status, CreateDate=@CreateDate  ");
            strSql.Append(" where Id=@Id ");
            IDbHelper h = GlobalHelp.GetDataAccessHelper();

            h.CreateCommand(strSql.ToString());
            if (model.Id == null)
            {
                h.AddParameter("@Id", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Id", model.Id);
            }
            if (model.Type == null)
            {
                h.AddParameter("@Type", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Type", model.Type);
            }
            if (model.UrlTitle == null)
            {
                h.AddParameter("@UrlTitle", DBNull.Value);
            }
            else
            {
                h.AddParameter("@UrlTitle", model.UrlTitle);
            }
            if (model.Url == null)
            {
                h.AddParameter("@Url", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Url", model.Url);
            }
            if (model.UrlContent == null)
            {
                h.AddParameter("@UrlContent", DBNull.Value);
            }
            else
            {
                h.AddParameter("@UrlContent", model.UrlContent);
            }
            if (model.Remark == null)
            {
                h.AddParameter("@Remark", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Remark", model.Remark);
            }
            if (model.Status == null)
            {
                h.AddParameter("@Status", DBNull.Value);
            }
            else
            {
                h.AddParameter("@Status", model.Status);
            }
            if (model.CreateDate == null)
            {
                h.AddParameter("@CreateDate", DBNull.Value);
            }
            else
            {
                h.AddParameter("@CreateDate", model.CreateDate);
            }

            return(h.ExecuteNonQuery());
        }