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

            strSql.Append("update img set ");
            strSql.Append("Img_address=@Img_address,");
            strSql.Append("Img_text=@Img_text,");
            strSql.Append("Img_is=@Img_is");
            strSql.Append(" where Img_id=@Img_id ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@Img_address", MySqlDbType.VarChar, 255),
                new MySqlParameter("@Img_text",    MySqlDbType.VarChar, 255),
                new MySqlParameter("@Img_is",      MySqlDbType.Int32,    11),
                new MySqlParameter("@Img_id",      MySqlDbType.Int32, 11)
            };
            parameters[0].Value = model.Img_address;
            parameters[1].Value = model.Img_text;
            parameters[2].Value = model.Img_is;
            parameters[3].Value = model.Img_id;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Bookhole_blog.Model.img model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into img(");
            strSql.Append("Img_id,Img_address,Img_text,Img_is)");
            strSql.Append(" values (");
            strSql.Append("@Img_id,@Img_address,@Img_text,@Img_is)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@Img_id",      MySqlDbType.Int32,    11),
                new MySqlParameter("@Img_address", MySqlDbType.VarChar, 255),
                new MySqlParameter("@Img_text",    MySqlDbType.VarChar, 255),
                new MySqlParameter("@Img_is",      MySqlDbType.Int32, 11)
            };
            parameters[0].Value = model.Img_id;
            parameters[1].Value = model.Img_address;
            parameters[2].Value = model.Img_text;
            parameters[3].Value = model.Img_is;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Bookhole_blog.Model.img DataRowToModel(DataRow row)
 {
     Bookhole_blog.Model.img model = new Bookhole_blog.Model.img();
     if (row != null)
     {
         if (row["Img_id"] != null && row["Img_id"].ToString() != "")
         {
             model.Img_id = int.Parse(row["Img_id"].ToString());
         }
         if (row["Img_address"] != null)
         {
             model.Img_address = row["Img_address"].ToString();
         }
         if (row["Img_text"] != null)
         {
             model.Img_text = row["Img_text"].ToString();
         }
         if (row["Img_is"] != null && row["Img_is"].ToString() != "")
         {
             model.Img_is = int.Parse(row["Img_is"].ToString());
         }
     }
     return(model);
 }
Esempio n. 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Bookhole_blog.Model.img GetModel(int Img_id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select Img_id,Img_address,Img_text,Img_is from img ");
            strSql.Append(" where Img_id=@Img_id ");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@Img_id", MySqlDbType.Int32, 11)
            };
            parameters[0].Value = Img_id;

            Bookhole_blog.Model.img model = new Bookhole_blog.Model.img();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters);

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