Java program bridge joint database

zhaozj2021-02-16  57

/ ************************************************** ****** * Program file: saving.java * Establishment time: July 01, 2004 * Established: Inberkong

* Last modified: July 01, 2004 * Modifier: Inberkong * function: customer repayment loan *************************** *************************** / // 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 ( "login "); 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 ( "Loan-back system"); 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.jdbcodbcodbdriver "); connection 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!"));}}

}

转载请注明原文地址:https://www.9cbs.com/read-18103.html

New Post(0)