Subversion Repository Public Repository

TransPort_Tracking

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bestray.transtracking.views;

import com.bestray.transtracking.controller.OwnerPaymentController;
import com.bestray.transtracking.dto.OwnerPaymentSearchDTO;
import com.bestray.transtracking.exceptions.TransTrackException;
import com.bestray.transtracking.reports.VehicleOwnerPaymentReport;
import com.bestray.transtracking.util.CollectionUtil;
import com.bestray.trastrack.domain.Code;
import com.bestray.trastrack.domain.Employee;
import com.bestray.trastrack.domain.OwnerPayment;
import com.bestray.trastrack.domain.OwnerPaymentBalanceSum;
import com.bestray.trastrack.domain.VehicleOwner;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.text.DecimalFormat;
import java.util.Date;
import java.util.Vector;
import javax.swing.JOptionPane;
import javax.swing.ListSelectionModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;
import org.apache.commons.lang.StringUtils;
import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;

/**
 *
 * @author Bitu
 */
public class VehicleOwnerPayment extends javax.swing.JPanel {

    /**
     * Creates new form VehicleOwnerPayment
     */
    public VehicleOwnerPayment() {
        populateData();
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        vehicleOwnerPaymentDate = new org.jdesktop.swingx.JXDatePicker();
        vehicle_owner_combo = new javax.swing.JComboBox();
        paid_mode_combo = new javax.swing.JComboBox();
        amount_textbox = new javax.swing.JTextField();
        paid_by_combo = new javax.swing.JComboBox();
        jPanel2 = new javax.swing.JPanel();
        jLabel6 = new javax.swing.JLabel();
        balance_tb = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        amount_tb = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        remainingbalance_tb = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        vownerpayment_textarea = new javax.swing.JTextArea();
        jLabel28 = new javax.swing.JLabel();
        jLabel29 = new javax.swing.JLabel();
        jLabel30 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        owner_search_tb = new javax.swing.JComboBox();
        jLabel13 = new javax.swing.JLabel();
        fromDate = new org.jdesktop.swingx.JXDatePicker();
        toDate = new org.jdesktop.swingx.JXDatePicker();
        jLabel14 = new javax.swing.JLabel();
        searchButton = new javax.swing.JButton();
        jPanel4 = new javax.swing.JPanel();
        deletebt = new javax.swing.JButton();
        editButton = new javax.swing.JButton();
        saveButton = new javax.swing.JButton();
        resetButton = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        owner_payment_table = new javax.swing.JTable(){
            public boolean isCellEditable(int row, int column){
                return false;
            }
            public Component prepareRenderer(TableCellRenderer renderer, int rowIndex, int vColIndex) {
                Component c = super.prepareRenderer(renderer, rowIndex, vColIndex);
                if (rowIndex % 2 == 0 && !isCellSelected(rowIndex, vColIndex)) {
                    c.setForeground(Color.BLACK);
                    c.setBackground(new Color(200, 225, 250));
                }
                else if(rowIndex % 2 == 0 && isCellSelected(rowIndex, vColIndex)){
                    c.setForeground(Color.WHITE);
                    c.setBackground(Color.BLUE);
                }
                else if(rowIndex % 2 != 0 && isCellSelected(rowIndex, vColIndex)){
                    c.setForeground(Color.WHITE);
                    c.setBackground(Color.BLUE);
                }
                else {
                    c.setForeground(Color.BLACK);
                    c.setBackground(getBackground());
                }
                return c;
            }
        };
        pdfbt = new javax.swing.JButton();
        excelbt = new javax.swing.JButton();

        setBackground(new java.awt.Color(200, 225, 250));
        setOpaque(false);
        setPreferredSize(new java.awt.Dimension(1037, 600));

        jLabel15.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Truck2.png"))); // NOI18N

        jLabel16.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 14)); // NOI18N
        jLabel16.setText("Vehicle Owner Payment");

        jPanel1.setBackground(new java.awt.Color(200, 225, 250));
        jPanel1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel1.setOpaque(false);

        jLabel1.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        jLabel1.setText("Date :");

        jLabel2.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        jLabel2.setText("Vehicle Owner Name :");

        jLabel3.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        jLabel3.setText("Amount Paid :");

        jLabel4.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        jLabel4.setText("Paid Mode :");

        jLabel5.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        jLabel5.setText("Paid By :");

        vehicleOwnerPaymentDate.setFormats(new String[] {"dd/MM/yyyy"});
        vehicleOwnerPaymentDate.setDate(new Date());

        vehicle_owner_combo.setModel(new javax.swing.DefaultComboBoxModel(vehicleOwnerList));
        AutoCompleteDecorator.decorate(this.vehicle_owner_combo);
        vehicle_owner_combo.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                vehicle_owner_comboItemStateChanged(evt);
            }
        });

        paid_mode_combo.setModel(new javax.swing.DefaultComboBoxModel(codeList));
        paid_mode_combo.setSelectedIndex(-1);

        amount_textbox.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                amount_textboxFocusLost(evt);
            }
        });

        paid_by_combo.setModel(new javax.swing.DefaultComboBoxModel(paidByList));
        paid_by_combo.setSelectedIndex(CollectionUtil.getDefaultEmployeeIndex(paidByList));
        AutoCompleteDecorator.decorate(this.paid_by_combo);

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel2.setOpaque(false);

        jLabel6.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        jLabel6.setText("Remaning Balance :");

        balance_tb.setEditable(false);
        balance_tb.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        balance_tb.setForeground(new java.awt.Color(255, 0, 0));

        jLabel7.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        jLabel7.setText("Amount Paid :");

        amount_tb.setEditable(false);
        amount_tb.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        amount_tb.setForeground(new java.awt.Color(255, 0, 0));

        jLabel8.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        jLabel8.setText("Balance :");

        remainingbalance_tb.setEditable(false);
        remainingbalance_tb.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        remainingbalance_tb.setForeground(new java.awt.Color(255, 0, 0));

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel6)
                    .addComponent(jLabel7)
                    .addComponent(jLabel8))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(remainingbalance_tb, javax.swing.GroupLayout.DEFAULT_SIZE, 106, Short.MAX_VALUE)
                    .addComponent(amount_tb)
                    .addComponent(balance_tb))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(balance_tb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(amount_tb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(remainingbalance_tb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jLabel10.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        jLabel10.setText("Notes :");

        vownerpayment_textarea.setColumns(20);
        vownerpayment_textarea.setLineWrap(true);
        vownerpayment_textarea.setRows(5);
        vownerpayment_textarea.setWrapStyleWord(true);
        jScrollPane2.setViewportView(vownerpayment_textarea);

        jLabel28.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel28.setForeground(new java.awt.Color(255, 0, 0));
        jLabel28.setText("*");

        jLabel29.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel29.setForeground(new java.awt.Color(255, 0, 0));
        jLabel29.setText("*");

        jLabel30.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel30.setForeground(new java.awt.Color(255, 0, 0));
        jLabel30.setText("*");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel28)
                    .addComponent(jLabel29)
                    .addComponent(jLabel30))
                .addGap(1, 1, 1)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4)
                    .addComponent(jLabel5)
                    .addComponent(jLabel10))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(vehicleOwnerPaymentDate, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(vehicle_owner_combo, 0, 203, Short.MAX_VALUE)
                            .addComponent(amount_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(paid_by_combo, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(paid_mode_combo, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 371, Short.MAX_VALUE)
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel1)
                            .addComponent(vehicleOwnerPaymentDate, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel2)
                            .addComponent(vehicle_owner_combo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel28))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel3)
                            .addComponent(amount_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel29))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(paid_mode_combo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel30))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(paid_by_combo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel10)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jPanel3.setBackground(new java.awt.Color(200, 225, 250));
        jPanel3.setOpaque(false);

        jLabel9.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        jLabel9.setText("Vehicle Owner Name :");

        owner_search_tb.setModel(new javax.swing.DefaultComboBoxModel(ownerSearchList));
        AutoCompleteDecorator.decorate(this.owner_search_tb);

        jLabel13.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        jLabel13.setText("From:");

        fromDate.setFormats(new String[] {"dd/MM/yyyy"});
        fromDate.setDate(new Date());

        toDate.setFormats(new String[] {"dd/MM/yyyy"});
        toDate.setDate(new Date());

        jLabel14.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        jLabel14.setText("To:");

        searchButton.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        searchButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/search.png"))); // NOI18N
        searchButton.setText("Search");
        searchButton.setOpaque(false);
        searchButton.setPreferredSize(new java.awt.Dimension(85, 25));
        searchButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                searchButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(0, 0, 0)
                .addComponent(jLabel9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(owner_search_tb, javax.swing.GroupLayout.PREFERRED_SIZE, 185, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel13)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(fromDate, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel14)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(toDate, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(searchButton, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, 0))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(0, 0, 0)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(fromDate, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel13))
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(toDate, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel14)
                        .addComponent(searchButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel9)
                        .addComponent(owner_search_tb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(0, 0, 0))
        );

        jPanel4.setBackground(new java.awt.Color(200, 225, 250));
        jPanel4.setOpaque(false);

        deletebt.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        deletebt.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/delete.png"))); // NOI18N
        deletebt.setText("Delete");
        deletebt.setMaximumSize(new java.awt.Dimension(85, 20));
        deletebt.setMinimumSize(new java.awt.Dimension(85, 20));
        deletebt.setOpaque(false);
        deletebt.setPreferredSize(new java.awt.Dimension(85, 25));
        deletebt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deletebtActionPerformed(evt);
            }
        });

        editButton.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        editButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/edit.png"))); // NOI18N
        editButton.setText("Edit");
        editButton.setMaximumSize(new java.awt.Dimension(85, 20));
        editButton.setMinimumSize(new java.awt.Dimension(85, 20));
        editButton.setOpaque(false);
        editButton.setPreferredSize(new java.awt.Dimension(85, 25));
        editButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editButtonActionPerformed(evt);
            }
        });

        saveButton.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        saveButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/save 2.png"))); // NOI18N
        saveButton.setText("Save");
        saveButton.setOpaque(false);
        saveButton.setPreferredSize(new java.awt.Dimension(85, 25));
        saveButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveButtonActionPerformed(evt);
            }
        });

        resetButton.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        resetButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/refresh.png"))); // NOI18N
        resetButton.setText("Reset");
        resetButton.setOpaque(false);
        resetButton.setPreferredSize(new java.awt.Dimension(85, 25));
        resetButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                resetButtonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap(579, Short.MAX_VALUE)
                .addComponent(resetButton, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(editButton, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(saveButton, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(deletebt, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, 0))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addGap(0, 0, 0)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(resetButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(editButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(saveButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(deletebt, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(0, 0, 0))
        );

        jScrollPane1.setPreferredSize(new java.awt.Dimension(452, 415));

        owner_payment_table.setModel(new javax.swing.table.DefaultTableModel(ownerPaymentData,header));
        owner_payment_table.setRowHeight(20);
        owner_payment_table.setShowHorizontalLines(false);
        owner_payment_table.setShowVerticalLines(false);
        owner_payment_table.getColumnModel().getColumn(0).setPreferredWidth(87);
        owner_payment_table.getColumnModel().getColumn(0).setMaxWidth(87);
        owner_payment_table.getTableHeader().setFont(new Font("SansSerif", Font.BOLD, 12));
        owner_payment_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        jScrollPane1.setViewportView(owner_payment_table);

        pdfbt.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        pdfbt.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/pdf-icon.png"))); // NOI18N
        pdfbt.setText("Export Pdf");
        pdfbt.setOpaque(false);
        pdfbt.setPreferredSize(new java.awt.Dimension(85, 25));
        pdfbt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pdfbtActionPerformed(evt);
            }
        });

        excelbt.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        excelbt.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Excel-icon.png"))); // NOI18N
        excelbt.setText("Export Excel");
        excelbt.setOpaque(false);
        excelbt.setPreferredSize(new java.awt.Dimension(85, 25));
        excelbt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                excelbtActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel15)
                        .addGap(2, 2, 2)
                        .addComponent(jLabel16)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(excelbt, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(pdfbt, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel16))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 187, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(excelbt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pdfbt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void resetButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_resetButtonActionPerformed
        clearFields();
    }//GEN-LAST:event_resetButtonActionPerformed

    private void editButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editButtonActionPerformed
        try{
        int row = owner_payment_table.getSelectedRow();
        Object o = owner_payment_table.getValueAt(row, 0);
        displayRowValues(Long.valueOf(o.toString()));
        }catch(Exception e){
            JOptionPane.showMessageDialog(null, "Record not selected for Edit.");
        }
    }//GEN-LAST:event_editButtonActionPerformed

    private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
      
        try {
            if(validateOwnerPayment()){
            ownerPayment.setPayment_date(vehicleOwnerPaymentDate.getDate());
            
            VehicleOwner vehicleOwner = (VehicleOwner)vehicle_owner_combo.getSelectedItem();
            ownerPayment.setOwner_id(vehicleOwner.getId());
            
            Code code = (Code)paid_mode_combo.getSelectedItem();
            ownerPayment.setPayment_mode_id(code.getId());
            
            ownerPayment.setAmount(Double.parseDouble(amount_textbox.getText()));
            
            Employee emp = (Employee)paid_by_combo.getSelectedItem();
            ownerPayment.setPaid_by_id(emp.getId());
            
            ownerPayment.setRemarks(vownerpayment_textarea.getText());
            controller.saveVehicleOwnerTransaction(ownerPayment);
            JOptionPane.showMessageDialog(null,"Payment Details Saved");
            clearFields();
            }   
        } catch(Exception e){
            JOptionPane.showMessageDialog(null,"Vehicle Owner Payment Information not Saved");
        }
        
    }//GEN-LAST:event_saveButtonActionPerformed

    private void deletebtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deletebtActionPerformed
       int row = owner_payment_table.getSelectedRow();
            if (row >= 0) {
            Object o = owner_payment_table.getValueAt(row, 0);
            try{
                if(JOptionPane.showConfirmDialog(null, "Do you want to delete the selected Record.","", JOptionPane.OK_CANCEL_OPTION)==0){
                controller.deleteVehicleOwnerTransaction(Long.valueOf(o.toString()));
                 JOptionPane.showMessageDialog(null, "Selected Payment Transaction Deleted");
                 clearFields();
                }else{
                    clearFields();
                }
            }catch(TransTrackException e){
               
                JOptionPane.showMessageDialog(null, e.getMessage());
            }
           
        }else{
                JOptionPane.showMessageDialog(null, "Record not selected for Delete");
            }
    }//GEN-LAST:event_deletebtActionPerformed

    private void amount_textboxFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_amount_textboxFocusLost
        if(StringUtils.isNotBlank(amount_textbox.getText())){
            Double amountpaid = Double.parseDouble(amount_textbox.getText());
           
            amount_tb.setText(String.valueOf(Double.parseDouble(twoDForm.format(amountpaid))));
             Double totalremaining= Double.parseDouble(balance_tb.getText())-Double.parseDouble(amount_tb.getText());
            remainingbalance_tb.setText(String.valueOf(Double.parseDouble(twoDForm.format(totalremaining))));
        }else{
            amount_tb.setText(String.valueOf(0.0));
        }

    }//GEN-LAST:event_amount_textboxFocusLost

    private void vehicle_owner_comboItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_vehicle_owner_comboItemStateChanged
        if(vehicle_owner_combo.getSelectedItem()!=null){
           VehicleOwner p = (VehicleOwner)vehicle_owner_combo.getSelectedItem();
            Long ownerId = p.getId();
            populatebalance(ownerId);
            //openingBalanceAmount =0;
           // openingBalanceType = "";
             //openingBalancetb.setVisible(false);
             //openingBalancelb.setVisible(false);
             //jLabel22.setVisible(false);
            // pendingpartybalance(ID);
        }

    }//GEN-LAST:event_vehicle_owner_comboItemStateChanged

    private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchButtonActionPerformed
        try{
            OwnerPaymentSearchDTO search = new OwnerPaymentSearchDTO();
        VehicleOwner client = (VehicleOwner)owner_search_tb.getSelectedItem();
        search.setVehicleOwnerName(client.getId());
        search.setSearchFrom(fromDate.getDate());
        search.setSearchTo(toDate.getDate());
        search(search);
        }
        catch(Exception e){
          JOptionPane.showMessageDialog(null, "Select Owner Name !"); 
           owner_search_tb.requestFocus();
        }
    }//GEN-LAST:event_searchButtonActionPerformed

    private void pdfbtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pdfbtActionPerformed
        // TODO add your handling code here:
        int reply = JOptionPane.showConfirmDialog(null, "Do you want to download the Report ?", "Vehicle Owner Payment Report", JOptionPane.YES_NO_OPTION);  
        if (reply == JOptionPane.YES_OPTION){  
        try{
            if(owner_search_tb.getSelectedItem()!=null){

                VehicleOwnerPaymentReport vehicleOwnerPaymentReport=new VehicleOwnerPaymentReport();
                vehicleOwner=owner_search_tb.getSelectedItem().toString();
                System.out.println(vehicleOwner);
                from=fromDate.getDate();
                to=toDate.getDate();
                vehicleOwnerPaymentReport.getPdfReport(vehicleOwner,from,to);
                reply = JOptionPane.showConfirmDialog(null, "Do you want to open this File ?", "Vehicle Owner Payment Report", JOptionPane.YES_NO_OPTION);
                if (reply == JOptionPane.YES_OPTION)
                {
                    vehicleOwnerPaymentReport.openPdfReport();
                }

            }
            else{
                
                 JOptionPane.showMessageDialog(null, "Choose Vehicle Owner");  
            }

        }
        catch(Exception e){
            String error=e.getMessage();
            JOptionPane.showMessageDialog(null, error+"\n So, Document can't be Generated");
        }
        }
    }//GEN-LAST:event_pdfbtActionPerformed

    private void excelbtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_excelbtActionPerformed
        // TODO add your handling code here:
        int reply = JOptionPane.showConfirmDialog(null, "Do you want to download the Report ?", "Vehicle Owner Payment Report", JOptionPane.YES_NO_OPTION);  
        if (reply == JOptionPane.YES_OPTION){  
        try{
            if(owner_search_tb.getSelectedItem()!=null){

                VehicleOwnerPaymentReport vehicleOwnerPaymentReport=new VehicleOwnerPaymentReport();
                vehicleOwner=owner_search_tb.getSelectedItem().toString();
                from=fromDate.getDate();
                to=toDate.getDate();
                vehicleOwnerPaymentReport.getXlsReport(vehicleOwner,from,to);
                reply = JOptionPane.showConfirmDialog(null, "Do you want to open this File ?", "Vehicle Owner Payment Report", JOptionPane.YES_NO_OPTION);
                if (reply == JOptionPane.YES_OPTION)
                {
                    vehicleOwnerPaymentReport.openXlsReport();
                }

            }
            else{
                
                 JOptionPane.showMessageDialog(null, "Choose Vehicle Owner");  
            }

        }
        catch(Exception e){
            String error=e.getMessage();
            JOptionPane.showMessageDialog(null, error+"\n So, Document can't be Generated");
        }
        }
    }//GEN-LAST:event_excelbtActionPerformed
    private Date from,to;
    private String vehicleOwner;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField amount_tb;
    private javax.swing.JTextField amount_textbox;
    private javax.swing.JTextField balance_tb;
    private javax.swing.JButton deletebt;
    private javax.swing.JButton editButton;
    private javax.swing.JButton excelbt;
    private org.jdesktop.swingx.JXDatePicker fromDate;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel28;
    private javax.swing.JLabel jLabel29;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTable owner_payment_table;
    private javax.swing.JComboBox owner_search_tb;
    private javax.swing.JComboBox paid_by_combo;
    private javax.swing.JComboBox paid_mode_combo;
    private javax.swing.JButton pdfbt;
    private javax.swing.JTextField remainingbalance_tb;
    private javax.swing.JButton resetButton;
    private javax.swing.JButton saveButton;
    private javax.swing.JButton searchButton;
    private org.jdesktop.swingx.JXDatePicker toDate;
    private org.jdesktop.swingx.JXDatePicker vehicleOwnerPaymentDate;
    private javax.swing.JComboBox vehicle_owner_combo;
    private javax.swing.JTextArea vownerpayment_textarea;
    // End of variables declaration//GEN-END:variables
    private Vector<Employee> paidByList = new Vector<Employee>();
    private Vector<VehicleOwner> vehicleOwnerList = new Vector<VehicleOwner>();
    private Vector<Code> codeList = new Vector<Code>();
    private Vector<VehicleOwner> ownerSearchList = new Vector<VehicleOwner>();
    private Vector<Vector<String>> ownerPaymentData = new Vector<Vector<String>>();
    TableRowSorter<TableModel> sorter;
    Vector header = new Vector<String>();
    private Code cd;
    DecimalFormat twoDForm = new DecimalFormat("#.##");
    private OwnerPayment ownerPayment;
    private OwnerPaymentController controller;
    
    
    private void populateData() {
        
        controller = new OwnerPaymentController();
        paidByList = controller.getPaidByList();
        /*Employee employee = new Employee();
        employee.setEmployee_Name("--None--");
        paidByList.add(0,employee); */
        vehicleOwnerList = controller.getVehicleOwnerList();
        VehicleOwner owner = new VehicleOwner();
        owner.setOwnername("--None--");
        vehicleOwnerList.add(0,owner);
        codeList = controller.getCodeList();
        ownerSearchList = controller.getVehicleOwnerList();
        VehicleOwner owners = new VehicleOwner();
        owners.setOwnername("--None--");
        ownerSearchList.add(0,owners);
        
        header.add("ID");
        header.add("Date");
        header.add("Owner Name");
        header.add("Amount");
        header.add("Payment Mode");
        header.add("Note");
        
        ownerPayment = new OwnerPayment();       
    }

    private void clearFields() {
        ownerPayment = new OwnerPayment();
        vehicle_owner_combo.setSelectedIndex(0);
        amount_textbox.setText("");
        //paid_by_combo.setSelectedIndex(0);
        paid_by_combo.setSelectedIndex(CollectionUtil.getDefaultEmployeeIndex(paidByList));
        paid_mode_combo.setSelectedIndex(-1);
        vownerpayment_textarea.setText("");
        owner_search_tb.setSelectedIndex(0);
        fromDate.setDate(new Date());
        toDate.setDate(new Date());
        amount_tb.setText("");
        remainingbalance_tb.setText("");
        balance_tb.setText("");
        ownerPaymentData.clear();
        owner_payment_table.setModel(new javax.swing.table.DefaultTableModel(ownerPaymentData, header));
    }
    
    private void populatebalance(Long ownerId) {
        OwnerPaymentBalanceSum sumbalance = controller.getBalanceSum(ownerId);
        OwnerPaymentBalanceSum sumownerpayment = controller.getPaymentBalanceSum(ownerId);
        balance_tb.setText(String.valueOf(sumbalance.getSumBalance()-sumownerpayment.getSumBalance()));
    }

    private void search(OwnerPaymentSearchDTO search) {
        try{
            ownerPaymentData.clear();
        ownerPaymentData = controller.getSearchResults(search);
        if (ownerPaymentData == null || ownerPaymentData.size() == 0) {
                JOptionPane.showMessageDialog(null, "No Record Found");
        } 
        owner_payment_table.setModel(new javax.swing.table.DefaultTableModel(ownerPaymentData, header));
        sorter = new TableRowSorter<TableModel>();
        sorter = new TableRowSorter<TableModel>(owner_payment_table.getModel());
        owner_payment_table.setRowSorter(sorter);
        
        }catch(TransTrackException e){
             JOptionPane.showMessageDialog(null, e.getMessage());
        }
    }

    private void displayRowValues(Long valueOf) {
        ownerPayment = controller.getOwnerPaymentDetails(valueOf);
        if (ownerPayment != null) {
            vehicleOwnerPaymentDate.setDate(ownerPayment.getPayment_date());
            if(ownerPayment.getOwner_id()!=null){
                vehicle_owner_combo.setSelectedIndex(CollectionUtil.getOwnerIndex(vehicleOwnerList, ownerPayment.getOwner_id()));
            }
            if(ownerPayment.getPaid_by_id()!=null){
                paid_by_combo.setSelectedIndex(CollectionUtil.getEmployeeNameIndex(paidByList, ownerPayment.getPaid_by_id()));
            }
            amount_textbox.setText(String.valueOf(ownerPayment.getAmount()));
            if(ownerPayment.getPayment_mode_id() != null){
                paid_mode_combo.setSelectedIndex(CollectionUtil.getCodeIndex(codeList, ownerPayment.getPayment_mode_id()));
            }
            vownerpayment_textarea.setText(ownerPayment.getRemarks());
            OwnerPaymentBalanceSum sumbalance = controller.getBalanceSum(ownerPayment.getOwner_id());
            OwnerPaymentBalanceSum sumownerpayment = controller.getPaymentBalanceSum(ownerPayment.getOwner_id());
            balance_tb.setText(String.valueOf((sumbalance.getSumBalance()-sumownerpayment.getSumBalance())+ownerPayment.getAmount()));
        }
    }
    
     private boolean validateOwnerPayment() {
       boolean valid = true;
       
        if(this.vehicle_owner_combo.getSelectedItem() == null){
           JOptionPane.showMessageDialog(null, "Vehicle Owner Name should be Selected", "Error", JOptionPane.ERROR_MESSAGE);
           vehicle_owner_combo.requestFocus();
            valid = false;
       }else if((this.amount_textbox.getText().trim().length() == 0)||(!StringUtils.isNotBlank(this.amount_textbox.getText()))){
           JOptionPane.showMessageDialog(null, "Payment Amount must not be empty", "Error", JOptionPane.ERROR_MESSAGE);
           amount_textbox.requestFocus();
            valid = false;
       }else if (!(this.amount_textbox.getText().matches("^\\d*[\\.]?\\d*$"))){
            JOptionPane.showMessageDialog(null, "Amount should be Numerical", "Error", JOptionPane.ERROR_MESSAGE);
            amount_textbox.requestFocus();
            valid = false;

        }else if(this.paid_mode_combo.getSelectedItem() == null){
           JOptionPane.showMessageDialog(null, "Paid Mode should be Selected", "Error", JOptionPane.ERROR_MESSAGE);
           paid_mode_combo.requestFocus();
            valid = false;
       }else if(this.paid_by_combo.getSelectedItem() == null){
           JOptionPane.showMessageDialog(null, "Paid by should be Selected", "Error", JOptionPane.ERROR_MESSAGE);
           paid_by_combo.requestFocus();
            valid = false;
       }
       
        return valid;
    }
}

Commits for TransPort_Tracking/TransPortTracking/src/main/java/com/bestray/transtracking/views/VehicleOwnerPayment.java

Diff revisions: vs.
Revision Author Commited Message
1 girijabapi picture girijabapi Sat 28 Jul, 2018 05:29:14 +0000