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
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.Font;
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.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
import javax.swing.Box;
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.JPanel;
import javax.swing.JProgressBar;
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 DataBase.DatabaseManagement;
import Method.GetNowTime;
import Method.IpIsTrue;
import PbuliClass.BuMens;
import PbuliClass.Get_Tb_Gass;
import PbuliClass.Get_collectors;
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 anchor.Anchor_Dell;
import tbDataModel.TbGas;
@SuppressWarnings("rawtypes")
public class GasManage 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;//È«²¿É¾³ý°´Å¥
    JScrollPane gd=null;//¹ö¶¯Ãæ°å
    JTable table=null;//ÉêÃ÷±í¸ñ
    Vector rowData=null;
    DefaultTableModel tableModel=null;//ÉùÃ÷±í¸ñÄ£ÐÍ
    List list=null;
    int selectedRow;//±»Ñ¡ÖеÄÐÐ
    String departMent;//±êÇ©ËùÊôµÄ²¿ÃÅ
    BuMens bums;
    AddGasMac addgas=null;
    AlertGasMac alertgas=null;
    Container rq;
    
    
    public GasManage() {//¹¹Ôì·½·¨
        String title="ÆøÌå´«¸ÐÆ÷¹ÜÀí";
        if(Systems.sys().getLanguage().equals("English")) {
            title="Gas sensor management";
        }
        this.setTitle(title);
        rq=getContentPane();//»ñÈ¡ÈÝÆ÷
        bums=new BuMens();
        rq.setLayout(new BorderLayout());
        rq.setBackground(Color.white);
        rq.add(getGd(),BorderLayout.CENTER);
        rq.add(getNorthPanel(),BorderLayout.NORTH);
        this.setFrameIcon(new ImageIcon("image/icon/gas.png"));//ÉèÖô°Ìåͼ±ê        
 
    }
 
 
 
    /**»ñÈ¡Äϲ¿Ãæ°åµÄ·½·¨*/    
    public NothJPanel getNorthPanel() {
        if(northPanel==null) {
            northPanel=new NothJPanel();
            Box topicBox = Box.createHorizontalBox();// ´´½¨Ò»¸öˮƽÏäÈÝÆ÷
            topicBox.add(getSearchFileld());//Ìí¼ÓËÑË÷Îı¾¿ò
            topicBox.add(Box.createHorizontalStrut(3));// Ìí¼ÓÒ»¸ö3ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getSearch());//Ìí¼ÓËÑË÷°´Å¥
            topicBox.add(Box.createHorizontalStrut(5));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getShuaxin());//Ìí¼Óˢа´Å¥
            topicBox.add(Box.createHorizontalStrut(5));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getAdd());//Ìí¼ÓÐÂÔö°´Å¥
            topicBox.add(Box.createHorizontalStrut(5));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(get_alter());//Ìí¼Óɾ³ý°´Å¥
            topicBox.add(Box.createHorizontalStrut(5));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getDelete());//Ìí¼Óɾ³ý°´Å¥
            topicBox.add(Box.createHorizontalStrut(5));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getDeleteAll());//Ìí¼Óɾ³ýÈ«²¿°´Å¥
            topicBox.add(Box.createHorizontalStrut(5));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù
            topicBox.add(getOutport());//Ìí¼Óµ¼³ö±í¸ñ°´Å¥
            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 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 serch=getSearchFileld().getText().trim();
                        updateSerch(serch);    
                    }
                }
            });
 
        }
        return search;
    }
 
    /**ËÑË÷·½·¨*/
    public void updateSerch(String serch) {    
        if(Anchor_Dell.serch_anchor(serch)==null) {
            ShowMessage.zidingyi("Ö÷ÈËÄãËÑË÷"+serch+"²»´æÔÚ...");
            return;
        }
        int tagnum=table.getRowCount();//±í¸ñ×ÜÐÐÊý
        if(tagnum >0 ) {
            for (int i = 0; i < tagnum; i++) {//ɾ³ýËùÓÐÐÐ
                tableModel.removeRow(0);                            
            }
            //½«ÁбíÖÐËùÓнá¹û¼¯¸øµ½list¼¯ºÏ
            
        }
 
    }
 
    /**»ñȡˢа´Å¥µÄ·½·¨*/    
    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.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    if(addgas==null) {
                        addgas=new AddGasMac("ÐÂÔöÆøÌå´«¸ÐÆ÷¶Ô»°¿ò");
                    }
 
                }
            });
 
        }
        return add;
    }
 
    /**»ñÈ¡±í¸ñ±»Ñ¡ÖеÄÐз½·¨*/    
    public int getSelectedRow() {
        selectedRow=getTable().getSelectedRow();        
        return selectedRow;
 
    }
 
    public JButtonModel get_alter() {
        if(alter==null){
            alter=new JButtonModel(buttonTitle.getAlert());
            alter.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {                    
                    if(selectedRow!=-1 && alertgas ==null) {
                        alertgas=new AlertGasMac("ÐÞ¸ÄÆøÌå¼ì²âÉ豸¶Ô»°¿ò£¡");
                    }else {
                    ShowMessage.zidingyi("ÇëÑ¡ÔñÐèÒªÐ޸ĵÄÐУ¡");
                    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 tongdao=(String) table.getValueAt(selectedRows[i], 6);
                            String collet=(String) table.getValueAt(selectedRows[i], 5);
                            String deleteSql="DELETE FROM tb_gas WHERE id='"+table.getValueAt(selectedRows[i], 0)+"'";
                            Get_Tb_Gass.delete_gas(tongdao,collet);
                            DatabaseManagement.update(deleteSql);// É¾³ý±êÇ©ÐÅÏ¢
                        }
                        //ɾ³ý³É¹¦ÌáʾÐÅÏ¢
                        ShowMessage.delteSuccess(selectedRows.length);        
                        //ɾ³ýËùÓб»Ñ¡ÖеÄÐÐ
                        for(int j=selectedRows.length-1;j>=0;j--){//ÕâÊǹؼü´úÂë
                            tableModel.removeRow(selectedRows[j]);//ɾ³ýÈÎÒⱻѡÖÐÐÐ
                        }
                        table.setModel(tableModel);//¸üбí¸ñÄ£ÐÍ
                        
                    }
                    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_gas";
                        Get_Tb_Gass.deleteall_gas();
                        DatabaseManagement.update(deleteSql);
                        ShowMessage.zidingyi("È«²¿É¾³ý³É¹¦£¡");    
                        rq.repaint();
                        updateTable();//ˢбí¸ñ 
                    }
                }
            });
 
        }
        return deleteAll;
    }
 
    /**»ñÈ¡µ¼³ö±í¸ñ°´Å¥µÄ·½·¨*/    
    public JButtonModel getOutport() {
        OutButton.setAddtime("addtime");
        OutButton.setDataName("tb_gas");
        return new OutButton().get_ouotport_button();        
 
    }
 
    /**»ñÈ¡¹ö¶¯Ãæ°åµÄ·½·¨*/    
    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= {"É豸±àºÅ", "°²×°Î»ÖÃ", "ÆøÌåÀàÐÍ", "Ũ¶ÈÖµ", "¸æ¾¯Çé¿ö", "²É¼¯ÒǵØÖ·",
                    "ËùÔÚͨµÀ", "¸æ¾¯ãÐÖµ", "IPµØÖ·", "X×ø±ê", "Y×ø±ê", "¸üÐÂʱ¼ä"};//±í¸ñÁÐÃû
            String[] name2= {"Equipment Number", "Installation Location",
                    "Gas Type", "Concentration Value", "Alarm Condition", 
                    "Collection Address","Current Channel", 
                    "Alarm Threshold", "IP", "X", "Y", "Time"};//±í¸ñÁÐÃû
            String[] columnNames=English.columnNames(name1, name2);
            //Ìí¼Ó±í¸ñÁÐÏòÁ¿
            Vector<String> columnName=new Vector<>();
            for(int i=0;i<columnNames.length;i++){
                columnName.add(columnNames[i]);            
            }
            //Ìí¼Ó±í¸ñÐÐÏòÁ¿Êý¾Ý 
            rowData=new Vector();            
            greateTables tables=new greateTables();
            tableModel=new DefaultTableModel(rowData, columnName){  
                //  ÊµÏÖÈÃÕû¸ö±í¸ñ²»²»ÔÊÐí±»±à¼­
                public boolean isCellEditable(int row,int column){  
                    return false;  
                }  
            };            
            table=tables.getTable(tableModel);
            getRowData(Get_Tb_Gass.get_gass() );
            
            table.getColumnModel().getColumn(1).setPreferredWidth(155);
            table.getColumnModel().getColumn(8).setPreferredWidth(100);
            table.getColumnModel().getColumn(11).setPreferredWidth(155);
            TableColumn column = table.getColumnModel().getColumn(4);// »ñÈ¡±í¸ñµÚ4ÁжÔÏó
            column.setCellRenderer(new TableCellRenderer() {// ÉèÖõÚ7ÁеÄäÖȾÆ÷                
                public Component getTableCellRendererComponent(
                        JTable table, Object value, boolean isSelected,
                        boolean hasFocus, int row, int column) {
                    JProgressBar bar=new JProgressBar();//´´½¨½ø¶ÈÌõ
                    bar.setBorderPainted(false);//ÊÇ·ñÏÔʾ½ø¶ÈÌõ±ß¿ò
                    bar.setBackground(Color.white);
                    bar.setValue(99);//ÉèÖýø¶ÈÌõµÄÖµ
                    if(value.equals("Õý³£")) {
                        bar.setForeground(Color.green);//ÏÔʾ½ø¶ÈÌõµÄÑÕÉ«
                        return bar;// °Ñͼ±ê×÷ΪΪäÖȾ¿Ø¼þ
                    }
                    else{
                        bar.setForeground(Color.red);//ÏÔʾ½ø¶ÈÌõµÄÑÕÉ«
                        return bar;// °Ñͼ±ê×÷ΪΪäÖȾ¿Ø¼þ
                    }
                }
            });
        }
        return table;
 
    }
 
    /**Ìí¼Ó±í¸ñÐÐÏòÁ¿Êý¾Ý·½·¨*/ 
    public void getRowData(Vector<TbGas> gasv ) {
        Iterator<TbGas> iterator = gasv .iterator();//´´½¨µü´úÆ÷        
        while (iterator.hasNext()) {//µü´úÆ÷´æÔÚÔªËØ            
            TbGas gas = iterator.next();//½«µü´úÆ÷ÀïÃæµÄÔªËØ¸øµ½info¼¯ºÏ
            Vector<String> row = new Vector<>();
            row.add(String.valueOf(gas.getId()));
            row.add(gas.getWei_zhi());
            row.add(gas.getGas_type());
            row.add(gas.getNong_du());
            row.add(gas.getStatus());
            row.add(gas.getCollect_ip());
            row.add(gas.getTong_dao());
            row.add(gas.getWaring_zhi());
            row.add(gas.getIp());
            row.add(gas.getX());
            row.add(gas.getY());
            row.add(gas.getAddtime());
            tableModel.addRow(row);
        }
    }
 
    /**ˢбí¸ñ·½·¨*/
    public void updateTable() {    
        if(tableModel !=null) {
        tableModel.getDataVector().clear();
        getRowData(Get_Tb_Gass.get_gass());
        gd.validate();
        }
    }
 
 
 
    /**ÐÂÔöÆøÌå¼ì²âÉ豸¶Ô»°¿ò*/
    class AddGasMac extends JDialog implements WindowListener{
 
        /**
         * 
         */
        private static final long serialVersionUID = 1L;
        JlableModel  id_label=null;
        JlableModel  gasid=null;//ËùÔÚͨµÀ
        JlableModel  gasName=null;//²É¼¯ÒǵØÖ·
        JlableModel  gastype=null;//´«¸ÐÆ÷ÀàÐÍ
        JlableModel  gasip=null;//É豸ip
        JlableModel  gas_x=null;//É豸°²×°X×ø±ê
        JlableModel  gas_y=null;//É豸°²×°Y×ø±ê
        JlableModel  warning=null;//É豸¸æ¾¯ãÐÖµ
 
        JButtonModel sure=null;//È·¶¨°´Å¥
        JButtonModel quxiao=null;//È¡Ïû°´Å¥
 
 
        JTextField gasid_File=null;
        JTextField id_File=null;
        JComboBox<String> gasName_box=null;
        JTextField gasip_File=null;
        JTextField gas_x_File=null;
        JTextField gas_y_File=null;
        JTextField warning_File=null;
 
        JComboBox<String> gastype_Box=null;//ÆøÌåÀàÐÍÑ¡ÔñÏÂÀ­Áбí
 
        JPanel mb=null;//ÉêÃ÷Ò»¸öÃæ°å
 
        /**¹Ø±Õ¶Ô»°¿ò·½·¨*/
        public void closeTagDialog() {
            this.dispose();
 
        }
        /**»ñÈ¡¶Ô»°¿ò·½·¨*/
        public AddGasMac(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-210;//´°Ìåx0×ø±ê
            int y0=height-180;//´°Ìåy0×ø±ê
            Container rq=getContentPane();        
            rq.add(getMb());
            this.setBounds(x0, y0,420,460);
            this.addWindowListener((WindowListener) this);
            this.setVisible(true);
        }
 
 
        public JPanel getMb() {
            if(mb==null){
                mb=new JPanel();
                mb.setLayout(null);
                getGasid().setBounds(40,20,100,25);
                getGasName().setBounds(40,60,100,25);
                getGastype().setBounds(40,100,100,25);
                getGasip().setBounds(40,140,100,25);
                getGas_x().setBounds(40,180,100,25);
                getGas_y().setBounds(40,220,100,25);
                getWarning().setBounds(40,260,100,25);
 
                getSure().setBounds(70,350,80,25);
                getQuxiao().setBounds(180,350,80,25);
 
                getGasid_File().setBounds(140,20,120,25);
                get_gasName_box().setBounds(140,60,120,25);
                get_gastype_Box().setBounds(140,100,120,25);
                getGasip_File().setBounds(140,140,120,25);
                getGas_x_File().setBounds(140,180,120,25);
                getGas_y_File().setBounds(140,220,120,25);
                getWarning_File().setBounds(140,260,120,25);
                getId_label().setBounds(40, 300, 80, 25);
                getId_File().setBounds(140, 300, 120, 25);
 
 
                mb.add(getGasid());
                mb.add(getGasName());
                mb.add(getGastype());
                mb.add(getGasip());
                mb.add(getGas_x());
                mb.add(getGas_y());
                mb.add(getWarning());
                mb.add(getSure());
                mb.add(getQuxiao());
                mb.add(getGasid_File());
                mb.add(get_gasName_box());
                mb.add(getGasip_File());
                mb.add(getGas_x_File());
                mb.add(getGas_y_File());
                mb.add(getWarning_File());
                mb.add(get_gastype_Box());
                mb.add(getId_label());
                mb.add(getId_File());
            }
            return mb;
        }
 
 
        /**»ñȡȷ¶¨°´Å¥*/
        public JButtonModel getSure() {
            if(sure==null) {
                sure=new JButtonModel("È·  ¶¨");
                sure.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        String tong_dao=getGasid_File().getText().trim();
                        if(tong_dao.equals("")) {
                            ShowMessage.zidingyi("ËùÔÚͨµÀ²»ÄÜΪ¿Õ");
                            return;
                        }
                        String collect_ip=(String) get_gasName_box().getSelectedItem();
                        if(collect_ip.length()>4) {
                            ShowMessage.zidingyi("²É¼¯ÒǵØÖ·²»ÄÜÌ«³¤£¡");
                            return;
                        }
                        String wei_zhi=Get_collectors.get_coleectr(collect_ip).getMacname();
                        String gas_type=(String) get_gastype_Box().getSelectedItem();
                        String nong_du="0";
                        String status="Õý³£";                        
                        String waring_zhi=getWarning_File().getText();
                        String ip=getGasip_File().getText().trim();
                        String x=getGas_x_File().getText().trim();
                        String y=getGas_y_File().getText().trim();
                        String id=id_File.getText().trim();
 
 
                        
 
                        
 
                        if(!IpIsTrue.ipCheck(ip)) {
                            ShowMessage.zidingyi("IPµØÖ·ÓдíÎó£¡");
                            return;
                        }
 
                        if(waring_zhi.equals("")) {
                            ShowMessage.zidingyi("¸æ¾¯ãÐÖµ²»ÄÜΪ¿Õ");
                            return;
                        }
                        
                        if(id.equals("")) {
                            ShowMessage.zidingyi("É豸±àºÅ²»ÄÜΪ¿Õ");
                            return;                            
                        }
                        
                        if(Get_Tb_Gass.get_tbGas(id) !=null) {
                            ShowMessage.zidingyi("É豸±àºÅÒѾ­´æÔÚ²»ÄÜÖØ¸´");
                            return;
                        }
                        
                        if(Get_Tb_Gass.get_gas(tong_dao, collect_ip)==null) {
                            String updateSQL="INSERT tb_gas (id,wei_zhi,gas_type,nong_du,status,collect_ip,tong_dao,waring_zhi,ip,x,y,addtime) VALUES ('"
                                    +id+"','"
                                    +wei_zhi+"','"
                                    +gas_type+"','"
                                    +nong_du+"','"
                                    +status+"','"
                                    +collect_ip+"','"
                                    +tong_dao+"','"
                                    +waring_zhi+"','"
                                    +ip+"','"
                                    +x+"','"
                                    +y+"','"
                                    +GetNowTime.now()+"')";                            
                            ShowMessage.save(DatabaseManagement.update(updateSQL));
                            Get_Tb_Gass.add_gas(id,tong_dao, collect_ip, gas_type, ip, x, y, waring_zhi);
                            
                            
                            //ÐÂÔöÒ»ÐÐÊý¾Ý,Ïò±í¸ñĩβÌí¼ÓÒ»ÐÐÊý¾Ý                            
                            Vector<String> addrowData=new Vector<>();
                            addrowData.add(id);
                            addrowData.add(wei_zhi);
                            addrowData.add(gas_type);
                            addrowData.add(nong_du);
                            addrowData.add(status);
                            addrowData.add(collect_ip);
                            addrowData.add(tong_dao);
                            addrowData.add(waring_zhi);
                            addrowData.add(ip);
                            addrowData.add(x);
                            addrowData.add(y);
                            addrowData.add(GetNowTime.now());
                            tableModel.addRow(addrowData);
 
 
                            
                        }else {
                            ShowMessage.zidingyi("ËùÔÚͨµÀ"+tong_dao+"²É¼¯ÒÇIP"+collect_ip+"ÒѾ­´æÔÚ²»ÄÜÖØ¸´Ìí¼Ó£¡");
                        }
 
                        
                    }
                });
            }
 
            return sure;
        }
 
 
 
        /**»ñȡȡÏû°´Å¥*/
        public JButtonModel getQuxiao() {
            if(quxiao==null) {
                quxiao=new JButtonModel("È¡  Ïû");
                quxiao.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        closeTagDialog();
                        addgas=null;
                    }
                });
            }
            return quxiao;
        }
 
        /**ËùÔÚͨµÀ*/
        public JlableModel getGasid() {
            if(gasid==null) {
                gasid=new JlableModel("ËùÔÚͨµÀ£º");
            }
            return gasid;
        }
 
        /**²É¼¯ÒǵØÖ·*/
        public JlableModel getGasName() {
            
            if(gasName==null) {
                gasName=new  JlableModel("²É¼¯ÒǵØÖ·£º");
            }
            
            return gasName;
        }
 
        /**ÆøÌå´«¸ÐÆ÷ÀàÐÍ*/
        public JlableModel getGastype() {
            if(gastype==null) {
                gastype=new  JlableModel("´«¸ÐÆ÷ÀàÐÍ£º");
            }
            return gastype;
        }
 
        /**É豸IP*/
        public JlableModel getGasip() {
            if(gasip==null) {
                gasip=new  JlableModel("É豸IP£º");
            }
            return gasip;
        }
 
        /**X×ø±ê*/
        public JlableModel getGas_x() {
            if(gas_x==null) {
                gas_x=new  JlableModel("°²×°X×ø±ê£º");
            }
            return gas_x;
        }
 
        /**Y×ø±ê*/
        public JlableModel getGas_y() {
            if(gas_y==null) {
                gas_y=new  JlableModel("°²×°Y×ø±ê£º");
            }
            return gas_y;
        }
 
        /**¸æ¾¯ãÐÖµÉèÖÃ*/
        public JlableModel getWarning() {
            if(warning==null) {
                warning=new  JlableModel("¸æ¾¯ãÐÖµ£º");
            }
            return warning;
        }
 
        /**ËùÔÚͨµÀÎı¾*/
        public JTextField getGasid_File() {
            if(gasid_File==null) {
                gasid_File=new JTextField(10);
            }
            return gasid_File;
        }
 
        /**²É¼¯ÒǵØÖ·ÏÂÀ­¿ò*/
        public JComboBox<String> get_gasName_box() {
            if(gasName_box==null) {                        
                gasName_box=new JComboBox<>();//´´½¨ÏÂÀ­¿ò¶ÔÏó
                gasName_box.setFont(new Font("΢ÈíÑźÚ", Font.PLAIN, 12));//ÉèÖÃ×ÖÌå
                String[] type= Get_collectors.get_macid();
                ComboBoxModel<String > coModel=new DefaultComboBoxModel<>(type);//ÏÂÀ­ÁбíÄ£ÐÍ            
                gasName_box.setModel(coModel);
                gasName_box.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        String xuan=(String) gasName_box.getSelectedItem();
                        gasip_File.setText(Get_collectors.get_ip(xuan));                    
                        
                    }
                });
            }
            
            return gasName_box;
        }
 
        /**É豸IPÎı¾*/
        public JTextField getGasip_File() {
            if(gasip_File==null) {
                gasip_File=new JTextField(10);
                gasip_File.setEnabled(false);
            }
            return gasip_File;
        }
 
        /**X×ø±êÎı¾*/
        public JTextField getGas_x_File() {
            if(gas_x_File==null) {
                gas_x_File=new JTextField(10);
            }
            return gas_x_File;
        }
 
        /**Y×ø±êÎı¾*/
        public JTextField getGas_y_File() {
            if(gas_y_File==null) {
                gas_y_File=new JTextField(10);
            }
            return gas_y_File;
        }
 
        /**¸æ¾¯ãÐÖµÎı¾*/
        public JTextField getWarning_File() {
            if(warning_File==null) {
                warning_File=new JTextField(10); 
            }
            return warning_File;
        }
 
        /**É豸ÐͺÅÑ¡Ôñ*/
        public JComboBox<String> get_gastype_Box() {    
 
            if(gastype_Box==null) {                        
                gastype_Box=new JComboBox<>();//´´½¨ÏÂÀ­¿ò¶ÔÏó
                gastype_Box.setFont(new Font("΢ÈíÑźÚ", Font.PLAIN, 12));//ÉèÖÃ×ÖÌå
                String[] type= {"Ñ¡ÔñÆøÌåÀàÐÍ","C O","H2S","CH4","CO2","O 2","SO2"};
                ComboBoxModel<String > coModel=new DefaultComboBoxModel<>(type);//ÏÂÀ­ÁбíÄ£ÐÍ    
                gastype_Box.setModel(coModel);    
                gastype_Box.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        String qiti=(String) gastype_Box.getSelectedItem();
                        switch(qiti){
                        case "C O":
                            warning_File.setText("100");
                           break; 
                        case "H2S" :
                            warning_File.setText("10");
                           break; 
                           
                        case "CH4" :
                            warning_File.setText("25");
                          break; 
                          
                        case "CO2":
                            warning_File.setText("1000");
                            break;
                        case "O 2":
                            warning_File.setText("23");
                            break;
                        case "SO2": 
                            warning_File.setText("10");
                            break;                        
                    }
                    }
                });
                        
            }
 
            return gastype_Box;
        }
        public JlableModel getId_label() {
            if(id_label==null) {
                id_label=new JlableModel("É豸±àºÅ:");
            }
            return id_label;
        }
        public JTextField getId_File() {
            if(id_File==null) {
                id_File=new JTextField(10);
            }
            return id_File;
        }
        @Override
        public void windowOpened(WindowEvent e) {
            // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
            
        }
        @Override
        public void windowClosing(WindowEvent e) {
            // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
            addgas=null;
            
        }
        @Override
        public void windowClosed(WindowEvent e) {
            // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
            
        }
        @Override
        public void windowIconified(WindowEvent e) {
            // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
            
        }
        @Override
        public void windowDeiconified(WindowEvent e) {
            // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
            
        }
        @Override
        public void windowActivated(WindowEvent e) {
            // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
            
        }
        @Override
        public void windowDeactivated(WindowEvent e) {
            // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
            
        }
    }
 
 
    /**ÐÞ¸ÄÆøÌåÉ豸¶Ô»°¿ò*/
    class AlertGasMac extends AddGasMac{
 
        /**
         * 
         */
        private static final long serialVersionUID = 1L;
 
        public AlertGasMac(String title) {
            super(title);
            // TODO ×Ô¶¯Éú³ÉµÄ¹¹Ô캯Êý´æ¸ù
            getGasid_File().setText((String) getTable().getValueAt(getSelectedRow(), 6));
            get_gasName_box().setSelectedItem((String) getTable().getValueAt(getSelectedRow(), 5));
            get_gastype_Box().setSelectedItem((String) getTable().getValueAt(getSelectedRow(), 2));
            getGasip_File().setText((String) getTable().getValueAt(getSelectedRow(), 8));
            getGas_x_File().setText((String) getTable().getValueAt(getSelectedRow(), 9));
            getGas_y_File().setText((String) getTable().getValueAt(getSelectedRow(), 10));
            getWarning_File().setText((String) getTable().getValueAt(getSelectedRow(), 7));
            getId_File().setText((String) getTable().getValueAt(getSelectedRow(), 0));
            getId_File().setEnabled(false);
            
        }
        
        public void windowClosing(WindowEvent e) {
            // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
            alertgas=null;
            
        }
        /**»ñȡȡÏû°´Å¥*/
        public JButtonModel getQuxiao() {
            if(quxiao==null) {
                quxiao=new JButtonModel("È¡  Ïû");
                quxiao.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        closeTagDialog();
                        alertgas=null;
                    }
                });
            }
            return quxiao;
        }
        
        /**»ñȡȷ¶¨°´Å¥*/
        public JButtonModel getSure() {
 
            if(sure==null) {
                sure=new JButtonModel("È·  ¶¨");
                sure.addActionListener(new ActionListener() {
                    public void actionPerformed(ActionEvent e) {
                        String id=(String) getTable().getValueAt(getSelectedRow(), 0);
                        String tong_dao=getGasid_File().getText().trim();
                        String collect_ip=(String) get_gasName_box().getSelectedItem();
                        String gas_type=(String) get_gastype_Box().getSelectedItem();
                        String x=getGas_x_File().getText().trim();
                        String y=getGas_y_File().getText().trim();
                        String warning_zhi=getWarning_File().getText().trim();
                        if(Get_Tb_Gass.alert_gasc(id, tong_dao, collect_ip, gas_type, x, y, warning_zhi)) {                            
                            ShowMessage.zidingyi("Ð޸ijɹ¦£¡");
                            updateTable() ;
                        }else {
                            ShowMessage.zidingyi("дÈëÊý¾Ý¿âʧ°Ü£¡");
                        }
 
                    }
                });
 
            }
            return sure;            
        }
 
    }
 
}