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

📄 huanji.java~30~

📁 java实战网吧计费系统
💻 JAVA~30~
字号:
package mysystem;

import java.awt.BorderLayout;

import javax.swing.JPanel;
import mysystem.Face;
import javax.swing.JComboBox;
import java.awt.Rectangle;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JLabel;
import java.awt.Color;
import java.awt.Font;
import javax.swing.JOptionPane;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Dimension;
import java.awt.Point;
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 mysystem.Lianjie;
import javax.swing.event.AncestorEvent;
import javax.swing.event.AncestorListener;
import javax.swing.ImageIcon;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class huanji extends JPanel {

    Face main;
    Lianjie lian=new Lianjie();
    Connection con;
    Statement s;
    ResultSet rs;
    public huanji(Face g) {
        try {
            main=g;
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        this.setLayout(null);
        jComboBox1.setForeground(Color.magenta);
        jComboBox1.setBounds(new Rectangle(110, 140, 75, 20));
        jComboBox2.setForeground(Color.magenta);
        jComboBox2.setBounds(new Rectangle(110, 200, 75, 20));
        jTextField1.setForeground(Color.magenta);
        jTextField1.setText("");
        jTextField1.setBounds(new Rectangle(110, 260, 75, 20));
        jButton1.setBounds(new Rectangle(41, 349, 57, 20));
        jButton1.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 12));
        jButton1.setForeground(Color.magenta);
        jButton1.setText("确定");
        jButton1.addActionListener(new huanji_jButton1_actionAdapter(this));
        jButton2.setBounds(new Rectangle(128, 349, 57, 20));
        jButton2.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 12));
        jButton2.setForeground(Color.magenta);
        jButton2.setText("上机");
        jButton2.addActionListener(new huanji_jButton2_actionAdapter(this));
        jButton3.setBounds(new Rectangle(212, 350, 57, 20));
        jButton3.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 12));
        jButton3.setForeground(Color.magenta);
        jButton3.setText("下机");
        jButton3.addActionListener(new huanji_jButton3_actionAdapter(this));
        jLabel1.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 15));
        jLabel1.setForeground(Color.magenta);
        jLabel1.setText("原机号");
        jLabel1.setBounds(new Rectangle(30, 140, 64, 14));
        jLabel2.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 15));
        jLabel2.setForeground(Color.magenta);
        jLabel2.setText("新机号");
        jLabel2.setBounds(new Rectangle(30, 200, 53, 15));
        jLabel3.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 15));
        jLabel3.setForeground(Color.magenta);
        jLabel3.setText("卡号");
        jLabel3.setBounds(new Rectangle(30, 260, 42, 15));
        jOptionPane1.addAncestorListener(new
                                         huanji_jOptionPane1_ancestorAdapter(this));
        jLabel4.setText("");
        jLabel4.setBounds(new Rectangle( 0,0, 650, 488));
        this.add(jButton1);
        this.add(jButton2);
        this.add(jButton3);
        this.add(jComboBox1);
        this.add(jComboBox2);
        this.add(jTextField1);
        this.add(jLabel1);
        this.add(jLabel2);
        this.add(jLabel3);
        this.add(jLabel4);
        jLabel4 .setIcon(new ImageIcon("12.jpg"));
        con=lian.con();
          s=con.createStatement();
        rs=s.executeQuery("select ID from computer where onuse='Y' order by ID");
      while(rs.next())
      {
      jComboBox1.addItem(rs.getInt(1));
      }
    rs=s.executeQuery("select ID from computer where Onuse='N' order by ID");
     while(rs.next())
     {
     jComboBox2.addItem(rs.getInt(1));
     }


    }

    JComboBox jComboBox1 = new JComboBox();
    JComboBox jComboBox2 = new JComboBox();
    JTextField jTextField1 = new JTextField();
    JButton jButton1 = new JButton();
    JButton jButton2 = new JButton();
    JButton jButton3 = new JButton();
    JLabel jLabel1 = new JLabel();
    JLabel jLabel2 = new JLabel();
    JLabel jLabel3 = new JLabel();
    JOptionPane jOptionPane1 = new JOptionPane();
    JLabel jLabel4 = new JLabel();
    public void jButton2_actionPerformed(ActionEvent e) {
          Shangjiface jiemian=new Shangjiface(main) ;
           main.setContentPane(jiemian);
          main.show();

    }

    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 jButton1_actionPerformed(ActionEvent e) {
    try
     {
            String u=jComboBox1.getSelectedItem().toString();
            String p=jComboBox2.getSelectedItem().toString();
            String k=jTextField1.getText();
            int i=Integer.parseInt(jComboBox1.getSelectedItem().toString());
            int r=Integer.parseInt(jComboBox2.getSelectedItem().toString());
         if(u.equals("")==false&&k.equals("")==false&&p.equals("")==false)
        {
              rs=s.executeQuery("select ID,kahao,kaishi from computer where ID='"+u+"' and kahao='"+k+"'");
             if(rs.next())
             {     String t=rs.getString(3);

                 s.executeUpdate("update computer set onuse='N' ,kaishi=null,kahao=null where ID="+i);
                 s.executeUpdate("update computer set onuse='Y' ,kaishi='"+t+"',kahao='"+k+"' where ID="+r);

                 jComboBox1.removeItem(jComboBox1.getSelectedItem());
                 jComboBox1.addItem(p);
                 jComboBox2.removeItem(jComboBox2.getSelectedItem());
                 jComboBox2.addItem(u);
                 jOptionPane1.showMessageDialog(this,"已经成功换机!");
                 jTextField1.setText("");
             }

        else
        {jOptionPane1.showMessageDialog(this,"卡号与原机号不匹配!请重新输入卡号!");
        jTextField1.setText("");
        }

     }
        else{  jOptionPane1.showMessageDialog(this,"未输入卡号!");}

    }catch(NullPointerException N)
    { jOptionPane1.showMessageDialog(this,"机器号为空!");}
       catch(SQLException G)
       {}


    }

    public void jOptionPane1_ancestorAdded(AncestorEvent event) {

    }
}


class huanji_jOptionPane1_ancestorAdapter implements AncestorListener {
    private huanji adaptee;
    huanji_jOptionPane1_ancestorAdapter(huanji adaptee) {
        this.adaptee = adaptee;
    }

    public void ancestorAdded(AncestorEvent event) {
        adaptee.jOptionPane1_ancestorAdded(event);
    }

    public void ancestorRemoved(AncestorEvent event) {
    }

    public void ancestorMoved(AncestorEvent event) {
    }
}


class huanji_jButton1_actionAdapter implements ActionListener {
    private huanji adaptee;
    huanji_jButton1_actionAdapter(huanji adaptee) {
        this.adaptee = adaptee;
    }

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


class huanji_jButton3_actionAdapter implements ActionListener {
    private huanji adaptee;
    huanji_jButton3_actionAdapter(huanji adaptee) {
        this.adaptee = adaptee;
    }

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


class huanji_jButton2_actionAdapter implements ActionListener {
    private huanji adaptee;
    huanji_jButton2_actionAdapter(huanji adaptee) {
        this.adaptee = adaptee;
    }

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

⌨️ 快捷键说明

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