protected void gvCountry_RowDeleting(object sender, GridViewDeleteEventArgs e) { try { TransactionResult result; // Get the selected row's Country id int countryIDToDelete = Convert.ToInt32(gvCountry.DataKeys[e.RowIndex].Value); // Delete the selected Country _currentCountry = new Country(); _currentCountry.CountryID = countryIDToDelete; _currentCountry.ScreenMode = ScreenMode.Delete; result = _currentCountry.Commit(); // Display the status of the delete System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<script>alert('" + result.Message.ToString() + ".');"); sb.Append("</script>"); ScriptManager.RegisterStartupScript(this.Page, typeof(string), "MyScript", sb.ToString(), false); // If successfully deleted, get the country details if (result.Status == TransactionStatus.Success) { GetCountryDetails(); tcntAllCSCTabs.ActiveTab = tpnlCountry; } } catch (Exception ex) { ErrorLog.LogErrorMessageToDB("Countries.aspx", "", "gvCountry_RowDeleting", ex.Message.ToString(), new ECGroupConnection()); throw; } }
protected void btnCountryAdd_Click(object sender, ImageClickEventArgs e) { try { // Create a new Country Object _currentCountry = new Country(); // Set whether Add / Edit if (txtCountryID.Text.ToString() != "0") _currentCountry.AddEditOption = 1; else _currentCountry.AddEditOption = 0; // Assign values to the Country Object _currentCountry.CountryID = Convert.ToInt32(txtCountryID.Text.ToString()); _currentCountry.CountryDescription = txtCountry.Text.ToString(); // Add / Edit the Country TransactionResult result; _currentCountry.ScreenMode = ScreenMode.Add; result = _currentCountry.Commit(); // Display the Status - Whether successfully saved or not System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("<script>alert('" + result.Message.ToString() + ".');"); sb.Append("</script>"); ScriptManager.RegisterStartupScript(this.Page, typeof(string), "MyScript", sb.ToString(), false); // If successful get the country details if (result.Status == TransactionStatus.Success) { GetCountryDetails(); txtCountryID.Text = "0"; txtCountry.Text = ""; tcntAllCSCTabs.ActiveTab = tpnlCountry; } else { txtCountryID.Text = "0"; txtCountry.Text = ""; tcntAllCSCTabs.ActiveTab = tpnlCountry; } } catch (Exception ex) { ErrorLog.LogErrorMessageToDB("Countries.aspx", "", "btnCountryAdd_Click", ex.Message.ToString(), new ECGroupConnection()); throw; } }