?? teacherinfopanel.java~2~
字號:
package superframe.factionpanels.infopanel;
import com.borland.jbcl.layout.XYConstraints;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JComboBox;
import superframe.link.SQLRunner;
import java.sql.ResultSet;
import javax.swing.JOptionPane;
public class TeacherInfoPanel extends InfoPanel {
public TeacherInfoPanel(boolean e){
try {
initialize(e);//初始化父類
} catch (Exception ex) {
}
}
protected void initialize(boolean e){
try {
super.initialize(e);
} catch (Exception ex) {
}
jLabel1.setText("姓名");
jTextField_name.setText("jTextField1");
jLabel2.setText("職工號");
jTextField_teacher_no.setText("jTextField2");
jLabel3.setText("性別");
jLabel4.setText("聯系電話");
jTextField_phone.setText("jTextField3");
jLabel5.setText("職稱");
jLabel6.setText("學院");
this.add(jLabel1, new XYConstraints(56, 45, 82, 38));
this.add(jTextField_name, new XYConstraints(128, 53, 95, 29));
this.add(jLabel2, new XYConstraints(297, 51, 80, 31));
this.add(jTextField_teacher_no, new XYConstraints(427, 52, 96, 30));
this.add(jLabel3, new XYConstraints(56, 113, 60, 31));
this.add(jComboBox_sex, new XYConstraints(128, 115, 96, 31));
this.add(jLabel5, new XYConstraints(297, 113, 65, 34));
this.add(jLabel6, new XYConstraints(57, 176, 71, 37));
this.add(jComboBox_coname, new XYConstraints(128, 181, 163, 32));
this.add(jLabel4, new XYConstraints(56, 241, 67, 33));
this.add(jTextField_phone, new XYConstraints(128, 243, 180, 32));
this.add(jComboBox_post, new XYConstraints(427, 116, 109, 32));
}
public void setSwingEnable(boolean e) {
jTextField_name.setEnabled(e);
jTextField_teacher_no.setEnabled(e);
jComboBox_sex.setEnabled(e);
jTextField_phone.setEnabled(e);
jComboBox_post.setEnabled(e);
jComboBox_coname.setEnabled(e);
}
public boolean delete() {
return SQLRunner.executSql("delete from teacher where teacher_no='"+keyValue+"'");
}
public boolean update() {
try{
String class_no;
if(jComboBox_class.getSelectedItem()==null){
}else{
String clname=(String)(jComboBox_class.getSelectedItem());
ResultSet rs=SQLRunner.getResult("select * from class where clname='"+clname+"'");
if(!rs.next())System.out.println("can't find clname");
class_no=rs.getString("class_no").trim();
}
String score=jTextField_score.getText().trim();
if(score.equals(""))score="null";
String sname=jTextField_name.getText().trim();
String stu_no=jTextField_stu_no.getText().trim();
String home_phone=jTextField_home_phone.getText().trim();
String address=jTextField_address.getText().trim();
String nation;
if(jComboBox_nation.getSelectedItem()==null){
nation="";
}else{
nation=((String)jComboBox_nation.getSelectedItem()).trim();
}String Build_no;
if(jComboBox_Build_no.getSelectedItem()==null){
Build_no="";
}else{
Build_no=((String)jComboBox_Build_no.getSelectedItem()).trim();
}String sex;
if(jComboBox_sex.getSelectedItem()==null){
sex="";
}else{
sex=((String)jComboBox_sex.getSelectedItem()).trim();
}String polity;
if(jComboBox_polity.getSelectedItem()==null){
polity="";
}else{
polity=((String)jComboBox_polity.getSelectedItem()).trim();
}String source;
if(jComboBox_source.getSelectedItem()==null){
source="";
}else{
source=((String)jComboBox_source.getSelectedItem()).trim();
}String dorm_no;
if(jComboBox_Build_no.getSelectedItem()==null||jComboBox_apartment_no.getSelectedItem()==null){
dorm_no="";
}else{
dorm_no=((String)jComboBox_Build_no.getSelectedItem()).trim()+((String)jComboBox_apartment_no.getSelectedItem()).trim();
}String updatesql="update student set class_no='"+class_no+"',dorm_no='"+dorm_no+"',nation='"+nation+"',polity='"+polity+"',sex='"+sex+"',source='"+source+"',home_phone='"+home_phone+"',address='"+address+"',score="+score+",sname='"+sname+"' where stu_no='"+stu_no+"'";
return SQLRunner.executSql(updatesql);
}catch(Exception e){
JOptionPane.showMessageDialog(null,e.toString(),"系統提示",JOptionPane.ERROR_MESSAGE);
return false;
}
}
public boolean insert() {
return false;
}
public void setAllInfo(String keyValue) {
}
public void setAllNew() {
}
JLabel jLabel1 = new JLabel();
JTextField jTextField_name = new JTextField();
JLabel jLabel2 = new JLabel();
JTextField jTextField_teacher_no = new JTextField();
JLabel jLabel3 = new JLabel();
JComboBox jComboBox_sex = new JComboBox();
JLabel jLabel4 = new JLabel();
JTextField jTextField_phone = new JTextField();
JLabel jLabel5 = new JLabel();
JComboBox jComboBox_post = new JComboBox();
JLabel jLabel6 = new JLabel();
JComboBox jComboBox_coname = new JComboBox();
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -