Ejemplo n.º 1
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();
        }
Ejemplo n.º 2
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);
                }
            }
        }
Ejemplo n.º 3
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();
        }