Example #1
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            var app   = AppController.Instance;
            var query = new FixtureBuilder();

            Dictionary <string, int> userDictionary = new Dictionary <string, int>();

            userDictionary = query.getUsernamesAndIds();

            string username = usernameTextBox.Text.ToLower();
            int    userId;

            if (string.IsNullOrEmpty(username))
            {
                MessageBox.Show("Please enter your username");
            }
            else
            {
                if (userDictionary.TryGetValue(username, out userId))
                {
                    app.setCurrentUser(username, userId);
                    this.Hide();
                    new MainForm().ShowDialog();
                }
                else
                {
                    MessageBox.Show("Username not recognised");
                    usernameTextBox.Clear();
                }
            }
        }
Example #2
0
        private void usersComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            SuspendLayout();

            var fb              = new FixtureBuilder();
            var UserId          = fb.getUserId(usersComboBox.SelectedItem.ToString());
            var predictionsList = fb.getPredictions(UserId);

            predictionsUserControl.Update(predictionsList);

            ResumeLayout();
        }
Example #3
0
        private void myPredictionsButton_Click(object sender, EventArgs e)
        {
            SuspendLayout();

            try
            {
                var app             = AppController.Instance;
                var CurrentUserId   = app.getCurrentUser().UserID;
                var fb              = new FixtureBuilder();
                var CurrentUserName = fb.getUsername(CurrentUserId);
                var predictionsList = fb.getPredictions(CurrentUserId);
                var usersSubmitted  = fb.usersSubmitted();

                usersComboBox.Items.Clear();

                foreach (String u in usersSubmitted)
                {
                    usersComboBox.Items.Add(u);
                }

                usersComboBox.SelectedIndex = usersComboBox.FindStringExact(CurrentUserName);

                if (predictionsList.Count > 0)
                {
                    predictionsUserControl.Update(predictionsList);
                    mainPanel.Controls.Add(predictionsUserControl);

                    usersComboBox.Visible          = true;
                    backButton.Visible             = false;
                    nextButton.Visible             = false;
                    submitButton.Visible           = false;
                    menuButton.Visible             = true;
                    tableUsercontrol.Visible       = false;
                    tablePanel.Visible             = false;
                    predictionsUserControl.Visible = true;
                }
                else
                {
                    displayMessage("Predictions currently unavailable. Are you sure you've submitted them?");
                }
            }
            catch (Exception)
            {
                displayMessage("Your predictions for this week are currently unavailable.");
                tablePanel.Visible = true;
            }

            ResumeLayout();
        }
Example #4
0
        private void statsButton_Click(object sender, EventArgs e)
        {
            var fb = new FixtureBuilder();
            //var weekStats = fb.getWeekStats();
            var totalStats = fb.getTotalStats();

            //if (weekStats.Count < 1 || totalStats.Count < 1)
            if (totalStats.Count < 1)
            {
                MessageBox.Show("There are no stats to display.");
            }
            else
            {
                tablePanel.Visible   = false;
                submitButton.Visible = false;
                backButton.Enabled   = false;

                try
                {
                    fixtureBoxList[fix].Visible = false;
                }
                catch (Exception) { }

                nextButton.Visible = false;
                backButton.Visible = false;
                menuButton.Visible = true;

                mainPanel.Controls.Add(tableUsercontrol);

                //foreach (KeyValuePair<string, int> user in weekStats)
                //{
                //    var pointsUserControl = new PointsUserControl();
                //    pointsUserControl.setUserPoints(user.Key + "    " + user.Value, user.Value.ToString());
                //    tableUsercontrol.Add(pointsUserControl, 1);
                //}

                tableUsercontrol.RemoveAll();

                foreach (KeyValuePair <string, int> user in totalStats)
                {
                    var pointsUserControl = new PointsUserControl();
                    pointsUserControl.setUserPoints(user.Key + "    " + user.Value, user.Value.ToString());
                    tableUsercontrol.Add(pointsUserControl, 0);
                }

                tableUsercontrol.Visible = true;
            }
        }