www.pudn.com > TestToolsProject.rar > CustomDeviceRecordReport.java, change:2014-11-22,size:39561b


package com.mervyn.testtools; 
 
import hysun.util.DateChooser; 
 
import java.awt.BorderLayout; 
import java.awt.Toolkit; 
 
import javax.swing.JPanel; 
import javax.swing.JFrame; 
import java.awt.Dimension; 
import javax.swing.JLabel; 
import java.awt.Rectangle; 
import java.awt.event.ItemEvent; 
import java.awt.event.KeyAdapter; 
import java.awt.event.KeyEvent; 
import java.io.UnsupportedEncodingException; 
import java.sql.Connection; 
import java.sql.DriverManager; 
import java.sql.ResultSet; 
import java.sql.ResultSetMetaData; 
import java.sql.SQLException; 
import java.sql.Statement; 
import java.text.SimpleDateFormat; 
import java.util.Vector; 
 
import javax.swing.JOptionPane; 
import javax.swing.JTable; 
import javax.swing.JTextField; 
import javax.swing.JButton; 
import javax.swing.JComboBox; 
import javax.swing.SwingConstants; 
import javax.swing.JTabbedPane; 
import javax.swing.JScrollPane; 
import javax.swing.table.AbstractTableModel; 
import javax.swing.table.DefaultTableCellRenderer; 
 
public class CustomDeviceRecordReport extends JFrame { 
 
	private static final long serialVersionUID = 1L; 
 
	private JPanel jContentPane = null; 
 
	private JLabel jLabel = null; 
 
	private JTextField jTextField = null; 
 
	private JButton jButton = null; 
 
	private JButton jButton1 = null; 
 
	private JLabel jLabel1 = null; 
 
	private JComboBox jComboBox = null; 
 
	private JLabel jLabel2 = null; 
 
	private JTextField jTextField1 = null; 
 
	private JLabel jLabel3 = null; 
 
	private JTextField jTextField2 = null; 
 
	private JLabel jLabel4 = null; 
 
	private JComboBox jComboBox1 = null; 
 
	private JLabel jLabel5 = null; 
 
	private JComboBox jComboBox2 = null; 
 
	private JLabel jLabel6 = null; 
 
	private JTextField jTextField3 = null; 
 
	private JLabel jLabel7 = null; 
 
	private JButton jButton2 = null; 
 
	private JButton jButton4 = null; 
 
	private JButton jButton5 = null; 
 
	private JScrollPane jScrollPane = null; 
 
	private JLabel jLabel8 = null; 
 
	private JTextField jTextField4 = null; 
 
	private JButton jButton6 = null; 
 
	private JButton jButton7 = null; 
 
	private JLabel jLabel9 = null; 
 
	private JTextField jTextField5 = null; 
 
	private static final SimpleDateFormat FORMATTER = new SimpleDateFormat( 
			"yyyy-MM-dd"); 
	 
 
	Vector<Vector> vector; // @jve:decl-index=0: 
 
	AbstractTableModel tm; 
 
	void initTable(final String[] title) { 
		final JTable table; 
		vector = new Vector<Vector>(); 
		tm = new AbstractTableModel() {// 实现表格抽象类的接口 
			public int getColumnCount() { 
				return title.length; 
			} 
 
			public int getRowCount() { 
				return vector.size(); 
			} 
 
			public Object getValueAt(int row, int column) { 
				if (!vector.isEmpty()) { 
					return ((Vector) vector.elementAt(row)).elementAt(column); 
				} else { 
					return null; 
				} 
			} 
 
			public void setValueAt(Object value, int row, int column) { 
			} 
 
			public String getColumnName(int column) { 
				return title[column]; 
			} 
 
			public Class getColumnClass(int n) { 
				return getValueAt(0, n).getClass(); 
			} 
 
			public boolean isCellEditable(int row, int column) { 
				return false; 
			} 
		}; 
		table = new JTable(tm); 
		table.setCellSelectionEnabled(false); 
		table.setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); 
		table.setShowHorizontalLines(true); 
		table.setShowVerticalLines(true); 
		DefaultTableCellRenderer r = new DefaultTableCellRenderer(); 
		r.setHorizontalAlignment(JLabel.CENTER); 
		table.setDefaultRenderer(Object.class, r); 
		jScrollPane.setViewportView(table); 
		table.addMouseListener(new java.awt.event.MouseAdapter() { 
			public void mouseClicked(java.awt.event.MouseEvent e) { 
				jTextField.setText(tm.getValueAt(table.getSelectedRow(), 0).toString()); 
			} 
		}); 
 
	} 
	/** 
	 * This is the default constructor 
	 */ 
	public CustomDeviceRecordReport() { 
		super(); 
		initialize(); 
	} 
 
	/** 
	 * This method initializes this 
	 *  
	 * @return void 
	 */ 
	private void initialize() { 
		this.setSize(749, 459); 
		this.setContentPane(getJContentPane()); 
		this.setTitle("客户收发货报表"); 
		String[] title = {"状态","时间","F460C300","F660","T103H","F803G-8"}; 
		initTable(title); 
		int windowWidth = this.getWidth(); // 获得窗口宽 
		int windowHeight = this.getHeight(); // 获得窗口高 
		Toolkit kit = Toolkit.getDefaultToolkit(); // 定义工具包 
		Dimension screenSize = kit.getScreenSize(); // 获取屏幕的尺寸 
		int screenWidth = screenSize.width; // 获取屏幕的宽 
		int screenHeight = screenSize.height; // 获取屏幕的高 
		this.setLocation(screenWidth / 2 - windowWidth / 2, screenHeight / 2 
				- windowHeight / 2);// 设置窗口居中显示 
	} 
 
	/** 
	 * This method initializes jContentPane 
	 *  
	 * @return javax.swing.JPanel 
	 */ 
	private JPanel getJContentPane() { 
		if (jContentPane == null) { 
			jLabel9 = new JLabel(); 
			jLabel9.setBounds(new Rectangle(149, 105, 44, 23)); 
			jLabel9.setText("备注:"); 
			jLabel8 = new JLabel(); 
			jLabel8.setBounds(new Rectangle(142, 72, 43, 24)); 
			jLabel8.setText("日期:"); 
			jLabel7 = new JLabel(); 
			jLabel7.setBounds(new Rectangle(120, 104, 22, 24)); 
			jLabel7.setHorizontalAlignment(SwingConstants.CENTER); 
			jLabel7.setHorizontalTextPosition(SwingConstants.CENTER); 
			jLabel7.setText("台"); 
			jLabel6 = new JLabel(); 
			jLabel6.setBounds(new Rectangle(6, 104, 48, 24)); 
			jLabel6.setText("数  量:"); 
			jLabel5 = new JLabel(); 
			jLabel5.setBounds(new Rectangle(353, 72, 56, 24)); 
			jLabel5.setHorizontalAlignment(SwingConstants.CENTER); 
			jLabel5.setHorizontalTextPosition(SwingConstants.CENTER); 
			jLabel5.setText("型   号:"); 
			jLabel4 = new JLabel(); 
			jLabel4.setBounds(new Rectangle(5, 72, 53, 24)); 
			jLabel4.setText("状   态:"); 
			jLabel3 = new JLabel(); 
			jLabel3.setBounds(new Rectangle(376, 42, 44, 24)); 
			jLabel3.setText("地址:"); 
			jLabel2 = new JLabel(); 
			jLabel2.setBounds(new Rectangle(202, 42, 69, 24)); 
			jLabel2.setHorizontalAlignment(SwingConstants.CENTER); 
			jLabel2.setHorizontalTextPosition(SwingConstants.CENTER); 
			jLabel2.setText("联系电话:"); 
			jLabel1 = new JLabel(); 
			jLabel1.setBounds(new Rectangle(5, 42, 73, 24)); 
			jLabel1.setText("用户信息:"); 
			jLabel = new JLabel(); 
			jLabel.setBounds(new Rectangle(5, 11, 73, 24)); 
			jLabel.setHorizontalAlignment(SwingConstants.CENTER); 
			jLabel.setHorizontalTextPosition(SwingConstants.CENTER); 
			jLabel.setText("用户名称:"); 
			jContentPane = new JPanel(); 
			jContentPane.setLayout(null); 
			jContentPane.add(jLabel, null); 
			jContentPane.add(getJTextField(), null); 
			jContentPane.add(getJButton(), null); 
			jContentPane.add(getJButton1(), null); 
			jContentPane.add(jLabel1, null); 
			jContentPane.add(getJComboBox(), null); 
			jContentPane.add(jLabel2, null); 
			jContentPane.add(getJTextField1(), null); 
			jContentPane.add(jLabel3, null); 
			jContentPane.add(getJTextField2(), null); 
			jContentPane.add(jLabel4, null); 
			jContentPane.add(getJComboBox1(), null); 
			jContentPane.add(jLabel5, null); 
			jContentPane.add(getJComboBox2(), null); 
			jContentPane.add(jLabel6, null); 
			jContentPane.add(getJTextField3(), null); 
			jContentPane.add(jLabel7, null); 
			jContentPane.add(getJButton2(), null); 
			jContentPane.add(getJButton4(), null); 
			jContentPane.add(getJButton5(), null); 
			jContentPane.add(getJScrollPane(), null); 
			jContentPane.add(jLabel8, null); 
			jContentPane.add(getJTextField4(), null); 
			jContentPane.add(getJButton6(), null); 
			jContentPane.add(getJButton7(), null); 
			jContentPane.add(jLabel9, null); 
			jContentPane.add(getJTextField5(), null); 
		} 
		return jContentPane; 
	} 
 
	/** 
	 * This method initializes jTextField 
	 *  
	 * @return javax.swing.JTextField 
	 */ 
	private JTextField getJTextField() { 
		if (jTextField == null) { 
			jTextField = new JTextField(); 
			jTextField.setBounds(new Rectangle(82, 11, 161, 24)); 
		} 
		return jTextField; 
	} 
 
	/** 
	 * This method initializes jButton 
	 *  
	 * @return javax.swing.JButton 
	 */ 
	private JButton getJButton() { 
		if (jButton == null) { 
			jButton = new JButton(); 
			jButton.setBounds(new Rectangle(247, 11, 86, 24)); 
			jButton.setText("查询"); 
			jButton.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) { 
					jComboBox.removeAllItems(); 
					jComboBox2.removeAllItems(); 
					Vector<String> items = new Vector<String>(); 
					boolean value = false; 
					ResultSet rs; 
					String SelectStr = "select * from UserInformation where User like '%" 
							+ jTextField.getText() + "%'"; 
					try { 
						rs = SelectSub(SelectStr); 
						while (rs.next()) { 
							items.add(rs.getString(1)); // 获得数据库第一列 
							value = true; 
						} 
						int UserInforCount = items.size(); 
						for (int UserNo = 0; UserNo < UserInforCount; UserNo++) { 
							jComboBox.addItem(items.get(UserNo)); 
						} 
 
						if (value == false) { 
							JOptionPane.showMessageDialog(null, "查询不到用户信息", 
									"异常信息", JOptionPane.INFORMATION_MESSAGE); 
						} 
						rs.close(); 
					} catch (SQLException e7) { 
						// TODO 自动生成 catch 块 
						e7.printStackTrace(); 
						JOptionPane.showMessageDialog(null, e.toString(), 
								"异常信息", JOptionPane.INFORMATION_MESSAGE); 
					} 
				} 
			}); 
		} 
		return jButton; 
	} 
 
	/** 
	 * This method initializes jButton1 
	 *  
	 * @return javax.swing.JButton 
	 */ 
	private JButton getJButton1() { 
		if (jButton1 == null) { 
			jButton1 = new JButton(); 
			jButton1.setBounds(new Rectangle(333, 11, 86, 24)); 
			jButton1.setText("添加用户"); 
			jButton1.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) { 
					RegeidtUserInformation RegeditUser = new RegeidtUserInformation(); 
					RegeditUser.setVisible(true); 
				} 
			}); 
		} 
		return jButton1; 
	} 
 
	/** 
	 * This method initializes jComboBox 
	 *  
	 * @return javax.swing.JComboBox 
	 */ 
	private JComboBox getJComboBox() { 
		if (jComboBox == null) { 
			jComboBox = new JComboBox(); 
			jComboBox.setBounds(new Rectangle(82, 42, 116, 24)); 
			jComboBox.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) { 
					jComboBox2.removeAllItems(); 
					String DeviceMenu=""; 
					Vector<String> heads = new Vector<String>(); 
					ResultSet rs,rsGetColumnName,rsSelect=null; 
					boolean ResultisNoEmpty = false; 
					String SelectStr = "select * from UserInformation where User like '" 
							+ jComboBox.getSelectedItem() + "'"; 
					String SelectDeviceTypt = "select DeviceType from UserInformation where User='" 
							+ jComboBox.getSelectedItem() + "'"; 
					rs = SelectSub(SelectStr); 
					try { 
						while (rs.next()) { 
							jTextField1.setText(rs.getString(2)); 
							jTextField2.setText(rs.getString(3)); 
						} 
						rsGetColumnName = SelectSub(SelectDeviceTypt); 
						String GetDeviceTypt = ""; 
						while (rsGetColumnName.next()) { 
							GetDeviceTypt = rsGetColumnName.getString(1); 
							ResultisNoEmpty = true; 
						} 
						DeviceMenu="状态,时间,备注,"+GetDeviceTypt; 
						if (ResultisNoEmpty == true) { 
							String DeviceType[] = GetDeviceTypt.split(","); 
							int i = DeviceType.length; 
							for (int j = 0; j < i; j++) { 
								jComboBox2.addItem(DeviceType[j]); 
							} 
							String DeviceMenuValue[]=DeviceMenu.split(","); 
							int MenuCount=DeviceMenuValue.length; 
							initTable(DeviceMenuValue); 
							String SelectDeviceInfor="select * from "+jComboBox.getSelectedItem(); 
							rsSelect=SelectSub(SelectDeviceInfor); 
							ShowTable(rsSelect,MenuCount); 
						} 
						//rsSelect.close(); 
						rsGetColumnName.close(); 
					} catch (SQLException e7) { 
						// TODO 自动生成 catch 块 
						e7.printStackTrace(); 
						JOptionPane.showMessageDialog(null, e.toString(), 
								"异常信息", JOptionPane.INFORMATION_MESSAGE); 
					} 
					/* 
					 * String SelectType="select * from 
					 * "+jComboBox.getSelectedItem(); 
					 * rsGetColumnName=SelectSub(SelectType); try { Vector<String> 
					 * heads=new Vector<String>(); ResultSetMetaData 
					 * rsmd=rsGetColumnName.getMetaData(); int 
					 * count=rsmd.getColumnCount(); for(int i=3;i<=count-1;i++){ 
					 * heads.add(rsmd.getColumnName(i)); } 
					 *  
					 * int i=heads.size(); for(int j=0;j<i;j++) { 
					 * jComboBox2.addItem(heads.get(j)); } 
					 *  
					 * rs.close(); rsGetColumnName.close(); } catch 
					 * (SQLException e7) { // TODO 自动生成 catch 块 
					 * e7.printStackTrace(); JOptionPane.showMessageDialog(null, 
					 * e.toString(), "异常信息", JOptionPane.INFORMATION_MESSAGE); } 
					 */ 
				} 
			}); 
		} 
		return jComboBox; 
	} 
  
	private void ShowTable(ResultSet rs, int Count) { 
		try { 
			vector.removeAllElements(); 
			tm.fireTableStructureChanged(); 
			switch (Count) { 
			case 3: 
				while (rs.next()) { 
					String Remarks=""; 
					Remarks=rs.getString(3); 
					if(Remarks==null) 
					{ 
						Remarks=" "; 
					} 
					Vector<String> Result = new Vector<String>(); 
					Result.addElement(rs.getString(1)); 
					Result.addElement(rs.getString(2)); 
					Result.addElement(Remarks); 
					vector.addElement(Result); 
					tm.fireTableStructureChanged(); 
					 
				} 
				rs.close(); 
				break; 
			case 4: 
				while (rs.next()) { 
					String Remarks="",first=""; 
					Remarks=rs.getString(3); 
					first=rs.getString(4); 
					if(Remarks==null) 
					{ 
						Remarks=" "; 
					} 
					if(first==null) 
					{ 
						first=" "; 
					} 
					Vector<String> Result = new Vector<String>(); 
					Result.addElement(rs.getString(1)); 
					Result.addElement(rs.getString(2)); 
					Result.addElement(Remarks); 
					Result.addElement(first); 
					vector.addElement(Result); 
					tm.fireTableStructureChanged(); 
				} 
				rs.close(); 
				break; 
			case 5: 
				while (rs.next()) { 
					String Remarks="",first="",second=""; 
					Remarks=rs.getString(3); 
					first=rs.getString(4); 
					second=rs.getString(5); 
					if(Remarks==null) 
					{ 
						Remarks=" "; 
					} 
					if(first==null) 
					{ 
						first=" "; 
					} 
					if(second==null) 
					{ 
						second=" "; 
					} 
					Vector<String> Result = new Vector<String>(); 
					Result.addElement(rs.getString(1)); 
					Result.addElement(rs.getString(2)); 
					Result.addElement(Remarks); 
					Result.addElement(first); 
					Result.addElement(second); 
					vector.addElement(Result); 
					tm.fireTableStructureChanged(); 
				} 
				rs.close(); 
				break; 
			case 6: 
				while (rs.next()) { 
					String Remarks="",first="",second="",third=""; 
					Remarks=rs.getString(3); 
					first=rs.getString(4); 
					second=rs.getString(5); 
					third=rs.getString(6); 
					if(Remarks==null) 
					{ 
						Remarks=" "; 
					} 
					if(first==null) 
					{ 
						first=" "; 
					} 
					if(second==null) 
					{ 
						second=" "; 
					} 
					if(third==null) 
					{ 
						third=" "; 
					} 
					Vector<String> Result = new Vector<String>(); 
					Result.addElement(rs.getString(1)); 
					Result.addElement(rs.getString(2)); 
					Result.addElement(Remarks); 
					Result.addElement(first); 
					Result.addElement(second); 
					Result.addElement(third); 
					vector.addElement(Result); 
					tm.fireTableStructureChanged(); 
				} 
				rs.close(); 
				break; 
			case 7: 
				while (rs.next()) { 
					String Remarks="",first="",second="",third="",fourth=""; 
					Remarks=rs.getString(3); 
					first=rs.getString(4); 
					second=rs.getString(5); 
					third=rs.getString(6); 
					fourth=rs.getString(7); 
					if(Remarks==null) 
					{ 
						Remarks=" "; 
					} 
					if(first==null) 
					{ 
						first=" "; 
					} 
					if(second==null) 
					{ 
						second=" "; 
					} 
					if(third==null) 
					{ 
						third=" "; 
					} 
					if(fourth==null) 
					{ 
						fourth=" "; 
					} 
					Vector<String> Result = new Vector<String>(); 
					Result.addElement(rs.getString(1)); 
					Result.addElement(rs.getString(2)); 
					Result.addElement(Remarks); 
					Result.addElement(first); 
					Result.addElement(second); 
					Result.addElement(third); 
					Result.addElement(fourth); 
					vector.addElement(Result); 
					tm.fireTableStructureChanged(); 
				} 
				rs.close(); 
				break; 
			case 8: 
				while (rs.next()) { 
					String Remarks="",first="",second="",third="",fourth="",fridy=""; 
					Remarks=rs.getString(3); 
					first=rs.getString(4); 
					second=rs.getString(5); 
					third=rs.getString(6); 
					fourth=rs.getString(7); 
					fridy=rs.getString(8); 
					if(Remarks==null) 
					{ 
						Remarks=" "; 
					} 
					if(first==null) 
					{ 
						first=" "; 
					} 
					if(second==null) 
					{ 
						second=" "; 
					} 
					if(third==null) 
					{ 
						third=" "; 
					} 
					if(fourth==null) 
					{ 
						fourth=" "; 
					} 
					if(fridy==null) 
					{ 
						fridy=" "; 
					} 
					Vector<String> Result = new Vector<String>(); 
					Result.addElement(rs.getString(1)); 
					Result.addElement(rs.getString(2)); 
					Result.addElement(Remarks); 
					Result.addElement(first); 
					Result.addElement(second); 
					Result.addElement(third); 
					Result.addElement(fourth); 
					Result.addElement(fridy); 
					vector.addElement(Result); 
					tm.fireTableStructureChanged(); 
				} 
				rs.close(); 
				break; 
			case 9: 
				while (rs.next()) { 
					String Remarks="",first="",second="",third="",fourth="",fridy="",sixth=""; 
					Remarks=rs.getString(3); 
					first=rs.getString(4); 
					second=rs.getString(5); 
					third=rs.getString(6); 
					fourth=rs.getString(7); 
					fridy=rs.getString(8); 
					sixth=rs.getString(9); 
					if(Remarks==null) 
					{ 
						Remarks=" "; 
					} 
					if(first==null) 
					{ 
						first=" "; 
					} 
					if(second==null) 
					{ 
						second=" "; 
					} 
					if(third==null) 
					{ 
						third=" "; 
					} 
					if(fourth==null) 
					{ 
						fourth=" "; 
					} 
					if(fridy==null) 
					{ 
						fridy=" "; 
					} 
					if(sixth==null) 
					{ 
						sixth=" "; 
					} 
					 
					Vector<String> Result = new Vector<String>(); 
					Result.addElement(rs.getString(1)); 
					Result.addElement(rs.getString(2)); 
					Result.addElement(Remarks); 
					Result.addElement(first); 
					Result.addElement(second); 
					Result.addElement(third); 
					Result.addElement(fourth); 
					Result.addElement(fridy); 
					Result.addElement(sixth); 
					vector.addElement(Result); 
					tm.fireTableStructureChanged(); 
				} 
				rs.close(); 
				break; 
			case 10: 
				while (rs.next()) { 
					String Remarks="",first="",second="",third="",fourth="",fridy="",sixth="",seven=""; 
					Remarks=rs.getString(3); 
					first=rs.getString(4); 
					second=rs.getString(5); 
					third=rs.getString(6); 
					fourth=rs.getString(7); 
					fridy=rs.getString(8); 
					sixth=rs.getString(9); 
					seven=rs.getString(10); 
					if(Remarks==null) 
					{ 
						Remarks=" "; 
					} 
					if(first==null) 
					{ 
						first=" "; 
					} 
					if(second==null) 
					{ 
						second=" "; 
					} 
					if(third==null) 
					{ 
						third=" "; 
					} 
					if(fourth==null) 
					{ 
						fourth=" "; 
					} 
					if(fridy==null) 
					{ 
						fridy=" "; 
					} 
					if(sixth==null) 
					{ 
						sixth=" "; 
					} 
					if(seven==null) 
					{ 
						seven=" "; 
					} 
					Vector<String> Result = new Vector<String>(); 
					Result.addElement(rs.getString(1)); 
					Result.addElement(rs.getString(2)); 
					Result.addElement(Remarks); 
					Result.addElement(first); 
					Result.addElement(second); 
					Result.addElement(third); 
					Result.addElement(fourth); 
					Result.addElement(fridy); 
					Result.addElement(sixth); 
					Result.addElement(seven); 
					vector.addElement(Result); 
					tm.fireTableStructureChanged(); 
				} 
				rs.close(); 
				break; 
			default: { 
 
			} 
 
			} 
			 
 
		} catch (SQLException e) { 
			// TODO 自动生成 catch 块 
			e.printStackTrace(); 
		} 
 
	} 
	private ResultSet SelectSub(String SelectStr) { 
		Connection conSelect; 
		Statement sqlSelect; // 声明Statement对象 
		ResultSet rsSubSelect = null; 
		try { 
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
			String url = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=E:/VSTBackup/VSTDatabaseLocal.mdb"; 
			conSelect = DriverManager.getConnection(url); 
			sqlSelect = conSelect.createStatement(); 
			rsSubSelect = sqlSelect.executeQuery(SelectStr); 
 
		} catch (ClassNotFoundException e6) { 
			// TODO 自动生成 catch 块 
			e6.printStackTrace(); 
			JOptionPane.showMessageDialog(null, e6.toString(), "异常信息", 
					JOptionPane.INFORMATION_MESSAGE); 
		} catch (SQLException e7) { 
			// TODO 自动生成 catch 块 
			e7.printStackTrace(); 
			JOptionPane.showMessageDialog(null, e7.toString(), "异常信息", 
					JOptionPane.INFORMATION_MESSAGE); 
		} 
		return rsSubSelect; 
	} 
 
	private int ExcuteSub(String ExcuteStr) { 
		int ReturnDeleteValue = 0; 
		Connection conExcute; 
		Statement sqlExcute; // 声明Statement对象 
		try { 
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
			String url = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=E:/VSTBackup/VSTDatabaseLocal.mdb"; 
			conExcute = DriverManager.getConnection(url); 
			sqlExcute = conExcute.createStatement(); 
			ReturnDeleteValue = sqlExcute.executeUpdate(ExcuteStr); 
			sqlExcute.close(); 
			conExcute.close(); 
		} catch (ClassNotFoundException e6) { 
			// TODO 自动生成 catch 块 
			e6.printStackTrace(); 
			JOptionPane.showMessageDialog(null, e6.toString(), "异常信息", 
					JOptionPane.INFORMATION_MESSAGE); 
		} catch (SQLException e7) { 
			// TODO 自动生成 catch 块 
			e7.printStackTrace(); 
			JOptionPane.showMessageDialog(null, e7.toString(), "异常信息", 
					JOptionPane.INFORMATION_MESSAGE); 
		} 
 
		return ReturnDeleteValue; 
	} 
 
	/** 
	 * This method initializes jTextField1 
	 *  
	 * @return javax.swing.JTextField 
	 */ 
	private JTextField getJTextField1() { 
		if (jTextField1 == null) { 
			jTextField1 = new JTextField(); 
			jTextField1.setBounds(new Rectangle(275, 42, 96, 24)); 
			jTextField1.setEditable(false); 
		} 
		return jTextField1; 
	} 
 
	/** 
	 * This method initializes jTextField2 
	 *  
	 * @return javax.swing.JTextField 
	 */ 
	private JTextField getJTextField2() { 
		if (jTextField2 == null) { 
			jTextField2 = new JTextField(); 
			jTextField2.setBounds(new Rectangle(424, 42, 275, 24)); 
			jTextField2.setEditable(false); 
		} 
		return jTextField2; 
	} 
 
	/** 
	 * This method initializes jComboBox1 
	 *  
	 * @return javax.swing.JComboBox 
	 */ 
	private JComboBox getJComboBox1() { 
		if (jComboBox1 == null) { 
			jComboBox1 = new JComboBox(); 
			jComboBox1.setBounds(new Rectangle(61, 72, 78, 24)); 
			jComboBox1.addItem("收货"); 
			jComboBox1.addItem("发货"); 
			jComboBox1.addItemListener(new java.awt.event.ItemListener() { 
				public void itemStateChanged(java.awt.event.ItemEvent e) { 
					if (e.getStateChange() == ItemEvent.SELECTED) { 
						jButton2.setText(jComboBox1.getSelectedItem() 
								.toString()); 
					} 
				} 
			}); 
 
		} 
		return jComboBox1; 
	} 
 
	/** 
	 * This method initializes jComboBox2 
	 *  
	 * @return javax.swing.JComboBox 
	 */ 
	private JComboBox getJComboBox2() { 
		if (jComboBox2 == null) { 
			jComboBox2 = new JComboBox(); 
			jComboBox2.setBounds(new Rectangle(411, 72, 85, 24)); 
		} 
		return jComboBox2; 
	} 
 
	/** 
	 * This method initializes jTextField3 
	 *  
	 * @return javax.swing.JTextField 
	 */ 
	private JTextField getJTextField3() { 
		if (jTextField3 == null) { 
			jTextField3 = new JTextField(); 
			jTextField3.setBounds(new Rectangle(59, 104, 64, 24)); 
			jTextField3.setHorizontalAlignment(JTextField.CENTER); 
			jTextField3.addKeyListener(new KeyAdapter() { 
				public void keyTyped(KeyEvent e) { 
					int keyChar = e.getKeyChar(); 
					if (keyChar >= KeyEvent.VK_0 && keyChar <= KeyEvent.VK_9) { 
 
					} else { 
						e.consume(); // 关键,屏蔽掉非法输入 
						/* 
						 * JOptionPane.showMessageDialog(null, 
						 * "只能输入0-9等数字字符,其它输入无效!!", "提示信息", 
						 * JOptionPane.INFORMATION_MESSAGE); 
						 */ 
					} 
				} 
			}); 
			jTextField3 
					.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() { 
						public void mouseMoved(java.awt.event.MouseEvent e) { 
							jTextField3.setToolTipText("只能输入0-9等数字字符,其它输入无效!!"); 
						} 
					}); 
		} 
		return jTextField3; 
	} 
 
	/** 
	 * This method initializes jButton2 
	 *  
	 * @return javax.swing.JButton 
	 */ 
	private JButton getJButton2() { 
		if (jButton2 == null) { 
			jButton2 = new JButton(); 
			jButton2.setBounds(new Rectangle(446, 105, 85, 22)); 
			jButton2.setText("收货"); 
			jButton2.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) { 
					if (!jTextField4.getText().equals("")) { 
						if (!jComboBox2.getSelectedItem().equals("")) { 
							if (!jTextField3.getText().equals("")) {//454545455 
								ExcuteStorgeSub(); 
							} else { 
								JOptionPane.showMessageDialog(null, 
										"为确保数据安全,收发货数量不能为空!!!", "异常信息", 
										JOptionPane.ERROR_MESSAGE); 
							} 
						} else { 
							JOptionPane.showMessageDialog(null, 
									"为确保数据安全,收发货设备型号不能为空!!!", "异常信息", 
									JOptionPane.ERROR_MESSAGE); 
						} 
					} else { 
						JOptionPane.showMessageDialog(null, 
								"为确保数据安全,收发货时间时间不能为空!!!", "异常信息", 
								JOptionPane.ERROR_MESSAGE); 
						jTextField4.setText(getdate()); 
					} 
 
				} 
			}); 
		} 
		return jButton2; 
	} 
	private int StorgeCount() 
	{ 
		String SelectStorge=""; 
		return 0; 
	} 
 
	private void ExcuteStorgeSubBack() { 
		String SelectExcuteStatus = "select * from " 
				+ jComboBox.getSelectedItem() + " where 状态='" 
				+ jComboBox1.getSelectedItem() + "' and 时间='" 
				+ jTextField4.getText() + "'"; 
		ResultSet rsStatus = null; 
		boolean StatusVlaue = false; 
		int DeviceCount = 0; 
		if (jComboBox1.getSelectedItem().equals("发货")) { 
			DeviceCount = -Integer.parseInt(jTextField3.getText()); 
		} else { 
			DeviceCount = Integer.parseInt(jTextField3.getText()); 
		} 
		rsStatus = SelectSub(SelectExcuteStatus); 
		try { 
			while (rsStatus.next()) { 
				StatusVlaue = true; 
			} 
			if (StatusVlaue == true) { 
				int ExcuteStatusValue = 0; 
				String UpdateIntoStr = "update " + jComboBox.getSelectedItem() 
						+ " set " + jComboBox2.getSelectedItem() + "=" 
						+ DeviceCount + " where 状态='" 
						+ jComboBox1.getSelectedItem() + "' and 时间='" 
						+ jTextField4.getText() + "'"; 
				if (jButton2.getText().equals("发货")) { 
					int DeviceCountValue = 0; 
					String SumCountStr = "select sum(" 
							+ jComboBox2.getSelectedItem() + ") from " 
							+ jComboBox.getSelectedItem(); 
					ResultSet rsSum = null; 
					rsSum = SelectSub(SumCountStr); 
					while (rsSum.next()) { 
						DeviceCountValue = rsSum.getInt(1); 
					} 
					System.out.println("当前库存:" + DeviceCountValue); 
					ExcuteStatusValue = ExcuteSub(UpdateIntoStr); 
				} else { 
					ExcuteStatusValue = ExcuteSub(UpdateIntoStr); 
				} 
				if (ExcuteStatusValue == 1) { 
					JOptionPane.showMessageDialog(null, "您的操作已完成!", "提示信息", 
							JOptionPane.INFORMATION_MESSAGE); 
				} else { 
					JOptionPane.showMessageDialog(null, "操作失败,请检查输入的内容是否正确!!", 
							"错误信息", JOptionPane.ERROR_MESSAGE); 
				} 
			} else { 
				int ExcuteStatusValue = 0; 
				String InsertIntoStr = "insert into " 
						+ jComboBox.getSelectedItem() + "(状态,时间," 
						+ jComboBox2.getSelectedItem() + ")" + " values('" 
						+ jComboBox1.getSelectedItem() + "','" 
						+ jTextField4.getText() + "'," + DeviceCount + ")"; 
				if (jButton2.getText().equals("发货")) { 
					int DeviceCountValue = 0; 
					String SumCountStr = "select sum(" 
							+ jComboBox2.getSelectedItem() + ") from " 
							+ jComboBox.getSelectedItem(); 
					ResultSet rsSum = null; 
					rsSum = SelectSub(SumCountStr); 
					while (rsSum.next()) { 
						DeviceCountValue = rsSum.getInt(1); 
					} 
					System.out.println("当前库存:" + DeviceCountValue); 
					ExcuteStatusValue = ExcuteSub(InsertIntoStr); 
				} else { 
					ExcuteStatusValue = ExcuteSub(InsertIntoStr); 
				} 
 
				if (ExcuteStatusValue == 1) { 
					JOptionPane.showMessageDialog(null, "您的操作已完成!", "提示信息", 
							JOptionPane.INFORMATION_MESSAGE); 
				} else { 
					JOptionPane.showMessageDialog(null, "操作失败,请检查输入的内容是否正确!!", 
							"错误信息", JOptionPane.ERROR_MESSAGE); 
				} 
			} 
			rsStatus.close(); 
		} catch (SQLException e1) { 
			// TODO 自动生成 catch 块 
			e1.printStackTrace(); 
		} 
	} 
	 
	 
	private void ExcuteStorgeSub() { 
		int StorgeValue=0; 
		String SelectExcuteStatus = "select "+jComboBox2.getSelectedItem()+" from " 
				+ jComboBox.getSelectedItem() + " where 状态='" 
				+ jComboBox1.getSelectedItem() + "' and 时间='" 
				+ jTextField4.getText() + "'"; 
		ResultSet rsStatus = null; 
		boolean StatusVlaue = false; 
		rsStatus = SelectSub(SelectExcuteStatus); 
		try  
		{ 
			while (rsStatus.next())  
			{ 
				StatusVlaue = true; 
				StorgeValue=rsStatus.getInt(1); 
			} 
			 
			if (StatusVlaue == true)  
			{ 
				int ExcuteStatusValue = 0; 
				int DeviceCount = 0; 
				if (jComboBox1.getSelectedItem().equals("发货"))  
				{ 
					DeviceCount = -Integer.parseInt(jTextField3.getText())+StorgeValue; 
				}  
				else  
				{ 
					DeviceCount = Integer.parseInt(jTextField3.getText())+StorgeValue; 
				} 
				String UpdateIntoStr = "update " + jComboBox.getSelectedItem() 
						+ " set " + jComboBox2.getSelectedItem() + "=" 
						+ DeviceCount + " where 状态='" 
						+ jComboBox1.getSelectedItem() + "' and 时间='" 
						+ jTextField4.getText() + "'"; 
				if (jButton2.getText().equals("发货"))  
				{ 
					int DeviceCountValue = 0; 
					String SumCountStr = "select sum(" 
							+ jComboBox2.getSelectedItem() + ") from " 
							+ jComboBox.getSelectedItem(); 
					ResultSet rsSum = null; 
					rsSum = SelectSub(SumCountStr); 
					while (rsSum.next())  
					{ 
						DeviceCountValue = rsSum.getInt(1); 
					} 
					System.out.println("当前库存:" + DeviceCountValue); 
					int Count=DeviceCountValue+DeviceCount; 
					if(Count>=0) 
					{ 
						ExcuteStatusValue = ExcuteSub(UpdateIntoStr); 
					} 
					else 
					{ 
						Object[] options = {"确定","取消"}; 
						 int response=JOptionPane.showOptionDialog ( null, " 发货数量已经超过欠用户数额,是否继续发货?","警告信息",JOptionPane.YES_OPTION ,JOptionPane.PLAIN_MESSAGE,null, options, options[0] ) ; 
						 if (response == 0) 
						 { 
							 ExcuteStatusValue = ExcuteSub(UpdateIntoStr); 
						 } 
						 else 
						 { 
							  
					     } 
					} 
				}  
				else  
				{ 
					ExcuteStatusValue = ExcuteSub(UpdateIntoStr); 
				} 
				if (ExcuteStatusValue == 1)  
				{ 
					JOptionPane.showMessageDialog(null, "您的操作已完成!", "提示信息", 
							JOptionPane.INFORMATION_MESSAGE); 
				}  
				else  
				{ 
					JOptionPane.showMessageDialog(null, "操作失败,请检查输入的内容是否正确!!", 
							"错误信息", JOptionPane.ERROR_MESSAGE); 
				} 
			}  
			else  
			{ 
				int ExcuteStatusValue = 0; 
				int DeviceCount = 0; 
				if (jComboBox1.getSelectedItem().equals("发货"))  
				{ 
					DeviceCount = -Integer.parseInt(jTextField3.getText()); 
				}  
				else  
				{ 
					DeviceCount = Integer.parseInt(jTextField3.getText()); 
				} 
				String InsertIntoStr = "insert into " 
						+ jComboBox.getSelectedItem() + "(状态,时间," 
						+ jComboBox2.getSelectedItem() + ")" + " values('" 
						+ jComboBox1.getSelectedItem() + "','" 
						+ jTextField4.getText() + "'," + DeviceCount + ")"; 
				if (jButton2.getText().equals("发货"))  
				{ 
					int DeviceCountValue = 0; 
					String SumCountStr = "select sum(" 
							+ jComboBox2.getSelectedItem() + ") from " 
							+ jComboBox.getSelectedItem(); 
					ResultSet rsSum = null; 
					rsSum = SelectSub(SumCountStr); 
					while (rsSum.next())  
					{ 
						DeviceCountValue = rsSum.getInt(1); 
					} 
					System.out.println("当前库存:" + DeviceCountValue);//超额发送请求 
					int Count=DeviceCountValue+DeviceCount; 
					if(Count>=0) 
					{ 
						ExcuteStatusValue = ExcuteSub(InsertIntoStr); 
					} 
					else 
					{ 
						Object[] options = {"确定","取消"}; 
						 int response=JOptionPane.showOptionDialog ( null, " 发货数量已经超过欠用户数额,是否继续发货?","警告信息",JOptionPane.YES_OPTION ,JOptionPane.PLAIN_MESSAGE,null, options, options[0] ) ; 
						 if (response == 0) 
						 { 
							 ExcuteStatusValue = ExcuteSub(InsertIntoStr); 
						 } 
						 else if(response == 1) 
						 { 
							  
					     } 
					} 
					 
				}  
				else  
				{ 
					ExcuteStatusValue = ExcuteSub(InsertIntoStr); 
				} 
 
				if (ExcuteStatusValue == 1)  
				{ 
					JOptionPane.showMessageDialog(null, "您的操作已完成!", "提示信息", 
							JOptionPane.INFORMATION_MESSAGE); 
				}  
				else  
				{ 
					JOptionPane.showMessageDialog(null, "操作失败,请检查输入的内容是否正确!!", 
							"错误信息", JOptionPane.ERROR_MESSAGE); 
				} 
			} 
			rsStatus.close(); 
		}  
		catch (SQLException e1)  
		{ 
			// TODO 自动生成 catch 块 
			e1.printStackTrace(); 
		} 
	} 
 
	/** 
	 * This method initializes jButton4 
	 *  
	 * @return javax.swing.JButton 
	 */ 
	private JButton getJButton4() { 
		if (jButton4 == null) { 
			jButton4 = new JButton(); 
			jButton4.setBounds(new Rectangle(531, 105, 85, 22)); 
			jButton4.setText("重置"); 
		} 
		return jButton4; 
	} 
 
	/** 
	 * This method initializes jButton5 
	 *  
	 * @return javax.swing.JButton 
	 */ 
	private JButton getJButton5() { 
		if (jButton5 == null) { 
			jButton5 = new JButton(); 
			jButton5.setBounds(new Rectangle(616, 105, 85, 22)); 
			jButton5.setText("返回"); 
			jButton5.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) { 
					TestToolsPing TestForm = new TestToolsPing(); 
					TestForm.setVisible(true); 
					setVisible(false); 
				} 
			}); 
		} 
		return jButton5; 
	} 
 
	/** 
	 * This method initializes jScrollPane 
	 *  
	 * @return javax.swing.JScrollPane 
	 */ 
	private JScrollPane getJScrollPane() { 
		if (jScrollPane == null) { 
			jScrollPane = new JScrollPane(); 
			jScrollPane.setBounds(new Rectangle(5, 134, 717, 264)); 
		} 
		return jScrollPane; 
	} 
 
	/** 
	 * This method initializes jTextField4 
	 *  
	 * @return javax.swing.JTextField 
	 */ 
	private JTextField getJTextField4() { 
		if (jTextField4 == null) { 
			jTextField4 = new JTextField(); 
			jTextField4.setBounds(new Rectangle(188, 72, 86, 24)); 
			jTextField4.setHorizontalAlignment(JTextField.CENTER); 
		} 
		return jTextField4; 
	} 
 
	/** 
	 * This method initializes jButton6 
	 *  
	 * @return javax.swing.JButton 
	 */ 
	private JButton getJButton6() { 
		if (jButton6 == null) { 
			jButton6 = new JButton(); 
			jButton6.setBounds(new Rectangle(275, 72, 61, 23)); 
			jButton6.setText("日期"); 
			jButton6.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) { 
					jTextField4.setText(getdate()); 
				} 
			}); 
		} 
		return jButton6; 
	} 
 
	public String getdate() { 
		String returnvalue = ""; 
		final DateChooser dc = new DateChooser(this, true); 
		dc.setLocationRelativeTo(jTextField4); 
		dc.setVisible(true); 
		java.util.Calendar cal = dc.getSelectedDate(); 
		if (cal != null) { 
			returnvalue = FORMATTER.format(cal.getTime()); 
		} 
 
		return returnvalue; 
	} 
 
	/** 
	 * This method initializes jButton7 
	 *  
	 * @return javax.swing.JButton 
	 */ 
	private JButton getJButton7() { 
		if (jButton7 == null) { 
			jButton7 = new JButton(); 
			jButton7.setBounds(new Rectangle(501, 72, 92, 24)); 
			jButton7.setText("添加型号"); 
			jButton7.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) { 
					System.out.println(jComboBox.getSelectedItem()); 
					if (!jComboBox.getSelectedItem().equals("")) { 
						String DeviceType = JOptionPane 
								.showInputDialog("Please Input The DeviceType:"); 
						DeviceType = DeviceType.replaceAll("-", "_"); 
						String SelectDeviceTypt = "select DeviceType from UserInformation where User='" 
								+ jComboBox.getSelectedItem() + "'"; 
						if (DeviceType == null) { 
							JOptionPane.showMessageDialog(null, "您已取消操作!", 
									"异常信息", JOptionPane.ERROR_MESSAGE); 
						} else if (DeviceType.equals("")) { 
							JOptionPane.showMessageDialog(null, 
									"您输入了一个空值,系统禁止创建一个空值的设备型号!!", "异常信息", 
									JOptionPane.ERROR_MESSAGE); 
						} else { 
							ResultSet rsGetColumnName = null; 
							rsGetColumnName = SelectSub(SelectDeviceTypt); 
							String GetDeviceTypt = ""; 
							try { 
								while (rsGetColumnName.next()) { 
									GetDeviceTypt = rsGetColumnName 
											.getString(1); 
								} 
							} catch (SQLException e1) { 
								// TODO 自动生成 catch 块 
								e1.printStackTrace(); 
							} 
							if (GetDeviceTypt.equals("")) { 
								GetDeviceTypt = DeviceType; 
							} else { 
								GetDeviceTypt = GetDeviceTypt + "," 
										+ DeviceType; 
							} 
							String ExcuteUserStr = "update UserInformation set DeviceType='" 
									+ GetDeviceTypt 
									+ "' where User='" 
									+ jComboBox.getSelectedItem() + "'"; 
							String ExcuteStr = "alter table " 
									+ jComboBox.getSelectedItem() 
									+ " add column " + DeviceType + " Text(20)"; 
 
							System.out.println(ExcuteStr); 
							int GetExcuteUserResult = ExcuteSub(ExcuteStr); 
							if (GetExcuteUserResult == -1) { 
 
								int GetExcuteResult = ExcuteSub(ExcuteUserStr); 
								if (GetExcuteResult == 1) { 
									System.out.println(ExcuteUserStr); 
									String DeviceTypeD[] = GetDeviceTypt 
											.split(","); 
									int i = DeviceTypeD.length; 
									jComboBox2.removeAllItems(); 
									for (int j = 0; j < i; j++) { 
										jComboBox2.addItem(DeviceTypeD[j]); 
									} 
									JOptionPane.showMessageDialog(null, 
											"添加设备型号成功!!", "操作完成", 
											JOptionPane.INFORMATION_MESSAGE); 
								} else { 
									JOptionPane.showMessageDialog(null, 
											"添加设备型号失败!!", "异常信息", 
											JOptionPane.ERROR_MESSAGE); 
								} 
 
							} else { 
								JOptionPane.showMessageDialog(null, 
										"更新设备型号失败!", "异常信息", 
										JOptionPane.ERROR_MESSAGE); 
							} 
 
						} 
					} else { 
						JOptionPane.showMessageDialog(null, 
								"为系统的安全,请选择需要添加设备型号的用户信息!!", "异常信息", 
								JOptionPane.ERROR_MESSAGE); 
					} 
 
				} 
			}); 
		} 
		return jButton7; 
	} 
 
	/** 
	 * This method initializes jTextField5 
	 *  
	 * @return javax.swing.JTextField 
	 */ 
	private JTextField getJTextField5() { 
		if (jTextField5 == null) { 
			jTextField5 = new JTextField(); 
			jTextField5.setBounds(new Rectangle(195, 104, 162, 24)); 
		} 
		return jTextField5; 
	} 
 
} //  @jve:decl-index=0:visual-constraint="10,10"