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
/*
 * 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.ButtonType;
import com.bestray.healthcarecommonutil.util.GlossyButton;
import com.bestray.healthcarecommonutil.util.PreferenceUtil;
import com.bestray.healthcarecommonutil.util.SimpleGradientPanel;
import com.bestray.healthcarecommonutil.util.Theme;
import com.bestray.healthcarecommonutil.vo.TAccount;
import com.bestray.healthcarecommonutil.vo.TCCodeValues;
import com.bestray.healthcarecommonutil.vo.TInventoryMaster;
import com.bestray.healthcarepharmacy.controller.InventoryMasterController;
import com.bestray.healthcarepharmacy.controller.PharmacyCodeValuesController;
import com.bestray.healthcarepharmacy.util.CollectionUtill;
import com.bestray.healthcarepharmacy.util.MessageProperties;
import java.awt.event.ActionEvent;
import java.util.Date;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.prefs.Preferences;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.InputMap;
import javax.swing.JComponent;
import javax.swing.JOptionPane;
import javax.swing.JRootPane;
import javax.swing.KeyStroke;
import org.springframework.orm.hibernate3.HibernateOptimisticLockingFailureException;

/**
 *
 * @author user3
 */
public class InventoryUpdateDialog extends javax.swing.JDialog {
    

    /**
     * Creates new form InventoryUpdateDialog
     */
    public InventoryUpdateDialog(java.awt.Frame parent, boolean modal,TInventoryMaster inventoryMaster,String s) {
        super(parent, modal);
        populate();
        initComponents();
        this.inventory = inventoryMaster;
        if(s.equalsIgnoreCase("SHOW")){
            update_bt.setVisible(false);
            mfrs_txt.setEditable(false);
            quantity_txt.setEditable(false);
            batch_number_txt.setEditable(false);
            mrp_txt.setEditable(false);
            unit_combo.setEditable(false);
            ptr_txt.setEditable(false);
            free_txt.setEditable(false);
            replace_txt.setEditable(false);
            quantity_unit_txt.setEditable(false);
            expd_DateChooser.setEnabled(false);
            mfgd_DateChooser.setEnabled(false);
            unit_combo.setEnabled(false);
        }
        showInventory(inventory);
    }

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

        jPanel2 = new SimpleGradientPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jPanel1 = new SimpleGradientPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        product_name_txt = new javax.swing.JTextField();
        quantity_txt = new javax.swing.JTextField();
        batch_number_txt = new javax.swing.JTextField();
        mrp_txt = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        ptr_txt = new javax.swing.JTextField();
        free_txt = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        replace_txt = new javax.swing.JTextField();
        mfrs_txt = new javax.swing.JTextField();
        quantity_unit_txt = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        mfgd_DateChooser = new com.toedter.calendar.JDateChooser();
        jLabel12 = new javax.swing.JLabel();
        expd_DateChooser = new com.toedter.calendar.JDateChooser();
        unit_combo = new javax.swing.JComboBox();
        update_bt = new GlossyButton("Update",Theme.GLOSSY_GREEN_THEME,ButtonType.BUTTON_ROUNDED_RECTANGLUR);

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Inventory Details");

        jPanel2.setLayout(new java.awt.BorderLayout());

        jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
        jScrollPane1.setOpaque(false);

        jLabel1.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setText("Product  Name :");

        jLabel2.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel2.setText("Quantity :");

        jLabel3.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel3.setText("Manufacturer :");

        jLabel4.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel4.setText("Batch Number :");

        jLabel5.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel5.setText("M.R.P  :");

        product_name_txt.setEditable(false);
        product_name_txt.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        product_name_txt.setBorder(null);
        product_name_txt.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        product_name_txt.setEnabled(false);
        product_name_txt.setOpaque(false);
        product_name_txt.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                product_name_txtKeyTyped(evt);
            }
        });

        quantity_txt.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        quantity_txt.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                quantity_txtKeyTyped(evt);
            }
        });

        batch_number_txt.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        batch_number_txt.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                batch_number_txtKeyTyped(evt);
            }
        });

        mrp_txt.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        mrp_txt.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                mrp_txtKeyTyped(evt);
            }
        });

        jLabel6.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel6.setText("Unit :");

        jLabel7.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel7.setText("Free :");

        ptr_txt.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        ptr_txt.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                ptr_txtKeyTyped(evt);
            }
        });

        free_txt.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        free_txt.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                free_txtKeyTyped(evt);
            }
        });

        jLabel8.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel8.setText("P.T.R :");

        jLabel9.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel9.setText("Replace :");

        replace_txt.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        replace_txt.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                replace_txtKeyTyped(evt);
            }
        });

        mfrs_txt.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        mfrs_txt.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                mfrs_txtKeyTyped(evt);
            }
        });

        quantity_unit_txt.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        quantity_unit_txt.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                quantity_unit_txtKeyTyped(evt);
            }
        });

        jLabel10.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel10.setText("Q/U :");

        jLabel11.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel11.setText("Mfgd :");

        mfgd_DateChooser.setDateFormatString("dd/MM/yyyy");

        jLabel12.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel12.setText("Expd :");

        expd_DateChooser.setDateFormatString("dd/MM/yyyy");

        unit_combo.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        unit_combo.setModel(new javax.swing.DefaultComboBoxModel(medicineTypeList));
        //unit_combo.setSelectedIndex(-1);

        update_bt.setFont(new java.awt.Font("SansSerif", 1, 11)); // NOI18N
        update_bt.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Edit-icon 16X16.png"))); // NOI18N
        update_bt.setText("Update");
        update_bt.setOpaque(false);
        update_bt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                update_btActionPerformed(evt);
            }
        });

        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(jLabel1)
                            .addComponent(jLabel3)
                            .addComponent(jLabel2)
                            .addComponent(jLabel6)
                            .addComponent(jLabel4)
                            .addComponent(jLabel5)
                            .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel10)
                            .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(replace_txt, javax.swing.GroupLayout.DEFAULT_SIZE, 210, Short.MAX_VALUE)
                            .addComponent(expd_DateChooser, javax.swing.GroupLayout.DEFAULT_SIZE, 210, Short.MAX_VALUE)
                            .addComponent(mfgd_DateChooser, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(free_txt)
                            .addComponent(ptr_txt)
                            .addComponent(mrp_txt)
                            .addComponent(batch_number_txt)
                            .addComponent(quantity_unit_txt)
                            .addComponent(unit_combo, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(quantity_txt)
                            .addComponent(mfrs_txt)
                            .addComponent(product_name_txt)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(update_bt)
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addGap(19, 19, 19))
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel10, jLabel2, jLabel3, jLabel4, jLabel5, jLabel6, jLabel7, jLabel8, jLabel9});

        jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {expd_DateChooser, replace_txt});

        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(product_name_txt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(mfrs_txt, 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(jLabel2)
                    .addComponent(quantity_txt, 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(jLabel6)
                    .addComponent(unit_combo, 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(quantity_unit_txt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(batch_number_txt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addComponent(mrp_txt, 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(ptr_txt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(free_txt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(replace_txt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel11)
                    .addComponent(mfgd_DateChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel12)
                    .addComponent(expd_DateChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(update_bt)
                .addContainerGap())
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jLabel1, jLabel10, jLabel2, jLabel3, jLabel4, jLabel5, jLabel6, jLabel7, jLabel8, jLabel9});

        jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {batch_number_txt, mrp_txt, product_name_txt, quantity_txt, unit_combo});

        jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {expd_DateChooser, mfgd_DateChooser, replace_txt});

        jScrollPane1.setViewportView(jPanel1);

        jPanel2.add(jScrollPane1, java.awt.BorderLayout.CENTER);

        getContentPane().add(jPanel2, java.awt.BorderLayout.CENTER);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void product_name_txtKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_product_name_txtKeyTyped
        
        // TODO add your handling code here:
    }//GEN-LAST:event_product_name_txtKeyTyped

    private void quantity_txtKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_quantity_txtKeyTyped
        // TODO add your handling code here:
    }//GEN-LAST:event_quantity_txtKeyTyped

    private void batch_number_txtKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_batch_number_txtKeyTyped
        // TODO add your handling code here:
    }//GEN-LAST:event_batch_number_txtKeyTyped

    private void mrp_txtKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_mrp_txtKeyTyped
        // TODO add your handling code here:
    }//GEN-LAST:event_mrp_txtKeyTyped

    private void update_btActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_update_btActionPerformed
        try{
            System.out.println("HELLOO"+inventory.getId());
            inventory.setMaximumRetailPrice(Double.valueOf(mrp_txt.getText()));
            inventory.setInventoryBatchNumber(batch_number_txt.getText());
            inventory.setInventoryQuantity(quantity_txt.getText());
            inventory.setInventoryMfrs(mfrs_txt.getText());
            inventory.setInventoryExpiryDate(expd_DateChooser.getDate());
            inventory.setInventoryFree(free_txt.getText());
            inventory.setInventoryPtr(Double.valueOf(ptr_txt.getText()));
            inventory.setInventoryReplacement(replace_txt.getText());
            inventory.setInventoryUnit(unit_combo.getSelectedItem().toString());
            inventory.setManufactureDate(mfgd_DateChooser.getDate());
            inventory.setQuantityPerUnit(Double.valueOf(quantity_unit_txt.getText()));
            inventory.setUpdatedDate(new Date());
            inventory.setUpdatedBy((useraccount.getFirstName()+" "+ useraccount.getLastName()));
            updatedInventory = inventoryMasterController.updateInventoryMaster(inventory);
            dispose();
        }catch(HibernateOptimisticLockingFailureException e){
            JOptionPane.showMessageDialog(null, MessageProperties.getMessage("error.update",new Object[]{"Inventory Details"}));
            e.printStackTrace();
      }catch(ProcessingException e){
            e.printStackTrace();
            JOptionPane.showMessageDialog(null, MessageProperties.getMessage("error.save",new Object[]{"Inventory Details"}));
            throw new HealthCareException(MessageProperties.getMessage("error.dao"));
        }catch(Exception e){
            e.printStackTrace();
            JOptionPane.showMessageDialog(null, MessageProperties.getMessage("error.save",new Object[]{"Inventory Details"}));
        }
    }//GEN-LAST:event_update_btActionPerformed

    private void ptr_txtKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_ptr_txtKeyTyped
        // TODO add your handling code here:
    }//GEN-LAST:event_ptr_txtKeyTyped

    private void free_txtKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_free_txtKeyTyped
        // TODO add your handling code here:
    }//GEN-LAST:event_free_txtKeyTyped

    private void replace_txtKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_replace_txtKeyTyped
        // TODO add your handling code here:
    }//GEN-LAST:event_replace_txtKeyTyped

    private void mfrs_txtKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_mfrs_txtKeyTyped
        // TODO add your handling code here:
    }//GEN-LAST:event_mfrs_txtKeyTyped

    private void quantity_unit_txtKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_quantity_unit_txtKeyTyped
        // TODO add your handling code here:
    }//GEN-LAST:event_quantity_unit_txtKeyTyped

    /**
     * @param args the command line arguments
     
    public static void main(String args[]) {
        /* Set the Nimbus look and feel 
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(InventoryUpdateDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(InventoryUpdateDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(InventoryUpdateDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(InventoryUpdateDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog 
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                InventoryUpdateDialog dialog = new InventoryUpdateDialog(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }*/
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField batch_number_txt;
    private com.toedter.calendar.JDateChooser expd_DateChooser;
    private javax.swing.JTextField free_txt;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private com.toedter.calendar.JDateChooser mfgd_DateChooser;
    private javax.swing.JTextField mfrs_txt;
    private javax.swing.JTextField mrp_txt;
    private javax.swing.JTextField product_name_txt;
    private javax.swing.JTextField ptr_txt;
    private javax.swing.JTextField quantity_txt;
    private javax.swing.JTextField quantity_unit_txt;
    private javax.swing.JTextField replace_txt;
    private javax.swing.JComboBox unit_combo;
    private javax.swing.JButton update_bt;
    // End of variables declaration//GEN-END:variables
    private TInventoryMaster inventory;
    private TAccount useraccount;
    private Preferences myPrefObj = Preferences.userRoot();
    private InventoryMasterController inventoryMasterController ;
    private Vector<TCCodeValues> medicineTypeList = new Vector<TCCodeValues>();
    private PharmacyCodeValuesController pharmacyCodeValuesController;
    private TInventoryMaster updatedInventory;
    
    private void populate() {
        inventoryMasterController = (InventoryMasterController)PharmacyHomeFrame.context.getBean("inventoryMasterController");
        pharmacyCodeValuesController = (PharmacyCodeValuesController)PharmacyHomeFrame.context.getBean("pharmacyCodeValuesController");
        inventory = new TInventoryMaster();
        try{
            useraccount = (TAccount)PreferenceUtil.getObject(myPrefObj, "user");
            }catch(Exception e){
            JOptionPane.showMessageDialog(null,MessageProperties.getMessage("error.fetch",new Object[]{"visit type"}));
            }
        try {
            medicineTypeList = pharmacyCodeValuesController.getCodeValues("MEDICINE TYPE");
        } catch (ProcessingException ex) {
            Logger.getLogger(InventoryUpdateDialog.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    private void showInventory(TInventoryMaster inventory) {
         
           if(inventory!=null){
            product_name_txt.setText(String.valueOf(inventory.getInventoryMed().getMedicationName()));
            mfrs_txt.setText(inventory.getInventoryMfrs());
            quantity_txt.setText(inventory.getInventoryQuantity());
            batch_number_txt.setText(inventory.getInventoryBatchNumber());
            mrp_txt.setText(String.valueOf(inventory.getMaximumRetailPrice()));
            unit_combo.setSelectedIndex(CollectionUtill.getCodeValueIndex(medicineTypeList,inventory.getInventoryUnit()));
            ptr_txt.setText(String.valueOf(inventory.getInventoryPtr()));
            free_txt.setText(String.valueOf(inventory.getInventoryFree()));
            replace_txt.setText(String.valueOf(inventory.getInventoryReplacement()));
            quantity_unit_txt.setText(String.valueOf(inventory.getQuantityPerUnit()));
            expd_DateChooser.setDate(inventory.getInventoryExpiryDate());
            mfgd_DateChooser.setDate(inventory.getManufactureDate());
           }
        
    }
    
    protected JRootPane createRootPane() {
        JRootPane rootPane = new JRootPane();
        KeyStroke stroke = KeyStroke.getKeyStroke("ESCAPE");
        Action actionListener = new AbstractAction() {
          public void actionPerformed(ActionEvent actionEvent) {
            dispose();
          }
        };
        InputMap inputMap = rootPane
            .getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
        inputMap.put(stroke, "ESCAPE");
        rootPane.getActionMap().put("ESCAPE", actionListener);

        return rootPane;
    }    
    public TInventoryMaster updatedInventoryRecord(){
        return updatedInventory;
    }
}

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

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