📄 modifydoctorinfo.java~7~
字号:
package cliniquemanager;
import javax.swing.*;
import java.awt.Rectangle;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.table.TableModel;
import javax.swing.table.AbstractTableModel;
import java.sql.*;
/**
* <p>Title: CliniqueManager</p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: shine</p>
*
* @author robin
* @version 1.0
*/
public class ModifyDoctorInfo extends JDialog {
Database db;
ResultSet rs;
String strUsername=new String();
JButton jButton1 = new JButton();
JPasswordField jPasswordField1 = new JPasswordField();
JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JTextField jTextField1 = new JTextField();
JLabel jLabel3 = new JLabel();
JLabel jLabel4 = new JLabel();
JTextField jTextField2 = new JTextField();
JButton jButton2 = new JButton();
JLabel jLabel5 = new JLabel();
JTextField jTextField3 = new JTextField();
JButton jButton3 = new JButton();
JTextField jTextField4 = new JTextField();
JTextField jTextField5 = new JTextField();
JLabel jLabel6 = new JLabel();
JTextField jTextField6 = new JTextField();
public ModifyDoctorInfo(Frame owner, String title, boolean modal,String strUsername) {
super(owner, title, modal);
try {
setDefaultCloseOperation(DISPOSE_ON_CLOSE);
jbInit(strUsername);
pack();
} catch (Exception exception) {
exception.printStackTrace();
}
}
public ModifyDoctorInfo(String strUsername) {
this(new Frame(), "修改医生信息", false,strUsername);
}
private void jbInit(String strUsername) throws Exception {
this.getContentPane().setLayout(null);
this.strUsername=strUsername;
jPasswordField1.setText("");
jPasswordField1.setBounds(new Rectangle(130, 85, 190, 30));
jTextField6.setText("jTextField6");
jTextField6.setBounds(new Rectangle(123, 284, 190, 30));
jLabel6.setText("密码(*):");
jLabel6.setBounds(new Rectangle(32, 83, 100, 31));
jTextField5.setText("");
jTextField5.setBounds(new Rectangle(130, 303, 190, 30));
jTextField4.setText("");
jTextField4.setBounds(new Rectangle(131, 251, 190, 30));
jTextField3.setBounds(new Rectangle(131, 197, 190, 30));
jLabel5.setText("真实姓名(*):");
jLabel5.setBounds(new Rectangle(32, 144, 101, 31));
jTextField2.setText("");
jTextField2.setBounds(new Rectangle(130, 142, 190, 30));
jLabel4.setText("用户名(*):");
jLabel4.setBounds(new Rectangle(32, 32, 97, 31));
jLabel3.setText("专业(*):");
jLabel3.setBounds(new Rectangle(32, 198, 101, 30));
jTextField1.setText("");
jTextField1.setBounds(new Rectangle(131, 32, 190, 30));
jLabel2.setText("电话号码:");
jLabel2.setBounds(new Rectangle(32, 250, 100, 31));
jLabel1.setText("Email:");
jLabel1.setBounds(new Rectangle(32, 304, 100, 31));
jButton1.setBounds(new Rectangle(27, 376, 89, 29));
jButton1.setText("修改");
jButton1.addActionListener(new ModifyDoctorInfo_jButton1_actionAdapter(this));
jButton2.setBounds(new Rectangle(132, 375, 88, 29));
jButton2.setText("置空");
jButton2.addActionListener(new ModifyDoctorInfo_jButton2_actionAdapter(this));
jButton3.setBounds(new Rectangle(234, 376, 91, 29));
jButton3.setText("取消");
jButton3.addActionListener(new ModifyDoctorInfo_jButton3_actionAdapter(this));
jTextField3.setText("");
this.getContentPane().add(jPasswordField1);
this.getContentPane().add(jLabel4);
this.getContentPane().add(jLabel6);
this.getContentPane().add(jTextField1);
this.getContentPane().add(jLabel5);
this.getContentPane().add(jTextField3);
this.getContentPane().add(jTextField2);
this.getContentPane().add(jLabel2);
this.getContentPane().add(jButton3);
this.getContentPane().add(jTextField5);
this.getContentPane().add(jButton1);
this.getContentPane().add(jButton2);
this.getContentPane().add(jTextField4);
this.getContentPane().add(jLabel3);
this.getContentPane().add(jLabel1);
}
int checkData(){ //检察数据是否有效
if(jTextField2.getText().equals("")==true|| jTextField3.getText().equals("")==true){
JOptionPane.showMessageDialog(null,"请输入完整的数据!","系统提示",JOptionPane.ERROR_MESSAGE);
return 0;
}
return 1;
}
public void jButton3_actionPerformed(ActionEvent e) {
dispose();
}
public void jButton2_actionPerformed(ActionEvent e) {
jTextField2.setText("");
jTextField3.setText("");
jTextField4.setText("");
jTextField5.setText("");
}
public void jButton1_actionPerformed(ActionEvent e) {
if(checkData()==1){
db= new Database();
Statement stm=db.getStatement();
String url=new String();
String strValue=new String();
url="UPDATE doctor set name='"+jTextField3.getText()+"',profession='"+jTextField3.getText()+"'";
if(jTextField4.getText()!="")
url = url + ",phone='"+jTextField4.getText()+"'";
if(jTextField5.getText()!="")
url = url + ",email='"+jTextField5.getText()+"'";
url=url+" WHERE username='"+strUsername+"'";
try{
stm.executeUpdate(url);
}catch(SQLException se){
se.printStackTrace();
}
db.close();
JOptionPane.showMessageDialog(null,"修改成功!","系统提示",JOptionPane.INFORMATION_MESSAGE);
}
}
}
class ModifyDoctorInfo_jButton1_actionAdapter implements ActionListener {
private ModifyDoctorInfo adaptee;
ModifyDoctorInfo_jButton1_actionAdapter(ModifyDoctorInfo adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
class ModifyDoctorInfo_jButton2_actionAdapter implements ActionListener {
private ModifyDoctorInfo adaptee;
ModifyDoctorInfo_jButton2_actionAdapter(ModifyDoctorInfo adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}
class ModifyDoctorInfo_jButton3_actionAdapter implements ActionListener {
private ModifyDoctorInfo adaptee;
ModifyDoctorInfo_jButton3_actionAdapter(ModifyDoctorInfo adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton3_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -