/// <summary> /// 更新一条数据 /// </summary> public bool Update(IMeiWei.Model.role model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update role set "); strSql.Append("RoleName=@RoleName"); strSql.Append(" where Id=@Id"); MySqlParameter[] parameters = { new MySqlParameter("@RoleName", MySqlDbType.VarChar, 255), new MySqlParameter("@Id", MySqlDbType.Int64, 20) }; parameters[0].Value = model.RoleName; parameters[1].Value = model.Id; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(IMeiWei.Model.role model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into role("); strSql.Append("RoleName)"); strSql.Append(" values ("); strSql.Append("@RoleName)"); MySqlParameter[] parameters = { new MySqlParameter("@RoleName", MySqlDbType.VarChar, 255) }; parameters[0].Value = model.RoleName; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public IMeiWei.Model.role DataRowToModel(DataRow row) { IMeiWei.Model.role model = new IMeiWei.Model.role(); if (row != null) { if (row["Id"] != null && row["Id"].ToString() != "") { model.Id = long.Parse(row["Id"].ToString()); } if (row["RoleName"] != null) { model.RoleName = row["RoleName"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public IMeiWei.Model.role GetModel(long Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select Id,RoleName from role "); strSql.Append(" where Id=@Id"); MySqlParameter[] parameters = { new MySqlParameter("@Id", MySqlDbType.Int64) }; parameters[0].Value = Id; IMeiWei.Model.role model = new IMeiWei.Model.role(); DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }