private void btnSave_Click(object sender, EventArgs e) { hasTheSaveButtonPressed = true; bool ok = false; AppLinks appLinks = new AppLinks(); if (Validation.AppLinkDataValidation(cmbCountry.Text, cmbApplication.Text, cmbCategory.Text, txtDescription.Text, txtURL.Text)) { MessageBox.Show("Please enter the AppLink details."); return; } else { appLinks.Description = txtDescription.Text; appLinks.Link = txtURL.Text; if (txtCredentialId.Text == "") { appLinks.CredentialId = 0; } else { appLinks.CredentialId = CredentialId; } foreach (Country country in countryList) { if (cmbCountry.Text == country.CountryName) { appLinks.CountryId = country.CountryId; } } foreach (App app in appList) { if (cmbApplication.Text == app.ApplicationName) { appLinks.ApplicationId = app.ApplicationId; } } foreach (Category category in categoryList) { if (cmbCategory.Text == category.CategoryName) { appLinks.AppCategoryId = category.CategoryId; } } } #region "UPDATE" //UPDATE if (GlobalLinkId > 0) { appLinks.AppLinkId = GlobalLinkId; ok = DALHelpers.UpdateAppLink(appLinks); if (ok == true) { MessageBox.Show("The record was successfully saved!"); } else { MessageBox.Show("Error: An error has ocurred when trying to update the App Link!"); } this.Close(); } #endregion #region "NEW" else { //NEW ok = DALHelpers.AddAppLink(appLinks); if (ok == true) { MessageBox.Show("The record was successfully saved!"); } else { MessageBox.Show("Error: An error has ocurred when trying to add a new App Link!"); } this.Close(); } #endregion }