📄 solutionandreplycaseselectionjpanel.java
字号:
package file1;
/*
* @Author:黄顺武
* Description:客户申诉解决情况和反馈情况查询和录入面版
* Create Time:2008-2-2
*/
import javax.swing.*;
import java.sql.*;
import java.awt.*;
import sun.jdbc.rowset.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
public class SolutionAndReplyCaseSelectionJPanel extends JPanel implements
MouseListener {
private JLabel appealID = new JLabel("记录编号 :");
private JComboBox appealIDBox = new JComboBox();
private JButton solutionQuery = new JButton("解决情况查询");
private JButton replyQuery = new JButton("反馈情况查询");
private DBConnection con = null;
private JPanel panelEcho = new JPanel();
private JPanel panel1 = new JPanel();
private JPanel panel2 = new JPanel();
private JPanel panel3 = new JPanel();
public SolutionAndReplyCaseSelectionJPanel() {
con = new DBConnection();
int valueReturned = getResolutionAndReplyIDS();
if (valueReturned == 1) {
return;
}
panelEcho.setLayout(new FlowLayout(FlowLayout.LEADING, 15, 0));
panelEcho.add(appealID);
panelEcho.add(appealIDBox);
panel1.setLayout(new FlowLayout(FlowLayout.LEADING, 10, 0));
panel2.setLayout(new FlowLayout(FlowLayout.LEADING, 10, 0));
panel1.add(solutionQuery);
panel2.add(replyQuery);
panel3.setLayout(new GridLayout(3, 1, 0, 20));
panel3.add(panelEcho);
panel3.add(panel1);
panel3.add(panel2);
this.add(panel3);
solutionQuery.setBorder(null);
replyQuery.setBorder(null);
solutionQuery.setToolTipText("双击进入选定记录的解决情况录入界面!");
replyQuery.setToolTipText("双击进入选定记录的反馈情况录入界面!");
solutionQuery.addMouseListener(this);
replyQuery.addMouseListener(this);
}
private int getResolutionAndReplyIDS() {// 从数据库中读取两种查询条件的id,成功返回0,否则返回1
String sqlStr = "select ID from Appeal";
try {
CachedRowSet crs = con.getResultSet(sqlStr);
while (crs.next()) {
appealIDBox.addItem(String.valueOf(crs.getInt(1)));
}
appealIDBox.setSelectedIndex(-1);
} catch (ClassNotFoundException cnfe) {
JOptionPane.showMessageDialog(null, "发生ClassNotFound错误!", "",
JOptionPane.INFORMATION_MESSAGE);
return 1;
} catch (SQLException sqle) {
JOptionPane.showMessageDialog(null, "发生Sql错误!", "",
JOptionPane.INFORMATION_MESSAGE);
return 1;
}
return 0;
}
public void mouseExited(MouseEvent me) {
}
public void mouseReleased(MouseEvent me) {
}
public void mousePressed(MouseEvent me) {
}
public void mouseEntered(MouseEvent me) {
}
public void mouseClicked(MouseEvent me) {
if (me.getSource() == solutionQuery) {
if (me.getClickCount() == 2) {// 双击了"解决情况查询"按钮,弹出解决情况数据录入界面
int appealID = 0;
try {
appealID = Integer.valueOf(((String) appealIDBox
.getSelectedItem()));// 申诉记录的ID
} catch (NumberFormatException nfe) {
JOptionPane.showMessageDialog(null, "解决情况所针对的申诉记录编号不能为空!",
"", JOptionPane.INFORMATION_MESSAGE);
return;
}
SolutionDataInJPanel solutionDataInJPanel = new SolutionDataInJPanel();// 实例化客户申诉情况数据录入面版
JDialog dialog = new JDialog(MainFrame.getMainFrame(), true);
dialog.setSize(450, 300);
dialog.setLocation(400, 300);
dialog.getContentPane().setLayout(new BorderLayout());
dialog.getContentPane().add(solutionDataInJPanel,
BorderLayout.CENTER);
dialog.setVisible(true);
SolutionRecord solutionRecord = solutionDataInJPanel
.getSolutionRecord();
if (solutionRecord.getOperater() != -1
&& !solutionRecord.getOperateTime().trim().equals("")) {
solutionRecord.setAppealID(appealID);
} else {
return;
}
SolutionRecordOperate solutionRecordOperate = new SolutionRecordOperate();
solutionRecordOperate.insertToDB(solutionRecord);
} else if (me.getClickCount() == 1) {// 单击了"解决情况查询"按钮,弹出解决情况数据录入界面
String item = (String) appealIDBox.getSelectedItem();
if (item == null) {
JOptionPane.showMessageDialog(null, "申诉记录编号不能为空!", "",
JOptionPane.INFORMATION_MESSAGE);
return;
}
int id = Integer.valueOf(item);
SolutionRecordJPanel solutionRecordJPanel = new SolutionRecordJPanel(
id);
JDialog dialog = new JDialog();
dialog.setSize(450, 300);
dialog.setLocation(400, 300);
dialog.getContentPane().setLayout(new BorderLayout());
dialog.getContentPane().add(solutionRecordJPanel,
BorderLayout.CENTER);
dialog.setVisible(true);
}
} else if (me.getSource() == replyQuery) {
if (me.getClickCount() == 2) {// 双击了"反馈情况查询"按钮,弹出反馈情况数据录入界面
int appealID = 0;
try {
appealID = Integer.valueOf(((String) appealIDBox
.getSelectedItem()));// 申诉记录的ID
} catch (NumberFormatException nfe) {
JOptionPane.showMessageDialog(null, "反馈情况所针对的申诉记录编号不能为空!",
"", JOptionPane.INFORMATION_MESSAGE);
return;
}
FeedBackDataInJPanel feedBackDataInJPanel = new FeedBackDataInJPanel();// 实例化客户申诉情况数据录入面版
JDialog dialog = new JDialog(MainFrame.getMainFrame(), true);
dialog.setSize(450, 300);
dialog.setLocation(400, 300);
dialog.getContentPane().setLayout(new BorderLayout());
dialog.getContentPane().add(feedBackDataInJPanel,
BorderLayout.CENTER);
dialog.setVisible(true);
FeedBackRecord feedBackRecord = feedBackDataInJPanel
.getFeedBackRecord();
if (feedBackRecord.getOperater() != -1
&& !feedBackRecord.getOperateTime().trim().equals("")) {
feedBackRecord.setAppealID(appealID);
}
FeedBackRecordOperate feedBackRecordOperate = new FeedBackRecordOperate();
feedBackRecordOperate.insertToDB(feedBackRecord);
} else if (me.getClickCount() == 1) {// 单击了"反馈情况查询"按钮,弹出反馈情况数据录入界面
String item = (String) appealIDBox.getSelectedItem();
if (item == null) {
JOptionPane.showMessageDialog(null, "申诉记录编号不能为空!", "",
JOptionPane.INFORMATION_MESSAGE);
return;
}
int id = Integer.valueOf(item);
FeedBackRecordJPanel feedBackRecordJPanel = new FeedBackRecordJPanel(
id);
JDialog dialog = new JDialog();
dialog.setSize(450, 300);
dialog.setLocation(400, 300);
dialog.getContentPane().setLayout(new BorderLayout());
dialog.getContentPane().add(feedBackRecordJPanel,
BorderLayout.CENTER);
dialog.setVisible(true);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -