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

📄 tezcdialog.java~3~

📁 简单的学生管理系统。。用JBUILER和SQL2000。
💻 JAVA~3~
字号:
package studentgl;import java.awt.*;import javax.swing.*;import java.awt.event.*;import java.sql.*;/** * <p>Title: </p> * <p>Description: </p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: </p> * @author not attributable * @version 1.0 */public class tezcDialog extends JDialog {  JPanel panel1 = new JPanel();  JLabel jLabel1 = new JLabel();  JLabel jLabel2 = new JLabel();  JLabel jLabel3 = new JLabel();  JLabel jLabel4 = new JLabel();  JTextField jTextField1 = new JTextField();  JTextField jTextField2 = new JTextField();  JComboBox jComboBox1 = new JComboBox();  JPasswordField jPasswordField1 = new JPasswordField();  JTextField jTextField3 = new JTextField();  JLabel jLabel5 = new JLabel();  JButton jButton1 = new JButton();  JButton jButton2 = new JButton();  private  Connection con;  private  mainFrame Frame1;  private  Statement stmt;  public tezcDialog(mainFrame frame, String title, boolean modal) {    super(frame, title, modal);    this.setLocation(309,239);    Frame1=frame;    try {      jbInit();      pack();    }    catch(Exception ex) {      ex.printStackTrace();    }  }  public tezcDialog() {    this(null, "", false);  }  private void jbInit() throws Exception {    panel1.setLayout(null);    jLabel1.setFont(new java.awt.Font("Serif", 0, 16));    jLabel1.setForeground(SystemColor.textHighlight);    jLabel1.setVerifyInputWhenFocusTarget(true);    jLabel1.setHorizontalAlignment(SwingConstants.CENTER);    jLabel1.setText("教师号:");    jLabel1.setBounds(new Rectangle(-1, 15, 85, 37));    jLabel2.setBounds(new Rectangle(196, 12, 85, 37));    jLabel2.setText("姓名:");    jLabel2.setHorizontalAlignment(SwingConstants.CENTER);    jLabel2.setVerifyInputWhenFocusTarget(true);    jLabel2.setForeground(SystemColor.textHighlight);    jLabel2.setFont(new java.awt.Font("Serif", 0, 16));    jLabel3.setFont(new java.awt.Font("Serif", 0, 16));    jLabel3.setForeground(SystemColor.textHighlight);    jLabel3.setVerifyInputWhenFocusTarget(true);    jLabel3.setHorizontalAlignment(SwingConstants.CENTER);    jLabel3.setText("性别:");    jLabel3.setBounds(new Rectangle(-1, 72, 85, 37));    jLabel4.setFont(new java.awt.Font("Serif", 0, 16));    jLabel4.setForeground(Color.red);    jLabel4.setVerifyInputWhenFocusTarget(true);    jLabel4.setHorizontalAlignment(SwingConstants.CENTER);    jLabel4.setText("密码:");    jLabel4.setBounds(new Rectangle(199, 70, 85, 37));    jTextField1.setFont(new java.awt.Font("Serif", 0, 12));    jTextField1.setText("");    jTextField1.setBounds(new Rectangle(83, 17, 104, 27));    jTextField2.setBounds(new Rectangle(262, 17, 104, 27));    jTextField2.setText("");    jTextField2.setFont(new java.awt.Font("Serif", 0, 12));    Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");    String url = "jdbc:microsoft:sqlserver://ISSAC:1433;DatabaseName=StudentGL";    String username = "sa";    String password = "123456";    Connection con = DriverManager.getConnection(url,username,password);    Statement stmt1 = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY);    ResultSet strs1 = stmt1.executeQuery("select distinct Sex from StudentInfo");    jComboBox1.setFont(new java.awt.Font("Serif", 0, 12));    jComboBox1.setBounds(new Rectangle(83, 76, 109, 23));    jComboBox1.addItem("");   while(strs1.next()){   jComboBox1.addItem(strs1.getString("Sex"));  }  con.close();    jPasswordField1.setText("");    jPasswordField1.setBounds(new Rectangle(262, 73, 106, 27));    jTextField3.setBackground(Color.lightGray);    jTextField3.setFont(new java.awt.Font("Serif", 0, 12));    jTextField3.setForeground(Color.red);    jTextField3.setSelectedTextColor(Color.white);    jTextField3.setText("所有选项都为必填!");    jTextField3.setBounds(new Rectangle(129, 130, 238, 30));    jLabel5.setFont(new java.awt.Font("Serif", 0, 16));    jLabel5.setForeground(Color.orange);    jLabel5.setText("提示信息:");    jLabel5.setBounds(new Rectangle(40, 129, 84, 30));    jButton1.setBounds(new Rectangle(82, 196, 73, 25));    jButton1.setFont(new java.awt.Font("Serif", 0, 12));    jButton1.setForeground(Color.red);    jButton1.setText("确定");    jButton1.addActionListener(new tezcDialog_jButton1_actionAdapter(this));    jButton2.setBounds(new Rectangle(269, 195, 73, 25));    jButton2.setFont(new java.awt.Font("Serif", 0, 12));    jButton2.setForeground(Color.orange);    jButton2.setText("重设");    jButton2.addActionListener(new tezcDialog_jButton2_actionAdapter(this));    getContentPane().add(panel1);    panel1.add(jLabel2, null);    panel1.add(jLabel1, null);    panel1.add(jLabel3, null);    panel1.add(jLabel4, null);    panel1.add(jTextField1, null);    panel1.add(jTextField2, null);    panel1.add(jComboBox1, null);    panel1.add(jPasswordField1, null);    panel1.add(jTextField3, null);    panel1.add(jLabel5, null);    panel1.add(jButton1, null);    panel1.add(jButton2, null);    con = connect.getconn();  }  void jButton1_actionPerformed(ActionEvent e) {    try {    con=connect.getconn();    stmt=con.createStatement();    String teid=jTextField1.getText().trim();    String xm=jTextField2.getText().trim();    String sex=jComboBox1.getSelectedItem().toString();    String pwd= jPasswordField1.getText().trim();    int rowcount=0;    String loginQuery="select * from TeacherInfo where TeID="+teid+"";    ResultSet rs = stmt.executeQuery(loginQuery);    while (rs.next()){      rowcount++;    }if(rowcount==1){       jTextField3.setText("教师号已经存在,请重新输入!");     }     else if((rowcount==0)){     String insert="insert into TeacherInfo values('"+teid+"','"+pwd+"','"+xm+"','"+sex+"')";     stmt.executeUpdate(insert);     Frame1.login=true;     this.hide();     return;     }    con.close();  }catch(SQLException ex){     System.out.print("系统或者输进数据错误!");}  }  void jButton2_actionPerformed(ActionEvent e) {    jTextField1.setText("");    jTextField2.setText("");    jTextField3.setText("所有选项都为必填!");    jPasswordField1.setText("");    jComboBox1.setSelectedIndex(0);  }}class tezcDialog_jButton1_actionAdapter implements java.awt.event.ActionListener {  tezcDialog adaptee;  tezcDialog_jButton1_actionAdapter(tezcDialog adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton1_actionPerformed(e);  }}class tezcDialog_jButton2_actionAdapter implements java.awt.event.ActionListener {  tezcDialog adaptee;  tezcDialog_jButton2_actionAdapter(tezcDialog adaptee) {    this.adaptee = adaptee;  }  public void actionPerformed(ActionEvent e) {    adaptee.jButton2_actionPerformed(e);  }}

⌨️ 快捷键说明

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