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
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bestray.transtracking.views;

import com.bestray.transtracking.controller.CostToVehicleController;
import com.bestray.transtracking.dto.CostToVehicleSearchDTO;
import com.bestray.transtracking.exceptions.TransTrackException;
import com.bestray.transtracking.reports.AllCostToVehicleReport;
import com.bestray.transtracking.reports.CostToVehicleReport;
import com.bestray.transtracking.util.CollectionUtil;
import com.bestray.trastrack.domain.Code;
import com.bestray.trastrack.domain.CostToVehicle;
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.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 User1
 */
public class CostToVehicleEntry extends javax.swing.JPanel {

    /**
     * Creates new form CostToVehicleEntry
     */
    public CostToVehicleEntry() {
        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();
        vehicle_cost_date = new org.jdesktop.swingx.JXDatePicker();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        owned_vehicle_cb = new javax.swing.JComboBox();
        paid_mode_cb = new javax.swing.JComboBox();
        cost_amount_tb = new javax.swing.JTextField();
        paid_by_cb = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        note_textarea = new javax.swing.JTextArea();
        jLabel1 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jLabel11 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        remaining_office_expensestb = new javax.swing.JTextField();
        jLabel22 = new javax.swing.JLabel();
        cost_to_vehicles_todaytb = new javax.swing.JTextField();
        jLabel23 = new javax.swing.JLabel();
        remaining_amounttb = new javax.swing.JTextField();
        jLabel24 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        refreshbt = new javax.swing.JButton();
        editbt = new javax.swing.JButton();
        savebt = new javax.swing.JButton();
        deletebt = new javax.swing.JButton();
        jLabel14 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jLabel15 = new javax.swing.JLabel();
        VehicleNumberSearchCombo = new javax.swing.JComboBox();
        jLabel16 = new javax.swing.JLabel();
        fromDate = new org.jdesktop.swingx.JXDatePicker();
        jLabel17 = new javax.swing.JLabel();
        toDate = new org.jdesktop.swingx.JXDatePicker();
        SearchBtn = new javax.swing.JButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        CostToVehicleSearchTable = 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;
            }
        };
        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("Date :");

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

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

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

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

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

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

        paid_mode_cb.setModel(new javax.swing.DefaultComboBoxModel(paidModes));
        paid_mode_cb.setSelectedIndex(-1);

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

        paid_by_cb.setModel(new javax.swing.DefaultComboBoxModel(paidbyList));
        paid_by_cb.setSelectedIndex(CollectionUtil.getDefaultEmployeeIndex(paidbyList));
        AutoCompleteDecorator.decorate(this.paid_by_cb);
        //paid_by_cb.setSelectedIndex(-1);

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

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

        note_textarea.setColumns(20);
        note_textarea.setRows(5);
        jScrollPane1.setViewportView(note_textarea);

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

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

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

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

        jLabel11.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        jLabel11.setText("Remaining Office Expenses :");

        jLabel18.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        jLabel18.setText("Cost To Vehicles done today:");

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

        jLabel22.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        jLabel22.setText("INR");

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

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

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

        jLabel24.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        jLabel24.setText("INR");

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

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jLabel18, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel20, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(cost_to_vehicles_todaytb, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 105, Short.MAX_VALUE)
                    .addComponent(remaining_office_expensestb, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(remaining_amounttb))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel22)
                    .addComponent(jLabel23)
                    .addComponent(jLabel24))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel4Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel11, jLabel18});

        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(remaining_office_expensestb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel22))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel18)
                    .addComponent(cost_to_vehicles_todaytb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel23))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(remaining_amounttb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel24)
                    .addComponent(jLabel20))
                .addContainerGap())
        );

        jPanel4Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jLabel11, jLabel18});

        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(jLabel1)
                    .addComponent(jLabel9)
                    .addComponent(jLabel10))
                .addGap(1, 1, 1)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addComponent(jLabel2)
                    .addComponent(jLabel3)
                    .addComponent(jLabel4)
                    .addComponent(jLabel8)
                    .addComponent(jLabel6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(owned_vehicle_cb, 0, 233, Short.MAX_VALUE)
                                .addGap(286, 286, 286))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                            .addComponent(paid_mode_cb, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                            .addComponent(cost_amount_tb, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE))
                                        .addGap(0, 0, 0)
                                        .addComponent(jLabel7))
                                    .addComponent(vehicle_cost_date, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                        .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(paid_by_cb, javax.swing.GroupLayout.PREFERRED_SIZE, 224, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 263, 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(jLabel2)
                            .addComponent(vehicle_cost_date, 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(jLabel3)
                            .addComponent(owned_vehicle_cb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(paid_mode_cb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel9))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(cost_amount_tb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7)
                            .addComponent(jLabel10))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(paid_by_cb, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jPanel4, 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(jLabel8)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 78, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

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

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

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

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

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

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap(634, Short.MAX_VALUE)
                .addComponent(refreshbt, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(editbt, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(savebt, 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))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(0, 0, 0)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(savebt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(editbt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(refreshbt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(deletebt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
        );

        jLabel14.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 14)); // NOI18N
        jLabel14.setText("Cost To Vehicle Entry");

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

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

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

        VehicleNumberSearchCombo.setModel(new javax.swing.DefaultComboBoxModel(vehicleSearchNumber));
        AutoCompleteDecorator.decorate(this.VehicleNumberSearchCombo);
        VehicleNumberSearchCombo.setSelectedIndex(-1);

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

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

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

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

        SearchBtn.setFont(new java.awt.Font("Microsoft Sans Serif", 1, 12)); // NOI18N
        SearchBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/search.png"))); // NOI18N
        SearchBtn.setText("Search");
        SearchBtn.setOpaque(false);
        SearchBtn.setPreferredSize(new java.awt.Dimension(85, 25));
        SearchBtn.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SearchBtnActionPerformed(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(jLabel15)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(VehicleNumberSearchCombo, javax.swing.GroupLayout.PREFERRED_SIZE, 188, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(41, 41, 41)
                .addComponent(jLabel16)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(fromDate, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel17)
                .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, 240, Short.MAX_VALUE)
                .addComponent(SearchBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addGap(0, 0, 0)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15)
                    .addComponent(VehicleNumberSearchCombo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel16)
                    .addComponent(jLabel17)
                    .addComponent(SearchBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(fromDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(toDate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(0, 0, 0))
        );

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

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

        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(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, 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)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, 0)
                        .addComponent(jLabel14)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(jScrollPane2, 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(jLabel14)
                    .addComponent(jLabel13, 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)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, 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())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void savebtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_savebtActionPerformed
       try{
       if(validateCostToVehicle()){
        vehiclecost.setCost_to_vehicle_date(vehicle_cost_date.getDate());
        Vehicle vehicle = (Vehicle) owned_vehicle_cb.getSelectedItem();
        vehiclecost.setVehicle_id(vehicle.getId());
        Code c = (Code)paid_mode_cb.getSelectedItem();
        vehiclecost.setPaid_mode_id(c.getId());
        vehiclecost.setCost_amount(Double.parseDouble(cost_amount_tb.getText()));
        Employee e = (Employee)paid_by_cb.getSelectedItem();
        vehiclecost.setPaid_by_id(e.getId());
        vehiclecost.setNote(note_textarea.getText());
        controller = new CostToVehicleController();
        controller.saveCostToVehicleEntry(vehiclecost);
        JOptionPane.showMessageDialog(null,"Cost to Vehicle Entry has been Saved");
        clearfields();
       }
     }catch(Exception e)
     {
         JOptionPane.showMessageDialog(null,"Data not Saved");
     }
    }//GEN-LAST:event_savebtActionPerformed

    private void refreshbtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshbtActionPerformed
        clearfields();
    }//GEN-LAST:event_refreshbtActionPerformed

    private void SearchBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SearchBtnActionPerformed
        
        try{
            CostToVehicleSearchDTO search = new CostToVehicleSearchDTO();
            Vehicle vehicle = (Vehicle) VehicleNumberSearchCombo.getSelectedItem();
            //System.out.println(vehicle.getId());
            search.setVehicleId(vehicle.getId());
            search.setSearchFrom(fromDate.getDate());
            search.setSearchTo(toDate.getDate());
            search(search);
        }catch(Exception e)
        {
             JOptionPane.showMessageDialog(null, "Select Vehicle Number ");
            VehicleNumberSearchCombo.requestFocus();
        }
        
    }//GEN-LAST:event_SearchBtnActionPerformed

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

    private void deletebtActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deletebtActionPerformed
       int row = CostToVehicleSearchTable.getSelectedRow();
            if (row >= 0) {
            Object o = CostToVehicleSearchTable.getValueAt(row, 0);
            try {
                if(JOptionPane.showConfirmDialog(null, "Do you want to delete the selected Record","", JOptionPane.OK_CANCEL_OPTION)==0){
                controller.deleteCostToVehicleRecord(Long.valueOf(o.toString()));
                 JOptionPane.showMessageDialog(null, "Selected Information Deleted");
                 clearfields();
                 // doSearch();
             }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 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 ?", "Cost To Vehicle Report", JOptionPane.YES_NO_OPTION);  
        if (reply == JOptionPane.YES_OPTION){  
        try{
            if(VehicleNumberSearchCombo.getSelectedItem()!=null){
               
                    CostToVehicleReport costToVehicleReport=new CostToVehicleReport();
                    vehicleNo=VehicleNumberSearchCombo.getSelectedItem().toString();
                    from=fromDate.getDate();
                    to=toDate.getDate();
                    costToVehicleReport.getXlsReport(vehicleNo,from,to);
                    reply = JOptionPane.showConfirmDialog(null, "Do you want to open this File ?", "Cost To Vehicle Report", JOptionPane.YES_NO_OPTION);  
                    if (reply == JOptionPane.YES_OPTION)  
                    {  
                         costToVehicleReport.openXlsReport();
                    } 
               
            }
            else{
                AllCostToVehicleReport allCostToVehicleReport=new AllCostToVehicleReport();
                from=fromDate.getDate();
                to=toDate.getDate();
                allCostToVehicleReport.getXlsReport(from,to);
                reply = JOptionPane.showConfirmDialog(null, "Do you want to open this File ?", "All Cost To Vehicle Report", JOptionPane.YES_NO_OPTION);  
                if (reply == JOptionPane.YES_OPTION)  
                {  
                    allCostToVehicleReport.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 ?", "Cost To Vehicle Report", JOptionPane.YES_NO_OPTION);  
        if (reply == JOptionPane.YES_OPTION){  
         try{
            if(VehicleNumberSearchCombo.getSelectedItem()!=null){
               
                    CostToVehicleReport costToVehicleReport=new CostToVehicleReport();
                    vehicleNo=VehicleNumberSearchCombo.getSelectedItem().toString();
                    from=fromDate.getDate();
                    to=toDate.getDate();
                    costToVehicleReport.getPdfReport(vehicleNo,from,to);
                    reply = JOptionPane.showConfirmDialog(null, "Do you want to open this File ?", "Cost To Vehicle Report", JOptionPane.YES_NO_OPTION);  
                    if (reply == JOptionPane.YES_OPTION)  
                    {  
                         costToVehicleReport.openPdfReport();
                    } 
               
            }
            else{
                AllCostToVehicleReport allCostToVehicleReport=new AllCostToVehicleReport();
                from=fromDate.getDate();
                to=toDate.getDate();
                allCostToVehicleReport.getPdfReport(from,to);
                reply = JOptionPane.showConfirmDialog(null, "Do you want to open this File ?", "All Client Collection Report", JOptionPane.YES_NO_OPTION);  
                if (reply == JOptionPane.YES_OPTION)  
                {  
                    allCostToVehicleReport.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 owned_vehicle_cbActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_owned_vehicle_cbActionPerformed
        getRemianingBalance();
    }//GEN-LAST:event_owned_vehicle_cbActionPerformed

    private void cost_amount_tbFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_cost_amount_tbFocusLost
        if (StringUtils.isNotBlank(cost_amount_tb.getText())) {
            cost_to_vehicles_todaytb.setText(cost_amount_tb.getText());
            remaining_amounttb.setText(String.valueOf(Double.parseDouble(remaining_office_expensestb.getText())-Double.parseDouble(cost_to_vehicles_todaytb.getText())));
        } else {
        }
    }//GEN-LAST:event_cost_amount_tbFocusLost
    Date from,to;
    String vehicleNo;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTable CostToVehicleSearchTable;
    private javax.swing.JButton SearchBtn;
    private javax.swing.JComboBox VehicleNumberSearchCombo;
    private javax.swing.JTextField cost_amount_tb;
    private javax.swing.JTextField cost_to_vehicles_todaytb;
    private javax.swing.JButton deletebt;
    private javax.swing.JButton editbt;
    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 jLabel11;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel3;
    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.JTextArea note_textarea;
    private javax.swing.JComboBox owned_vehicle_cb;
    private javax.swing.JComboBox paid_by_cb;
    private javax.swing.JComboBox paid_mode_cb;
    private javax.swing.JButton pdfbt;
    private javax.swing.JButton refreshbt;
    private javax.swing.JTextField remaining_amounttb;
    private javax.swing.JTextField remaining_office_expensestb;
    private javax.swing.JButton savebt;
    private org.jdesktop.swingx.JXDatePicker toDate;
    private org.jdesktop.swingx.JXDatePicker vehicle_cost_date;
    // End of variables declaration//GEN-END:variables
    private Vector<Employee> paidbyList = new Vector<Employee>();
    private Vector<Vehicle> ownedVehicleList = new Vector<Vehicle>();
    private Vector<Vehicle> vehicleSearchNumber = new Vector<Vehicle>();
    private Vector<Vector<String>> costToVehicleSearchData = new Vector<Vector<String>>();
    TableRowSorter<TableModel> sorter;
    Vector header = new Vector<String>();
    private Vector<Code> paidModes = new Vector<Code>();
    //private CostToVehicle costTovehicle = new CostToVehicle();
    private CostToVehicleController controller;
    private CostToVehicle vehiclecost; 
    
    
    private void populateData() {
    
        controller = new CostToVehicleController();
        //vehiclecost = new CostToVehicle();
        paidbyList = controller.getPaidByList();
        ownedVehicleList = controller.getOwnedVehicleList();
        vehicleSearchNumber = controller.getOwnedVehicleSearchList();
        paidModes = controller.getPaidModeList();
        header = new Vector<String>();
        header.add("ID");
        header.add("Date");
        header.add("Vehicle Number");
        header.add("Paid Mode");
        header.add("Amount");
        header.add("Paid By");
        //header.add("Notes");
        vehiclecost = new CostToVehicle();
        
    }
    private void clearfields(){
       vehiclecost = new CostToVehicle();
       //vehicle_cost_date.setDate(new Date());
       owned_vehicle_cb.setSelectedIndex(-1);
       paid_mode_cb.setSelectedIndex(-1);
       cost_amount_tb.setText("");
       //paid_by_cb.setSelectedIndex(-1);
       paid_by_cb.setSelectedIndex(CollectionUtil.getDefaultEmployeeIndex(paidbyList));
       note_textarea.setText("");
       fromDate.setDate(new Date());
       toDate.setDate(new Date());
       VehicleNumberSearchCombo.setSelectedIndex(-1);
       cost_to_vehicles_todaytb.setText("");
       remaining_office_expensestb.setText("");
       remaining_amounttb.setText("");
       costToVehicleSearchData.clear();
       CostToVehicleSearchTable.setModel(new javax.swing.table.DefaultTableModel(costToVehicleSearchData, header));
       CostToVehicleSearchTable.getColumnModel().getColumn(0).setPreferredWidth(87);
        CostToVehicleSearchTable.getColumnModel().getColumn(0).setMaxWidth(87);
          
     }

    private void search(CostToVehicleSearchDTO search){
        
        try {
             costToVehicleSearchData.clear();
             costToVehicleSearchData = controller.getSearchResults(search);
            if(costToVehicleSearchData == null || costToVehicleSearchData.size() == 0) 
            {
                JOptionPane.showMessageDialog(null, "No Record Found");
               
            } 
             CostToVehicleSearchTable.setModel(new javax.swing.table.DefaultTableModel(costToVehicleSearchData, header));
             CostToVehicleSearchTable.getColumnModel().getColumn(0).setPreferredWidth(87);
                CostToVehicleSearchTable.getColumnModel().getColumn(0).setMaxWidth(87);
             sorter = new TableRowSorter<TableModel>();
             sorter = new TableRowSorter<TableModel>(CostToVehicleSearchTable.getModel());
             CostToVehicleSearchTable.setRowSorter(sorter);
         
        } catch (TransTrackException e) {
            JOptionPane.showMessageDialog(null, e.getMessage());
        }
    }
//Long costid;
    private void displayRowValues(Long costovehicleID) {
        vehiclecost = controller.getCostoVehicleRegistrationDetails(costovehicleID);
        
        if(vehiclecost != null){
           // System.out.println("ID2: "+vehiclecost.getId());
            //costid=vehiclecost.getId();
           // jobscrolltb.setText(String.valueOf(jobEntry.getJob_scroll()));
            vehicle_cost_date.setDate(vehiclecost.getCost_to_vehicle_date());
            //Transaction_type_combobox.setSelectedItem(jobEntry.getJob_transaction_type());
            if(vehiclecost.getVehicle_id() != null){
                owned_vehicle_cb.setSelectedIndex(CollectionUtil.getVehicleNumberIndex(ownedVehicleList, vehiclecost.getVehicle_id()));
            }
            if(vehiclecost.getPaid_mode_id() != null){
                paid_mode_cb.setSelectedIndex(CollectionUtil.getCodeIndex(paidModes, vehiclecost.getPaid_mode_id()));
            }
            cost_amount_tb.setText(String.valueOf(vehiclecost.getCost_amount()));
            if(vehiclecost.getPaid_by_id() != null){
                paid_by_cb.setSelectedIndex(CollectionUtil.getDriverIndex(paidbyList, vehiclecost.getPaid_by_id()));
            }
            note_textarea.setText(vehiclecost.getNote());
            
        }
    }

    private boolean validateCostToVehicle() {
       boolean valid=true;
        if(this.owned_vehicle_cb.getSelectedIndex() == -1){
            JOptionPane.showMessageDialog(null, "Vehicle Number should be Selected", "Error", JOptionPane.ERROR_MESSAGE);
            owned_vehicle_cb.requestFocus();
            valid = false;
        }
        else if(this.paid_mode_cb.getSelectedIndex() == -1){
            JOptionPane.showMessageDialog(null, "Paid Mode should be Selected", "Error", JOptionPane.ERROR_MESSAGE);
            paid_mode_cb.requestFocus();
            valid = false;
        }
        else if ((this.cost_amount_tb.getText().trim().length() == 0)||(!StringUtils.isNotBlank(this.cost_amount_tb.getText()))) {
            JOptionPane.showMessageDialog(null, "Amount must not be Empty", "Error", JOptionPane.ERROR_MESSAGE);
            cost_amount_tb.requestFocus();
            valid = false;
        }
        else if (!(this.cost_amount_tb.getText().matches("^\\d*[\\.]?\\d*$")))
        {

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

        }
         else if(this.cost_amount_tb.getText().matches("^[\\.]+$"))
        {
            JOptionPane.showMessageDialog(null, "Enter valid Amount ", "Error", JOptionPane.ERROR_MESSAGE);
            cost_amount_tb.requestFocus();
            valid = false;
        }
        else if(this.paid_by_cb.getSelectedIndex() == -1){
            JOptionPane.showMessageDialog(null, "Paid By should be Selected", "Error", JOptionPane.ERROR_MESSAGE);
            paid_by_cb.requestFocus();
            valid = false;
        }
        return valid;
    
    }

    private void getRemianingBalance() {
        //Double TotalOfficeExpense = controller.getTotalOfficeExpense();
        //Double TotalCostToVehicles = controller.getTotalCostToVehicles();
        //Double subtract = TotalOfficeExpense-TotalCostToVehicles;
        //String s = BigDecimal.valueOf(subtract).toPlainString();
        remaining_office_expensestb.setText(String.valueOf(controller.getTotalOfficeExpense()-controller.getTotalCostToVehicles()));
        //remaining_office_expensestb.setText(s);
        //cost_to_vehicles_todaytb.setText(String.valueOf(controller.getTotalCostToVehicles()));
        //remaining_amounttb.setText(String.valueOf(Double.parseDouble(remaining_office_expensestb.getText())-Double.parseDouble(cost_to_vehicles_todaytb.getText())));

    }
    
}

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

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