package src;
//Download by http://www.codefans.net
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import java.text.SimpleDateFormat;
import java.util.Date;
//import java.util.Vector;
public class My_MainFrame {
private final static javax.swing.ImageIcon icon = new javax.swing.ImageIcon("res/logo1.jpg");
private JFrame frame = new javax.swing.JFrame();
private JMenuBar menuBar = null;
private JToolBar toolBar = null;
private JSplitPane splitPane = null;
private JScrollPane scrollPane = null;
private JPanel panel = null;
private JTabbedPane tabbedPane = new javax.swing.JTabbedPane();
private JButton stuff_in = null;//原料进入
private JButton product_in = null;//产品进入
private JButton stuff_quit = null;//原料退料
private JButton stuff_stock = null;//原料库存
private JButton product_stock = null;//产品库存
private JButton yield_draw = null;//生产领料
//private JButton yield_consume = null;//生产发料
private JButton yield_off = null;//生产退料
private JButton yield_scrap = null;//生产废料
//private JButton old_record = null;//仓库记录
private JButton product_out = null;//产品输出
private JButton product_return = null;//产品返修
private JButton product_cancle = null;//产品退货
private JButton handle_record = null;//操作记录
private JButton flotsam_record = null;//废料记录
private JButton product_out_record = null;//出货记录
private JButton stuff_old_record = null;//原料记录
private JButton product_old_record = null;//成品记录
private JButton help = null;//帮助
private JButton about = null;//关于
private JButton exit_system = null;//退出系统
private String sql = null;
public My_MainFrame() {
// TODO 自动生成构造函数存根
}
public My_MainFrame(String name){
try{
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
}catch(Exception exe){System.err.print(exe.getMessage());}
java.awt.Toolkit tool = frame.getToolkit();
Image image = tool.getImage("res/logo.jpg");
java.awt.Dimension dimn = tool.getScreenSize();
String title = "仓库管理系统--"+name;
frame.setTitle(title);
frame.setIconImage(image);
frame.setFocusable(true);
frame.setLayout(new java.awt.BorderLayout());
frame.setJMenuBar(createJMenuBar());
frame.add(createJToolBar(),"North");
frame.add(createSplitPane(),"Center");
//frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
frame.addWindowListener(new WindowListener(){
public void windowActivated(WindowEvent e){}
//因对窗口调用dispose()而将其关闭时调用
public void windowClosed(WindowEvent e){}
//用户试图从窗口的系统菜单中关闭窗口时调用
public void windowClosing(WindowEvent e){
String name = frame.getTitle().trim().substring(8);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date(System.currentTimeMillis());
String day = sdf.format(date);
String s ="'"+day+"','"+name+"','"+"退出"+"'";
String sql = "insert into handle_record values("+s+")";
USeDB.UpdateDB(sql);
frame.dispose();
System.exit(0);
}
//当窗口不再是活动窗口时调用
public void windowDeactivated(WindowEvent e){}
//窗口从最小化状态变为正常状态时调用
public void windowDeiconified(WindowEvent e){}
//窗口从正常状态变为最小状态时调用
public void windowIconified(WindowEvent e){}
//窗口首次变为可见时调用
public void windowOpened(WindowEvent e){}
});
//frame.setSize(dimn);
frame.setPreferredSize(dimn);
frame.setBackground(java.awt.Color.pink);
frame.pack();
frame.validate();
frame.setVisible(true);
}
private JMenu createSystem_Manage_Menu(){
javax.swing.JMenu systemMenu = new javax.swing.JMenu("系统管理");
javax.swing.JMenuItem logoin = new javax.swing.JMenuItem("注 册");
logoin.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
new AddUser();
}
});
javax.swing.JMenuItem logoout = new javax.swing.JMenuItem("删除用户");
logoout.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
String jp = new JOptionPane().showInputDialog(frame,"请输入要删除的用户名!","输入用户名",JOptionPane.YES_NO_CANCEL_OPTION).trim();
if(USeDB.delUser(jp)){
JOptionPane.showConfirmDialog(null, "用户删除成功!");
}
JOptionPane.showConfirmDialog(null, "用户删除失败!");
}
});
javax.swing.JMenuItem datatidy = new javax.swing.JMenuItem("数据整理");
logoin.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
}
});
systemMenu.add(logoin);
systemMenu.add(logoout);
systemMenu.add(datatidy);
return systemMenu;
}
private JMenu createStuff_Manage_Menu()
{
javax.swing.JMenu stuffMenu = new javax.swing.JMenu("原料管理");
javax.swing.JMenuItem stuff_in = new javax.swing.JMenuItem("原料进入");
stuff_in.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e1){
AddStuffIn("原料进入");
}
});
javax.swing.JMenuItem stuff_quit = new javax.swing.JMenuItem("原料退还");
stuff_quit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e2){
AddStuffQuit("原料退还");
}
});
javax.swing.JMenuItem stuff_stock = new javax.swing.JMenuItem("原料库存");
stuff_stock.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e3){
String tit[] = {"原料编号","原料名","生产商","收货员","检验员","单位","数量","规格","颜色","存放处","时间","备注"};
String sql = "select * from stuff_in";
AddTable("原料库存",tit,sql);
}
});
javax.swing.JMenuItem yield_draw = new javax.swing.JMenuItem("生产开单");
yield_draw.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e4){
AddYieldDraw("生产开单");
}
});
javax.swing.JMenuItem yield_off = new javax.swing.JMenuItem("生产退料");
yield_off.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e4){
AddStuffIn("生产退料");
}
});
javax.swing.JMenuItem yield_scrap = new javax.swing.JMenuItem("生产废料");
yield_scrap.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e5){
AddYieldScrap("生产废料");
}
});
stuffMenu.add(stuff_in);
stuffMenu.add(stuff_quit);
stuffMenu.addSeparator();
stuffMenu.add(stuff_stock);
stuffMenu.add(yield_draw);
stuffMenu.addSeparator();
stuffMenu.add(yield_off);
stuffMenu.add(yield_scrap);
return stuffMenu;
}
private JMenu createProduct_Manage_Menu(){
javax.swing.JMenu productMenu = new javax.swing.JMenu("成品管理");
javax.swing.JMenuItem product_in = new javax.swing.JMenuItem("成品进入");
product_in.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e6){
AddProductIn("成品进入");
}
});
javax.swing.JMenuItem product_stock = new javax.swing.JMenuItem("成品库存");
product_stock.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e7){
String tit[] ={"成品编号","成品名","客户","成品规格","单位","数量","生产单位","入库时间","备注"};
/*Vector ve = new Vector();
ve.add("成品编号");
ve.add("成品名");
ve.add("客户");
ve.add("成品规格");
ve.add("单位");
ve.add("数量");
ve.add("生产单位");
ve.add("入库时间");
ve.add("备注");*/
String sql = "select * from product_in";
AddTable("成品库存",tit,sql);
}
});
javax.swing.JMenuItem product_out = new javax.swing.JMenuItem("成品发货");
product_out.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e6){
AddProductOut("成品发货");
}
});
javax.swing.JMenuItem product_return = new javax.swing.JMenuItem("成品返修");
product_return.addActionListener(new ActionListener(){
public void actionPerformed(Actio