示例#1
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;
                }
            }
        }
示例#2
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;
                }
            }
        }