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

📄 srchpatientinfo.java~17~

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

import java.awt.BorderLayout;

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.GridLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import com.borland.dx.dataset.Column;
import java.awt.Dimension;
import java.awt.Font;
import javax.swing.JOptionPane;
import javax.swing.JComboBox;

/**
 * <p>Title: CliniqueManager</p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: shine</p>
 *
 * @author robin
 * @version 1.0
 */
public class SrchPatientInfo extends JPanel {
    BorderLayout borderLayout1 = new BorderLayout();
    Database database1 = new Database();
    JPanel pnlButton = new JPanel();
    JPanel pnlInfo = new JPanel();
    JPanel pnlSouth = new JPanel();
    JPanel pnlNorth = new JPanel();
    JScrollPane jScrollPane1 = new JScrollPane();
    JdbTable dbtblPatient = 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 rsSearchPatient = new QueryDataSet();
    JLabel lblTip = new JLabel();
    GridLayout gridLayout3 = new GridLayout();
    JLabel jLabel3 = new JLabel();
    JLabel jLabel4 = new JLabel();
    GridLayout gridLayout1 = new GridLayout();
    JLabel jLabel5 = new JLabel();
    JLabel jLabel6 = new JLabel();
    JLabel jLabel7 = new JLabel();
    JLabel lblTop = new JLabel();
    String sql;
   // String tsql="select ptnt_id as '编号',name as '姓名',dname as '主治医生',sex as '性别',blood as '血型',height as '身高',weigth as '体重' from patient ";
    String tsql="select ptnt_id as '编号', name as '姓名',dname as '主治医生',sex as '性别',blood as '血型', birth as '生日',height as '身高',weight as'体重',leechdom as '所用药品' from patient ";
    JLabel jLabel1 = new JLabel();
    GridLayout gridLayout2 = new GridLayout();
    JLabel lblDocName = new JLabel();
    JTextField txtDocName = new JTextField();
    public SrchPatientInfo() {
        try {
            jbInit();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    private void jbInit() throws Exception {
        Dimension dimen = new Dimension(90,30);
        this.setLayout(borderLayout1);
        database1.setConnection(new ConnectionDescriptor(
                "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=Clinique",
                "sa", "", false, "com.microsoft.jdbc.sqlserver.SQLServerDriver"));
        btnExit.setText("退      出");
        btnExit.addActionListener(new SrchPatientInfo_btnExit_actionAdapter(this));
        btnAll.setText("全部显示");
        btnAll.addActionListener(new SrchPatientInfo_btnAll_actionAdapter(this));
        btnSearch2.setText("模糊查找");
        btnSearch2.addActionListener(new
                                     SrchPatientInfo_btnSearch2_actionAdapter(this));
        btnSearch1.setText("精确查找");
        btnSearch1.addActionListener(new
                                     SrchPatientInfo_btnSearch1_actionAdapter(this));
        lblName.setToolTipText("");
        lblName.setText("病人姓名:");
        pnlSouth.setLayout(gridLayout1);
        pnlInfo.setLayout(gridLayout2);
        search(tsql);
        lblTip.setToolTipText("");
        lblTip.setText("提示:若知道病人姓名或主治医生,则输入后点按钮“精确查询”,若只知道其中的部分,则输入后点按钮“模糊查询”");
        pnlButton.setLayout(gridLayout3);
        gridLayout3.setColumns(6);
        gridLayout1.setColumns(1);
        gridLayout1.setRows(8);
        lblTop.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
        lblTop.setText("病人信息查询");

        lblDocName.setText("主治医生:");
       /* rsSearchPatient.setQuery(new QueryDescriptor(database1,
                "select ptnt_id, name, sex, leechdom, height, dname, blood, birth, " +
                "weight from patient", null, true, Load.ALL));*/
        pnlButton.add(jLabel3);
        pnlButton.add(btnSearch1);
        pnlButton.add(btnSearch2);
        pnlButton.add(btnAll);
        pnlButton.add(btnExit);
        pnlButton.add(jLabel4);
        pnlSouth.add(jLabel6);
        this.add(jScrollPane1, java.awt.BorderLayout.CENTER);
        jScrollPane1.getViewport().add(dbtblPatient);
        pnlInfo.add(lblName);
        pnlInfo.add(txtName);
        pnlInfo.add(jLabel1);
        pnlInfo.add(lblDocName);
        pnlInfo.add(txtDocName);
        pnlSouth.add(pnlInfo, null);
        pnlSouth.add(jLabel5);
        pnlSouth.add(pnlButton, null);
        pnlSouth.add(jLabel7);
        pnlNorth.add(lblTop);
        pnlSouth.add(lblTip, null);
        this.add(pnlSouth, java.awt.BorderLayout.SOUTH);
        this.add(pnlNorth, java.awt.BorderLayout.NORTH);
    }

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

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

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

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

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

}


class SrchPatientInfo_btnExit_actionAdapter implements ActionListener {
    private SrchPatientInfo adaptee;
    SrchPatientInfo_btnExit_actionAdapter(SrchPatientInfo adaptee) {
        this.adaptee = adaptee;
    }

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


class SrchPatientInfo_btnAll_actionAdapter implements ActionListener {
    private SrchPatientInfo adaptee;
    SrchPatientInfo_btnAll_actionAdapter(SrchPatientInfo adaptee) {
        this.adaptee = adaptee;
    }

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


class SrchPatientInfo_btnSearch2_actionAdapter implements ActionListener {
    private SrchPatientInfo adaptee;
    SrchPatientInfo_btnSearch2_actionAdapter(SrchPatientInfo adaptee) {
        this.adaptee = adaptee;
    }

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


class SrchPatientInfo_btnSearch1_actionAdapter implements ActionListener {
    private SrchPatientInfo adaptee;
    SrchPatientInfo_btnSearch1_actionAdapter(SrchPatientInfo adaptee) {
        this.adaptee = adaptee;
    }

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

⌨️ 快捷键说明

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