예제 #1
0
        private void ButtonStartGame_Click(object sender, EventArgs e)
        {
            bool      playagain;
            GameField new_game;

            do
            {
                new_game = new GameField();

                playagain = false;
                try
                {
                    new_game.FillUserForm(login_user.Email, ByteArrayToImage(login_user.UserImage), user_mail, user_score, user_id);
                }
                catch (Exception) { };

                if (new_game.ShowDialog() == DialogResult.OK)
                {
                    playagain = new_game.PlayAgin;
                    if (new_game.score > 0)
                    {
                        UserRezalts newrezalt = new UserRezalts
                        {
                            UserScore = new_game.score,
                            UserID    = login_user.Id,
                        };

                        context.UserRezalts.Add(newrezalt);
                        context.SaveChanges();
                    }
                }
                else
                {
                    try
                    {
                        if (new_game.score > 0)
                        {
                            UserRezalts newrezalt = new UserRezalts
                            {
                                UserScore = new_game.score,
                                UserID    = login_user.Id,
                            };

                            context.UserRezalts.Add(newrezalt);
                            context.SaveChanges();
                        }
                    }
                    catch (Exception) { };
                }
            } while (playagain);
        }
예제 #2
0
        private void ButtonStartPlay_Click(object sender, EventArgs e)
        {
            bool      playagain;
            GameField games;

            do
            {
                games     = new GameField();
                playagain = false;


                if (games.ShowDialog() == DialogResult.OK)
                {
                    playagain = games.PlayAgin;
                    if (games.score > 0)
                    {
                        UserRezalts newrezalt = new UserRezalts
                        {
                            UserScore = games.score,
                            UserID    = 2,
                        };

                        context.UserRezalts.Add(newrezalt);
                        context.SaveChanges();
                    }
                }
                else
                {
                    if (games.score > 0)
                    {
                        UserRezalts newrezalt = new UserRezalts
                        {
                            UserScore = games.score,
                            UserID    = 2,
                        };

                        context.UserRezalts.Add(newrezalt);
                        context.SaveChanges();
                    }
                }
            } while (playagain);
        }