📄 bikeinfo.java
字号:
{
JOptionPane.showMessageDialog(this,"该代号不存在,请重新输入!","警告",JOptionPane.WARNING_MESSAGE);
studentnumber.setText("");
name.setText("");
password.setText("");
telephone.setText("");
adress.setText("");
sex.setSelectedIndex(0);
party.setSelected(false);
age.setText("");
grade.setSelectedIndex(0);
resume.setText("");
photo.setIcon(new ImageIcon("2.gif"));
}
}
catch(SQLException ee3)
{
}
}
if(e.getSource()==change)
{
Connection con=null;
Statement sql=null;
Statement sql2=null;
ResultSet result;
ResultSet resul2t;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e4)
{
System.out.println(""+e4);
}
try
{
con=DriverManager.getConnection("jdbc:odbc:me2","zww","123");
sql=con.createStatement();
sql2=con.createStatement();
result=sql.executeQuery("SELECT * FROM studentb");
String temps=studentnumber.getText();
long templong=Long.parseLong(temps);
boolean tempbool=false;
while(result.next())
{
if(result.getLong("sn")==templong)
{
tempbool=true;
String s2="'"+name.getText()+"'";
sql2.executeUpdate("UPDATE studentb SET name="+s2+" WHERE sn="+templong+"");
String temps3=new String(password.getText());
String s3="'"+temps3+"'";
sql2.executeUpdate("UPDATE studentb SET password="+s3+" WHERE sn="+templong+"");
int t4=sex.getSelectedIndex();
sql2.executeUpdate("UPDATE studentb SET sex="+t4+" WHERE sn="+templong+"");
String s5=age.getText();
int t5=Integer.parseInt(s5);
sql2.executeUpdate("UPDATE studentb SET age="+t5+" WHERE sn="+templong+"");
int t6=grade.getSelectedIndex();
sql2.executeUpdate("UPDATE studentb SET grade="+t6+" WHERE sn="+templong+"");
sql2.executeUpdate("UPDATE studentb SET party="+new Boolean(party.isSelected())+" WHERE sn="+templong+"");
String s8="'"+telephone.getText()+"'";
sql2.executeUpdate("UPDATE student SET telephone="+s8+" WHERE sn="+templong+"");
String s9="'"+adress.getText()+"'";
sql2.executeUpdate("UPDATE studentb SET adress="+s9+" WHERE sn="+templong+"");
String s10="'"+filenamepath+"'";
sql2.executeUpdate("UPDATE studentb SET photo="+s10+" WHERE sn="+templong+"");
String s11="'"+resume.getText()+"'";
sql2.executeUpdate("UPDATE studentb SET resume="+s11+" WHERE sn="+templong+"");
JOptionPane.showMessageDialog(this,"修改成功!","提示:",JOptionPane.INFORMATION_MESSAGE);
}
}
if(tempbool==false)
{
JOptionPane.showMessageDialog(this,"该号不存在,请重新输入!","警告:",JOptionPane.WARNING_MESSAGE);
studentnumber.setText("");
name.setText("");
password.setText("");
telephone.setText("");
adress.setText("");
sex.setSelectedIndex(0);
party.setSelected(false);
age.setText("");
grade.setSelectedIndex(0);
resume.setText("");
photo.setIcon(new ImageIcon("2.gif"));
}
}
catch(SQLException ee4)
{
}
}
if(e.getSource()==next)
{
Connection con=null;
Statement sql=null;
ResultSet result;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e5)
{
System.out.println(""+e5);
}
try
{
con=DriverManager.getConnection("jdbc:odbc:me2","zww","123");
sql=con.createStatement();
result=sql.executeQuery("SELECT * FROM studentb");
String temps=studentnumber.getText();
long templong=Long.parseLong(temps);
boolean tempbool=false;
boolean tempbool2=false;
while(result.next())
{
if(tempbool2==true)
{
long templong2=result.getLong("sn");
String tempsn=String.valueOf(templong2);
studentnumber.setText(tempsn);
name.setText(result.getString("name"));
password.setText(result.getString("password"));
telephone.setText(result.getString("telephone"));
adress.setText(result.getString("adress"));
sex.setSelectedIndex(result.getInt("sex"));
party.setSelected(result.getBoolean("party"));
int tempage=result.getInt("age");
String tempage1=String.valueOf(tempage);
age.setText(tempage1);
grade.setSelectedIndex(result.getInt("grade"));
resume.setText(result.getString("resume"));
photo.setIcon(new ImageIcon(result.getString("photo")));
tempbool2=false;
}
if(result.getLong("sn")==templong)
{
tempbool=true;
tempbool2=true;
}
}
if(tempbool==false)
{
JOptionPane.showMessageDialog(this,"该号不存在,请重新输入!","警告:",JOptionPane.WARNING_MESSAGE);
studentnumber.setText("");
name.setText("");
password.setText("");
telephone.setText("");
adress.setText("");
sex.setSelectedIndex(0);
party.setSelected(false);
age.setText("");
grade.setSelectedIndex(0);
resume.setText("");
photo.setIcon(new ImageIcon("2.gif"));
}
}
catch(SQLException ee5)
{
}
}
if(e.getSource()==previous)
{
Connection con=null;
Statement sql=null;
ResultSet result;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e5)
{
System.out.println(""+e5);
}
try
{
con=DriverManager.getConnection("jdbc:odbc:me2","zww","123");
sql=con.createStatement();
sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
result=sql.executeQuery("SELECT * FROM studentb");
String temps=studentnumber.getText();
long templong=Long.parseLong(temps);
boolean tempbool=false;
boolean tempbool2=false;
result.afterLast();
while(result.previous())
{
if(tempbool2==true)
{
long templong2=result.getLong("sn");
String tempsn=String.valueOf(templong2);
studentnumber.setText(tempsn);
name.setText(result.getString("name"));
password.setText(result.getString("password"));
telephone.setText(result.getString("telephone"));
adress.setText(result.getString("adress"));
sex.setSelectedIndex(result.getInt("sex"));
party.setSelected(result.getBoolean("party"));
int tempage=result.getInt("age");
String tempage1=String.valueOf(tempage);
age.setText(tempage1);
grade.setSelectedIndex(result.getInt("grade"));
resume.setText(result.getString("resume"));
photo.setIcon(new ImageIcon(result.getString("photo")));
tempbool2=false;
}
if(result.getLong("sn")==templong)
{
tempbool=true;
tempbool2=true;
}
}
if(tempbool==false)
{
JOptionPane.showMessageDialog(this,"该号不存在,请重新输入!","警告:",JOptionPane.WARNING_MESSAGE);
studentnumber.setText("");
name.setText("");
password.setText("");
telephone.setText("");
adress.setText("");
sex.setSelectedIndex(0);
party.setSelected(false);
age.setText("");
grade.setSelectedIndex(0);
resume.setText("");
photo.setIcon(new ImageIcon("2.gif"));
}
}
catch(SQLException ee5)
{
}
}
if(e.getSource()==first)
{
Connection con=null;
Statement sql=null;
ResultSet result;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e5)
{
System.out.println(""+e5);
}
try
{
con=DriverManager.getConnection("jdbc:odbc:me2","zww","123");
sql=con.createStatement();
result=sql.executeQuery("SELECT * FROM studentb");
boolean once=false;
while(result.next()&&once==false)
{
long templong2=result.getLong("sn");
String tempsn=String.valueOf(templong2);
studentnumber.setText(tempsn);
name.setText(result.getString("name"));
password.setText(result.getString("password"));
telephone.setText(result.getString("telephone"));
adress.setText(result.getString("adress"));
sex.setSelectedIndex(result.getInt("sex"));
party.setSelected(result.getBoolean("party"));
int tempage=result.getInt("age");
String tempage1=String.valueOf(tempage);
age.setText(tempage1);
grade.setSelectedIndex(result.getInt("grade"));
resume.setText(result.getString("resume"));
photo.setIcon(new ImageIcon(result.getString("photo")));
once=true;
}
}
catch(SQLException ee5)
{
}
}
if(e.getSource()==last)
{
Connection con=null;
Statement sql=null;
ResultSet result;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e5)
{
System.out.println(""+e5);
}
try
{
con=DriverManager.getConnection("jdbc:odbc:me2","zww","123");
sql=con.createStatement();
sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
result=sql.executeQuery("SELECT * FROM studentb");
boolean once=false;
result.afterLast();
while(result.previous()&&once==false)
{
long templong2=result.getLong("sn");
String tempsn=String.valueOf(templong2);
studentnumber.setText(tempsn);
name.setText(result.getString("name"));
password.setText(result.getString("password"));
telephone.setText(result.getString("telephone"));
adress.setText(result.getString("adress"));
sex.setSelectedIndex(result.getInt("sex"));
party.setSelected(result.getBoolean("party"));
int tempage=result.getInt("age");
String tempage1=String.valueOf(tempage);
age.setText(tempage1);
grade.setSelectedIndex(result.getInt("grade"));
resume.setText(result.getString("resume"));
photo.setIcon(new ImageIcon(result.getString("photo")));
once=true;
}
}
catch(SQLException ee5)
{
}
}
}
}
//------------------------------------------------------------------------------------------------------------------------------
class BikeRemain extends JFrame implements ActionListener
{
static int idcount=0;
static int idcount2=0;
JTextField studentnumber;
JTextField name;
JTextField password;
JTextField telephone;
JTextField adress;
JComboBox sex;
JCheckBox party;
JTextField age;
JComboBox grade;
JButton backcolor;
JButton forcolor;
JLabel photo;
JButton photoButton;
JTextArea resume;
JSplitPane split_one;
JSplitPane split_two;
JSplitPane split_three;
JButton add;
JButton delete;
JButton search;
JButton change;
JButton next;
JButton previous;
JButton first;
JButton last;
JTable table;
DefaultTableModel model;
JCheckBoxMenuItem toolbarVisible;
JMenuItem count;
JMenuItem exit;
JToolBar toolbar;
JButton countButton;
JButton exitButton;
JLabel dispTime;
JLabel position=new JLabel();
int num=0;
String filenamepath="2.gif";
BikeRemain()
{
super("自行车进库管理系统");
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
//System.exit(0);
//System.runFinalizersOnExit(false);
System.runFinalization();
//new ExitWindow();
}
});
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -