/// <summary> /// 更新一条数据 /// </summary> public bool Update(WK.Model.bus_wx_user model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update bus_wx_user set "); strSql.Append("user_id=@user_id,"); strSql.Append("access_token=@access_token,"); strSql.Append("expires_in=@expires_in,"); strSql.Append("refresh_token=@refresh_token,"); strSql.Append("open_id=@open_id,"); strSql.Append("scope=@scope,"); strSql.Append("remark=@remark,"); strSql.Append("create_by=@create_by,"); strSql.Append("create_date=@create_date,"); strSql.Append("update_by=@update_by,"); strSql.Append("update_date=@update_date"); strSql.Append(" where id=@id"); MySqlParameter[] parameters = { new MySqlParameter("@user_id", MySqlDbType.Int32, 11), new MySqlParameter("@access_token", MySqlDbType.VarChar, 1000), new MySqlParameter("@expires_in", MySqlDbType.Int32, 11), new MySqlParameter("@refresh_token", MySqlDbType.VarChar, 1000), new MySqlParameter("@open_id", MySqlDbType.VarChar, 1000), new MySqlParameter("@scope", MySqlDbType.VarChar, 1000), new MySqlParameter("@remark", MySqlDbType.VarChar, 500), new MySqlParameter("@create_by", MySqlDbType.Int32, 11), new MySqlParameter("@create_date", MySqlDbType.DateTime), new MySqlParameter("@update_by", MySqlDbType.Int32, 11), new MySqlParameter("@update_date", MySqlDbType.DateTime), new MySqlParameter("@id", MySqlDbType.Int32, 11) }; parameters[0].Value = model.user_id; parameters[1].Value = model.access_token; parameters[2].Value = model.expires_in; parameters[3].Value = model.refresh_token; parameters[4].Value = model.open_id; parameters[5].Value = model.scope; parameters[6].Value = model.remark; parameters[7].Value = model.create_by; parameters[8].Value = model.create_date; parameters[9].Value = model.update_by; parameters[10].Value = model.update_date; parameters[11].Value = model.id; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WK.Model.bus_wx_user DataRowToModel(DataRow row) { WK.Model.bus_wx_user model = new WK.Model.bus_wx_user(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["user_id"] != null && row["user_id"].ToString() != "") { model.user_id = int.Parse(row["user_id"].ToString()); } if (row["access_token"] != null) { model.access_token = row["access_token"].ToString(); } if (row["expires_in"] != null && row["expires_in"].ToString() != "") { model.expires_in = int.Parse(row["expires_in"].ToString()); } if (row["refresh_token"] != null) { model.refresh_token = row["refresh_token"].ToString(); } if (row["open_id"] != null) { model.open_id = row["open_id"].ToString(); } if (row["scope"] != null) { model.scope = row["scope"].ToString(); } if (row["remark"] != null) { model.remark = row["remark"].ToString(); } if (row["create_by"] != null && row["create_by"].ToString() != "") { model.create_by = int.Parse(row["create_by"].ToString()); } if (row["create_date"] != null && row["create_date"].ToString() != "") { model.create_date = DateTime.Parse(row["create_date"].ToString()); } if (row["update_by"] != null && row["update_by"].ToString() != "") { model.update_by = int.Parse(row["update_by"].ToString()); } if (row["update_date"] != null && row["update_date"].ToString() != "") { model.update_date = DateTime.Parse(row["update_date"].ToString()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(WK.Model.bus_wx_user model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into bus_wx_user("); strSql.Append("user_id,access_token,expires_in,refresh_token,open_id,scope,remark,create_by,create_date,update_by,update_date)"); strSql.Append(" values ("); strSql.Append("@user_id,@access_token,@expires_in,@refresh_token,@open_id,@scope,@remark,@create_by,@create_date,@update_by,@update_date)"); MySqlParameter[] parameters = { new MySqlParameter("@user_id", MySqlDbType.Int32, 11), new MySqlParameter("@access_token", MySqlDbType.VarChar, 1000), new MySqlParameter("@expires_in", MySqlDbType.Int32, 11), new MySqlParameter("@refresh_token", MySqlDbType.VarChar, 1000), new MySqlParameter("@open_id", MySqlDbType.VarChar, 1000), new MySqlParameter("@scope", MySqlDbType.VarChar, 1000), new MySqlParameter("@remark", MySqlDbType.VarChar, 500), new MySqlParameter("@create_by", MySqlDbType.Int32, 11), new MySqlParameter("@create_date", MySqlDbType.DateTime), new MySqlParameter("@update_by", MySqlDbType.Int32, 11), new MySqlParameter("@update_date", MySqlDbType.DateTime) }; parameters[0].Value = model.user_id; parameters[1].Value = model.access_token; parameters[2].Value = model.expires_in; parameters[3].Value = model.refresh_token; parameters[4].Value = model.open_id; parameters[5].Value = model.scope; parameters[6].Value = model.remark; parameters[7].Value = model.create_by; parameters[8].Value = model.create_date; parameters[9].Value = model.update_by; parameters[10].Value = model.update_date; int rows = DbHelperMySQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public WK.Model.bus_wx_user GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select id,user_id,access_token,expires_in,refresh_token,open_id,scope,remark,create_by,create_date,update_by,update_date from bus_wx_user "); strSql.Append(" where id=@id"); MySqlParameter[] parameters = { new MySqlParameter("@id", MySqlDbType.Int32) }; parameters[0].Value = id; WK.Model.bus_wx_user model = new WK.Model.bus_wx_user(); DataSet ds = DbHelperMySQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }