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
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bestray.transtracking.views;

import com.bestray.transtracking.controller.DriverPaymentController;
import com.bestray.transtracking.controller.VehicleExpenseController;
import com.bestray.transtracking.dto.EmployeePaymentSearchDTO;
import com.bestray.transtracking.exceptions.TransTrackException;
import com.bestray.transtracking.reports.AllEmployeePaymentReport;
import com.bestray.transtracking.reports.DriverPaymentReport;
import com.bestray.transtracking.reports.EmployeePaymentReport;
import com.bestray.transtracking.util.CollectionUtil;
import com.bestray.trastrack.domain.Code;
import com.bestray.trastrack.domain.DriverStaffPayment;
import com.bestray.trastrack.domain.Employee;
import com.bestray.trastrack.domain.Vehicle;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.util.Date;
import java.util.Vector;
import javax.sql.DataSource;
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;
import org.springframework.jdbc.core.JdbcTemplate;

/**
 *
 * @author user2
 */
public class DriverPaymentPannel extends javax.swing.JPanel {

    /**
     * Creates new form DriverPaymentPannel
     */
    public DriverPaymentPannel() {
       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() {

        jPanel1 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        VehicleNumberlb = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        Amountlb = new javax.swing.JLabel();
        Amounttb = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        Notestb = new javax.swing.JTextField();
        Notes1tb = new javax.swing.JTextField();
        paydate = new org.jdesktop.swingx.JXDatePicker();
        DriverNameCombo = new javax.swing.JComboBox();
        VehicleNumbercombo = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        EmployeeCategoryCombo = new javax.swing.JComboBox();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        Refreshbtn = new javax.swing.JButton();
        Savebtn = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        EmplNameSearchCombo = new javax.swing.JComboBox();
        jLabel9 = new javax.swing.JLabel();
        fromDate = new org.jdesktop.swingx.JXDatePicker();
        toDate = new org.jdesktop.swingx.JXDatePicker();
        jLabel10 = new javax.swing.JLabel();
        searchButton = new javax.swing.JButton();
        search_mode_combo = new javax.swing.JComboBox();
        jLabel23 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        ResultTable = 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;
            }
        };
        Delete = new javax.swing.JButton();
        editbtn = new javax.swing.JButton();
        excelbt = new javax.swing.JButton();
        pdfbt = new javax.swing.JButton();

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

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

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

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

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

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

        Amounttb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AmounttbActionPerformed(evt);
            }
        });

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

        Notestb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                NotestbActionPerformed(evt);
            }
        });

        Notes1tb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Notes1tbActionPerformed(evt);
            }
        });

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

        DriverNameCombo.setModel(new javax.swing.DefaultComboBoxModel(driverNameList));
        AutoCompleteDecorator.decorate(this.DriverNameCombo);
        DriverNameCombo.setSelectedIndex(-1);
        DriverNameCombo.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                DriverNameComboItemStateChanged(evt);
            }
        });

        VehicleNumbercombo.setModel(new javax.swing.DefaultComboBoxModel(vehicleNumberList));
        AutoCompleteDecorator.decorate(this.VehicleNumbercombo);
        VehicleNumbercombo.setSelectedIndex(-1);
        VehicleNumbercombo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                VehicleNumbercomboActionPerformed(evt);
            }
        });

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

        EmployeeCategoryCombo.setModel(new javax.swing.DefaultComboBoxModel(codeList));
        EmployeeCategoryCombo.setEnabled(false);
        EmployeeCategoryCombo.setSelectedIndex(-1);
        EmployeeCategoryCombo.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                EmployeeCategoryComboItemStateChanged(evt);
            }
        });
        EmployeeCategoryCombo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                EmployeeCategoryComboActionPerformed(evt);
            }
        });

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

        jLabel13.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabel13.setForeground(new java.awt.Color(255, 0, 0));
        jLabel13.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.LEADING)
                    .addComponent(jLabel13)
                    .addComponent(jLabel12))
                .addGap(1, 1, 1)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4)
                    .addComponent(jLabel7)
                    .addComponent(VehicleNumberlb)
                    .addComponent(Amountlb)
                    .addComponent(jLabel6)
                    .addComponent(jLabel2))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(Amounttb, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Notestb, javax.swing.GroupLayout.PREFERRED_SIZE, 308, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Notes1tb, javax.swing.GroupLayout.PREFERRED_SIZE, 308, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(VehicleNumbercombo, javax.swing.GroupLayout.Alignment.LEADING, 0, 257, Short.MAX_VALUE)
                        .addComponent(DriverNameCombo, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(paydate, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(EmployeeCategoryCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(paydate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel12, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel4)
                        .addComponent(DriverNameCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(EmployeeCategoryCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(VehicleNumberlb)
                    .addComponent(VehicleNumbercombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Amountlb)
                    .addComponent(Amounttb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel13))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(Notestb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(Notes1tb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

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

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

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

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

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

        EmplNameSearchCombo.setModel(new javax.swing.DefaultComboBoxModel(driverList));
        AutoCompleteDecorator.decorate(this.EmplNameSearchCombo);
        EmplNameSearchCombo.setSelectedIndex(-1);

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

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

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

        jLabel10.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        jLabel10.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);
            }
        });

        search_mode_combo.setModel(new javax.swing.DefaultComboBoxModel(new String[] { selectionType.DRIVER.getDescription(), selectionType.VEHICLE.getDescription()}));
        search_mode_combo.setSelectedIndex(-1);
        search_mode_combo.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                search_mode_comboItemStateChanged(evt);
            }
        });

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

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addComponent(jLabel23)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(search_mode_combo, javax.swing.GroupLayout.PREFERRED_SIZE, 144, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(32, 32, 32)
                .addComponent(EmplNameSearchCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 221, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 73, Short.MAX_VALUE)
                .addComponent(jLabel9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(fromDate, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(10, 10, 10)
                .addComponent(jLabel10)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(toDate, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(71, 71, 71)
                .addComponent(searchButton, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, 0))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(0, 0, 0)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel23)
                        .addComponent(search_mode_combo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(EmplNameSearchCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel9)
                        .addComponent(fromDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(toDate, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel10)
                        .addComponent(searchButton, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(0, 0, 0))
        );

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

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

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

        editbtn.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        editbtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/edit.png"))); // NOI18N
        editbtn.setText("Edit");
        editbtn.setOpaque(false);
        editbtn.setPreferredSize(new java.awt.Dimension(85, 25));
        editbtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editbtnActionPerformed(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);
            }
        });

        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);
            }
        });

        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(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addGap(2, 2, 2)
                        .addComponent(jLabel8)
                        .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)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .addComponent(Refreshbtn, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(editbtn, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(Savebtn, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(Delete, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                                .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.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {Refreshbtn, Savebtn});

        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel8)
                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))
                .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)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Refreshbtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Savebtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Delete, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(editbtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, 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(66, Short.MAX_VALUE))
        );

        layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {Refreshbtn, Savebtn});

    }// </editor-fold>//GEN-END:initComponents

    private void AmounttbActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AmounttbActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_AmounttbActionPerformed

    private void NotestbActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NotestbActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_NotestbActionPerformed

    private void Notes1tbActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Notes1tbActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_Notes1tbActionPerformed

    private void VehicleNumbercomboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_VehicleNumbercomboActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_VehicleNumbercomboActionPerformed

    private void EmployeeCategoryComboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_EmployeeCategoryComboActionPerformed
        // TODO add your handling code here:
         //updateState();
        /* if(EmployeeCategoryCombo.getSelectedItem()!=null){
            
            Code v = (Code)EmployeeCategoryCombo.getSelectedItem();
            Long ID = v.getId();
           // displayVehicleinformations(ID);
            
        }*/
         
         
         
    }//GEN-LAST:event_EmployeeCategoryComboActionPerformed

    private void SavebtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SavebtnActionPerformed
        // TODO add your handling code here:
        try{
        if(validateDriverPayment()){
        //driverstaffpayment.setPayment_scroll_id(Long.parseLong(PaymentScrolltb.getText()));
        driverstaffpayment.setPayment_date(paydate.getDate());
       
        Vehicle vehicle = (Vehicle)VehicleNumbercombo.getSelectedItem();
         if(vehicle != null){
        driverstaffpayment.setVehicle_number_id(vehicle.getId());
        }else{
             driverstaffpayment.setVehicle_number_id(null);
         }
        Code empTypeId = (Code)EmployeeCategoryCombo.getSelectedItem();
        Employee emp = (Employee)DriverNameCombo.getSelectedItem();
        if(empTypeId != null){
        driverstaffpayment.setEmployee_type_id(empTypeId.getId());
        }
        if(emp != null){
        driverstaffpayment.setEmployee_name_id(emp.getId());
        }
        driverstaffpayment.setPayment_amount(Float.parseFloat(Amounttb.getText()));
        driverstaffpayment.setNote_1(Notestb.getText().toUpperCase());
        driverstaffpayment.setNote_2(Notes1tb.getText().toUpperCase());

        controller = new DriverPaymentController();
        controller.AddDriverStaffPayment(driverstaffpayment);

        JOptionPane.showMessageDialog(null,"Driver Staff Payment Information has been Saved");
        clearAllFields();
        }
     }catch(Exception e)
     {
          JOptionPane.showMessageDialog(null,"Driver Staff Payment Information not Saved");
     }
    }//GEN-LAST:event_SavebtnActionPerformed

    private void RefreshbtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RefreshbtnActionPerformed
       
        clearAllFields();
    }//GEN-LAST:event_RefreshbtnActionPerformed

    private void searchButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchButtonActionPerformed
      
      try{
        if(search_mode_combo.getSelectedItem().toString().equalsIgnoreCase("Vehicle")){
            EmployeePaymentSearchDTO search = new EmployeePaymentSearchDTO();
            Vehicle vehicle = (Vehicle) EmplNameSearchCombo.getSelectedItem();
            search.setVehicleId(vehicle.getId());
            search.setSearchFrom(fromDate.getDate());
            search.setSearchTo(toDate.getDate());
            search(search);
        }else if(search_mode_combo.getSelectedItem().toString().equalsIgnoreCase("Driver")){
            try{ 
                EmployeePaymentSearchDTO search = new EmployeePaymentSearchDTO();
                Employee employee = (Employee) EmplNameSearchCombo.getSelectedItem();
                search.setEmployeeId(employee.getId());
                search.setSearchFrom(fromDate.getDate());
                search.setSearchTo(toDate.getDate());
                search(search);
             }catch(Exception e){
                    JOptionPane.showMessageDialog(null, "Select Driver Name");
                    EmplNameSearchCombo.requestFocus();
             }
        }
       }catch(Exception e){
           JOptionPane.showMessageDialog(null, "Select Search Type");
            search_mode_combo.requestFocus();
       }
    }//GEN-LAST:event_searchButtonActionPerformed

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

    private void DeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DeleteActionPerformed
        
            int row = ResultTable.getSelectedRow();
            if(row >=0){
            Object o = ResultTable.getValueAt(row, 0);
            try {
                if(JOptionPane.showConfirmDialog(null, "Do you want to delete the selected Record.","", JOptionPane.OK_CANCEL_OPTION)==0){   
                 controller.deleteDriverPayment(Long.valueOf(o.toString()));
                 JOptionPane.showMessageDialog(null, "Selected Employee payment Information Deleted");
                 clearAllFields();
            }
            else{
                   clearAllFields();
                }
            }catch(TransTrackException e) {

                JOptionPane.showMessageDialog(null, e.getMessage());
            }
          }
          else{
                JOptionPane.showMessageDialog(null, "Record not selected for Delete");
         }
     
    }//GEN-LAST:event_DeleteActionPerformed

    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 ?", "Driver Payment Report", JOptionPane.YES_NO_OPTION);  
        if (reply == JOptionPane.YES_OPTION){  
        try{
            if(EmplNameSearchCombo.getSelectedItem()!=null){
                if(search_mode_combo.getSelectedItem().toString().equalsIgnoreCase("Vehicle")){
                    DriverPaymentReport driverPaymentReport=new DriverPaymentReport();
                    Vehicle vehicle=(Vehicle)EmplNameSearchCombo.getSelectedItem();
                    Long vehicleNo=vehicle.getId();
                    from=fromDate.getDate();
                    to=toDate.getDate();
                    driverPaymentReport.getXlsReport(vehicleNo,from,to);
                    reply = JOptionPane.showConfirmDialog(null, "Do you want to open this File ?", "Driver Payment Report", JOptionPane.YES_NO_OPTION);
                    if (reply == JOptionPane.YES_OPTION)
                    {
                        driverPaymentReport.openXlsReport();
                    }
                }else{
                    EmployeePaymentReport employeePaymentReport=new EmployeePaymentReport();
                    empName=EmplNameSearchCombo.getSelectedItem().toString();
                    from=fromDate.getDate();
                    to=toDate.getDate();
                    employeePaymentReport.getXlsReport(empName,from,to);
                    reply = JOptionPane.showConfirmDialog(null, "Do you want to open this File ?", "Driver Payment Report", JOptionPane.YES_NO_OPTION);
                    if (reply == JOptionPane.YES_OPTION)
                    {
                        employeePaymentReport.openXlsReport();
                    }
                }
            }
            else{
                AllEmployeePaymentReport allEmployeePaymentReport=new AllEmployeePaymentReport();
                from=fromDate.getDate();
                to=toDate.getDate();
                allEmployeePaymentReport.getXlsReport(from,to);
                reply = JOptionPane.showConfirmDialog(null, "Do you want to open this File ?", "All Driver Payment Report", JOptionPane.YES_NO_OPTION);
                if (reply == JOptionPane.YES_OPTION)
                {
                    allEmployeePaymentReport.openXlsReport();
                }
            }
            

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

    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 ?", "Driver Payment Report", JOptionPane.YES_NO_OPTION);  
        if (reply == JOptionPane.YES_OPTION){  
        try{
            if(EmplNameSearchCombo.getSelectedItem()!=null){
                if(search_mode_combo.getSelectedItem().toString().equalsIgnoreCase("Vehicle")){
                    DriverPaymentReport driverPaymentReport=new DriverPaymentReport();
                    Vehicle vehicle =(Vehicle)EmplNameSearchCombo.getSelectedItem();
                    Long vehicleNo=vehicle.getId();
                    from=fromDate.getDate();
                    to=toDate.getDate();
                    driverPaymentReport.getPdfReport(vehicleNo,from,to);
                    reply = JOptionPane.showConfirmDialog(null, "Do you want to open this File ?", "Driver Payment Report", JOptionPane.YES_NO_OPTION);
                    if (reply == JOptionPane.YES_OPTION)
                    {
                        driverPaymentReport.openPdfReport();
                    }
                }else{
                    EmployeePaymentReport employeePaymentReport=new EmployeePaymentReport();
                    empName=EmplNameSearchCombo.getSelectedItem().toString();
                    from=fromDate.getDate();
                    to=toDate.getDate();
                    employeePaymentReport.getPdfReport(empName,from,to);
                    reply = JOptionPane.showConfirmDialog(null, "Do you want to open this File ?", "Driver Payment Report", JOptionPane.YES_NO_OPTION);
                    if (reply == JOptionPane.YES_OPTION)
                    {
                        employeePaymentReport.openPdfReport();
                    }
                }

            }
            else{
                AllEmployeePaymentReport allEmployeePaymentReport=new AllEmployeePaymentReport();
                from=fromDate.getDate();
                to=toDate.getDate();
                allEmployeePaymentReport.getPdfReport(from,to);
                reply = JOptionPane.showConfirmDialog(null, "Do you want to open this File ?", "All Driver Payment Report", JOptionPane.YES_NO_OPTION);
                if (reply == JOptionPane.YES_OPTION)
                {
                    allEmployeePaymentReport.openPdfReport();
                }
            }

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

    private void DriverNameComboItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_DriverNameComboItemStateChanged
      if(DriverNameCombo.getSelectedItem()!=null){
            
            Employee v = (Employee)DriverNameCombo.getSelectedItem();
            Long ID = v.getId();
            displayEmployeenformations(ID);
            
        }
    }//GEN-LAST:event_DriverNameComboItemStateChanged

    private void EmployeeCategoryComboItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_EmployeeCategoryComboItemStateChanged
        //UpdateState();
    }//GEN-LAST:event_EmployeeCategoryComboItemStateChanged

    private void search_mode_comboItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_search_mode_comboItemStateChanged
        if(search_mode_combo.getSelectedItem()!=null){

            String selectedValue = (String)search_mode_combo.getSelectedItem();
            if(selectedValue.equals(selectionType.DRIVER.getDescription())){
                //populateDriverNames();
                EmplNameSearchCombo.setModel(new javax.swing.DefaultComboBoxModel(driverNameList));
                EmplNameSearchCombo.setSelectedIndex(-1);
            }else if(selectedValue.equals(selectionType.VEHICLE.getDescription())){
                //populateVehicleNumbers();
                EmplNameSearchCombo.setModel(new javax.swing.DefaultComboBoxModel(vehicleNumberList));
                EmplNameSearchCombo.setSelectedIndex(-1);
            }
            //System.out.println("Selected Value "+selectedValue);

        }
    }//GEN-LAST:event_search_mode_comboItemStateChanged
    enum selectionType{
        DRIVER("Driver"),
        VEHICLE("Vehicle");
        private String description;
        private selectionType(String description) {
            this.description = description;
        }
        public String getDescription() {
            return description;
        }
    }
    
    private Date from,to;
    private String empName;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel Amountlb;
    private javax.swing.JTextField Amounttb;
    private javax.swing.JButton Delete;
    private javax.swing.JComboBox DriverNameCombo;
    private javax.swing.JComboBox EmplNameSearchCombo;
    private javax.swing.JComboBox EmployeeCategoryCombo;
    private javax.swing.JTextField Notes1tb;
    private javax.swing.JTextField Notestb;
    private javax.swing.JButton Refreshbtn;
    private javax.swing.JTable ResultTable;
    private javax.swing.JButton Savebtn;
    private javax.swing.JComboBox VehicleNumbercombo;
    private javax.swing.JLabel VehicleNumberlb;
    private javax.swing.JButton editbtn;
    private javax.swing.JButton excelbt;
    private org.jdesktop.swingx.JXDatePicker fromDate;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    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.JScrollPane jScrollPane1;
    private org.jdesktop.swingx.JXDatePicker paydate;
    private javax.swing.JButton pdfbt;
    private javax.swing.JButton searchButton;
    private javax.swing.JComboBox search_mode_combo;
    private org.jdesktop.swingx.JXDatePicker toDate;
    // End of variables declaration//GEN-END:variables
         private DataSource dso;
         private JdbcTemplate jdbsTemplateObj;
         private Vector<Employee> driverList = new Vector<Employee>();
         private Vector<Employee> driverNameList = new Vector<Employee>();
         private Vector<Vehicle> vehicleNumber = new Vector<Vehicle>();
         private Vector<Vehicle> vehicleNumberList = new Vector<Vehicle>();
         private Vector<Code> codeList = new Vector<Code>();
         private Vector<Vector<String>> EmployeePaymentData = new Vector<Vector<String>>();
         private Vector<Vector<String>> vehicleExpenseSearchData = new Vector<Vector<String>>();
         private DriverPaymentController controller;
         private VehicleExpenseController vehicleExpensecontroller;
         private Code v2;
         private Employee e2;
         private DriverStaffPayment driverstaffpayment = new DriverStaffPayment();
         Vector header = new Vector<String>();
         TableRowSorter<TableModel> sorter;
     
     
     private void populateData() {
        controller = new DriverPaymentController();
        vehicleExpensecontroller= new VehicleExpenseController();
        driverList = controller.getDriversList();
        driverNameList = controller.getDriverNameList();
        vehicleNumber = controller.getVehicle_numberList();
        vehicleNumberList = controller.getVehicleList();
        codeList = controller.getCodeList();
        header.add("ID");
        header.add("Date");
        header.add("Employee Name");
        header.add("Employee Catagory");
        header.add("Amount");
        
       //driverstaffpayment = new DriverStaffPayment();
                      
    }
    private void clearAllFields(){
        driverstaffpayment = new DriverStaffPayment();
        //paydate.setDate(new Date());
        //PaymentScrolltb.setText("");
        EmployeeCategoryCombo.setSelectedIndex(-1);
        VehicleNumbercombo.setSelectedIndex(-1);
        DriverNameCombo.setSelectedIndex(-1);
        Amounttb.setText("");
        Notestb.setText("");
        Notes1tb.setText("");
        EmplNameSearchCombo.setSelectedIndex(-1);
        fromDate.setDate(new Date());
        toDate.setDate(new Date());
        EmployeePaymentData.clear();
        vehicleExpenseSearchData.clear();
        ResultTable.setModel(new javax.swing.table.DefaultTableModel(EmployeePaymentData, header));
        ResultTable.getColumnModel().getColumn(0).setPreferredWidth(87);
        ResultTable.getColumnModel().getColumn(0).setMaxWidth(87);
        
    }
    /*private void UpdateState(){
         if(EmployeeCategoryCombo.getSelectedItem()!=null){
             {
                 updateState();
             }
         //dipositedtb.setEnabled(true);
         //jLabel7.setEnabled(true);
         }else{
             
             VehicleNumbercombo.setEnabled(false);
             VehicleNumberlb.setEnabled(false);
         }
     }
    
    protected void updateState() {
        
    //boolean enabled = (!EmployeeCategoryCombo.getSelectedItem().toString().equals("Office Staff"));
    //VehicleNumbercombo.setEnabled(enabled ); 
    //VehicleNumberlb.setEnabled(enabled );
        if((!EmployeeCategoryCombo.getSelectedItem().toString().equalsIgnoreCase("Permanent Driver"))&&(!EmployeeCategoryCombo.getSelectedItem().toString().equalsIgnoreCase("Temporary Driver"))){
             VehicleNumberlb.setEnabled(false);
            VehicleNumbercombo.setEnabled(false);      
            //dipositedtb.setText("");
        }        
        else{
            VehicleNumberlb.setEnabled(true);
            VehicleNumbercombo.setEnabled(true);  
            //dipositedtb.setText("");
        }
    }*/
    
    
    private boolean validateDriverPayment() {
        boolean valid = true;
        
        if (this.DriverNameCombo.getSelectedIndex() == -1) {
            JOptionPane.showMessageDialog(null, "Employee Name should be Selected", "Error", JOptionPane.ERROR_MESSAGE);
            DriverNameCombo.requestFocus();
            valid = false;
       
        }
        /*else if (EmployeeCategoryCombo.getSelectedIndex() == -1) {

            JOptionPane.showMessageDialog(null, "Employee category should be Selected", "Error", JOptionPane.ERROR_MESSAGE);
            EmployeeCategoryCombo.requestFocus();
            valid = false;
       }*/
        else if ((this.Amounttb.getText().trim().length() == 0)||(!StringUtils.isNotBlank(this.Amounttb.getText()))) {
            JOptionPane.showMessageDialog(null, "Amount must not be Empty", "Error", JOptionPane.ERROR_MESSAGE);
            Amounttb.requestFocus();
            valid = false;
        }
         else if (!(this.Amounttb.getText().matches("^\\d*[\\.]?\\d*$")))
        {

            JOptionPane.showMessageDialog(null, "Amount should be Numerical", "Error", JOptionPane.ERROR_MESSAGE);
            Amounttb.requestFocus();
            valid = false;

        }
        else if(this.Amounttb.getText().matches("^[\\.]+$"))
        {
            JOptionPane.showMessageDialog(null, "Enter valid Amount ", "Error", JOptionPane.ERROR_MESSAGE);
            Amounttb.requestFocus();
            valid = false;
        }
      
       return valid;        
    }
     private void search(EmployeePaymentSearchDTO search) {
         try{
             EmployeePaymentData.clear();
            EmployeePaymentData = controller.getSearchResults(search);
        if (EmployeePaymentData == null || EmployeePaymentData.size() == 0) {
                JOptionPane.showMessageDialog(null, "No Record Found");
            } 
        ResultTable.setModel(new javax.swing.table.DefaultTableModel(EmployeePaymentData, header));
        ResultTable.getColumnModel().getColumn(0).setPreferredWidth(87);
        ResultTable.getColumnModel().getColumn(0).setMaxWidth(87);
        sorter = new TableRowSorter<TableModel>();
        sorter = new TableRowSorter<TableModel>(ResultTable.getModel());
        ResultTable.setRowSorter(sorter);
        
         }catch(TransTrackException e){
             JOptionPane.showMessageDialog(null, e.getMessage());
         }
    }
    

    private void displayRowValues(Long driverpaymentId) {
        
        driverstaffpayment = controller.getDriverPaymentDetails(driverpaymentId);
        
      
       if(driverstaffpayment.getEmployee_type_id() != null){
               EmployeeCategoryCombo.setSelectedIndex(CollectionUtil.getCodeIndex(codeList, driverstaffpayment.getEmployee_type_id()));
        }
        if(driverstaffpayment.getVehicle_number_id() != null)
        {
            VehicleNumbercombo.setSelectedIndex(CollectionUtil.getVehicleNumberIndex(vehicleNumberList, driverstaffpayment.getVehicle_number_id()));
        }
       if(driverstaffpayment.getEmployee_name_id() != null)
       {
            DriverNameCombo.setSelectedIndex(CollectionUtil.getDriverIndex(driverNameList, driverstaffpayment.getEmployee_name_id()));
       }
        
        paydate.setDate(driverstaffpayment.getPayment_date());
        //PaymentScrolltb.setText(String.valueOf(driverstaffpayment.getPayment_scroll_id()));
        Amounttb.setText(String.valueOf(driverstaffpayment.getPayment_amount()));
        Notestb.setText(driverstaffpayment.getNote_1());
        Notes1tb.setText(driverstaffpayment.getNote_2());
        
    
    }        

    private void displayEmployeenformations(Long employeeID) {
        e2 = controller.getEmployeeInfo(employeeID);
        
        if(e2 != null && e2.getCategoryCodeId() != null){
                EmployeeCategoryCombo.setSelectedIndex(CollectionUtil.getCodeIndex(codeList, e2.getCategoryCodeId()));
            }
        
        /*if(e2 != null && e2.getEmployee_Name() != null){
                VehicleNumbercombo.setSelectedIndex(CollectionUtil.getVehicleNumberIndex(vehicleNumber, e2.));
            }*/
    }
     
}

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

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