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

📄 edirfrm.java

📁 ATM系统分为前台和后台
💻 JAVA
字号:
package atm;

import java.awt.BorderLayout;

import javax.swing.ButtonGroup;
import javax.swing.JPanel;
import javax.swing.JFrame;
//import java.awt.Dimension;
import javax.swing.JLabel;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
//import java.sql.SQLException;

import javax.swing.JTextField;
//import javax.swing.JComboBox;
import javax.swing.JRadioButton;
import javax.swing.JButton;

import oo.Sql;
import javax.swing.JComboBox;

public class EdirFrm extends JFrame {

	private static final long serialVersionUID = 1L;

	private JPanel jContentPane = null;

	private JPanel jPanel = null;

	private JLabel jLabel = null;

	private JLabel jLabel1 = null;

	private JLabel jLabel2 = null;

	private JLabel jLabel3 = null;

	private JLabel jLabel4 = null;

	private JTextField jTextField = null;

	private JPanel jPanel1 = null;

	private JRadioButton jRadioButton = null;

	private JRadioButton jRadioButton1 = null;

	private JButton jButton = null;

	private JButton jButton1 = null;

	/**
	 * This is the default constructor
	 */
	public EdirFrm() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(305, 262);
		this.setContentPane(getJContentPane());
		this.setTitle("卡修改");
		try{
			con=db.getConn();
			ResultSet rs=db.executeQuery("select * from cardInfo");
			while(rs.next()){
				jTextField.setText(rs.getString("cardID"));
				jTextField.setEnabled(false);
			//	jComboBox.addItem(rs.getString(2));
			//	jComboBox1.addItem(rs.getString(3));
			}
		}catch(Exception E){
			E.printStackTrace();
		}finally{
			db.closeDB();
		}
		
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(new BorderLayout());
			jContentPane.add(getJPanel(), BorderLayout.CENTER);
		}
		return jContentPane;
	}

	/**
	 * This method initializes jPanel	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanel() {
		if (jPanel == null) {
			GridBagConstraints gridBagConstraints21 = new GridBagConstraints();
			gridBagConstraints21.fill = GridBagConstraints.VERTICAL;
			gridBagConstraints21.gridy = 3;
			gridBagConstraints21.weightx = 1.0;
			gridBagConstraints21.gridx = 1;
			GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
			gridBagConstraints11.fill = GridBagConstraints.VERTICAL;
			gridBagConstraints11.gridy = 2;
			gridBagConstraints11.weightx = 1.0;
			gridBagConstraints11.gridx = 1;
			GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
			gridBagConstraints10.gridx = 1;
			gridBagConstraints10.gridy = 6;
			GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
			gridBagConstraints5.gridx = 1;
			gridBagConstraints5.gridy = 5;
			GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
			gridBagConstraints9.gridx = 1;
			gridBagConstraints9.gridy = 4;
			GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
			gridBagConstraints6.fill = GridBagConstraints.VERTICAL;
			gridBagConstraints6.gridy = 0;
			gridBagConstraints6.weightx = 1.0;
			gridBagConstraints6.gridx = 1;
			GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
			gridBagConstraints4.gridx = 0;
			gridBagConstraints4.gridy = 4;
			jLabel4 = new JLabel();
			jLabel4.setText("是否挂失:");
			GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
			gridBagConstraints3.gridx = 0;
			gridBagConstraints3.gridy = 3;
			jLabel3 = new JLabel();
			jLabel3.setText("存款类型:");
			GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
			gridBagConstraints2.gridx = 0;
			gridBagConstraints2.gridy = 2;
			jLabel2 = new JLabel();
			jLabel2.setText("货币种类:");
			GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
			gridBagConstraints1.gridx = 0;
			gridBagConstraints1.gridy = 1;
			jLabel1 = new JLabel();
			jLabel1.setText("");
			GridBagConstraints gridBagConstraints = new GridBagConstraints();
			gridBagConstraints.gridx = 0;
			gridBagConstraints.gridy = 0;
			jLabel = new JLabel();
			jLabel.setText("卡号:");
			jPanel = new JPanel();
			jPanel.setLayout(new GridBagLayout());
			jPanel.add(jLabel, gridBagConstraints);
			jPanel.add(jLabel1, gridBagConstraints1);
			jPanel.add(jLabel2, gridBagConstraints2);
			jPanel.add(jLabel3, gridBagConstraints3);
			jPanel.add(jLabel4, gridBagConstraints4);
			jPanel.add(getJTextField(), gridBagConstraints6);
			jPanel.add(getJPanel1(), gridBagConstraints9);
			jPanel.add(getJButton(), gridBagConstraints5);
			jPanel.add(getJButton1(), gridBagConstraints10);
			jPanel.add(getJComboBox(), gridBagConstraints11);
			jPanel.add(getJComboBox1(), gridBagConstraints21);
		}
		return jPanel;
	}

	/**
	 * This method initializes jTextField	
	 * 	
	 * @return javax.swing.JTextField	
	 */
	private JTextField getJTextField() {
		if (jTextField == null) {
			jTextField = new JTextField();
			jTextField.setColumns(18);
		}
		return jTextField;
	}

	/**
	 * This method initializes jPanel1	
	 * 	
	 * @return javax.swing.JPanel	
	 */
	private JPanel getJPanel1() {
		if (jPanel1 == null) {
			jPanel1 = new JPanel();
			jPanel1.setLayout(new GridBagLayout());
			jPanel1.add(getJRadioButton(), new GridBagConstraints());
			jPanel1.add(getJRadioButton1(), new GridBagConstraints());
			group=new ButtonGroup();///
			group.add(getJRadioButton1());
			group.add(getJRadioButton());
		}
		return jPanel1;
	}
	private ButtonGroup group; 
	/**
	 * This method initializes jRadioButton	
	 * 	
	 * @return javax.swing.JRadioButton	
	 */
	private JRadioButton getJRadioButton() {
		if (jRadioButton == null) {
			jRadioButton = new JRadioButton();
			jRadioButton.setText("是");
			jRadioButton.addItemListener(new java.awt.event.ItemListener() {
				public void itemStateChanged(java.awt.event.ItemEvent e) {
					System.out.println("itemStateChanged()"); // TODO Auto-generated Event stub itemStateChanged()
	            if(jRadioButton.isSelected());
	            flag=1;
				}
			});
		}
		return jRadioButton;
	}
	/**
	 * This method initializes jRadioButton1	
	 * 	
	 * @return javax.swing.JRadioButton	
	 */
	private JRadioButton getJRadioButton1() {
		if (jRadioButton1 == null) {
			jRadioButton1 = new JRadioButton();
			jRadioButton1.setText("否");
			jRadioButton1.addItemListener(new java.awt.event.ItemListener() {
				public void itemStateChanged(java.awt.event.ItemEvent e) {
					System.out.println("itemStateChanged()"); // TODO Auto-generated Event stub itemStateChanged()
				if(jRadioButton1.isSelected());
				flag=0;
				}
			});
		}
		return jRadioButton1;
	}
     int flag=0;
	/**
	 * This method initializes jButton	
	 * 	
	 * @return javax.swing.JButton	
	 */
	
	private JButton getJButton() {
		if (jButton == null) {
			jButton = new JButton();
			jButton.setText(" 确定修改");
			jButton.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
					quer();
				}
			});
		}
		return jButton;
	}
	Sql db=new Sql();  //  @jve:decl-index=0:
	Connection con;
	ResultSet rs;

	private JComboBox jComboBox = null;

	private JComboBox jComboBox1 = null;
	public void quer(){
		db.getConn();
     //   boolean success = false;
        ResultSet rs = db.executeQuery("SELECT * FROM cardInfo");
        //查询并判断原始信息是否匹配jTextField.getText().equals(rs.getString("cardID")) ||+jRadioButton.getText()+"'"||jRadioButton1.getText().equals("IsReportLoss")
        try {
         /*   while (rs.next()) {
                if ( jComboBox.getSelectedItem().equals("curType")||jComboBox1.getSelectedItem().equals("savingType")) {
                    success = true;
                }
            }*/
            //匹配则容许修改
         //   if (success) {
               // if (db.executeUpdateSQL("UPDATE cardInfo SET curType='"+jComboBox.getSelectedItem()+"',savingType='"+jComboBox1.getSelectedItem()+"'")) {
            	  if (db.executeUpdateSQL("UPDATE cardInfo SET savingType ='" + jComboBox1.getSelectedItem() +"',curType='"+jComboBox.getSelectedItem()+"',IsReportLoss =" +  flag+ " WHERE cardID ='" + jTextField.getText().trim()+"'")) {
            		javax.swing.JOptionPane.showMessageDialog(this,"信息修改成功。");
                } else {
                    javax.swing.JOptionPane.showMessageDialog(this, "信息修改失败,请重试。");
                }
       /* //*    } else {
                javax.swing.JOptionPane.showMessageDialog(this,"未修改用户!请重新修改!");
                return;
         //   }*/
        } catch (Exception ex) {
            javax.swing.JOptionPane.showMessageDialog(this,ex.getMessage().toString());
         //   return;
        } 
		/*try{
			con=db.getConn();
			ResultSet rs=db.executeQuery("select * from cardInfo");
			while(rs.next()){
				
				if(db.executeUpdateSQL("update cardInfo set curType='"+jComboBox.getSelectedItem()+"',savingType='"+jComboBox1.getSelectedItem()+"','"+jRadioButton.getText()+"' where cardID='"+UserFrm.cardID+"'")){
					javax.swing.JOptionPane.showMessageDialog(this,"信息修改成功。");
				}else {
                    javax.swing.JOptionPane.showMessageDialog(this, "信息修改失败,请重试。");
                }
			}
		}catch(Exception E){
			E.printStackTrace();
		}finally{
			db.closeDB();
		}*/
	}

	/**
	 * This method initializes jButton1	
	 * 	
	 * @return javax.swing.JButton	
	 */
	public void close(){
		this.setVisible(false);
	}
	private JButton getJButton1() {
		if (jButton1 == null) {
			jButton1 = new JButton();
			jButton1.setText("返回");
			jButton1.addActionListener(new java.awt.event.ActionListener() {
				public void actionPerformed(java.awt.event.ActionEvent e) {
					System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
				close();
				}
			});
		}
		return jButton1;
	}

	/**
	 * This method initializes jComboBox	
	 * 	
	 * @return javax.swing.JComboBox	
	 */
	String[] a={"美元","RMB"};
	String[] aa={"活期","定期","定活两期"};
	private JComboBox getJComboBox() {
		if (jComboBox == null) {
			jComboBox = new JComboBox(a);
		}
		return jComboBox;
	}

	/**
	 * This method initializes jComboBox1	
	 * 	
	 * @return javax.swing.JComboBox	
	 */
	private JComboBox getJComboBox1() {
		if (jComboBox1 == null) {
			jComboBox1 = new JComboBox(aa);
		}
		return jComboBox1;
	}

}  //  @jve:decl-index=0:visual-constraint="10,17"

⌨️ 快捷键说明

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