package com.mwq.frame;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Calendar;
import java.util.Date;
import java.util.Vector;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.JToggleButton;
import javax.swing.SwingConstants;
import javax.swing.WindowConstants;
import javax.swing.border.TitledBorder;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import javax.swing.table.DefaultTableModel;
import com.mwq.DrinkeryManage;
import com.mwq.dao.Dao;
import com.mwq.frame.personnel.HandoverDialog;
import com.mwq.frame.personnel.ManagerManageDialog;
import com.mwq.frame.personnel.RecordManageDialog;
import com.mwq.frame.personnel.UpdatePasswordDialog;
import com.mwq.frame.stat.DayDialog;
import com.mwq.frame.stat.MonthDialog;
import com.mwq.frame.stat.YearDialog;
import com.mwq.frame.system.DeskNumDialog;
import com.mwq.frame.system.MenuDialog;
import com.mwq.frame.system.SortDialog;
import com.mwq.mwing.MButton;
import com.mwq.mwing.MTable;
import com.mwq.tool.Today;
public class TipWizardFrame extends JFrame {
private JTextField changeTextField;
private JTextField realWagesTextField;
private JTextField expenditureTextField;
private JTextField priceTextField;
private JTextField amountTextField;
private JTextField unitTextField;
private JTextField nameTextField;
private JTextField codeTextField;
private JComboBox numComboBox;
private JLabel timeLabel;
private JLabel menuLabel;
public JLabel operatorLabel;
private PopupMenuListener popupMenuListener;
private JPopupMenu popupMenu;
private ButtonGroup buttonGroup = new ButtonGroup();
private Vector<Vector<Vector<Object>>> itemOfDeskV;
private MTable rightTable;
private DefaultTableModel rightTableModel;
private Vector<String> rightTableColumnV;
private Vector<Vector<Object>> rightTableDataV;
private MTable leftTable;
private DefaultTableModel leftTableModel;
private Vector<String> leftTableColumnV;
private Vector<Vector<Object>> leftTableDataV;
public Vector managerV;
private final Dimension screenSize = Toolkit.getDefaultToolkit()
.getScreenSize();
private final Dao dao = Dao.getInstance();
/**
* Launch the application
*
* @param args
*/
public static void main(String args[]) {
try {
TipWizardFrame frame = new TipWizardFrame(null);
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Create the frame
*/
public TipWizardFrame(Vector managerV) {
super();
setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);// 不执行任何操作
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {// 将在关闭窗体之前被执行
if (rightTable.getRowCount() > 0)// 查看是否有正在消费的餐台
JOptionPane.showMessageDialog(null, "还有未结账的餐台,当前不能退出系统!",
"友情提示", JOptionPane.WARNING_MESSAGE);// 弹出提示
else
System.exit(0);// 退出系统
}
});
setTitle("明日科技");
setBounds(100, 100, 1024, 768);
setExtendedState(TipWizardFrame.MAXIMIZED_BOTH);
this.managerV = managerV;
final JLabel iconLabel = new JLabel();
iconLabel.setPreferredSize(new Dimension(0, 100));
iconLabel.setHorizontalAlignment(SwingConstants.CENTER);
iconLabel.setIcon(new ImageIcon(TipWizardFrame.class
.getResource("/img/main_top.png")));
getContentPane().add(iconLabel, BorderLayout.NORTH);
final JSplitPane splitPane = new JSplitPane();
splitPane.setBorder(new TitledBorder(null, "",
TitledBorder.DEFAULT_JUSTIFICATION,
TitledBorder.DEFAULT_POSITION, null, null));
splitPane.setDividerLocation(754);
getContentPane().add(splitPane, BorderLayout.CENTER);
final JTabbedPane leftTabbedPane = new JTabbedPane();
splitPane.setLeftComponent(leftTabbedPane);
final JScrollPane leftScrollPane = new JScrollPane();
leftTabbedPane.addTab("签单列表", null, leftScrollPane, null);
itemOfDeskV = new Vector<Vector<Vector<Object>>>();
leftTableColumnV = new Vector<String>();
String leftTableColumns[] = { " ", "序 号", "商品编号", "商品名称", "单 位",
"数 量", "单 价", "金 额" };
for (int i = 0; i < leftTableColumns.length; i++) {
leftTableColumnV.add(leftTableColumns[i]);
}
leftTableDataV = new Vector<Vector<Object>>();
leftTableModel = new DefaultTableModel(leftTableDataV, leftTableColumnV);
leftTableModel.addTableModelListener(new TableModelListener() {
public void tableChanged(TableModelEvent e) { // 当添加或移除表格行时被执行
int rowCount = leftTable.getRowCount();// 获得“签单列表”中的行数
int expenditure = 0;// 默认消费 0 元
for (int row = 0; row < rowCount; row++) {// 通过循环统计消费金额
expenditure += Integer.valueOf(leftTable.getValueAt(row, 7)
.toString());// 累加消费金额
}
expenditureTextField.setText(expenditure + "");// 更新“消费金额”文本框
}
});
leftTable = new MTable(leftTableModel);
leftScrollPane.setViewportView(leftTable);
final JTabbedPane rightTabbedPane = new JTabbedPane();
splitPane.setRightComponent(rightTabbedPane);
final JScrollPane rightScrollPane = new JScrollPane();
rightTabbedPane.addTab("开台列表", null, rightScrollPane, null);
rightTableColumnV = new Vector<String>();
rightTableColumnV.add("序 号");
rightTableColumnV.add("台 号");
rightTableColumnV.add("开台时间");
rightTableDataV = new Vector<Vector<Object>>();
rightTableModel = new DefaultTableModel(rightTableDataV,
rightTableColumnV);
rightTable = new MTable(rightTableModel);
rightTable.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
int selectedRow = rightTable.getSelectedRow();// 获得“开台列表”中的选中行
leftTableDataV.removeAllElements(); // 清空“签单列表”中的现有项目
leftTableDataV.addAll(itemOfDeskV.get(selectedRow));// 向“签单列表”添加新选中餐台的消费项目
leftTableModel.setDataVector(leftTableDataV, leftTableColumnV);// 刷新“签单列表”表格模型的数据
leftTable.setRowSelectionInterval(0);// 选中“签单列表”中的第一行
numComboBox.setSelectedItem(rightTable.getValueAt(selectedRow,
1));// 同步选中“台号”选择框中的该台号
}
});
rightScrollPane.setViewportView(rightTable);
final JPanel operatePanel = new JPanel();
operatePanel.setPreferredSize(new Dimension(0, 200));
operatePanel.setLayout(new BorderLayout());
getContentPane().add(operatePanel, BorderLayout.SOUTH);
final JPanel orderDishesPanel = new JPanel();
operatePanel.add(orderDishesPanel, BorderLayout.NORTH);
final JLabel numLabel = new JLabel(); // 创建“台号”�