源码获取:博客首页 "资源" 里下载!
功能介绍:
登陆界面、管理员界面、用户界面、汽车租赁文档
系统主页:
@SuppressWarnings("serial")
public class SystemMainView extends JFrame implements ActionListener{
JButton button,btnOk,select;
JScrollPane jsp;
JTextPane area=new JTextPane();
JTextField textfield;
JFileChooser fc=new JFileChooser();
File file=null;
ImageIcon imageIcon=new ImageIcon("E:\\图片册\\lan.jpg");
public SystemMainView(){
setTitle("药品管理系统");
this.setSize( 900, 500);
setResizable(false);
setLocationRelativeTo(null);
layoutUI();
this.setVisible(true);
}
private void layoutUI(){
//对象实例化
JTabbedPane tab = new JTabbedPane(JTabbedPane.TOP);
//容器
Container container = this.getLayeredPane();
//对象化面板
JPanel combop = new JPanel(){
public void paintComponent(Graphics g) {
super.paintComponent(g);
ImageIcon icon=new ImageIcon("E:\\图片册\\pu.jpg");
g.drawImage(icon.getImage(), 0, 0, null);
}
};
JPanel p1 = new EmployeeManagerView();
JPanel p2 = new Medicine();
JPanel p3 = new MarketView();
JPanel p4 = new MarketMessage();
JPanel p5 = new JPanel(){
public void paintComponent(Graphics g) {
super.paintComponent(g);
ImageIcon icon=new ImageIcon("E:\\图片册\\pu.jpg");
g.drawImage(icon.getImage(), 0, 0, null);
}
};
p5.add(new JButton("药品信息百科"));
textfield=new JTextField(10);
p5.add(textfield);
select=new JButton("浏览");
p5.add(select);
select.addActionListener(this);
p5.add(btnOk=new JButton("确定"));
btnOk.addActionListener(this);
tab.add(p1," 用户管理 ");
tab.add(p2," 药品库存管理 ");
tab.add(p3," 进销管理 ");
tab.add(p4," 营销信息 ");
// tab.add(p5," 问答园地 ");
tab.setBackground(Color.green);
tab.setFont(new Font("Dialog",1,17));
JLabel JL = new JLabel("药品管理系统");
combop.add(JL);
JL.setFont(new Font("Dialog",1,23));
JL.setBackground(Color.green);
container.setLayout(new BorderLayout());
container.setBackground(Color.cyan);
container.add(combop,BorderLayout.NORTH);
container.add(tab,BorderLayout.CENTER);
}
public void actionPerformed(ActionEvent e){
if (e.getSource()==select){
int intRetVal=fc.showOpenDialog(this);
if(intRetVal==JFileChooser.APPROVE_OPTION){
file=fc.getSelectedFile();
textfield.setText(file.getPath());
}
}
if(e.getSource()==btnOk){
JFrame f=new JFrame();
f.setSize(500, 370);
f.setLocationRelativeTo(null);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);
area=new JTextPane();
jsp=new JScrollPane(area);
jsp.getViewport().setBackground(Color.green);
area.setBackground(Color.cyan);
area.setOpaque(false);
//area.setLineWrap(true);
//area.setWrapStyleWord(true);
f.add(jsp);
try{
readFile(area);
}catch(Exception ex){
}
}
}
private void readFile(JTextPane area)throws Exception{
if(file !=null){
FileReader fr=new FileReader(file);
BufferedReader br=new BufferedReader(new InputStreamReader(new FileInputStream(file),"GBK"));
try{
while (br.ready()){
area.setText(area.getText()+br.readLine()+"\r\n");
}
}finally{
br.close();
fr.close();
}
}
}
}
服务信息业务处理:
package com.view;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
import com.db.SqlHelper;
@SuppressWarnings("serial")
public class ServiceInfo extends JFrame {
@SuppressWarnings("unused")
private MarketView area;
private DefaultTableModel dtm1 = new DefaultTableModel();
private JTable empeJtable = new JTable(dtm1);
private JScrollPane centerJscrollPane = new JScrollPane(empeJtable){
public void paintComponent(Graphics g){
super.paintComponent(g);
ImageIcon icon=new ImageIcon("E:\\图片册\\pu.jpg");
g.drawImage(icon.getImage(), 0, 0, null);
}
};
private JButton returnBtn;
private ArrayList<Object[]> datas = null;
public ServiceInfo(MarketView area) {
this.area=area;
setTitle("药市信息");
setSize(600, 300);
setLocationRelativeTo(null);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
setLayout(new BorderLayout());
add(centerJscrollPane);
dtm1.addColumn("药品id");
dtm1.addColumn("药品名称");
dtm1.addColumn("入市时间");
dtm1.addColumn("药品分类");
dtm1.addColumn("地区市场");
dtm1.addColumn("市场价格");
dtm1.addColumn("流通数量");
refreshJTable2();
returnBtn = new JButton("返回");
returnBtn.setBackground(Color.lightGray);
add(returnBtn,BorderLayout.SOUTH);
returnBtn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
dispose();
}
});
}
@SuppressWarnings({ "null", "unused" })
private ArrayList<Object[]> getServiceInfoByDb() throws SQLException {
ArrayList<Object[]> serviceinfomation = new ArrayList<Object[]>();
// 查询sql语句
String sql = "select * from serviceinfo";
// 查询数据
ResultSet result = new SqlHelper().query(sql, new String[] {});
if (result != null) {
while (result.next()) {
Object rows[] = new Object[7];
rows[0] = result.getString(1);
rows[1] = result.getString(2);
rows[2] = result.getString(3);
rows[3] = result.getString(4);
rows[4] = result.getString(5);
rows[5] = result.getString(6);
rows[6] = result.getString(7);
serviceinfomation.add(rows);
}
} else {
JOptionPane.showConfirmDialog(null, "没有查询到", "提示", JOptionPane.WARNING_MESSAGE);
}
return serviceinfomation;
}
public void refreshJTable2() {
dtm1.setNumRows(0);
try {
datas = getServiceInfoByDb();
for (int i = 0; i < datas.size(); i++) {
dtm1.addRow(datas.get(i));
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
源码获取:博客首页 "资源" 里下载!