Advertisement
Guest User

Untitled

a guest
Dec 11th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1.  
  2. class ParticipantsInDB {
  3. Connection conn;
  4. final String tableName = "participants";
  5. void addParticipant(Participant part) {
  6. PreparedStatement st = conn.prepareStatement("INSERT INTO " + tableName + "
  7. VALUES( ? , ? , ? , ? , ? )
  8. ");
  9. try {
  10. st.setString(1, part.getId());
  11. st.setString(2, part.getEFirstName());
  12. st.setString(3, part.getELastName());
  13. //...
  14. st.executeUpdate();
  15. } finally {
  16. st.close();
  17. }
  18. }
  19. void deleteAllParticipants() {
  20. PreparedStatement st = conn.prepareStatement("DELETE FROM " + tableName);
  21. try {
  22. st.executeUpdate();
  23. } finally {
  24. st.close();
  25. }
  26. }
  27. void deleteParticipant(String participantId) {
  28. PreparedStatement st = conn.prepareStatement("DELETE FROM " + tableName + "
  29. WHERE id = ? ");
  30. try {
  31. st.setString(1, participantId);
  32. st.executeUpdate();
  33. } finally {
  34. st.close();
  35. }
  36. }
  37. void prepareStatement(String first, String second, Sting third = " "){
  38. try {
  39. st.setString(1, part.getId());
  40. st.setString(2, part.getEFirstName());
  41. st.setString(3, part.getELastName());
  42. //...
  43. st.executeUpdate();
  44. } finally {
  45. st.close();
  46. }
  47. }
  48. void set(int placement, )
  49.  
  50. }
  51.  
  52. rozw:
  53. zad.2
  54. class ParticipantsInDB{
  55.  
  56. }
  57.  
  58.  
  59. zad 3
  60. class Form1 extends JDialog {
  61. JComboBox comboBoxReportType;
  62. Form1() {
  63. comboBoxReportType = new JComboBox();
  64. comboBoxReportType.addItem("r1");
  65. comboBoxReportType.addItem("r2");
  66. ...
  67. comboBoxReportType.addItem("r31c");
  68. }
  69. void processReport1() {
  70. //print some fancy report...
  71. }
  72. void processReport2() {
  73. //print another totally different fancy report...
  74. }
  75. ...
  76. void processReport31c() {
  77. //print yet another totally different fancy report...
  78. }
  79. void printReport(String repNo) {
  80. if (repNo.equals("r1"))
  81. processReport1();
  82. else if (repNo.equals("r2"))
  83. processReport2();
  84. ...
  85. else if (repNo.equals("r31c"))
  86. processReport31c();
  87. }
  88. void onPrintClick() {
  89. printReport((String) comboBoxReportType.getSelectedItem());
  90. }
  91. }
  92.  
  93. class Report1{
  94.  
  95. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement