欢迎来到虫虫下载站 | 资源下载 资源专辑 关于我们
虫虫下载站

medicine_data_input.java~185~

使用Java语言开发的数据库课程设计——医药管理信息系统。
JAVA~185~
第 1 页 / 共 4 页
字号:
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.BorderFactory;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.border.TitledBorder;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.Connection;
import java.sql.SQLException;
import java.awt.Font;
import java.awt.Toolkit;
import java.awt.Cursor;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import java.awt.Dimension;
import java.util.Vector;
import javax.swing.table.DefaultTableModel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import com.borland.jbcl.layout.XYLayout;
import javax.swing.JComboBox;
import javax.swing.JTextArea;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import java.awt.event.WindowAdapter;
import java.awt.Color;
import java.awt.event.WindowEvent;
import java.awt.SystemColor;
import com.borland.jbcl.layout.XYConstraints;
import com.borland.jbcl.layout.*;

public class medicine_data_input extends JFrame
{
    BorderLayout borderLayout1 = new BorderLayout();
    JTabbedPane jTabbedPane1 = new JTabbedPane();
    JPanel jPanel1 = new JPanel();
    JPanel jPanel2 = new JPanel();
    JLabel jLabel1 = new JLabel();
    JLabel jLabel2 = new JLabel();
    JLabel jLabel3 = new JLabel();
    JLabel jLabel4 = new JLabel();
    JLabel jLabel5 = new JLabel();
    JLabel jLabel6 = new JLabel();
    JLabel jLabel7 = new JLabel();
    JLabel jLabel8 = new JLabel();
    JTextField jTextField1 = new JTextField();
    JTextField jTextField2 = new JTextField();
    JTextField jTextField3 = new JTextField();
    JTextField jTextField4 = new JTextField();
    JLabel jLabel9 = new JLabel();
    JLabel jLabel10 = new JLabel();
    JLabel jLabel11 = new JLabel();
    JLabel jLabel12 = new JLabel();
    JLabel jLabel13 = new JLabel();
    XYLayout xYLayout1 = new XYLayout();
    Object[] danwei = {"盒","包","袋","罐","粒","片","瓶","个"};
    Object[] youxiaoqi = {"6个月","一年","18个月","二年","30个月","三年","三年以上"};
    Object[] jixing = {"针剂","片剂","胶囊","口服液","药油","药酒","冲剂","丸剂"};
    Object[] leibie = {"中药","西药","中成药","中成药(外用)","消毒","参茸"};
    Object[] query_option = {"通用名称","药品类别","剂型","单位"};
    Object[] zqcx ={"药品编号","药品名称"};
    JComboBox jComboBox1 = new JComboBox(leibie);
    JComboBox jComboBox2 = new JComboBox(youxiaoqi);
    JComboBox jComboBox3 = new JComboBox(danwei);
    JComboBox jComboBox4 = new JComboBox(jixing);
    JPanel jPanel3 = new JPanel();
    JTextField jTextField5 = new JTextField();
    JTextField jTextField6 = new JTextField();
    JTextField jTextField7 = new JTextField();
    JTextField jTextField8 = new JTextField();
    JTextField jTextField9 = new JTextField();
    JLabel jLabel14 = new JLabel();
    XYLayout xYLayout2 = new XYLayout();
    JTextField jTextField10 = new JTextField();
    JButton jButton1 = new JButton();
    JButton jButton2 = new JButton();
    JPanel jPanel6 = new JPanel();
    JButton jButton3 = new JButton();
    JButton jButton4 = new JButton();
    XYLayout xYLayout5 = new XYLayout();
    JLabel jLabel31 = new JLabel();
    JTextField jTextField22 = new JTextField();
    Icon pic = new ImageIcon(".\\images\\question.jpg");
    Icon bg = new ImageIcon(".\\images\\user.jpg");
    Icon search = new ImageIcon(".\\images\\search.gif");
    Icon cancel = new ImageIcon(".\\images\\cancel.jpg");

    String query;
    String check;
    String save;
    String insert_data;
    String delete;
    String Driver = "com.microsoft.jdbc.sqlserver.SQLServerDriver";
    String conURL = "jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=CASY";
    String Username = "sa";
    String Password = "111111";

    String cnd1 = null;
    String cnd2 = null;
    String cnd3 = null;
    String cnd4 = null;
    String cnd5 = null;
    String cnd6 = null;

    JPanel jPanel7 = new JPanel();
    JPanel jPanel8 = new JPanel();
    XYLayout xYLayout7 = new XYLayout();
    JLabel jLabel30 = new JLabel();
    JButton jButton7 = new JButton();
    JLabel jLabel32 = new JLabel();
    JTextField jTextField23 = new JTextField();
    JLabel jLabel33 = new JLabel();
    JTextField jTextField28 = new JTextField();
    XYLayout xYLayout8 = new XYLayout();
    JTextArea jTextArea1 = new JTextArea();
    TitledBorder titledBorder1 = new TitledBorder("");
    TitledBorder titledBorder2 = new TitledBorder("");
    JPanel jPanel4 = new JPanel();
    JPanel jPanel5 = new JPanel();
    BorderLayout borderLayout3 = new BorderLayout();
    JScrollPane jScrollPane1 = new JScrollPane();
    JTable jTable1 = new JTable();
    XYLayout xYLayout3 = new XYLayout();
    JLabel jLabel15 = new JLabel();
    JComboBox jComboBox5 = new JComboBox(query_option);
    JTextField jTextField11 = new JTextField();
    JButton jButton5 = new JButton();
    JButton jButton6 = new JButton();
    JLabel jLabel17 = new JLabel();

    Vector header;
    Vector data;
    String header_name[] = {"药品编号","药品名称","通用名称","药品类别","有效期","单位","剂型",
                            "包装数量","产地","零售价格","进货价格","批发价格","库存量"};

     DefaultTableModel tableModel1 = null;
    JTextField jTextField12 = new JTextField();
    JTextField jTextField13 = new JTextField();
    JComboBox jComboBox6 = new JComboBox(zqcx);
    JButton jButton8 = new JButton();
    JLabel jLabel16 = new JLabel();
    JLabel jLabel18 = new JLabel();
    XYLayout xYLayout4 = new XYLayout();
    JPanel jPanel9 = new JPanel();
    JLabel jLabel19 = new JLabel();
    BorderLayout borderLayout2 = new BorderLayout();
    public medicine_data_input()
    {
        this.setSize(676, 518);
        this.setTitle("数据录入/修改");
        this.setResizable(false);
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension frameSize = getSize();
        if (frameSize.height > screenSize.height) {
            frameSize.height = screenSize.height;
        }
        if (frameSize.width > screenSize.width) {
            frameSize.width = screenSize.width;
        }
        setLocation((screenSize.width - frameSize.width) / 2,
                    (screenSize.height - frameSize.height) / 2);

        this.addWindowListener(new WindowAdapter()
        {
            public void windowClosing(WindowEvent e)
            {
                new mainWin();
                dispose();
            }
        });
        try
        {
            jbInit();
        }
        catch (Exception exception)
        {
            exception.printStackTrace();
        }
        this.setVisible(true);
    }
    public void clearPane1()
    {
        jTextField1.setText("");
        jTextField2.setText("");
        jTextField3.setText("");
        jTextField4.setText("");
        jTextField5.setText("");
        jTextField6.setText("");
        jTextField7.setText("");
        jTextField8.setText("");
        jTextField9.setText("0");
    }

    public void Update_Data(String sql)
    {
        try
            {
                Connection con = DriverManager.getConnection(conURL, Username,
                        Password);
                Statement s = con.createStatement();
                s.executeUpdate(sql);
                JOptionPane.showMessageDialog(null, "操作成功", "操作完成!",
                                              JOptionPane.WARNING_MESSAGE);
                s.close();
            }
            catch (SQLException ex)
            {
                JOptionPane.showMessageDialog(null,"SQLException:" + ex.getMessage(),"警告!",JOptionPane.WARNING_MESSAGE);
            }
            jButton1.setEnabled(true);
            jButton3.setText("保  存");
            jTextField4.setText("0");
            jTextField7.setText("0.0");
            jTextField8.setText("0.0");
            jTextField9.setText("0");
    }

    private void jbInit() throws Exception
    {
        getContentPane().setLayout(borderLayout1);
        jLabel2.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jLabel2.setForeground(Color.black);
        jLabel2.setText("药品名称");
        jLabel3.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jLabel3.setForeground(Color.black);
        jLabel3.setText("通用名称");
        jLabel4.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jLabel4.setForeground(Color.black);
        jLabel4.setText(" 单 位 ");
        jLabel5.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jLabel5.setForeground(Color.black);
        jLabel5.setText(" 剂 型 ");
        jLabel6.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jLabel6.setForeground(Color.black);
        jLabel6.setText("包装数量");
        jLabel8.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jLabel8.setForeground(Color.black);
        jLabel8.setText(" 有效期");
        jLabel7.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jLabel7.setForeground(Color.black);
        jLabel7.setText("库存量");
        jTabbedPane1.setFont(new java.awt.Font("宋体", Font.BOLD, 14));
        jLabel1.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jLabel1.setForeground(Color.black);
        this.getContentPane().setBackground(SystemColor.control);
        jPanel1.setBackground(new Color(236, 233, 173));

⌨️ 快捷键说明

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