· 8 years ago · Jul 13, 2018, 04:40 PM
1/*
2 * To change this license header, choose License Headers in Project Properties.
3 * To change this template file, choose Tools | Templates
4 * and open the template in the editor.
5 */
6package my.customermanager;
7
8
9import java.awt.Dimension;
10import java.awt.Toolkit;
11import java.awt.event.WindowAdapter;
12import java.awt.event.WindowEvent;
13import java.io.File;
14import java.io.FileWriter;
15import java.io.IOException;
16import java.sql.Connection;
17import java.sql.PreparedStatement;
18import java.sql.ResultSet;
19import java.text.DateFormat;
20import java.text.SimpleDateFormat;
21import java.util.Calendar;
22import java.util.Date;
23import java.util.GregorianCalendar;
24import javax.swing.JFileChooser;
25import javax.swing.JFrame;
26import javax.swing.JLabel;
27import javax.swing.JOptionPane;
28
29import javax.swing.JTable;
30import javax.swing.JTextArea;
31import javax.swing.ListSelectionModel;
32import javax.swing.UIManager;
33
34import javax.swing.table.TableModel;
35import net.proteanit.sql.DbUtils;
36
37/**
38 *
39 * @author Nikhil
40 */
41public class mainmenu extends javax.swing.JFrame {
42 Connection conn=null;
43ResultSet rs=null;
44PreparedStatement pst=null;
45private javax.swing.JTable jtableexp;
46
47
48 /**
49 * Creates new form mainmenu
50 */
51 public mainmenu() {
52 initComponents();
53 conn=dbb.java_db();
54
55 final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
56 setSize(screenSize);
57 // setResizable(false);
58 setExtendedState(JFrame.MAXIMIZED_BOTH);
59 setVisible(true);
60 setTitle("Menu");
61
62 checkifexitss();
63
64
65 this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
66addWindowListener(new WindowAdapter() {
67 @Override
68 public void windowClosing(WindowEvent we)
69 {
70 String ObjButtons[] = {"Yes","No"};
71 int PromptResult = JOptionPane.showOptionDialog(null,"Are you sure you want to exit?","CIM System",JOptionPane.DEFAULT_OPTION,JOptionPane.WARNING_MESSAGE,null,ObjButtons,ObjButtons[1]);
72 if(PromptResult==JOptionPane.YES_OPTION)
73 {
74 System.exit(0);
75 }
76 }
77});
78
79
80 }
81
82 /**
83 * This method is called from within the constructor to initialize the form.
84 * WARNING: Do NOT modify this code. The content of this method is always
85 * regenerated by the Form Editor.
86 */
87 @SuppressWarnings("unchecked")
88 // <editor-fold defaultstate="collapsed" desc="Generated Code">
89 private void initComponents() {
90
91 jPanel1 = new javax.swing.JPanel();
92 jButton5 = new javax.swing.JButton();
93 jLabel1 = new javax.swing.JLabel();
94 jLabel2 = new javax.swing.JLabel();
95 jPanel2 = new javax.swing.JPanel();
96 jButton1 = new javax.swing.JButton();
97 jButton8 = new javax.swing.JButton();
98 jButton7 = new javax.swing.JButton();
99 jButton3 = new javax.swing.JButton();
100 jButton2 = new javax.swing.JButton();
101 jButton4 = new javax.swing.JButton();
102 jButton6 = new javax.swing.JButton();
103
104 setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
105
106 jPanel1.setBackground(new java.awt.Color(153, 204, 255));
107
108 jButton5.setFont(new java.awt.Font("Dialog", 1, 13)); // NOI18N
109 jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/my/customermanager/lout.png"))); // NOI18N
110 jButton5.addActionListener(new java.awt.event.ActionListener() {
111 public void actionPerformed(java.awt.event.ActionEvent evt) {
112 jButton5ActionPerformed(evt);
113 }
114 });
115
116 jLabel1.setFont(new java.awt.Font("Arial Black", 1, 16)); // NOI18N
117 jLabel1.setForeground(new java.awt.Color(0, 0, 0));
118 jLabel1.setText("Logout:");
119
120 jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/my/customermanager/regg.png"))); // NOI18N
121
122 jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/my/customermanager/Add.png"))); // NOI18N
123 jButton1.setText("Customer Manager");
124 jButton1.addActionListener(new java.awt.event.ActionListener() {
125 public void actionPerformed(java.awt.event.ActionEvent evt) {
126 jButton1ActionPerformed(evt);
127 }
128 });
129
130 jButton8.setText("Backup Data");
131 jButton8.addActionListener(new java.awt.event.ActionListener() {
132 public void actionPerformed(java.awt.event.ActionEvent evt) {
133 jButton8ActionPerformed(evt);
134 }
135 });
136
137 jButton7.setText("Cash Collectors");
138 jButton7.addActionListener(new java.awt.event.ActionListener() {
139 public void actionPerformed(java.awt.event.ActionEvent evt) {
140 jButton7ActionPerformed(evt);
141 }
142 });
143
144 jButton3.setText("Usage Record");
145 jButton3.addActionListener(new java.awt.event.ActionListener() {
146 public void actionPerformed(java.awt.event.ActionEvent evt) {
147 jButton3ActionPerformed(evt);
148 }
149 });
150
151 jButton2.setText("Manage User");
152 jButton2.addActionListener(new java.awt.event.ActionListener() {
153 public void actionPerformed(java.awt.event.ActionEvent evt) {
154 jButton2ActionPerformed(evt);
155 }
156 });
157
158 jButton4.setText("Birthdays Today");
159 jButton4.addActionListener(new java.awt.event.ActionListener() {
160 public void actionPerformed(java.awt.event.ActionEvent evt) {
161 jButton4ActionPerformed(evt);
162 }
163 });
164
165 jButton6.setText("Reports");
166 jButton6.addActionListener(new java.awt.event.ActionListener() {
167 public void actionPerformed(java.awt.event.ActionEvent evt) {
168 jButton6ActionPerformed(evt);
169 }
170 });
171
172 javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
173 jPanel2.setLayout(jPanel2Layout);
174 jPanel2Layout.setHorizontalGroup(
175 jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
176 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
177 .addContainerGap(99, Short.MAX_VALUE)
178 .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
179 .addGroup(jPanel2Layout.createSequentialGroup()
180 .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
181 .addGap(18, 18, 18)
182 .addComponent(jButton4))
183 .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
184 .addGroup(jPanel2Layout.createSequentialGroup()
185 .addComponent(jButton2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
186 .addGap(18, 18, 18)
187 .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE))
188 .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
189 .addGroup(jPanel2Layout.createSequentialGroup()
190 .addComponent(jButton7)
191 .addGap(18, 18, 18)
192 .addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE))))
193 .addContainerGap(91, Short.MAX_VALUE))
194 );
195 jPanel2Layout.setVerticalGroup(
196 jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
197 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
198 .addContainerGap(46, Short.MAX_VALUE)
199 .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
200 .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
201 .addComponent(jButton6, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE))
202 .addGap(18, 18, 18)
203 .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
204 .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
205 .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
206 .addGap(18, 18, 18)
207 .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
208 .addComponent(jButton8, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
209 .addComponent(jButton7, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
210 .addGap(18, 18, 18)
211 .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
212 .addContainerGap())
213 );
214
215 javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
216 jPanel1.setLayout(jPanel1Layout);
217 jPanel1Layout.setHorizontalGroup(
218 jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
219 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
220 .addGap(55, 55, 55)
221 .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 624, javax.swing.GroupLayout.PREFERRED_SIZE)
222 .addGap(50, 50, 50)
223 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
224 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
225 .addComponent(jLabel1)
226 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
227 .addComponent(jButton5, javax.swing.GroupLayout.PREFERRED_SIZE, 39, javax.swing.GroupLayout.PREFERRED_SIZE)
228 .addGap(22, 22, 22))
229 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
230 .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
231 .addContainerGap(14, Short.MAX_VALUE))))
232 );
233 jPanel1Layout.setVerticalGroup(
234 jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
235 .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
236 .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
237 .addGroup(jPanel1Layout.createSequentialGroup()
238 .addGap(15, 15, 15)
239 .addComponent(jButton5))
240 .addGroup(jPanel1Layout.createSequentialGroup()
241 .addGap(26, 26, 26)
242 .addComponent(jLabel1)))
243 .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
244 .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
245 .addGap(100, 100, 100))
246 .addGroup(jPanel1Layout.createSequentialGroup()
247 .addGap(26, 26, 26)
248 .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 436, javax.swing.GroupLayout.PREFERRED_SIZE)
249 .addContainerGap(284, Short.MAX_VALUE))
250 );
251
252 javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
253 getContentPane().setLayout(layout);
254 layout.setHorizontalGroup(
255 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
256 .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
257 );
258 layout.setVerticalGroup(
259 layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
260 .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
261 );
262
263 pack();
264 }// </editor-fold>
265
266 private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
267
268 CustomerMgmt cm = new CustomerMgmt();
269 cm.setVisible(true);
270
271
272 }
273
274 private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
275 // TODO add your handling code here:
276 Mainn j = new Mainn();
277 // j.setVisible(true);
278 this.dispose();
279
280 try{
281 Date currentDate = GregorianCalendar.getInstance().getTime();
282 DateFormat df = DateFormat.getDateInstance();
283 String dateString = df.format(currentDate);
284
285 Date d = new Date();
286 SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
287 String timeString = sdf.format(d);
288
289 String valuetime = timeString;
290 String valuedate = dateString;
291
292
293 int valueid = userss.userid;
294 String valuename = userss.username;
295 String reg = "insert into logg (userid,username,date,status) values ('"+valueid+"','"+valuename+"','"+valuedate+" / "+valuetime+"','Logged out')" ;
296 pst=conn.prepareStatement(reg);
297 pst.execute();
298 this.dispose();
299 }
300 catch (Exception e){
301
302 JOptionPane.showMessageDialog(null, e);
303
304 }
305 finally {
306
307 try{
308 rs.close();
309 pst.close();
310
311 }
312 catch(Exception e){
313
314 }
315 }
316
317 }
318
319 private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {
320 loggdetails add = new loggdetails();
321 add.setVisible(true);
322 }
323
324 private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
325 addusers au = new addusers();
326 au.setVisible(true);
327 }
328
329 private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {
330
331 try{
332 Date datenow = Calendar.getInstance().getTime();
333 String date = new SimpleDateFormat("dd/MM").format(datenow);
334
335
336 String sql =" select fname,lname,mobile,dob from custinfo";
337
338 pst=conn.prepareStatement(sql);
339 // pst.setString(1,date);
340 rs=pst.executeQuery();
341 String msg = "";
342 String str = date;
343 while (rs.next()) {
344 String dob = rs.getString("dob");
345 if(dob.contains(str)){
346 msg = msg +""+rs.getString("fname")+" "+rs.getString("lname")+" ,Contact No. "+rs.getString("mobile")+"\n";
347
348 }
349
350 }
351
352 if(msg.length() == 0)
353 { msg= "No Birthdays Today";
354 }
355
356
357 //JOptionPane.showMessageDialog(this, rs, "Hello", WIDTH);
358 JFrame jf = new JFrame();
359 jf.setTitle("Birthday Notifier");
360 JLabel label1 = new JLabel("");
361 JTextArea textArea = new JTextArea(5, 20);
362 textArea.setText(msg);
363 jf.add(textArea);
364
365 textArea.setEditable(false);
366 jf.setSize(300,300);
367 jf.setLocationRelativeTo(null);
368 jf.setVisible(true);
369
370
371
372
373 }catch(Exception e){
374 JOptionPane.showMessageDialog(null, e);
375 }
376 finally {
377
378 try{
379
380 rs.close();
381 pst.close();
382
383
384 }
385 catch(Exception e){
386
387 }
388 }
389
390
391
392 }
393
394 private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {
395 reportss rt = new reportss();
396 rt.setVisible(true);
397 }
398
399 private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {
400 cashcollection cc = new cashcollection();
401 cc.setVisible(true);
402 }
403
404 private void jButton8ActionPerformed(java.awt.event.ActionEvent evt) {
405
406 String ObjButtons[] = {"Customer Data","Invoice Data"};
407 int PromptResult = JOptionPane.showOptionDialog(null,"Which Data you want to backup ?","CIM System",JOptionPane.DEFAULT_OPTION,JOptionPane.WARNING_MESSAGE,null,ObjButtons,ObjButtons[1]);
408 if(PromptResult==JOptionPane.YES_OPTION)
409 {
410 jtableexp = new javax.swing.JTable();
411
412 try{
413
414
415 String sql ="select id,fid,creator,task,type,status,fname,mname,lname,gender,dob,email,mobile,addr1,addr2,pincode,uid,pan,staffnote,custnote from custinfo "; //ORDER BY userid DESC
416 //String sql ="select fname,lname,mobile,dob from custinfo";
417 pst=conn.prepareStatement(sql);
418
419
420 rs=pst.executeQuery();
421
422 jtableexp.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
423 jtableexp.setModel(DbUtils.resultSetToTableModel(rs));
424
425
426
427
428
429
430
431
432
433 }
434 catch(Exception e){
435 System.out.println(e);
436 }
437 finally {
438
439 try{
440 rs.close();
441 pst.close();
442
443 }
444 catch(Exception e){
445
446 }
447
448
449
450 }
451 JFileChooser fc = new JFileChooser();
452 int option = fc.showSaveDialog(mainmenu.this);
453 if(option == JFileChooser.APPROVE_OPTION){
454 String filename = fc.getSelectedFile().getName();
455 String path = fc.getSelectedFile().getParentFile().getPath();
456
457 int len = filename.length();
458 String ext = "";
459 String file = "";
460
461 if(len > 4){
462 ext = filename.substring(len-4, len);
463 }
464
465 if(ext.equals(".csv")){
466 file = path + "\\" + filename;
467 }else{
468 file = path + "\\" + filename + ".csv";
469 }
470 toExcel(jtableexp, new File(file));
471 }
472
473 JOptionPane.showMessageDialog(null,"Exported as .csv (Excel File)");
474 }
475 else
476 if(PromptResult==JOptionPane.NO_OPTION)
477 {
478 jtableexp = new javax.swing.JTable();
479
480 try{
481
482
483 String sql ="select id,userid,name,task,type,status,total,paid,balance,phone,cashcollector,date,cashcollector1,date1,cashcollector2,date2 from inv "; //ORDER BY userid DESC
484 //String sql ="select fname,lname,mobile,dob from custinfo";
485 pst=conn.prepareStatement(sql);
486
487
488 rs=pst.executeQuery();
489
490 jtableexp.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
491 jtableexp.setModel(DbUtils.resultSetToTableModel(rs));
492
493
494
495
496
497
498
499
500
501 }
502 catch(Exception e){
503 System.out.println(e);
504 }
505 finally {
506
507 try{
508 rs.close();
509 pst.close();
510
511 }
512 catch(Exception e){
513
514 }
515
516
517
518 }
519 JFileChooser fc = new JFileChooser();
520 int option = fc.showSaveDialog(mainmenu.this);
521 if(option == JFileChooser.APPROVE_OPTION){
522 String filename = fc.getSelectedFile().getName();
523 String path = fc.getSelectedFile().getParentFile().getPath();
524
525 int len = filename.length();
526 String ext = "";
527 String file = "";
528
529 if(len > 4){
530 ext = filename.substring(len-4, len);
531 }
532
533 if(ext.equals(".csv")){
534 file = path + "\\" + filename;
535 }else{
536 file = path + "\\" + filename + ".csv";
537 }
538 toExcel(jtableexp, new File(file));
539 }
540
541 }
542
543
544
545
546 //JTable jtableexp = null;
547
548
549
550
551
552
553
554
555
556
557 }
558
559 /**
560 * @param args the command line arguments
561 */
562 public static void main(String args[]) {
563 /* Set the Nimbus look and feel */
564 //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
565 /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
566 * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
567 */
568 try {
569 for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
570 if ("Nimbus".equals(info.getName())) {
571 javax.swing.UIManager.setLookAndFeel(info.getClassName());
572 break;
573 }
574 }
575 } catch (ClassNotFoundException ex) {
576 java.util.logging.Logger.getLogger(mainmenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
577 } catch (InstantiationException ex) {
578 java.util.logging.Logger.getLogger(mainmenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
579 } catch (IllegalAccessException ex) {
580 java.util.logging.Logger.getLogger(mainmenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
581 } catch (javax.swing.UnsupportedLookAndFeelException ex) {
582 java.util.logging.Logger.getLogger(mainmenu.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
583 }
584 //</editor-fold>
585
586 /* Create and display the form */
587 java.awt.EventQueue.invokeLater(new Runnable() {
588 public void run() {
589 try {
590 UIManager.setLookAndFeel(
591 UIManager.getSystemLookAndFeelClassName());
592 } catch(Exception e) {
593 e.printStackTrace();
594 }
595 new mainmenu().setVisible(true);
596 }
597 });
598 }
599
600
601 public void toExcel(JTable jtableexp, File ddst){
602 try{
603 TableModel model = jtableexp.getModel();
604 // DefaultTableModel model = (DefaultTableModel) jtableexp.getModel();
605 FileWriter excel = new FileWriter(ddst);
606
607 for(int i = 0; i < model.getColumnCount(); i++){
608 //excel.write(model.getColumnName(i) + "\t");
609 excel.write(model.getColumnName(i) + ",");
610 }
611
612 excel.write("\n");
613
614 for(int i=0; i< model.getRowCount(); i++) {
615 for(int j=0; j < model.getColumnCount(); j++) {
616 if(model.getValueAt(i,j)!= null){
617 // excel.write(model.getValueAt(i,j).toString()+"\t");
618 excel.write(model.getValueAt(i,j).toString()+",");
619 }
620 else{
621 //excel.write(""+"\t");
622 excel.write(""+",");
623 }
624 }
625 excel.write("\n");
626 }
627
628 excel.close();
629 JOptionPane.showMessageDialog(null,"Exported as .csv (Excel File)");
630
631 }catch(IOException e){ System.out.println(e); }
632}
633
634 // Variables declaration - do not modify
635 private javax.swing.JButton jButton1;
636 private javax.swing.JButton jButton2;
637 private javax.swing.JButton jButton3;
638 private javax.swing.JButton jButton4;
639 private javax.swing.JButton jButton5;
640 private javax.swing.JButton jButton6;
641 private javax.swing.JButton jButton7;
642 private javax.swing.JButton jButton8;
643 private javax.swing.JLabel jLabel1;
644 private javax.swing.JLabel jLabel2;
645 private javax.swing.JPanel jPanel1;
646 private javax.swing.JPanel jPanel2;
647 // End of variables declaration
648
649 private void checkifexitss() {
650 try {
651 String sql ="CREATE TABLE IF NOT EXISTS collection ( name TEXT, balance NUMERIC, paid NUMERIC, total INTEGER, c_id INTEGER PRIMARY KEY AUTOINCREMENT, UNIQUE (name COLLATE NOCASE) )";
652 pst=conn.prepareStatement(sql);
653 pst.execute();
654
655
656 }catch (Exception e){
657
658 JOptionPane.showMessageDialog(null, e);
659 } finally {
660
661 try{
662 rs.close();
663 pst.close();
664
665 }catch (Exception e){
666
667 }
668 }
669 }
670}