Exemplo n.º 1
0
        private void materialFlatButton2_Click(object sender, EventArgs e)
        {
            ScorecDb db = new ScorecDb();

            using (BrainStormerEntitiesS brdb = new BrainStormerEntitiesS())
            {
                var sc = new Score {
                    UserID = userName, Scores = score, TimePlayed = DateTime.Now
                };
                try
                {
                    brdb.Entry(sc).State = EntityState.Added;
                    brdb.SaveChanges();
                }
                catch (Exception)
                {
                    brdb.Entry(sc).State = EntityState.Modified;
                    brdb.SaveChanges();
                }
            }
            Hide();
            var wc = new WelcomScreen();

            wc.userName = userName;
            wc.score    = score.ToString();
            wc.Closed  += (s, args) => this.Close();
            wc.Show();
        }
Exemplo n.º 2
0
        private void materialRaisedButton1_Click(object sender, EventArgs e)
        {
            string userName = txtEmail.Text;

            string passWord = txtPassWord.Text;

            try
            {
                var un = logdb.First(r => r.Key == userName);
                if (un.Key == userName && un.Value == passWord)
                {
                    using (BrainStormerEntities2 br = new BrainStormerEntities2())
                    {
                        var temp = br.playerLogins.First(p => p.Email == userName);
                        id1 = temp.Id;
                    }

                    MessageBox.Show("Login Successfull");
                    Hide();
                    var wc = new GameScreen();
                    try
                    {
                        using (BrainStormerEntitiesS br = new BrainStormerEntitiesS())
                        {
                            var temp = br.Scores.First(s => s.UserID == userName);
                            wc.score = (float)temp.Scores;
                        }
                    }
                    catch (Exception)
                    {
                        wc.score = 10;
                    }
                    wc.userName = userName;
                    wc.Id       = id1;
                    wc.Closed  += (s, args) => this.Close();
                    wc.userName = userName;
                    wc.Show();
                }
                else
                {
                    MessageBox.Show("Invalid Email Or Password");
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Invalid Email Or Password");
            }
        }
Exemplo n.º 3
0
        private void Scores_Load(object sender, EventArgs e)
        {
            using (BrainStormerEntitiesS br = new BrainStormerEntitiesS())
            {
                foreach (var i in br.Scores)
                {
                    highscores.Add((float)i.Scores, i.UserID);
                }
            }

            try
            {
                var p1 = highscores.ElementAt(0);
                lblScore.Text    = p1.Key.ToString();
                lblUserName.Text = p1.Value;
            }
            catch (Exception)
            {
                lblScore.Text    = "NULL";
                lblUserName.Text = "NULL";
            }
            try
            {
                var p2 = highscores.ElementAt(1);
                lblScore1.Text    = p2.Key.ToString();
                lblUserName1.Text = p2.Value;
            }
            catch (Exception)
            {
                lblScore1.Text    = "NULL";
                lblUserName1.Text = "NULL";
            }
            try
            {
                var p3 = highscores.ElementAt(3);
                lblScore2.Text    = p3.Key.ToString();
                lblUserName2.Text = p3.Value;
            }
            catch (Exception)
            {
                lblScore2.Text    = "NULL";
                lblUserName2.Text = "NULL";
            }
        }