medicine_information.java~156~

来自「使用Java语言开发的数据库课程设计——医药管理信息系统。」· JAVA~156~ 代码 · 共 882 行 · 第 1/3 页

JAVA~156~
882
字号
import java.awt.*;

import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.Font;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.ResultSet;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.*;
import javax.swing.BorderFactory;
import java.awt.Color;
import javax.swing.border.TitledBorder;

public class medicine_information 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 = {"中药","西药","中成药","中成药(外用)","消毒","参茸"};
    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();
    XYLayout xYLayout3 = new XYLayout();
    JPanel jPanel4 = new JPanel();
    JPanel jPanel5 = new JPanel();
    JLabel jLabel15 = new JLabel();
    XYLayout xYLayout4 = new XYLayout();
    JTextField jTextField11 = new JTextField();
    JLabel jLabel16 = new JLabel();
    JTextField jTextField12 = new JTextField();
    JPanel jPanel6 = new JPanel();
    JButton jButton3 = new JButton();
    JButton jButton4 = new JButton();
    XYLayout xYLayout5 = new XYLayout();
    XYLayout xYLayout6 = new XYLayout();
    JLabel jLabel17 = new JLabel();
    JLabel jLabel18 = new JLabel();
    JTextField jTextField13 = new JTextField();
    JLabel jLabel19 = new JLabel();
    JTextField jTextField14 = new JTextField();
    JTextField jTextField15 = new JTextField();
    JLabel jLabel20 = new JLabel();
    JLabel jLabel21 = new JLabel();
    JLabel jLabel22 = new JLabel();
    JTextField jTextField16 = new JTextField();
    JLabel jLabel23 = new JLabel();
    JTextField jTextField17 = new JTextField();
    JTextField jTextField18 = new JTextField();
    JLabel jLabel24 = new JLabel();
    JLabel jLabel25 = new JLabel();
    JLabel jLabel26 = new JLabel();
    JTextField jTextField19 = new JTextField();
    JLabel jLabel27 = new JLabel();
    JTextField jTextField20 = new JTextField();
    JTextField jTextField21 = new JTextField();
    JLabel jLabel28 = new JLabel();
    JLabel jLabel29 = new JLabel();
    JLabel jLabel31 = new JLabel();
    JTextField jTextField22 = new JTextField();
    JButton jButton5 = new JButton();
    JTextField jTextField24 = new JTextField();
    JTextField jTextField25 = new JTextField();
    JTextField jTextField26 = new JTextField();
    JTextField jTextField27 = new JTextField();
    Icon pic = new ImageIcon(".\\images\\question.jpg");

    String query;
    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";
    JButton jButton6 = new JButton();
    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("");
    public medicine_information()
    {
        try
        {
            this.setSize(new Dimension(676, 518));
            this.setVisible(true);
            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);

            jbInit();
            this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        }
        catch (Exception exception)
        {
            exception.printStackTrace();
        }
    }
    public void clearPane1()
    {
        jTextField1.setText("");
        jTextField2.setText("");
        jTextField3.setText("");
        jTextField4.setText("");
        jTextField5.setText("");
        jTextField6.setText("");
        jTextField7.setText("");
        jTextField8.setText("");
        jTextField9.setText("");
    }
    public void clearPanel2()
    {
        jTextField11.setText("");
        jTextField12.setText("");
        jTextField13.setText("");
        jTextField14.setText("");
        jTextField15.setText("");
        jTextField16.setText("");
        jTextField17.setText("");
        jTextField18.setText("");
        jTextField19.setText("");
        jTextField20.setText("");
        jTextField21.setText("");
        jTextField24.setText("");
        jTextField25.setText("");
        jTextField26.setText("");
        jTextField27.setText("");
    }

    public void Connect_DB()
    {
        try
        {
            Class.forName(Driver);
        }
        catch(ClassNotFoundException ee)
        {
            JOptionPane.showMessageDialog(null,"ForName:" + ee.getMessage(),"错误!",
                     JOptionPane.WARNING_MESSAGE);
        }

    }

    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.0");

    }

    private void jbInit() throws Exception
    {
        this.setResizable(false);
        getContentPane().setLayout(borderLayout1);
        jLabel2.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jLabel2.setForeground(Color.red);
        jLabel2.setText("药品名称");
        jLabel3.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jLabel3.setForeground(Color.red);
        jLabel3.setText("通用名称");
        jLabel4.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jLabel4.setForeground(Color.red);
        jLabel4.setText(" 单 位 ");
        jLabel5.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jLabel5.setForeground(Color.red);
        jLabel5.setText(" 剂 型 ");
        jLabel6.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jLabel6.setForeground(Color.red);
        jLabel6.setText("包装数量");
        jLabel8.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jLabel8.setForeground(Color.red);
        jLabel8.setText(" 有效期");
        jLabel7.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jLabel7.setForeground(Color.red);
        jLabel7.setText(" 批 号 ");
        jTabbedPane1.setFont(new java.awt.Font("宋体", Font.BOLD, 14));
        jLabel1.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jLabel1.setForeground(Color.red);
        this.getContentPane().setBackground(SystemColor.control);
        jPanel1.setBackground(new Color(0, 219, 0));
        jPanel1.setFont(new java.awt.Font("宋体", Font.PLAIN, 10));
        jLabel9.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jLabel9.setForeground(Color.red);
        jLabel9.setText(" 产 地 ");
        jLabel10.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jLabel10.setForeground(Color.red);
        jLabel10.setText("进货价格");
        jLabel11.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jLabel11.setForeground(Color.red);
        jLabel11.setText("批发价格");
        jLabel12.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jLabel12.setForeground(Color.red);
        jLabel12.setText("零售价格");
        jLabel13.setFont(new java.awt.Font("宋体", Font.BOLD, 15));
        jLabel13.setForeground(Color.red);
        jLabel13.setText("药品类别");
        jPanel3.setBackground(Color.orange);
        jPanel3.setBorder(BorderFactory.createRaisedBevelBorder());
        jPanel3.setLayout(xYLayout2);
        jPanel1.setLayout(xYLayout1);
        jLabel1.setText("药品编号");
        jLabel14.setFont(new java.awt.Font("宋体", Font.BOLD, 14));
        jLabel14.setForeground(Color.blue);
        jLabel14.setText("药品编号");
        jButton1.setText("修  改");
        jButton1.addActionListener(new
                                   medicine_information_jButton1_actionAdapter(this));
        jButton2.setText("新资料");
        jButton2.addActionListener(new
                                   medicine_information_jButton2_actionAdapter(this));
        jPanel2.setLayout(xYLayout3);
        jPanel4.setBackground(Color.orange);
        jPanel4.setBorder(BorderFactory.createEtchedBorder());
        jPanel4.setLayout(xYLayout4);
        jPanel5.setBackground(new Color(66, 227, 0));
        jPanel5.setLayout(xYLayout6);
        jLabel15.setFont(new java.awt.Font("宋体", Font.BOLD, 14));
        jLabel15.setText("药品编号");
        jLabel16.setFont(new java.awt.Font("宋体", Font.BOLD, 14));

⌨️ 快捷键说明

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