⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 shangjiface.java~145~

📁 java实战网吧计费系统
💻 JAVA~145~
字号:
package mysystem;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.awt.BorderLayout;
import java.awt.Frame;
import java.sql.SQLException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.PreparedStatement;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JButton;
import java.awt.Rectangle;
import java.awt.Color;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import javax.swing.JFormattedTextField;

import javax.swing.JButton;
import java.awt.Rectangle;
import java.awt.Color;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JComboBox;

import mysystem.Lianjie;
import javax.swing.JPasswordField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import java.lang.Integer;
import mysystem.Face;
import java.awt.Font;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import java.awt.Dimension;
import java.awt.Point;
import mysystem.huanji;
/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class Shangjiface extends JPanel  {
   Lianjie co=new Lianjie();
   Statement s;
   ResultSet rs;
   ResultSet  rss;
   Connection c;
   Face main;
    JPanel panel1 = new JPanel();
    JButton jButton1 = new JButton();
    JButton jButton2 = new JButton();
    JLabel jLabel1 = new JLabel();
    JLabel jLabel2 = new JLabel();
    JLabel jLabel3 = new JLabel();
    JLabel jLabel4 = new JLabel();
    JComboBox jComboBox1 = new JComboBox();
    JTextField jTextField1 = new JTextField();
    JTextField   jTextField3 = new JTextField();
    JPasswordField jPasswordField1 = new JPasswordField();
    JOptionPane jOptionPane1 = new JOptionPane();
    JButton jButton3 = new JButton();
    JLabel jLabel5 = new JLabel();
    JButton jButton4 = new JButton();
    public Shangjiface(Face j) {
       try {
            main=j;
           jbInit();
       } catch (Exception exception) {
           exception.printStackTrace();
       }
   }




    private void jbInit() throws Exception {
        setSize(new Dimension(650,488 ));
        panel1.setLayout(null);
        jButton1.setBounds(new Rectangle(130, 389, 57, 20));
        jButton1.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 10));
        jButton1.setForeground(Color.magenta);
        jButton1.setText("确定");
        jButton1.addActionListener(new Shangjiface_jButton1_actionAdapter(this));
        jButton2.setBounds(new Rectangle(48, 389, 57, 20));
        jButton2.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 10));
        jButton2.setForeground(Color.magenta);
        jButton2.setText("重置");
        jButton2.addActionListener(new Shangjiface_jButton2_actionAdapter(this));
        jLabel1.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 15));
        jLabel1.setForeground(Color.magenta);
        jLabel1.setText("机器号码");
        jLabel1.setBounds(new Rectangle(20, 150, 70, 25));
        jLabel2.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 15));
        jLabel2.setForeground(Color.magenta);
        jLabel2.setText("卡号");
        jLabel2.setBounds(new Rectangle(20, 200, 55,25));
        jLabel3.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 15));
        jLabel3.setForeground(Color.magenta);
        jLabel3.setText("密码");
        jLabel3.setBounds(new Rectangle(21, 250, 55, 25));
        jLabel4.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 15));
        jLabel4.setForeground(Color.magenta);
        jLabel4.setText("开始时间");
        jLabel4.setBounds(new Rectangle(20, 300, 70, 25));
        jComboBox1.setForeground(Color.red);
        jComboBox1.setBounds(new Rectangle(90, 150, 60, 20));
        jTextField1.setForeground(Color.magenta);

        jTextField1.setText("");
        jTextField1.setBounds(new Rectangle(90, 200, 80, 20));
        jTextField3.setForeground(Color.magenta);

        jTextField3.setText("");
        jTextField3.setBounds(new Rectangle(90, 300, 130, 20));
        panel1.setBackground(Color.green);
        panel1.setBounds(new Rectangle(10, 16, 1, 1));
        jPasswordField1.setForeground(Color.magenta);
        jPasswordField1.setText("");
        jPasswordField1.setBounds(new Rectangle(90, 250, 80, 20));
        this.setLayout(null);
        jButton3.setBounds(new Rectangle(213, 389, 57, 20));
        jButton3.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 10));
        jButton3.setForeground(Color.magenta);
        jButton3.setText("下机");
        jButton3.addActionListener(new Shangjiface_jButton3_actionAdapter(this));
        jLabel5.setText("");
        jLabel5.setBounds(new Rectangle( 0, 0, 650, 488));
        jLabel5 .setIcon(new ImageIcon("2.jpg"));
        jButton4.setBounds(new Rectangle(294, 390, 57, 20));
        jButton4.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 10));
        jButton4.setForeground(Color.magenta);
        jButton4.setText("换机");
        jButton4.addActionListener(new Shangjiface_jButton4_actionAdapter(this));
        this.add(panel1);
        this.add(jLabel4);
        this.add(jLabel3);
        this.add(jLabel2);
        this.add(jLabel1);
        this.add(jPasswordField1);
        this.add(jTextField1);
        this.add(jComboBox1);
        this.add(jTextField3);
        this.add(jButton2);
        this.add(jButton4);
        this.add(jButton1);
        this.add(jButton3);
        this.add(jLabel5);
        c= co.con();
        Times t=new Times();
        t.start();
      jTextField3.setEditable(false);
     s=c.createStatement();
     rs=s.executeQuery("select ID from computer where Onuse='0' order by ID");
      while(rs.next())
      {
      jComboBox1.addItem(rs.getInt(1));
      }



    }

    public void jButton1_actionPerformed(ActionEvent e) {
      String n=jTextField1.getText();
      String p=jPasswordField1.getText();
      String t=jTextField3.getText();
      if(n.equals("")==true||p.equals("")==true)
      { jOptionPane1.showMessageDialog(this,"信息输入不完全!,请重新输入!");   }
     try{

         rs=s.executeQuery("select ID,password from card where ID like'"+n+"'and password like '"+p+"' ");
         if(!rs.next()&&n.equals("")==false&&p.equals("")==false)

       { jOptionPane1.showMessageDialog(this,"信息输入错误!请重新输入!");}
       else
    {rss=s.executeQuery("select Id,password ,balance from card where Id like'"+n+"'and password like '"+p+"'and balance>='2.0' ");

        if(rss.next())

            {
         int i=Integer.parseInt(jComboBox1.getSelectedItem().toString());
                jOptionPane1.showMessageDialog(this,"您已成功登陆!您的余额还剩 "+rss.getFloat(3)+" 元" );
                s.executeUpdate("update computer set  id='"+ jTextField1.getText()+"',OnUse='1';update Record set BeginTime='"+ jTextField3.getText()+"' where ID="+i);

                jComboBox1.removeItem(jComboBox1.getSelectedItem());



       jTextField1.setText("");
       jPasswordField1.setText("") ;}
       else

   {

       if( n.equals("")==false&&p.equals("")==false) jOptionPane1.showMessageDialog(this,"您的余额不足!!" );}

    }




 }  catch (SQLException N)
     {System.out.println(N); }



    }

    class Times extends Thread{
         public void run(){
             while(true){
                 Date d = new Date();
                 SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

                 jTextField3.setText(sim.format(d));
                 try {

                     Thread.sleep(1000);

                 } catch (Exception ex) {
                     System.out.println(ex);
                 }
      }
  }


}


    public void jButton2_actionPerformed(ActionEvent e) {

        jPasswordField1.setText("");
        jTextField1.setText("");

    }

    public void jButton3_actionPerformed(ActionEvent e) {
        xiajiface xia=new xiajiface(main);
            xia.setSize(483,344);
            Dimension dsize=xia.getPreferredSize();
            Dimension fsize=xia.getSize();

            Point loc=getLocation();
            xia.setLocation(5*(fsize.width-dsize.width)/6+loc.x,4*(fsize.height-dsize.height)/5+loc.y );
         xia.show();
    }


    public void jButton4_actionPerformed(ActionEvent e) {

        huanji jiemian=new huanji(main) ;
        main.setContentPane(jiemian);
       main.show();




    }

    class Shangjiface_jButton1_actionAdapter implements ActionListener {
    private Shangjiface adaptee;
    Shangjiface_jButton1_actionAdapter(Shangjiface adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton1_actionPerformed(e);
    }
}}


class Shangjiface_jButton4_actionAdapter implements ActionListener {
    private Shangjiface adaptee;
    Shangjiface_jButton4_actionAdapter(Shangjiface adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton4_actionPerformed(e);
    }
}


class Shangjiface_jButton3_actionAdapter implements ActionListener {
    private Shangjiface adaptee;
    Shangjiface_jButton3_actionAdapter(Shangjiface adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton3_actionPerformed(e);
    }
}


class Shangjiface_jButton2_actionAdapter implements ActionListener {
    private Shangjiface adaptee;
    Shangjiface_jButton2_actionAdapter(Shangjiface adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.jButton2_actionPerformed(e);
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -