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

📄 guanli.java~69~

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

import java.awt.BorderLayout;

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

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class guanli extends JPanel {
    Face main;
    Lianjie co=new Lianjie();
    Statement s;
    Connection c;
    ResultSet rs;



    JLabel jLabel1 = new JLabel();
    JLabel jLabel2 = new JLabel();
    JLabel jLabel3 = new JLabel();
    JButton jButton2 = new JButton();
    JButton jButton3 = new JButton();
    JButton jButton4 = new JButton();
    JButton jButton5 = new JButton();
    JTextField jTextField2 = new JTextField();
    JTextField jTextField3 = new JTextField();
    JTextField jTextField4 = new JTextField();
    JTextField jTextField5 = new JTextField();
    JLabel jLabel5 = new JLabel();
    JPasswordField jPasswordField1 = new JPasswordField();
    JTextField jTextField8 = new JTextField();
    JLabel jLabel4 = new JLabel();
    JButton jButton1 = new JButton();
    JTextField jTextField1 = new JTextField();
    JPasswordField jPasswordField2 = new JPasswordField();
    JTextField jTextField6 = new JTextField();
    JTextField jTextField7 = new JTextField();
    JLabel jLabel6 = new JLabel();
    JOptionPane jOptionPane1 = new JOptionPane();
    public guanli(Face k) {
        try {
            main=k;
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        this.setLayout(null);
        jLabel1.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 15));
        jLabel1.setForeground(Color.magenta);
        jLabel1.setText("卡号");
        jLabel1.setBounds(new Rectangle(10, 80, 80, 20));
        jLabel2.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 15));
        jLabel2.setForeground(Color.magenta);
        jLabel2.setText("用户名");
        jLabel2.setBounds(new Rectangle(110, 80, 80, 20));
        jLabel3.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 15));
        jLabel3.setForeground(Color.magenta);
        jLabel3.setText("密码");
        jLabel3.setBounds(new Rectangle(210, 80, 80, 20));
        jButton2.setBounds(new Rectangle(510, 200, 80, 20));
        jButton2.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 12));
        jButton2.setForeground(Color.magenta);
        jButton2.setText("用户充值");
        jButton2.addActionListener(new guanli_jButton2_actionAdapter(this));
        jButton3.setBounds(new Rectangle(510, 260, 80, 20));
        jButton3.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 12));
        jButton3.setForeground(Color.magenta);
        jButton3.setText("添加用户");
        jButton3.addActionListener(new guanli_jButton3_actionAdapter(this));
        jButton4.setBounds(new Rectangle(199, 365, 57, 20));
        jButton4.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 12));
        jButton4.setForeground(Color.magenta);
        jButton4.setText("上机");
        jButton4.addActionListener(new guanli_jButton4_actionAdapter(this));
        jButton5.setBounds(new Rectangle(344, 364, 57, 20));
        jButton5.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 12));
        jButton5.setForeground(Color.magenta);
        jButton5.setText("下机");
        jButton5.addActionListener(new guanli_jButton5_actionAdapter(this));
        jTextField2.setForeground(Color.magenta);
        jTextField2.setText("");
        jTextField2.setBounds(new Rectangle(110, 140, 80, 20));
        jTextField3.setForeground(Color.magenta);
        jTextField3.setText("");
        jTextField3.setBounds(new Rectangle(10, 200, 80, 20));
        jTextField4.setForeground(Color.magenta);
        jTextField4.setText("");
        jTextField4.setBounds(new Rectangle(110, 200, 80, 20));
        jTextField5.setForeground(Color.magenta);
        jTextField5.setText("");
        jTextField5.setBounds(new Rectangle(410, 200, 77, 20));
        jLabel5.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 15));
        jLabel5.setForeground(Color.magenta);
        jLabel5.setText("金额");
        jLabel5.setBounds(new Rectangle(410, 80, 80, 20));
        jPasswordField1.setForeground(Color.magenta);
        jPasswordField1.setText("");
        jPasswordField1.setBounds(new Rectangle(210, 260, 80, 20));
        jTextField8.setForeground(Color.magenta);
        jTextField8.setText("");
        jTextField8.setBounds(new Rectangle(410, 260, 80, 20));
        jLabel4.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 15));
        jLabel4.setForeground(Color.magenta);
        jLabel4.setText("重复密码");
        jLabel4.setBounds(new Rectangle(310, 80, 80, 20));
        jButton1.setBounds(new Rectangle(510, 140, 80, 20));
        jButton1.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 12));
        jButton1.setForeground(Color.magenta);
        jButton1.setText("删除用户");
        jButton1.addActionListener(new guanli_jButton1_actionAdapter(this));
        jTextField1.setForeground(Color.magenta);
        jTextField1.setText("");
        jTextField1.setBounds(new Rectangle(10, 140, 80, 20));
        jPasswordField2.setForeground(Color.magenta);
        jPasswordField2.setText("");
        jPasswordField2.setBounds(new Rectangle(310, 260, 80, 20));
        jTextField6.setForeground(Color.magenta);
        jTextField6.setText("");
        jTextField6.setBounds(new Rectangle(10, 260, 80, 20));
        jTextField7.setForeground(Color.magenta);
        jTextField7.setText("");
        jTextField7.setBounds(new Rectangle(110, 260, 80, 20));
        jLabel6.setText("");
        jLabel6.setBounds(new Rectangle(0, 0, 650, 488));
        jLabel6 .setIcon(new ImageIcon("6.jpg"));
        this.add(jLabel3);
        this.add(jLabel1);
        this.add(jTextField1);
        this.add(jTextField3);
        this.add(jTextField6);
        this.add(jLabel2);
        this.add(jTextField2);
        this.add(jTextField4);
        this.add(jTextField7);
        this.add(jPasswordField1);
        this.add(jPasswordField2);
        this.add(jTextField8);
        this.add(jLabel5);
        this.add(jLabel4);
        this.add(jTextField5);
        this.add(jButton3);
        this.add(jButton2);
        this.add(jButton1);
        this.add(jButton5);
        this.add(jButton4);
        this.add(jLabel6);
        c=co.con();
           s=c.createStatement();

    }

    public void jButton4_actionPerformed(ActionEvent e) {
        Shangjiface jiemian=new Shangjiface(main) ;
       main.setContentPane(jiemian);
   main.show();

    }

    public void jButton5_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(4*(fsize.width-dsize.width)/5+loc.x,4*(fsize.height-dsize.height)/5+loc.y );
        xia.show();

    }

    public void jButton1_actionPerformed(ActionEvent e) {

       String u=jTextField1.getText().toString();
       String p=jTextField2.getText().toString();
        try{
              rs=s.executeQuery("select *from card where name='"+p+"' and kahao='"+u+"'");

           if(rs.next())
            {   s.executeUpdate("update card set name=null, password=null,fee='0' where name like '"+p+"' and kahao like '"+u+"'");
              jOptionPane1.showMessageDialog(this,"删除成功!");
              jTextField1.setText("");
               jTextField2.setText("");

            }
        else  jOptionPane1.showMessageDialog(this,"卡号与用户名不匹配!请重新输入");

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



    }

    public void jButton2_actionPerformed(ActionEvent e) {


        String u=jTextField3.getText().toString();
        String p=jTextField4.getText().toString();
        String n= jTextField5.getText().toString();

         try{
               rs=s.executeQuery("select fee from card where name like '"+p+"' and kahao like '"+u+"'");

            if(rs.next())
             {
                 float y=rs.getFloat(1);
                 int W=Integer.parseInt(n);
                 float g=y+W;
                 s.executeUpdate("update card set fee='"+g+"' where name like '"+p+"' and kahao like '"+u+"'");

                 if(n.equals("")==false)
                { jOptionPane1.showMessageDialog(this,"冲值成功!金额总计为"+g+"元");
               jTextField3.setText("");
                jTextField4.setText("");
                jTextField5.setText("");}
              if (n.equals("")==true)
            { jOptionPane1.showMessageDialog(this,"未填写金额!!");}
             }
         else  jOptionPane1.showMessageDialog(this,"卡号与用户名不匹配!请重新输入");

         }
       catch(SQLException N)
         {
             jOptionPane1.showMessageDialog(this,"冲值失败!请检查金额书写格式!");
             System.out .println(N) ;
          }catch(Exception B)
          {jOptionPane1.showMessageDialog(this,"冲值失败!请检查金额书写格式!");}



    }

    public void jButton3_actionPerformed(ActionEvent e) {

    try{    String u=jTextField6.getText().toString();
        String p = jTextField7.getText().toString();
        String n = jTextField8.getText().toString();
        String l = jPasswordField1.getText().toString();
        String m = jPasswordField2.getText().toString();
        if (u.equals("") == false && p.equals("") == false && n.equals("") == false &&
            l.equals("") == false && m.equals("") == false) {
            rs = s.executeQuery("select kahao  from card where kahao like '"+u+"'and name <> 'null'");
            if (rs.next()) {
                jOptionPane1.showMessageDialog(this, "卡号" + u + "已经被使用!");

            }

            else{

                rs = s.executeQuery("select kahao  from card where kahao like '"+u+"'");
                if(!rs.next())
                     jOptionPane1.showMessageDialog(this, "卡号" + u + "不存在!");
                 else{
                if(l.equals(m)==false)
            {     jOptionPane1.showMessageDialog(this, "两次密码不同!!");           }

             if(l.equals(m)==true)
            {     s.executeUpdate("update card set  name='"+p+"', password='"+m+"',fee='"+n+"' where kahao='"+u+"'");
                 jOptionPane1.showMessageDialog(this, "成功添加新卡号"+u+"!");
                 jTextField6.setText("");
                 jTextField7.setText("");
                 jTextField8.setText("");
                 jPasswordField1.setText("");
                  jPasswordField2.setText("");
                }
            }
            }

        }

        else {
            jOptionPane1.showMessageDialog(this, "请输入完整!不能有空项");
        }
    }

    catch(SQLException E)
    {System.out.println(E);
     jOptionPane1.showMessageDialog(this, "添加失败!请检查书写格式!");}
    catch(Exception M)
    {jOptionPane1.showMessageDialog(this, "添加失败!请检查书写格式!");}
    }
}


class guanli_jButton3_actionAdapter implements ActionListener {
    private guanli adaptee;
    guanli_jButton3_actionAdapter(guanli adaptee) {
        this.adaptee = adaptee;
    }

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


class guanli_jButton2_actionAdapter implements ActionListener {
    private guanli adaptee;
    guanli_jButton2_actionAdapter(guanli adaptee) {
        this.adaptee = adaptee;
    }

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


class guanli_jButton1_actionAdapter implements ActionListener {
    private guanli adaptee;
    guanli_jButton1_actionAdapter(guanli adaptee) {
        this.adaptee = adaptee;
    }

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


class guanli_jButton4_actionAdapter implements ActionListener {
    private guanli adaptee;
    guanli_jButton4_actionAdapter(guanli adaptee) {
        this.adaptee = adaptee;
    }

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


class guanli_jButton5_actionAdapter implements ActionListener {
    private guanli adaptee;
    guanli_jButton5_actionAdapter(guanli adaptee) {
        this.adaptee = adaptee;
    }

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

⌨️ 快捷键说明

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