📄 updateteainfohandler.java
字号:
package jin.handler;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.util.*;
import jin.internalFrame.*;
import jin.dao.*;
import jin.bean.*;
public class UpdateTeaInfoHandler
{
private UpdateTeaInfo updateTeaInfo;
private JTextField field;
private JComboBox[] comboBoxs;
public UpdateTeaInfoHandler(UpdateTeaInfo updateTeaInf)
{
this.updateTeaInfo=updateTeaInf;
field=updateTeaInfo.getField();
comboBoxs=updateTeaInfo.getComboBoxs();
String sql1="select * from teaInfo";
TeaInfoDAO teaInfoDAO=new TeaInfoDAO();
ArrayList teaList=teaInfoDAO.excuteQuery(sql1);
TeaInfoBean teaInfoBean=null;
for(int i=0;i<teaList.size();i++)
{
teaInfoBean=(TeaInfoBean)teaList.get(i);
comboBoxs[0].addItem(teaInfoBean.getTeaID());
}
updateTeaInfo.getButtonsPanel().getButton(0).addActionListener
(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
boolean BOK=false;
int flag=0;
//String sql1="select * from teaInfo";
TeaInfoDAO teaInfoDAO=new TeaInfoDAO();
//ArrayList teaList=teaInfoDAO.excuteQuery(sql1);
//TeaInfoBean teaInfoBean=null;
String sql2="";
//for(int i=0;i<teaList.size();i++)
//{
//teaInfoBean=(TeaInfoBean)teaList.get(i);
//if(teaInfoBean.getTeaID().trim().equals(fields[0].getText().trim()))
//{
String text=comboBoxs[1].getSelectedItem().toString().trim();
if(text.equals("姓名"))
{
sql2="update teaInfo set teaName='"+field.getText().trim()+"' where teaID='"+comboBoxs[0].getSelectedItem().toString().trim()+"'";
BOK=teaInfoDAO.update(sql2);
}
if(text.equals("专业编号"))
{
String sql="select * from majorInfo";
MajorInfoDAO majorInfoDAO=new MajorInfoDAO();
ArrayList majorList=majorInfoDAO.excuteQuery(sql);
MajorInfoBean majorInfoBean=null;
for(int j=0;j<majorList.size();j++)
{
majorInfoBean=(MajorInfoBean)majorList.get(j);
if(majorInfoBean.getMajorID().trim().equals(field.getText().trim()))
{
flag=1;
sql2="update teaInfo set majorID='"+field.getText().trim()+"' where teaID='"+comboBoxs[0].getSelectedItem().toString().trim()+"'";
break;
}
}
if(flag==1)
{
BOK=teaInfoDAO.update(sql2);
/*
if(BOK)
{
JOptionPane.showMessageDialog(null,"修改专业信息成功!");
}
*/
}
if(flag==0)
{
JOptionPane.showMessageDialog(null,"不存在该专业!");
}
}
if(text.equals("状态"))
{
sql2="update teaInfo set state='"+field.getText().trim()+"' where teaID='"+comboBoxs[0].getSelectedItem().toString().trim()+"'";
BOK=teaInfoDAO.update(sql2);
}
if(text.equals("删除标记"))
{
sql2="update teaInfo set delRecord='"+field.getText().trim()+"' where teaID='"+comboBoxs[0].getSelectedItem().toString().trim()+"'";
BOK=teaInfoDAO.update(sql2);
}
if(BOK)
{
JOptionPane.showMessageDialog(null,"修改教师信息成功!");
}
else
{
JOptionPane.showMessageDialog(null,"修改教师信息失败!");
}
//}
//}
updateTeaInfo.setVisible(false);
}
}
);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -