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

            strSql.Append("update betdetail set ");
            strSql.Append("itemid=@itemid,");
            strSql.Append("name=@name,");
            strSql.Append("formulaid=@formulaid,");
            strSql.Append("description=@description");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",          SqlDbType.VarChar,  20),
                new SqlParameter("@itemid",      SqlDbType.VarChar,  20),
                new SqlParameter("@name",        SqlDbType.NVarChar, 50),
                new SqlParameter("@formulaid",   SqlDbType.VarChar,  20),
                new SqlParameter("@description", SqlDbType.NVarChar, 1000)
            };
            parameters[0].Value = model.id;
            parameters[1].Value = model.itemid;
            parameters[2].Value = model.name;
            parameters[3].Value = model.formulaid;
            parameters[4].Value = model.description;

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

            strSql.Append("select  top 1 id,itemid,name,formulaid,description from betdetail ");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.VarChar, 50)
            };
            parameters[0].Value = id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                model.id          = ds.Tables[0].Rows[0]["id"].ToString();
                model.itemid      = ds.Tables[0].Rows[0]["itemid"].ToString();
                model.name        = ds.Tables[0].Rows[0]["name"].ToString();
                model.formulaid   = ds.Tables[0].Rows[0]["formulaid"].ToString();
                model.description = ds.Tables[0].Rows[0]["description"].ToString();
                return(model);
            }
            else
            {
                return(null);
            }
        }
Пример #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public void Add(SeoWebSite.Model.BetDetail model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into betdetail(");
            strSql.Append("id,itemid,name,formulaid,description)");
            strSql.Append(" values (");
            strSql.Append("@id,@itemid,@name,@formulaid,@description)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",          SqlDbType.VarChar,  20),
                new SqlParameter("@itemid",      SqlDbType.VarChar,  20),
                new SqlParameter("@name",        SqlDbType.NVarChar, 50),
                new SqlParameter("@formulaid",   SqlDbType.VarChar,  20),
                new SqlParameter("@description", SqlDbType.NVarChar, 1000)
            };
            parameters[0].Value = model.id;
            parameters[1].Value = model.itemid;
            parameters[2].Value = model.name;
            parameters[3].Value = model.formulaid;
            parameters[4].Value = model.description;

            DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);
        }
Пример #4
0
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public SeoWebSite.Model.BetDetail GetModel(string id)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 id,itemid,name,formulaid,description from betdetail ");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters = {
                    new SqlParameter("@id", SqlDbType.VarChar,50)};
            parameters[0].Value = id;

            SeoWebSite.Model.BetDetail model=new SeoWebSite.Model.BetDetail();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                model.id=ds.Tables[0].Rows[0]["id"].ToString();
                model.itemid=ds.Tables[0].Rows[0]["itemid"].ToString();
                model.name=ds.Tables[0].Rows[0]["name"].ToString();
                model.formulaid=ds.Tables[0].Rows[0]["formulaid"].ToString();
                model.description=ds.Tables[0].Rows[0]["description"].ToString();
                return model;
            }
            else
            {
                return null;
            }
        }