Subversion Repository Public Repository

Satyam

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

import com.bestray.healthcarecommonutil.ContextLoading;
import com.bestray.healthcarecommonutil.exception.HealthCareException;
import com.bestray.healthcarecommonutil.exception.ProcessingException;
import com.bestray.healthcarecommonutil.util.StandardButton;
import com.bestray.healthcarecommonutil.util.Theme;
import com.bestray.healthcarecommonutil.vo.TAccount;
import com.bestray.healthcarecommonutil.vo.TDepartmentMaster;
import com.bestray.healthcareemr.Controller.LoginController;
import com.bestray.healthcareemr.Controller.UserSetupController;
import com.bestray.healthcareemr.Util.LicenseDetail;
import com.bestray.healthcareemr.Util.MessageProperties;
import com.bestray.healthcarecommonutil.util.PreferenceUtil;
import com.bestray.healthcarecommonutil.vo.TAccDeptRole;
import com.bestray.healthcarecommonutil.vo.TAccountDepartment;
import com.bestray.healthcarecommonutil.vo.TRolePermission;
import com.bestray.healthcareemr.Controller.DeptWithRoleController;
import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.Vector;

import java.util.prefs.Preferences;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.UIManager;
import org.apache.log4j.Logger;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

// TODO: Auto-generated Javadoc
/**
 * The Class HealthcareLogin.
 *
 * @author user3
 */
public class HealthcareLogin extends javax.swing.JFrame {

    /** Creates new form HealthcareLogin. */
    static Logger logger = Logger.getLogger(HealthcareLogin.class.getName());
    
    /** The context. */
    public static ApplicationContext context ;
    static{
        context =new ClassPathXmlApplicationContext( new String[] {"healthCareBeans.xml","healthCareCommonUtilBeans.xml","HealthCareInpatientBeans.xml","labInformationBeans.xml","HealthCareDentalBeans.xml"});
        ContextLoading.context = context;
    }
    
    /**
     * Instantiates a new healthcare login.
     */
    public HealthcareLogin() {
        populate();
        initComponents();
        logincontroller=(LoginController)HealthcareLogin.context.getBean("loginController");
        //setLocationRelativeTo(null);
        setExtendedState(this.getExtendedState() | this.MAXIMIZED_BOTH);
        setIconImage(Toolkit.getDefaultToolkit().getImage(HealthcareHome.class.getResource("/images/Plus-icon64X64.png")));
        //Change c = new Change();
        //c.execute();
        
    }

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

        jPanel6 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jPanel5 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jPanel7 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jPanel8 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jPanel9 = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        username_label = new javax.swing.JLabel();
        username_textfield = new javax.swing.JTextField();
        password_label = new javax.swing.JLabel();
        password_textfield = new javax.swing.JPasswordField();
        login_button = new StandardButton("Login", Theme.STANDARD_SILVER_THEME);//new GlossyButton("Login",Theme.GLOSSY_GREEN_THEME,ButtonType.BUTTON_ROUNDED);
        register_bt = new javax.swing.JButton();
        Department_label = new javax.swing.JLabel();
        Department_combo = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();

        jPanel6.setBackground(new java.awt.Color(0, 255, 255));

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel2.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());

        jPanel5.setBackground(new java.awt.Color(251, 251, 248));
        jPanel5.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel5.setLayout(new java.awt.BorderLayout());
        jPanel2.add(jPanel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 40, 390, 230));

        jLabel4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/login_backgroung.png"))); // NOI18N
        jPanel2.add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, -1, -1));

        jPanel3.setBackground(new java.awt.Color(255, 255, 255));
        jPanel3.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel3.setLayout(new java.awt.BorderLayout());

        jPanel4.setBackground(new java.awt.Color(255, 255, 255));
        jPanel4.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jPanel4.setLayout(new java.awt.BorderLayout());

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, 667, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, 671, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, 341, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("EMR Login");

        jPanel7.setBackground(new java.awt.Color(255, 255, 255));

        jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/EMR MOTO.gif"))); // NOI18N

        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Universal Logo.png")));

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addComponent(jLabel1)
                .addGap(0, 0, 0)
                .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 460, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(0, 0, Short.MAX_VALUE))
        );

        jPanel8.setBackground(new java.awt.Color(255, 255, 255));
        jPanel8.setLayout(new java.awt.BorderLayout());

        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/bestray deta logo.png"))); // NOI18N
        jPanel8.add(jLabel2, java.awt.BorderLayout.CENTER);

        jPanel9.setBackground(new java.awt.Color(255, 204, 204));
        jPanel9.setLayout(null);

        jPanel1.setOpaque(false);

        username_label.setFont(new java.awt.Font("Batang", 1, 16)); // NOI18N
        username_label.setForeground(new java.awt.Color(255, 255, 255));
        username_label.setText("Username    :");

        password_label.setFont(new java.awt.Font("Batang", 1, 16)); // NOI18N
        password_label.setForeground(new java.awt.Color(255, 255, 255));
        password_label.setText("Password     :");

        password_textfield.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusLost(java.awt.event.FocusEvent evt) {
                password_textfieldFocusLost(evt);
            }
        });
        password_textfield.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                password_textfieldKeyPressed(evt);
            }
        });

        login_button.setFont(new java.awt.Font("SansSerif", 1, 11)); // NOI18N
        login_button.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/Actions-system-log-out-icon.png"))); // NOI18N
        login_button.setText("Login");
        login_button.setOpaque(false);
        login_button.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                login_buttonActionPerformed(evt);
            }
        });

        register_bt.setVisible(false);
        register_bt.setText("Register");
        register_bt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                register_btActionPerformed(evt);
            }
        });

        Department_label.setFont(new java.awt.Font("Batang", 1, 16)); // NOI18N
        Department_label.setForeground(new java.awt.Color(255, 255, 255));
        Department_label.setVisible(false);
        Department_label.setText("Department :");

        Department_combo.setVisible(false);
        Department_combo.setModel(new javax.swing.DefaultComboBoxModel());
        Department_combo.setSelectedIndex(-1);
        Department_combo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Department_comboActionPerformed(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()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(password_label)
                            .addComponent(username_label))
                        .addGap(6, 6, 6)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(username_textfield)
                            .addComponent(password_textfield, javax.swing.GroupLayout.PREFERRED_SIZE, 192, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(Department_label, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(Department_combo, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(register_bt)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(login_button, javax.swing.GroupLayout.PREFERRED_SIZE, 111, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

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

        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(username_label)
                    .addComponent(username_textfield, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(password_label)
                    .addComponent(password_textfield, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Department_combo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Department_label))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(login_button, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(register_bt))
                .addContainerGap())
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {password_textfield, username_textfield});

        jPanel9.add(jPanel1);
        jPanel1.setBounds(190, 90, 333, 163);

        jLabel3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/user_Login icon.png"))); // NOI18N
        jPanel9.add(jLabel3);
        jLabel3.setBounds(60, 30, 130, 180);

        jLabel6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/images/blue.jpg"))); // NOI18N
        jPanel9.add(jLabel6);
        jLabel6.setBounds(-510, -10, 1430, 390);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, 654, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, 0)
                .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, 473, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE)
                    .addComponent(jPanel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents
    
    /**
     * Login_button action performed.
     *
     * @param evt the evt
     */
    private void login_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_login_buttonActionPerformed
       try{
        if(validateLogin()){
            TAccount account = getUserAccount();            
            if(account!=null){
                //if(Department_combo.getSelectedItem()!=null){
                    //List<String> userpermission = logincontroller.getPermissionForUser(account);
                List<TRolePermission> rolepermissions = new ArrayList<TRolePermission>();
                List<TRolePermission> permissionslist = new ArrayList<TRolePermission>();
                List<String> permissions = new ArrayList<String>();
                
                    List<TAccountDepartment> userdepartments = logincontroller.getUserDepartments(account);
                    for(TAccountDepartment depts:userdepartments){
                        if(depts.getDefaultDept()!=null && depts.getDefaultDept().equalsIgnoreCase("Y")){
                            PreferenceUtil.putObject(myPrefObj, "selecteddepartment", depts);
                            List<TAccDeptRole> defaultdeptroles = deptWithRoleController.getAssociatedRole(depts);
                            for(TAccDeptRole r: defaultdeptroles){
                                rolepermissions = userSetupController.getRolePermission(r.getRoleId());
                                for(TRolePermission permission:rolepermissions){
                                   permissionslist.add(permission);
                                } 
                             }
                            Set<TRolePermission> dupli = new HashSet<TRolePermission>(permissionslist);
                            for(TRolePermission s:dupli){
                                String str = s.getPermissionId().getPermissionName();
                                permissions.add(str);
                            }
                        }
                    }
                    
                    PreferenceUtil.putObject(myPrefObj, "user", account);
                    PreferenceUtil.putObject(myPrefObj, "permissions", permissions);
                    //PreferenceUtil.putObject(myPrefObj, "permissions", userpermission);
                    PreferenceUtil.putObject(myPrefObj, "departments", userdepartments);
                    //String dept=Department_combo.getSelectedItem().toString();
                    //PreferenceUtil.putObject(myPrefObj, "dept", dept);
                    dispose();
                    HealthCareEmrAdvanceHome home = new HealthCareEmrAdvanceHome();
                    
                    home.setVisible(true);
                    System.out.println("checkkk....");
                //}else{
                 //   JOptionPane.showMessageDialog(null, "Department should be selected");
                    
                //}
            }else{
                
                JOptionPane.showMessageDialog(null, MessageProperties.getMessage("error.login"), "Error", JOptionPane.ERROR_MESSAGE);
                clearFields();
                username_textfield.requestFocus();
                
            }
           
        }else{
                showValidateMessage();
                clearFields();
            }
       }catch(ProcessingException ex){
           JOptionPane.showMessageDialog(null, MessageProperties.getMessage("error.db"));
       }catch(Exception ex){
           ex.printStackTrace();
           JOptionPane.showMessageDialog(null, MessageProperties.getMessage("error.login"), "Error", JOptionPane.ERROR_MESSAGE);
           throw new HealthCareException("Error:\n In Putting User In Session");
       }
    }//GEN-LAST:event_login_buttonActionPerformed

    /**
     * Register_bt action performed.
     *
     * @param evt the evt
     */
    private void register_btActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_register_btActionPerformed
        AccountPanel accpanel = new AccountPanel();
        JFrame f = new JFrame();
        f.add(accpanel,java.awt.BorderLayout.CENTER);
        f.setVisible(true);
        f.setLocationRelativeTo(null);
    }//GEN-LAST:event_register_btActionPerformed

    /**
     * Department_combo action performed.
     *
     * @param evt the evt
     */
    private void Department_comboActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Department_comboActionPerformed
        // TODO add your handling code here:
          
           
    }//GEN-LAST:event_Department_comboActionPerformed
    
    /**
     * Password_textfield focus lost.
     *
     * @param evt the evt
     */
    private void password_textfieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_password_textfieldFocusLost
        /*try{
            if(validateLogin()){
            TAccount useraccount = getUserAccount();
            if(useraccount!=null){
                Vector<String> departments = logincontroller.getDepartments(useraccount);
                Department_label.setVisible(true);
                Department_combo.setVisible(true);
                Department_combo.setModel(new javax.swing.DefaultComboBoxModel(departments));
                Department_combo.setSelectedIndex(-1);
                
            }
            }
        }catch(ProcessingException ex){
           JOptionPane.showMessageDialog(null, MessageProperties.getMessage("error.db"));
        }catch(Exception ex){
           JOptionPane.showMessageDialog(null, MessageProperties.getMessage("error.login"), "Error", JOptionPane.ERROR_MESSAGE);
           throw new HealthCareException("Error:\n In Putting User In Session");
       }*/
    }//GEN-LAST:event_password_textfieldFocusLost

    /**
     * Password_textfield key pressed.
     *
     * @param evt the evt
     */
    private void password_textfieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_password_textfieldKeyPressed
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            login_button.doClick();
        }
    }//GEN-LAST:event_password_textfieldKeyPressed
    
    /**
     * Gets the user account.
     *
     * @return the user account
     */
    private TAccount getUserAccount(){
        TAccount account = new TAccount();
        TAccount useraccount = null;
        if(validateLogin()){
            account.setUserName(username_textfield.getText());
            account.setPassword(password_textfield.getText());
            try{
                useraccount = logincontroller.authorizedUser(account);
                if(useraccount!=null){
                    System.out.println("Username: "+useraccount.getUserName()+"    Password: "+useraccount.getPassword());
                    if(!useraccount.getPassword().equals(password_textfield.getText())){
                        useraccount = null;
                    }
                }
            }catch(ProcessingException ex){
                JOptionPane.showMessageDialog(null, MessageProperties.getMessage("error.db"));
            }
        }
        return useraccount;
    }
    
    /**
     * Clear fields.
     */
    public void clearFields(){
        username_textfield.setText("");
        password_textfield.setText("");
        Department_label.setVisible(false);
        Department_combo.setVisible(false);
        
    }
    
    /**
     * The main method.
     *
     * @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;
                }*/UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(HealthcareLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(HealthcareLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(HealthcareLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(HealthcareLogin.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        // Create and display the for
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                
                if(licenseDetail.validateLicense()){
                    new HealthcareLogin().setVisible(true);
                }else{
                    JOptionPane.showMessageDialog(null, "Your License Expired...");
                }
                
            }
        });
        /*net.extranetsoftware.libraries.rampart.AppLauncher.launchApp(new Runnable() {
            public void run() {
                new HealthcareLogin().setVisible(true);
            }
        });*/
        logger.info("Entering EMR application.");
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox Department_combo;
    private javax.swing.JLabel Department_label;
    private javax.swing.JLabel jLabel1;
    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.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JPanel jPanel9;
    private javax.swing.JButton login_button;
    private javax.swing.JLabel password_label;
    private javax.swing.JPasswordField password_textfield;
    private javax.swing.JButton register_bt;
    private javax.swing.JLabel username_label;
    private javax.swing.JTextField username_textfield;
    // End of variables declaration//GEN-END:variables
    /** The logincontroller. */
    private LoginController logincontroller;
    
    /** The department list. */
    private Vector<TDepartmentMaster> departmentList = new Vector<TDepartmentMaster>();
    
    /** The department master. */
    private TDepartmentMaster departmentMaster;
    
    /** The login controller. */
    private LoginController loginController;
    
    /** The user setup controller. */
    private UserSetupController userSetupController; 
    
    /** The my pref obj. */
    private Preferences myPrefObj;
    
    /** The license detail. */
    private static LicenseDetail licenseDetail = new LicenseDetail();
    
    private DeptWithRoleController deptWithRoleController;
    /*class Change extends SwingWorker {
     protected Object doInBackground() throws Exception {
         CardLayout cl = (CardLayout)(backpanel.getLayout());
         Thread.sleep(2000);
         cl.next(backpanel);
         doInBackground();
         return null;
     } 
    }*/
    
    /**
     * Populate.
     */
    private void populate() {
        departmentMaster = new TDepartmentMaster();
        userSetupController=(UserSetupController)HealthcareLogin.context.getBean("userSetupController");
        deptWithRoleController=(DeptWithRoleController)HealthcareLogin.context.getBean("deptWithRoleController");
        myPrefObj = Preferences.userRoot();
        /*try{
            departmentList = userSetupController.getDepartmentList();
            System.out.println(departmentList);
        }catch(ProcessingException e){
             JOptionPane.showMessageDialog(null,MessageProperties.getMessage("error.fetch",new Object[]{"department"}));
             throw new HealthCareException(MessageProperties.getMessage("error.dao"));
         }*/
    }
    
    /**
     * Validate login.
     *
     * @return true, if successful
     */
    private boolean validateLogin() {
        boolean valid = true;
        if (this.username_textfield.getText().trim().length() == 0) {
            
            valid = false;
        }
        else if (this.password_textfield.getText().trim().length() == 0) {
            
            valid = false;
        }
       
        return valid;
    }
    
    /**
     * Show validate message.
     */
    public void showValidateMessage(){
        if (this.username_textfield.getText().trim().length() == 0) {
            JOptionPane.showMessageDialog(null, "Username or Password must not be Empty", "Error", JOptionPane.ERROR_MESSAGE);
            username_textfield.requestFocus();
        }
        else if (this.password_textfield.getText().trim().length() == 0) {
            JOptionPane.showMessageDialog(null, "Username or Password must not be empty.", "Error", JOptionPane.ERROR_MESSAGE);
            username_textfield.requestFocus();
        }
    }
    
}

Commits for Satyam/AuroCareEMR/src/main/java/com/bestray/healthcareemr/Views/HealthcareLogin.java

Diff revisions: vs.
Revision Author Commited Message
1 girijabapi picture girijabapi Fri 20 Jul, 2018 05:59:17 +0000