小超市管理系统

时间:2016-07-08 14:06:18
【文件属性】:

文件名称:小超市管理系统

文件大小:704KB

文件格式:DOC

更新时间:2016-07-08 14:06:18

java

java的小超市管理系统 public class Login extends Frame implements ActionListener,WindowListener //登陆界面 { public int screanWidth,screanHeight; String idin=null; String keyin=null; String passwordD=null; public static String persontyD=null; MenuBar menubar; Menu menu; MenuItem quet,help; Label id,key; TextField idtf,keytf; Box boxV1,boxV2,boxV3,baseBox,boxx; Button enterB; Login() { setTitle("超市管理系统登陆界面"); Toolkit tool=getToolkit(); Dimension dim=tool.getScreenSize(); screanWidth=dim.width; screanHeight=dim.height; setBounds(dim.width/3,dim.height/3,320,215); menubar=new MenuBar(); menu=new Menu("功能"); help=new MenuItem("帮助"); quet=new MenuItem("退出"); quet.setShortcut(new MenuShortcut(KeyEvent.VK_E)); quet.addActionListener(new ActionListener() //匿名类实例控制 { public void actionPerformed(ActionEvent p){ System.exit(0); }} ); menu.add(help); menu.add(quet); menubar.add(menu); setMenuBar(menubar); id=new Label("请输入帐号:",Label.RIGHT); key=new Label("请输入密码:",Label.RIGHT); idtf=new TextField(10); keytf=new TextField(10); keytf.setEchoChar('*'); enterB=new Button("登陆"); boxV1=Box.createVerticalBox(); boxV1.add(Box.createVerticalStrut(35)); boxV1.add(id); boxV1.add(Box.createVerticalStrut(15)); boxV1.add(key); boxV1.add(Box.createVerticalStrut(15)); boxV2=Box.createVerticalBox(); boxV2.add(Box.createVerticalStrut(35)); boxV2.add(idtf); boxV2.add(Box.createVerticalStrut(15)); boxV2.add(keytf); boxV2.add(Box.createVerticalStrut(15)); baseBox=Box.createHorizontalBox(); baseBox.add(Box.createHorizontalStrut(25)); baseBox.add(boxV1); baseBox.add(Box.createHorizontalStrut(5)); baseBox.add(boxV2); baseBox.add(Box.createHorizontalStrut(70)); boxV3=Box.createHorizontalBox(); boxV3.add(Box.createHorizontalStrut(125)); boxV3.add(enterB); boxV3.add(Box.createHorizontalStrut(125)); boxx=Box.createVerticalBox(); boxx.add(baseBox); boxx.add(Box.createVerticalStrut(15)); boxx.add(boxV3); boxx.add(Box.createVerticalStrut(70)); add(boxx); enterB.addActionListener(this); addWindowListener(this); setResizable(false); setVisible(true); } public void actionPerformed(ActionEvent e) { Connection con; Statement sql; ResultSet rs; if (e.getSource()==enterB) { idin=idtf.getText(); keyin=keytf.getText(); try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); } catch (ClassNotFoundException f) {System.out.println(""+f);} try {con=DriverManager.getConnection("jdbc:odbc:q","",""); sql=con.createStatement(); rs=sql.executeQuery("SELECT * FROM password where ID='"+idin+"'"); while(rs.next()){ passwordD=rs.getString(2); persontyD=rs.getString(3);} con.close();} catch (SQLException g) {System.out.println(g);} if (keyin.equals(passwordD)) {View2 frame=new View2(); this.setVisible(false); } else {JOptionPane.showMessageDialog(this," 帐户或密码错误\n 请重新输入","提示",JOptionPane.WARNING_MESSAGE); } } } public void windowActivated(WindowEvent o) {validate();} public void windowDeactivated(WindowEvent o) {setBounds(screanWidth/3,screanHeight/3,320,215); validate();} public void windowClosing(WindowEvent o) {dispose();} public void windowClosed(WindowEvent o) {System.exit(0);} public void windowIconified(WindowEvent o) {} public void windowDeiconified(WindowEvent o) {setBounds(screanWidth/3,screanHeight/3,320,215); validate();} public void windowOpened(WindowEvent o){} }


网友评论