Example #1
0
        private void PopulateCompetitorPricing()
        {
            var connectionString = ConfigurationManager.ConnectionStrings["LiveDb"].ConnectionString;

            using (var conn = new SqlConnection(connectionString))
            {
                conn.Open();
                using (var cmd = new SqlCommand())
                {
                    cmd.Connection  = conn;
                    cmd.CommandText = "SELECT ProductId, TillDescription, RegularPrice, OfferPrice, Barcode, Image FROM Products WHERE OfferPrice IS NOT NULL";
                    var reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        if (m_competitorLookupCancellationToken.IsCancellationRequested)
                        {
                            return;
                        }
                        var item = new CompetitorItem
                        {
                            ProductId       = (int)reader["ProductId"],
                            Barcode         = (string)reader["Barcode"],
                            RegularPrice    = (Decimal)reader["RegularPrice"],
                            OfferPrice      = (Decimal?)reader["OfferPrice"],
                            TillDescription = (string)reader["TillDescription"]
                        };
                        item.CompetitorPrice = CompetitorLookup.LookupCompetitorPrice(item.TillDescription, item.OfferPrice);

                        AddCompetitorItemToTableCallback update = new AddCompetitorItemToTableCallback(AddCompetitorItemToTable);
                        this.Invoke(update, new object[] { item });
                    }
                }
            }
        }
Example #2
0
        private void PopulateCompetitorPricing()
        {
            var connectionString = ConfigurationManager.ConnectionStrings["LiveDb"].ConnectionString;
            using (var conn = new SqlConnection(connectionString))
            {
                conn.Open();
                using (var cmd = new SqlCommand())
                {
                    cmd.Connection = conn;
                    cmd.CommandText = "SELECT ProductId, TillDescription, RegularPrice, OfferPrice, Barcode, Image FROM Products WHERE OfferPrice IS NOT NULL";
                    var reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        if (m_competitorLookupCancellationToken.IsCancellationRequested)
                        {
                            return;
                        }
                        var item = new CompetitorItem
                        {
                            ProductId = (int)reader["ProductId"],
                            Barcode = (string)reader["Barcode"],
                            RegularPrice = (Decimal)reader["RegularPrice"],
                            OfferPrice = (Decimal?)reader["OfferPrice"],
                            TillDescription = (string)reader["TillDescription"]
                        };
                        item.CompetitorPrice = CompetitorLookup.LookupCompetitorPrice(item.TillDescription, item.OfferPrice);

                        AddCompetitorItemToTableCallback update = new AddCompetitorItemToTableCallback(AddCompetitorItemToTable);
                        this.Invoke(update, new object[] {item});
                    }
                }
            }
        }