lbTip.setBounds(0, 0, 600, 50); con.add(lbTip);
name.setBounds(80, 80, 50, 25); con.add(name);
inputName.setBounds(160, 80, 150, 23); con.add(inputName); sex.setBounds(80, 115, 50, 25); JRB1.setBounds(160, 115, 50, 25); JRB2.setBounds(260,115, 50, 25); con.add(sex); con.add(JRB1); con.add(JRB2);
brithday.setBounds(80, 150, 90, 25); choiceOne.setBounds(180, 150, 70, 25); year.setBounds(260, 150, 40, 25); choiceTwo.setBounds(290, 150, 70, 25); month.setBounds(370, 150, 40, 25); choiceThree.setBounds(400, 150, 70, 25); day.setBounds(500, 150, 30, 25); con.add(brithday); con.add(choiceOne); con.add(choiceTwo); con.add(choiceThree); con.add(year); con.add(month); con.add(day);
for(int i=1990;i<=2017;i++)
choiceOne.add(String.valueOf(i));
27
for(int j=1;j<=12;j++)
choiceTwo.add(String.valueOf(j));
for(int k=1;k<=31;k++)
choiceThree.add(String.valueOf(k));
group.add(JRB1); group.add(JRB2);
address.setBounds(80, 190, 80, 25); inputAdress.setBounds(180, 190, 150, 23); con.add(address); con.add(inputAdress); tel.setBounds(80, 230, 80, 25); inputTel.setBounds(180, 230, 150, 23); con.add(tel); con.add(inputTel);
organization.setBounds(80, 270, 80, 25); position.setBounds(80, 310, 80, 25); choiceFour.setBounds(180, 270, 150, 30); choiceFive.setBounds(180, 310, 150, 30); con.add(choiceFour); con.add(choiceFive); con.add(organization); con.add(position);
choiceFour.add(\青年志愿者协会\choiceFour.add(\篮球协会\choiceFour.add(\英语协会\choiceFour.add(\校学生会\choiceFive.add(\会长\choiceFive.add(\副会长\choiceFive.add(\社团成员\btnAdd.setBounds(150, 355, 60, 30); btnCancel.setBounds(270, 355, 60, 30);
28
con.add(btnAdd); con.add(btnCancel);
btnAdd.addActionListener(new ActionListener() {
private int Id;
public void actionPerformed(ActionEvent arg0) { String Name=inputName.getText().trim();
String xingbie=group.getSelection().getActionCommand(); String brith=choiceOne.getSelectedItem()+\年
\月\日\
String address=inputAdress.getText().trim(); String tel=(String)inputTel.getText().trim(); String organization=choiceFour.getSelectedItem(); String position=choiceFive.getSelectedItem(); if(StringUtil.isEmpty(Name)) { }
if(StringUtil.isEmpty(address)) { }
if(StringUtil.isEmpty(tel)) { }
peopleInformation information=new
29
JOptionPane.showMessageDialog(null,\姓名不能为空!\inputName.requestFocus(); return;
JOptionPane.showMessageDialog(null,\住址不能为空!\inputTel.requestFocus(); return;
JOptionPane.showMessageDialog(null,\电话号码不能为空!\inputTel.requestFocus(); return;
peopleInformation(Id,Name,xingbie,brith,address,tel,organization,position); }
}
});
btnCancel.addActionListener(new ActionListener(){ });
this.setVisible(true);
public void actionPerformed(ActionEvent arg0) { }
}
int flag=new addInformation().addBookType(information); if(flag>0) {
JOptionPane.showMessageDialog(null, \添加成功!\inputName.setText(\inputAdress.setText(\inputTel.setText(\inputName.requestFocus();
}else{ }
JOptionPane.showMessageDialog(null, \添加失败!\
创建与information表对应的JaveBeen对象peopleInformation,该类中的属性与information表中的字段一一对应,并包括了各属性的get与set方法,具体代码如下:
package com.zky.www.model;
public class peopleInformation {
private int Id;
private String name; private String sex; private String address;
30
private String brithday; private String tel; private String organization; private String position; private String paint; private String brithYear; private String brithMonth; private String brithDay; public peopleInformation(int Id) { }
public peopleInformation(int Id,String name) { }
public peopleInformation(int Id,String name,String sex,String brithday,String address,String tel,String organization,String position) {
super(); this.Id=Id;
super(); this.Id=Id; this.name=name;
super(); this.Id=Id; this.name=name; this.sex=sex;
this.brithday=brithday; this.address=address; this.tel=tel;
31