Пример #1
0
        private void FillDataGrid()
        {
            HookADuckDataClassesDataContext context = new HookADuckDataClassesDataContext();
            List <GetAllPrizesResult>       prizes  = context.GetAllPrizes().ToList <GetAllPrizesResult>();

            gridPrizes.ItemsSource = prizes;

            gridPrizes.ItemContainerGenerator.StatusChanged += (s, e) =>
            {
                if (gridPrizes.ItemContainerGenerator.Status == GeneratorStatus.ContainersGenerated)
                {
                    foreach (GetAllPrizesResult prize in gridPrizes.ItemsSource)
                    {
                        var row = gridPrizes.ItemContainerGenerator.ContainerFromItem(prize) as DataGridRow;
                        if (prize.Won == 1)
                        {
                            if (row != null)
                            {
                                row.Background = Brushes.Pink;
                            }
                        }
                    }
                }
            };
        }
Пример #2
0
        private void FillDataGrid()
        {
            HookADuckDataClassesDataContext context = new HookADuckDataClassesDataContext();
            List <GetAllDucksResult>        ducks   = context.GetAllDucks().ToList <GetAllDucksResult>();

            gridDucks.ItemsSource = ducks;
        }
Пример #3
0
        private void TxtBarcode_KeyDown(object sender, KeyEventArgs e)
        {
            string etr = e.Key.ToString();

            if (etr == "Return")
            {
                HookADuckDataClassesDataContext context = new HookADuckDataClassesDataContext();
                List <CheckDuckResult>          prizes  = context.CheckDuck(Barcode.Text).ToList <CheckDuckResult>();

                RoutedEventArgs args = new RoutedEventArgs();
                switch (prizes.Count)
                {
                case 0:
                    // Invalid Barcode scanned, not in the database
                    CheckPrize(null, args);
                    //MessageBox.Show("Invalid Barcode scanned, please try again");
                    break;

                case 1:
                    CheckPrize(prizes[0], args);
                    //if (prizes[0].PrizeID == null)
                    //{
                    //    no prize assigned to wristband
                    //    CheckPrize(prizes[0], args);
                    //    MessageBox.Show("Sorry, no prize assigned to this wristband");
                    //}
                    //else
                    //{
                    //    wristband has won a prize
                    //    List<GetPrizeResult> prize = context.GetPrize(prizes[0].PrizeID).ToList<GetPrizeResult>();
                    //    if (prize[0].Won == 0)
                    //    {
                    //        string description = prize[0].Prize.TrimEnd(' ');
                    //        string name = prizes[0].Name.TrimEnd(' ');
                    //        MessageBox.Show("Congratulations, you have won a " + description + " from " + name);

                    //        string image = prize[0].Image;
                    //        var uri = new Uri(@"c:\users\chrisd.dakotais\documents\visual studio 2017\Projects\HookADuck\HookADuck\Images\" + image);
                    //        rubberduck.Source = new BitmapImage(uri);
                    //        update the prize to set it as won
                    //        context.UpdatePrize(prize[0].ID);
                    //    }
                    //    else
                    //    {
                    //        MessageBox.Show("Sorry, this prize has already been won");
                    //    }
                    //}

                    // update the duck to set it as scanned
                    context.UpdateDuck(Barcode.Text);
                    break;

                default:
                    // error - more than one prize assigned
                    MessageBox.Show("Congratulations, wristband has won a prize");
                    break;
                }
            }
        }
Пример #4
0
        private void CheckPrize(object sender)
        {
            CheckDuckResult duck = sender as CheckDuckResult;

            if (duck == null)
            {
                labelPrizeMessage.Text = "Invalid Barcode scanned, please try again";
                pictureBox.Image       = GetResourceImage("sad_duck");
            }
            else if (duck.PrizeID == null)
            {
                string name = duck.Name.TrimEnd(' ');
                labelPrizeMessage.Text = @"Sorry, " + name + @" Duck says “You haven’t won a prize this time. Well, its not all bad news, we have a Dakota pen for you”";
                //Blink(labelPrizeMessage, false);
                pictureBox.Image = GetResourceImage("sad_duck");
            }
            else
            {
                // wristband has won a prize
                HookADuckDataClassesDataContext context = new HookADuckDataClassesDataContext();
                List <GetPrizeResult>           won     = context.GetPrize(duck.PrizeID).ToList <GetPrizeResult>();
                if (won[0].Won == 0)
                {
                    string description = won[0].Prize.TrimEnd(' ');
                    string name        = duck.Name.TrimEnd(' ');
                    string image       = won[0].Image.TrimEnd(' ');
                    //SoftBlink(labelPrizeMessage, Color.White, Color.FromArgb(0, 182, 222), 3000, false);
                    labelPrizeMessage.Text = "Congratulations, " + name + " Duck is a lucky duck and you're the winner of a " + description;
                    //Blink(labelPrizeMessage, true);
                    pictureBox.Image = GetResourceImage(image);

                    // update the prize to set it as won
                    context.UpdatePrize(won[0].ID);
                }
                else
                {
                    string description = won[0].Prize.TrimEnd(' ');
                    string name        = duck.Name.TrimEnd(' ');
                    string image       = won[0].Image.TrimEnd(' ');

                    labelPrizeMessage.Text = "Sorry, " + name + " Duck says “My " + won[0].Prize.TrimEnd(' ') + " has already been won”";
                    //Blink(labelPrizeMessage, false);
                    //SoftBlink(labelPrizeMessage, Color.White, Color.FromArgb(0, 182, 222), 1000, false);
                    pictureBox.Image = GetResourceImage(image);
                }
            }

            textBoxBarcode.Clear();
            timerChangePicture.Stop();
            timerChangePicture.Start();
        }
Пример #5
0
        public CheckPrize(object sender)
        {
            InitializeComponent();
            CheckDuckResult duck = sender as CheckDuckResult;

            if (duck == null)
            {
                textBlockMessage.Text = "Invalid Barcode scanned, please try again";
            }
            else if (duck.PrizeID == null)
            {
                string name = duck.Name.TrimEnd(' ');
                //MessageBox.Show("Congratulations, you have won a " + description + " from " + name);
                textBlockMessage.Text = @"Sorry, " + name + @" says 'I don't have a prize!'";
                var uri = new Uri(@"c:\users\chrisd.dakotais\documents\visual studio 2017\Projects\HookADuck\HookADuck\Images\sad_duck.jpg");
                prizeImage.Source = new BitmapImage(uri);
            }
            else
            {
                // wristband has won a prize
                HookADuckDataClassesDataContext context = new HookADuckDataClassesDataContext();
                List <GetPrizeResult>           won     = context.GetPrize(duck.PrizeID).ToList <GetPrizeResult>();
                if (won[0].Won == 0)
                {
                    string description = won[0].Prize.TrimEnd(' ');
                    string name        = duck.Name.TrimEnd(' ');
                    string image       = won[0].Image;
                    //MessageBox.Show("Congratulations, you have won a " + description + " from " + name);
                    textBlockMessage.Text = "Congratulations, you have won a " + description + " from " + name;

                    var uri = new Uri(@"c:\users\chrisd.dakotais\documents\visual studio 2017\Projects\HookADuck\HookADuck\Images\" + image);
                    prizeImage.Source = new BitmapImage(uri);
                    // update the prize to set it as won
                    context.UpdatePrize(won[0].ID);
                }
                else
                {
                    string description = won[0].Prize.TrimEnd(' ');
                    string name        = duck.Name.TrimEnd(' ');
                    string image       = won[0].Image;
                    //MessageBox.Show("Congratulations, you have won a " + description + " from " + name);
                    textBlockMessage.Text = "Sorry, " + name + " says my " + won[0].Prize.TrimEnd(' ') + " has already been won!";

                    var uri = new Uri(@"c:\users\chrisd.dakotais\documents\visual studio 2017\Projects\HookADuck\HookADuck\Images\" + image);
                    prizeImage.Source = new BitmapImage(uri);
                }
            }
        }
Пример #6
0
        private void CheckPrize(object sender)
        {
            CheckDuckResult duck = sender as CheckDuckResult;

            if (duck == null)
            {
                labelPrizeMessage.Text = "Invalid Barcode scanned, please try again";
                pictureBox.Image       = GetResourceImage("sad_duck");
            }
            else if (duck.PrizeID == null)
            {
                string name = duck.Name.TrimEnd(' ');
                labelPrizeMessage.Text = @"Sorry, " + name + @" says 'I don't have a prize!'";
                pictureBox.Image       = GetResourceImage("sad_duck");
            }
            else
            {
                // wristband has won a prize
                HookADuckDataClassesDataContext context = new HookADuckDataClassesDataContext();
                List <GetPrizeResult>           won     = context.GetPrize(duck.PrizeID).ToList <GetPrizeResult>();
                if (won[0].Won == 0)
                {
                    string description = won[0].Prize.TrimEnd(' ');
                    string name        = duck.Name.TrimEnd(' ');
                    string image       = won[0].Image.TrimEnd(' ');

                    labelPrizeMessage.Text = "Congratulations, you have won a " + description + " from " + name;
                    pictureBox.Image       = GetResourceImage(image);

                    // update the prize to set it as won
                    context.UpdatePrize(won[0].ID);
                }
                else
                {
                    string description = won[0].Prize.TrimEnd(' ');
                    string name        = duck.Name.TrimEnd(' ');
                    string image       = won[0].Image.TrimEnd(' ');

                    labelPrizeMessage.Text = "Sorry, " + name + " says my " + won[0].Prize.TrimEnd(' ') + " has already been won!";
                    pictureBox.Image       = GetResourceImage(image);
                }
            }

            textBoxBarcode.Clear();
            timerChangePicture.Start();
        }
Пример #7
0
        private void textBoxBarcode_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyData.ToString() == "Return")
            {
                //labelPrizeMessage.Text = String.Empty;
                //SoftBlink(labelPrizeMessage, Color.White, Color.FromArgb(0, 182, 222), 0, false);

                string duckCode = textBoxBarcode.Text;
                if (textBoxBarcode.Text.Length == 22)
                {
                    duckCode = textBoxBarcode.Text.Remove(0, 17);
                    duckCode = duckCode.Remove(duckCode.Length - 1);
                }

                HookADuckDataClassesDataContext context = new HookADuckDataClassesDataContext();
                List <CheckDuckResult>          prizes  = context.CheckDuck(duckCode).ToList <CheckDuckResult>();

                EventArgs args = new EventArgs();
                switch (prizes.Count)
                {
                case 0:
                    // Invalid Barcode scanned, not in the database
                    CheckPrize(null /*, args*/);
                    //MessageBox.Show("Invalid Barcode scanned, please try again");
                    break;

                case 1:
                    CheckPrize(prizes[0] /*, args*/);

                    // update the duck to set it as scanned
                    context.UpdateDuck(textBoxBarcode.Text);
                    break;

                default:
                    // error - more than one prize assigned
                    MessageBox.Show("Congratulations, wristband has won a prize");
                    break;
                }
            }
        }