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

📄 xiajiface.java

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

import java.awt.BorderLayout;
import java.awt.Frame;

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 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.JEditorPane;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.awt.Font;
import java.awt.Dimension;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import java.awt.SystemColor;
import mysystem.Face;
import mysystem.xiajijiemian;
import javax.swing.JFrame;
import javax.swing.event.AncestorEvent;
import javax.swing.event.AncestorListener;
import javax.swing.JOptionPane;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class xiajiface extends JFrame {
   String kahao;
   String  kaishi;
   Lianjie co=new Lianjie();
   float sheng;
   int fee = 0;
   Face main;
   Statement s;
   ResultSet rs;
   Connection c;
    JButton jButton1 = new JButton();
    JLabel jLabel2 = new JLabel();
    JTextField jTextField1 = new JTextField();
    JComboBox jComboBox1 = new JComboBox();
    JLabel jLabel1 = new JLabel();
    JLabel jLabel3 = new JLabel();
    Date date = new Date();
      SimpleDateFormat myformat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    public xiajiface(Face frame) {

        try {
          main=frame;
            jbInit();

        } catch (Exception exception) {
            exception.printStackTrace();}
    }


private void jbInit() throws Exception {
        this.getContentPane().setLayout(null);
        c= co.con();
        s=c.createStatement();
        rs=s.executeQuery("select ID from computer where Onuse='Y' order by ID");
    while(rs.next())
    {
     jComboBox1.addItem(rs.getInt(1) );
        }
        jButton1.setBounds(new Rectangle(132, 254, 57, 20));
        jButton1.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 10));
        jButton1.setForeground(Color.magenta);
        jButton1.setText("确定");
        jButton1.addActionListener(new xiajiface_jButton1_actionAdapter(this));
        jLabel2.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 15));
        jLabel2.setForeground(Color.magenta);
        jLabel2.setText("下机时间");
        jLabel2.setBounds(new Rectangle(14, 187, 130, 30));
        jTextField1.setForeground(Color.magenta);
        jTextField1.setCaretColor(Color.green);
        jTextField1.setSelectedTextColor(Color.magenta);
        jTextField1.setText("");
        jTextField1.setBounds(new Rectangle(89, 192, 130, 20));
        jComboBox1.setForeground(Color.magenta);
        jComboBox1.setBounds(new Rectangle(90, 137, 65, 20));

        jLabel1.setBounds(new Rectangle(17, 130, 130, 30));
        jLabel1.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 15));
        jLabel1.setForeground(Color.magenta);
        jLabel1.setText("机器号码");
        jLabel3.setText("");
        jLabel3.setBounds(new Rectangle(0, 0, 483, 344));
        jLabel3.addAncestorListener(new xiajiface_jLabel3_ancestorAdapter(this));
        this.getContentPane().add(jLabel2);
        this.getContentPane().add(jTextField1);
        this.getContentPane().add(jComboBox1);
        this.getContentPane().add(jLabel1);
        this.getContentPane().add(jButton1);
        this.getContentPane().add(jLabel3);
        jTextField1.setEditable(false);

      System.out.println(myformat.format(date));
      this.jTextField1.setText(myformat.format(date));
      jLabel3 .setIcon(new ImageIcon("3.jpg"));
    }

    public void jButton1_actionPerformed(ActionEvent e) {



            this.dispose();
            xiajijiemian jiemian=new xiajijiemian(main) ;
            main.setContentPane(jiemian);
            main.show();


             int i=Integer.parseInt(jComboBox1.getSelectedItem().toString());
        try{

            rs= s.executeQuery("select kahao, kaishi from computer where ID ="+i );
          if(rs.next())

          {
              kahao=rs.getString(1);
              kaishi=rs.getString(2);

           s.executeQuery("update computer set onuse='N' ,kaishi=null,kahao=null where ID="+i);

          jComboBox1.removeItem(jComboBox1.getSelectedItem());
          }
      }

      catch(NullPointerException L)
       {System.out .println(L);}

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




   try{
        int beginYear = Integer.parseInt(kaishi.substring(0, 4));
        int beginMonth = Integer.parseInt(kaishi.substring(5, 7));
        int beginDay = Integer.parseInt(kaishi.substring(8, 10));
        int beginHour = Integer.parseInt(kaishi.substring(11, 13));
        int beiginMinute = Integer.parseInt(kaishi.substring(14, 16));

        int endYear = Integer.parseInt(myformat.format(date).toString().substring(0, 4));
        int endMonth = Integer.parseInt(myformat.format(date).toString().substring(5 , 7));
        int endDay = Integer.parseInt(myformat.format(date).toString().substring(8, 10));
        int endHour = Integer.parseInt(myformat.format(date).toString().substring(11, 13));
        int endMinute = Integer.parseInt(myformat.format(date).toString().substring(14, 16));


        int playMinutes = 0;
        playMinutes = ((endYear - beginYear) * 365 * 24 * 60 +
                       (endMonth - beginMonth) * 30 * 24 * 60 +
                       (endDay - beginDay) * 24 * 60 +
                       (endHour - beginHour) * 60 + (endMinute - beiginMinute)
                      );

        int modNum = playMinutes % 60;
        int playHours = 0;
        playHours = playMinutes / 60;
        if (playHours == 0 || (modNum > 5 && playHours > 0)) {
            playHours++;
        }
        fee = playHours * 2;



         rs=s.executeQuery("select fee from card where kahao='"+kahao+"'");
          while(rs.next())
          {   sheng=rs.getFloat(1);    }
         float n=sheng-fee;
          s.executeUpdate("update card set fee='"+n+"' where kahao='"+kahao+"'");


     jiemian.jLabel7.setText(jComboBox1.getSelectedItem().toString());
    jiemian.jLabel8.setText(kahao);
    jiemian.jLabel9.setText(kaishi);
    jiemian.jLabel10.setText(myformat.format(date));
    jiemian.jLabel11.setText(""+fee);
    jiemian.jLabel12.setText(""+(sheng-fee));    }
    catch(SQLException N)
    {      System.out .println(N) ;    }
    catch(NullPointerException L)
       {System.out .println(L);}


    }

    public void jLabel3_ancestorAdded(AncestorEvent event) {

    }

}


class xiajiface_jLabel3_ancestorAdapter implements AncestorListener {
    private xiajiface adaptee;
    xiajiface_jLabel3_ancestorAdapter(xiajiface adaptee) {
        this.adaptee = adaptee;
    }

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

    public void ancestorRemoved(AncestorEvent event) {
    }

    public void ancestorMoved(AncestorEvent event) {
    }
}


class xiajiface_jButton1_actionAdapter implements ActionListener {
    private xiajiface adaptee;
    xiajiface_jButton1_actionAdapter(xiajiface adaptee) {
        this.adaptee = adaptee;
    }

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

⌨️ 快捷键说明

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