Subversion Repository Public Repository

Pharmacy_09_03_18

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
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bestray.healthcarepharmacy.view;


import com.bestray.healthcarecommonutil.exception.HealthCareException;
import com.bestray.healthcarecommonutil.exception.ProcessingException;
import com.bestray.healthcarecommonutil.util.DisabledGlassPane;
import com.bestray.healthcarecommonutil.util.PreferenceUtil;
import com.bestray.healthcarecommonutil.util.SimpleGradientPanel;
import com.bestray.healthcarecommonutil.util.StandardButton;
import com.bestray.healthcarecommonutil.vo.TAccount;
import com.bestray.healthcarecommonutil.vo.TCCodeValues;
import com.bestray.healthcarecommonutil.vo.TInventoryMaster;
import com.bestray.healthcarecommonutil.vo.TMedicationMaster;
import com.bestray.healthcarecommonutil.vo.TPatient;
import com.bestray.healthcarecommonutil.vo.TPharmacyBilling;
import com.bestray.healthcarecommonutil.vo.TPharmacySales;
import com.bestray.healthcarepharmacy.controller.PharmacyCodeValuesController;
import com.bestray.healthcarepharmacy.controller.PharmacyPatientController;
import com.bestray.healthcarepharmacy.controller.PurchaseController;
import com.bestray.healthcarepharmacy.controller.SalesBillingController;
import com.bestray.healthcarepharmacy.report.SalesBillingReport;
import com.bestray.healthcarepharmacy.util.MessageProperties;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.Frame;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.prefs.Preferences;
import javax.swing.DefaultCellEditor;
import javax.swing.JOptionPane;
import javax.swing.JRootPane;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import org.hibernate.exception.ConstraintViolationException;
import org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException;


/**
 *
 * @author user3
 */
public class PatientBillingPanel extends SimpleGradientPanel{

    /**
     * Creates new form PatientBillingPanel
     */
    public PatientBillingPanel() {
        populate();
        initComponents();
        showProductTable();
    }

    /**
     * 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() {

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        patient_name_Label = new javax.swing.JLabel();
        doctor_name_Label = new javax.swing.JLabel();
        patient_name_textbox = new javax.swing.JTextField();
        doctor_name_textbox = new javax.swing.JTextField();
        patient_address_Label = new javax.swing.JLabel();
        patient_address_textbox = new javax.swing.JTextField();
        sales_dateChooser = new com.toedter.calendar.JDateChooser();
        pat_search_bt = new javax.swing.JButton();
        patient_name_Label2 = new javax.swing.JLabel();
        new_patient_radiobutton = new javax.swing.JRadioButton();
        search_patient_radiobutton = new javax.swing.JRadioButton();
        patient_gender_label = new javax.swing.JLabel();
        patient_contact_no_label = new javax.swing.JLabel();
        patient_contact_no_textbox = new javax.swing.JTextField();
        patient_gender_combobox = new javax.swing.JComboBox();
        jScrollPane1 = new javax.swing.JScrollPane();
        product_table = new javax.swing.JTable(){

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

        };
        jToolBar2 = new javax.swing.JToolBar();
        med_add_bt = new javax.swing.JButton();
        remove_bt = new javax.swing.JButton();
        jPanel2 = new javax.swing.JPanel();
        save_button = new StandardButton("Receipt");
        reset_bt = new StandardButton("Receipt");
        generate_receipt_bt = new StandardButton("Receipt");
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        jLabel14 = new javax.swing.JLabel();
        vat_txt = new javax.swing.JTextField();
        tax_txt = new javax.swing.JTextField();
        totalamount_txt = new javax.swing.JTextField();
        discount_txt = new javax.swing.JTextField();
        paidamount_txt = new javax.swing.JTextField();
        balanceamount_txt = new javax.swing.JTextField();
        done_sales_bt = new StandardButton("Receipt");

        setOpaque(false);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Patient details", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("SansSerif", 1, 10), java.awt.Color.black)); // NOI18N
        jPanel1.setOpaque(false);

        patient_name_Label.setFont(new java.awt.Font("SansSerif", 0, 10)); // NOI18N
        patient_name_Label.setText("Name :");
        patient_name_Label.setMaximumSize(new java.awt.Dimension(72, 18));
        patient_name_Label.setMinimumSize(new java.awt.Dimension(72, 18));
        patient_name_Label.setPreferredSize(new java.awt.Dimension(72, 18));

        doctor_name_Label.setFont(new java.awt.Font("SansSerif", 0, 10)); // NOI18N
        doctor_name_Label.setText("Doctor Name:");
        doctor_name_Label.setMaximumSize(new java.awt.Dimension(72, 18));
        doctor_name_Label.setMinimumSize(new java.awt.Dimension(72, 18));
        doctor_name_Label.setPreferredSize(new java.awt.Dimension(72, 18));
        doctor_name_Label.setVisible(false);

        patient_name_textbox.setEditable(false);
        patient_name_textbox.setBackground(new java.awt.Color(255, 255, 255));
        patient_name_textbox.setFont(new java.awt.Font("SansSerif", 1, 10)); // NOI18N
        patient_name_textbox.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        patient_name_textbox.setNextFocusableComponent(patient_address_textbox);

        doctor_name_textbox.setEditable(false);
        doctor_name_textbox.setBackground(new java.awt.Color(255, 255, 255));
        doctor_name_textbox.setFont(new java.awt.Font("SansSerif", 1, 10)); // NOI18N
        doctor_name_textbox.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        doctor_name_textbox.setVisible(false);

        patient_address_Label.setFont(new java.awt.Font("SansSerif", 0, 10)); // NOI18N
        patient_address_Label.setText("Address :");
        patient_address_Label.setMaximumSize(new java.awt.Dimension(72, 18));
        patient_address_Label.setMinimumSize(new java.awt.Dimension(72, 18));
        patient_address_Label.setPreferredSize(new java.awt.Dimension(72, 18));

        patient_address_textbox.setEditable(false);
        patient_address_textbox.setFont(new java.awt.Font("SansSerif", 1, 10)); // NOI18N
        patient_address_textbox.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        patient_address_textbox.setNextFocusableComponent(patient_gender_combobox);

        sales_dateChooser.setBackground(new java.awt.Color(255, 255, 255));
        sales_dateChooser.setDate(new Date());
        sales_dateChooser.setDateFormatString("dd/MM/yyyy");
        sales_dateChooser.setFont(new java.awt.Font("SansSerif", 1, 10)); // NOI18N

        pat_search_bt.setFont(new java.awt.Font("SansSerif", 1, 10)); // NOI18N
        pat_search_bt.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/search-icon16X16.png"))); // NOI18N
        pat_search_bt.setContentAreaFilled(false);
        pat_search_bt.setFocusable(false);
        pat_search_bt.setMargin(new java.awt.Insets(2, 16, 2, 16));
        pat_search_bt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pat_search_btActionPerformed(evt);
            }
        });

        patient_name_Label2.setFont(new java.awt.Font("SansSerif", 0, 10)); // NOI18N
        patient_name_Label2.setText("Date:");
        patient_name_Label2.setMaximumSize(new java.awt.Dimension(72, 18));
        patient_name_Label2.setMinimumSize(new java.awt.Dimension(72, 18));
        patient_name_Label2.setPreferredSize(new java.awt.Dimension(72, 18));

        buttonGroup1.add(new_patient_radiobutton);
        new_patient_radiobutton.setFont(new java.awt.Font("SansSerif", 0, 10)); // NOI18N
        new_patient_radiobutton.setText("New Patient");
        new_patient_radiobutton.setNextFocusableComponent(search_patient_radiobutton);
        new_patient_radiobutton.setOpaque(false);
        new_patient_radiobutton.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                new_patient_radiobuttonItemStateChanged(evt);
            }
        });
        new_patient_radiobutton.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                new_patient_radiobuttonPropertyChange(evt);
            }
        });
        new_patient_radiobutton.setSelected(true);

        buttonGroup1.add(search_patient_radiobutton);
        search_patient_radiobutton.setFont(new java.awt.Font("SansSerif", 0, 10)); // NOI18N
        search_patient_radiobutton.setText("Search Patient");
        search_patient_radiobutton.setNextFocusableComponent(patient_name_textbox);
        search_patient_radiobutton.setOpaque(false);
        search_patient_radiobutton.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                search_patient_radiobuttonItemStateChanged(evt);
            }
        });

        patient_gender_label.setFont(new java.awt.Font("SansSerif", 0, 10)); // NOI18N
        patient_gender_label.setText("Gender :");
        patient_gender_label.setMaximumSize(new java.awt.Dimension(72, 18));
        patient_gender_label.setMinimumSize(new java.awt.Dimension(72, 18));
        patient_gender_label.setPreferredSize(new java.awt.Dimension(72, 18));

        patient_contact_no_label.setFont(new java.awt.Font("SansSerif", 0, 10)); // NOI18N
        patient_contact_no_label.setText("Contact No :");
        patient_contact_no_label.setMaximumSize(new java.awt.Dimension(72, 18));
        patient_contact_no_label.setMinimumSize(new java.awt.Dimension(72, 18));
        patient_contact_no_label.setPreferredSize(new java.awt.Dimension(72, 18));

        patient_contact_no_textbox.setEditable(true);
        patient_contact_no_textbox.setFont(new java.awt.Font("SansSerif", 1, 10)); // NOI18N
        patient_contact_no_textbox.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        patient_contact_no_textbox.setNextFocusableComponent(med_add_bt);

        patient_gender_combobox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "MALE", "FEMALE" }));
        patient_gender_combobox.setSelectedIndex(-1);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(patient_name_Label, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(patient_address_Label, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addComponent(patient_address_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(103, 103, 103)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(patient_name_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, 0)
                                .addComponent(pat_search_bt, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(new_patient_radiobutton)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addComponent(search_patient_radiobutton)))
                        .addGap(30, 30, 30)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(doctor_name_Label, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(doctor_name_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 365, Short.MAX_VALUE)
                                .addComponent(patient_name_Label2, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(patient_gender_label, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(patient_gender_combobox, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel1Layout.createSequentialGroup()
                                        .addComponent(patient_contact_no_label, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(patient_contact_no_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addGap(0, 0, Short.MAX_VALUE)))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(sales_dateChooser, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {doctor_name_textbox, patient_address_textbox, patient_name_textbox});

        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(sales_dateChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(patient_name_Label2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(doctor_name_Label, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(doctor_name_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(new_patient_radiobutton)
                        .addComponent(search_patient_radiobutton)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(patient_name_Label, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(patient_name_textbox, javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pat_search_bt, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(patient_gender_label, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(patient_gender_combobox, 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(patient_address_Label, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(patient_address_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(patient_contact_no_label, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(patient_contact_no_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {doctor_name_Label, doctor_name_textbox, patient_address_Label, patient_address_textbox, patient_contact_no_textbox, patient_name_Label, patient_name_Label2, patient_name_textbox, sales_dateChooser});

        product_table.setFont(new java.awt.Font("SansSerif", 0, 11)); // NOI18N
        product_table.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        product_table.setRowHeight(25);
        product_table.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                product_tableKeyReleased(evt);
            }
        });
        jScrollPane1.setViewportView(product_table);

        jToolBar2.setFloatable(false);
        jToolBar2.setRollover(true);
        jToolBar2.setOpaque(false);

        med_add_bt.setFont(new java.awt.Font("SansSerif", 1, 10)); // NOI18N
        med_add_bt.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Add-icon16x16.png"))); // NOI18N
        med_add_bt.setText("Add Medicine");
        med_add_bt.setFocusable(false);
        med_add_bt.setMargin(new java.awt.Insets(2, 16, 2, 16));
        med_add_bt.setNextFocusableComponent(remove_bt);
        med_add_bt.setOpaque(false);
        med_add_bt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                med_add_btActionPerformed(evt);
            }
        });
        jToolBar2.add(med_add_bt);

        remove_bt.setFont(new java.awt.Font("SansSerif", 1, 10)); // NOI18N
        remove_bt.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/minus-icon.png"))); // NOI18N
        remove_bt.setText("Remove");
        remove_bt.setFocusable(false);
        remove_bt.setMargin(new java.awt.Insets(2, 16, 2, 16));
        remove_bt.setNextFocusableComponent(done_sales_bt);
        remove_bt.setOpaque(false);
        remove_bt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                remove_btActionPerformed(evt);
            }
        });
        jToolBar2.add(remove_bt);

        jPanel2.setOpaque(false);

        save_button.setFont(new java.awt.Font("SansSerif", 1, 13)); // NOI18N
        save_button.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Save-icon 24X24.png"))); // NOI18N
        save_button.setText("Save & Print");
        save_button.setFocusable(false);
        save_button.setMargin(new java.awt.Insets(2, 16, 2, 16));
        save_button.setOpaque(false);
        save_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                save_buttonActionPerformed(evt);
            }
        });

        reset_bt.setFont(new java.awt.Font("SansSerif", 1, 13)); // NOI18N
        reset_bt.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/resetField24X24.png"))); // NOI18N
        reset_bt.setText("Refresh");
        reset_bt.setFocusable(false);
        reset_bt.setMargin(new java.awt.Insets(2, 16, 2, 16));
        reset_bt.setOpaque(false);
        reset_bt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                reset_btActionPerformed(evt);
            }
        });

        generate_receipt_bt.setFont(new java.awt.Font("SansSerif", 1, 13)); // NOI18N
        generate_receipt_bt.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/report 16X16.png"))); // NOI18N
        generate_receipt_bt.setText("Receipt");
        generate_receipt_bt.setOpaque(false);
        generate_receipt_bt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                generate_receipt_btActionPerformed(evt);
            }
        });

        jLabel9.setFont(new java.awt.Font("SansSerif", 0, 10)); // NOI18N
        jLabel9.setText("Total Amount:");
        jLabel9.setMaximumSize(new java.awt.Dimension(72, 18));
        jLabel9.setMinimumSize(new java.awt.Dimension(72, 18));
        jLabel9.setPreferredSize(new java.awt.Dimension(72, 18));

        jLabel10.setFont(new java.awt.Font("SansSerif", 0, 10)); // NOI18N
        jLabel10.setText("Discount:");
        jLabel10.setMaximumSize(new java.awt.Dimension(72, 18));
        jLabel10.setMinimumSize(new java.awt.Dimension(72, 18));
        jLabel10.setPreferredSize(new java.awt.Dimension(72, 18));

        jLabel11.setFont(new java.awt.Font("SansSerif", 0, 10)); // NOI18N
        jLabel11.setText("Paid Amount:");
        jLabel11.setMaximumSize(new java.awt.Dimension(72, 18));
        jLabel11.setMinimumSize(new java.awt.Dimension(72, 18));
        jLabel11.setPreferredSize(new java.awt.Dimension(72, 18));

        jLabel12.setFont(new java.awt.Font("SansSerif", 0, 10)); // NOI18N
        jLabel12.setText("Balance Amount:");
        jLabel12.setMaximumSize(new java.awt.Dimension(72, 18));
        jLabel12.setMinimumSize(new java.awt.Dimension(72, 18));
        jLabel12.setPreferredSize(new java.awt.Dimension(72, 18));

        jLabel13.setFont(new java.awt.Font("SansSerif", 0, 10)); // NOI18N
        jLabel13.setText("Vat:");
        jLabel13.setMaximumSize(new java.awt.Dimension(72, 18));
        jLabel13.setMinimumSize(new java.awt.Dimension(72, 18));
        jLabel13.setPreferredSize(new java.awt.Dimension(72, 18));
        jLabel13.setVisible(false);

        jLabel14.setFont(new java.awt.Font("SansSerif", 0, 10)); // NOI18N
        jLabel14.setText("Tax:");
        jLabel14.setMaximumSize(new java.awt.Dimension(72, 18));
        jLabel14.setMinimumSize(new java.awt.Dimension(72, 18));
        jLabel14.setPreferredSize(new java.awt.Dimension(72, 18));
        jLabel14.setVisible(false);

        vat_txt.setFont(new java.awt.Font("SansSerif", 1, 10)); // NOI18N
        vat_txt.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        vat_txt.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        vat_txt.setVisible(false);

        tax_txt.setFont(new java.awt.Font("SansSerif", 1, 10)); // NOI18N
        tax_txt.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        tax_txt.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        tax_txt.setVisible(false);

        totalamount_txt.setFont(new java.awt.Font("SansSerif", 1, 10)); // NOI18N
        totalamount_txt.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        totalamount_txt.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        discount_txt.setFont(new java.awt.Font("SansSerif", 1, 10)); // NOI18N
        discount_txt.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        discount_txt.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        discount_txt.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                discount_txtKeyReleased(evt);
            }
        });

        paidamount_txt.setFont(new java.awt.Font("SansSerif", 1, 10)); // NOI18N
        paidamount_txt.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        paidamount_txt.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        paidamount_txt.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                paidamount_txtKeyReleased(evt);
            }
        });

        balanceamount_txt.setFont(new java.awt.Font("SansSerif", 1, 10)); // NOI18N
        balanceamount_txt.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        balanceamount_txt.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        done_sales_bt.setFont(new java.awt.Font("SansSerif", 1, 13)); // NOI18N
        done_sales_bt.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Done 16X16.png"))); // NOI18N
        done_sales_bt.setText("Done");
        done_sales_bt.setFocusable(false);
        done_sales_bt.setMargin(new java.awt.Insets(2, 16, 2, 16));
        done_sales_bt.setNextFocusableComponent(save_button);
        done_sales_bt.setOpaque(false);
        done_sales_bt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                done_sales_btActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(discount_txt, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(paidamount_txt, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(balanceamount_txt, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(totalamount_txt, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(generate_receipt_bt)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(save_button)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(reset_bt))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(tax_txt, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, Short.MAX_VALUE))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(vat_txt, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(done_sales_bt)))))
                .addContainerGap())
        );

        jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {generate_receipt_bt, reset_bt, save_button});

        jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel10, jLabel11, jLabel12, jLabel9});

        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(save_button, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(generate_receipt_bt, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(reset_bt, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(totalamount_txt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(discount_txt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(paidamount_txt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                    .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(balanceamount_txt, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)))
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                        .addComponent(vat_txt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(done_sales_bt))
                                    .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(tax_txt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))))
                .addContainerGap())
        );

        jPanel2Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {generate_receipt_bt, reset_bt, save_button});

        jPanel2Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {balanceamount_txt, discount_txt, jLabel10, jLabel11, jLabel12, jLabel13, jLabel14, jLabel9, paidamount_txt, tax_txt, totalamount_txt, vat_txt});

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jToolBar2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jScrollPane1)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jToolBar2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, 0)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void pat_search_btActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pat_search_btActionPerformed
            TPatient searchedPatient = new TPatient();      
            searchedPatient = null;     
            DisabledGlassPane glassPane = new DisabledGlassPane();
            JRootPane rootPane = SwingUtilities.getRootPane(this);
            rootPane.setGlassPane(glassPane);
            PatientLookUpDialog lookUpDialoge = new PatientLookUpDialog(MainAPP, true);
            lookUpDialoge.setResizable(false);
            lookUpDialoge.setLocationRelativeTo(null);
            glassPane.activate("");
            lookUpDialoge.setVisible(true);
            lookUpDialoge.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
            glassPane.deactivate(); 
            if(lookUpDialoge.patient!=null){
             searchedPatient = lookUpDialoge.patient;
            }else if(PatientRecordDialog.patient!= null){
             searchedPatient = PatientRecordDialog.patient;
            }
            
            if(searchedPatient!= null){
                showPatientDetails(searchedPatient);
                patient = searchedPatient;
            }
    }//GEN-LAST:event_pat_search_btActionPerformed

    private void reset_btActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_reset_btActionPerformed
        clearSalesInfo();
    }//GEN-LAST:event_reset_btActionPerformed

    private void med_add_btActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_med_add_btActionPerformed
//       Code for validate Add Medicine button
        if(patient!= null || patientType.equalsIgnoreCase("registerPatient")){
            DisabledGlassPane glassPane = new DisabledGlassPane();
            JRootPane rootPane = SwingUtilities.getRootPane(this);
            rootPane.setGlassPane(glassPane);
            InventorySearchDialog resultDialoge = new InventorySearchDialog(MainAPP, true);
            resultDialoge.setResizable(false);
            resultDialoge.setLocationRelativeTo(null);
            glassPane.activate("");
            resultDialoge.setVisible(true);
            resultDialoge.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
            glassPane.deactivate();
            selectedList = resultDialoge.getInventoryList();
         
                if(selectedList!=null){
                    showAllSelectedMed(selectedList);
                }
            }else{
                JOptionPane.showMessageDialog(null, "Select patient information");
            }     
    }//GEN-LAST:event_med_add_btActionPerformed

    private void remove_btActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_remove_btActionPerformed
      int row = product_table.getSelectedRow();
        model = (DefaultTableModel)product_table.getModel();
        if(row!=-1){
            if(model.getValueAt(row, 0)!=null){
                removeList.add((TInventoryMaster)model.getValueAt(row, 0));
                model.removeRow(row);
            }else{
                model.removeRow(row);
            }
        }else{
            JOptionPane.showMessageDialog(null, "No product record seleted for delete");
        }
    }//GEN-LAST:event_remove_btActionPerformed

    private void save_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_save_buttonActionPerformed
        try {
            
            if(validateSalesBilling()){
                /*if(patientType.equalsIgnoreCase("registerPatient")){
                    patient = savePatient();
                }*/
                if(new_patient_radiobutton.isSelected()){
                    patient = savePatient();                    
                }
                                
                TPharmacyBilling pharmacySalesBilling = saveBillingDetails();
                saveSalesProduct(pharmacySalesBilling);
                JOptionPane.showMessageDialog(null, "Saved Successfully");
                salesBillingReport = new SalesBillingReport();
                Long patientId = patient.getId();
                String patientName = patient.getPatientFName();
                Long billingId = pharmacySalesBilling.getId();
                                
                try {
                    salesBillingReport.getPdfReport(patientId,patientName,billingId);
                } catch (Exception ex) {
                    ex.printStackTrace();
                    Logger.getLogger(PatientBillingPanel.class.getName()).log(Level.SEVERE, null, ex);
                }
                salesBillingReport.openPdfReport();
                
                clearSalesInfo();
            }
        } catch (ProcessingException ex) {
            ex.printStackTrace();
                Logger.getLogger(PharmacyPurchasePanel.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_save_buttonActionPerformed

    private void generate_receipt_btActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_generate_receipt_btActionPerformed
            DisabledGlassPane glassPane = new DisabledGlassPane();
            JRootPane rootPane = SwingUtilities.getRootPane(this);
            rootPane.setGlassPane(glassPane);
            BillingDialog billingDialog = new BillingDialog(MainAPP, true,"SALE");
            billingDialog.setResizable(false);
            billingDialog.setLocationRelativeTo(null);
            glassPane.activate("");
            billingDialog.setVisible(true);
            billingDialog.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
            glassPane.deactivate();
    }//GEN-LAST:event_generate_receipt_btActionPerformed

    private void done_sales_btActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_done_sales_btActionPerformed
        if(validateDoneButton()){
            Double price = 0d;
            Double totalamt= 0d;
            for (int i = 0;i< product_table.getRowCount();i++){
                if(product_table.getValueAt(i, 9)!= null){
                    price = Double.valueOf(product_table.getValueAt(i, 9).toString()) ;
                    totalamt =totalamt+price ;
                }
            }
            totalamount_txt.setText(totalamt.toString());
            paidamount_txt.setText(totalamt.toString());
            discount_txt.setText("0.0");
            balanceamount_txt.setText("0.0");
        }
    }//GEN-LAST:event_done_sales_btActionPerformed

    private void product_tableKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_product_tableKeyReleased
            int row = product_table.getSelectedRow();
            if(product_table.getCellEditor()!=null){
                 product_table.getCellEditor().stopCellEditing();
            }
            if(product_table.getValueAt(row, 7)!=null && product_table.getValueAt(row, 8)!=null) {
                Double quantity = Double.valueOf(product_table.getValueAt(row, 8).toString());
                Double mrp = Double.valueOf(product_table.getValueAt(row, 7).toString());
                price = quantity * mrp ;
                String s = String.valueOf(price);
                product_table.setValueAt(s, row, 9);
            }
    }//GEN-LAST:event_product_tableKeyReleased

    private void discount_txtKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_discount_txtKeyReleased
        Double discount = 0d;
        Double total = 0d;
        Double paidamt =0d;
        Double balance =0d;
        if(discount_txt.getText()!=null)
        {
           total = Double.valueOf(totalamount_txt.getText());
           discount = Double.valueOf(discount_txt.getText());
           paidamt = total -discount;
           paidamount_txt.setText(paidamt.toString());
           balance = (total-discount)-paidamt ;
           balanceamount_txt.setText(balance.toString()); 
        }    
    }//GEN-LAST:event_discount_txtKeyReleased

    private void paidamount_txtKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_paidamount_txtKeyReleased
        Double balanceamt = 0d; 
        Double paid =0d;
        Double total = 0d;
        Double discount = 0d;
        if(paidamount_txt.getText()!= null)
         {
           paid = Double.valueOf(paidamount_txt.getText().toString());
           total = Double.valueOf(totalamount_txt.getText().toString());
           discount = Double.valueOf(discount_txt.getText().toString());
           balanceamt = (total-discount)- paid;
           balanceamount_txt.setText(balanceamt.toString());
         }
    }//GEN-LAST:event_paidamount_txtKeyReleased

    private void new_patient_radiobuttonItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_new_patient_radiobuttonItemStateChanged
        showPatientDetailsByPatientType();
        //clearSalesInfo();
    }//GEN-LAST:event_new_patient_radiobuttonItemStateChanged

    private void search_patient_radiobuttonItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_search_patient_radiobuttonItemStateChanged
        showPatientDetailsByPatientType();
        //clearSalesInfo();
    }//GEN-LAST:event_search_patient_radiobuttonItemStateChanged

    private void new_patient_radiobuttonPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_new_patient_radiobuttonPropertyChange
//        showPatientDetailsByPatientType();
//        clearSalesInfo();
    }//GEN-LAST:event_new_patient_radiobuttonPropertyChange

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField balanceamount_txt;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JTextField discount_txt;
    private javax.swing.JLabel doctor_name_Label;
    private javax.swing.JTextField doctor_name_textbox;
    private javax.swing.JButton done_sales_bt;
    private javax.swing.JButton generate_receipt_bt;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JToolBar jToolBar2;
    private javax.swing.JButton med_add_bt;
    private javax.swing.JRadioButton new_patient_radiobutton;
    private javax.swing.JTextField paidamount_txt;
    private javax.swing.JButton pat_search_bt;
    private javax.swing.JLabel patient_address_Label;
    private javax.swing.JTextField patient_address_textbox;
    private javax.swing.JLabel patient_contact_no_label;
    private javax.swing.JTextField patient_contact_no_textbox;
    private javax.swing.JComboBox patient_gender_combobox;
    private javax.swing.JLabel patient_gender_label;
    private javax.swing.JLabel patient_name_Label;
    private javax.swing.JLabel patient_name_Label2;
    private javax.swing.JTextField patient_name_textbox;
    private javax.swing.JTable product_table;
    private javax.swing.JButton remove_bt;
    private javax.swing.JButton reset_bt;
    private com.toedter.calendar.JDateChooser sales_dateChooser;
    private javax.swing.JButton save_button;
    private javax.swing.JRadioButton search_patient_radiobutton;
    private javax.swing.JTextField tax_txt;
    private javax.swing.JTextField totalamount_txt;
    private javax.swing.JTextField vat_txt;
    // End of variables declaration//GEN-END:variables
    private TAccount useraccount;
    SalesBillingReport salesBillingReport;
    private Preferences myPrefObj = Preferences.userRoot();
    private Double price = 0d;
    private TPatient patient;
    private TPatient pat;
    private TPatient patientData;
    private PurchaseController purchaseController ;
    private SalesBillingController salesBillingController ;
    private PharmacyPatientController patientController;
    private PharmacyCodeValuesController pharmacyCodeValuesController;
    private DefaultTableModel model;
    private Vector<Object> addObject;
    private List<TInventoryMaster> selectedList;
    private List<TMedicationMaster> medicationList = new ArrayList<TMedicationMaster>();
    private List<TInventoryMaster> removeList = new ArrayList<TInventoryMaster>();
    private List<TPharmacySales> pharmacySalesList = new ArrayList<TPharmacySales>();
    private Vector<TCCodeValues> genderList = new Vector<TCCodeValues>();
    private Frame MainAPP;
    private TPharmacySales pharmacySales;
    private String billNo;
    private String patientId;
    private String patientType = null;
    /** The sdf. */
    private SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
    
    private void populate() {
        purchaseController=(PurchaseController)PharmacyHomeFrame.context.getBean("purchaseController");
        salesBillingController=(SalesBillingController)PharmacyHomeFrame.context.getBean("salesBillingController");
        pharmacyCodeValuesController=(PharmacyCodeValuesController)PharmacyHomeFrame.context.getBean("pharmacyCodeValuesController");
        pat = new TPatient();
        
        try{
                genderList = pharmacyCodeValuesController.getCodeValues("gender");
        }catch(ProcessingException e){
             JOptionPane.showMessageDialog(null,MessageProperties.getMessage("error.fetch",new Object[]{"gender"}));
             throw new HealthCareException(MessageProperties.getMessage("error.dao"));
        }
        try{
            useraccount = (TAccount)PreferenceUtil.getObject(myPrefObj, "user");
            }catch(Exception e){
            JOptionPane.showMessageDialog(null,MessageProperties.getMessage("error.fetch",new Object[]{"visit type"}));
            }
    }
    
    public String getNewPatientId(){
        String patID = "";
        
        return patID;
    }
    
    private void clearSalesInfo() {
        patient_name_textbox.setText(null);
        patient_address_textbox.setText(null);
        patient_gender_combobox.setSelectedIndex(-1);
        patient_contact_no_textbox.setText(null);
        doctor_name_textbox.setText(null);
        sales_dateChooser.setDate(new Date());
        totalamount_txt.setText(null);
        balanceamount_txt.setText(null);
        paidamount_txt.setText(null);
        tax_txt.setText(null);
        vat_txt.setText(null);
        discount_txt.setText(null);
        DefaultTableModel tableModel =  (DefaultTableModel)product_table.getModel();
        tableModel.setRowCount(0);
        patient = new TPatient();
       
    }

    private void showPatientDetails(TPatient p) {
        patient_name_textbox.setText(p.getPatientFName().toString()+" "+p.getPatientLName().toString());
        if(p.getPresentAddress1().length()>0 && p.getPresentAddress1()!= null){
        patient_address_textbox.setText(p.getPresentAddress1());
        }else{
            patient_address_textbox.setText("");
        }
        if(p.getPatientGender() != null){
        patient_gender_combobox.setSelectedItem(p.getPatientGender());
        }else{
            patient_gender_combobox.setSelectedIndex(-1);
        }
        if(p.getPatientHtNumber() != null){
        patient_contact_no_textbox.setText(p.getPatientHtNumber().toString());
        }else{
            patient_contact_no_textbox.setText("");
        }
    }
    private void showAllSelectedMed(List<TInventoryMaster> selectedList) {
     
        model = (DefaultTableModel)product_table.getModel();
                for(TInventoryMaster store: selectedList){
                    addObject = new Vector<Object>();
                    addObject.add(store);
                    addObject.add(store.getInventoryMed().getMedicationName());
                    addObject.add(store.getInventoryMfrs());
                    addObject.add(store.getInventoryBatchNumber());
                    addObject.add(store.getInventoryUnit());
                    addObject.add(sdf.format(store.getManufactureDate()));
                    addObject.add(sdf.format(store.getInventoryExpiryDate()));
                    addObject.add(store.getMaximumRetailPrice());
                    addObject.add(null);
                    addObject.add(null);
                    model.addRow(addObject);
                 }
        
    }
    private void showProductTable() {
        product_table.setModel(new javax.swing.table.DefaultTableModel(new Object [][] {},new String [] {
                "Obj","Product Name","MFG","Batch No.","Unit","Mfg Date","Expiry Date","M.R.P","Quantity","Price"}));
        JTextField textField = new JTextField();
        textField.setEditable(false);
        textField.setBackground(new java.awt.Color(255, 255, 255));
        product_table.getColumn("Product Name").setCellEditor(new DefaultCellEditor(textField));
        product_table.getColumn("MFG").setCellEditor(new DefaultCellEditor(textField));
        product_table.getColumn("Unit").setCellEditor(new DefaultCellEditor(textField));
        product_table.getColumn("Batch No.").setCellEditor(new DefaultCellEditor(textField));
        product_table.getColumn("Expiry Date").setCellEditor(new DefaultCellEditor(textField));
        product_table.getColumn("Mfg Date").setCellEditor(new DefaultCellEditor(textField));
        product_table.getColumn("M.R.P").setCellEditor(new DefaultCellEditor(textField));
        product_table.getColumnModel().getColumn(0).setMinWidth(0);
        product_table.getColumnModel().getColumn(0).setPreferredWidth(0);
        product_table.getColumnModel().getColumn(0).setMaxWidth(0);
        product_table.getTableHeader().setFont(new Font("SansSerif", Font.BOLD, 11));
        product_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 
    }
    
    private TPharmacyBilling saveBillingDetails()throws ProcessingException{
        
        TPharmacyBilling pharmacyBilling = new TPharmacyBilling();
        
        try {
            System.out.println("####patient: "+patient.getPatientId());
                pharmacyBilling.setPatientDetail(patient);
                pharmacyBilling.setBillingNumber("S"+purchaseController.getPurchaseBillingNo("SALE"));
                pharmacyBilling.setBillingType("SALE");
                pharmacyBilling.setTotalProductPrice(Double.parseDouble(totalamount_txt.getText()));
                pharmacyBilling.setTax(0d);
                pharmacyBilling.setVat(0d);
                pharmacyBilling.setDiscountPrice(Double.parseDouble(discount_txt.getText()));
                pharmacyBilling.setTotalPriceToBePaid(Double.parseDouble(totalamount_txt.getText())-Double.parseDouble(discount_txt.getText()));
                pharmacyBilling.setPaidPrice(Double.parseDouble(paidamount_txt.getText()));
                pharmacyBilling.setBalanceAmount(Double.parseDouble(balanceamount_txt.getText()));
                pharmacyBilling.setBillingDate(sales_dateChooser.getDate());
                pharmacyBilling.setCreatedDate(new Date());
                pharmacyBilling.setCreatedBy((useraccount.getFirstName()+" "+ useraccount.getLastName()));

            return purchaseController.savePurchaseBilling(pharmacyBilling);
        }catch(HibernateOptimisticLockingFailureException e){
            e.printStackTrace();
                JOptionPane.showMessageDialog(null, MessageProperties.getMessage("error.update",new Object[]{"Billing Detail"}));
                throw e;
        }catch(ProcessingException e){
            e.printStackTrace();
                JOptionPane.showMessageDialog(null, MessageProperties.getMessage("error.save",new Object[]{"Billing Detail"}));
                throw new HealthCareException(MessageProperties.getMessage("error.dao"));
        }catch(Exception e){
            e.printStackTrace();
               JOptionPane.showMessageDialog(null, MessageProperties.getMessage("error.save",new Object[]{"Billing Detail"}));
               throw e;
        }
    }
    
    
    private TPatient savePatient(){
        
        try{
            System.out.println("1. pat.getPatientId(): "+pat.getPatientId());
            if(pat.getPatientId()== null){                
                patientId = salesBillingController.getPatientId();
                //patientId = patientController.getPatientId();
                //patientId = "S00007";
            }
            pat.setPatientId(patientId);
            System.out.println("2. pat.getPatientId(): "+pat.getPatientId());
            if(patient_name_textbox.getText().length() > 0){
            pat.setPatientFName(patient_name_textbox.getText().toUpperCase());
            }else{
                pat.setPatientFName("CASH");
            }
            pat.setPatientMName("");
            pat.setPatientLName("");
            if(patient_address_textbox.getText().length() > 0 ){
            pat.setPresentAddress1(patient_address_textbox.getText());
            }else{
                pat.setPresentAddress1("");
            }
            if(patient_gender_combobox.getSelectedIndex() != -1){
                pat.setPatientGender(patient_gender_combobox.getSelectedItem().toString());
            }else{
                pat.setPatientGender("");
            }
            if(patient_contact_no_textbox.getText().length() >0 ){
                pat.setPatientHtNumber(Long.valueOf(patient_contact_no_textbox.getText().toString()));
            }else{
                pat.setPatientHtNumber(null);
            }
            pat.setBirthDate(null);
            pat.setPatientMNumber(null);
            pat.setPatientENumber(null);
            pat.setPatientEAddress("");
            pat.setPresentAddress2("");
            pat.setPresentPatientCity("");
            pat.setPresentPatientDistrict("");
            pat.setPresentPatientState("");
            pat.setPresentPatientCountry("");
            pat.setPresentPatientPincode(null);
            if(pat.getId()==null){
                 
                    salesBillingController.savePatient(pat);
//                    JOptionPane.showMessageDialog(null, MessageProperties.getMessage("success.save",new Object[]{"Patient"}));
                     }else{
                salesBillingController.savePatient(pat);
//                JOptionPane.showMessageDialog(null, MessageProperties.getMessage("success.save",new Object[]{"Patient"}));
            }
        }catch(HibernateOptimisticLockingFailureException e){
                JOptionPane.showMessageDialog(null, MessageProperties.getMessage("error.update",new Object[]{"Patient"}));
        }catch(ConstraintViolationException e){
               try{
                    patientId = salesBillingController.getPatientId(); 
                    pat.setPatientId(patientId);
                    salesBillingController.savePatient(pat);
               }catch(Exception ex){}
        }catch(Exception e){
                JOptionPane.showMessageDialog(null, MessageProperties.getMessage("error.save",new Object[]{"Patient"}));
        }
        patientData = pat;
        return pat;
    }

    private void saveSalesProduct(TPharmacyBilling pharmacySalesBilling) {
        try{
                pharmacySalesList = new ArrayList<TPharmacySales>();
                product_table.clearSelection();
                if(product_table.getCellEditor()!=null){
                    product_table.getCellEditor().stopCellEditing();
                }

                for(int i=0;i<product_table.getRowCount();i++){
                    
                    pharmacySales = new TPharmacySales();
                    pharmacySales.setSalesInventory((TInventoryMaster)product_table.getValueAt(i,0));
                    pharmacySales.setSalesBillingNumber(pharmacySalesBilling);
                    pharmacySales.setSalesDate(sales_dateChooser.getDate());
                    pharmacySales.setSalesQuantity(String.valueOf(product_table.getValueAt(i,8)));
                    pharmacySales.setSalesAmount(Double.parseDouble(String.valueOf(product_table.getValueAt(i,9))));
                    pharmacySales.setCreatedDate(new Date());
                    pharmacySales.setCreatedBy((useraccount.getFirstName()+" "+ useraccount.getLastName()));
                    
                    pharmacySalesList.add(pharmacySales);
                }

                List<TPharmacySales> soldMedicines = salesBillingController.saveSalesDetails(pharmacySalesList);
                
                if (!soldMedicines.isEmpty()) {
                
                    for (TPharmacySales tPharmacySales : soldMedicines) {
                        
                        TInventoryMaster inventory = new TInventoryMaster();
                        inventory = tPharmacySales.getSalesInventory();
                        inventory.setInventoryQuantity(String.valueOf(Long.parseLong(inventory.getInventoryQuantity())-Long.parseLong(tPharmacySales.getSalesQuantity())));
                        salesBillingController.updateInventoryQuantity(inventory);
                    }
                    
                }

           } catch (ProcessingException ex) {
                Logger.getLogger(PharmacyPurchasePanel.class.getName()).log(Level.SEVERE, null, ex);
           }
    }
//validate sales billing
    private boolean validateSalesBilling() {                                            
         boolean valid = true;
//            if(patient == null)
//            {
//                JOptionPane.showMessageDialog(null, "Select patient information");
//                valid = false;
//            }else
                if(!(selectedList.size()>0) ){
                JOptionPane.showMessageDialog(null, "Please add medicine");
                valid = false;
            }else if(!validateProductTable() ){
                valid = false;
            }else if(totalamount_txt.getText().length()<1){
                JOptionPane.showMessageDialog(null, "Enter total amount");
                totalamount_txt.requestFocus();
                totalamount_txt.selectAll();
                valid = false;
            }else if(!(totalamount_txt.getText().length()<1) && !(totalamount_txt.getText().matches("^\\d*[\\.]?\\d*$") )){
                JOptionPane.showMessageDialog(null, "Invalid total amount");
                totalamount_txt.requestFocus();
                totalamount_txt.selectAll();
                valid = false;
            }else if(discount_txt.getText().length()<1){
                JOptionPane.showMessageDialog(null, "Enter discount amount");
                discount_txt.requestFocus();
                discount_txt.selectAll();
                valid = false;
            }else if(!(discount_txt.getText().length()<1) && !(discount_txt.getText().matches("^\\d*[\\.]?\\d*$") )){
                JOptionPane.showMessageDialog(null, "Invalid discount amount");
                discount_txt.requestFocus();
                discount_txt.selectAll();
                valid = false;
            }else if(paidamount_txt.getText().length()<1){
                JOptionPane.showMessageDialog(null, "Enter paid amount");
                paidamount_txt.requestFocus();
                paidamount_txt.selectAll();
                valid = false;
            }else if(!(paidamount_txt.getText().length()<1) && !(paidamount_txt.getText().matches("^\\d*[\\.]?\\d*$") )){
                JOptionPane.showMessageDialog(null, "Invalid paid amount");
                paidamount_txt.requestFocus();
                paidamount_txt.selectAll();
                valid = false;
            }else if(balanceamount_txt.getText().length()<1){
                JOptionPane.showMessageDialog(null, "Enter balance amount");
                balanceamount_txt.requestFocus();
                balanceamount_txt.selectAll();
                valid = false;
            }else if(!(balanceamount_txt.getText().length()<1) && !(balanceamount_txt.getText().matches("^\\d*[\\.]?\\d*$") )){
                JOptionPane.showMessageDialog(null, "Invalid balance amount");
                balanceamount_txt.requestFocus();
                balanceamount_txt.selectAll();
                valid = false;
            }
        return valid;
    }
    private boolean validateProductTable() {
        boolean validate = true;
        for(int i=0;i<product_table.getRowCount();i++){
                    TInventoryMaster inventoryobj = (TInventoryMaster)product_table.getValueAt(i,0); 
                    String inventoryquan = inventoryobj.getInventoryQuantity();
              if(product_table.getValueAt(i,8)==null ){
                  JOptionPane.showMessageDialog(null, "Enter quantity");
                  validate = false;
                }else if(!(product_table.getValueAt(i,8)==null ) && !(String.valueOf(product_table.getValueAt(i,8)).matches("^[0-9]*$") )){
                    JOptionPane.showMessageDialog(null, "Invalid quantity");
                    validate = false;
                }else if(product_table.getValueAt(i,9)==null ) {
                    JOptionPane.showMessageDialog(null, "Enter price");
                    validate = false;
                }else if(!(product_table.getValueAt(i,9)==null ) && !(String.valueOf(product_table.getValueAt(i,9)).matches("^\\d*[\\.]?\\d*$") )){
                    JOptionPane.showMessageDialog(null, "Invalid price");
                    validate = false;
                }else if(Integer.parseInt(inventoryquan)<Integer.parseInt(product_table.getValueAt(i,8).toString())){
                    JOptionPane.showMessageDialog(null, "Sorry,Entered quantity is not available."); 
                    validate = false;
                }
          }     
        return validate;
    } 
    private boolean validateDoneButton() {                                            
         boolean valid = true;
//            if(patient == null)
//            {
//                JOptionPane.showMessageDialog(null, "Select patient information");
//                valid = false;
//            }else
                if(!(selectedList.size()>0) ){
                JOptionPane.showMessageDialog(null, "Please add medicine");
                valid = false;
            }else if(!validateProductTable() ){
                valid = false;
            }
        return valid;
    }
    private void showPatientDetailsByPatientType(){
        if(new_patient_radiobutton.isSelected()){
            clearSalesInfo();
            patientType = "registerPatient";
            patient_name_Label.setVisible(true);
            pat_search_bt.setVisible(false);
            patient_address_Label.setVisible(true);
            patient_gender_label.setVisible(true);
            patient_contact_no_label.setVisible(true);
            patient_name_textbox.setVisible(true);
            patient_address_textbox.setVisible(true);
            patient_gender_combobox.setVisible(true);
            patient_contact_no_textbox.setVisible(true);  
            patient_name_textbox.setEditable(true);
            patient_address_textbox.setEditable(true);
//            patient_gender_combobox.setEditable(true);
            patient_gender_combobox.setEnabled(true);
            patient_contact_no_textbox.setEditable(true);
//            patient_contact_no_textbox.setEnabled(true);
            doctor_name_textbox.setEditable(true);
                    
        }else if(search_patient_radiobutton.isSelected()){
            clearSalesInfo();
            patientType = "searchPatient";
            patient_name_Label.setVisible(true);
            pat_search_bt.setVisible(true);
            patient_address_Label.setVisible(true);
            patient_gender_label.setVisible(true);
            patient_contact_no_label.setVisible(true);
            patient_name_textbox.setVisible(true);
            patient_address_textbox.setVisible(true);
            patient_gender_combobox.setVisible(true);
            patient_contact_no_textbox.setVisible(true);  
            patient_name_textbox.setEditable(false);
            patient_address_textbox.setEditable(false);
//            patient_gender_combobox.setEditable(false);
            patient_gender_combobox.setEnabled(false);
            patient_contact_no_textbox.setEditable(false);
//            patient_contact_no_textbox.setEnabled(false);
            doctor_name_textbox.setEditable(false);
                    
        }
    }
}

Commits for Pharmacy_09_03_18/Dr Gyana ProjectSpace/DrGyanaPharmacy/src/main/java/com/bestray/healthcarepharmacy/view/PatientBillingPanel.java

Diff revisions: vs.
Revision Author Commited Message
1 girijabapi picture girijabapi Fri 27 Jul, 2018 07:30:57 +0000