JF_view_query_rkqk.java
上传用户:whbcdz
上传日期:2008-08-04
资源大小:7683k
文件大小:9k
源码类别:

JavaScript

开发平台:

Java

  1. package appjxc.view;
  2. import javax.swing.*;
  3. import java.awt.BorderLayout;
  4. import java.awt.FlowLayout;
  5. import java.awt.SystemColor;
  6. import javax.swing.border.Border;
  7. import javax.swing.border.TitledBorder;
  8. import java.awt.Font;
  9. import javax.swing.border.BevelBorder;
  10. import java.awt.Color;
  11. import javax.swing.BorderFactory;
  12. import java.awt.Dimension;
  13. import appjxc.model.obj_medicine;
  14. import appjxc.model.Obj_client;
  15. import appjxc.model.Obj_gys;
  16. import javax.swing.table.DefaultTableModel;
  17. import java.awt.event.ItemEvent;
  18. import java.awt.event.ItemListener;
  19. import java.awt.event.ActionEvent;
  20. import java.awt.event.ActionListener;
  21. import java.awt.event.KeyEvent;
  22. import java.awt.event.KeyAdapter;
  23. public class JF_view_query_rkqk extends JInternalFrame {
  24.     BorderLayout borderLayout1 = new BorderLayout();
  25.     JPanel jPanel1 = new JPanel();
  26.     JScrollPane jScrollPane1 = new JScrollPane();
  27.     JTable jTable1 = new JTable();
  28.     FlowLayout flowLayout1 = new FlowLayout();
  29.     JLabel jLabel1 = new JLabel();
  30.     Border border1 = BorderFactory.createLineBorder(SystemColor.controlText, 2);
  31.     Border border2 = new TitledBorder(border1, "查询参数设置");
  32.     JLabel jLabel2 = new JLabel();
  33.     JComboBox jCid = new JComboBox();
  34.     JComboBox jCysf = new JComboBox();
  35.     JLabel jLabel3 = new JLabel();
  36.     JTextField jTvalue = new JTextField();
  37.     JButton jByes = new JButton();
  38.     JButton jBquit = new JButton();
  39.     Object[] object = {new obj_medicine(),new Obj_client(),new Obj_gys()};
  40.     String[] name = {"rkdjh","rkrq","rksl","rkje"};
  41.     //int _objIndex = 0,_idIndex = 0,_ysfIndex = 0;
  42.     int _idIndex,_ysfIndex;
  43.     JCheckBox jCheckBox1 = new JCheckBox();
  44.     JCheckBox jCheckBox2 = new JCheckBox();
  45.     public JF_view_query_rkqk() {
  46.         try {
  47.             _idIndex = 0;
  48.             _ysfIndex = 0;
  49.             jbInit();
  50.         } catch (Exception ex) {
  51.             ex.printStackTrace();
  52.         }
  53.     }
  54.     public static void main(String[] args) {
  55.         JF_view_query_rkqk jf_view_query_jbqk = new JF_view_query_rkqk();
  56.     }
  57.     private void jbInit() throws Exception {
  58.         jCysf.addItem("like");
  59.         jCysf.addItem(">");
  60.         jCysf.addItem("<");
  61.         jCysf.addItem(">=");
  62.         jCysf.addItem("<=");
  63.         jCid.addItem("入库单据号");
  64.         jCid.addItem("入库日期");
  65.         jCid.addItem("入库数量");
  66.         jCid.addItem("入库金额");
  67.         border2 = new TitledBorder(border1, "设置查询参数",
  68.                                      TitledBorder.DEFAULT_JUSTIFICATION,
  69.                                      TitledBorder.DEFAULT_POSITION,
  70.                                      new java.awt.Font("新宋体", 0, 12),
  71.                                      Color.red);
  72.         this.getContentPane().setLayout(borderLayout1);
  73.         jLabel3.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
  74.         jLabel3.setText("数值:");
  75.         jTvalue.setMinimumSize(new Dimension(106, 21));
  76.         jTvalue.setPreferredSize(new Dimension(136, 24));
  77.         jTvalue.setText("");
  78.         jByes.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
  79.         jByes.setText("查询");
  80.         jByes.addActionListener(new JF_view_query_rkqk_jByes_actionAdapter(this));
  81.         jBquit.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
  82.         jBquit.setText("关闭");
  83.         jLabel1.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
  84.         jLabel2.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
  85.         jCid.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
  86.         jCid.addItemListener(new JF_view_query_rkqk_jCid_itemAdapter(this));
  87.         jCysf.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
  88.         flowLayout1.setHgap(8);
  89.         flowLayout1.setVgap(8);
  90.         borderLayout1.setVgap(3);
  91.         this.setClosable(true);
  92.         this.setMaximizable(true);
  93.         jCysf.addItemListener(new JF_view_query_rkqk_jCysf_itemAdapter(this));
  94.         jCid.setPreferredSize(new Dimension(95, 25));
  95.         jCid.addKeyListener(new JF_view_query_rkqk_jCid_keyAdapter(this));
  96.         jCysf.setPreferredSize(new Dimension(85, 25));
  97.         jTvalue.addKeyListener(new JF_view_query_rkqk_jTvalue_keyAdapter(this));
  98.         jCheckBox1.setText("jCheckBox1");
  99.         jCheckBox2.setText("jCheckBox2");
  100.         this.getContentPane().add(jPanel1, java.awt.BorderLayout.NORTH);
  101.         jPanel1.setFont(new java.awt.Font("新宋体", Font.PLAIN, 12));
  102.         jPanel1.setBorder(border2);
  103.         jLabel2.setText("运算符:");
  104.         jPanel1.add(jCheckBox1);
  105.         jPanel1.add(jLabel1);
  106.         jPanel1.add(jCid);
  107.         jPanel1.add(jLabel2);
  108.         jPanel1.add(jCheckBox2);
  109.         jPanel1.add(jCysf);
  110.         jPanel1.add(jLabel3);
  111.         jPanel1.add(jTvalue);
  112.         jPanel1.add(jByes);
  113.         jPanel1.add(jBquit);
  114.         jLabel1.setText("查询字段:");
  115.         jPanel1.setLayout(flowLayout1);
  116.         this.getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
  117.         jScrollPane1.getViewport().add(jTable1);
  118.         this.setSize(850,550);
  119.         this.setVisible(true);
  120.     }
  121.     public void jByes_actionPerformed(ActionEvent e) {
  122.         if (jTvalue.getText().trim().length() <= 0){
  123.             JOptionPane.showMessageDialog(null,"请输入查询数值!!","提示",JOptionPane.ERROR_MESSAGE);
  124.             jTvalue.requestFocus();
  125.             return;
  126.         }
  127.         DefaultTableModel defaultmodel = null;
  128.         int choose;
  129.         String queryStr = null,whereStr = null;
  130.         appjxc.constrol.BuildTable buildTable = new appjxc.constrol.BuildTable();
  131.         /*if (_ysfIndex == 0){
  132.             whereStr = name[_idIndex] + " " +
  133.                        String.valueOf(jCysf.getItemAt(_ysfIndex)) +
  134.                        " '" + jTvalue.getText().trim() + "%'";
  135.         }else{
  136.             whereStr = name[_idIndex] + " " +
  137.                        String.valueOf(jCysf.getItemAt(_ysfIndex)) +
  138.                        " '" + jTvalue.getText().trim() + "'";
  139.         }
  140.         /*switch (choose){
  141.                case 0:
  142.                    queryStr = " From  obj_medicine where " + whereStr;
  143.                    defaultmodel = buildTable.getmedicineTableModel(queryStr);
  144.                    break;
  145.                case 1:
  146.                    queryStr = " From  Obj_client where " + whereStr;
  147.                    defaultmodel = buildTable.getClientTableModel(queryStr);
  148.                    break;
  149.               case 2:
  150.                   queryStr = " From  Obj_gys where " + whereStr;
  151.                   defaultmodel = buildTable.getGysTableModel(queryStr);
  152.                   break;
  153.         }*/
  154.         jTable1.setModel(defaultmodel);
  155.         if (jTable1.getRowCount() <= 0 ){
  156.             JOptionPane.showMessageDialog(null,"没有找到满足条件的数据!!!","系统提示",JOptionPane.ERROR_MESSAGE);
  157.         }
  158.     }
  159.     public void jCid_keyPressed(KeyEvent e) {
  160.     }
  161.      public void jCid_itemStateChanged(ItemEvent e) {
  162.         _idIndex = jCid.getSelectedIndex();
  163.         jCysf.removeAllItems();
  164.         if (_idIndex == 0){
  165.             jCysf.addItem("like");
  166.             jCysf.addItem(">");
  167.             jCysf.addItem("<");
  168.             jCysf.addItem(">=");
  169.             jCysf.addItem("<=");
  170.         }else{
  171.             jCysf.addItem(">");
  172.             jCysf.addItem("=");
  173.             jCysf.addItem("<");
  174.             jCysf.addItem(">=");
  175.             jCysf.addItem("<=");
  176.         }
  177.     }
  178.     /*public void jCysf_itemStateChanged(ItemEvent e) {
  179.         _ysfIndex = jCysf.getSelectedIndex();
  180.     }
  181.     public void jTvalue_keyPressed(KeyEvent e) {
  182.         if (e.getKeyCode() == KeyEvent.VK_ENTER){
  183.             ActionEvent yesevent = new ActionEvent(jByes,0,null);
  184.             this.jByes_actionPerformed(yesevent);
  185.         }
  186.     }*/
  187. }
  188. class JF_view_query_rkqk_jTvalue_keyAdapter extends KeyAdapter {
  189.     private JF_view_query_rkqk adaptee;
  190.     JF_view_query_rkqk_jTvalue_keyAdapter(JF_view_query_rkqk adaptee) {
  191.         this.adaptee = adaptee;
  192.     }
  193.     public void keyPressed(KeyEvent e) {
  194.        // adaptee.jTvalue_keyPressed(e);
  195.     }
  196. }
  197. class JF_view_query_rkqk_jCysf_itemAdapter implements ItemListener {
  198.     private JF_view_query_rkqk adaptee;
  199.     JF_view_query_rkqk_jCysf_itemAdapter(JF_view_query_rkqk adaptee) {
  200.         this.adaptee = adaptee;
  201.     }
  202.     public void itemStateChanged(ItemEvent e) {
  203.        //adaptee.jCysf_itemStateChanged(e);
  204.     }
  205. }
  206. class JF_view_query_rkqk_jCid_itemAdapter implements ItemListener {
  207.     private JF_view_query_rkqk adaptee;
  208.     JF_view_query_rkqk_jCid_itemAdapter(JF_view_query_rkqk adaptee) {
  209.         this.adaptee = adaptee;
  210.     }
  211.     public void itemStateChanged(ItemEvent e) {
  212.         adaptee.jCid_itemStateChanged(e);
  213.     }
  214. }
  215. class JF_view_query_rkqk_jCid_keyAdapter extends KeyAdapter {
  216.     private JF_view_query_rkqk adaptee;
  217.     JF_view_query_rkqk_jCid_keyAdapter(JF_view_query_rkqk adaptee) {
  218.         this.adaptee = adaptee;
  219.     }
  220.     public void keyPressed(KeyEvent e) {
  221.         adaptee.jCid_keyPressed(e);
  222.     }
  223. }
  224. class JF_view_query_rkqk_jByes_actionAdapter implements ActionListener {
  225.     private JF_view_query_rkqk adaptee;
  226.     JF_view_query_rkqk_jByes_actionAdapter(JF_view_query_rkqk adaptee) {
  227.         this.adaptee = adaptee;
  228.     }
  229.     public void actionPerformed(ActionEvent e) {
  230.         adaptee.jByes_actionPerformed(e);
  231.     }
  232. }