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

import com.bestray.healthcarecommonutil.exception.ProcessingException;
import com.bestray.healthcarecommonutil.util.ButtonType;
import com.bestray.healthcarecommonutil.util.StandardButton;
import com.bestray.healthcarecommonutil.util.TextPrompt;
import com.bestray.healthcarecommonutil.util.Theme;
import com.bestray.healthcarecommonutil.vo.TAccDeptRole;
import com.bestray.healthcarecommonutil.vo.TAccount;
import com.bestray.healthcarecommonutil.vo.TAccountDepartment;
import com.bestray.healthcarecommonutil.vo.TRole;
import com.bestray.healthcareemr.Controller.DeptWithRoleController;
import com.bestray.healthcareemr.Util.MessageProperties;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
import java.awt.event.KeyEvent;
import java.util.List;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import javax.swing.JOptionPane;
import javax.swing.ListSelectionModel;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;

/**
 *
 * @author user3
 */
public class AssignDeptWithRoles extends javax.swing.JPanel {

    /**
     * Creates new form AssignDeptWithRoles
     */
    public AssignDeptWithRoles() {
        populate();
        initComponents();
        changecolumnlength();
        changedeptassignedtable();
        TextPrompt tp7 = new TextPrompt("Search For Username", searchtextfield);
        tp7.setForeground( Color.RED );
        tp7.changeAlpha(0.5f);
        tp7.changeStyle(Font.BOLD);
        updateUsernameTable();
    }

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

        searchtextfield = new javax.swing.JTextField();
        searchbutton = new StandardButton("My List", Theme.STANDARD_NAVYBLUE_THEME,ButtonType.BUTTON_RECTANGULAR);
        jScrollPane1 = new javax.swing.JScrollPane();
        usernametable = 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;
            }
        };
        jScrollPane2 = new javax.swing.JScrollPane();
        deptassignedtable = 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;
            }
        };
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        allrolelist = new javax.swing.JList();
        jButton2 = new StandardButton("My List", Theme.STANDARD_SILVER_THEME,ButtonType.BUTTON_RECTANGULAR);
        jPanel2 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jScrollPane4 = new javax.swing.JScrollPane();
        assignedrolelist = new javax.swing.JList();
        jButton3 = new StandardButton("My List", Theme.STANDARD_SILVER_THEME,ButtonType.BUTTON_RECTANGULAR);

        setOpaque(false);

        searchtextfield.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                searchtextfieldKeyPressed(evt);
            }
        });

        searchbutton.setText("Search");
        searchbutton.setOpaque(false);
        searchbutton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                searchbuttonActionPerformed(evt);
            }
        });

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

            },
            new String [] {
                "Account Id", "Usernames"
            }
        ));
        usernametable.setRowHeight(21);
        usernametable.getTableHeader().setReorderingAllowed(false);
        usernametable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                usernametableMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(usernametable);

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

            },
            new String [] {
                "Acc Department Id", "Departments Assigned"
            }
        ));
        deptassignedtable.setRowHeight(21);
        deptassignedtable.getTableHeader().setReorderingAllowed(false);
        deptassignedtable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                deptassignedtableMouseClicked(evt);
            }
        });
        jScrollPane2.setViewportView(deptassignedtable);

        jPanel1.setBackground(new java.awt.Color(153, 204, 255));
        jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        jLabel1.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        jLabel1.setText("All Roles");

        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(jLabel1)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGap(0, 0, 0)
                .addComponent(jLabel1)
                .addGap(0, 0, 0))
        );

        allrolelist.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N
        allrolelist.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane3.setViewportView(allrolelist);

        jButton2.setText("Add Role");
        jButton2.setOpaque(false);
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jPanel2.setBackground(new java.awt.Color(153, 204, 255));
        jPanel2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        jLabel2.setFont(new java.awt.Font("SansSerif", 1, 12)); // NOI18N
        jLabel2.setText("Assigned Roles");

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel2)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(0, 0, 0)
                .addComponent(jLabel2)
                .addGap(0, 0, 0))
        );

        assignedrolelist.setFont(new java.awt.Font("SansSerif", 0, 12)); // NOI18N
        assignedrolelist.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jScrollPane4.setViewportView(assignedrolelist);

        jButton3.setText("Remove Role");
        jButton3.setOpaque(false);
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addComponent(searchtextfield, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(searchbutton)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 249, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jButton3, 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)
                            .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 267, Short.MAX_VALUE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 264, Short.MAX_VALUE)
                    .addComponent(jButton2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(searchtextfield, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(searchbutton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jScrollPane3)
                            .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 356, Short.MAX_VALUE)))
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(jButton3))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void searchbuttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchbuttonActionPerformed
       if(searchtextfield.getText().trim().length()>0){
           String username = searchtextfield.getText();
            if(username.trim().length()>0){
                try {
                    List<TAccount> acclist = deptrolecontroller.getUserByUsername(username);
                    usernametable.setModel(new javax.swing.table.DefaultTableModel(new Object [][] {},new String [] {"Account Id", "Usernames"}));
                    changecolumnlength();
                    model = (DefaultTableModel)usernametable.getModel();
                    for(TAccount acc:acclist){
                        addObject = new Vector<Object>();
                        addObject.add(acc.getId());
                        addObject.add(acc.getUserName());
                        model.addRow(addObject);
                    }
                } catch (ProcessingException ex) {
                    Logger.getLogger(UserSecurityPanel.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
       }
    }//GEN-LAST:event_searchbuttonActionPerformed

    private void searchtextfieldKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_searchtextfieldKeyPressed
        if (evt.getKeyCode() == KeyEvent.VK_ENTER) {
            searchbutton.doClick();
        }
    }//GEN-LAST:event_searchtextfieldKeyPressed
    
    private void usernametableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_usernametableMouseClicked
        int row = usernametable.getSelectedRow();
        if(row!=-1){
            try {
                accid = Integer.valueOf(usernametable.getValueAt(row,0).toString());
                TAccount acc = deptrolecontroller.getAccountByAccountId(accid);
                accdeptList = deptrolecontroller.getDeptByAcc(acc);
                deptassignedtable.setModel(new javax.swing.table.DefaultTableModel(new Object [][] {},new String [] {"Acc Dept Id", "Departments Assigned"}));
                changedeptassignedtable();
                model = (DefaultTableModel)deptassignedtable.getModel();
                for(TAccountDepartment accdept:accdeptList){
                    addObject = new Vector<Object>();
                    addObject.add(accdept.getId());
                    addObject.add(accdept.getDeptId().getDepartmentName());
                    model.addRow(addObject);
                }
            } catch (ProcessingException ex) {
                Logger.getLogger(AssignDeptWithRoles.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }//GEN-LAST:event_usernametableMouseClicked
    private Long accdeptid=0L;
    private void deptassignedtableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_deptassignedtableMouseClicked
        int row = deptassignedtable.getSelectedRow();
        if(row!=-1){
            accdeptid = Long.valueOf(deptassignedtable.getValueAt(row,0).toString());
            assignedrolemodel = new DefaultListModel();
            try {
                TAccountDepartment accdept = deptrolecontroller.getAccDeptById(accdeptid);
                List<TRole> roles = deptrolecontroller.getRolesByAccDept(accdept);
                for(TRole role:roles){
                    assignedrolemodel.addElement(role);
                }
                assignedrolelist.setModel(assignedrolemodel);
                roleList = deptrolecontroller.getAllRoles();
                allrolemodel = new DefaultListModel();
                
                for(int i=0;i<assignedrolemodel.getSize();i++){
                    if(roleList.contains(assignedrolemodel.get(i))){
                        TRole r = (TRole)assignedrolemodel.get(i);
                        roleList.remove(r);
                    }
                }
                for(TRole role:roleList){
                    allrolemodel.addElement(role);
                }
                allrolelist.setModel(allrolemodel);
               
            } catch (ProcessingException ex) {
                Logger.getLogger(UserSecurityPanel.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }//GEN-LAST:event_deptassignedtableMouseClicked

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        try { 
            int row = deptassignedtable.getSelectedRow();
            if(row!=-1){
                accdeptid = Long.valueOf(deptassignedtable.getValueAt(row,0).toString());
            }
            TAccountDepartment accdept = deptrolecontroller.getAccDeptById(accdeptid);
            if(accdept!=null && row !=-1){
                if(!allrolelist.isSelectionEmpty()){
                    TRole selectedrole = (TRole)allrolelist.getSelectedValue();
                    if(assignedrolemodel.contains(selectedrole)){
                        JOptionPane.showMessageDialog(null, "Role Already Exist");
                    }else{
                            accDeptRole.setAccountDeptId(accdept);
                            accDeptRole.setRoleId(selectedrole);
                            assignedrolemodel.addElement(selectedrole);
                            allrolemodel.removeElement(selectedrole);
                            deptrolecontroller.saveDeptWithAssociatedRoles(accDeptRole);
                    }
            }else{
                    JOptionPane.showMessageDialog(null, "Select role from list to be added");
                }
            }else{
                JOptionPane.showMessageDialog(null, "Select department first");
            }
        } catch (ProcessingException ex) {
            Logger.getLogger(UserSecurityPanel.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        try { 
            int row = deptassignedtable.getSelectedRow();
            if(row!=-1){
                accdeptid = Long.valueOf(deptassignedtable.getValueAt(row,0).toString());
            }
            TAccountDepartment accdept = deptrolecontroller.getAccDeptById(accdeptid);
            if(accdept!=null && row !=-1){
                if(!assignedrolelist.isSelectionEmpty()){
                    TRole selectedrole = (TRole)assignedrolelist.getSelectedValue();
                    TAccDeptRole getdeptrole = deptrolecontroller.getDeptAssociatedRole(accdept,selectedrole);
                            assignedrolemodel.removeElement(selectedrole);
                            allrolemodel.addElement(selectedrole);
                            deptrolecontroller.deleteRoleFromDept(getdeptrole);
                }else{
                    JOptionPane.showMessageDialog(null, "Select role from list to be removed");
                }
            }else{
                JOptionPane.showMessageDialog(null, "Select deptartment first");
            }
        }catch(IllegalArgumentException ex) {
            JOptionPane.showMessageDialog(null, MessageProperties.getMessage("error.update",new Object[]{"Role"}));
        }catch(ProcessingException ex) {
            JOptionPane.showMessageDialog(null, MessageProperties.getMessage("error.delete",new Object[]{"Role"}));
        }
    }//GEN-LAST:event_jButton3ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JList allrolelist;
    private javax.swing.JList assignedrolelist;
    private javax.swing.JTable deptassignedtable;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JButton searchbutton;
    private javax.swing.JTextField searchtextfield;
    private javax.swing.JTable usernametable;
    // End of variables declaration//GEN-END:variables
    private List<TAccount> usernameList;
    private List<TAccountDepartment> accdeptList;
    private List<TRole> roleList;
    private DeptWithRoleController deptrolecontroller;
    DefaultTableModel model;
    private Vector<Object> addObject;
    private Integer accid=0;
    DefaultListModel allrolemodel;
    DefaultListModel assignedrolemodel;
    TAccDeptRole accDeptRole;
    
    private void populate(){
        accDeptRole = new TAccDeptRole();
        deptrolecontroller = (DeptWithRoleController)HealthcareLogin.context.getBean("deptWithRoleController");
        try {
            usernameList = deptrolecontroller.allAccountList();
        } catch (ProcessingException ex) {
            Logger.getLogger(UserSecurityPanel.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    private void changecolumnlength() {
        usernametable.getColumnModel().getColumn(0).setMinWidth(0);
        usernametable.getColumnModel().getColumn(0).setPreferredWidth(0);
        usernametable.getColumnModel().getColumn(0).setMaxWidth(0);
        usernametable.getTableHeader().setFont(new Font("SansSerif", Font.BOLD, 12));
        usernametable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        
    }
    
    private void changedeptassignedtable(){
        deptassignedtable.getColumnModel().getColumn(0).setMinWidth(0);
        deptassignedtable.getColumnModel().getColumn(0).setPreferredWidth(0);
        deptassignedtable.getColumnModel().getColumn(0).setMaxWidth(0);
        deptassignedtable.getTableHeader().setFont(new Font("SansSerif", Font.BOLD, 12));
        deptassignedtable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    }
    
    private void updateUsernameTable() {
        try {
            usernameList = deptrolecontroller.allAccountList();
            usernametable.setModel(new javax.swing.table.DefaultTableModel(new Object [][] {},new String [] {"Account Id", "Usernames"}));
            changecolumnlength();
            model = (DefaultTableModel)usernametable.getModel();
            for(TAccount acc:usernameList){
               addObject = new Vector<Object>();
               addObject.add(acc.getId());
               addObject.add(acc.getUserName());
               model.addRow(addObject);
            }
        } catch (ProcessingException ex) {
            Logger.getLogger(UserSecurityPanel.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

Commits for Pharmacy_09_03_18/Dr Gyana ProjectSpace/DrGyanaEMR/src/main/java/com/bestray/healthcareemr/Views/AssignDeptWithRoles.java

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