Пример #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public void Update(ROYcms.Sys.Model.ROYcms_CaiRss model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update " + PubConstant.date_prefix + "CaiRss set ");
            strSql.Append("RssUrl=@RssUrl,");
            strSql.Append("Encode=@Encode,");
            strSql.Append("HtmlStar=@HtmlStar,");
            strSql.Append("HtmlEnd=@HtmlEnd,");
            strSql.Append("Path=@Path,");
            strSql.Append("Time=@Time");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",       SqlDbType.Int,         4),
                new SqlParameter("@RssUrl",   SqlDbType.NVarChar,  500),
                new SqlParameter("@Encode",   SqlDbType.NVarChar,   10),
                new SqlParameter("@HtmlStar", SqlDbType.NVarChar, 1000),
                new SqlParameter("@HtmlEnd",  SqlDbType.NVarChar, 1000),
                new SqlParameter("@Path",     SqlDbType.NVarChar,  500),
                new SqlParameter("@Time",     SqlDbType.DateTime)
            };
            parameters[0].Value = model.id;
            parameters[1].Value = model.RssUrl;
            parameters[2].Value = model.Encode;
            parameters[3].Value = model.HtmlStar;
            parameters[4].Value = model.HtmlEnd;
            parameters[5].Value = model.Path;
            parameters[6].Value = model.Time;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Пример #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ROYcms.Sys.Model.ROYcms_CaiRss GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,RssUrl,Encode,HtmlStar,HtmlEnd,Path,Time from " + PubConstant.date_prefix + "CaiRss ");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            ROYcms.Sys.Model.ROYcms_CaiRss model = new ROYcms.Sys.Model.ROYcms_CaiRss();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["id"].ToString() != "")
                {
                    model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString());
                }
                model.RssUrl   = ds.Tables[0].Rows[0]["RssUrl"].ToString();
                model.Encode   = ds.Tables[0].Rows[0]["Encode"].ToString();
                model.HtmlStar = ds.Tables[0].Rows[0]["HtmlStar"].ToString();
                model.HtmlEnd  = ds.Tables[0].Rows[0]["HtmlEnd"].ToString();
                model.Path     = ds.Tables[0].Rows[0]["Path"].ToString();
                if (ds.Tables[0].Rows[0]["Time"].ToString() != "")
                {
                    model.Time = DateTime.Parse(ds.Tables[0].Rows[0]["Time"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Пример #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(ROYcms.Sys.Model.ROYcms_CaiRss model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into " + PubConstant.date_prefix + "CaiRss(");
            strSql.Append("RssUrl,Encode,HtmlStar,HtmlEnd,Path,Time)");
            strSql.Append(" values (");
            strSql.Append("@RssUrl,@Encode,@HtmlStar,@HtmlEnd,@Path,@Time)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@RssUrl",   SqlDbType.NVarChar,  500),
                new SqlParameter("@Encode",   SqlDbType.NVarChar,   10),
                new SqlParameter("@HtmlStar", SqlDbType.NVarChar, 1000),
                new SqlParameter("@HtmlEnd",  SqlDbType.NVarChar, 1000),
                new SqlParameter("@Path",     SqlDbType.NVarChar,  500),
                new SqlParameter("@Time",     SqlDbType.DateTime)
            };
            parameters[0].Value = model.RssUrl;
            parameters[1].Value = model.Encode;
            parameters[2].Value = model.HtmlStar;
            parameters[3].Value = model.HtmlEnd;
            parameters[4].Value = model.Path;
            parameters[5].Value = model.Time;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }