JF_view_query_rkqk.java
资源名称:Appjxc.rar [点击查看]
上传用户:whbcdz
上传日期:2008-08-04
资源大小:7683k
文件大小:9k
源码类别:
JavaScript
开发平台:
Java
- package appjxc.view;
- import javax.swing.*;
- import java.awt.BorderLayout;
- import java.awt.FlowLayout;
- import java.awt.SystemColor;
- import javax.swing.border.Border;
- import javax.swing.border.TitledBorder;
- import java.awt.Font;
- import javax.swing.border.BevelBorder;
- import java.awt.Color;
- import javax.swing.BorderFactory;
- import java.awt.Dimension;
- import appjxc.model.obj_medicine;
- import appjxc.model.Obj_client;
- import appjxc.model.Obj_gys;
- import javax.swing.table.DefaultTableModel;
- import java.awt.event.ItemEvent;
- import java.awt.event.ItemListener;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.KeyEvent;
- import java.awt.event.KeyAdapter;
- public class JF_view_query_rkqk extends JInternalFrame {
- BorderLayout borderLayout1 = new BorderLayout();
- JPanel jPanel1 = new JPanel();
- JScrollPane jScrollPane1 = new JScrollPane();
- JTable jTable1 = new JTable();
- FlowLayout flowLayout1 = new FlowLayout();
- JLabel jLabel1 = new JLabel();
- Border border1 = BorderFactory.createLineBorder(SystemColor.controlText, 2);
- Border border2 = new TitledBorder(border1, "查询参数设置");
- JLabel jLabel2 = new JLabel();
- JComboBox jCid = new JComboBox();
- JComboBox jCysf = new JComboBox();
- JLabel jLabel3 = new JLabel();
- JTextField jTvalue = new JTextField();
- JButton jByes = new JButton();
- JButton jBquit = new JButton();
- Object[] object = {new obj_medicine(),new Obj_client(),new Obj_gys()};
- String[] name = {"rkdjh","rkrq","rksl","rkje"};
- //int _objIndex = 0,_idIndex = 0,_ysfIndex = 0;
- int _idIndex,_ysfIndex;
- JCheckBox jCheckBox1 = new JCheckBox();
- JCheckBox jCheckBox2 = new JCheckBox();
- public JF_view_query_rkqk() {
- try {
- _idIndex = 0;
- _ysfIndex = 0;
- jbInit();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public static void main(String[] args) {
- JF_view_query_rkqk jf_view_query_jbqk = new JF_view_query_rkqk();
- }
- private void jbInit() throws Exception {
- jCysf.addItem("like");
- jCysf.addItem(">");
- jCysf.addItem("<");
- jCysf.addItem(">=");
- jCysf.addItem("<=");
- jCid.addItem("入库单据号");
- jCid.addItem("入库日期");
- jCid.addItem("入库数量");
- jCid.addItem("入库金额");
- border2 = new TitledBorder(border1, "设置查询参数",
- TitledBorder.DEFAULT_JUSTIFICATION,
- TitledBorder.DEFAULT_POSITION,
- new java.awt.Font("新宋体", 0, 12),
- Color.red);
- this.getContentPane().setLayout(borderLayout1);
- jLabel3.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
- jLabel3.setText("数值:");
- jTvalue.setMinimumSize(new Dimension(106, 21));
- jTvalue.setPreferredSize(new Dimension(136, 24));
- jTvalue.setText("");
- jByes.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
- jByes.setText("查询");
- jByes.addActionListener(new JF_view_query_rkqk_jByes_actionAdapter(this));
- jBquit.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
- jBquit.setText("关闭");
- jLabel1.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
- jLabel2.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
- jCid.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
- jCid.addItemListener(new JF_view_query_rkqk_jCid_itemAdapter(this));
- jCysf.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
- flowLayout1.setHgap(8);
- flowLayout1.setVgap(8);
- borderLayout1.setVgap(3);
- this.setClosable(true);
- this.setMaximizable(true);
- jCysf.addItemListener(new JF_view_query_rkqk_jCysf_itemAdapter(this));
- jCid.setPreferredSize(new Dimension(95, 25));
- jCid.addKeyListener(new JF_view_query_rkqk_jCid_keyAdapter(this));
- jCysf.setPreferredSize(new Dimension(85, 25));
- jTvalue.addKeyListener(new JF_view_query_rkqk_jTvalue_keyAdapter(this));
- jCheckBox1.setText("jCheckBox1");
- jCheckBox2.setText("jCheckBox2");
- this.getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);
- jPanel1.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
- jPanel1.setBorder(border2);
- jLabel2.setText("运算符:");
- jPanel1.add(jCheckBox1);
- jPanel1.add(jLabel1);
- jPanel1.add(jCid);
- jPanel1.add(jLabel2);
- jPanel1.add(jCheckBox2);
- jPanel1.add(jCysf);
- jPanel1.add(jLabel3);
- jPanel1.add(jTvalue);
- jPanel1.add(jByes);
- jPanel1.add(jBquit);
- jLabel1.setText("查询字段:");
- jPanel1.setLayout(flowLayout1);
- this.getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
- jScrollPane1.getViewport().add(jTable1);
- this.setSize(850,550);
- this.setVisible(true);
- }
- public void jByes_actionPerformed(ActionEvent e) {
- if (jTvalue.getText().trim().length() <= 0){
- JOptionPane.showMessageDialog(null,"请输入查询数值!!","提示",JOptionPane.ERROR_MESSAGE);
- jTvalue.requestFocus();
- return;
- }
- DefaultTableModel defaultmodel = null;
- int choose;
- String queryStr = null,whereStr = null;
- appjxc.constrol.BuildTable buildTable = new appjxc.constrol.BuildTable();
- /*if (_ysfIndex == 0){
- whereStr = name[_idIndex] + " " +
- String.valueOf(jCysf.getItemAt(_ysfIndex)) +
- " '" + jTvalue.getText().trim() + "%'";
- }else{
- whereStr = name[_idIndex] + " " +
- String.valueOf(jCysf.getItemAt(_ysfIndex)) +
- " '" + jTvalue.getText().trim() + "'";
- }
- /*switch (choose){
- case 0:
- queryStr = " From obj_medicine where " + whereStr;
- defaultmodel = buildTable.getmedicineTableModel(queryStr);
- break;
- case 1:
- queryStr = " From Obj_client where " + whereStr;
- defaultmodel = buildTable.getClientTableModel(queryStr);
- break;
- case 2:
- queryStr = " From Obj_gys where " + whereStr;
- defaultmodel = buildTable.getGysTableModel(queryStr);
- break;
- }*/
- jTable1.setModel(defaultmodel);
- if (jTable1.getRowCount() <= 0 ){
- JOptionPane.showMessageDialog(null,"没有找到满足条件的数据!!!","系统提示",JOptionPane.ERROR_MESSAGE);
- }
- }
- public void jCid_keyPressed(KeyEvent e) {
- }
- public void jCid_itemStateChanged(ItemEvent e) {
- _idIndex = jCid.getSelectedIndex();
- jCysf.removeAllItems();
- if (_idIndex == 0){
- jCysf.addItem("like");
- jCysf.addItem(">");
- jCysf.addItem("<");
- jCysf.addItem(">=");
- jCysf.addItem("<=");
- }else{
- jCysf.addItem(">");
- jCysf.addItem("=");
- jCysf.addItem("<");
- jCysf.addItem(">=");
- jCysf.addItem("<=");
- }
- }
- /*public void jCysf_itemStateChanged(ItemEvent e) {
- _ysfIndex = jCysf.getSelectedIndex();
- }
- public void jTvalue_keyPressed(KeyEvent e) {
- if (e.getKeyCode() == KeyEvent.VK_ENTER){
- ActionEvent yesevent = new ActionEvent(jByes,0,null);
- this.jByes_actionPerformed(yesevent);
- }
- }*/
- }
- class JF_view_query_rkqk_jTvalue_keyAdapter extends KeyAdapter {
- private JF_view_query_rkqk adaptee;
- JF_view_query_rkqk_jTvalue_keyAdapter(JF_view_query_rkqk adaptee) {
- this.adaptee = adaptee;
- }
- public void keyPressed(KeyEvent e) {
- // adaptee.jTvalue_keyPressed(e);
- }
- }
- class JF_view_query_rkqk_jCysf_itemAdapter implements ItemListener {
- private JF_view_query_rkqk adaptee;
- JF_view_query_rkqk_jCysf_itemAdapter(JF_view_query_rkqk adaptee) {
- this.adaptee = adaptee;
- }
- public void itemStateChanged(ItemEvent e) {
- //adaptee.jCysf_itemStateChanged(e);
- }
- }
- class JF_view_query_rkqk_jCid_itemAdapter implements ItemListener {
- private JF_view_query_rkqk adaptee;
- JF_view_query_rkqk_jCid_itemAdapter(JF_view_query_rkqk adaptee) {
- this.adaptee = adaptee;
- }
- public void itemStateChanged(ItemEvent e) {
- adaptee.jCid_itemStateChanged(e);
- }
- }
- class JF_view_query_rkqk_jCid_keyAdapter extends KeyAdapter {
- private JF_view_query_rkqk adaptee;
- JF_view_query_rkqk_jCid_keyAdapter(JF_view_query_rkqk adaptee) {
- this.adaptee = adaptee;
- }
- public void keyPressed(KeyEvent e) {
- adaptee.jCid_keyPressed(e);
- }
- }
- class JF_view_query_rkqk_jByes_actionAdapter implements ActionListener {
- private JF_view_query_rkqk adaptee;
- JF_view_query_rkqk_jByes_actionAdapter(JF_view_query_rkqk adaptee) {
- this.adaptee = adaptee;
- }
- public void actionPerformed(ActionEvent e) {
- adaptee.jByes_actionPerformed(e);
- }
- }