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

📄 srchleechdominfo.java~18~

📁 医疗管理系统
💻 JAVA~18~
字号:
package cliniquemanager;

import javax.swing.JPanel;
import com.borland.dx.sql.dataset.Database;
import com.borland.dx.sql.dataset.QueryDataSet;
import com.borland.dx.sql.dataset.ConnectionDescriptor;
import javax.swing.JScrollPane;
import com.borland.dbswing.JdbTable;
import com.borland.dx.sql.dataset.Load;
import com.borland.dx.sql.dataset.QueryDescriptor;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Dimension;
import java.awt.Font;
import javax.swing.JOptionPane;
import java.awt.Rectangle;
import javax.swing.JEditorPane;
import javax.swing.border.TitledBorder;
import java.awt.SystemColor;

/**
 * <p>Title: CliniqueManager</p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: shine</p>
 *
 * @author robin
 * @version 1.0
 */
public class SrchLeechdomInfo extends JPanel {
    Database database1 = new Database();
    JScrollPane jScrollPane1 = new JScrollPane();
    JdbTable dbtblDoctor = new JdbTable();
    JButton btnExit = new JButton();
    JButton btnAll = new JButton();
    JButton btnSearch2 = new JButton();
    JButton btnSearch1 = new JButton();
    JLabel lblName = new JLabel();
    JTextField txtName = new JTextField();
    QueryDataSet rsSearchLeechdom = new QueryDataSet();
    JLabel lblTip = new JLabel();
    JLabel lblTop = new JLabel();
    String sql;
    String tsql="select name as '药品名称',factory as '出产厂家',price as '价格' from leechdom ";
    JLabel lblFactory = new JLabel();
    JTextField txtFactory = new JTextField();
    TitledBorder titledBorder1 = new TitledBorder("基本操作");
    TitledBorder titledBorder2 = new TitledBorder("管理员信息");
    JEditorPane jEditorPane2 = new JEditorPane();
    TitledBorder titledBorder3 = new TitledBorder("查询条件");
    JEditorPane jEditorPane3 = new JEditorPane();
    JEditorPane jEditorPane1 = new JEditorPane();
    TitledBorder titledBorder4 = new TitledBorder("提示信息");


    public SrchLeechdomInfo() {
        try {
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        this.setSize(new Dimension(1000,700));
        this.setLayout(null);
        database1.setConnection(new ConnectionDescriptor(
                "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=Clinique",
                "sa", "", false, "com.microsoft.jdbc.sqlserver.SQLServerDriver"));
        btnExit.setBounds(new Rectangle(672, 547, 100, 30));
        btnExit.setText("退      出");
        btnExit.addActionListener(new SrchLeechdomInfo_btnExit_actionAdapter(this));
        btnAll.setBounds(new Rectangle(525, 547, 100, 30));
        btnAll.setText("全部显示");
        btnAll.addActionListener(new SrchLeechdomInfo_btnAll_actionAdapter(this));
        btnSearch2.setBounds(new Rectangle(381, 547, 100, 30));
        btnSearch2.setText("模糊查找");
        btnSearch2.addActionListener(new
                                     SrchLeechdomInfo_btnSearch2_actionAdapter(this));
        btnSearch1.setBounds(new Rectangle(233, 547, 100, 30));
        btnSearch1.setText("精确查找");
        btnSearch1.addActionListener(new
                                     SrchLeechdomInfo_btnSearch1_actionAdapter(this));
        lblName.setToolTipText("");
        lblName.setText("药品名称:");
        lblName.setBounds(new Rectangle(56, 480, 72, 15));
        search(tsql);
        lblTip.setToolTipText("");
        lblTip.setText("若知道药品名称或出产厂家,则输入后点按钮“精确查询”,若只知道其中的部分,则输入后点按钮“模糊查询”");
        lblTip.setBounds(new Rectangle(55, 614, 612, 38));
        lblTop.setBounds(new Rectangle(430, 20, 140, 24));
        lblTop.setText("药品信息查询");
        lblTop.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
        lblTop.setBounds(new Rectangle(430, 20, 140, 24));

        lblFactory.setText("出产厂家:");
        lblFactory.setBounds(new Rectangle(514, 480, 86, 15));
        rsSearchLeechdom.setReadOnly(true);
        jScrollPane1.setBounds(new Rectangle(0, 34, 400, 82));
        txtName.setBounds(new Rectangle(149, 473, 187, 32));
        txtFactory.setBounds(new Rectangle(618, 473, 187, 32));
        jScrollPane1.setBorder(titledBorder2);
        jScrollPane1.setBounds(new Rectangle(30, 50, 940, 400));
        jEditorPane1.setBackground(SystemColor.control);
        jEditorPane1.setEnabled(false);
        jEditorPane1.setBorder(titledBorder1);
        jEditorPane1.setEditable(false);
        jEditorPane1.setBounds(new Rectangle(30, 526, 940, 69));
        jEditorPane2.setBackground(SystemColor.control);
        jEditorPane2.setEnabled(false);
        jEditorPane2.setBorder(titledBorder3);
        jEditorPane2.setEditable(false);
        jEditorPane2.setBounds(new Rectangle(30, 449, 940, 78));
        jEditorPane3.setBackground(SystemColor.control);
        jEditorPane3.setEnabled(false);
        jEditorPane3.setBorder(titledBorder4);
        jEditorPane3.setEditable(false);
        jEditorPane3.setBounds(new Rectangle(30, 594, 940, 71));
        dbtblDoctor.setEditable(false);

        this.add(lblName);
        this.add(lblFactory);
        this.add(txtName);
        this.add(txtFactory);
        this.add(btnSearch1);
        this.add(btnSearch2);
        this.add(btnAll);
        this.add(btnExit);
        this.add(lblTip);
        this.add(lblTop);
        this.add(jScrollPane1, null);
        jScrollPane1.getViewport().add(dbtblDoctor);
        this.add(jEditorPane2);
        this.add(jEditorPane3);
        this.add(jEditorPane1);
    }

    public void search(String sql){
        rsSearchLeechdom.closeStatement();
        rsSearchLeechdom.setQuery(new QueryDescriptor(database1,
                sql, null, true,
                Load.ALL));
        dbtblDoctor.setDataSet(rsSearchLeechdom);
        rsSearchLeechdom.refresh();
    }

    public void btnSearch1_actionPerformed(ActionEvent e) {
        if (txtName.getText().equals("") && txtFactory.getText().equals("")) {
            JOptionPane.showMessageDialog(null, "请输入查询信息");
            return;
        }
        if(txtName.getText().equals(""))
            sql = tsql + "where factory='" + txtFactory.getText() + "'";
        else if(txtFactory.getText().equals(""))
            sql = tsql + "where name='" + txtName.getText() + "'";
        else
            sql = tsql + "where name='" + txtName.getText() + "' and factory='" + txtFactory.getText() + "'";
        search(sql);
        txtName.setText("");
        txtFactory.setText("");
    }

    public void btnSearch2_actionPerformed(ActionEvent e) {
        if (txtName.getText().equals("") && txtFactory.getText().equals("")) {
            JOptionPane.showMessageDialog(null, "请输入查询信息");
            return;
        }
        if(txtName.getText().equals(""))
            sql = tsql + "where factory like '%" + txtFactory.getText() + "%'";
        else if(txtFactory.getText().equals(""))
            sql = tsql + "where name like '%" + txtName.getText() + "%'";
        else
            sql = tsql + "where name like '%" + txtName.getText() + "%' and factory like '%" + txtFactory.getText() + "%'";
        search(sql);
        txtName.setText("");
        txtFactory.setText("");
    }

    public void btnAll_actionPerformed(ActionEvent e) {
        search(tsql);
    }

    public void btnExit_actionPerformed(ActionEvent e) {
        this.setVisible(false);
    }

}


class SrchLeechdomInfo_btnExit_actionAdapter implements ActionListener {
    private SrchLeechdomInfo adaptee;
    SrchLeechdomInfo_btnExit_actionAdapter(SrchLeechdomInfo adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.btnExit_actionPerformed(e);
    }
}


class SrchLeechdomInfo_btnAll_actionAdapter implements ActionListener {
    private SrchLeechdomInfo adaptee;
    SrchLeechdomInfo_btnAll_actionAdapter(SrchLeechdomInfo adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.btnAll_actionPerformed(e);
    }
}


class SrchLeechdomInfo_btnSearch2_actionAdapter implements ActionListener {
    private SrchLeechdomInfo adaptee;
    SrchLeechdomInfo_btnSearch2_actionAdapter(SrchLeechdomInfo adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.btnSearch2_actionPerformed(e);
    }
}


class SrchLeechdomInfo_btnSearch1_actionAdapter implements ActionListener {
    private SrchLeechdomInfo adaptee;
    SrchLeechdomInfo_btnSearch1_actionAdapter(SrchLeechdomInfo adaptee) {
        this.adaptee = adaptee;
    }

    public void actionPerformed(ActionEvent e) {
        adaptee.btnSearch1_actionPerformed(e);
    }
}

⌨️ 快捷键说明

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