⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 processioncaseselectionjpanel.java

📁 JAVA实现的酒店管理系统
💻 JAVA
字号:
package file1;

/*
 * @Author:
 * Create Time:2008-2-22
 * Description:货品损益情况条件选择面版
 */
import javax.swing.*;
import java.sql.*;
import java.awt.*;
import sun.jdbc.rowset.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

public class ProcessionCaseSelectionJPanel extends JPanel implements
		MouseListener {

	private JLabel goodNotEqualID = new JLabel("货品损益记录编号 :");
	private JComboBox goodNotEqualIDBox = new JComboBox();
	private JButton processionQuery = new JButton("处理情况查询");
	private DBConnection con = null;
	private JPanel panelEcho = new JPanel();
	private JPanel panel1 = new JPanel();
	private JPanel panel2 = new JPanel();

	public ProcessionCaseSelectionJPanel() {
		con = new DBConnection();
		int valueReturned = getGoodNotEqualIDs();
		if (valueReturned == 1) {
			return;
		}
		panelEcho.setLayout(new FlowLayout(FlowLayout.LEADING, 15, 0));
		panelEcho.add(goodNotEqualID);
		panelEcho.add(goodNotEqualIDBox);
		panel1.setLayout(new FlowLayout(FlowLayout.LEADING, 10, 0));
		panel1.add(processionQuery);
		panel2.setLayout(new GridLayout(2, 1, 0, 20));
		panel2.add(panelEcho);
		panel2.add(panel1);
		this.add(panel2);
		processionQuery.setBorder(null);
		processionQuery.setToolTipText("双击进入选定记录的处理情况录入界面!");
		processionQuery.addMouseListener(this);
	}

	private int getGoodNotEqualIDs() {// 从数据库中读取两种查询条件的id,成功返回0,否则返回1
		String sqlStr = "select ID from GoodNotEqual";
		try {
			CachedRowSet crs = con.getResultSet(sqlStr);
			while (crs.next()) {
				goodNotEqualIDBox.addItem(String.valueOf(crs.getInt(1)));
			}
			goodNotEqualIDBox.setSelectedIndex(-1);
		} catch (ClassNotFoundException cnfe) {
			JOptionPane.showMessageDialog(null, "发生ClassNotFound错误!", "",
					JOptionPane.INFORMATION_MESSAGE);
			return 1;
		} catch (SQLException sqle) {
			JOptionPane.showMessageDialog(null, "发生Sql错误!", "",
					JOptionPane.INFORMATION_MESSAGE);
			return 1;
		}
		return 0;
	}

	public void mouseExited(MouseEvent me) {

	}

	public void mouseReleased(MouseEvent me) {

	}

	public void mousePressed(MouseEvent me) {

	}

	public void mouseEntered(MouseEvent me) {

	}

	public void mouseClicked(MouseEvent me) {
		if (me.getSource() == processionQuery) {
			if (me.getClickCount() == 2) {// 双击了"处理情况查询"按钮,弹出处理情况数据录入界面
				int goodNotEqualID = 0;
				try {
					goodNotEqualID = Integer
							.valueOf(((String) goodNotEqualIDBox
									.getSelectedItem()));// 货品损益记录的ID
				} catch (NumberFormatException nfe) {
					JOptionPane.showMessageDialog(null,
							"处理情况所针对的货品损益记录编号不能为空!", "",
							JOptionPane.INFORMATION_MESSAGE);
					return;
				}
				ProcessionRecordDataInJPanel processionRecordDataInJPanel = new ProcessionRecordDataInJPanel();// 实例化客户申诉情况数据录入面版
				JDialog dialog = new JDialog(MainFrame.getMainFrame(), true);
				dialog.setSize(450, 300);
				dialog.setLocation(400, 300);
				dialog.getContentPane().setLayout(new BorderLayout());
				dialog.getContentPane().add(processionRecordDataInJPanel,
						BorderLayout.CENTER);
				dialog.setVisible(true);
				ProcessionRecord processionRecord = processionRecordDataInJPanel
						.getProcessionRecord();
				if (processionRecord.getOperater() != -1
						&& !processionRecord.getOperateTime().trim().equals("")) {
					processionRecord.setGoodNotEqualID(goodNotEqualID);
				} else {
					return;
				}
				ProcessionRecordOperate processionRecordOperate = new ProcessionRecordOperate();
				processionRecordOperate.insertToDB(processionRecord);

			} else if (me.getClickCount() == 1) {// 单击了"解决情况查询"按钮,弹出解决情况数据录入界面
				String item = (String) goodNotEqualIDBox.getSelectedItem();
				if (item == null) {
					JOptionPane.showMessageDialog(null, "货品损益记录编号不能为空!", "",
							JOptionPane.INFORMATION_MESSAGE);
					return;
				}
				int id = Integer.valueOf(item);
				ProcessionRecordJPanel processionRecordJPanel = new ProcessionRecordJPanel(
						id);
				JDialog dialog = new JDialog();
				dialog.setSize(450, 300);
				dialog.setLocation(400, 300);
				dialog.getContentPane().setLayout(new BorderLayout());
				dialog.getContentPane().add(processionRecordJPanel,
						BorderLayout.CENTER);
				dialog.setVisible(true);
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -