📄 warehousemanagepanel.java
字号:
package shopingmanager;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import java.awt.Dimension;
import java.awt.Rectangle;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.SwingConstants;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;
import java.util.Vector;
import java.sql.ResultSet;
import javax.swing.JOptionPane;
import java.awt.event.FocusEvent;
import java.awt.event.FocusAdapter;
import java.awt.Font;
import java.awt.Color;
import java.awt.SystemColor;
import javax.swing.JComboBox;
import javax.swing.ImageIcon;
import javax.swing.BorderFactory;
public class WarehouseManagePanel extends JPanel {
//创建连接
ConnectSQL cs = new ConnectSQL("SuperMarketMIB");
//创建结果集
ResultSet rs;
// 创建日期时间
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
String date = sdf.format(new java.util.Date());
//创建表模板
AbstractTableModel tm;
AbstractTableModel ttm;
//创建库存明细表
String title[] = {"货物号", "货物名称", "货物类型", "进货单价", "出货单价", "货物数量", "总价", "日期"};
Vector vc;
//创建库存预警表
String title1[] = {"货物号", "货物名称", "货物类型", "进货单价", "出货单价", "货物数量", "总价",
"日期"};
Vector vct;
public WarehouseManagePanel() {
try {
vc = new Vector();
tm = new AbstractTableModel() {
public int getColumnCount() {
return title.length;
}
public int getRowCount() {
return vc.size();
}
public Object getValueAt(int row, int colum) {
if (!vc.isEmpty()) {
return ((Vector) vc.elementAt(row)).elementAt(colum);
} else {
return null;
}
}
public String getColumnName(int column) {
return title[column];
}
public void setValueAt
(Object value, int row, int column) {}
public Class getColumnClass(int c) {
return getValueAt(0, c).getClass();
}
public boolean isCellEditable(int row, int column) {
return false;
}
};
tblWarning = new JTable(tm);
//设置帮助提示
tblWarning.setToolTipText("显示全部查询结果");
//设置表格调整尺寸模式
tblWarning.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
//设置单元格选择方式
tblWarning.setCellSelectionEnabled(false);
//设置是否显示单元格间的分割线
tblWarning.setShowVerticalLines(true);
tblWarning.setShowHorizontalLines(true);
vct = new Vector();
ttm = new AbstractTableModel() {
public int getColumnCount() {
return title1.length;
}
public int getRowCount() {
return vct.size();
}
public Object getValueAt(int row, int colum) {
if (!vct.isEmpty()) {
return ((Vector) vct.elementAt(row)).elementAt(colum);
} else {
return null;
}
}
public String getColumnName(int column) {
return title1[column];
}
public void setValueAt
(Object value, int row, int column) {}
public Class getColumnClass(int c) {
return getValueAt(0, c).getClass();
}
public boolean isCellEditable(int row, int column) {
return false;
}
};
tblParticular = new JTable(ttm);
//设置帮助提示
tblParticular.setToolTipText("显示全部查询结果");
//设置表格调整尺寸模式
tblParticular.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
//设置单元格选择方式
tblParticular.setCellSelectionEnabled(false);
//设置是否显示单元格间的分割线
tblParticular.setShowVerticalLines(true);
tblParticular.setShowHorizontalLines(true);
//获取出货货号
ConnectSQL cs = new ConnectSQL("SuperMarketMIB");
ResultSet rs = null;
String sql = "select * from warehouseinfo";
cmbShipmentId.addItem("请选择货物号");
try {
rs = cs.GetRs(sql);
while (rs.next()) {
this.cmbShipmentId.addItem(rs.getString(1));
}
} catch (Exception ex) {
} finally {
cs.closed();
}
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
private void jbInit() throws Exception {
setLayout(null);
setOpaque(false);
setSize(new Dimension(600, 450));
pnlOrder.setOpaque(false);
pnlOrder.setBounds(new Rectangle(0, 0, 600, 450));
pnlOrder.setLayout(null);
lblStockId.setHorizontalAlignment(SwingConstants.RIGHT);
lblStockId.setText("进货号:");
lblStockId.setBounds(new Rectangle(134, 51, 126, 36));
lblStockName.setHorizontalAlignment(SwingConstants.RIGHT);
lblStockName.setText("进货名称:");
lblStockName.setBounds(new Rectangle(134, 102, 126, 36));
lblStockNo.setHorizontalAlignment(SwingConstants.RIGHT);
lblStockNo.setText("进货数量:");
lblStockNo.setBounds(new Rectangle(134, 204, 126, 36));
txtStockId.setBounds(new Rectangle(278, 51, 141, 36));
txtStockId.addFocusListener(new
WarehouseManagePanel_txtStockId_focusAdapter(this));
txtStockName.setBounds(new Rectangle(278, 102, 141, 36));
txtStockPrice.setBounds(new Rectangle(278, 153, 141, 36));
txtStockNo.setBounds(new Rectangle(278, 204, 141, 36));
lblStockPrice.setHorizontalAlignment(SwingConstants.RIGHT);
lblStockPrice.setText("进货单价:");
lblStockPrice.setBounds(new Rectangle(134, 153, 126, 36));
btnOrderOk.setBounds(new Rectangle(182, 335, 97, 32));
btnOrderOk.setFont(new java.awt.Font("方正姚体", Font.BOLD, 16));
btnOrderOk.setForeground(SystemColor.activeCaption);
btnOrderOk.setBorder(BorderFactory.createRaisedBevelBorder());
btnOrderOk.setContentAreaFilled(false);
btnOrderOk.setText("确定");
btnOrderOk.setToolTipText("进货");
btnOrderOk.addActionListener(new
WarehouseManagePanel_btnOrderOk_actionAdapter(this));
btnOrderReset.setBounds(new Rectangle(301, 335, 97, 32));
btnOrderReset.setFont(new java.awt.Font("方正姚体", Font.BOLD, 16));
btnOrderReset.setForeground(SystemColor.activeCaption);
btnOrderReset.setBorder(BorderFactory.createRaisedBevelBorder());
btnOrderReset.setOpaque(false);
btnOrderReset.setContentAreaFilled(false);
btnOrderReset.setText("重置");
btnOrderReset.setToolTipText("清空文本框");
btnOrderReset.addActionListener(new
WarehouseManagePanel_btnOrderReset_actionAdapter(this));
pnlShipment.setOpaque(false);
pnlShipment.setBounds(new Rectangle(0, 0, 600, 450));
pnlShipment.setLayout(null);
lblOutPrice.setHorizontalAlignment(SwingConstants.RIGHT);
lblOutPrice.setText("出货单价:");
lblOutPrice.setBounds(new Rectangle(134, 153, 126, 36));
lblOutNo.setHorizontalAlignment(SwingConstants.RIGHT);
lblOutNo.setText("出货数量:");
lblOutNo.setBounds(new Rectangle(134, 204, 126, 36));
btnShipmentOk.setBounds(new Rectangle(182, 335, 97, 32));
btnShipmentOk.setFont(new java.awt.Font("方正姚体", Font.BOLD, 16));
btnShipmentOk.setForeground(SystemColor.activeCaption);
btnShipmentOk.setBorder(BorderFactory.createRaisedBevelBorder());
btnShipmentOk.setOpaque(false);
btnShipmentOk.setContentAreaFilled(false);
btnShipmentOk.setText("确定");
btnShipmentOk.setToolTipText("出货");
btnShipmentOk.addActionListener(new
WarehouseManagePanel_btnShipmentOk_actionAdapter(this));
lblOutId.setHorizontalAlignment(SwingConstants.RIGHT);
lblOutId.setText("出货号:");
lblOutId.setBounds(new Rectangle(134, 51, 126, 36));
txtOutName.setBounds(new Rectangle(278, 105, 141, 36));
lblOutName.setHorizontalAlignment(SwingConstants.RIGHT);
lblOutName.setText("出货名称:");
lblOutName.setBounds(new Rectangle(134, 102, 126, 36));
txtOutNo.setBounds(new Rectangle(278, 204, 141, 36));
btnShipmentReset.setBounds(new Rectangle(301, 335, 97, 32));
btnShipmentReset.setFont(new java.awt.Font("方正姚体", Font.BOLD, 16));
btnShipmentReset.setForeground(SystemColor.activeCaption);
btnShipmentReset.setBorder(BorderFactory.createRaisedBevelBorder());
btnShipmentReset.setOpaque(false);
btnShipmentReset.setContentAreaFilled(false);
btnShipmentReset.setText("重置");
btnShipmentReset.setToolTipText("清空文本框");
btnShipmentReset.addActionListener(new
WarehouseManagePanel_btnShipmentReset_actionAdapter(this));
txtOutPrice.setBounds(new Rectangle(278, 153, 141, 36));
pnlWarning.setOpaque(false);
pnlWarning.setBounds(new Rectangle(0, 0, 600, 450));
pnlWarning.setLayout(null);
scpWarning.setForeground(Color.cyan);
scpWarning.setOpaque(false);
scpWarning.setBounds(new Rectangle(82, 78, 462, 253));
btnWarningRefurbish.setBounds(new Rectangle(232, 359, 151, 40));
btnWarningRefurbish.setFont(new java.awt.Font("方正姚体", Font.BOLD, 16));
btnWarningRefurbish.setForeground(SystemColor.activeCaption);
btnWarningRefurbish.setBorder(BorderFactory.createRaisedBevelBorder());
btnWarningRefurbish.setOpaque(false);
btnWarningRefurbish.setContentAreaFilled(false);
btnWarningRefurbish.setText("刷 新");
btnWarningRefurbish.setToolTipText("更新库存不足的货物");
btnWarningRefurbish.addActionListener(new
WarehouseManagePanel_btnWarningRefurbish_actionAdapter(this));
pnlParticular.setOpaque(false);
pnlParticular.setBounds(new Rectangle(0, 0, 600, 450));
pnlParticular.setLayout(null);
btnParticularRefurbish.setBounds(new Rectangle(408, 344, 151, 40));
btnParticularRefurbish.setFont(new java.awt.Font("方正姚体", Font.BOLD, 18));
btnParticularRefurbish.setForeground(SystemColor.activeCaption);
btnParticularRefurbish.setBorder(BorderFactory.createRaisedBevelBorder());
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -