public static List <Sell_Transaction> GetAll() { List <Sell_Transaction> allSell_Transaction = new List <Sell_Transaction> { }; MySqlConnection conn = DB.Connection(); conn.Open(); MySqlCommand cmd = conn.CreateCommand() as MySqlCommand; cmd.CommandText = @"SELECT * FROM sell_transaction;"; MySqlDataReader rdr = cmd.ExecuteReader() as MySqlDataReader; while (rdr.Read()) { int id = rdr.GetInt32(0); int userseller = rdr.GetInt32(1); int userbuyer = rdr.GetInt32(2); int gameId = rdr.GetInt32(3); string status = rdr.GetString(4); string gamePhoto = rdr.GetString(5); DateTime date = rdr.GetDateTime(6); Sell_Transaction newSell_Transaction = new Sell_Transaction(gameId, userseller, status, date, gamePhoto, userbuyer, id); allSell_Transaction.Add(newSell_Transaction); } conn.Close(); if (conn != null) { conn.Dispose(); } return(allSell_Transaction); }
public override bool Equals(System.Object otherSell_Transaction) { if (!(otherSell_Transaction is Sell_Transaction)) { return(false); } else { Sell_Transaction newSell_Transaction = (Sell_Transaction)otherSell_Transaction; return(this.GetId().Equals(newSell_Transaction.GetId())); } }
public static Sell_Transaction Find(int id) { MySqlConnection conn = DB.Connection(); conn.Open(); var cmd = conn.CreateCommand() as MySqlCommand; cmd.CommandText = @"SELECT * FROM sell_transaction WHERE id = (@searchId);"; MySqlParameter searchId = new MySqlParameter(); searchId.ParameterName = "@searchId"; searchId.Value = id; cmd.Parameters.Add(searchId); var rdr = cmd.ExecuteReader() as MySqlDataReader; int foundid = 0; int userseller = 0; int userbuyer = 0; int gameId = 0; string status = ""; string gamePhoto = ""; DateTime date = new DateTime(2000, 1, 1, 1, 0, 0); while (rdr.Read()) { foundid = rdr.GetInt32(0); userseller = rdr.GetInt32(1); userbuyer = rdr.GetInt32(2); gameId = rdr.GetInt32(3); status = rdr.GetString(4); gamePhoto = rdr.GetString(5); date = rdr.GetDateTime(6); } Sell_Transaction foundSell_Transaction = new Sell_Transaction(gameId, userseller, status, date, gamePhoto, userbuyer, foundid); conn.Close(); if (conn != null) { conn.Dispose(); } return(foundSell_Transaction); }