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
/*
 * 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.SimpleGradientPanel;
import com.bestray.healthcarecommonutil.util.StandardButton;
import com.bestray.healthcarecommonutil.vo.TPharmacyBilling;
import com.bestray.healthcarecommonutil.vo.TStockiestDetailMaster;
import com.bestray.healthcarepharmacy.controller.PharmacyReportController;
import com.bestray.healthcarepharmacy.util.MessageProperties;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Vector;
import javax.swing.JOptionPane;
import javax.swing.ListSelectionModel;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;

/**
 *
 * @author User1
 */
public class PharmacyTransactionReportPanel extends SimpleGradientPanel {

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

        buttonGroup1 = new javax.swing.ButtonGroup();
        jPanel1 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        detail_Datelb = new javax.swing.JLabel();
        datechooser = new com.toedter.calendar.JDateChooser();
        detail_monthlb = new javax.swing.JLabel();
        detail_monthchooser = new com.toedter.calendar.JMonthChooser();
        detail_month_year_chosser = new com.toedter.calendar.JYearChooser();
        detail_yearchooser = new com.toedter.calendar.JYearChooser();
        detail_yearlb = new javax.swing.JLabel();
        view_bt = new StandardButton("Receipt");
        jToolBar2 = new javax.swing.JToolBar();
        jLabel1 = new javax.swing.JLabel();
        dailyReport_button = new javax.swing.JToggleButton();
        monthlyReport_button = new javax.swing.JToggleButton();
        yearlyReport_button = new javax.swing.JToggleButton();
        jXTitledPanel1 = new org.jdesktop.swingx.JXTitledPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        stockist_transaction_table = new javax.swing.JTable(){

            public boolean isCellEditable(int row, int column){
                return false;
            }
            public Component prepareRenderer(TableCellRenderer renderer, int rowIndex, int vColIndex) {
                Component c = super.prepareRenderer(renderer, rowIndex, vColIndex);
                if (rowIndex % 2 == 0 && !isCellSelected(rowIndex, vColIndex)) {
                    c.setForeground(Color.BLACK);
                    c.setBackground(new Color(200, 225, 250));
                }
                else if(rowIndex % 2 == 0 && isCellSelected(rowIndex, vColIndex)){
                    c.setForeground(Color.WHITE);
                    c.setBackground(Color.BLUE);
                }
                else if(rowIndex % 2 != 0 && isCellSelected(rowIndex, vColIndex)){
                    c.setForeground(Color.WHITE);
                    c.setBackground(Color.BLUE);
                }
                else {
                    c.setForeground(Color.BLACK);
                    c.setBackground(getBackground());
                }
                return c;
            }

        };
        jXTitledPanel2 = new org.jdesktop.swingx.JXTitledPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        Sales_transaction_table = new javax.swing.JTable(){

            public boolean isCellEditable(int row, int column){
                return false;
            }
            public Component prepareRenderer(TableCellRenderer renderer, int rowIndex, int vColIndex) {
                Component c = super.prepareRenderer(renderer, rowIndex, vColIndex);
                if (rowIndex % 2 == 0 && !isCellSelected(rowIndex, vColIndex)) {
                    c.setForeground(Color.BLACK);
                    c.setBackground(new Color(200, 225, 250));
                }
                else if(rowIndex % 2 == 0 && isCellSelected(rowIndex, vColIndex)){
                    c.setForeground(Color.WHITE);
                    c.setBackground(Color.BLUE);
                }
                else if(rowIndex % 2 != 0 && isCellSelected(rowIndex, vColIndex)){
                    c.setForeground(Color.WHITE);
                    c.setBackground(Color.BLUE);
                }
                else {
                    c.setForeground(Color.BLACK);
                    c.setBackground(getBackground());
                }
                return c;
            }

        };
        jLabel3 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        balance_purchase_amount_textbox = new javax.swing.JTextField();
        paid_purchase_amount_textbox = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        paid_sales_amount_textbox = new javax.swing.JTextField();
        balance_sales_amount_textbox = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();

        setOpaque(false);

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

        jLabel4.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N
        jLabel4.setForeground(new java.awt.Color(102, 102, 102));
        jLabel4.setText("Parameters :");

        detail_Datelb.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        detail_Datelb.setText("Date :");
        detail_Datelb.setVisible(false);

        datechooser.setDate(new Date());
        datechooser.setFont(new java.awt.Font("SansSerif", 1, 11)); // NOI18N
        datechooser.setOpaque(false);
        datechooser.setVisible(false);

        detail_monthlb.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        detail_monthlb.setText("Month :");
        detail_monthlb.setVisible(false);

        detail_monthchooser.setFont(new java.awt.Font("SansSerif", 1, 11)); // NOI18N
        detail_monthchooser.setOpaque(false);
        detail_monthchooser.setVisible(false);

        detail_month_year_chosser.setVisible(false);
        detail_month_year_chosser.setOpaque(false);

        detail_yearchooser.setOpaque(false);
        detail_yearchooser.setVisible(false);

        detail_yearlb.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        detail_yearlb.setText("Year :");
        detail_yearlb.setVisible(false);

        view_bt.setFont(new java.awt.Font("SansSerif", 1, 10)); // NOI18N
        view_bt.setText("View");
        view_bt.setOpaque(false);
        view_bt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                view_btActionPerformed(evt);
            }
        });
        view_bt.setVisible(false);

        jToolBar2.setBackground(new java.awt.Color(255, 255, 255));
        jToolBar2.setFloatable(false);
        jToolBar2.setRollover(true);
        jToolBar2.setOpaque(false);

        jLabel1.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        jLabel1.setText("                             Report Name :   ");
        jToolBar2.add(jLabel1);

        dailyReport_button.setBackground(new java.awt.Color(255, 255, 255));
        buttonGroup1.add(dailyReport_button);
        dailyReport_button.setFont(new java.awt.Font("SansSerif", 1, 10)); // NOI18N
        dailyReport_button.setText("Daily Report");
        dailyReport_button.setFocusable(false);
        dailyReport_button.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        dailyReport_button.setMargin(new java.awt.Insets(2, 20, 2, 20));
        dailyReport_button.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        dailyReport_button.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                dailyReport_buttonItemStateChanged(evt);
            }
        });
        dailyReport_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                dailyReport_buttonActionPerformed(evt);
            }
        });
        jToolBar2.add(dailyReport_button);

        monthlyReport_button.setBackground(new java.awt.Color(255, 255, 255));
        buttonGroup1.add(monthlyReport_button);
        monthlyReport_button.setFont(new java.awt.Font("SansSerif", 1, 10)); // NOI18N
        monthlyReport_button.setText("Monthly Report");
        monthlyReport_button.setFocusable(false);
        monthlyReport_button.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        monthlyReport_button.setMargin(new java.awt.Insets(2, 20, 2, 20));
        monthlyReport_button.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        monthlyReport_button.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                monthlyReport_buttonItemStateChanged(evt);
            }
        });
        monthlyReport_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                monthlyReport_buttonActionPerformed(evt);
            }
        });
        jToolBar2.add(monthlyReport_button);

        yearlyReport_button.setBackground(new java.awt.Color(255, 255, 255));
        buttonGroup1.add(yearlyReport_button);
        yearlyReport_button.setFont(new java.awt.Font("SansSerif", 1, 10)); // NOI18N
        yearlyReport_button.setText("Yearly Report");
        yearlyReport_button.setFocusable(false);
        yearlyReport_button.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        yearlyReport_button.setMargin(new java.awt.Insets(2, 20, 2, 20));
        yearlyReport_button.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        yearlyReport_button.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                yearlyReport_buttonItemStateChanged(evt);
            }
        });
        yearlyReport_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                yearlyReport_buttonActionPerformed(evt);
            }
        });
        jToolBar2.add(yearlyReport_button);

        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()
                .addComponent(jLabel4)
                .addGap(18, 18, 18)
                .addComponent(detail_Datelb)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(datechooser, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(detail_monthlb)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(detail_monthchooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(detail_month_year_chosser, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(detail_yearlb)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(detail_yearchooser, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(view_bt)
                .addContainerGap())
            .addComponent(jToolBar2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(0, 0, 0)
                .addComponent(jToolBar2, 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, false)
                    .addComponent(datechooser, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(detail_monthchooser, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(detail_month_year_chosser, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(detail_yearlb, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(detail_monthlb, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(detail_yearchooser, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(detail_Datelb, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(view_bt, javax.swing.GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE))
                .addGap(5, 5, 5))
        );

        jXTitledPanel1.setTitle("Purchase Details");
        jXTitledPanel1.setTitleFont(new java.awt.Font("SansSerif", 1, 10)); // NOI18N

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

            },
            new String [] {
                "Billing Number", "Total product PTR", "Paid Price", "Balance Amount"
            }
        ));
        stockist_transaction_table.setOpaque(false);
        stockist_transaction_table.setRowHeight(25);
        stockist_transaction_table.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane1.setViewportView(stockist_transaction_table);

        javax.swing.GroupLayout jXTitledPanel1Layout = new javax.swing.GroupLayout(jXTitledPanel1.getContentContainer());
        jXTitledPanel1.getContentContainer().setLayout(jXTitledPanel1Layout);
        jXTitledPanel1Layout.setHorizontalGroup(
            jXTitledPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1)
        );
        jXTitledPanel1Layout.setVerticalGroup(
            jXTitledPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 296, Short.MAX_VALUE)
        );

        jXTitledPanel2.setTitle("Sales Details");
        jXTitledPanel2.setTitleFont(new java.awt.Font("SansSerif", 1, 10)); // NOI18N

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

            },
            new String [] {
                "Billing Number", "Total product MRP", "Paid Price", "Balance Amount"
            }
        ));
        Sales_transaction_table.setOpaque(false);
        Sales_transaction_table.setRowHeight(25);
        Sales_transaction_table.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane2.setViewportView(Sales_transaction_table);

        javax.swing.GroupLayout jXTitledPanel2Layout = new javax.swing.GroupLayout(jXTitledPanel2.getContentContainer());
        jXTitledPanel2.getContentContainer().setLayout(jXTitledPanel2Layout);
        jXTitledPanel2Layout.setHorizontalGroup(
            jXTitledPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 515, Short.MAX_VALUE)
        );
        jXTitledPanel2Layout.setVerticalGroup(
            jXTitledPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
        );

        jLabel3.setFont(new java.awt.Font("SansSerif", 1, 14)); // NOI18N
        jLabel3.setText("Total Paid Amount (Rs.): ");

        jLabel8.setFont(new java.awt.Font("SansSerif", 1, 14)); // NOI18N
        jLabel8.setText("Total Balance Amount (Rs.): ");

        balance_purchase_amount_textbox.setEditable(false);
        balance_purchase_amount_textbox.setOpaque(false);
        balance_purchase_amount_textbox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                balance_purchase_amount_textboxActionPerformed(evt);
            }
        });

        paid_purchase_amount_textbox.setEditable(false);
        paid_purchase_amount_textbox.setOpaque(false);

        jLabel5.setFont(new java.awt.Font("SansSerif", 1, 14)); // NOI18N
        jLabel5.setText("Total Paid Amount (Rs.): ");

        paid_sales_amount_textbox.setEditable(false);
        paid_sales_amount_textbox.setOpaque(false);

        balance_sales_amount_textbox.setEditable(false);
        balance_sales_amount_textbox.setOpaque(false);
        balance_sales_amount_textbox.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                balance_sales_amount_textboxActionPerformed(evt);
            }
        });

        jLabel9.setFont(new java.awt.Font("SansSerif", 1, 14)); // NOI18N
        jLabel9.setText("Total Balance Amount (Rs.): ");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jXTitledPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGap(41, 41, 41))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel3)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(paid_purchase_amount_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                    .addComponent(jLabel8)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(balance_purchase_amount_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(281, 281, 281)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(paid_sales_amount_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                    .addComponent(jLabel9)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addComponent(balance_sales_amount_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(jXTitledPanel2, 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()
                .addGap(0, 0, 0)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jXTitledPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jXTitledPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(paid_purchase_amount_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(balance_purchase_amount_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(paid_sales_amount_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(balance_sales_amount_textbox, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void dailyReport_buttonItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_dailyReport_buttonItemStateChanged
        
    }//GEN-LAST:event_dailyReport_buttonItemStateChanged

    private void dailyReport_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dailyReport_buttonActionPerformed
        detail_Datelb.setVisible(true);
        datechooser.setVisible(true);
        detail_monthlb.setVisible(false);
        detail_monthchooser.setVisible(false);
        detail_yearlb.setVisible(false);
        detail_yearchooser.setVisible(false);
        detail_month_year_chosser.setVisible(false);
        jPanel1.setVisible(true);
        dailyReport_button.setEnabled(false);
        monthlyReport_button.setEnabled(true);
        yearlyReport_button.setEnabled(true);
        view_bt.setVisible(true);
    }//GEN-LAST:event_dailyReport_buttonActionPerformed

    private void monthlyReport_buttonItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_monthlyReport_buttonItemStateChanged
        
    }//GEN-LAST:event_monthlyReport_buttonItemStateChanged

    private void monthlyReport_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_monthlyReport_buttonActionPerformed

        detail_monthlb.setVisible(true);
        detail_monthchooser.setVisible(true);
        detail_month_year_chosser.setVisible(true);
        detail_Datelb.setVisible(false);
        datechooser.setVisible(false);
        detail_yearlb.setVisible(false);
        detail_yearchooser.setVisible(false);
        jPanel1.setVisible(true);
        dailyReport_button.setEnabled(true);
        monthlyReport_button.setEnabled(false);
        yearlyReport_button.setEnabled(true);
        view_bt.setVisible(true);
    }//GEN-LAST:event_monthlyReport_buttonActionPerformed

    private void yearlyReport_buttonItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_yearlyReport_buttonItemStateChanged
        
    }//GEN-LAST:event_yearlyReport_buttonItemStateChanged

    private void yearlyReport_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_yearlyReport_buttonActionPerformed

        
        detail_yearlb.setVisible(true);
        detail_yearchooser.setVisible(true);
        detail_Datelb.setVisible(false);
        datechooser.setVisible(false);
        detail_monthlb.setVisible(false);
        detail_monthchooser.setVisible(false);
        detail_month_year_chosser.setVisible(false);
        jPanel1.setVisible(true);
        dailyReport_button.setEnabled(true);
        monthlyReport_button.setEnabled(true);
        yearlyReport_button.setEnabled(false);
        view_bt.setVisible(true);
    }//GEN-LAST:event_yearlyReport_buttonActionPerformed

    private void view_btActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_view_btActionPerformed
            
        showPurchaseTrancsactions();
        showSalesTrancsactions();
        
    }//GEN-LAST:event_view_btActionPerformed

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

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

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTable Sales_transaction_table;
    private javax.swing.JTextField balance_purchase_amount_textbox;
    private javax.swing.JTextField balance_sales_amount_textbox;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JToggleButton dailyReport_button;
    private com.toedter.calendar.JDateChooser datechooser;
    private javax.swing.JLabel detail_Datelb;
    private com.toedter.calendar.JYearChooser detail_month_year_chosser;
    private com.toedter.calendar.JMonthChooser detail_monthchooser;
    private javax.swing.JLabel detail_monthlb;
    private com.toedter.calendar.JYearChooser detail_yearchooser;
    private javax.swing.JLabel detail_yearlb;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JToolBar jToolBar2;
    private org.jdesktop.swingx.JXTitledPanel jXTitledPanel1;
    private org.jdesktop.swingx.JXTitledPanel jXTitledPanel2;
    private javax.swing.JToggleButton monthlyReport_button;
    private javax.swing.JTextField paid_purchase_amount_textbox;
    private javax.swing.JTextField paid_sales_amount_textbox;
    private javax.swing.JTable stockist_transaction_table;
    private javax.swing.JButton view_bt;
    private javax.swing.JToggleButton yearlyReport_button;
    // End of variables declaration//GEN-END:variables
    private Vector<Object> addObject;
    private TStockiestDetailMaster selectedStockiest;
    private DefaultTableModel model;
    private SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
    private PharmacyReportController pharmacyReportController;
    
    private void populateData() {        
        pharmacyReportController = (PharmacyReportController)PharmacyHomeFrame.context.getBean("pharmacyReportController");        
    }
    
    private void showPurchaseTrancsactions() {
        defaultStockiestTransactionTable();
        Double paidAmount = 0d;
        Double balanceAmount = 0d;
        List<TPharmacyBilling> availablePurchaseTransactions = new ArrayList<TPharmacyBilling>();
        
        try{
            if(!dailyReport_button.isEnabled()){
                Date date=datechooser.getDate();
                availablePurchaseTransactions = pharmacyReportController.getavailablePurchaseTransactionsByDate(date);
         }else if(!monthlyReport_button.isEnabled()){
                    String month=getMonthFullName(detail_monthchooser.getMonth());
                    int year = detail_month_year_chosser.getYear();
                    availablePurchaseTransactions = pharmacyReportController.getavailablePurchaseTransactionsByMonth(month,year);
         }else if(!yearlyReport_button.isEnabled()){
                    int year = detail_yearchooser.getYear();
                    availablePurchaseTransactions = pharmacyReportController.getavailablePurchaseTransactionsByYear(year);
         }
           
        }catch(ProcessingException e){
            e.printStackTrace();
             JOptionPane.showMessageDialog(null,MessageProperties.getMessage("error.fetch",new Object[]{"Billing details"}));
             throw new HealthCareException(MessageProperties.getMessage("error.dao"));
        }
        if(availablePurchaseTransactions.size()==0){
            JOptionPane.showMessageDialog(null,"No Purchase Data present");
        }
        model = (DefaultTableModel)stockist_transaction_table.getModel();
                for(TPharmacyBilling billing: availablePurchaseTransactions){
                    addObject = new Vector<Object>();
                    addObject.add(billing);
//                    addObject.add(sdf.format(billing.getBillingDate()));
                    addObject.add(billing.getBillingNumber());
//                    addObject.add(billing.getTotalProductPrice());
                    addObject.add(billing.getTotalPriceToBePaid());
                    addObject.add(billing.getPaidPrice());
                    addObject.add(billing.getBalanceAmount());
                    model.addRow(addObject);
                 }
                for(int row=0;row<stockist_transaction_table.getRowCount();row++){
                                if(!stockist_transaction_table.getValueAt(row, 3).toString().equalsIgnoreCase("")){
                                    paidAmount+=Double.parseDouble(stockist_transaction_table.getValueAt(row, 3).toString());
                                }
                                if(!stockist_transaction_table.getValueAt(row, 4).toString().equalsIgnoreCase("")){
                                    balanceAmount+=Double.parseDouble(stockist_transaction_table.getValueAt(row, 4).toString());
                                }
                            }
                paid_purchase_amount_textbox.setText(String.valueOf(paidAmount));
                balance_purchase_amount_textbox.setText(String.valueOf(balanceAmount));
    }
    private void defaultStockiestTransactionTable(){
        stockist_transaction_table.setModel(new javax.swing.table.DefaultTableModel(new Object [][] {},new String [] {
                "Obj",  "Billing Number",  "Total Product PTR", "Paid Price", "Balance Amount"}));
        stockist_transaction_table.getColumnModel().getColumn(0).setMinWidth(0);
        stockist_transaction_table.getColumnModel().getColumn(0).setPreferredWidth(0);
        stockist_transaction_table.getColumnModel().getColumn(0).setMaxWidth(0);
        stockist_transaction_table.getTableHeader().setFont(new Font("SansSerif", Font.BOLD, 11));
        stockist_transaction_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 
        
    }
    
    private void showSalesTrancsactions() {
        defaultSalesTransactionTable();
        Double paidAmount = 0d;
        Double balanceAmount = 0d;
        List<TPharmacyBilling> availableSalesTransactions = new ArrayList<TPharmacyBilling>();
        try{
            if(!dailyReport_button.isEnabled()){
                Date date=datechooser.getDate();
                availableSalesTransactions = pharmacyReportController.getavailableSalesTransactionsByDate(date);
         }else if(!monthlyReport_button.isEnabled()){
                    String month=getMonthFullName(detail_monthchooser.getMonth());
                    int year = detail_month_year_chosser.getYear();
                    availableSalesTransactions = pharmacyReportController.getavailableSalesTransactionsByMonth(month,year);
         }else if(!yearlyReport_button.isEnabled()){
                    int year = detail_yearchooser.getYear();
                    availableSalesTransactions = pharmacyReportController.getavailableSalesTransactionsByYear(year);
         }
           
        }catch(ProcessingException e){
            e.printStackTrace();
             JOptionPane.showMessageDialog(null,MessageProperties.getMessage("error.fetch",new Object[]{"Billing details"}));
             throw new HealthCareException(MessageProperties.getMessage("error.dao"));
        }
    if(availableSalesTransactions.size()==0){
            JOptionPane.showMessageDialog(null,"No Sales Data present");
        }
        model = (DefaultTableModel)Sales_transaction_table.getModel();
                for(TPharmacyBilling billing: availableSalesTransactions){
                    addObject = new Vector<Object>();
                    addObject.add(billing);
//                    addObject.add(sdf.format(billing.getBillingDate()));
                    addObject.add(billing.getBillingNumber());
//                    addObject.add(billing.getTotalProductPrice());
                    addObject.add(billing.getTotalPriceToBePaid());
                    addObject.add(billing.getPaidPrice());
                    addObject.add(billing.getBalanceAmount());
                    model.addRow(addObject);
                 }
                for(int row=0;row<Sales_transaction_table.getRowCount();row++){
                                if(!Sales_transaction_table.getValueAt(row, 3).toString().equalsIgnoreCase("")){
                                    paidAmount+=Double.parseDouble(Sales_transaction_table.getValueAt(row, 3).toString());
                                }
                                if(!Sales_transaction_table.getValueAt(row, 4).toString().equalsIgnoreCase("")){
                                    balanceAmount+=Double.parseDouble(Sales_transaction_table.getValueAt(row, 4).toString());
                                }
                            }
                paid_sales_amount_textbox.setText(String.valueOf(paidAmount));
                balance_sales_amount_textbox.setText(String.valueOf(balanceAmount));
    }


    private void defaultSalesTransactionTable(){
        Sales_transaction_table.setModel(new javax.swing.table.DefaultTableModel(new Object [][] {},new String [] {
                "Obj",  "Billing Number",  "Total Product MRP", "Paid Price", "Balance Amount"}));
        Sales_transaction_table.getColumnModel().getColumn(0).setMinWidth(0);
        Sales_transaction_table.getColumnModel().getColumn(0).setPreferredWidth(0);
        Sales_transaction_table.getColumnModel().getColumn(0).setMaxWidth(0);
        Sales_transaction_table.getTableHeader().setFont(new Font("SansSerif", Font.BOLD, 11));
        Sales_transaction_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 
    }
    
    private String getMonthFullName(int monthNumber)
        {
        String monthName="";
        if(monthNumber>=0 && monthNumber<12)
        try
        {
        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.MONTH, monthNumber);
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MMMM");
        simpleDateFormat.setCalendar(calendar);
        monthName = simpleDateFormat.format(calendar.getTime());
        } catch (Exception e)
        {
        }

        return monthName;
       }

}

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

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