Ejemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.messages.messages_rate model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update messages_rate set ");
            strSql.Append("rate=@rate,");
            strSql.Append("upd_time=@upd_time");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@rate",     MySqlDbType.Int32,     11),
                new MySqlParameter("@upd_time", MySqlDbType.DateTime),
                new MySqlParameter("@id",       MySqlDbType.Int32, 11)
            };
            parameters[0].Value = model.rate;
            parameters[1].Value = model.upd_time;
            parameters[2].Value = model.id;

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

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

            strSql.Append("insert into messages_rate(");
            strSql.Append("rate,upd_time)");
            strSql.Append(" values (");
            strSql.Append("@rate,@upd_time)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@rate",     MySqlDbType.Int32, 11),
                new MySqlParameter("@upd_time", MySqlDbType.DateTime)
            };
            parameters[0].Value = model.rate;
            parameters[1].Value = model.upd_time;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.messages.messages_rate DataRowToModel(DataRow row)
 {
     Maticsoft.Model.messages.messages_rate model = new Maticsoft.Model.messages.messages_rate();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["rate"] != null && row["rate"].ToString() != "")
         {
             model.rate = int.Parse(row["rate"].ToString());
         }
         if (row["upd_time"] != null && row["upd_time"].ToString() != "")
         {
             model.upd_time = DateTime.Parse(row["upd_time"].ToString());
         }
     }
     return(model);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.messages.messages_rate GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select id,rate,upd_time from messages_rate ");
            strSql.Append(" where id=@id");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@id", MySqlDbType.Int32)
            };
            parameters[0].Value = id;

            Maticsoft.Model.messages.messages_rate model = new Maticsoft.Model.messages.messages_rate();
            DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters);

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