package com.hua.View;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.Connection;
import java.sql.ResultSet;
import java.util.Vector;
import javax.swing.ButtonGroup;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JButton;
import javax.swing.JInternalFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.border.TitledBorder;
import javax.swing.table.DefaultTableModel;
import com.hua.Medicines.depository.MedicinesInformation;
import com.hua.Medicines.depository.MedicinesType;
import com.hua.People.User;
import com.hua.Util.DbUtil;
import com.hua.dao.MedicalDao;
/**
* 药品-->药品管理操作:管理员添加、删除、修改
* @author 沈shuohua
*
*/
public class MedicalOperateInternalFrame extends JInternalFrame {
private JTextField queryMedicalNameTxt;
private JTable medicalInformationTable;
private JTextField idTxt;
private JTextField medicalNameTxt;
private JTextField storeNumberTxt;
private JTextField priceTxt;
private JTextField producedDateTxt;
private JTextField expirationTxt;
private final ButtonGroup buttonGroup = new ButtonGroup();
private final ButtonGroup buttonGroup_1 = new ButtonGroup();
public static User user;
private MedicalDao medicalDao =new MedicalDao();
private DbUtil dbUtil = new DbUtil();
private JTextArea queryMedicalDescArea;
private JRadioButton ChineseMedicalTypeRadioButton;
private JRadioButton WesternMedicalTypeRadioButton;
private JRadioButton ChineseRadioButton;
private JRadioButton WesternRadioButton;
private JTextArea producedAddressArea;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
MedicalOperateInternalFrame frame = new MedicalOperateInternalFrame();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public MedicalOperateInternalFrame() {
setClosable(true);
setIconifiable(true);
setBounds(100, 100, 912, 607);
JPanel panel = new JPanel();
panel.setBorder(new TitledBorder(null, "\u641C\u7D22\u6761\u4EF6", TitledBorder.LEADING, TitledBorder.TOP, null, null));
JScrollPane scrollPane = new JScrollPane();
JPanel panel_1 = new JPanel();
panel_1.setBorder(new TitledBorder(null, "\u6DFB\u52A0\u3001\u4FEE\u6539\u3001\u5220\u9664", TitledBorder.LEADING, TitledBorder.TOP, null, null));
GroupLayout groupLayout = new GroupLayout(getContentPane());
groupLayout.setHorizontalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(Alignment.TRAILING, groupLayout.createSequentialGroup()
.addContainerGap()
.addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
.addComponent(panel, GroupLayout.DEFAULT_SIZE, 882, Short.MAX_VALUE)
.addGroup(groupLayout.createParallelGroup(Alignment.LEADING, false)
.addComponent(panel_1, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(scrollPane, GroupLayout.DEFAULT_SIZE, 874, Short.MAX_VALUE)))
.addContainerGap())
);
groupLayout.setVerticalGroup(
groupLayout.createParallelGroup(Alignment.LEADING)
.addGroup(groupLayout.createSequentialGroup()
.addComponent(panel, GroupLayout.PREFERRED_SIZE, 152, GroupLayout.PREFERRED_SIZE)
.addGap(27)
.addComponent(scrollPane, GroupLayout.PREFERRED_SIZE, 157, GroupLayout.PREFERRED_SIZE)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(panel_1, GroupLayout.DEFAULT_SIZE, 222, Short.MAX_VALUE)
.addContainerGap())
);
JLabel lblNewLabel_2 = new JLabel("\u7F16 \u53F7\uFF1A");
idTxt = new JTextField();
idTxt.setEditable(false);
idTxt.setColumns(10);
JLabel lblNewLabel_3 = new JLabel("\u836F\u54C1\u540D\u79F0\uFF1A");
medicalNameTxt = new JTextField();
medicalNameTxt.setColumns(10);
JLabel lblNewLabel_4 = new JLabel("\u5E93 \u5B58 \u91CF\uFF1A");
storeNumberTxt = new JTextField();
storeNumberTxt.setColumns(10);
JLabel lblNewLabel_5 = new JLabel("\u4EF7 \u683C\uFF1A");
priceTxt = new JTextField();
priceTxt.setColumns(10);
JLabel lblNewLabel_6 = new JLabel("\u751F\u4EA7\u65E5\u671F\uFF1A");
producedDateTxt = new JTextField();
producedDateTxt.setColumns(10);
JLabel lblNewLabel_7 = new JLabel("\u4FDD \u8D28 \u671F\uFF1A");
expirationTxt = new JTextField();
expirationTxt.setColumns(10);
JLabel lblNewLabel_8 = new JLabel("\u751F\u4EA7\u5730\u5740\uFF1A");
producedAddressArea = new JTextArea();
JLabel lblNewLabel_9 = new JLabel("\u836F\u54C1\u63CF\u8FF0\uFF1A");
JTextArea meidcalDescArea = new JTextArea();
JButton btnNewButton_1 = new JButton("\u6DFB\u52A0");
btnNewButton_1.addActionListener(new ActionListener() {
/**
* 添加事件处理
*/
public void actionPerformed(ActionEvent e) {
addActionPerformed(e);
}
});
JButton btnNewButton_2 = new JButton("\u4FEE\u6539");
btnNewButton_2.addActionListener(new ActionListener() {
/**
* 修改事件处理
*/
public void actionPerformed(ActionEvent e) {
updateActionPerformed(e);
}
});
JButton btnNewButton_3 = new JButton("\u5220\u9664");
btnNewButton_3.addActionListener(new ActionListener() {
/**
* 删除事件处理
*/
public void actionPerformed(ActionEvent e) {
deleteActionPerformed(e);
}
});
ChineseRadioButton = new JRadioButton("\u4E2D\u836F");
buttonGroup_1.add(ChineseRadioButton);
ChineseRadioButton.setSelected(true);
WesternRadioButton = new JRadioButton("\u897F\u836F");
buttonGroup_1.add(WesternRadioButton);
GroupLayout gl_panel_1 = new GroupLayout(panel_1);
gl_panel_1.setHorizontalGroup(
gl_panel_1.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_1.createSequentialGroup()
.addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_1.createSequentialGroup()
.addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_1.createSequentialGroup()
.addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_1.createSequentialGroup()
.addGap(18)
.addComponent(lblNewLabel_2)
.addGap(12)
.addComponent(idTxt, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panel_1.createSequentialGroup()
.addGap(19)
.addComponent(lblNewLabel_3)
.addGap(11)
.addComponent(medicalNameTxt, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)))
.addGap(93)
.addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_1.createSequentialGroup()
.addGap(1)
.addComponent(lblNewLabel_7)
.addGap(9)
.addComponent(expirationTxt, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
.addGroup(gl_panel_1.createSequentialGroup()
.addComponent(lblNewLabel_6)
.addPreferredGap(ComponentPlacement.UNRELATED)
.addComponent(producedDateTxt, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
.addGap(94)
.addComponent(lblNewLabel_9))))
.addGroup(gl_panel_1.createSequentialGroup()
.addGroup(gl_panel_1.createParallelGroup(Alignment.LEADING)
.addGroup(gl_panel_1.createSequentialGroup()
.addGap(19)
.addCompo