⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbsearch.java

📁 我做的第一个java MIS项目
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        card.add(btncardsearch);
        card.add(btncardback);
        pnl3.add(spnlrec);
        spnlrec.getViewport().add(jdbTable3);
        tabpnl.add(rec, "查询记录");
        tabpnl.add(cd, "查询碟片数据");
        cd.add(pnlcd);
        cd.add(btncdreset);
        cd.add(btncdback);
        cd.add(btncdsearch2);
        tabpnl.add(card, "查询会员卡");
        pnlcd.add(jLabel5);
        pnlcd.add(cboxcdid);
        pnlcd.add(cboxcdmtype);
        pnlcd.add(cboxcdnotes);
        pnlcd.add(txfcdid);
        pnlcd.add(cobcdmtype);
        pnlcd.add(cboxcdexist);
        pnlcd.add(cboxcdexistyes);
        pnlcd.add(cboxcdtype);
        pnlcd.add(txacdnotes);
        pnlcd.add(cobcdtype);
        pnlcd.add(txfcdactor);
        pnlcd.add(cboxcdactor);
        pnlcd.add(cboxcdname);
        pnlcd.add(txfcdname);
        jdbTable2.add(spnlcd);
        pnl2.add(spnlcd);
        spnlrec.setBounds(new Rectangle(0, 0, 574, 263));
        spnlcd.getViewport().add(jdbTable2);
        spnlcd.setBounds(new Rectangle(0, 0, 574, 263));
        cobcdtype.addItem("VCD");
        cobcdtype.addItem("DVD");
        cobcdmtype.addItem("动作");
        cobcdmtype.addItem("喜剧");
        cobcdmtype.addItem("灾难");
        cobcdmtype.addItem("战争");
        cobcdmtype.addItem("警匪");
        cobcdmtype.addItem("恐怖");
        cobcdmtype.addItem("科幻");
        cobcdmtype.addItem("动漫");
        cobcdmtype.addItem("灾难");
        cobcdmtype.addItem("文艺");
        cobcdmtype.addItem("爱情");
        backpic.setBounds(new Rectangle(0, 0, 796, 476));
        this.add(backpic);


    }

    JTabbedPane tabpnl = new JTabbedPane();
    JPanel card =new JPanel();
    JPanel cd =new JPanel();
    JPanel rec=new JPanel();
    JPanel pnlcard = new JPanel();
    JPanel pnlrec = new JPanel();
    JLabel jLabel1 = new JLabel();
    JPanel pnl1 = new JPanel();
    JPanel pnl2 = new JPanel();
    JPanel pnl3 = new JPanel();
    Database database1 = new Database();
    QueryDataSet queryDataSet1 = new QueryDataSet();

    JTextField txfcardid = new JTextField();
    JTextField txfcardusername = new JTextField();
    JTextField txfcardbalance1 = new JTextField();
    JTextField txfcardbalance2 = new JTextField();
    JTextField txfcardrestnum1 = new JTextField();
    JTextField txfcardrestnum2 = new JTextField();
    JCheckBox cboxcardid = new JCheckBox();
    JCheckBox cboxcardusername = new JCheckBox();
    JCheckBox cboxcardbalance = new JCheckBox();
    JCheckBox cboxcardrestnum = new JCheckBox();
    JLabel jLabel2 = new JLabel();
    JLabel jLabel3 = new JLabel();
    JLabel jLabel4 = new JLabel();
    JLabel jLabel6 = new JLabel();
    JButton btncardreset = new JButton();
    JButton btncardsearch = new JButton();
    JdbTable jdbTable1 = new JdbTable();
    JScrollPane spnlcard = new JScrollPane();
    JButton btncardback = new JButton();
    JTextField txfcdactor = new JTextField();
    JCheckBox cboxcdexist = new JCheckBox();
    JTextField txfcdname = new JTextField();
    JTextField txfcdid = new JTextField();
    JCheckBox cboxcdid = new JCheckBox();
    JPanel pnlcd = new JPanel();
    JButton btncdreset = new JButton();
    JButton btncdback = new JButton();
    JCheckBox cboxcdexistyes = new JCheckBox();
    JCheckBox cboxcdtype = new JCheckBox();
    JCheckBox cboxcdname = new JCheckBox();
    JComboBox cobcdtype = new JComboBox();
    JCheckBox cboxcdmtype = new JCheckBox();
    JComboBox cobcdmtype = new JComboBox();
    JCheckBox cboxcdactor = new JCheckBox();
    JCheckBox cboxcdnotes = new JCheckBox();
    JTextArea txacdnotes = new JTextArea();
    JLabel jLabel5 = new JLabel("请选择需要查询的项目:");
    JButton btncdsearch2 = new JButton();
    JdbTable jdbTable2 = new JdbTable();
    JScrollPane spnlcd = new JScrollPane();
    JScrollPane spnlrec = new JScrollPane();

    JdbTable jdbTable3 = new JdbTable();
    JLabel jLabel7 = new JLabel("请选择需要查询的项目:");
    JCheckBox cboxreccardid = new JCheckBox();
    JLabel jLabel8 = new JLabel();
    JTextField txfreccardid = new JTextField();
    JLabel jLabel10 = new JLabel();
    JTextField txfrecendtime2 = new JTextField();
    JTextField txfrecstarttime2 = new JTextField();
    JTextField txfrecstarttime1 = new JTextField();
    JTextField txfrecendtime1 = new JTextField();
    JCheckBox cboxrecstarttime = new JCheckBox();
    JCheckBox cboxreccdid = new JCheckBox();
    JCheckBox cboxrecendtime = new JCheckBox();
    JTextField txfreccdid = new JTextField();
    JButton btnrecback = new JButton();
    JButton btnrecreset = new JButton();
    JButton btnrecsearch = new JButton();
    JLabel backpic = new JLabel(new ImageIcon(".\\pic\\mainback.jpg"));


    //定义CARD业务变量
    String strcardid="";String strcardrestnum="";String strcardbalance="";String strcardusername="";
    //定义CD业务变量
    String strcdid="";String strcdexist="";String strcdname="";String strcdtype="";String strcdmtype="";String strcdactor="";String strcdnotes="";
    //定义REC业务变量
    String strreccdid="";String strreccardid="";String strrecstarttime="";String strrecendtime="";



//~~~~~~~~~~~~~~~~~~~~CARD业务~~~~~~~~~~~~~~~~//
    //card界面点击选择时的动作
    public void cboxcardusername_actionPerformed(ActionEvent e) {
        if(!cboxcardusername.isSelected())
        {txfcardusername.setEnabled(false);}
        else
        {txfcardusername.setEnabled(true);}
    }
    public void cboxcardbalance_actionPerformed(ActionEvent e) {
        if(!cboxcardbalance.isSelected())
        {txfcardbalance1.setEnabled(false);txfcardbalance2.setEnabled(false);}
        else
        {txfcardbalance1.setEnabled(true);txfcardbalance2.setEnabled(true);}
    }
    public void cboxcardrestnum_actionPerformed(ActionEvent e) {
        if(!cboxcardrestnum.isSelected())
        {txfcardrestnum1.setEnabled(false);txfcardrestnum2.setEnabled(false);}
        else
        {txfcardrestnum1.setEnabled(true);txfcardrestnum2.setEnabled(true);}
    }
    public void cboxcardid_actionPerformed(ActionEvent e) {
        if(!cboxcardid.isSelected())
        {txfcardid.setEnabled(false);}
        else
        {txfcardid.setEnabled(true);}
    }
    //card查询按钮动作
    public void btncardsearch_actionPerformed(ActionEvent e) {
        //分别得到对应的SQL语句
        if(cboxcardid.isSelected())
        {strcardid=" and cardid = '"+txfcardid.getText()+"'";}
        else{strcardid="";}
        if(cboxcardusername.isSelected())
        {strcardusername=" and cardusername like '%"+ txfcardusername.getText()+"%'";}
        else{strcardusername="";}
        if(cboxcardbalance.isSelected())
        {strcardbalance=" and cardbalance between "+txfcardbalance1.getText()+" and "+txfcardbalance2.getText();}
        else{strcardbalance="";}
        if(cboxcardrestnum.isSelected())
        {strcardrestnum=" and cardrestnum between "+txfcardrestnum1.getText()+" and "+txfcardrestnum2.getText();}
        else{strcardrestnum="";}
        //组合sql语句
        String searchcard="select cardid as '会员卡号',cardusername as '会员姓名',cardbalance as '会员余额' ,cardrestnum as '可借碟数' from card where 1=1"+strcardid+strcardusername+strcardbalance+strcardrestnum;
        queryDataSet1.close();
        queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1,searchcard, null, true, Load.ALL));
        queryDataSet1.open();
        card.add(pnl1);
        //显示表
        pnl1.setBounds(new Rectangle(25, 22, 574, 263));
        pnlcard.setBounds(new Rectangle(1083, 1065, 631, 359));
        //显示返回按钮
        btncardsearch.setVisible(false);
        btncardreset.setVisible(false);
        btncardback.setBounds(new Rectangle(500, 299, 80, 26));
    }
    //card重置按钮动作
    public void btncardreset_actionPerformed(ActionEvent e) {
         txfcardid.setText("");
         txfcardid.setEnabled(false);
         txfcardusername.setText("");
         txfcardusername.setEnabled(false);
         txfcardbalance1.setText("");
         txfcardbalance1.setEnabled(false);
         txfcardbalance2.setText("");
         txfcardbalance2.setEnabled(false);
         txfcardrestnum1.setText("");
         txfcardrestnum1.setEnabled(false);
         txfcardrestnum2.setText("");
         txfcardrestnum2.setEnabled(false);
         cboxcardid.setSelected(false);
         cboxcardid.setEnabled(true);
         cboxcardusername.setSelected(false);
         cboxcardusername.setEnabled(true);
         cboxcardbalance.setSelected(false);
         cboxcardbalance.setEnabled(true);
         cboxcardrestnum.setSelected(false);
         cboxcardrestnum.setEnabled(true);
    }
    //card返回按钮动作
    public void btncardback_actionPerformed(ActionEvent e) {
        //显示查询按钮
        btncardsearch.setVisible(true);
        btncardreset.setVisible(true);
        btncardback.setBounds(new Rectangle(500, 400, 80, 26));
        //显示查询项目
        pnlcard.setBounds(new Rectangle(25, 22, 574, 263));
        pnl1.setBounds(new Rectangle(1083, 1065, 631, 359));
        //删除rs表
        card.remove(pnl1);
    }
//~~~~~~~~~~~~~~~~~~~~CARD业务~~~~~~~~~~~~~~~~//




//~~~~~~~~~~~~~~~~~~~~CD业务~~~~~~~~~~~~~~~~~//
    //cd界面点击选择时的动作
    public void cboxcdactor_actionPerformed(ActionEvent e) {
        if(!cboxcdactor.isSelected())
        {txfcdactor.setEnabled(false);}
        else
        {txfcdactor.setEnabled(true);}
    }
    public void cboxcdmtype_actionPerformed(ActionEvent e) {
        if(!cboxcdmtype.isSelected())
        {cobcdmtype.setEnabled(false);}
        else
        {cobcdmtype.setEnabled(true);}
    }
    public void cboxcdtype_actionPerformed(ActionEvent e) {
        if(!cboxcdtype.isSelected())
        {cobcdtype.setEnabled(false);}
        else
        {cobcdtype.setEnabled(true);}
    }
    public void cboxcdname_actionPerformed(ActionEvent e) {
        if(!cboxcdname.isSelected())
        {txfcdname.setEnabled(false);}
        else
        {txfcdname.setEnabled(true);}
    }
    public void cboxcdexist_actionPerformed(ActionEvent e) {
        if(!cboxcdexist.isSelected())
        {cboxcdexistyes.setEnabled(false);}
        else
        {cboxcdexistyes.setEnabled(true);}
    }
    public void cboxcdnotes_actionPerformed(ActionEvent e) {
        if(!cboxcdnotes.isSelected())
        {txacdnotes.setEnabled(false);txacdnotes.setBackground(new Color(210, 210, 210));}
        else
        {txacdnotes.setEnabled(true);txacdnotes.setBackground(new Color(255, 255, 255));}
    }
    public void cboxcdid_actionPerformed(ActionEvent e) {
        if(!cboxcdid.isSelected())
        {txfcdid.setEnabled(false);}
        else
        {txfcdid.setEnabled(true);}
    }
    //cd重置按钮动作
    public void btncdreset_actionPerformed(ActionEvent e) {
        cboxcdid.setSelected(false);txfcdid.setText("");txfcdid.setEnabled(false);
        cboxcdexist.setSelected(false);cboxcdexistyes.setSelected(false);cboxcdexistyes.setEnabled(false);
        cboxcdname.setSelected(false);txfcdname.setText("");txfcdname.setEnabled(false);
        cboxcdtype.setSelected(false);cobcdtype.setSelectedIndex(0);cobcdtype.setEnabled(false);
        cboxcdmtype.setSelected(false);cobcdmtype.setSelectedIndex(0);cobcdmtype.setEnabled(false);
        cboxcdactor.setSelected(false);txfcdactor.setText("");txfcdactor.setEnabled(false);
        cboxcdnotes.setSelected(false);txacdnotes.setText("");txacdnotes.setEnabled(false);
    }
    //cd查询按钮动作
    public void btncdsearch2_actionPerformed(ActionEvent e) {
        //分别得到对应的SQL语句
        if(cboxcdid.isSelected())
        {strcdid=" and cdid = '"+txfcdid.getText()+"'";}
        else{strcdid="";}
        if(cboxcdexist.isSelected())
        {if (cboxcdexistyes.isSelected()){strcdexist=" and cdexist=1 ";}else{strcdexist=" and cdexist=0 ";}}
        else{strcdexist="";}
        if(cboxcdname.isSelected())
        {strcdname=" and cdname like '%"+txfcdname.getText()+"%'";}
        else{strcdname="";}
        if(cboxcdtype.isSelected())
        {strcdtype=" and cdtype = '"+cobcdtype.getSelectedItem().toString()+"'";}
        else{strcdtype="";}
        if(cboxcdmtype.isSelected())
        {strcdmtype=" and cdmtype = '"+cobcdmtype.getSelectedItem().toString()+"'";}
        else{strcdmtype="";}
        if(cboxcdactor.isSelected())
        {strcdactor=" and cdactor like '%"+txfcdactor.getText()+"%'";}
        else{strcdactor="";}
        if(cboxcdnotes.isSelected())
        {strcdnotes =" and cdnotes like '%"+txacdnotes.getText()+"%'";}
        else{strcdnotes="";}
        //组合sql语句
        String searchcd="select cdid as '碟片编号',cdexist as '在库',cdname as '影片名称',cdtype as '载体种类' ,cdmtype as '影片种类',cdactor as '主 演', cdnotes as '备 注' from cd where 1=1"+strcdid+strcdexist+strcdname+strcdtype+strcdmtype+strcdactor+strcdnotes;
        queryDataSet1.close();
        queryDataSet1.setQuery(new com.borland.dx.sql.dataset.QueryDescriptor(database1,searchcd, null, true, Load.ALL));
        queryDataSet1.open();
        //显示表
        cd.add(pnl2);
        pnl2.setBounds(new Rectangle(25, 22, 574, 263));
        pnlcd.setBounds(new Rectangle(1083, 1065, 631, 359));
        btncdreset.setVisible(false);
        btncdback.setBounds(new Rectangle(500, 299, 80, 26));
        //显示返回按钮
        btncdsearch2.setVisible(false);
        btncdreset.setVisible(false);
        btncdback.setBounds(new Rectangle(500, 299, 80, 26));

    }
    //cd返回按钮动作
    public void btncdback_actionPerformed(ActionEvent e) {
        //显示查询按钮
        btncdsearch2.setVisible(true);
        btncdreset.setVisible(true);
        btncdback.setBounds(new Rectangle(500, 400, 80, 26));
        //显示查询项目
        pnlcd.setBounds(new Rectangle(25, 22, 574, 263));
        pnl2.setBounds(new Rectangle(1083, 1065, 631, 359));
        //删除rs表
        cd.remove(pnl2);
    }
//~~~~~~~~~~~~~~~~~~~~CD业务~~~~~~~~~~~~~~~~~//

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -