Ejemplo n.º 1
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Bookhole_blog.Model.about_me DataRowToModel(DataRow row)
 {
     Bookhole_blog.Model.about_me model = new Bookhole_blog.Model.about_me();
     if (row != null)
     {
         if (row["About_title"] != null)
         {
             model.About_title = row["About_title"].ToString();
         }
         if (row["About_text"] != null)
         {
             model.About_text = row["About_text"].ToString();
         }
         if (row["About_img"] != null)
         {
             model.About_img = row["About_img"].ToString();
         }
         if (row["About_phone"] != null && row["About_phone"].ToString() != "")
         {
             model.About_phone = int.Parse(row["About_phone"].ToString());
         }
         if (row["About_email"] != null)
         {
             model.About_email = row["About_email"].ToString();
         }
     }
     return(model);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Bookhole_blog.Model.about_me model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into about_me(");
            strSql.Append("About_title,About_text,About_img,About_phone,About_email)");
            strSql.Append(" values (");
            strSql.Append("@About_title,@About_text,@About_img,@About_phone,@About_email)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@About_title", MySqlDbType.VarChar,  50),
                new MySqlParameter("@About_text",  MySqlDbType.VarChar, 255),
                new MySqlParameter("@About_img",   MySqlDbType.VarChar,  40),
                new MySqlParameter("@About_phone", MySqlDbType.Int32,    11),
                new MySqlParameter("@About_email", MySqlDbType.VarChar, 30)
            };
            parameters[0].Value = model.About_title;
            parameters[1].Value = model.About_text;
            parameters[2].Value = model.About_img;
            parameters[3].Value = model.About_phone;
            parameters[4].Value = model.About_email;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Bookhole_blog.Model.about_me GetModel()
        {
            //该表无主键信息,请自定义主键/条件字段
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select About_title,About_text,About_img,About_phone,About_email from about_me ");
            strSql.Append(" where ");
            MySqlParameter[] parameters =
            {
            };

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

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