📄 ydq.java
字号:
a[i][2]=s3;
a[i][3]=s4.substring(0,10);
a[i][4]=s5;
a[i][5]=s6;
i++;
}
}
con.close();
}
}
}
class chaxunyuandaima extends Frame implements ActionListener
{TextArea text;
Button button,button2;
String s;
PrintJob p=null;
Graphics g=null;
FileDialog filedialog_save;
FileReader file_reader;
FileWriter file_writer;
BufferedReader in;
BufferedWriter out;
chaxunyuandaima()
{super("查询程序源代码");
setBackground(color);
setSize(300,400);
text=new TextArea(30,50);
setBounds(200,200,600,500);
setVisible(false);
button=new Button("代码另存为");
button2=new Button("打印代码");
button.addActionListener(this);
button2.addActionListener(this);
Panel p1=new Panel();
p1.add(text,"left");
p1.add(button,"center");
p1.add(button2,"east");
add(p1);
validate();
filedialog_save=new FileDialog(this,"代码另存为",FileDialog.SAVE);
addWindowListener (new WindowAdapter()
{public void windowClosing(WindowEvent e)
{setVisible(false);}
}
);
filedialog_save.addWindowListener (new WindowAdapter()
{public void windowClosing(WindowEvent e)
{filedialog_save.setVisible(false);}
}
);
try
{file_reader =new FileReader("ydq.java");
in =new BufferedReader(file_reader);
while((s=in.readLine())!=null)
text.append(s+'\n');
in.close();
file_reader.close();
}
catch(IOException e3) {}
}
public void actionPerformed(ActionEvent e)
{if(e.getSource()==button)
{ filedialog_save.setVisible(true);
try
{File file=new File(filedialog_save.getDirectory(),filedialog_save.getFile());
file_writer =new FileWriter(file);
out =new BufferedWriter(file_writer);
out.write(text.getText(),0,(text.getText().length()));
out.flush();
out.close();
file_writer.close();
}
catch(IOException e4) {}
}
else if(e.getSource()==button2)
{p=getToolkit().getPrintJob(this,"打印程序代码",null);
g=p.getGraphics();
g.translate(120,200);
text.printAll(g);
g.dispose();
p.end();
}
}
}
class getip extends Frame
{TextField text;
getip()
{super("查询IP地址");
setBackground(color);
setSize(100,100);
text=new TextField(20);
setBounds(200,200,300,100);
setVisible(false);
Panel p1=new Panel();
p1.add(text);
add(p1);
validate();
addWindowListener (new WindowAdapter()
{public void windowClosing(WindowEvent e)
{setVisible(false);}
}
);
try
{InetAddress address=InetAddress.getLocalHost();
String ipname=address.getHostAddress();
text.setText(ipname);
}
catch(UnknownHostException e) {}
}
}
class kaishiyunxing extends Frame implements ActionListener
{TextField text;
Button button;
kaishiyunxing()
{super("开始---运行");
setBackground(color);
setSize(50,50);
text=new TextField(18);
setBounds(200,200,250,250);
setVisible(false);
button=new Button("运行");
button.addActionListener(this);
Panel p1=new Panel();
p1.add(text,"left");
p1.add(button,"Center");
add(p1);
validate();
addWindowListener (new WindowAdapter()
{public void windowClosing(WindowEvent e)
{setVisible(false);}
}
);
}
public void actionPerformed(ActionEvent e)
{ boolean s=true;
if(e.getSource()==button)
try
{Runtime ce=Runtime.getRuntime();
String qq=text.getText();
File f=new File("c:/windows",qq);
ce.exec(f.getAbsolutePath());
s=false;
return;
}
catch(Exception e1) {}
if(s)
{text.setText("c:/windows下没有该程序");}
}
}
}
}
//管理员页面(独立的类,不需要从denglu类里调用参数)
class admin extends Frame implements ActionListener
{ MenuBar menubar;
Menu menu1,menu2,menu3;
MenuItem item1,item2,item3,item4,item5,item6,item7;
Connection con=null;
Statement sql=null;
ResultSet rs=null;
Color color2=Color.cyan;
admin()
{ super("系统管理员界面");
setBackground(Color.cyan);
setSize(200,300);
setBounds(200,200,500,300);
setVisible(true);
menubar=new MenuBar();
menu1=new Menu("基本信息管理");
menu2=new Menu("课 程");
menu3=new Menu("评 教");
item1=new MenuItem("用户管理");
item2=new MenuItem("信息管理");
item3=new MenuItem("退出");
item4=new MenuItem("基本信息管理");
item5=new MenuItem("设置背景颜色");
item6=new MenuItem("成绩管理");
item7=new MenuItem("评教信息查询");
menu1.add(item1);
menu1.addSeparator();
menu1.add(item2);
menu1.addSeparator();
menu1.add(item5);
menu1.addSeparator();
menu1.add(item3);
menu2.add(item4);
menu2.addSeparator();
menu2.add(item6);
menu3.add(item7);
menubar.add(menu1);
menubar.add(menu2);
menubar.add(menu3);
setMenuBar(menubar);
item1.addActionListener(this);
item2.addActionListener(this);
item3.addActionListener(this);
item4.addActionListener(this);
item5.addActionListener(this);
item6.addActionListener(this);
item7.addActionListener(this);
addWindowListener (new WindowAdapter()
{public void windowClosing(WindowEvent e)
{System.exit(0);}
}
);
}
public void actionPerformed(ActionEvent e)
{if(e.getSource()==item1)
{ yonghuguanli jj=new yonghuguanli();
jj.setVisible(true);
}
else if(e.getSource()==item2)
{xinxi kkk=new xinxi();
kkk.setVisible(true);
}
else if(e.getSource()==item3)
{System.exit(0);
}
else if(e.getSource()==item4)
{kecheng ll=new kecheng();
ll.setVisible(true);
}
else if(e.getSource()==item5)
{color2=JColorChooser.showDialog(this,"杨德青",getBackground());
setBackground(color2);
}
else if(e.getSource()==item6)
{chengji oo=new chengji();
oo.setVisible(true);
}
else if(e.getSource()==item7)
{pingjiaochaxun ll=new pingjiaochaxun();
ll.setVisible(true);
}
}
class yonghuguanli extends Frame implements ActionListener
{ Label label1,label2,label3;
TextField text1,text2,text3;
Button button1,button2,button3;
Connection con=null;
Statement sql=null;
ResultSet rs=null;
yonghuguanli()
{super("用户管理页面");
setBackground(color2);
setSize(100,400);
setBounds(200,200,700,300);
setVisible(false);
label1=new Label("用户名");
label2=new Label("密码");
label3=new Label("确认密码");
text1=new TextField(10);
text2=new TextField(15);
text3=new TextField(15);
button1=new Button("查询密码");
button2=new Button("添加用户");
button3=new Button("删除用户");
button1.addActionListener(this);
button2.addActionListener(this);
button3.addActionListener(this);
Panel p1=new Panel();
Panel p2=new Panel();
Panel p3=new Panel();
Panel p4=new Panel();
Panel p5=new Panel();
Panel p6=new Panel();
p1.add(label1,"West");
p1.add(text1,"Center");
p2.add(label2,"West");
p2.add(text2,"Center");
p3.add(label3,"West");
p3.add(text3,"Center");
p4.add(button1,"West");
p4.add(button2,"Center");
p4.add(button3,"East");
p5.add(p1,"North");
p5.add(p2,"Center");
p5.add(p3,"South");
p6.add(p5,"West");
p6.add(p4,"Center");
add(p6);
addWindowListener (new WindowAdapter()
{public void windowClosing(WindowEvent e)
{dispose();}
}
);
}
public void actionPerformed(ActionEvent e)
{if (e.getSource()==button1)
{try
{chaxunmima();
}
catch(SQLException e5) {}
}
else if(e.getSource()==button2)
{try
{adduser();
}
catch(SQLException q5) {}
}
else if(e.getSource()==button3)
{try
{deleteuser();
}
catch(SQLException e7) {}
}
}
public void chaxunmima() throws SQLException
{ try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}
catch(ClassNotFoundException e2) {}
con=DriverManager.getConnection("jdbc:odbc:qqq","","");
sql=con.createStatement();
String s1="'"+text1.getText().trim()+"'";
rs=sql.executeQuery("select * from denglu where 用户名="+s1);
while(rs.next())
{ String qq=rs.getString("密码");
text2.setText(qq);
con.close();
return;
}
JOptionPane.showMessageDialog(this,"该用户不存在","提示",JOptionPane.WARNING_MESSAGE);
}
public void adduser() throws SQLException
{ try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}
catch(ClassNotFoundException e2) {}
con=DriverManager.getConnection("jdbc:odbc:qqq","","");
sql=con.createStatement();
String s1="'"+text1.getText().trim()+"'";
String s2="'"+text2.getText().trim()+"'";
String s3="'"+text3.getText().trim()+"'";
rs=sql.executeQuery("select * from denglu where 用户名="+s1);
while(rs.next())
{ JOptionPane.showMessageDialog(this,"数据库已有该用户","提示",JOptionPane.WARNING_MESSAGE);
return;
}
if(text1.getText().equals(""))
{JOptionPane.showMessageDialog(this,"用户名不能为空","提示",JOptionPane.WARNING_MESSAGE);
return;
}
if(text2.getText().equals("")&&text3.getText().equals(""))
{JOptionPane.showMessageDialog(this,"密码不能为空","提示",JOptionPane.WARNING_MESSAGE);
return;
}
if(s2.equals(s3))
{sql.executeUpdate("insert into denglu values("+s1+","+s2+",'用户')");
JOptionPane.showMessageDialog(this,"添加成功","提示",JOptionPane.WARNING_MESSAGE);
con.close();
}
else
{JOptionPane.showMessageDialog(this,"两次输入的密码不一样,请重新输入","提示",JOptionPane.WARNING_MESSAGE);
}
}
public void deleteuser() throws SQLException
{ try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}
catch(ClassNotFoundException e2) {}
con=DriverManager.getConnection("jdbc:odbc:qqq","","");
sql=con.createStatement();
String s1="'"+text1.getText().trim()+"'";
rs=sql.executeQuery("select * from denglu where 用户名="+s1);
while(rs.next())
{sql.executeUpdate("delete from denglu where 用户名="+s1);
JOptionPane.showMessageDialog(this,"删除成功","提示",JOptionPane.WARNING_MESSAGE);
text1.setText("");
text2.setText("");
text3.setText("");
con.close();
return;
}
JOptionPane.showMessageDialog(this,"数据库中没有该用户","警告",JOptionPane.WARNING_MESSAGE);
}
}
class xinxi extends Frame implements ActionListener
{ Label label1,label2,label3,label4,label5,label6,label7,label8;
Button button1,button2;
TextField text1,text2,text3,text4,text5,text6,text7,text8;
Connection con=null;
Statement sql=null;
ResultSet rs=null;
String ll1,ll2,ll3,ll4,ll5,ll6,ll7;
xinxi()
{super("信息管理");
setBackground(color2);
setSize(400,400);
setBounds(200,200,700,300);
setVisible(false);
label1=new Label("用户名");
label2=new Label("姓名");
label3=new Label("性别");
label4=new Label("出生日期");
label5=new Label("家庭住址");
label6=new Label("院系");
label7=new Label("班级");
label8=new Label("爱好");
button1=new Button("查询");
button2=new Button("修改");
text1=new TextField(10);
text2=new TextField(10);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -