Guest User

Untitled

a guest
Oct 16th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.58 KB | None | 0 0
  1. public static void createBDCustomers(){
  2.  
  3. String sql = "CREATE TABLE IF NOT EXISTS Cliente1 (n"
  4. + " id integer PRIMARY KEY,n"
  5. + " name varchar NOT NULL,n"
  6. + " ruc varchar,n"
  7. + " repLegal varchar,n"
  8. + " nombreContactoEmpresa varchar,n"
  9. + " correoContactoEmpresa varchar,n"
  10. + " numeroContacto varchar,n"
  11. + " cedulaRepLegal varchar,n"
  12. + " nit varchar,n"
  13. + " noContribuyenteMuniPa varchar,n"
  14. + " contraMuniPa varcharn"
  15. + ");";
  16. String url = "jdbc:sqlite:Cliente1.db";
  17.  
  18. try (Connection miConexion = DriverManager.getConnection(url);
  19. Statement stmt = miConexion.createStatement()) {
  20. stmt.execute(sql);
  21. } catch (SQLException e) {
  22. System.out.println(e.getMessage());
  23. }
  24. }
  25.  
  26. public static void createDBPDF(){
  27.  
  28. String sql = "CREATE TABLE IF NOT EXISTS PDF (n"
  29. + " id INTEGER PRIMARY KEY,n"
  30. + " nombrecliente varchar,n"
  31. + " nombrepdf varchar,n"
  32. + " archivopdf mediumblobn"
  33. + ");";
  34. String url = "jdbc:sqlite:PDF.db";
  35.  
  36. try (Connection miConexion = DriverManager.getConnection(url);
  37. Statement stmt = miConexion.createStatement()) {
  38. stmt.execute(sql);
  39. } catch (SQLException e) {
  40. System.out.println(e.getMessage());
  41. }
  42.  
  43. }
  44.  
  45.  
  46. public static void createDBObligaciones(){
  47.  
  48. String sql = "CREATE TABLE IF NOT EXISTS Obligaciones (n"
  49. + " id INTEGER PRIMARY KEY,n"
  50. + " nombrecliente varchar,n"
  51. + " obligacion varchar,n"
  52. + " fecha varchar,n"
  53. + " hora varchar,n"
  54. + " color integer,n"
  55. + " send varcharn"
  56. + ");";
  57. String url = "jdbc:sqlite:Obligaciones.db";
  58.  
  59. try (Connection miConexion = DriverManager.getConnection(url);
  60. Statement stmt = miConexion.createStatement()) {
  61. stmt.execute(sql);
  62. } catch (SQLException e) {
  63. System.out.println(e.getMessage());
  64. }
  65.  
  66. }
  67.  
  68. public void Reminders(){
  69.  
  70. ActionListener timerReminders = (ActionEvent e) -> {
  71.  
  72. try(Connection miConexion = DriverManager.getConnection("jdbc:sqlite:Obligaciones.db");
  73. Statement miStatement = miConexion.createStatement();
  74. ResultSet miResultSet = miStatement.executeQuery("SELECT obligacion, fecha, hora, color, send FROM Obligaciones");){
  75. while(miResultSet.next()){
  76.  
  77. SimpleDateFormat FormatterDate = new SimpleDateFormat("dd-MM-yyyy HH:mm");
  78.  
  79. Calendar cal = Calendar.getInstance();
  80. try {
  81. cal.setTime(FormatterDate.parse(miResultSet.getString("fecha")+" "+miResultSet.getString("hora")));
  82. } catch (ParseException ex) {
  83. Logger.getLogger(Interface.class.getName()).log(Level.SEVERE, null, ex);
  84. }
  85.  
  86. Date dateUser = cal.getTime();
  87. Date date = new Date();
  88.  
  89. if(dateUser.before(date) || dateUser.equals(date)){
  90.  
  91. JOptionPane.showMessageDialog(this, "Se paso el primer if");
  92.  
  93. if(miResultSet.getString("send").equals("notsent")){
  94. JOptionPane.showMessageDialog(this, "Se paso el segundo if");
  95.  
  96. JOptionPane.showMessageDialog(this, "Se paso el tercer if");
  97. UpdateObligacionesColorAndSend(miResultSet.getString("obligacion"), 0, "sent");
  98. pnlObligaciones.removeAll();
  99. loadBtnObligacion(lblNameC.getText());
  100.  
  101. if (SystemTray.isSupported()) {
  102. sendNotification("Nombre Cliente", "Bañar al perro", "/img/logo.jpg");
  103. } else {
  104. System.err.println("System tray not supported!");
  105. }
  106.  
  107. UpdateObligacionesColorAndSend(miResultSet.getString("obligacion"), 0, "sent");
  108. pnlObligaciones.removeAll();
  109. loadBtnObligacion(lblNameC.getText());
  110.  
  111. if (SystemTray.isSupported()) {
  112. sendNotification("Nombre Cliente", "Bañar al perro", "/img/logo.jpg");
  113. } else {
  114. System.err.println("System tray not supported!");
  115. }
  116.  
  117. }
  118.  
  119. }else{
  120.  
  121. }
  122.  
  123. miConexion.close();
  124. miStatement.close();
  125. miResultSet.close();
  126.  
  127. }
  128.  
  129. }catch(SQLException ev){
  130. System.out.println(ev);
  131. }
  132.  
  133. };
  134.  
  135. Timer timer = new Timer(1000, timerReminders);
  136. timer.setInitialDelay(0);
  137. timer.start();
  138.  
  139. }
Add Comment
Please, Sign In to add comment