登录页面,库存管理页面
This commit is contained in:
@@ -4,39 +4,66 @@ import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Random;
|
||||
|
||||
public class Main extends JFrame implements ActionListener {
|
||||
|
||||
JButton jb1,jb2,jb3;
|
||||
|
||||
JButton jb1,jb2;
|
||||
JTextField tf1,tf3;
|
||||
JPasswordField tf2;
|
||||
JLabel jl1,jl2,jl3,jl4,jl5;
|
||||
Random rand = new Random();
|
||||
Main(){
|
||||
super("超市进销存信息管理系统");
|
||||
jb1=new JButton("进货商品信息");
|
||||
jb2=new JButton("销售商品信息");
|
||||
jb3=new JButton("库存商品信息");
|
||||
super("登录");
|
||||
jb1=new JButton("登录");
|
||||
jb2=new JButton("取消");
|
||||
tf1=new JTextField(6);
|
||||
tf2=new JPasswordField(6);
|
||||
tf3=new JTextField(6);
|
||||
jl1=new JLabel("用户名",JLabel.CENTER);
|
||||
jl2=new JLabel("密码",JLabel.CENTER);
|
||||
jl3=new JLabel("验证码",JLabel.CENTER);
|
||||
jl4=new JLabel("验证码:",JLabel.CENTER);
|
||||
jl5=new JLabel("",JLabel.CENTER);
|
||||
jb1.addActionListener(this);
|
||||
jb2.addActionListener(this);
|
||||
jb3.addActionListener(this);
|
||||
setLayout(new GridLayout(3,3));
|
||||
setLayout(new GridLayout(5,2));
|
||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
add(jb1);
|
||||
add(jb2);
|
||||
add(jb3);
|
||||
setBounds(100,100,500,500);
|
||||
add(jl1);add(tf1);
|
||||
add(jl2);add(tf2);
|
||||
add(jl3);add(tf3);
|
||||
add(jl4);add(jl5);
|
||||
add(jb1);add(jb2);
|
||||
jl5.setText(Integer.toString(rand.nextInt(100)+100));
|
||||
setBounds(500,100,500,500);
|
||||
setVisible(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
if(e.getSource()==jb1){
|
||||
new InventoryProductManagement();//进入进货商品信息管理系统
|
||||
setVisible(false);
|
||||
Jdbc jdbc = new Jdbc();
|
||||
String sql = "select * from user where username='"+tf1.getText()+"' and password='"+tf2.getText()+"'"; ;
|
||||
try {
|
||||
ResultSet rs = jdbc.query(sql);
|
||||
jdbc.close();
|
||||
if(rs.next()&&tf3.getText().equals(jl5.getText())) {
|
||||
JOptionPane.showMessageDialog(null, "登录成功");
|
||||
new Home();
|
||||
this.setVisible(false);
|
||||
}
|
||||
else{
|
||||
JOptionPane.showMessageDialog(null,"登录失败");
|
||||
jl5.setText(Integer.toString(rand.nextInt(100)+100));
|
||||
}
|
||||
} catch (SQLException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}else if(e.getSource()==jb2){
|
||||
new SalesProductManagement();//进入销售商品信息管理系统
|
||||
setVisible(false);
|
||||
}else if(e.getSource()==jb3){
|
||||
new StockProductManagement();//进入库存商品信息管理系统
|
||||
setVisible(false);
|
||||
System.exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user