Guest User

Untitled

a guest
Jan 22nd, 2018
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.19 KB | None | 0 0
  1. class Gebruikers
  2. {
  3. // FIELDS
  4. private string _UserName;
  5. private string _Naam;
  6. private string _Groep;
  7.  
  8. // PROPERTIES
  9. public string UserName
  10. {
  11. get
  12. {
  13. return _UserName;
  14. }
  15. set
  16. {
  17. _UserName = value;
  18. }
  19. }
  20.  
  21. public string Naam
  22. {
  23. get
  24. {
  25. return _Naam;
  26. }
  27. set
  28. {
  29. _Naam = value;
  30. }
  31. }
  32.  
  33. public string Groep
  34. {
  35. get
  36. {
  37. return _Groep;
  38. }
  39. set
  40. {
  41. _Groep = value;
  42. }
  43. }
  44.  
  45. // CONSTRUCTOR
  46. public Gebruikers(string username, string naam, string groep)
  47. {
  48. _UserName = username;
  49. _Naam = naam;
  50. _Groep = groep;
  51. }
  52.  
  53. public Gebruikers()
  54. {
  55. }
  56.  
  57. public override string ToString()
  58. {
  59. return _UserName + " - " + _Naam + " - " + _Groep;
  60. }
  61. }
  62.  
  63. private void btnAddUser_Click(object sender, EventArgs e)
  64. {
  65. string userName = tbxAddUserName.Text;
  66.  
  67. try
  68. {
  69. if (UserNameCorrect(userName))
  70. {
  71. Gebruikers toevoegen = new Gebruikers(tbxAddUserName.Text, tbxAddNameofUser.Text, tbxAddNameofGroup.Text);
  72. database.AddUser(toevoegen);
  73.  
  74. ReloadStatistics();
  75. LaadUsers();
  76. }
  77. else
  78. {
  79. MessageBox.Show("De door u ingevoerde gebruikersnaam is niet juist! Zorg dat deze minimaal vier tekens en geen spaties bevat.", "Gebruikersnaam incorrect",
  80. MessageBoxButtons.OK, MessageBoxIcon.Information);
  81. }
  82. }
  83. catch (Exception exc)
  84. {
  85. switch (exc)
  86. {
  87. case SqlException _:
  88. case InvalidOperationException _:
  89. break;
  90. default:
  91. throw;
  92. }
  93. MessageBox.Show("De door u ingevoerde gebruiker bestaat al!", "Gebruiker bestaat al",
  94. MessageBoxButtons.OK, MessageBoxIcon.Information);
  95. }
  96. }
Add Comment
Please, Sign In to add comment