zsh_root
2024-01-02 7b595546af704983dbafcd0d385c8768ddacefc2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
package Frame;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.sql.ResultSet;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import javax.swing.Box;
import javax.swing.ButtonGroup;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.ImageIcon;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
 
import ColorAndFont.English;
import ColorAndFont.NothJPanel;
import ColorAndFont.UIColor;
import ColorAndFont.buttonTitle;
import Company.Dell_tbCompany;
import DataBase.DatabaseManagement;
import Method.GetNowTime;
import PbuliClass.BuMens;
import PbuliClass.DownloadFile;
import PbuliClass.ImExport;
import PbuliClass.JButtonModel;
import PbuliClass.JlableModel;
import PbuliClass.OutButton;
import PbuliClass.ShowMessage;
import PbuliClass.Systems;
import PbuliClass.WarningMessage;
import PbuliClass.greateTables;
import PbuliClass.jinternalFrame;
import person.Person;
import person.person_Dell;
 
/**´ËÀàÓÃÓÚÈËÔ±¹ÜÀí*/
@SuppressWarnings("rawtypes")
public class PersonManage extends jinternalFrame {
    /**
     * 
     */
    private static final long serialVersionUID = 1L;
    jinternalFrame jinerFrame=null;
    JInternalFrame jinFrame=null;    
    JPanel innerPanel=null;//ÄÚ²¿´°ÌåÃæ°å
    NothJPanel northPanel=null;//Äϲ¿Ãæ°å
    JPanel centerPanel=null;//Öв¿Ãæ°å
    JButtonModel jbut=null;//°´Å¥Ä£ÐÍ
    JTextField searchFileld=null;//ËÑË÷Îı¾¿ò
    JButtonModel search=null;//ËÑË÷°´Å¥
    JButtonModel shuaxin=null;//ˢа´Å¥
    JButtonModel add=null;//ÐÂÔö°´Å¥
    JButtonModel alter=null;//Ð޸İ´Å¥
    JButtonModel delete=null;//ɾ³ý°´Å¥
    JButtonModel deleteAll=null;//È«²¿É¾³ý°´Å¥
    JButtonModel enterPort=null;//µ¼ÈëÈËÔ±°´Å¥
    OutButton outbt=new OutButton();
    JButtonModel download=null;//Ä£°åÏÂÔØ°´Å¥
    JScrollPane gd=null;//¹ö¶¯Ãæ°å
    JTable table=null;//ÉêÃ÷±í¸ñ
    Vector rowData=new Vector();;
    DefaultTableModel tableModel=null;//ÉùÃ÷±í¸ñÄ£ÐÍ
    List list=null;
    int selectedRow;//±»Ñ¡ÖеÄÐÐ
    String departMent;//±êÇ©ËùÊôµÄ²¿ÃÅ
    Container rq;
    JComboBox<String> bumenComboBox2=null;//²¿ÃÅÑ¡ÔñÏÂÀ­Áбí¿ò
    public PersonManage() {//¹¹Ôì·½·¨
        String title="ÈËÔ±¹ÜÀí";
        if(Systems.sys().getLanguage().equals("English")) {
            title="Personnel management";
        }
        this.setTitle(title);
        rq=getContentPane();//»ñÈ¡ÈÝÆ÷
        rq.setLayout(new BorderLayout());
        rq.setBackground(Color.white);
        rq.add(getGd(),BorderLayout.CENTER);
        rq.add(getNorthPanel(),BorderLayout.NORTH);
        this.setFrameIcon(new ImageIcon("image/icon/renyuanicon.png"));//ÉèÖô°Ìåͼ±ê        
 
    }
    
    
 
    /**»ñÈ¡Äϲ¿Ãæ°åµÄ·½·¨*/    
    public NothJPanel getNorthPanel() {
        if(northPanel==null) {
            northPanel=new NothJPanel();
            Box topicBox = Box.createHorizontalBox();// ´´½¨Ò»¸öˮƽÏäÈÝÆ÷
            topicBox.add(getBumenComboBox2());
            topicBox.add(Box.createHorizontalStrut(10));
            topicBox.add(getSearchFileld());//Ìí¼ÓËÑË÷Îı¾¿ò            
            topicBox.add(Box.createHorizontalStrut(3));// Ìí¼ÓÒ»¸ö3ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getSearch());//Ìí¼ÓËÑË÷°´Å¥
            topicBox.add(Box.createHorizontalStrut(10));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getShuaxin());//Ìí¼Óˢа´Å¥
//            topicBox.add(Box.createHorizontalStrut(5));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù
//            topicBox.add(getAdd());//Ìí¼ÓÐÂÔö°´Å¥
            topicBox.add(Box.createHorizontalStrut(10));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getAlter());//Ìí¼ÓÐ޸İ´Å¥
            topicBox.add(Box.createHorizontalStrut(10));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getDelete());//Ìí¼Óɾ³ý°´Å¥
            topicBox.add(Box.createHorizontalStrut(10));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getDeleteAll());//Ìí¼Óɾ³ýÈ«²¿°´Å¥
            topicBox.add(Box.createHorizontalStrut(10));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getEnterPort());//Ìí¼Óµ¼ÈëÈËÔ±°´Å¥
            topicBox.add(Box.createHorizontalStrut(10));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getOutport());//Ìí¼Óµ¼³ö±í¸ñ°´Å¥
            topicBox.add(Box.createHorizontalStrut(10));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getDownload());//Ìí¼ÓÏÂÔØÄ£°å°´Å¥
            northPanel.add(topicBox );
        }
        return northPanel;
    }
    /**»ñÈ¡Öв¿Ãæ°åµÄ·½·¨*/    
    public JPanel getCenterPanel() {
        if(centerPanel==null) {
            centerPanel=new JPanel();
            centerPanel.add(getGd());//Ìí¼Ó¹ö¶¯Ãæ°å
            centerPanel.setBackground(Color.WHITE);
 
        }
        return centerPanel;
    }
    /**»ñÈ¡ËÑË÷Îı¾¿òµÄ·½·¨*/
    public JTextField getSearchFileld() {
        if(searchFileld==null){
            searchFileld=new JTextField(10);
            searchFileld.addKeyListener(new KeyListener() {    //¼üÅÌʼþ¼àÌý                
                public void keyTyped(KeyEvent e) {                
                    
                }                    
                public void keyReleased(KeyEvent e) {
                    int keyCode=e.getKeyCode();
                    if(keyCode==KeyEvent.VK_ENTER) {
                        getSearch().doClick();//ËÑË÷°´Å¥±»µã»÷
                    }                        
                }                    
                public void keyPressed(KeyEvent e) {                    
                    
                }
            });
 
        }
        return searchFileld; 
    }
    
    
    
    /**»ñȡѡÔñ²¿ÃÅÏÂÀ­¿ò*/
    public JComboBox<String> getBumenComboBox2() {
        if(bumenComboBox2==null) {                        
            bumenComboBox2=new JComboBox<>();//´´½¨ÏÂÀ­¿ò¶ÔÏó
            bumenComboBox2.setFont(new Font("΢ÈíÑźÚ", Font.PLAIN, 14));//ÉèÖÃ×ÖÌå
            ComboBoxModel<String > coModel=new DefaultComboBoxModel<>(BuMens.getBumenNames2());//ÏÂÀ­ÁбíÄ£ÐÍ
            bumenComboBox2.setModel(coModel);
            bumenComboBox2.updateUI();//¸üÐÂUI
            bumenComboBox2.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    String text=(String) bumenComboBox2.getSelectedItem();
                    if(text.equals("Ñ¡Ôñ²¿ÃÅ")) {
                        updateTable();
                    }else {
                        updateSerch(text);
                    }
                            
                }
            });
        }
 
        return bumenComboBox2;
    }
    
    /**»ñÈ¡ËÑË÷°´Å¥µÄ·½·¨*/    
    public JButtonModel getSearch() {
        if(search==null){
            search=new JButtonModel(buttonTitle.getSerch());
            search.addActionListener(new ActionListener() {    
                public void actionPerformed(ActionEvent e) {                
                    if(getSearchFileld().getText().length()>=1) {
                        String go=getSearchFileld().getText().trim();
                        updateSerch(go);
                    }else {
                        ShowMessage.zidingyi("ÊäÈëµÄËÑË÷ÄÚÈݲ»ÄÜΪ¿Õ");
                    }
                }
            });
 
        }
        return search;
    }
    
    /**ËÑË÷·½·¨*/
    public void updateSerch(String serch) {    
        if(person_Dell.serch(serch).size()==0) {
            ShowMessage.zidingyi("ÄãËÑË÷µÄ"+serch+"²»´æÔÚ£¡");
            return;
        }
        int tagnum=getTable().getRowCount();//±í¸ñ×ÜÐÐÊý
        if(tagnum !=0 ) {
            for (int i = 0; i < tagnum; i++) {//ɾ³ýËùÓÐÐР               
                tableModel.removeRow(0);                            
            }            
        }
        getRowData(person_Dell.serch(serch));
    }
    
    /**»ñȡˢа´Å¥µÄ·½·¨*/    
    public JButtonModel getShuaxin() {
        if(shuaxin==null){
            shuaxin=new JButtonModel(buttonTitle.getRefresh());
            shuaxin.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    updateTable() ;
                }
            });
 
        }
        return shuaxin;
    }
 
    /**»ñÈ¡ÐÂÔö°´Å¥µÄ·½·¨*/    
    public JButtonModel getAdd() {
        if(add==null){
            add=new JButtonModel(buttonTitle.getAddOne());
            add.setEnabled(false);
            add.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    new AddTagDialog("ÐÂÔöÈËÔ±¶Ô»°¿ò");
 
                }
            });
 
        }
        return add;
    }
    /**»ñÈ¡±í¸ñ±»Ñ¡ÖеÄÐз½·¨*/    
    public int getSelectedRow() {
        selectedRow=getTable().getSelectedRow();        
        return selectedRow;
 
    }
 
    /**»ñÈ¡Ð޸İ´Å¥µÄ·½·¨*/    
    public JButtonModel getAlter() {
 
 
        /**ÐÞ¸ÄÈËÔ±¶Ô»°¿ò*/
        class  alertDiolog extends AddTagDialog{
 
            /**
             * 
             */
            private static final long serialVersionUID = 1L;
 
            public alertDiolog(String title) {
                super(title);
            }
            
 
            public JTextField getSnameFile() {//ÖØÐ´ÁË»ñÈ¡ÐÕÃûµÄÎı¾¿ò
                if(snameFile==null) {
                    snameFile=new JTextField(8);                    
                    Object name=getTable().getValueAt(getSelectedRow(), 1);
                    snameFile.setText((String) name);
 
                }
                return snameFile;
            }
            //ÖØÐ´µç»°Îı¾¿ò
            public JTextField getPhoneNumFile() {
                if(phoneNumFile==null) {
                    phoneNumFile=new JTextField(12);
                    Object phone=getTable().getValueAt(getSelectedRow(), 5);
                    phoneNumFile.setText((String) phone);
                }
                return phoneNumFile;
            }
            /**»ñÈ¡±¸×¢Îı¾¿ò*/
            public JTextField getBeizhuFile() {
                if(beizhuFile==null) {
                    beizhuFile=new JTextField(12);
                    Object beizhu=getTable().getValueAt(getSelectedRow(), 6);
                    beizhuFile.setText((String) beizhu);
                }
                return beizhuFile;
            }    
 
 
            /**»ñȡѡÔñ±êÇ©ÏÂÀ­¿ò*/
            
            public  JTextField get_tag_field() {    
 
                if(tag_field==null) {                        
                    tag_field=new JTextField(8);
                    String tagID=(String) getTable().getValueAt(getSelectedRow(), 2);//±»Ñ¡ÖеÄIDºÅ
                    tag_field.setFont(new Font("΢ÈíÑźÚ", Font.PLAIN, 12));//ÉèÖÃ×ÖÌå
                    tag_field.setText(tagID);
                    tag_field.setEnabled(false);
                }
 
                return tag_field;
            }
 
            /**ÐÞ¸Ä±í·½·¨*/
            public void setUpadateSql(){
                // Ö´ÐÐSQL²éѯÓï¾ä»ñµÃµÄ½á¹û¼¯Èç¹û±êÇ©ÒѾ­´æÔÚÔò²»ÔÙÖ´ÐÐÏÂÃæµÄÓï¾ä
                String tagid=(String) getTable().getValueAt(getSelectedRow(), 2);
                String name=getName();
                String sex=getSelectedSex();
                String bumen=getDePartMent();
                String phone=getPhoneNumText();
                String time=GetNowTime.now();                
                String[] ziduan= {"p_name","p_department","p_sex","p_phone","p_addtiem","p_tagid"};
                String[] zhi= {name,bumen,sex,phone,time,tagid};
                if(DatabaseManagement.fast_alert_dbase("tb_person", ziduan, zhi)) {                    
                    person_Dell.alert_person(tagid, bumen, name, sex, phone);
                    getShuaxin();
                    ShowMessage.zidingyi(tagid+","+name+"Ð޸ijɹ¦£¡");
                }else {
                    ShowMessage.zidingyi(tagid+"ÐÞ¸Äʧ°Ü£¡");
                }
                
            }             
        }         
 
        if(alter==null){
            alter=new JButtonModel(buttonTitle.getAlert());
            alter.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    if(getSelectedRow()  !=-1) {//Èç¹ûÑ¡ÖеÄÐв»Îª¿Õ
                        new alertDiolog("ÐÞ¸ÄÈËÔ±¶Ô»°¿ò");
                    }
                    else {
                        ShowMessage.chooseRow(buttonTitle.getAlert());
                        return;
                    }
 
                }
            }); 
 
        }
        return alter;
    }
    /**»ñȡɾ³ý°´Å¥µÄ·½·¨*/    
    public JButtonModel getDelete() {
        if(delete==null){
            delete=new JButtonModel(buttonTitle.getDelete());
            delete.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    int[] selectedRows=table.getSelectedRows();//±»Ñ¡ÖÐÐеÄË÷Òý¼¯ºÏ
                    if(selectedRows.length !=0) {
                        for(int i=0;i<selectedRows.length;i++){                                
                            String tagid=(String) table.getValueAt(selectedRows[i], 2);                            
                            //½«±êÇ©Êý¾Ý±íÖеÄ״̬ÐÞ¸ÄΪ·ñ
                            String deleteSql="DELETE FROM tb_person WHERE p_tagid='"+tagid+"'";                            
                            if (DatabaseManagement.update(deleteSql)!=0) {
                                String update="UPDATE tb_tag SET state='δ°ó¶¨'  where tag_id='"+tagid+"'";
                                DatabaseManagement.update(update);
                                person_Dell.remove_person(tagid);
                                
                            }// Ð޸ıêÇ©ÐÅÏ¢    
                        }
                        //ɾ³ý³É¹¦ÌáʾÐÅÏ¢
                        ShowMessage.delteSuccess(selectedRows.length);                    
                        updateTable();//ˢбí¸ñ 
 
                    }
                    else {
                        ShowMessage.chooseRow(buttonTitle.getDelete());                
                    }
 
                }
            });
 
        }
        return delete;
    }
    /**»ñȡȫ²¿É¾³ý°´Å¥µÄ·½·¨*/    
    public JButtonModel getDeleteAll() {
        if(deleteAll==null){
            deleteAll=new JButtonModel(buttonTitle.getDeleteall());
            deleteAll.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    //Ñ¡Ôñ¶Ô»°¿òÈçyes·µ»Ø0£¬NO·µ»Ø1£¬È¡Ïû·µ»Ø2
                    WarningMessage warning=new WarningMessage();
                    warning.setMessage("Ñ¡Ôñɾ³ýÈ«²¿½«»á°Ñ±í¸ñÊý¾ÝÈ«²¿É¾³ýÈ·¶¨Âð£¿");
                    int warn=warning.getwarMss(getCenterPanel());
                    int tagnum=table.getRowCount();//±í¸ñ×ÜÐÐÊý
                    if(tagnum!=0 && warn==0) {
                        String deleteSql="TRUNCATE TABLE tb_person";
                        DatabaseManagement.update(deleteSql);// É¾³ýËùÓмǼ
                        String update="UPDATE tb_tag SET state='δ°ó¶¨' ";
                        ShowMessage.deleteAll(DatabaseManagement.update(update));
                        person_Dell.removall_person();
                        rq.repaint();
                    }
                }
            });
 
        }
        return deleteAll;
    }
    /**»ñÈ¡µ¼ÈëÈËÔ±°´Å¥µÄ·½·¨*/    
    public JButtonModel getEnterPort() {
        if(enterPort==null){
            enterPort=new JButtonModel(buttonTitle.getImport());
            enterPort.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    WarningMessage warning=new WarningMessage();
                    warning.setMessage("µ¼ÈëÊý¾Ý±ØÐëÏÈÏÂÔØÄ£°å£¬Ïȵã»÷ÏÂÔØÄ£°å°´¼üÏÂÔØ±í¸ñÄ£°å\nÄãÊÇ·ñÒѾ­ÏÂÔØÄ£°å²¢ÇÒ°´ÕÕÄ£°å¸ñʽÌîдÊý¾ÝÁË£¿");
                    int warn=warning.getwarMss(getCenterPanel());
                    if( warn==0) {
                    new ImExport().excelPersonToMysql(getNorthPanel());
                    updateTable();//ˢбí¸ñ 
                    }
                }
            });
 
        }
        return enterPort;
    }
    /**»ñÈ¡µ¼³ö±í¸ñ°´Å¥µÄ·½·¨*/    
    public JButtonModel getOutport() {
        OutButton.setAddtime("addtime");
        OutButton.setDataName("tb_person");
        return new OutButton().get_ouotport_button();        
        
    }
    /**»ñÈ¡ÏÂÔØÄ£°å°´Å¥µÄ·½·¨*/    
    public JButtonModel getDownload() {
        if(download==null){
            download=new JButtonModel(buttonTitle.getTemplate());
            download.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {;
                    DownloadFile dw=new DownloadFile();
                    dw.dowPersonFile(getNorthPanel());
                    
                }
            });
 
        }
        return download;
    }
    /**»ñÈ¡¹ö¶¯Ãæ°åµÄ·½·¨*/    
    public JScrollPane getGd() {
        if(gd==null){
            gd=new JScrollPane(getTable());
            gd.getViewport().setBackground(UIColor.getNorth_color());
 
        }
        return gd;
    }
    
    
    /**»ñÈ¡ÈËÔ±±í¸ñµÄ·½·¨*/    
    @SuppressWarnings({ "serial"})
    public JTable getTable() {
        if(table==null) {
            String[] name1= {"ÐòºÅ","ÐÕÃû","±êÇ©ID","ÐÔ±ð","²¿ÃÅ","µç»°","µçÁ¿(%)","ͼ±ê","״̬","ÐÄÂÊ","Ìí¼Óʱ¼ä"};//±í¸ñÁÐÃû
            String[] name2= {"Serial Number", "Name", "Tag ID", "Sex", 
                    "Department", "Phone", "Battery (%)", "Icon","HEART", "AddTime"};//±í¸ñÁÐÃû
            String[] columnNames=English.columnNames(name1, name2);
            //Ìí¼Ó±í¸ñÁÐÏòÁ¿
            Vector<String> columnName=new Vector<>();
            for(int i=0;i<columnNames.length;i++){
                columnName.add(columnNames[i]);            
            }
            
            //Ìí¼Ó±í¸ñÐÐÏòÁ¿Êý¾Ý            
            greateTables tables=new greateTables();
            tableModel=new DefaultTableModel(rowData, columnName){ 
                //  ÊµÏÖÈÃÕû¸ö±í¸ñ²»²»ÔÊÐí±»±à¼­
                public boolean isCellEditable(int row,int column){  
                    return false;  
                }  
            };
 
            table=tables.getTable(tableModel);    
            getRowData(person_Dell.getPerson_vector());
            table.setRowHeight(40);//ÉèÖñí¸ñÐиß
            
            //´úÂëΪÈñí¸ñÏÔʾͼƬ
            TableColumn column = table.getColumnModel().getColumn(7);// »ñÈ¡±í¸ñµÚ8ÁжÔÏó            
            column.setCellRenderer(new TableCellRenderer() {// ÉèÖõÚ3ÁеÄäÖȾÆ÷                
                public Component getTableCellRendererComponent(
                    JTable table, Object value, boolean isSelected,
                    boolean hasFocus, int row, int column) {
                    ImageIcon icon = (ImageIcon) value;
                    JLabel label = new JLabel(icon);// ´´½¨Í¼±ê
                 // °ÑÑ¡ÔñµÄ±êÇ©ÉèÖÃΪ͸Ã÷                    
                    label.setOpaque(true);                    
                    
                    if (row % 2 == 0) {
                        label.setBackground(UIColor.getTable_1());
                    } else {
                        label.setBackground(UIColor.getTable_2());
                    }
                    
                    if(isSelected) {
                        label.setBackground(UIColor.getTable_sekected());    
                    }
                    return label;// °Ñͼ±ê×÷ΪΪäÖȾ¿Ø¼þ
                }
            });
 
        }
        return table;
 
    }
 
    /**Ìí¼Ó±í¸ñÐÐÏòÁ¿Êý¾Ý·½·¨*/ 
    @SuppressWarnings("unchecked")
    public void getRowData(Vector<Person> person_vector ) {
        Iterator iterator =person_vector.iterator();//´´½¨µü´úÆ÷
        int i=0;
        while (iterator.hasNext()) {//µü´úÆ÷´æÔÚÔªËØ
            i++;
            Person info = (Person) iterator.next();//½«µü´úÆ÷ÀïÃæµÄÔªËØ¸øµ½info¼¯ºÏ
            Vector row = new Vector();
            row.add(String.valueOf(i));//ÐòºÅ
            row.add(info.getP_name());//ÐÕÃû
            row.add(info.getP_tagid());//±êÇ©id
            row.add(info.getP_sex());//ÐÔ±ð
            row.add(info.getP_department());//²¿ÃÅ
            row.add(info.getP_phone());//µç»°
            row.add(info.getP_power());//µçÁ¿
            row.add(info.getP_image());//ͼ±ê
            String zaixian="ÔÚÏß";
            if(info.getP_online().equals("0")) {
                zaixian="ÀëÏß";
            }        
            row.add(zaixian);//ÊÇ·ñÔÚÏß
            String baoliu16=info.getBaoliu16();
            if(baoliu16.equals("-1")) {
                baoliu16="δ֪";
            }
            row.add(baoliu16);//ÐÄÂÊ
            row.add(String.valueOf(info.getP_addtiem()));//Ìí¼Óʱ¼ä
            tableModel.addRow(row);// Ïò±í¸ñ¶ÔÏóÌí¼ÓÐÐÊý¾Ý
        }    
 
    }
 
    /**ˢбí¸ñ·½·¨*/
    /**ˢбí¸ñ·½·¨*/
    public void updateTable() {    
        if(tableModel !=null) {
        tableModel.getDataVector().clear();
        getRowData(person_Dell.getPerson_vector());
        gd.validate();
        }
    }
    
    
    
    /**¸ù¾ÝID»òÕßÐÕÃû»ñÈ¡ËùÔÚ²¿Ãŵķ½·¨*/
    public String getDepartMent(String tagid) {
        String serch="select * from tb_person where tag_id='"+tagid+"'or name='"+
                tagid+"'";
        list = DatabaseManagement.serch(serch);//½«ÁбíÖÐËùÓнá¹û¼¯¸øµ½list¼¯ºÏ
        Iterator iterator = list.iterator();//´´½¨µü´úÆ÷        
        while (iterator.hasNext()) {//µü´úÆ÷´æÔÚÔªËØ            
            List info = (List) iterator.next();//½«µü´úÆ÷ÀïÃæµÄÔªËØ¸øµ½list¼¯ºÏ                
            departMent=(String) info.get(3);
        }
        return departMent;        
    }
    
    /**ÐÂÔöÈËÔ±¶Ô»°¿ò*/
    class AddTagDialog extends JDialog{
 
        /**
         * 
         */
        private static final long serialVersionUID = 1L;
        JlableModel  tagId=null;//±êÇ©id    
        JlableModel  sname=null;//ÐÕÃû
        JlableModel  bumen=null;//²¿ÃÅ
        JlableModel  company=null;//²¿ÃÅ
        JlableModel  sex=null;//ÐÔ±ð
        JlableModel  phoneNum=null;//µç»°
        JlableModel  beizhu=null;//±¸×¢
        JButtonModel serchTag=null;//²éÕÒ±êÇ©
        JButtonModel sure=null;//È·¶¨°´Å¥
        JButtonModel quxiao=null;//È¡Ïû°´Å¥
        JRadioButton boy=null;//µ¥Ñ¡°´Å¥ÄÐ
        JRadioButton girl=null;//µ¥Ñ¡°´Å¥Å®
        ButtonGroup btgroup=null;//ÉêÃ÷°´Å¥×é
        JTextField tagIdFile=null;//±êÇ©idÎı¾¿ò
        JTextField snameFile=null;//ÐÕÃûÎı¾¿ò
        JTextField phoneNumFile=null;//µç»°ºÅÂëÎı¾¿ò
        JTextField beizhuFile=null;//±¸×¢Îı¾¿ò        
        JTextField tag_field=null;//»ñÈ¡±êÇ©µÄÎı¾¿ò 
        JTextField Company=null;//»ñÈ¡±êÇ©µÄÎı¾¿ò
        JPanel mb=null;//ÉêÃ÷Ò»¸öÃæ°å
        JComboBox<String> bumenComboBox=null;
        JComboBox<String> companyComboBox=null;
 
        /**¹Ø±Õ¶Ô»°¿ò·½·¨*/
        public void closeTagDialog() {
            this.dispose();
 
        }
        /**»ñÈ¡¶Ô»°¿ò·½·¨*/
        public AddTagDialog(String title) {        
            super();    
            this.setAlwaysOnTop(true);//×ÜÊÇÖö¥
            this.setTitle(title);
            Toolkit toolkit = getToolkit();// »ñµÃ´°Ì幤¾ß°ü
            Dimension screenSize = toolkit.getScreenSize();// »ñÈ¡ÆÁÄ»´óС
            int width = (int) (screenSize.width* 0.5);// ¼ÆËã´°Ìåпí¶È
            int height = (int) (screenSize.height * 0.5);// ¼ÆËã´°Ìåпí¶È
            int x0=width-160;//´°Ìåx0×ø±ê
            int y0=height-160;//´°Ìåy0×ø±ê
            Container rq=getContentPane();        
            rq.add(getMb());
            this.setBounds(x0, y0, 320, 360);
            this.setVisible(true);
        }
 
 
        public JPanel getMb() {
            btgroup=new ButtonGroup();
            btgroup.add(getBoy());
            btgroup.add(getGirl());
            if(mb==null){
                mb=new JPanel();
                mb.setLayout(new GridLayout(8, 1,10,10));
                JPanel mb1=new JPanel();    
                mb1.setLayout(new FlowLayout(FlowLayout.LEFT));
                JPanel mb2=new JPanel();
                mb2.setLayout(new FlowLayout(FlowLayout.LEFT));
                JPanel mb3=new JPanel();    
                mb3.setLayout(new FlowLayout(FlowLayout.LEFT));
                JPanel mb4=new JPanel();    
                mb4.setLayout(new FlowLayout(FlowLayout.LEFT));
                JPanel mb5=new JPanel();    
                mb5.setLayout(new FlowLayout(FlowLayout.LEFT));
                JPanel mb6=new JPanel();    
                mb6.setLayout(new FlowLayout(FlowLayout.LEFT));
                JPanel mb8=new JPanel();
                mb8.setLayout(new FlowLayout(FlowLayout.LEFT));
                JPanel mb7=new JPanel();
                mb8.add(getCompany());
                mb8.add(getCompanyComboBox());
                mb1.add(getTagId());
                mb1.add(get_tag_field());
                mb2.add(getSname());
                mb3.add(getBumen());
                mb2.add(getSnameFile());
                mb3.add(getBumenComboBox());
                mb4.add(getSex());
                mb4.add(getBoy());
                mb4.add(getGirl());
                mb5.add(getPhoneNum());
                mb5.add(getPhoneNumFile());
                mb6.add(getBeizhu());
                mb6.add(getBeizhuFile());
                mb7.add(getSure());
                mb7.add(getQuxiao());
                mb.add(mb1);
                mb.add(mb2);
                mb.add(mb3);
                mb.add(mb4);
                mb.add(mb5);
                mb.add(mb6);
                mb.add(mb8);
                mb.add(mb7);
            }
 
            return mb;
        }
 
        public JlableModel getTagId() {
            if(tagId==null) {
                tagId=new JlableModel();
                tagId.setText("   ±êÇ©ID: ");
 
            }
            return tagId;
        }
 
        public JlableModel getSname() {
            if(sname==null) {
                sname=new JlableModel();
                sname.setText("   ÐÕ    Ãû: ");
 
            }
            return sname;
        }
 
        public JlableModel getBumen() {
            if(bumen==null) {
                bumen=new JlableModel();
                bumen.setText("   ²¿    ÃÅ: ");            
            }
            return bumen;
        }
        /**»ñÈ¡ÐÔ±ðÄе¥Ñ¡°´Å¥*/
        public JRadioButton getBoy() {
            if(boy==null) {
                boy=new JRadioButton("ÄÐ");    
                boy.setSelected(true);//ĬÈÏÄб»Ñ¡ÖÐ
            }
            return boy;
        }
        /**»ñÈ¡ÐÔ±ðÅ®µ¥Ñ¡°´Å¥*/
        public JRadioButton getGirl() {
            if(girl==null) {
                girl=new JRadioButton("Å®");
            }
            return girl;
        }
 
 
        public JlableModel getCompany() {
            if(company==null) {
                company=new JlableModel();
                company.setText("   ¹«    Ë¾: ");
            }
            return company;
        }
 
        /**»ñȡѡÔñ¹«Ë¾ÏÂÀ­¿ò*/
        public JComboBox<String> getBumenComboBox() {
            if(bumenComboBox==null) {                        
                bumenComboBox=new JComboBox<>();//´´½¨ÏÂÀ­¿ò¶ÔÏó
                bumenComboBox.setFont(new Font("΢ÈíÑźÚ", Font.PLAIN, 12));//ÉèÖÃ×ÖÌå            
                ComboBoxModel<String > coModel=new DefaultComboBoxModel<>(BuMens.getBumenNames());//ÏÂÀ­ÁбíÄ£ÐÍ            
                bumenComboBox.setModel(coModel);
                bumenComboBox.setEditable(true);
            }
 
            return bumenComboBox;
        }
 
        /**»ñȡѡÔñ¹«Ë¾ÏÂÀ­¿ò*/
        public JComboBox<String> getCompanyComboBox() {
            if(companyComboBox==null) {
                companyComboBox=new JComboBox<>();//´´½¨ÏÂÀ­¿ò¶ÔÏó
                companyComboBox.setFont(new Font("΢ÈíÑźÚ", Font.PLAIN, 12));//ÉèÖÃ×ÖÌå
                ComboBoxModel<String > coModel=new DefaultComboBoxModel<>(Dell_tbCompany.getcompanyNames());//ÏÂÀ­ÁбíÄ£ÐÍ
                companyComboBox.setModel(coModel);
                companyComboBox.setEditable(true);
            }
            return companyComboBox;
        }
 
        public JlableModel getSex() {
            if(sex==null) {
                sex=new JlableModel();
                sex.setText("   ÐÔ    ±ð: ");            
            }
            return sex;
        }
 
        public JlableModel getPhoneNum() {
            if(phoneNum==null) {
                phoneNum=new JlableModel();
                phoneNum.setText("   µç    »°: ");            
            }
            return phoneNum;
        }
 
        public JlableModel getBeizhu() {
            if(beizhu==null) {
                beizhu=new JlableModel();
                beizhu.setText("   ±¸    ×¢: ");            
            }
            return beizhu;
        }
 
        /**»ñÈ¡±êÇ©Îı¾¿òIDµÄ·½·¨*/
        public String getTagID() {
            String tagId=get_tag_field().getText();//»ñÈ¡±êÇ©id
            return tagId;
 
        }
 
        /**»ñÈ¡±êÇ©Îı¾¿òÐÕÃûµÄ·½·¨*/
        public String getName(){
            String name=getSnameFile().getText().trim();//»ñÈ¡ÐÕÃû
            return name;        
        }
 
        /**»ñÈ¡²¿ÃÅÎı¾¿ò²¿Ãŵķ½·¨*/
        public String getDePartMent() {
            String dePartMent=(String) getBumenComboBox().getSelectedItem();//»ñÈ¡²¿ÃÅ
            return dePartMent;        
        }
 
        /**»ñÈ¡µç»°ºÅÂëÎı¾¿òºÅÂëµÄ·½·¨*/
        public String getPhoneNumText() {
            String phoneNum=getPhoneNumFile().getText().trim();//»ñÈ¡µç»°
            return phoneNum;        
        }
 
        /**»ñÈ¡ÐÔ±ðµÄ·½·¨*/
        public String getSelectedSex() {
            String sex="ÄÐ";
            if(getGirl().isSelected()) {
                sex="Å®";
            }
            return sex;        
        }
 
        /**»ñÈ¡±¸×¢Îı¾¿òÄÚÈݵķ½·¨*/
        public String getBeizhuText() {
            String beizhu=getBeizhuFile().getText().trim();//»ñÈ¡±¸×¢ÐÅÏ¢
            return beizhu;        
        }
 
        /**»ñȡȷ¶¨°´Å¥*/
        public JButtonModel getSure() {
            if(sure==null) {
                sure=new JButtonModel("È·¶¨");
                sure.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        if(getTagID() .equals("")) {
                            ShowMessage.zidingyi("±êÇ©ID²»ÄÜΪ¿Õ");
                            return;
                        }
 
                        if(getName().equals("")||getName().length()>4) {
                            ShowMessage.zidingyi("¼ì²éÐÕÃûÊÇ·ñΪ¿Õ»òÕß³¤¶È´óÓÚ4£¡");
                            return;
                        }
 
                        if(getPhoneNumText().length()>11) {
                            ShowMessage.zidingyi("µç»°ºÅÂë¹ý³¤Çë¼ì²é£¡");
                            return;
                        }
 
                        if(getBeizhuText().length()>15) {
                            ShowMessage.zidingyi("±¸×¢ÐÅÏ¢¹ý³¤ÇëÐ޸ģ¡");
                            return;
                        }
 
                        setUpadateSql();                    
                        String update="UPDATE tb_tag SET state='"+getName()+"'  where tag_id='"+getTagID()+"'";
                        DatabaseManagement.update(update);// Ð޸ıêÇ©ÐÅÏ¢
                        updateTable() ;
 
                    }
                });
            }
 
            return sure;
        }
 
        /**ÐÞ¸Ä±í·½·¨*/
        public void setUpadateSql(){
            // Ö´ÐÐSQL²éѯÓï¾ä»ñµÃµÄ½á¹û¼¯Èç¹û±êÇ©ÒѾ­´æÔÚÔò²»ÔÙÖ´ÐÐÏÂÃæµÄÓï¾ä
            ResultSet haveTag = DatabaseManagement.query("select * from tb_person where tag_id='"+getTagID()+"'");
            try {
                if (haveTag.next()) {// ½á¹û¼¯ÖбêÇ©IDÓг¬¹ýÒ»ÌõµÄ¼Ç¼
                    ShowMessage.zidingyi("±êÇ©Ìí¼Óʧ°Ü"+getTagID()+"±êÇ©ÒѾ­´æÔÚ£¡");
                    return;
                }
            } catch (Exception er) {
                er.printStackTrace();
            }                
            String updateSQL="INSERT tb_person (id,tag_id,name,departmentName,sex,phonenum,addtime,remark) VALUES (default,'"+
                    getTagID()+"','"+getName()+"','"+getDePartMent()+"','"+getSelectedSex()+"','"+
                    getPhoneNumText()+"','"+GetNowTime.now2()+"','"+getBeizhuText()+"')";
            DatabaseManagement.update(updateSQL);// Ìí¼Ó±êÇ©ÐÅÏ¢
            
            //Ìí¼Ó³É¹¦ÌáʾÐÅÏ¢
            ShowMessage.zidingyi("Ìí¼Ó³É¹¦£¡");
            //±êÇ©Ìí¼Ó³É¹¦ºóÐèÒªÐ޸ıêÇ©µÄʹÓÃ״̬ΪÊÇ
 
        }
 
 
        /**»ñȡȡÏû°´Å¥*/
        public JButtonModel getQuxiao() {
            if(quxiao==null) {
                quxiao=new JButtonModel("È¡Ïû");
                quxiao.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        closeTagDialog();
                    }
                });
            }
            return quxiao;
        }
 
        public JTextField getSnameFile() {
            if(snameFile==null) {
                snameFile=new JTextField(8);
            }
            return snameFile;
        }
 
        public JTextField getPhoneNumFile() {
            if(phoneNumFile==null) {
                phoneNumFile=new JTextField(12);
                phoneNumFile.setText("1234*******");
            }
            return phoneNumFile;
        }
        /**»ñÈ¡±¸×¢Îı¾¿ò*/
        public JTextField getBeizhuFile() {
            if(beizhuFile==null) {
                beizhuFile=new JTextField(12);
            }
            return beizhuFile;
        }
 
        /**»ñȡѡÔñ±êÇ©ÏÂÀ­¿ò*/
        public JTextField  get_tag_field() {    
 
            if(tag_field==null) {                        
                tag_field=new JTextField(10);//´´½¨ÏÂÀ­¿ò¶ÔÏó
                tag_field.setFont(new Font("΢ÈíÑźÚ", Font.PLAIN, 12));//ÉèÖÃ×ÖÌå          
            }
 
            return tag_field;
        }
 
    }
 
}