Advertisement
Guest User

metoder til MedlemPane

a guest
Sep 26th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. public void OpretMedlem() throws Exception {
  2. try {
  3. Connection connect = ConnectAll.getConnection();
  4. Statement stmt = connect.createStatement();
  5. stmt.executeUpdate("insert into Medlem values" + "( '" + txfIdOpret.getText() + "' , '"
  6. + txfNavnOpret.getText() + "' , '" + txfAdresseOpret.getText() + "' , '"
  7. + txfTelefonOpret.getText() + "' , '2017 - 09 - 26')");
  8. }
  9. catch (Exception e) {
  10. System.out.println(e);
  11. }
  12.  
  13. }
  14.  
  15. // public void OpretMedlem() throws Exception {
  16. // try {
  17. // PreparedStatement.this.setString(1, " ");
  18. // PreparedStatement.this.setInt(2, " ");
  19. // PreparedStatement.this.setString(3, " ");
  20. // PreparedStatement.this.setString(4, " ");
  21. // PreparedStatement.this.execute();
  22. //
  23. // }
  24. // catch (Exception e) {
  25. // System.out.println(e);
  26. //
  27. // }
  28. //
  29. // }
  30.  
  31. public void OpdaterMedlem() throws Exception {
  32. try {
  33. Connection connect = ConnectAll.getConnection();
  34. Statement stmt = connect.createStatement();
  35. stmt.executeUpdate("update Medlem set Navn = '"
  36. + txfNavnOpdater.getText() + "' , Adresse = '" + txfAdresseOpdater.getText()
  37. + "' , Telefon = '"
  38. + txfTelefonOpdater.getText() + "' where Id = " + txfIdOpdater.getText());
  39. }
  40. catch (Exception e) {
  41. System.out.println(e);
  42. }
  43. }
  44.  
  45. public void sletMedlem() {
  46. try {
  47. Connection connect = ConnectAll.getConnection();
  48. Statement stmt = connect.createStatement();
  49. stmt.executeUpdate("delete from Medlem where Id = " + txfIdOpdater.getText());
  50. stmt.executeUpdate(
  51. "delete from Holdmedlem where Medlem(Id) = " + txfIdOpdater.getText());
  52. }
  53. catch (Exception e) {
  54. System.out.println(e);
  55. }
  56. }
  57.  
  58. public void hentMedlem() throws Exception {
  59. try {
  60. Connection connect = ConnectAll.getConnection();
  61. Statement stmt = connect.createStatement();
  62. ResultSet res =
  63. stmt.executeQuery("select * from medlem where Id = " + txfIdOpdater.getText());
  64. while (res.next()) {
  65. txfNavnOpdater.setText(res.getString(2));
  66. txfAdresseOpdater.setText(res.getString(3));
  67. txfTelefonOpdater.setText(res.getString(4));
  68. }
  69. updateControls();
  70. }
  71. catch (Exception e) {
  72. System.out.println(e);
  73. }
  74. }
  75.  
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement