public Goods FindGoodByName(string name) { Goods g = null; string sql = "select * from goods where name ='" + name + "'"; MySqlConnection conn = GetConnection.getConnection(); MySqlCommand comd = new MySqlCommand(sql, conn); MySqlDataReader reader = comd.ExecuteReader(); while (reader.Read()) { g = new Goods(); g.id = reader.GetInt32(0); g.name = reader.GetString(1); g.price = reader.GetDouble(2); } conn.Close(); return(g); }
public List <Goods> FindGoodsBySellerId(int id) { List <Goods> list = new List <Goods>(); string sql = "select * from goods where s_id = " + id; MySqlConnection conn = GetConnection.getConnection(); MySqlCommand comd = new MySqlCommand(sql, conn); MySqlDataReader reader = comd.ExecuteReader(); while (reader.Read()) { Goods g = new Goods(); g = new Goods(); g.id = reader.GetInt32(0); g.name = reader.GetString(1); g.price = reader.GetDouble(2); list.Add(g); } return(list); }
public Customer FindCustomerByName(string name) { Customer c = null; string sql = "select * from customer where name = '" + name + "'"; MySqlConnection conn = GetConnection.getConnection(); MySqlCommand comd = new MySqlCommand(sql, conn); MySqlDataReader reader = comd.ExecuteReader(); while (reader.Read()) { c = new Customer(); c.id = reader.GetInt32(0); c.name = reader.GetString(1); c.psw = reader.GetString(2); c.telphone = reader.GetString(3); c.address = reader.GetString(4); } conn.Close(); return(c); }