Esempio n. 1
0
        public int CompareTo(object obj)
        {
            Games that = obj as Games;

            return(this.GameName.CompareTo(that.GameName));
        }
Esempio n. 2
0
 public PrintForm(Games games) : this()
 {
     this.games       = new GameCatalog();
     this.games.Games = games;
     Init();
 }
Esempio n. 3
0
 /// <summary>
 ///	 <para>
 ///	   Initializes a new instance of <see cref='Game'/> based on another <see cref='Game'/>.
 ///	</para>
 /// </summary>
 /// <param name='value'>
 ///	   A <see cref='Game'/> from which the contents are copied
 /// </param>
 public Games(Games value)
 {
     this.AddRange(value);
 }
Esempio n. 4
0
 /// Initializes with a collection of Game objects.
 /// Collection of data.
 public GameArgs(Games ts) : this()
 {
     this.t.AddRange(ts);
 }
Esempio n. 5
0
 /// Default constructor.
 public GameArgs()
 {
     t = new Games();
 }
Esempio n. 6
0
        private void btnAddNewGame_Click(object sender, RoutedEventArgs e)
        {
            string errors;

            errors = "You have the following errors:";

            bool check = true;

            decimal review, price;

            Uri uriResult;

            string Title = tbxEnterTitle.Text, Description = tbxEnterDescription.Text, Review = tbxEnterReview.Text, Price = tbxEnterPrice.Text, URL = tbxEnterURL.Text;

            if (Title == "" || Title == "Enter Title")
            {
                errors += "\nInvalid Title name";
                check   = false;
            }

            if (Description == "" || Description == "Enter Description")
            {
                errors += "\nInvalid Description";
                check   = false;
            }

            if (!decimal.TryParse(Review, out review))
            {
                errors += "\nInvalid Review: must be a decimal";
                check   = false;
            }
            else
            {
                decimal.TryParse(Review, out review);

                if (review > 10 || review < 0)
                {
                    errors += "\nInvalid Review: must be a number between 0 or 10";
                    check   = false;
                }
            }

            if (!Uri.TryCreate(URL, UriKind.Absolute, out uriResult))
            {
                errors += "\nInvalid URL";
                check   = false;
            }
            else
            {
                Uri.TryCreate(URL, UriKind.Absolute, out uriResult);
            }

            if (!decimal.TryParse(Price, out price))
            {
                errors += "\nInvalid Price: must be a decimal";
                check   = false;
            }
            else
            {
                decimal.TryParse(Price, out price);

                if (price < 0)
                {
                    errors += "\nInvalid Price: must be a number greater than or equal to 0";
                    check   = false;
                }
            }

            if (check)
            {
                Games game = new Games()
                {
                    GameName        = Title,
                    GameDescription = Description,
                    GamePrice       = price,
                    GameRating      = review,
                    ImageURL        = URL
                };

                db.Games.Add(game);
                MessageBox.Show("Added " + game.ToString() + " to the database");

                db.SaveChanges();
                MessageBox.Show("Saved changes");

                var query = from games in db.Games
                            select games;

                games = query.ToList();
                games.Sort();

                lbxGameList.ItemsSource = games;
            }
            else
            {
                MessageBox.Show(errors, "ERRORS", MessageBoxButton.OK, MessageBoxImage.Error);
                tbxEnterTitle.Text       = "Enter Title Name";
                tbxEnterDescription.Text = "Enter Description";
                tbxEnterPrice.Text       = "Price";
                tbxEnterReview.Text      = "0";
                tbxEnterURL.Text         = "Enter URL";
            }
        }