private void btnAdd_Click(object sender, EventArgs e) { if (txtKeyName == null || txtKeyName.Text.Length == 0 || txtKeyName.Text.Equals("")) { UtilityMethod.ShowMessage("Please enter a valid key name as given by the provider!", this, WeatherLionMain.PROGRAM_NAME + " - No Key Name", MessageBoxButtons.OK, MessageBoxIcon.Error); txtKeyName.Focus(); }// end of if block else if (pwdKeyValue == null || pwdKeyValue.Text.Length == 0 || pwdKeyValue.Text.Equals("")) { UtilityMethod.ShowMessage("Please enter a valid key value as given by the provider!", this, WeatherLionMain.PROGRAM_NAME + " - No Key Value", MessageBoxButtons.OK, MessageBoxIcon.Error); pwdKeyValue.Focus(); }// end of else if block else { string[] encryptedKey = LionSecurityManager.Encrypt(pwdKeyValue.Text, true).Split(':'); string selectedProvider = cboAccessProvider.SelectedItem.ToString(); switch (selectedProvider) { case "Here Maps Weather": if (!LionSecurityManager.hereMapsRequiredKeys.Contains(txtKeyName.Text.ToLower())) { UtilityMethod.ShowMessage($"The {selectedProvider} does not require a key \"{ txtKeyName.Text}\"!", this, $"{WeatherLionMain.PROGRAM_NAME} - Invalid Key Type", MessageBoxButtons.OK, MessageBoxIcon.Error); txtKeyName.Focus(); return; } // end of if block break; case "Yahoo! Weather": if (!LionSecurityManager.yahooRequiredKeys.Contains(txtKeyName.Text.ToLower())) { UtilityMethod.ShowMessage($"The {selectedProvider} does not require a key \"{ txtKeyName.Text}\"!", this, $"{WeatherLionMain.PROGRAM_NAME} - Invalid Key Type", MessageBoxButtons.OK, MessageBoxIcon.Error); txtKeyName.Focus(); return; } // end of if block break; default: break; }// end of switch block if (UtilityMethod.AddSiteKeyToDatabase(cboAccessProvider.SelectedItem.ToString(), txtKeyName.Text, encryptedKey[0], encryptedKey[1]) == 1) { if (txtKeyName.Enabled) { txtKeyName.Text = (""); } pwdKeyValue.Text = ""; UtilityMethod.ShowMessage("The key was successfully added to the database.", this, WeatherLionMain.PROGRAM_NAME + " - Success", MessageBoxButtons.OK, MessageBoxIcon.Information); txtKeyName.Focus(); }// end of if block else { UtilityMethod.ShowMessage("The key could not be added to the database!" + "\nPlease recheck the key and try again.", this, WeatherLionMain.PROGRAM_NAME + " - Error", MessageBoxButtons.OK, MessageBoxIcon.Error); txtKeyName.Focus(); } // end of else block } // end of else block } // end of method btnAdd_Click