package Frame;
|
import java.awt.BorderLayout;
|
import java.awt.Color;
|
import java.awt.Container;
|
import java.awt.Font;
|
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionListener;
|
import java.io.IOException;
|
import javax.swing.ComboBoxModel;
|
import javax.swing.DefaultComboBoxModel;
|
import javax.swing.ImageIcon;
|
import javax.swing.JComboBox;
|
import javax.swing.JPanel;
|
import javax.swing.JTextField;
|
|
import ColorAndFont.English;
|
import DataBase.DatabaseManagement;
|
import IDcardManage.IDcard;
|
import IDcardManage.JButtonImage;
|
import IDcardManage.bmpToJPG;
|
import Method.GetNowTime;
|
import PbuliClass.BuMens;
|
import PbuliClass.JButtonModel;
|
import PbuliClass.JlableModel;
|
import PbuliClass.ShowMessage;
|
import PbuliClass.Systems;
|
import PbuliClass.jinternalFrame;
|
import person.person_Dell;
|
import tbDataModel_Dell.Dell_adress_and_port;
|
|
public class SendTag extends jinternalFrame {
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 1L;
|
|
String name1="·¢¿¨»ú¶Ë¿Ú£º";
|
String name2="²¨ÌØÂÊ£º";
|
String name3="Ñ¡Ôñ²¿ÃÅ£º";
|
String name4="×´ ̬£º";
|
String name5="ÐÕ Ãû£º";
|
String name6="ÐÔ ±ð£º";
|
String name7="Ãñ ×壺";
|
String name8="³öÉúÈÕÆÚ£º";
|
String name9="ÓÐЧÆÚÏÞ£º";
|
String name10="Ö¤¼þºÅÂ룺";
|
String name11="µØ Ö·£º";
|
String name12="Ç©·¢»ú¹Ø£º";
|
String name13="¶¨Î»¿¨ID£º";
|
String name14="ÁªÏµ·½Ê½£º";
|
|
|
|
JlableModel jl_duankou;
|
JTextField tex_duankou=new JTextField();
|
|
JlableModel jl_botelv;
|
JTextField tex_botelv=new JTextField();
|
|
JlableModel jl_bumen;
|
|
|
JlableModel jl_state;
|
static JTextField tex_state=null;
|
|
|
JlableModel jl_name;
|
JTextField tex_name=new JTextField();
|
|
JlableModel jl_sex;
|
JTextField tex_sex=new JTextField();
|
|
JlableModel jl_zu;
|
JTextField tex_zu=new JTextField();
|
|
JlableModel jl_csdate;
|
JTextField tex_csdate=new JTextField();
|
|
JlableModel jl_youxiaodate;
|
JTextField tex_youxiaodate=new JTextField();
|
|
JlableModel jl_num;
|
JTextField tex_num=new JTextField();
|
|
JlableModel jl_dizhi;
|
JTextField tex_dizhi=new JTextField();
|
|
JlableModel jl_qianfajiguan;
|
JTextField tex_qianfajiguan=new JTextField();
|
|
JlableModel jl_UID=new JlableModel("UID£º");
|
JTextField tex_UID=new JTextField();
|
|
// JlableModel jl_type=new JlableModel("Ö¤¼þÀàÐÍ£º");
|
// JTextField tex_type=new JTextField();
|
|
// publicclass.JlableModel jl_fence=new JlableModel("Ñ¡ÔñÆäµ½·ÃÇøÓò£º");
|
// JComboBox<String> fence=null;
|
|
JComboBox<String> bumenComboBox=null;
|
|
JlableModel jl_idtag;
|
JTextField tex_idtag=new JTextField();
|
|
JlableModel jl_phone;
|
JTextField tex_phone=new JTextField();
|
|
// JlableModel jl_beizhu=new JlableModel("½Ó´ýÈËÔ±£º");
|
// JTextField tex_beizhu=new JTextField();
|
|
JButtonImage image=null;
|
|
JButtonModel but_reaIDcard=null;//¶ÁÉí·ÝÖ¤
|
JButtonModel but_tag=null;//¶Á±êÇ©
|
JButtonModel but_faka=null;//·¢¿¨
|
JButtonModel but_guihuan=null;//»¹¿¨
|
JButtonModel but_duankou=null;//±£´æ¶Ë¿Ú
|
JButtonModel but_faka_shebei=null;//Á¬½Ó·¢¿¨ÖÕ¶Ë
|
|
ImageIcon images =null;
|
|
int i=0;
|
|
boolean IDcard_read_succ=false;
|
boolean uwb_read_succ=false;
|
boolean lianjie=false;
|
|
public SendTag() {
|
if(Systems.sys().getLanguage().equals("English")) {
|
name1="Port£º";
|
name2="BaudRate£º";
|
name3="SelecBranch£º";
|
name4="Status£º";
|
name5="Name£º";
|
name6="Sex£º";
|
name7="Nationality£º";
|
name8="BirthDat£º";
|
name9="ValidityPeriod£º";
|
name10="IDNumber£º";
|
name11="Adress";
|
name12="Authority£º";
|
name13="TagID£º";
|
name14="Contact£º";
|
}
|
jl_duankou=new JlableModel(name1);
|
jl_botelv=new JlableModel(name2);
|
jl_bumen=new JlableModel(name3);
|
jl_state=new JlableModel(name4);
|
jl_name=new JlableModel(name5);
|
jl_sex=new JlableModel(name6);
|
jl_zu=new JlableModel(name7);
|
jl_csdate=new JlableModel(name8);
|
jl_youxiaodate=new JlableModel(name9);
|
jl_num=new JlableModel(name10);
|
jl_dizhi=new JlableModel(name11);
|
jl_qianfajiguan=new JlableModel(name12);
|
jl_idtag=new JlableModel(name13);
|
jl_phone=new JlableModel(name14);
|
|
|
|
String title="·¢·Å±êÇ©";
|
if(Systems.sys().getLanguage().equals("English")) {
|
title="Issue Tag";
|
}
|
this.setTitle(title);
|
Container rq=getContentPane();//»ñÈ¡ÈÝÆ÷
|
rq.setLayout(new BorderLayout());
|
this.setBounds(175, 0, 850, 570);
|
rq.setBackground(Color.white);
|
rq.add(getMb(),BorderLayout.CENTER);
|
this.setFrameIcon(new ImageIcon("image/icon/tagicon.png"));//ÉèÖô°Ìåͼ±ê
|
|
|
}
|
public JTextField getTex_state() {
|
if(tex_state==null) {
|
tex_state=new JTextField();
|
tex_state.setEditable(false);
|
tex_state.setCaretColor(Color.RED);
|
tex_state.setBackground(Color.WHITE);
|
tex_state.setForeground(Color.red);
|
tex_state.setText(IDcard.getState());
|
}
|
return tex_state;
|
}
|
|
|
static public void set_state(String state){
|
tex_state.setText(state);
|
}
|
|
public JPanel getMb() {
|
JPanel mb=new JPanel();
|
mb.setLayout(null);
|
mb.setBackground(Color.WHITE);
|
int height=25;
|
int x=100;
|
int y=100;
|
|
//Õ¼ÓõĶ˿Ú
|
jl_duankou.setBounds(x,y-90, 90, height);
|
|
tex_duankou.setBounds(x+90, y-90,100, height);
|
mb.add(jl_duankou);
|
mb.add(tex_duankou);
|
|
//²¨ÌØÂÊ
|
jl_botelv.setBounds(x+220,y-90,60, height);
|
tex_botelv.setBounds(x+280,y-90, 90, height);
|
if(Dell_adress_and_port.get_adr_port("faka") !=null) {
|
tex_duankou.setText(Dell_adress_and_port.get_adr_port("faka").getBaoliu());
|
tex_botelv.setText(Dell_adress_and_port.get_adr_port("faka").getBaoliu2());
|
}
|
|
tex_botelv.setEnabled(false);
|
mb.add(jl_botelv);
|
mb.add(tex_botelv);
|
|
mb.add(getBut_duankou());
|
but_duankou.setBounds(x+400,y-90, 90, height);
|
|
//Á¬½Ó·¢¿¨É豸
|
mb.add(getBut_faka_shebei());
|
but_faka_shebei.setBounds(x+520,y-90, 100, height);
|
|
//״̬
|
jl_state.setBounds(x,y-45, 65, height);
|
getTex_state().setBounds(x+65,y-45,560, height);
|
mb.add(jl_state);
|
mb.add(tex_state);
|
|
//ÐÕÃû
|
jl_name.setBounds(x, y, 65, height);
|
mb.add(jl_name);
|
tex_name.setBounds(x+65, y, 100, height);
|
mb.add(tex_name);
|
|
//ÐÔ±ð
|
jl_sex.setBounds(x+65+140, y,65, height);
|
mb.add(jl_sex);
|
tex_sex.setBounds(x+2*65+140, y, 50, height);
|
mb.add(tex_sex);
|
|
//Ãñ×å
|
jl_zu.setBounds(x+2*65+230, y, 65, height);
|
tex_zu.setBounds(x+3*65+230, y, 50, height);
|
mb.add(jl_zu);
|
mb.add(tex_zu);
|
|
|
//³öÉúÈÕÆÚ
|
jl_csdate.setBounds(x, y+50, 75, height);
|
tex_csdate.setBounds(x+75, y+50, 100, height);
|
mb.add(jl_csdate);
|
mb.add(tex_csdate);
|
|
//ÓÐЧÈÕÆÚ
|
jl_youxiaodate.setBounds(x+65+140, y+50, 75, height);
|
tex_youxiaodate.setBounds(x+65+140+75, y+50, 200, height);
|
mb.add(jl_youxiaodate);
|
mb.add(tex_youxiaodate);
|
|
//Ö¤¼þºÅÂë
|
jl_num.setBounds(x, y+100, 75, height);
|
tex_num.setBounds(x+75, y+100, 408, height);
|
mb.add(jl_num);
|
mb.add(tex_num);
|
|
//µØÖ·
|
jl_dizhi.setBounds(x, y+150, 75, height);
|
tex_dizhi.setBounds(x+75, y+150, 550, height);
|
mb.add(jl_dizhi);
|
mb.add(tex_dizhi);
|
|
//Ç©·¢»ú¹Ø
|
jl_qianfajiguan.setBounds(x, y+200, 75, height);
|
tex_qianfajiguan.setBounds(x+75, y+200,550, height);
|
mb.add(jl_qianfajiguan);
|
mb.add(tex_qianfajiguan);
|
|
//Ö¤¼þÀàÐÍ
|
// jl_type.setBounds(x, y+250,75, height);
|
// tex_type.setBounds(x+75, y+250, 85, height);
|
// mb.add(jl_type);
|
// mb.add(tex_type);
|
|
//¶¨Î»¿¨
|
jl_idtag.setBounds(x, y+250,75, height);
|
tex_idtag.setBounds(x+75, y+250, 85, height);
|
mb.add(jl_idtag);
|
mb.add(tex_idtag);
|
|
//ÁªÏµ·½Ê½
|
jl_phone.setBounds(x+185, y+250,75, height);
|
tex_phone.setBounds(x+260, y+250,100, height);
|
mb.add(jl_phone);
|
mb.add(tex_phone);
|
|
|
//¶ÁÉí·ÝÖ¤
|
getBut_reaIDcard().setBounds(x, y+350, 80, 60);
|
mb.add(but_reaIDcard);
|
|
//¶Á¶¨Î»¿¨
|
getBut_tag().setBounds(x+150, y+350, 80, 60);
|
mb.add(but_tag);
|
|
//·¢¿¨
|
getBut_faka().setBounds(x+300, y+350, 80, 60);
|
mb.add(but_faka);
|
|
//»¹¿¨
|
getBut_guihuan().setBounds(x+380+70, y+350, 80, 60);
|
mb.add(but_guihuan);
|
|
//ÕÕÆ¬
|
getImage().setBounds(x+3*65+330, y,102,126);
|
mb.add(image);
|
|
jl_bumen.setBounds(x+400, y+250,80, height);
|
mb.add(jl_bumen);
|
mb.add(getBumenComboBox());
|
bumenComboBox.setBounds(x+480, y+250,150, height);
|
|
|
//½Ó´ýÈËÔ±
|
// jl_beizhu.setBounds(x+190, y+300,75, height);
|
// tex_beizhu.setBounds(x+275, y+300,85, height);
|
// mb.add(jl_beizhu);
|
// mb.add(tex_beizhu);
|
return mb;
|
}
|
|
public JButtonModel getBut_reaIDcard() {
|
if(but_reaIDcard==null) {
|
but_reaIDcard=new JButtonModel(English.name("¶ÁÉí·ÝÖ¤", "ReadId"));
|
but_reaIDcard.addActionListener(new ActionListener() {
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
|
if(! lianjie) {
|
ShowMessage.zidingyi("·¢¿¨É豸״̬²»Õý³££¡ÇëÏÈÁ¬½ÓÉ豸...");
|
return;
|
}
|
|
i=0;
|
|
//¿¨ÈÏÖ¤
|
|
while(i<3) {
|
boolean rz=IDcard.CVR_Authenticate();
|
if(rz) {
|
i=8;
|
// System.out.println("¿¨ÈÏÖ¤³É¹¦...");
|
break;
|
}else {
|
try {
|
Thread.sleep(3000);
|
} catch (InterruptedException e1) {
|
// TODO ×Ô¶¯Éú³ÉµÄ catch ¿é
|
e1.printStackTrace();
|
}
|
// System.out.println(i+"Çë·ÅÉí·ÝÖ¤...");
|
getTex_state().setText(i+"Çë·ÅÉí·ÝÖ¤...");
|
i++;
|
}
|
}
|
|
if(i==8) {
|
getTex_state().setText("¿¨ÈÏÖ¤³É¹¦...");
|
if(IDcard.RedaCard()==1) {
|
getneirong();
|
IDcard_read_succ=true;
|
}
|
|
|
try {
|
bmpToJPG.bmp2jpg();
|
} catch (IOException e1) {
|
// TODO ×Ô¶¯Éú³ÉµÄ catch ¿é
|
e1.printStackTrace();
|
}
|
image.setIcon(bmpToJPG.getImages());
|
|
}else {
|
getTex_state().setText("¿¨ÈÏ֤ʧ°Ü...");
|
clearneirong();
|
}
|
|
|
}
|
});
|
}
|
return but_reaIDcard;
|
}
|
|
|
public JButtonModel getBut_tag() {
|
if(but_tag==null) {
|
String name="¶Á¶¨Î»¿¨";
|
if(Systems.sys().getLanguage().equals("English")) {
|
name="ReadCard";
|
}
|
but_tag=new JButtonModel(name);
|
but_tag.addActionListener(new ActionListener() {
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
// TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
|
tex_state.setText("¶Á¶¨Î»¿¨...");
|
tex_idtag.setText("");
|
// System.out.println("¿¨ÈÏÖ¤ÖÐ");
|
|
if(IDcard.M1_MF_HL_Request()==144) {
|
uwb_read_succ=true;
|
String rfidnum=String.valueOf(IDcard.kaohao);
|
tex_idtag.setText(rfidnum);
|
};
|
uwb_read_succ=true;
|
|
|
}
|
});
|
}
|
return but_tag;
|
}
|
|
|
public JButtonModel getBut_faka() {
|
if(but_faka==null) {
|
String name="°ó ¶¨";
|
if(Systems.sys().getLanguage().equals("English")) {
|
name="Bind";
|
}
|
but_faka=new JButtonModel(name);
|
but_faka.addActionListener(new ActionListener() {
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
// TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
|
if(!IDcard_read_succ) {
|
tex_state.setText("Éí·ÝÖ¤ÐÅÏ¢²»ÄÜΪ¿Õ£¬Çë¶ÁÈ¡Éí·ÝÖ¤ÐÅÏ¢...");
|
return;
|
}
|
|
if(tex_idtag.getText().length()<2 ) {
|
tex_state.setText("¶¨Î»¿¨IDÐÅÏ¢²»ÄÜÕýÈ·Çë¼ì²é...");
|
return;
|
}
|
|
|
|
|
String p_name=tex_name.getText();
|
String p_sex=tex_sex.getText().trim();
|
String p_minzu=tex_zu.getText().trim();
|
String p_idcardnum=tex_num.getText();
|
String p_phone=tex_phone.getText() ;
|
String p_tagid=tex_idtag.getText().replace("-", "");
|
String p_department=(String) bumenComboBox.getSelectedItem();
|
String p_adress=tex_dizhi.getText().trim();
|
|
// System.out.println("Éí·ÝÖ¤"+p_idcardnum);
|
|
if(person_Dell.get_Person_from_idcard(p_idcardnum) !=null) {
|
tex_state.setText(GetNowTime.now()+" Éí·ÝÖ¤ºÅ£º"+p_idcardnum+" ÒѾ°ó¶¨ÁË¿¨"+
|
person_Dell.get_Person_from_idcard(p_idcardnum).getP_tagid());
|
return;
|
}
|
|
images = new ImageIcon("systemFiles/hxzk.jpg");
|
images.getImage().flush();
|
image.setIcon(images);
|
bmpToJPG.deleteFile("zp.jpg");
|
bmpToJPG.deleteFile("zp.bmp");
|
|
if(person_Dell.get_Person(p_tagid)==null) {
|
if(person_Dell.add_person_in_database(
|
p_name,
|
p_tagid,
|
p_sex,
|
p_minzu,
|
p_phone,
|
p_department,
|
p_idcardnum,
|
p_adress)) {
|
tex_state.setText(p_name+"°ó¶¨³É¹¦£¡");
|
clearneirong();
|
}
|
}else {
|
if(person_Dell.alert_tbperson_database(
|
p_name,
|
p_tagid,
|
p_sex,
|
p_minzu,
|
p_phone,
|
p_department,
|
p_idcardnum,
|
p_adress)) {
|
tex_state.setText(p_name+"°ó¶¨³É¹¦±êÇ©"+p_tagid);
|
clearneirong();
|
}
|
}
|
}
|
|
|
});
|
}
|
return but_faka;
|
}
|
|
|
public JButtonModel getBut_guihuan() {
|
if(but_guihuan==null) {
|
String name="½â °ó";
|
if(Systems.sys().getLanguage().equals("English")) {
|
name="Untie";
|
}
|
but_guihuan=new JButtonModel(name);
|
but_guihuan.addActionListener(new ActionListener() {
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
// TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù
|
if(tex_idtag.getText().equals("")) {
|
tex_state.setText("ÇëÊäÈëÐèÒª½â°óµÄ¶¨Î»¿¨IDºÅ...");
|
return;
|
}
|
String p_tagid=tex_idtag.getText().replace("-", "");
|
|
if(person_Dell.get_Person(p_tagid) !=null) {
|
|
if(person_Dell.alert_tbperson_database(
|
"δ°ó¶¨",
|
p_tagid,
|
"ÄÐ",
|
"",
|
"",
|
"ϵͳĬÈÏ",
|
"",
|
"")) {
|
tex_state.setText(p_tagid+"½â³ý°ó¶¨³É¹¦£¡");
|
}
|
|
}
|
}
|
});
|
}
|
return but_guihuan;
|
}
|
|
|
public JButtonImage getImage() {
|
if(image==null) {
|
image=new JButtonImage ("ÕÕÆ¬");
|
image.setIcon(bmpToJPG.getImages());
|
|
}
|
|
return image;
|
}
|
|
|
/**»ñÈ¡ÄÚÈÝ*/
|
public void getneirong() {
|
tex_name.setText(IDcard.name);
|
|
tex_sex.setText(IDcard.sex);
|
|
tex_zu.setText(IDcard.minzu);
|
|
tex_csdate.setText(IDcard.chushengdate);
|
|
tex_youxiaodate.setText(IDcard.startdate+"-"+IDcard.jizhidate);
|
|
tex_num.setText(IDcard.idnum);
|
|
tex_dizhi.setText(IDcard.address);
|
|
tex_qianfajiguan.setText(IDcard.fazhengjiguan);
|
// tex_type.setText("Éí·ÝÖ¤");
|
|
}
|
|
/**Çå¿ÕÄÚÈÝ*/
|
public void clearneirong() {
|
tex_name.setText("");
|
|
tex_sex.setText("");
|
|
tex_zu.setText("");
|
|
tex_csdate.setText("");
|
|
tex_youxiaodate.setText("");
|
|
tex_num.setText("");
|
|
tex_dizhi.setText("");
|
|
tex_qianfajiguan.setText("");
|
|
tex_idtag.setText("");
|
|
// tex_type.setText("");
|
}
|
public JButtonModel getBut_duankou() {
|
if(but_duankou==null) {
|
String name="±£´æ¶Ë¿Ú";
|
if(Systems.sys().getLanguage().equals("English")) {
|
name="SavePort";
|
}
|
but_duankou=new JButtonModel(name);
|
but_duankou.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
String updateSQL="UPDATE tb_adress_and_port SET baoliu='"+tex_duankou.getText()
|
+"',baoliu2='"+tex_botelv.getText()
|
+"'where name='faka '";
|
|
if(DatabaseManagement.update(updateSQL)!=0) {
|
Dell_adress_and_port.alert("faka", "", "", "", "", tex_duankou.getText(), tex_botelv.getText(), "");
|
ShowMessage.zidingyi("±£´æ³É¹¦³É¹¦£¡");
|
}
|
|
}
|
});
|
}
|
return but_duankou;
|
}
|
|
|
|
|
public JButtonModel getBut_faka_shebei() {
|
if(but_faka_shebei==null) {
|
String name="Á¬½ÓÉ豸";
|
if(Systems.sys().getLanguage().equals("English")) {
|
name="ConnectDevice";
|
}
|
but_faka_shebei=new JButtonModel(name);
|
but_faka_shebei.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
IDcard.chushi();
|
tex_state.setText(IDcard.state);
|
if(tex_state.getText().equals("·¢¿¨É豸׼±¸¾ÍÐ÷...")) {
|
lianjie=true;
|
}
|
}
|
});
|
}
|
return but_faka_shebei;
|
}
|
|
/**»ñȡѡÔñ²¿ÃÅÏÂÀ¿ò*/
|
public JComboBox<String> getBumenComboBox() {
|
|
if(bumenComboBox==null) {
|
bumenComboBox=new JComboBox<>();//´´½¨ÏÂÀ¿ò¶ÔÏó
|
bumenComboBox.setFont(new Font("΢ÈíÑźÚ", Font.PLAIN, 12));//ÉèÖÃ×ÖÌå
|
if (BuMens.getBumenNames()==null){
|
return bumenComboBox;
|
}
|
ComboBoxModel<String > coModel=new DefaultComboBoxModel<>(BuMens.getBumenNames());//ÏÂÀÁбíÄ£ÐÍ
|
bumenComboBox.setModel(coModel);
|
bumenComboBox.updateUI();//¸üÐÂUI
|
|
}
|
|
return bumenComboBox;
|
}
|
|
|
|
|
}
|