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

            strSql.Append("update forecastscripts set ");
            strSql.Append("name=@name,");
            strSql.Append("content=@content,");
            strSql.Append("remark=@remark,");
            strSql.Append("win=@win,");
            strSql.Append("lost=@lost");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",      SqlDbType.Int,       4),
                new SqlParameter("@name",    SqlDbType.NVarChar, 50),
                new SqlParameter("@content", SqlDbType.Text),
                new SqlParameter("@remark",  SqlDbType.Text),
                new SqlParameter("@win",     SqlDbType.Int,       4),
                new SqlParameter("@lost",    SqlDbType.Int, 4)
            };
            parameters[0].Value = model.id;
            parameters[1].Value = model.name;
            parameters[2].Value = model.content;
            parameters[3].Value = model.remark;
            parameters[4].Value = model.win;
            parameters[5].Value = model.lost;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Esempio n. 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(SeoWebSite.Model.ForecastScripts model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into forecastscripts(");
            strSql.Append("name,content,remark,win,lost)");
            strSql.Append(" values (");
            strSql.Append("@name,@content,@remark,@win,@lost)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@name",    SqlDbType.NVarChar, 50),
                new SqlParameter("@content", SqlDbType.Text),
                new SqlParameter("@remark",  SqlDbType.Text),
                new SqlParameter("@win",     SqlDbType.Int,       4),
                new SqlParameter("@lost",    SqlDbType.Int, 4)
            };
            parameters[0].Value = model.name;
            parameters[1].Value = model.content;
            parameters[2].Value = model.remark;
            parameters[3].Value = model.win;
            parameters[4].Value = model.lost;

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

            if (obj == null)
            {
                return(1);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SeoWebSite.Model.ForecastScripts GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,name,content,remark,win,lost from forecastscripts ");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            SeoWebSite.Model.ForecastScripts model = new SeoWebSite.Model.ForecastScripts();
            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.name    = ds.Tables[0].Rows[0]["name"].ToString();
                model.content = ds.Tables[0].Rows[0]["content"].ToString();
                model.remark  = ds.Tables[0].Rows[0]["remark"].ToString();
                if (ds.Tables[0].Rows[0]["win"].ToString() != "")
                {
                    model.win = int.Parse(ds.Tables[0].Rows[0]["win"].ToString());
                }
                if (ds.Tables[0].Rows[0]["lost"].ToString() != "")
                {
                    model.lost = int.Parse(ds.Tables[0].Rows[0]["lost"].ToString());
                }
                return(model);
            }
            else
            {
                return(null);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public SeoWebSite.Model.ForecastScripts GetModel(int id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 id,name,content,remark,win,lost from forecastscripts ");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.Int,4)};
            parameters[0].Value = id;

            SeoWebSite.Model.ForecastScripts model=new SeoWebSite.Model.ForecastScripts();
            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.name=ds.Tables[0].Rows[0]["name"].ToString();
                model.content=ds.Tables[0].Rows[0]["content"].ToString();
                model.remark=ds.Tables[0].Rows[0]["remark"].ToString();
                if(ds.Tables[0].Rows[0]["win"].ToString()!="")
                {
                    model.win=int.Parse(ds.Tables[0].Rows[0]["win"].ToString());
                }
                if(ds.Tables[0].Rows[0]["lost"].ToString()!="")
                {
                    model.lost=int.Parse(ds.Tables[0].Rows[0]["lost"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }