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

📄 openpane.java

📁 课程设计:ATM Project源码
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.Locale;
import java.util.Date;
import java.sql.*;
import java.text.*;
import javax.swing.border.*;
public class OpenPane extends JPanel 
{  
   ReadAtmID Idsource;
   Component f;
   JLabel l1=new JLabel("卡号:");
   JLabel l2=new JLabel("姓名:");
   JLabel l3=new JLabel("密码:");
   JLabel l4=new JLabel("身份证:");
   JLabel l5=new JLabel("金额:");
   JLabel Title=new JLabel(new ImageIcon("..\\..\\title\\create.gif"));
Font font=new Font("宋体",Font.BOLD,32);
Font fontword = new Font("楷体_GB2312",Font.BOLD,18);
Font fontinput=new Font("Serif",Font.BOLD,18);
   JTextField txtCard= new JTextField(10);
   JTextField txtName= new JTextField(10);
   JPasswordField txtPwd= new JPasswordField(10);
   JTextField txtID= new JTextField(10);
   JTextField txtMoney= new JTextField(10);
   JButton btConfirm=new JButton("开户");
   JButton btCancel=new JButton("取消");
   JButton btBack=new JButton("返回");
   Icon img=new ImageIcon(".\\gif\\ts.gif");
   Date today =new Date();
   AtmAccount Customer;
   private ActionListener listener=new ActionResponse();
   public OpenPane (Component ComponentF)
   {
   	f=ComponentF;
   	Idsource = new ReadAtmID(f);
   	this.setLayout(null);
   	this.setBorder(BorderFactory.createTitledBorder(
            BorderFactory.createLineBorder(Color.BLACK,1),
            "请输入用户信息",TitledBorder.CENTER,TitledBorder.TOP));
   	l1.setBounds(150,115,100,35);
   	l2.setBounds(150,145,100,35);
    l3.setBounds(150,175,100,35);
    l4.setBounds(130,205,100,35);
    l5.setBounds(150,235,100,35);
    l1.setFont(fontword);
    l2.setFont(fontword);
    l3.setFont(fontword);
    l4.setFont(fontword);
    l5.setFont(fontword);
    l1.setForeground(Color.blue);
    l2.setForeground(Color.blue);
    l3.setForeground(Color.blue);
    l4.setForeground(Color.blue);
    l5.setForeground(Color.blue);
    btConfirm.setFont(fontinput);
    btCancel.setFont(fontinput);
    btBack.setFont(fontinput);
    txtCard.setBounds(220,120,150,20);
   	txtName.setBounds(220,150,150,20);
   	txtPwd.setBounds(220,180,150,20);
   	txtID.setBounds(220,210,150,20);
   	txtMoney.setBounds(220,240,150,20);
   	txtCard.setFont(fontinput);
   	txtCard.setEditable(false);
   	txtCard.setForeground(Color.red);
   	txtName.setFont(fontinput);
   	txtPwd.setFont(fontinput);
   	txtID.setFont(fontinput);
   	txtMoney.setFont(fontinput);
   	btConfirm.setBounds(420,300,100,30);
   	btCancel.setBounds(420,340,100,30);
   	btBack.setBounds(420,380,100,30);
   	Title.setBounds(50,20,490,100);
   	Title.setForeground(Color.red);
   	Title.setFont(font);
   	this.add(Title);
   	btConfirm.addActionListener(listener);
   	btCancel.addActionListener(listener);
   	btBack.addActionListener(listener);
   	this.add(l1);
   	this.add(l2);
   	this.add(l3);
   	this.add(l4);
   	this.add(l5);
   	this.add(txtCard);
   	this.add(txtName);
   	this.add(txtPwd);
   	this.add(txtID);
   	this.add(txtMoney);	
   	this.add(btConfirm);
   	this.add(btCancel);
   	this.add(btBack);
   	txtCard.setText(String.valueOf(Idsource.getid()));
   }

   class ActionResponse implements ActionListener
   {
   	public void actionPerformed (ActionEvent e) 
    {
	   String cmd = e.getActionCommand();
	   if (cmd.equals("开户"))
	   {
	    Locale CurLocale=new Locale("zh","CN");
	    txtCard.setText(String.valueOf(Idsource.getid()));
	    NumberFormat curformater=NumberFormat.getCurrencyInstance(CurLocale);
	    //Customer.Sum=curformater.format(Double.parseDouble(txtMoney.getText()));
        Customer =new AtmAccount(f);
	    Customer.CardID=txtCard.getText();
	    Customer.Name=txtName.getText();
	    Customer.Password=txtPwd.getPassword();
	    //JOptionPane.showMessageDialog(f, "您的输入可能有错!", "提示", JOptionPane.INFORMATION_MESSAGE);
	    Customer.Sum=Double.parseDouble(txtMoney.getText());
	    Customer.CreateDate=today;
	    Customer.Licence=txtID.getText();
	    Customer.LostFlag=false;
	    Customer.OutDate=today;
        String title = "请确定输入用户信息";
        int type = JOptionPane.INFORMATION_MESSAGE;
        SimpleDateFormat DateFormatter=new SimpleDateFormat("yyyy/MM/dd");
        String[] options={"开户","取消"};
        int optionType=JOptionPane.YES_NO_OPTION;
        int messageType=JOptionPane.QUESTION_MESSAGE; 
        String message = "姓名:"+Customer.Name+"\n金额:"+curformater.format(Customer.Sum)+"\n身份证号: "+Customer.Licence+"\n办卡日期: "+DateFormatter.format(Customer.CreateDate);
        System.out.println(DateFormatter.format(Customer.CreateDate));
        int result = JOptionPane.showOptionDialog(f,message, title, optionType,messageType,null,options,options[1]);
        if (result == JOptionPane.YES_OPTION)
        {//UpdateNew(Customer.CardID,Customer.Name,Customer.Password,Customer.Sum,Customer.CreateDate,Customer.Licence,false,Customer.OutDate);
        try{        Customer.UpdateNew();
                    Idsource.AddAtmid();
                    txtCard.setText(String.valueOf(Idsource.getid()));     }
      catch(SQLException Exp)
      {
      	JOptionPane.showMessageDialog(f, "输入值有误,请更正!", "错误:", JOptionPane.INFORMATION_MESSAGE);
      }
      catch(ClassNotFoundException Exp)
      {
      	JOptionPane.showMessageDialog(f, Exp.toString(), "错误:", JOptionPane.INFORMATION_MESSAGE);
      }
      catch(Exception Exp)
      {
      	JOptionPane.showMessageDialog(f,Exp.toString(), "错误:", JOptionPane.INFORMATION_MESSAGE);
      }
       
        }
       }  
    }
    
   } 
  }
  
		
	

⌨️ 快捷键说明

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