📄 dengluck.java
字号:
package chaoshi;import java.awt.*;import java.awt.event.*;import java.sql.*;import java.awt.Image;import java.awt.Graphics;import java.applet.Applet;public class dengluck extends Frame implements ActionListener{ static public String zhanghao=""; Label lhuanying=new Label("欢迎使用小型超市前台收款系统"); Label lzhanghao=new Label("输入帐号:"); Label lmima=new Label("输入密码:"); TextField tfzhanghao=new TextField("",16); TextField tfmima=new TextField("",16); Button bdenglu=new Button("登陆"); public dengluck() { super("登陆"); setLayout(null); setSize(400,300); setResizable(false); setLocation(300,100); this.addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e){ System.exit(0); } }); add(lhuanying); lhuanying.setBounds(1, 50, 400,20); lhuanying.setAlignment(java.awt.Label.CENTER); tfmima.setEchoChar('*'); add(lzhanghao); lzhanghao.setBounds(130,90,60,20); add(tfzhanghao); tfzhanghao.setBounds(190,90,80,20); tfzhanghao.addActionListener(this); add(lmima); lmima.setBounds(130,130,60,20); add(tfmima); tfmima.setBounds(190,130,80,20); add(bdenglu); bdenglu.setBounds(170,160,50,30); bdenglu.addActionListener(this); tfmima.addActionListener(this); tfmima.enableInputMethods(false); } public void actionPerformed(ActionEvent e){ if(e.getSource()==tfzhanghao){ tfmima.requestFocus(); } if(e.getSource()==bdenglu||e.getSource()==tfmima){ String drivers="sun.jdbc.odbc.JdbcOdbcDriver"; String url="jdbc:odbc:chaoshi"; try { Class.forName(drivers); Connection con=DriverManager.getConnection(url); Statement stmt=con.createStatement(); String sql="select 帐号,密码,权限 from zhb where 帐号='"+tfzhanghao.getText()+"' and 密码='"+tfmima.getText()+"'"; ResultSet rs=stmt.executeQuery(sql); if(rs.next()){ zhanghao=rs.getString(1); if(rs.getString("权限").equals("收银员")) { new syyck(zhanghao).setVisible(true); } else { new glyck(zhanghao).setVisible(true); } this.setVisible(false); } else{ new dcuowu(this, true); } rs.close(); stmt.close(); con.close(); } catch(java.lang.Exception e1){ e1.printStackTrace(); } } }class dcuowu extends Dialog implements ActionListener{ Label lcuowu=new Label("用户名或密码错误!"); Button bqueding =new Button("确定"); dcuowu(dengluck parent,boolean model){ super(parent,model); setTitle("错误"); setSize(300,120); setResizable(false); setLayout(null); setLocation(350,200); add(lcuowu);lcuowu.setAlignment(java.awt.Label.CENTER);lcuowu.setBounds(0, 50, 300, 22); add(bqueding);bqueding.setBounds(120, 80, 57, 26); addWindowListener(new WindowAdapter(){ public void windowClosing(WindowEvent e2){ dispose(); } }); bqueding.addActionListener(this); setVisible(true); } public void actionPerformed(ActionEvent e){ if(e.getSource()==bqueding){ tfmima.setText(""); dispose(); } }}}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -