public void SaveMarketplaceData(MarketplaceData mp) { try { using (MySqlCommand cmd = new MySqlCommand()) { cmd.Connection = conn; cmd.CommandText = string.Format("UPDATE marketplace_data SET Weight={0}, UOM={1}, Unpublish={2}, MAP={3} Where SKU='{4}' and MarketPlaceID={5}", mp.Weight, mp.UOM, mp.Unpublish == true ? 1 : 0, mp.MAP, mp.SKU, mp.MarketPlaceID); int numRowsUpdated = cmd.ExecuteNonQuery(); } } catch (MySql.Data.MySqlClient.MySqlException ex) { StaticLogger.LogException(ex); } }
public ObservableCollection <MarketplaceData> GetMarketDataByASIN(string asin, out string upc) { upc = string.Empty; ObservableCollection <MarketplaceData> data = new ObservableCollection <MarketplaceData>(); MySqlDataReader reader = null; try { string query = "select m.Name, mp.MarketPlaceID, mp.SKU, mp.Weight, mp.UOM, mp.Unpublish, mp.MAP, p.UPC, mp.Verified, mp.IsFood from products p, marketplace_data mp, marketplaces m where mp.SKU = p.SKU and "; query += "m.MarketPlaceID = mp.MarketPlaceID and p.ASIN=@asin;"; using (MySqlCommand cmd = new MySqlCommand(query, conn)) { cmd.Parameters.Add("@asin", MySqlDbType.VarChar); cmd.Parameters[0].Value = asin; using (reader = cmd.ExecuteReader()) { while (reader.Read()) { MarketplaceData mp = new MarketplaceData() { MarketPlaceName = reader.GetString(0), MarketPlaceID = reader.GetInt32(1), SKU = reader.GetString(2), Weight = reader.GetDouble(3), UOM = reader.GetInt32(4), Unpublish = reader.GetBoolean(5), MAP = reader.GetDouble(6), Verified = reader.IsDBNull(8) ? false : reader.GetBoolean(8), IsFood = reader.IsDBNull(9) ? false : reader.GetBoolean(9) }; data.Add(mp); upc = reader.GetString(7); } } } } catch (MySql.Data.MySqlClient.MySqlException ex) { StaticLogger.LogException(ex); } return(data); }
public ObservableCollection <MarketplaceData> GetMarketDataBySKU(string sku, out string upc) { upc = string.Empty; ObservableCollection <MarketplaceData> data = new ObservableCollection <MarketplaceData>(); MySqlDataReader reader = null; try { string query = "select m.Name, mp.*, p.UPC from products p, marketplace_data mp, marketplaces m where mp.SKU = p.SKU and "; query += "m.MarketPlaceID = mp.MarketPlaceID and p.SKU=@sku;"; using (MySqlCommand cmd = new MySqlCommand(query, conn)) { cmd.Parameters.Add("@sku", MySqlDbType.VarChar); cmd.Parameters[0].Value = sku; using (reader = cmd.ExecuteReader()) { while (reader.Read()) { MarketplaceData mp = new MarketplaceData() { MarketPlaceName = reader.GetString(0), MarketPlaceID = reader.GetInt32(1), SKU = reader.GetString(2), Weight = reader.GetDouble(3), UOM = reader.GetInt32(4), Unpublish = reader.GetBoolean(5), MAP = reader.GetDouble(6) }; data.Add(mp); upc = reader.GetString(7); } } } } catch (MySql.Data.MySqlClient.MySqlException ex) { StaticLogger.LogException(ex); } return(data); }