Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.44 KB | None | 0 0
  1. public partial class incidentCategorySearchControl : UserControl
  2. {
  3. public static incidentCategorySearchControl Instance { get; set; }
  4.  
  5.  
  6. public incidentCategorySearchControl()
  7. {
  8. InitializeComponent();
  9. Instance = this;
  10.  
  11. // This line of code is generated by Data Source Configuration Wizard
  12. incIncidentCategoryTableAdapter1.Fill(reinvenT_QualityDataSet1.IncIncidentCategory);
  13. }
  14.  
  15. public void updateGridControl()
  16. {
  17. MessageBox.Show("..........." );
  18. //categoryGridControl.RefreshDataSource();
  19. incIncidentCategoryTableAdapter1.Fill(reinvenT_QualityDataSet1.IncIncidentCategory);
  20.  
  21.  
  22. }
  23. }
  24.  
  25. private void saveCategoryChangeButton_Click(object sender, EventArgs e)
  26. {
  27. if (incidentCategoryDescTextBox.Text.Trim().Length == 0)
  28. {
  29. MessageBox.Show("Opslaan mislukt controleer a.u.b. of alle verplichte velden juist zijn ingevuld");
  30. }
  31. else
  32. {
  33. try
  34. {
  35.  
  36. using (SqlConnection con = new SqlConnection(SqlServerConnection.sqlConnection.ConnectionString))
  37. {
  38. con.Open();
  39.  
  40. using (SqlCommand cmd = new SqlCommand("UPDATE IncIncidentCategory SET IncIncidentCatDescription = @categoryDescription WHERE IncIncidentCategory = @categoryId", con))
  41. {
  42. IncidentCategory incidentCategoryUpdate = new IncidentCategory(Convert.ToInt32(incidentCategoryTextBox.Text), incidentCategoryDescTextBox.Text);
  43. cmd.CommandType = CommandType.Text;
  44. cmd.Parameters.AddWithValue("@categoryId", incidentCategoryUpdate._categoryId);
  45. cmd.Parameters.AddWithValue("@categoryDescription", incidentCategoryUpdate._description);
  46. cmd.ExecuteNonQuery();
  47. MessageBox.Show("Wijzigingen opgeslagen");
  48.  
  49. }
  50. }
  51.  
  52. incidentTypeChange.Instance.refreshCategorySearchBox();
  53. incidentTypeMaintenance.Instance.refreshCategorySearchBox();
  54. incidentCategorySearchControl.Instance.updateGridControl(); // update doesn't work
  55. //var control = new incidentCategorySearchControl();
  56. //control.updateDataGridView();
  57.  
  58.  
  59.  
  60. }
  61. catch
  62. {
  63. MessageBox.Show("Voer voor beide velden geldige waarden in a.u.b.");
  64. }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement