Esempio n. 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(SeoWebSite.Model.CountryClass model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update CountryClass set ");
            strSql.Append("data=@data");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@data", SqlDbType.NVarChar, 1000),
                new SqlParameter("@id",   SqlDbType.Int, 4)
            };
            parameters[0].Value = model.data;
            parameters[1].Value = model.id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SeoWebSite.Model.CountryClass GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,data from CountryClass ");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            SeoWebSite.Model.CountryClass model = new SeoWebSite.Model.CountryClass();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["data"] != null && ds.Tables[0].Rows[0]["data"].ToString() != "")
                {
                    model.data = ds.Tables[0].Rows[0]["data"].ToString();
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(SeoWebSite.Model.CountryClass model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into CountryClass(");
            strSql.Append("id,data)");
            strSql.Append(" values (");
            strSql.Append("@id,@data)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",   SqlDbType.Int,      4),
                new SqlParameter("@data", SqlDbType.NVarChar, 1000)
            };
            parameters[0].Value = model.id;
            parameters[1].Value = model.data;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Esempio n. 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SeoWebSite.Model.CountryClass GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("select  top 1 id,data from CountryClass ");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters[0].Value = id;

            SeoWebSite.Model.CountryClass model = new SeoWebSite.Model.CountryClass();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);
            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                if (ds.Tables[0].Rows[0]["data"] != null && ds.Tables[0].Rows[0]["data"].ToString() != "")
                {
                    model.data = ds.Tables[0].Rows[0]["data"].ToString();
                }
                return model;
            }
            else
            {
                return null;
            }
        }