Exemple #1
0
        private void AddCompetitorItemToTable(CompetitorItem item)
        {
            tableLayoutPanelCompetitorPricing.SuspendLayout();
            RichTextBox description = GetRichTextBoxForItemList(false);
            description.Text = item.TillDescription;

            RichTextBox regularPrice = GetRichTextBoxForItemList(false);
            regularPrice.Text = item.RegularPrice.ToString("C");

            RichTextBox offerPrice = GetRichTextBoxForItemList(false);
            offerPrice.Text = item.OfferPrice.HasValue ? item.OfferPrice.Value.ToString("C") : String.Empty;

            RichTextBox competitorPrice = GetRichTextBoxForItemList(false);
            competitorPrice.Text = "█ " + (item.CompetitorPrice.HasValue ? item.CompetitorPrice.Value.ToString("C") : "NO MATCH");

            if (item.CompetitorPrice > item.OfferPrice)
            {
                competitorPrice.ForeColor = Color.Green;
            }
            else
            {
                competitorPrice.ForeColor = Color.Red;
            }

            tableLayoutPanelCompetitorPricing.RowCount++;
            int nextRow = tableLayoutPanelCompetitorPricing.RowCount - 1;
            tableLayoutPanelCompetitorPricing.Controls.Add(description, 0, nextRow);
            tableLayoutPanelCompetitorPricing.Controls.Add(regularPrice, 1, nextRow);
            tableLayoutPanelCompetitorPricing.Controls.Add(offerPrice, 2, nextRow);
            tableLayoutPanelCompetitorPricing.Controls.Add(competitorPrice, 3, nextRow);
            tableLayoutPanelCompetitorPricing.ResumeLayout();
        }
Exemple #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 });
                    }
                }
            }
        }
Exemple #3
0
        private void AddCompetitorItemToTable(CompetitorItem item)
        {
            tableLayoutPanelCompetitorPricing.SuspendLayout();
            RichTextBox description = GetRichTextBoxForItemList(false);

            description.Text = item.TillDescription;

            RichTextBox regularPrice = GetRichTextBoxForItemList(false);

            regularPrice.Text = item.RegularPrice.ToString("C");

            RichTextBox offerPrice = GetRichTextBoxForItemList(false);

            offerPrice.Text = item.OfferPrice.HasValue ? item.OfferPrice.Value.ToString("C") : String.Empty;

            RichTextBox competitorPrice = GetRichTextBoxForItemList(false);

            competitorPrice.Text = "█ " + (item.CompetitorPrice.HasValue ? item.CompetitorPrice.Value.ToString("C") : "NO MATCH");

            if (item.CompetitorPrice > item.OfferPrice)
            {
                competitorPrice.ForeColor = Color.Green;
            }
            else
            {
                competitorPrice.ForeColor = Color.Red;
            }

            tableLayoutPanelCompetitorPricing.RowCount++;
            int nextRow = tableLayoutPanelCompetitorPricing.RowCount - 1;

            tableLayoutPanelCompetitorPricing.Controls.Add(description, 0, nextRow);
            tableLayoutPanelCompetitorPricing.Controls.Add(regularPrice, 1, nextRow);
            tableLayoutPanelCompetitorPricing.Controls.Add(offerPrice, 2, nextRow);
            tableLayoutPanelCompetitorPricing.Controls.Add(competitorPrice, 3, nextRow);
            tableLayoutPanelCompetitorPricing.ResumeLayout();
        }
Exemple #4
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});
                    }
                }
            }
        }