/*******************************************************
* 程序文件: Saving.java
* 建立时间: 2004年07月01日
* 建立人: InberKong
* 最后修改: 2004年07月01日
* 修改人: InberKong
* 功 能: 客户偿还贷款
*******************************************************/
//import java.sql.Connection;
//import java.sql.SQLException;
//import java.sql.PreparedStatement;
//import java.sql.ResultSet;
//import java.sql.DriverManager;
import java.sql.*;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.lang.*;
public class Saving extends JFrame implements ActionListener
{
static JFrame frameObject;
static JPanel panelObject;
static JLabel labelRegid;
static JLabel labelPsw;
static JLabel labelReturncash;
static JTextField textRegid;
static JPasswordField textPsw;
static JTextField textReturncash;
static JButton buttonLogin;
static JButton buttonCheck;
static ResultSet result;
static Connection con;
static PreparedStatement stat;
static String strSql;
public Saving()
{
panelObject=new JPanel();
frameObject.getContentPane().add(panelObject);
frameObject.setDefaultCloseOperation(frameObject.EXIT_ON_CLOSE);
labelRegid =new JLabel("labelRegid");
labelPsw =new JLabel("labelPsw");
labelReturncash=new JLabel("labelReturncash");
textRegid=new JTextField(15);
textPsw=new JPasswordField(15);
textReturncash=new JTextField(15);
buttonLogin= new JButton("登录");
buttonCheck=new JButton("还款");
panelObject.add(labelRegid);
panelObject.add(textRegid);
panelObject.add(labelPsw);
panelObject.add(textPsw);
panelObject.add(buttonLogin);
panelObject.add(labelReturncash);
panelObject.add(textReturncash);
panelObject.add(buttonCheck);
this.labelReturncash.setVisible(false);
this.textReturncash.setVisible(false);
this.buttonCheck.setVisible(false);
buttonLogin.addActionListener(this);
buttonCheck.addActionListener(this);
}
public static void main(String args[])
{
frameObject =new JFrame("贷款归还系统");
frameObject.setDefaultCloseOperation(frameObject.EXIT_ON_CLOSE);
frameObject.setVisible(true);
frameObject.setSize(300,300);
Saving h= new Saving();
}
public void actionPerformed(ActionEvent evt)
{
Object obj=evt.getSource();
if(obj==buttonLogin)
{
String CtextRegid=textRegid.getText();
String CtextPsw=textPsw.getText();
if(CtextRegid.length()==0)
{
JOptionPane.showMessageDialog(frameObject,new String("Please enter the Regid value!"));
}
else if(CtextPsw.length()==0)
{
JOptionPane.showMessageDialog(frameObject,new String("Please enter the Psw value!"));
}
else
{
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con;
con=DriverManager.getConnection("jdbc:odbc:MyDataSource","sa","123");
strSql="Select * from Cregister where reg_name=?";
stat=con.prepareStatement(strSql);
stat.setString(1,textRegid.getText());
result=stat.executeQuery();
}
catch(Exception e)
{
System.out.println(" Could not execute the query "+e);
}
labelRegid.setVisible(false);
labelPsw.setVisible(false);
textRegid.setVisible(false);
textPsw.setVisible(false);
buttonLogin.setVisible(false);
labelReturncash.setVisible(true);
textReturncash.setVisible(true);
buttonCheck.setVisible(true);
}
}
if(obj==buttonCheck)
{
JOptionPane.showMessageDialog(frameObject,new String("buttonCheck checked!"));
}
}
}