📄 mixselcetpanel.java~27~
字号:
package bank;
import javax.swing.*;
import java.awt.*;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.*;
import javax.swing.table.DefaultTableModel;
//混合查询......
public class mixSelcetPanel extends JPanel implements ActionListener{
public mixSelcetPanel()
{
this.setBackground(Color.pink);
try {
jbInit();
}
catch (Exception ex) {
ex.printStackTrace();
}
}
XYLayout xYLayout1 = new XYLayout();
JLabel jLabel1 = new JLabel();
JRadioButton jRadioButton1 = new JRadioButton();
JRadioButton jRadioButton2 = new JRadioButton();
JRadioButton jRadioButton3 = new JRadioButton();
JLabel jLabel2 = new JLabel();
JButton jButton1 = new JButton();
JLabel jLabel3 = new JLabel();
JComboBox jComboBox1 = new JComboBox();
JComboBox jComboBox2 = new JComboBox();
JComboBox jComboBox3 = new JComboBox();
JComboBox jComboBox4 = new JComboBox();
JLabel jLabel4 = new JLabel();
JLabel jLabel5 = new JLabel();
JLabel jLabel6 = new JLabel();
JLabel jLabel7 = new JLabel();
JScrollPane jScrollPane1=new JScrollPane();
private void jbInit() throws Exception {
this.setLayout(xYLayout1);
jLabel1.setFont(new java.awt.Font("宋体", Font.PLAIN, 16));
jLabel1.setForeground(Color.red);
jLabel1.setText("查询类型:");
xYLayout1.setWidth(528);
xYLayout1.setHeight(394);
jRadioButton1.setFont(new java.awt.Font("宋体", Font.PLAIN, 14));
jRadioButton1.setForeground(Color.green);
jRadioButton1.setText("存钱信息");
jRadioButton2.setFont(new java.awt.Font("宋体", Font.PLAIN, 14));
jRadioButton2.setForeground(Color.green);
jRadioButton2.setText("取钱信息");
jRadioButton3.setFont(new java.awt.Font("宋体", Font.PLAIN, 14));
jRadioButton3.setForeground(Color.green);
jRadioButton3.setText("转帐信息");
jLabel2.setFont(new java.awt.Font("宋体", Font.PLAIN, 16));
jLabel2.setForeground(Color.blue);
jLabel2.setText("结果:");
this.setBackground(new Color(236, 233, 156));
jButton1.setText("确定");
jButton1.addActionListener(new mixSelcetPanel_jButton1_actionAdapter(this));
jLabel3.setFont(new java.awt.Font("宋体", Font.PLAIN, 16));
jLabel3.setForeground(Color.red);
jLabel3.setText("服务时间:");
jLabel4.setText("年");
jLabel5.setText("月");
jLabel6.setText("日");
jLabel7.setText("时");
grounp.add(jRadioButton1);
grounp.add(jRadioButton2);
grounp.add(jRadioButton3);
//jScrollPane1.getViewport().
jComboBox1.addItem("2006");
jComboBox1.addItem("2007");
jComboBox1.addItem("2008");
jComboBox1.addItem("2009");
jComboBox1.addItem("2010");
jComboBox1.addItem("2011");
String a;
for(int i=1;i<13;i++)
{
a=""+i;
jComboBox2.addItem(a);
}
for(int i=1;i<32;i++)
{
a=""+i;
jComboBox3.addItem(a);
}
for(int i=1;i<25;i++)
{
a=""+i;
jComboBox4.addItem(a);
}
this.add(jLabel1, new XYConstraints(21, 28, 90, 31));
this.add(jRadioButton1, new XYConstraints(107, 43, 89, 32));
this.add(jRadioButton3, new XYConstraints(347, 44, -1, 32));
this.add(jRadioButton2, new XYConstraints(231, 44, 83, 31));
this.add(jLabel3, new XYConstraints(18, 94, 80, 41));
this.add(jLabel4, new XYConstraints(178, 102, 24, 37));
this.add(jComboBox2, new XYConstraints(206, 112, 52, 24));
this.add(jComboBox1, new XYConstraints(97, 111, 71, 24));
this.add(jLabel5, new XYConstraints(269, 112, 18, 19));
this.add(jLabel6, new XYConstraints(354, 109, 16, 22));
this.add(jLabel7, new XYConstraints(445, 112, 18, 17));
this.add(jLabel2, new XYConstraints(20, 137, 59, 36));
this.add(jComboBox4, new XYConstraints(378, 111, 48, 25));
this.add(jComboBox3, new XYConstraints(295, 111, 47, 26));
this.add(jButton1, new XYConstraints(426, 140, 84, 32));
this.add(jScrollPane1, new XYConstraints(12, 168, 416, 211));
jScrollPane1.getViewport().add(jt1);
jRadioButton1.addActionListener(this);
jRadioButton2.addActionListener(this);
jRadioButton3.addActionListener(this);
jt1.setModel(dtm);
dtm.addColumn("客户号");
dtm.addColumn("具体内容");
dtm.addColumn("操作时间");
}
DefaultTableModel dtm=new DefaultTableModel();
ButtonGroup grounp=new ButtonGroup();
Connection con;
private int i=0;
JTable jt1=new JTable();
private Integer year;
private Integer mon;
private Integer day;
private Integer hour;
public void actionPerformed(ActionEvent e) {
if(e.getSource()==jRadioButton1){
i=1;
}
else if(e.getSource()==jRadioButton1){
i=2;
}
else {
i=3;
}
}
public void jButton1_actionPerformed(ActionEvent e) {
if(i==0)JOptionPane.showMessageDialog(null,"请选择信息类型!");
//year=Integer.valueOf(jComboBox1.getSelectedItem().toString().trim());
// mon=Integer.valueOf(jComboBox2.getSelectedItem().toString().trim());
//day=Integer.valueOf(jComboBox3.getSelectedItem().toString().trim());
//hour=Integer.valueOf(jComboBox4.getSelectedItem().toString().trim());
String time=jComboBox1.getSelectedItem().toString().trim()+"-"+jComboBox2.getSelectedItem().toString().trim()
+"-"+jComboBox3.getSelectedItem().toString().trim()+" "+jComboBox4.getSelectedItem().toString().trim();
try{
con=bankconnect.getconn();
int la=0;
Statement stmt=con.createStatement();
String [] s=new String[3];
//有问题。。。。
String sql="select * from message where message_class="+i+" and convert(varchar(10),message_time,120)="+time;
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()){
for(int i=1;i<4;i++){
s[i-1]=rs.getString(i);
}
dtm.addRow(s);
la=1;
}
jt1.updateUI();
rs.close();
con.close();
if(la==0) JOptionPane.showMessageDialog(null,"对不起,没有该信息!");
}
catch(SQLException ex){
}
}
}
class mixSelcetPanel_jButton1_actionAdapter
implements ActionListener {
private mixSelcetPanel adaptee;
mixSelcetPanel_jButton1_actionAdapter(mixSelcetPanel adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -