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

📄 add_madicine.java~11~

📁 在个一个诊所系统,实现数据的查询和删除等的操作.
💻 JAVA~11~
字号:
package clinique;

import java.awt.*;
import java.sql.*;
import javax.swing.*;
import java.awt.Rectangle;
import com.borland.dbswing.JdbTable;
import com.borland.dx.sql.dataset.Database;
import com.borland.dx.sql.dataset.QueryDataSet;
import com.borland.dx.sql.dataset.ConnectionDescriptor;
import com.borland.dx.sql.dataset.Load;
import com.borland.dx.sql.dataset.QueryDescriptor;
import com.borland.dx.dataset.Column;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2007</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class add_madicine extends JPanel {
    public add_madicine() {
        try {
            jbInit();
            connect();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }

    private void connect()
    {
        try {
     Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
 } catch (ClassNotFoundException ce) {
     System.out.println(ce);
 }
 try {
     String url = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=clinique";
     Connection con = DriverManager.getConnection(url,"sa","");
     Statement s = con.createStatement();
 //    ResultSet rs = s.executeQuery("select * from madicine");
//     rs.close();
//     s.close();
//     con.close();
 } catch (SQLException ce) {
     System.out.println(ce);
 }

    }
    private void jbInit() throws Exception {
        this.setLayout(null);
        jScrollPane1.setBounds(new Rectangle(95, 178, 343, 194));
        database1.setConnection(new ConnectionDescriptor(
                "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=clinique",
                "sa", "", false, "com.microsoft.jdbc.sqlserver.SQLServerDriver"));
        queryDataSet1.setQuery(new QueryDescriptor(database1,
                "select * from medicine", null, true, Load.ALL));
        jdbTable1.setDataSet(queryDataSet1);
        column1.setColumnName("name");
        column1.setDataType(com.borland.dx.dataset.Variant.STRING);
        column1.setPrecision(50);
        column1.setTableName("medicine");
        column1.setWidth(13);
        column1.setServerColumnName("NAME");
        column1.setSqlType(1);
        column2.setColumnName("factory");
        column2.setDataType(com.borland.dx.dataset.Variant.STRING);
        column2.setPrecision(50);
        column2.setTableName("medicine");
        column2.setWidth(13);
        column2.setServerColumnName("FACTORY");
        column2.setSqlType(1);
        column3.setColumnName("price");
        column3.setDataType(com.borland.dx.dataset.Variant.BIGDECIMAL);
        column3.setPrecision(19);
        column3.setScale(4);
        column3.setTableName("medicine");
        column3.setWidth(13);
        column3.setServerColumnName("PRICE");
        column3.setSqlType(3);
        queryDataSet1.setColumns(new Column[] {column1, column2, column3});
        jBadd.setBounds(new Rectangle(75, 133, 92, 23));
        jBadd.setText("添加药品");
        jBadd.addActionListener(new add_madicine_jBadd_actionAdapter(this));
        jBexit.setBounds(new Rectangle(203, 134, 101, 23));
        jBexit.setText("取消");
        jBrefurbish.setBounds(new Rectangle(337, 133, 91, 23));
        jBrefurbish.setText("刷新数据");
        jLabel1.setText("药品名称:");
        jLabel1.setBounds(new Rectangle(71, 37, 63, 15));
        jLabel2.setText("药品厂家:");
        jLabel2.setBounds(new Rectangle(277, 38, 59, 15));
        jLabel3.setText("药品单价:");
        jLabel3.setBounds(new Rectangle(69, 85, 62, 15));
        mad_name.setBounds(new Rectangle(146, 33, 89, 20));
        mad_factory.setBounds(new Rectangle(356, 35, 90, 20));
        mad_price.setBounds(new Rectangle(146, 82, 89, 20));
        jBreturn.setBounds(new Rectangle(459, 135, 102, 23));
        jBreturn.setText("返回主窗体");
        this.setBackground(SystemColor.control);
        this.add(jLabel1);
        this.add(jLabel2);
        this.add(mad_price);
        this.add(jLabel3);
        this.add(mad_name);
        this.add(mad_factory);
        this.add(jScrollPane1);
        this.add(jBadd);
        this.add(jBexit);
        this.add(jBrefurbish);
        this.add(jBreturn);
        jScrollPane1.getViewport().add(jdbTable1);
    }



    JScrollPane jScrollPane1 = new JScrollPane();
    JdbTable jdbTable1 = new JdbTable();
    Database database1 = new Database();
    QueryDataSet queryDataSet1 = new QueryDataSet();
    Column column1 = new Column();
    Column column2 = new Column();
    Column column3 = new Column();
    JButton jBadd = new JButton();
    JButton jBexit = new JButton();
    JButton jBrefurbish = new JButton();
    JLabel jLabel1 = new JLabel();
    JLabel jLabel2 = new JLabel();
    JLabel jLabel3 = new JLabel();
    JTextField mad_name = new JTextField();
    JTextField mad_factory = new JTextField();
    JTextField mad_price = new JTextField();
    JButton jBreturn = new JButton();
    public void jBadd_actionPerformed(ActionEvent e) {
        String name;
        String factory;
        String price;
        name=mad_name.getText();
        factory=mad_factory.getText();
        price=mad_price.getText();
        String sqlStr;
        sqlStr="inset into madicine(name,factory,price) vlaues(\'name\',\'factory\',\'price\')";

    }

}


class add_madicine_jBadd_actionAdapter implements ActionListener {
    private add_madicine adaptee;
    add_madicine_jBadd_actionAdapter(add_madicine adaptee) {
        this.adaptee = adaptee;
    }

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

⌨️ 快捷键说明

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