import java.awt.Dialog;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import Com.aowin.stuff.DAO.Person;
import Com.aowin.stuff.View.Dialog1;
class SexException extends Exception{
public SexException(){
Dialog1 d=new
Dialog1("性别必须是数字");
d.paint();
}
}
public class DataBase {
private static String url=null;
private static String user=null;
private static String password=null;
private Connection conn=null;
private Statement state=null;
private ResultSet rs=null;
private PreparedStatement ps=null;
private String sql=null;
// 数据库驱动程序加载
static{
try{
url="jdbc:mysql://localhost:3306/se205";
user="root";
password="123";
Class.forName("com.mysql.jdbc.Driver");
}catch(ClassNotFoundException
e){
e.printStackTrace();
}
}
// 数据库连接
public Connection getConnection(){
try{
conn=DriverManager.getConnection(url,user,password);
state=conn.createStatement();
}catch(SQLException e){
e.printStackTrace();
}
return conn;
}
//数据插入
public void insert(String id,String name,String
sex,String department,String salary){
System.out.println(id+","+name+","+sex+","+department+","+salary);
try {
this.getConnection();
int
a=Integer.parseInt(id);
int b =
0;
if(sex.equals("0")){
b=0;
}
if(sex.equals("1")){
b=1;
}
int
c=Integer.parseInt(salary);
// sql="insert
into person values("+a+",'name',"+b+",'+department+',"+c+")";
sql="insert
into person values(?,?,?,?,?)";
System.out.println(sql);
System.out.println(id+"
"+name );
ps=conn.prepareStatement(sql);
ps.setInt(1,a);
ps.setString(2,
name);
ps.setInt(3,
b);
ps.setString(4,
department);
ps.setInt(5,
c);
ps.executeUpdate();
// state.executeUpdate(sql);
}catch(Exception e){
Dialog1 d=new
Dialog1("输入的ID重复");
d.paint();
}finally{
this.close();
}
}
//数据删除
public void delete(String id){
try {
this.getConnection();
rs=state.executeQuery("select
* from person where id="+id);
if(!rs.next()){
Dialog1
d=new Dialog1("没有该条记录,不可删除");
d.paint();
}
sql="delete
from person where id="+id;
state.executeUpdate(sql);
} catch (SQLException e)
{
e.printStackTrace();
}finally{
this.close();
}
}
//数据查询
public List<Person>
select(String id,String name,String sex,String department,String
salary){
System.out.println(id+",
"+name+" , "+sex+",
"+department+" , "+salary );
if(sex==null){
sex="";
}
List<Person>
list=new ArrayList<Person>();
try {
this.getConnection();
if("".equals(id)&&"".equals(name)&&"".equals(salary)&&"".equals(sex)&&"".equals(department)){
Dialog1
d=new Dialog1("请输入查询信息!");
d.paint();
return
list;
}
sql="select *
from person where id like '%"+id+"%' and name like '%"+name+"%' "
+
"and
sex like '%"+sex+"%' and department like '%"+department+"%' and
salary like '%"+salary+"%'";
System.out.println(sql);
rs=state.executeQuery(sql);
Person
person=null;
if(!rs.next()){
Dialog1
d=new Dialog1("没有这条记录");
d.paint();
return
list;
}
rs=state.executeQuery(sql);
while(rs.next()){
person=new
Person();
person.setId(rs.getInt("id"));
person.setName(rs.getString("name"));
person.setDepartment(rs.getString("department"));
person.setSalary(rs.getInt("salary"));
person.setSex(rs.getInt("sex"));
list.add(person);
}
} catch (SQLException e)
{
e.printStackTrace();
}finally{
this.close();
}
return list;
}
//数据库更新
public void updata(String id,String name,String
sex,String department,String salary){
int
a=0,b=0,c=0;
if(sex.equals("男")){
b=0;
}
if(sex.equals("女")){
b=1;
}
a=Integer.parseInt(id);
c=Integer.parseInt(salary);
// System.out.println(id+name+sex+salary+department+salary);
this.getConnection();
// sql="update
person set name='"+name+"',sex="+b+",department='"+department+"',"
+"salary="+c+" where id="+id;
sql="update
person set name=?,sex=?,department=?,salary=? where id=?";
try {
ps=conn.prepareStatement(sql);
ps.setString(1,
name);
ps.setInt(2,
b);
ps.setString(3,
department);
ps.setInt(4,
c);
ps.setInt(5,
a);
ps.executeUpdate();
} catch
(SQLException e) {
e.printStackTrace();
}finally{
this.close();
}
//System.out.println(sql);
// state.executeUpdate(sql);
}
//数据库遍历
public List reflash(){
try {
this.getConnection();
sql="select *
from person";
rs=state.executeQuery(sql);
} catch (SQLException e)
{
e.printStackTrace();
System.out.println("查询出错");
}
Person person=null;
List list=new
ArrayList();
try {
while(rs.next()){
person=new
Person();
person.setId(rs.getInt("Id"));
person.setName(rs.getString("Name"));
person.setSalary(rs.getInt("Salary"));
person.setSex(rs.getInt("Sex"));
person.setDepartment(rs.getString("Department"));
list.add(person);
}
} catch (SQLException e)
{
e.printStackTrace();
System.out.println("查询出错");
}finally{
this.close();
}
return list;
}
//数据库关闭
private void close(){
try{
if(rs!=null){
rs.close();
rs=null;
}
if(state!=null){
state.close();
state=null;
}
if(conn!=null){
conn.close();
conn=null;
}
if(ps!=null){
ps.close();
ps=null;
}
}catch(SQLException e){
e.printStackTrace();
}
}
}
package Com.aowin.stuff.DAO;
public class Person {
private int id;
private String name;
private int sex;
private String department;
private int salary;
public int getId() {
return this.id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public int getSex() {
return this.sex;
}
public void setSex(int sex) {
this.sex = sex;
}
public String getDepartment() {
return this.department;
}
public void setDepartment(String department)
{
this.department =
department;
}
public int getSalary() {
return this.salary;
}
public void setSalary(int salary) {
this.salary = salary;
}
}
package Com.aowin.stuff.DAO;
public class RowOfObject {
private String id;
private String name;
private String sex;
private String department;
private String salary;
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return this.sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public String getDepartment() {
return this.department;
}
public void setDepartment(String department)
{
this.department =
department;
}
public String getSalary() {
return this.salary;
}
public void setSalary(String salary) {
this.salary = salary;
}
}
package Com.aowin.stuff.Lisnter;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.table.DefaultTableModel;
import com.sun.java.swing.plaf.windows.resources.windows;
import Com.aowin.stuff.View.Window;
public class ButtonAddListener implements ActionListener{
boolean flag=false;
Window window=null;
DefaultTableModel model;
public ButtonAddListener(DefaultTableModel
model){
this.model=model;
}
public void actionPerformed(ActionEvent e)
{
if(!flag){
window=new
Window("增加",this.model);
window.paint();
window.setVisible(true);
flag=true;
}
else{
window.setVisible(true);
}
// window.addWindowListener(new
WindowAdapter(){
// public void
windowClosing(WindowEvent e) {
// flag=false;
// }
// });
}
}
package Com.aowin.stuff.Lisnter;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.table.DefaultTableModel;
import Com.aowin.stuff.View.Window;
public class ButtonDeleteListener implements
ActionListener{
boolean flag=false;
Window window=null;
DefaultTableModel model;
public ButtonDeleteListener(DefaultTableModel
model){
this.model=model;
}
public void actionPerformed(ActionEvent e)
{
if(!flag){
window=new
Window("删除",this.model);
window.paint();
window.setVisible(true);
flag=true;
}
else{
window.setVisible(true);
}
}
}
package Com.aowin.stuff.Lisnter;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Iterator;
import java.util.List;
import javax.swing.table.DefaultTableModel;
import Com.aowin.stuff.DAO.DataBase;
import Com.aowin.stuff.DAO.Person;
public class ButtonReflashListener implements
ActionListener{
DefaultTableModel model;
public ButtonReflashListener(DefaultTableModel
model){
this.model=model;
}
public void actionPerformed(ActionEvent e)
{
this.model.setRowCount(0);
DataBase db=new
DataBase();
db.getConnection();
List list=db.reflash();
Iterator
it=list.iterator();
Person person=null;
Object[]row=null;
while(it.hasNext()){
person=(Person)
it.next();
String
id=String.valueOf(person.getId());
String
name=person.getName();
String
sex=null;
if(person.getSex()==0){
sex="男";
}
if(person.getSex()==1){
sex="女";
}
String
department=person.getDepartment();
String
salary=String.valueOf(person.getSalary());
row=new
Object[]{id,name,sex,department,salary};
this.model.addRow(row);
}
}
}
package Com.aowin.stuff.Lisnter;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.table.DefaultTableModel;
import Com.aowin.stuff.View.Window;
public class ButtonSelectListener implements
ActionListener{
boolean flag=false;
Window window=null;
DefaultTableModel model=null;
public ButtonSelectListener(DefaultTableModel
model){
this.model=model;
}
public void actionPerformed(ActionEvent e)
{
if(!flag){
window=new
Window("查询",this.model);
window.paint();
window.setVisible(true);
flag=true;
}
else{
window.setVisible(true);
}
}
}
package Com.aowin.stuff.Lisnter;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import Com.aowin.stuff.View.Dialog2;
public class Dialog2DisposeListener implements
ActionListener{
Dialog2 d;
public Dialog2DisposeListener(Dialog2 d){
this.d=d;
}
public void actionPerformed(ActionEvent arg0)
{
this.d.dispose();
}
}
package Com.aowin.stuff.Lisnter;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Iterator;
import java.util.List;
import javax.swing.table.DefaultTableModel;
import Com.aowin.stuff.DAO.DataBase;
import Com.aowin.stuff.DAO.Person;
import Com.aowin.stuff.View.Dialog2;
public class Dialog2QueDingButtonListener implements
ActionListener{
Dialog2 d;
DefaultTableModel model;
public Dialog2QueDingButtonListener(Dialog2
d,DefaultTableModel model){
this.d=d;
this.model=model;
}
public void actionPerformed(ActionEvent e)
{
//导入数据库
DataBase db=new
DataBase();
List list=db.reflash();
Iterator
it2=list.iterator();
Person person=null;
for(int
k=0;k<this.model.getRowCount();k++){
String
id=this.model.getValueAt(k, 0).toString();
String
name=this.model.getValueAt(k, 1).toString();
String
sex=this.model.getValueAt(k, 2).toString();
String
department=this.model.getValueAt(k, 3).toString();
String
salary=this.model.getValueAt(k, 4).toString();
if(!it2.hasNext()){
System.out.println("bbbbbb");
db.insert(id,
name, sex, department, salary);
continue;
}
boolean
flag=true;
while(it2.hasNext()){
System.out.println("ccc");
person=(Person)
it2.next();
String
itid=String.valueOf(person.getId());
if(id.equals(itid)){
flag=false;
break;
}
}
if(flag){
System.out.println("dddddd");
db.insert(id,
name, sex, department, salary);
}
this.d.setVisible(false);
}
}
}
package Com.aowin.stuff.Lisnter;
import java.awt.Dialog;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import Com.aowin.stuff.View.Dialog1;
import Com.aowin.stuff.View.View;
public class DialogDisposeListener implements
ActionListener{
Dialog1 d;
public DialogDisposeListener(Dialog1 d){
this.d=d;
}
public void actionPerformed(ActionEvent arg0)
{
this.d.dispose();
}
}
package Com.aowin.stuff.Lisnter;
import java.awt.Point;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.Collections;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import tool.SortJTable;
import Com.aowin.stuff.DAO.RowOfObject;
public class HeaderListener implements MouseListener {
JTable table;
DefaultTableModel model;
int num = 1 ;
public HeaderListener(JTable table,
DefaultTableModel model) {
this.table = table;
this.model = model;
}
public void mouseClicked(MouseEvent e) {
if (e.getClickCount() == 2)
{
Point p =
e.getPoint();
int index =
table.columnAtPoint(p);
String name =
table.getColumnName(index);
RowOfObject
roo=null;
ArrayList<RowOfObject>
rows = new
ArrayList<RowOfObject>();
for (int i
= 0; i < table.getRowCount(); i++) {
roo
= new RowOfObject();
roo.setId(table.getValueAt(i,
0).toString());
roo.setName(table.getValueAt(i,
1).toString());
roo.setSex(table.getValueAt(i,
2).toString());
roo.setDepartment(table.getValueAt(i,
3).toString());
roo.setSalary(table.getValueAt(i,
4).toString());
rows.add(roo);
}
Collections.sort(rows,
new SortJTable(name,num));
num++;
model.setRowCount(0);
for (int i
= 0; i < rows.size(); i++) {
String[]
str = { rows.get(i).getId()+"", rows.get(i).getName(),
rows.get(i).getSex()+"",
rows.get(i).getDepartment(),
rows.get(i).getSalary()+""
};
model.addRow(str);
}
}
}
public void mouseEntered(MouseEvent e) {
}
public void mouseExited(MouseEvent e) {
}
public void mousePressed(MouseEvent e) {
}
public void mouseReleased(MouseEvent e) {
}
}
package Com.aowin.stuff.Lisnter;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import javax.swing.JFileChooser;
import javax.swing.JTable;
import javax.swing.filechooser.FileFilter;
import javax.swing.table.DefaultTableModel;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.OutputFormat;
import org.dom4j.io.XMLWriter;
public class MenuDaoChuListener implements ActionListener{
DefaultTableModel model;
JTable table;
public MenuDaoChuListener(DefaultTableModel
model,JTable table){
this.model=model;
this.table=table;
}
public void actionPerformed(ActionEvent e)
{
JFileChooser jfc=new
JFileChooser();
jfc.setFileFilter(new
FileChooserFilter());
int
i=jfc.showSaveDialog(null);
if(i==JFileChooser.APPROVE_OPTION){
File
file=jfc.getSelectedFile();
Document
doc=DocumentHelper.createDocument();
Element
root=doc.addElement("root");
for(int
k=0;k<table.getRowCount();k++){
String
id=table.getValueAt(k, 0).toString();
String
name=table.getValueAt(k, 1).toString();
String
sex=table.getValueAt(k, 2).toString();
String
department=table.getValueAt(k, 3).toString();
String
salary=table.getValueAt(k, 4).toString();
Element
person=root.addElement("Person");
person.addAttribute("id",
id);
person.addAttribute("name",
name);
person.addAttribute("sex",
sex);
person.addAttribute("department",
department);
person.addAttribute("salary",
salary);
}
try {
FileWriter
fw=new FileWriter(file);
OutputFormat
format = new OutputFormat();
format.setEncoding("gb2312");
XMLWriter
xw=new XMLWriter(fw,format);
xw.write(doc);
fw.flush();
fw.close();
} catch
(IOException e1) {
e1.printStackTrace();
}
}
}
}
class FileChooserFilter extends FileFilter{
public boolean accept(File f) {
if(f.isFile()&&f.getName().endsWith(".xml")){
return
true;
}
return false;
}
public String getDescription()
{
return ".xml";
}
}
package Com.aowin.stuff.Lisnter;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.Iterator;
import javax.swing.JFileChooser;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import Com.aowin.stuff.View.Dialog2;
public class MenuDaoRuListener implements ActionListener {
DefaultTableModel model;
JTable table;
public MenuDaoRuListener(DefaultTableModel
model,JTable table){
this.model=model;
this.table=table;
}
public void actionPerformed(ActionEvent e)
{
JFileChooser jfc=new
JFileChooser();
jfc.setFileFilter(new
FileChooserFilter());
int
i=jfc.showOpenDialog(null);
if(i==JFileChooser.APPROVE_OPTION){
File
file=jfc.getSelectedFile();
try {
SAXReader
reader=new SAXReader();
Document
doc=reader.read(file);
Element
root=doc.getRootElement();
Iterator
it = root.elementIterator();
Element
tmp;
Object[]
row=null;
for(;it.hasNext();){
tmp=(Element)
it.next();
String
id=tmp.attributeValue("id");
String
name=tmp.attributeValue("name");
String
sex=tmp.attributeValue("sex");
String
department=tmp.attributeValue("department");
String
salary=tmp.attributeValue("salary");
if(this.model.getRowCount()==0){
row=new
Object[]{id,name,sex,department,salary};
this.model.addRow(row);
continue;
}
boolean
flag=true;
for(int
j=0;j<this.model.getRowCount();j++){
String
jid=this.model.getValueAt(j,0).toString();
if(id.equals(jid)){
flag=false;
break;
}
}
if(flag){
row=new
Object[]{id,name,sex,department,salary};
this.model.addRow(row);
}
}
Dialog2
d=new Dialog2("要导入数据库吗?",model);
d.paint();
} catch
(Exception ee) {
}
}
}
}
package Com.aowin.stuff.Lisnter;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenuItem;
public class MenuExitListener implements ActionListener{
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
}
package Com.aowin.stuff.Lisnter;
import java.awt.Button;
import java.awt.Container;
import java.awt.Dialog;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.Label;
import java.awt.Panel;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import Com.aowin.stuff.View.Dialog1;
import Com.aowin.stuff.View.View;
public class MenuHelpListener implements ActionListener{
public void actionPerformed(ActionEvent arg0)
{
Dialog1 dialog=new
Dialog1("帮助");
Panel p=new Panel();
JButton button=new
JButton("返回");
button.setSize(100, 100);
button.addActionListener(new
DialogDisposeListener(dialog));
p.add(button,"Center");
JTextArea text=new
JTextArea("谢谢!");
JScrollPane scroll=new
JScrollPane(text);
dialog.add(scroll,"Center");
dialog.add(p,"South");
dialog.pack();
dialog.setResizable(false);
dialog.setSize(200,150);
dialog.setVisible(true);
}
}
package Com.aowin.stuff.Lisnter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import tool.Tool;
import Com.aowin.stuff.DAO.DataBase;
import Com.aowin.stuff.View.Dialog1;
public class MouseListener1 implements MouseListener{
DefaultTableModel model;
JTable table;
public MouseListener1(DefaultTableModel
model,JTable table){
this.model=model;
this.table=table;
}
public void mouseClicked(MouseEvent e) {
try{
int
row=this.table.getSelectedRow();
String
id=this.table.getValueAt(row,0).toString();
String
name=this.table.getValueAt(row, 1).toString();
String
sex=this.table.getValueAt(row, 2).toString();
String
department=this.table.getValueAt(row, 3).toString();
String
salary=this.table.getValueAt(row, 4).toString();
boolean
a=Tool.panduanId(id);
boolean
b=Tool.panduanName(name);
boolean
c=Tool.panduanSex2(sex);
boolean
d=Tool.panduanDepartment(department);
boolean
ee=Tool.panduanSalary(salary);
if(a&&b&&c&&d&&ee){
DataBase
db=new DataBase();
db.updata(id,
name, sex, department, salary);
}
}catch(java.lang.ArrayIndexOutOfBoundsException
ee){
Dialog1 d=new
Dialog1("请选择要修改的对象");
d.paint();
}
}
public void mouseEntered(MouseEvent arg0)
{
}
public void mouseExited(MouseEvent arg0)
{
}
public void mousePressed(MouseEvent arg0)
{
}
public void mouseReleased(MouseEvent arg0)
{
}
}
package Com.aowin.stuff.Lisnter;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.List;
import javax.swing.JComboBox;
import javax.swing.JRadioButton;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
import tool.Tool;
import Com.aowin.stuff.DAO.DataBase;
import Com.aowin.stuff.DAO.Person;
import Com.aowin.stuff.View.Window;
public class QueDing implements ActionListener{
private String shijian;
private String
id,name,sex,department,salary;
private List list;
private Person person;
private DefaultTableModel model=null;
private Window window;
public QueDing(List list,DefaultTableModel
model,String shijian,Window window){
this.list=list;
this.shijian=shijian;
this.model=model;
this.window=window;
}
public void actionPerformed(ActionEvent e)
{
this.id=((JTextField)list.get(0)).getText();
this.name=((JTextField)list.get(1)).getText();
JRadioButton
man=(JRadioButton)list.get(2);
JRadioButton
woman=(JRadioButton)list.get(3);
if(man.isSelected()){
this.sex="0";
}
if(woman.isSelected()){
this.sex="1";
}
this.department=(String)
((JComboBox)list.get(4)).getSelectedItem();
this.salary=((JTextField)list.get(5)).getText();
//System.out.println(this.sex+this.id+this.name+this.department+this.salary+this.shijian);
//else{
if(this.shijian.equals("增加")){
boolean
flag=Tool.panduan(this.id,this.name,this.sex,this.department,this.salary);
if(!flag){
DataBase
db=new DataBase();
db.insert(this.id,this.name,this.sex,this.department,this.salary);
window.dispose();
}
new
ButtonReflashListener(model).actionPerformed(e);
}
//按照id删除
else
if(this.shijian.equals("删除")){
// try{
// int
a=Integer.parseInt(this.id);
// DataBase
db=new DataBase();
// db.delete(this.id);
// }catch(Exception
ee){
// Dialog1
d=new Dialog1("请输入要删除的id号");
// d.paint();
// }
boolean
flag=Tool.panduan2(this.id);
if(flag){
DataBase
db=new DataBase();
db.delete(this.id);
this.window.setVisible(false);
}
new
ButtonReflashListener(model).actionPerformed(e);
}
//查询
else
if(this.shijian.equals("查询")){
this.model.setRowCount(0);
// boolean
flag=Tool.panduan2(this.id);
// if(flag){
DataBase
db=new DataBase();
List<Person>
list=db.select(this.id,this.name,this.sex,this.department,this.salary);
// if(obj
instanceof Person){
// person=(Person)obj;
// Object[]
row=new
Object[]{String.valueOf(person.getId()),person.getName(),String.valueOf(person.getSalary()),person.getDepartment(),String.valueOf(person.getSalary())};
// this.model.addRow(row);
// }
//Iterator
it=list.iterator();
for(Person
p:list){
// System.out.println(p.getSalary());
String
str=String.valueOf(p.getSex());
if(str.equals("0")){
str="男";
}
if(str.equals("1")){
str="女";
}