private void okButton_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(usernameTextbox.Text)) { MessageBox.Show("Username cannot be empty string!"); return; } if (string.IsNullOrWhiteSpace(passwordTextbox.Text)) { MessageBox.Show("Password cannot be empty string!"); return; } loginPanel.Enabled = false; loadingPicture.Enabled = true; loadingPicture.Visible = true; loadingPicture.BringToFront(); this.Refresh(); addTourneys = new AddTourneys(m_site, usernameTextbox.Text, passwordTextbox.Text); string json_result = addTourneys.getTourneys(); try { tourneyList = Utilities.JsonDeserialize <TourneyList>(json_result); loadingPicture.Visible = false; loginPanel.Enabled = true; if (tourneyList.error) { MessageBox.Show("Unable to validate username and password because : " + Environment.NewLine + tourneyList.message); return; } else { this.DialogResult = DialogResult.OK; this.Close(); if (m_site.Contains(m_productionSite)) { MessageBox.Show( "Please note that you are logged in to the production site. Your changes will impact content on the official public BFI web site!", "Production Web site warning!!!", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly); } } } catch (Exception ex) { MessageBox.Show("Exception : " + Environment.NewLine + ex.Message); loadingPicture.Visible = false; loginPanel.Enabled = true; return; } }
private Tuple <bool, string> GetTourneys(string site, string username, string password) { var addTourneys = new AddTourneys(site, username, password); var jsonResult = addTourneys.getTourneys(); try { m_tourneyList = Utilities.JsonDeserialize <TourneyList>(jsonResult); } catch (Exception) { return(null); } foreach (TourneyPageInfo pageInfo in m_tourneyList.content) { tourneyNamesCombobox.Items.Add(pageInfo.title); cmbTourneyName.Items.Add(pageInfo.title); } var currentYear = DateTime.Today.Year; tourneyYearCombobox.Items.Clear(); tourneyYearCombobox.Items.Add(currentYear - 1); tourneyYearCombobox.Items.Add(currentYear); tourneyYearCombobox.Items.Add(currentYear + 1); tourneyYearCombobox.SelectedIndex = 1; cmbYear.Items.Clear(); cmbYear.Items.Add(currentYear - 1); cmbYear.Items.Add(currentYear); cmbYear.Items.Add(currentYear + 1); cmbYear.SelectedIndex = 1; return(new Tuple <bool, string>(m_tourneyList.error, m_tourneyList.message)); }