示例#1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(guanbingking.Model.ProductImg model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update ProductImg set ");
            strSql.Append("Src=@Src,");
            strSql.Append("ProductId=@ProductId");
            strSql.Append(" where Id=@Id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Src",       SqlDbType.VarChar, 1),
                new SqlParameter("@ProductId", SqlDbType.Int,     4),
                new SqlParameter("@Id",        SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Src;
            parameters[1].Value = model.ProductId;
            parameters[2].Value = model.Id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(guanbingking.Model.ProductImg model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ProductImg(");
            strSql.Append("Id,Src,ProductId)");
            strSql.Append(" values (");
            strSql.Append("@Id,@Src,@ProductId)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id",        SqlDbType.Int,     4),
                new SqlParameter("@Src",       SqlDbType.VarChar, 1),
                new SqlParameter("@ProductId", SqlDbType.Int, 4)
            };
            parameters[0].Value = model.Id;
            parameters[1].Value = model.Src;
            parameters[2].Value = model.ProductId;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public guanbingking.Model.ProductImg DataRowToModel(DataRow row)
 {
     guanbingking.Model.ProductImg model = new guanbingking.Model.ProductImg();
     if (row != null)
     {
         if (row["Id"] != null && row["Id"].ToString() != "")
         {
             model.Id = int.Parse(row["Id"].ToString());
         }
         if (row["Src"] != null)
         {
             model.Src = row["Src"].ToString();
         }
         if (row["ProductId"] != null && row["ProductId"].ToString() != "")
         {
             model.ProductId = int.Parse(row["ProductId"].ToString());
         }
     }
     return(model);
 }
示例#4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public guanbingking.Model.ProductImg GetModel(int Id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 Id,Src,ProductId from ProductImg ");
            strSql.Append(" where Id=@Id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id", SqlDbType.Int, 4)
            };
            parameters[0].Value = Id;

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

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }