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

import com.bestray.healthcarecommonutil.exception.ProcessingException;
import com.bestray.healthcarecommonutil.util.DisabledGlassPane;
import com.bestray.healthcarecommonutil.util.SimpleGradientPanel;
import com.bestray.healthcarecommonutil.vo.TInventoryMaster;
import com.bestray.healthcarecommonutil.vo.TMedicationMaster;
import com.bestray.healthcarecommonutil.vo.TPharmacyPurchase;
import com.bestray.healthcarecommonutil.vo.TPharmacySales;
import com.bestray.healthcarepharmacy.controller.InventorySearchController;
import com.bestray.healthcarepharmacy.controller.PharmacyReportController;
import com.bestray.healthcarepharmacy.controller.PurchaseController;
import com.bestray.healthcarepharmacy.controller.SalesBillingController;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
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 javax.swing.JOptionPane;
import javax.swing.JRootPane;
import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;

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

    /**
     * Creates new form InventoryBalanceReportPanel
     */
    public InventoryBalanceReportPanel() {
        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();
        buttonGroup2 = new javax.swing.ButtonGroup();
        searchBy_panel = new javax.swing.JPanel();
        search_parameter_lable = new javax.swing.JLabel();
        search_parameter_textfield = new javax.swing.JTextField();
        search_Medicine_button = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        from_datechooser = new com.toedter.calendar.JDateChooser();
        jLabel7 = new javax.swing.JLabel();
        to_datechooser = new com.toedter.calendar.JDateChooser();
        view_result_bt = new javax.swing.JButton();
        jXTitledPanel1 = new org.jdesktop.swingx.JXTitledPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        inventory_balance_report_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;
            }

        };

        searchBy_panel.setOpaque(false);

        search_parameter_lable.setFont(new java.awt.Font("SansSerif", 1, 13)); // NOI18N
        search_parameter_lable.setText("Manufacturer Name :");
        search_parameter_lable.setVisible(false);

        search_parameter_textfield.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N
        search_parameter_textfield.setVisible(false);

        search_Medicine_button.setFont(new java.awt.Font("Tahoma", 1, 10)); // NOI18N
        search_Medicine_button.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/search-icon16X16.png"))); // NOI18N
        search_Medicine_button.setContentAreaFilled(false);
        search_Medicine_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                search_Medicine_buttonActionPerformed(evt);
            }
        });
        search_Medicine_button.setVisible(false);

        jLabel6.setFont(new java.awt.Font("SansSerif", 1, 13)); // NOI18N
        jLabel6.setForeground(new java.awt.Color(102, 102, 102));
        jLabel6.setText("From Date :");

        from_datechooser.setDate(new Date());
        from_datechooser.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        from_datechooser.setOpaque(false);

        jLabel7.setFont(new java.awt.Font("SansSerif", 1, 13)); // NOI18N
        jLabel7.setForeground(new java.awt.Color(102, 102, 102));
        jLabel7.setText("To Date :");

        to_datechooser.setDate(new Date());
        to_datechooser.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        to_datechooser.setOpaque(false);

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

        javax.swing.GroupLayout searchBy_panelLayout = new javax.swing.GroupLayout(searchBy_panel);
        searchBy_panel.setLayout(searchBy_panelLayout);
        searchBy_panelLayout.setHorizontalGroup(
            searchBy_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(searchBy_panelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(from_datechooser, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(to_datechooser, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(search_parameter_lable)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(search_parameter_textfield, javax.swing.GroupLayout.PREFERRED_SIZE, 260, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, 0)
                .addComponent(search_Medicine_button, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 239, Short.MAX_VALUE)
                .addComponent(view_result_bt)
                .addContainerGap())
        );
        searchBy_panelLayout.setVerticalGroup(
            searchBy_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(searchBy_panelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(searchBy_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(searchBy_panelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(search_parameter_lable)
                        .addComponent(search_parameter_textfield, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(search_Medicine_button))
                    .addComponent(from_datechooser, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(to_datechooser, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(view_result_bt))
                .addContainerGap())
        );

        searchBy_panelLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {from_datechooser, jLabel6, jLabel7, search_Medicine_button, search_parameter_lable, search_parameter_textfield, to_datechooser});

        jXTitledPanel1.setTitle("Inventory Balance Report");
        jXTitledPanel1.setTitleFont(new java.awt.Font("SansSerif", 1, 10)); // NOI18N

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

            },
            new String [] {
                "Sl No.", "Medication Name", "Opening stock", "Purchase Quantity", "Free", "sales Quantity", "Closing Stock"
            }
        ));
        inventory_balance_report_table.setRowHeight(20);
        inventory_balance_report_table.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane1.setViewportView(inventory_balance_report_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, javax.swing.GroupLayout.DEFAULT_SIZE, 1209, Short.MAX_VALUE)
        );
        jXTitledPanel1Layout.setVerticalGroup(
            jXTitledPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 291, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(searchBy_panel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jXTitledPanel1, 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()
                .addComponent(searchBy_panel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 74, Short.MAX_VALUE)
                .addComponent(jXTitledPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(21, 21, 21))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void search_Medicine_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_search_Medicine_buttonActionPerformed
        DisabledGlassPane glassPane = new DisabledGlassPane();
            JRootPane rootPane = SwingUtilities.getRootPane(this);
            rootPane.setGlassPane(glassPane);
            InventorySearchDialog resultDialoge = new InventorySearchDialog(MainAPP, true, "REPORT");
            resultDialoge.setResizable(false);
            resultDialoge.setLocationRelativeTo(null);
            glassPane.activate("");
            resultDialoge.setVisible(true);
            resultDialoge.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
            glassPane.deactivate();
            inventoryMaster = resultDialoge.getInventoryDetails();
            if (inventoryMaster!=null) {
                medicationMaster = inventoryMaster.getInventoryMed();
                search_parameter_textfield.setText(inventoryMaster.getInventoryMedicineName());
            }
    }//GEN-LAST:event_search_Medicine_buttonActionPerformed

    private void view_result_btActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_view_result_btActionPerformed
        Date fromDate = null;
        Date toDate = null;
        if(from_datechooser.getDate() != null){
        fromDate = from_datechooser.getDate();
        }if(to_datechooser.getDate() != null){
        toDate = to_datechooser.getDate();
        }
        List<TPharmacyPurchase> purchaseDetailBeforeGivenDate;
        List<TPharmacyPurchase> purchaseDetailBetweenTwoDate;
        List<TPharmacySales> salesDetailBeforeGivenDate;
        List<TPharmacySales> salesDetailBetweenTwoDate;
        List<String> obj = new ArrayList<String>();
        List<String> inventoryDetailBalance = new ArrayList<String>();
        int slNo = 0;
        if(fromDate != null && toDate !=null){
            try {
                defaultInventoryBalanceTable();
                List<TInventoryMaster> availableInventory = inventorySearchController.getAvailableInventory();
                if(availableInventory.size()>0){
                for(TInventoryMaster inventory : availableInventory){
                    
                    int purchaseOpeningQuantity = 0;
                    int purchaseQuantity = 0;
                    int purchaseFreeQuantity = 0;
                    int salesOpeningQuantity = 0;
                    int salesQuantity = 0;
                    int openingBalance = 0;
                    int closingBalance = 0;
                    
                     purchaseDetailBeforeGivenDate = purchaseController.getPurchaseDetailBeforeGivenDate(inventory.getInventoryMed(),fromDate);
                     purchaseDetailBetweenTwoDate = purchaseController.getPurchaseDetailBetweenTwoDate(inventory.getInventoryMed(),fromDate,toDate);
                     salesDetailBeforeGivenDate = salesBillingController.getSalesDetailBeforeGivenDate(inventory,fromDate);
                     salesDetailBetweenTwoDate = salesBillingController.getSalesDetailBetweenTwoDate(inventory,fromDate,toDate);
                    if(purchaseDetailBeforeGivenDate.size()>0){
                    for(TPharmacyPurchase purchase : purchaseDetailBeforeGivenDate){
                        purchaseOpeningQuantity = purchaseOpeningQuantity + Integer.parseInt(purchase.getPurchaseQuantity()) + Integer.parseInt(purchase.getPurchaseFree());
                    }
                    }if(salesDetailBeforeGivenDate.size() > 0){
                    for(TPharmacySales sales : salesDetailBeforeGivenDate){
                        salesOpeningQuantity = salesOpeningQuantity + Integer.parseInt(sales.getSalesQuantity()) ;
                    }
                    }
                    openingBalance = purchaseOpeningQuantity - salesOpeningQuantity;
                    if(purchaseDetailBetweenTwoDate.size() > 0){
                    for(TPharmacyPurchase purchase : purchaseDetailBetweenTwoDate){
                        purchaseQuantity = purchaseQuantity + Integer.parseInt(purchase.getPurchaseQuantity());
                        purchaseFreeQuantity = purchaseFreeQuantity + Integer.parseInt(purchase.getPurchaseFree());
                    }
                    }
                    if(salesDetailBetweenTwoDate.size() > 0){
                    for(TPharmacySales sales : salesDetailBetweenTwoDate){
                        salesQuantity = salesQuantity + Integer.parseInt(sales.getSalesQuantity());
                    }
                    }
                    closingBalance = openingBalance + purchaseQuantity + purchaseFreeQuantity - salesQuantity;
                    /*obj.add(inventory.getInventoryMed().getMedicationName());
                    obj.add(String.valueOf(openingBalance));
                    obj.add(String.valueOf(purchaseQuantity));
                    obj.add(String.valueOf(salesQuantity));
                    obj.add(String.valueOf(closingBalance));
                    inventoryDetailBalance.addAll(obj);
                    obj.clear();*/
                    
                    model = (DefaultTableModel)inventory_balance_report_table.getModel();
                        addObject = new Vector<Object>();
                        slNo = slNo + 1;
                        addObject.add(slNo);
                        addObject.add(inventory.getInventoryMed().getMedicationName());
                        addObject.add(openingBalance);
                        addObject.add(purchaseQuantity);
                        addObject.add(purchaseFreeQuantity);
                        addObject.add(salesQuantity);
                        addObject.add(closingBalance);
                        model.addRow(addObject);
                }
                }else{
                    JOptionPane.showMessageDialog(null, "No Inventory Details Available .");
                }
            } catch (ProcessingException ex) {
                Logger.getLogger(InventoryBalanceReportPanel.class.getName()).log(Level.SEVERE, null, ex);
                 
            }
            }
        
    }//GEN-LAST:event_view_result_btActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.ButtonGroup buttonGroup2;
    private com.toedter.calendar.JDateChooser from_datechooser;
    private javax.swing.JTable inventory_balance_report_table;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JScrollPane jScrollPane1;
    private org.jdesktop.swingx.JXTitledPanel jXTitledPanel1;
    private javax.swing.JPanel searchBy_panel;
    private javax.swing.JButton search_Medicine_button;
    private javax.swing.JLabel search_parameter_lable;
    private javax.swing.JTextField search_parameter_textfield;
    private com.toedter.calendar.JDateChooser to_datechooser;
    private javax.swing.JButton view_result_bt;
    // End of variables declaration//GEN-END:variables
    TInventoryMaster inventoryMaster = new TInventoryMaster();
    
    TMedicationMaster medicationMaster = new TMedicationMaster();
    
    private javax.swing.JFrame MainAPP;
    
    private DefaultTableModel model;
    
    private Vector<Object> addObject;
    /** The pagesize. */
    private int pagesize;   
    /** The index. */
    private  int index=0;   
    /** The search records. */
    private int searchRecords=0;   
    /** The sorter. */
    TableRowSorter<TableModel> sorter;
    
    private PharmacyReportController pharmacyReportController;
    
    private InventorySearchController inventorySearchController;
    
    private PurchaseController purchaseController;
    
    private SalesBillingController salesBillingController;
    
    

    private void populateData() {        
        pharmacyReportController = (PharmacyReportController)PharmacyHomeFrame.context.getBean("pharmacyReportController");  
        inventorySearchController = (InventorySearchController)PharmacyHomeFrame.context.getBean("inventorySearchController");
        purchaseController = (PurchaseController)PharmacyHomeFrame.context.getBean("purchaseController");
        salesBillingController = (SalesBillingController)PharmacyHomeFrame.context.getBean("salesBillingController");
        //defaultInventoryBalanceTable();
    }
    
    private void defaultInventoryBalanceTable(){
        inventory_balance_report_table.setModel(new javax.swing.table.DefaultTableModel(new Object [][] {},new String [] {
                "Sl No.", "Medication Name", "Opening Stock", "Total Purchase","Free", "Total Sale", "Closing Stock"}));
        
        inventory_balance_report_table.getTableHeader().setFont(new Font("SansSerif", Font.BOLD, 11));
        inventory_balance_report_table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 
    }

    private void showInventoryBalance(List<String> inventoryDetailBalance){
//        defaultInventoryBalanceTable();
       
    }
    
}

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

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