www.pudn.com > TestToolsProject.rar > CustomProductReceAndDisSystem.java, change:2014-08-29,size:32270b


package com.mervyn.testtools; 
 
import java.awt.BorderLayout; 
import java.awt.Toolkit; 
 
import javax.swing.JPanel; 
import javax.swing.JFrame; 
import java.awt.Dimension; 
import javax.swing.JButton; 
import java.awt.Rectangle; 
import java.io.File; 
import java.io.IOException; 
import java.io.UnsupportedEncodingException; 
import java.sql.Connection; 
import java.sql.DriverManager; 
import java.sql.ResultSet; 
import java.sql.SQLException; 
import java.sql.Statement; 
import java.text.SimpleDateFormat; 
import java.util.Date; 
import java.util.Vector; 
 
import javax.swing.JFileChooser; 
import javax.swing.JLabel; 
import javax.swing.JComboBox; 
import javax.swing.JCheckBox; 
import javax.swing.JOptionPane; 
import javax.swing.JTextField; 
import javax.swing.JScrollPane; 
import javax.swing.JTable; 
import javax.swing.event.DocumentEvent; 
import javax.swing.event.DocumentListener; 
import javax.swing.table.AbstractTableModel; 
import javax.swing.table.DefaultTableCellRenderer; 
import java.awt.Font; 
import javax.swing.SwingConstants; 
import java.awt.Color; 
 
import jxl.Cell; 
import jxl.Sheet; 
import jxl.Workbook; 
import jxl.format.Alignment; 
import jxl.read.biff.BiffException; 
import jxl.write.Label; 
import jxl.write.NumberFormats; 
import jxl.write.WritableCellFormat; 
import jxl.write.WritableSheet; 
import jxl.write.WritableWorkbook; 
import jxl.write.WriteException; 
import jxl.write.biff.RowsExceededException; 
 
//import com.mervyn.testsource.; 
 
public class CustomProductReceAndDisSystem extends JFrame { 
 
	private static final long serialVersionUID = 1L; 
 
	private JPanel jContentPane = null; 
 
	private JLabel jLabel = null; 
 
	private JComboBox jComboBox = null; 
 
	private JButton jButton = null; 
 
	private JLabel jLabel1 = null; 
 
	private JTextField jTextField = null; 
 
	private JLabel jLabel2 = null; 
 
	private JTextField jTextField1 = null; 
 
	private JLabel jLabel3 = null; 
 
	private JComboBox jComboBox1 = null; 
 
	private JScrollPane jScrollPane = null; 
 
	private JTable jTable = null; 
 
	private JButton jButton1 = null; 
	JFileChooser fc = new JFileChooser("D:/"); 
	private JButton jButton2 = null; 
	String[] title={"设备类型","设备型号","序列号","厂商名称","维修故障","客户名称","送修日期","修复结果"}; 
	Vector vector;  //  @jve:decl-index=0: 
	AbstractTableModel tm; 
 
	private JLabel jLabel6 = null; 
 
	private JButton jButton3 = null; 
 
	private JButton jButton4 = null; 
 
	private JLabel jLabel7 = null; 
 
	private JButton jButton5 = null; 
 
	private JButton jButton6 = null; 
	 
	private static String FiberHomeDatabasePath="";  //  @jve:decl-index=0: 
 
	private JLabel jLabel5 = null; 
 
	private JComboBox jComboBox2 = null; 
 
	public void SetFiberHomeDatbasePath() 
	{ 
		TestToolsPing CreateReportObject=new TestToolsPing(); 
		FiberHomeDatabasePath=CreateReportObject.GetFiberHomeDatabasePath(); 
	} 
	public String GetRemoteDatbasePath() 
	{ 
		SetFiberHomeDatbasePath(); 
		return FiberHomeDatabasePath; 
	} 
	void initTable() 
	{ 
		JTable table; 
		vector=new 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(true); 
		//table.setToolTipText("test tool tip"); 
		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); 
		//scroll=new JScrollPane(table); 
		jScrollPane.setViewportView(table); 
		//contentPane.add(scroll,null); 
		 
	} 
 
	/** 
	 * This is the default constructor 
	 */ 
	public CustomProductReceAndDisSystem() { 
		super(); 
		initialize(); 
		initTable(); 
		SetFiberHomeDatbasePath(); 
	} 
 
	/** 
	 * This method initializes this 
	 *  
	 * @return void 
	 */ 
	private void initialize() { 
		this.setSize(786, 401); 
		this.setContentPane(getJContentPane()); 
		this.setTitle("客户收发货管理系统"); 
		int windowWidth = this.getWidth(); // 获得窗口宽 
		int windowHeight = this.getHeight(); // 获得窗口高 
		Toolkit kit = Toolkit.getDefaultToolkit(); // 定义工具包 
		Dimension screenSize = kit.getScreenSize(); // 获取屏幕的尺寸 
		int screenWidth = screenSize.width; // 获取屏幕的宽 
		int screenHeight = screenSize.height; // 获取屏幕的高 
		System.out.println(screenHeight); 
		this.setLocation(screenWidth / 2 - windowWidth / 2, screenHeight / 2 
				- windowHeight / 2);// 设置窗口居中显示 
		 
		 
	} 
 
	/** 
	 * This method initializes jContentPane 
	 *  
	 * @return javax.swing.JPanel 
	 */ 
	private JPanel getJContentPane() { 
		if (jContentPane == null) { 
			jLabel5 = new JLabel(); 
			jLabel5.setBounds(new Rectangle(437, 41, 72, 24)); 
			jLabel5.setText("修复结果:"); 
			jLabel7 = new JLabel(); 
			jLabel7.setBounds(new Rectangle(621, 336, 139, 21)); 
			jLabel7.setText(""); 
			jLabel7.addMouseListener(new java.awt.event.MouseAdapter() { 
				public void mouseClicked(java.awt.event.MouseEvent e) { 
					try { 
						Runtime.getRuntime().exec("cmd  /c  start  "+jLabel7.getText()); 
						System.out.println("cmd  /c  start  "+jLabel7.getText()); 
					} catch (IOException e1) { 
						// TODO 自动生成 catch 块 
						e1.printStackTrace(); 
					}   
 
				} 
			}); 
			jLabel6 = new JLabel(); 
			jLabel6.setBounds(new Rectangle(188, 5, 421, 35)); 
			jLabel6.setFont(new Font("Dialog", Font.BOLD, 24)); 
			jLabel6.setHorizontalAlignment(SwingConstants.CENTER); 
			jLabel6.setHorizontalTextPosition(SwingConstants.CENTER); 
			jLabel6.setForeground(new Color(0, 204, 0)); 
			jLabel6.setText("请输入需要查询的序列号"); 
			jLabel3 = new JLabel(); 
			jLabel3.setBounds(new Rectangle(634, 41, 40, 25)); 
			jLabel3.setText("厂家:"); 
			jLabel2 = new JLabel(); 
			jLabel2.setBounds(new Rectangle(196, 41, 59, 25)); 
			jLabel2.setText("序列号:"); 
			jLabel1 = new JLabel(); 
			jLabel1.setBounds(new Rectangle(1, 41, 69, 22)); 
			jLabel1.setText("用        户:"); 
			jLabel = new JLabel(); 
			jLabel.setBounds(new Rectangle(3, 9, 67, 23)); 
			jLabel.setText("操作类型:"); 
			jContentPane = new JPanel(); 
			jContentPane.setLayout(null); 
			jContentPane.add(jLabel, null); 
			jContentPane.add(getJComboBox(), null); 
			jContentPane.add(getJButton(), null); 
			jContentPane.add(jLabel1, null); 
			jContentPane.add(getJTextField(), null); 
			jContentPane.add(jLabel2, null); 
			jContentPane.add(getJTextField1(), null); 
			jContentPane.add(jLabel3, null); 
			jContentPane.add(getJComboBox1(), null); 
			jContentPane.add(getJScrollPane(), null); 
			jContentPane.add(getJButton1(), null); 
			jContentPane.add(getJButton2(), null); 
			jContentPane.add(jLabel6, null); 
			jContentPane.add(getJButton3(), null); 
			jContentPane.add(getJButton4(), null); 
			jContentPane.add(jLabel7, null); 
			jContentPane.add(getJButton5(), null); 
			jContentPane.add(getJButton6(), null); 
			jContentPane.add(jLabel5, null); 
			jContentPane.add(getJComboBox2(), null); 
		} 
		return jContentPane; 
	} 
 
	/** 
	 * This method initializes jComboBox	 
	 * 	 
	 * @return javax.swing.JComboBox	 
	 */ 
	private JComboBox getJComboBox() { 
		if (jComboBox == null) { 
			jComboBox = new JComboBox(); 
			jComboBox.setBounds(new Rectangle(74, 8, 87, 25)); 
			jComboBox.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) { 
					if(jComboBox.getSelectedItem().equals("收货")) 
					{ 
						jLabel6.setVisible(false); 
					} 
					if(jComboBox.getSelectedItem().equals("发货")) 
					{ 
						jLabel6.setVisible(true); 
						 
						 
					} 
				} 
			}); 
			jComboBox.addItem("发货"); 
			jComboBox.addItem("收货"); 
			 
		} 
		return jComboBox; 
	} 
 
	/** 
	 * This method initializes jButton	 
	 * 	 
	 * @return javax.swing.JButton	 
	 */ 
	private JButton getJButton() { 
		if (jButton == null) { 
			jButton = new JButton(); 
			jButton.setBounds(new Rectangle(636, 6, 115, 29)); 
			jButton.setText("批量导入"); 
			jButton.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) { 
					 
						try { 
							File f = null; 
							Vector getVector = new Vector(); 
							fc.setMultiSelectionEnabled(false);// 选择模式,可选择文件和文件夹 
							fc.setFileSelectionMode(JFileChooser.FILES_ONLY); 
							fc.setFileHidingEnabled(true); // 设置是否显示隐藏文件 
							fc.setAcceptAllFileFilterUsed(false); 
							fc.removeChoosableFileFilter(fc.getAcceptAllFileFilter());  //移去所有文件过滤器 
						    fc.addChoosableFileFilter(new com.mervyn.testsource.MyFileFilter("xls","Excel文件")); 
							int returnValue = fc.showOpenDialog(null); 
							if (returnValue == JFileChooser.APPROVE_OPTION) { 
								f = fc.getSelectedFile(); 
								System.out.println(f.getName()); 
								ImportExcelInformationSub(f.getPath()); 
							} 
							 
						} catch (NumberFormatException nullstr) { 
							JOptionPane.showMessageDialog(null, "您放弃了数据库批量导入操作!","错误信息",JOptionPane.ERROR_MESSAGE); 
							 
						} 
					 
					 
				} 
			}); 
		} 
		return jButton; 
	} 
	public void ImportExcelInformationSub(String FilePath) 
	{ 
		String ReturnInsertIntoString=""; 
		Connection con; 
		Statement sql; // 声明Statement对象 
		ResultSet rs; 
		try { 
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
			String url = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+FiberHomeDatabasePath; 
			con = DriverManager.getConnection(url); 
			sql = con.createStatement(); 
			Workbook book = Workbook.getWorkbook(new File(FilePath)); 
			Sheet sheet = book.getSheet(0); 
			String NO, DeviceType, DeviceModel, SerialNumber, HarvestTime, Firm, ProductDate, Warranty, Repair, BreakDown, Operator, RepairOperator, Result, RMA_NO, CustomerName,GetBackCustomTime,RepairTime; 
			int row; 
            int insertValues=0; 
            int errorvalues=0; 
            String InserEcxuteStr=""; 
            int sheetCount=sheet.getRows(); 
            for(row=1;row<sheetCount;row++) 
            { 
            	Cell cell0 = sheet.getCell(0, row); 
            	NO = cell0.getContents(); 
            	Cell cell1 = sheet.getCell(1,row); 
            	DeviceType= cell1.getContents(); 
            	Cell cell2 = sheet.getCell(2, row); 
            	DeviceModel= cell2.getContents(); 
            	Cell cell3 = sheet.getCell(3, row); 
            	SerialNumber= cell3.getContents(); 
            	Cell cell4 = sheet.getCell(4, row); 
            	HarvestTime= cell4.getContents(); 
            	Cell cell5 = sheet.getCell(5, row); 
            	Firm= cell5.getContents(); 
            	Cell cell6 = sheet.getCell(6, row); 
            	ProductDate= cell6.getContents(); 
            	Cell cell7 = sheet.getCell(7, row); 
            	Warranty= cell7.getContents(); 
            	Cell cell8 = sheet.getCell(8, row); 
            	Repair= cell8.getContents(); 
            	Cell cell9 = sheet.getCell(9, row); 
            	BreakDown= cell9.getContents(); 
            	Cell cell10 = sheet.getCell(10, row); 
            	Operator= cell10.getContents(); 
            	Cell cell11 = sheet.getCell(11, row); 
            	RepairOperator= cell11.getContents(); 
            	Cell cell12 = sheet.getCell(12, row); 
            	Result= cell12.getContents(); 
            	Cell cell13 = sheet.getCell(13, row); 
            	RMA_NO= cell13.getContents(); 
            	Cell cell14 = sheet.getCell(14, row); 
            	CustomerName= cell14.getContents(); 
            	Cell cell15=sheet.getCell(15, row); 
            	GetBackCustomTime=cell15.getContents(); 
            	Cell cell16=sheet.getCell(16, row); 
            	RepairTime=cell16.getContents(); 
            	InserEcxuteStr="insert into CustomProductReceAndDisReport values('" 
            		+NO 
            		+ "','" 
            		+DeviceType 
            		+ "','" 
            		+DeviceModel 
            		+ "','" 
            		+SerialNumber 
            		+ "','" 
            		+HarvestTime 
            		+ "','" 
            		+Firm 
            		+ "','" 
            		+ProductDate 
            		+ "','" 
            		+Warranty 
            		+ "','" 
            		+Repair 
            		+ "','" 
            		+BreakDown 
            		+ "','" 
            		+Operator 
            		+ "','" 
            		+RepairOperator 
            		+ "','" 
            		+Result 
            		+ "','" 
            		+RMA_NO 
            		+ "','" 
            		+CustomerName 
            		+ "','" 
            		+GetBackCustomTime 
            		+ "','" 
            		+RepairTime 
            		+ "')"; 
            	sql.addBatch(InserEcxuteStr); 
            } 
            sql.executeBatch(); 
			con.commit(); 
			JOptionPane.showMessageDialog(null, "数据导入已完成!","提示信息",JOptionPane.INFORMATION_MESSAGE); 
		} catch (BiffException e) { 
			// TODO 自动生成 catch 块 
			e.printStackTrace(); 
			JOptionPane.showMessageDialog(null, e.toString(), 
					"异常信息", JOptionPane.INFORMATION_MESSAGE); 
		} catch (IOException e) { 
			// TODO 自动生成 catch 块 
			e.printStackTrace(); 
			JOptionPane.showMessageDialog(null, e.toString(), 
					"异常信息", JOptionPane.INFORMATION_MESSAGE); 
		} catch (ClassNotFoundException e) { 
			// TODO 自动生成 catch 块 
			e.printStackTrace(); 
			JOptionPane.showMessageDialog(null, e.toString(), 
					"异常信息", JOptionPane.INFORMATION_MESSAGE); 
		} catch (SQLException e) { 
			// TODO 自动生成 catch 块 
			e.printStackTrace(); 
			JOptionPane.showMessageDialog(null, e.toString(), 
					"异常信息", JOptionPane.INFORMATION_MESSAGE); 
		} 
	} 
 
	/** 
	 * This method initializes jTextField	 
	 * 	 
	 * @return javax.swing.JTextField	 
	 */ 
	private JTextField getJTextField() { 
		if (jTextField == null) { 
			jTextField = new JTextField(); 
			jTextField.setBounds(new Rectangle(72, 41, 115, 25)); 
		} 
		return jTextField; 
	} 
 
	/** 
	 * This method initializes jTextField1	 
	 * 	 
	 * @return javax.swing.JTextField	 
	 */ 
	private JTextField getJTextField1() { 
		if (jTextField1 == null) { 
			jTextField1 = new JTextField(); 
			jTextField1.setBounds(new Rectangle(256, 41, 131, 25)); 
			jTextField1.getDocument().addDocumentListener( 
					new DocumentListener() { 
						 
						public void changedUpdate(DocumentEvent arg0) { 
							// TODO 自动生成方法存根 
							jLabel6.setText("请输入查询序列号"); 
						} 
 
						public void insertUpdate(DocumentEvent arg0) { 
							if (jTextField1.getText().length() == 12)  
							{ 
								boolean value=false; 
								Connection con; 
								Statement sql; // 声明Statement对象 
								ResultSet rs; 
								String SelectStr="select 客户名称 from CustomProductReceAndDisReport where 序列号='"+jTextField1.getText()+"' and 返回用户日期=''"; 
								System.out.println(SelectStr); 
								try { 
									Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
									String url = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+FiberHomeDatabasePath; 
									con = DriverManager.getConnection(url); 
									sql = con.createStatement(); 
									rs = sql.executeQuery(SelectStr); 
									while (rs.next()) { 
										String CustomName = rs.getString(1); // 获得数据库第一列 
										jLabel6.setText(CustomName); 
										value=true; 
									} 
									if(value==false) 
									{ 
										jLabel6.setText("查询不到用户信息"); 
									} 
								} catch (ClassNotFoundException e) { 
									// TODO 自动生成 catch 块 
									e.printStackTrace(); 
									JOptionPane.showMessageDialog(null, e.toString(), 
											"异常信息", JOptionPane.INFORMATION_MESSAGE); 
								} catch (SQLException e) { 
									// TODO 自动生成 catch 块 
									e.printStackTrace(); 
									JOptionPane.showMessageDialog(null, e.toString(), 
											"异常信息", JOptionPane.INFORMATION_MESSAGE); 
								} 
							} 
							// TODO 自动生成方法存根 
							 
						} 
 
						public void removeUpdate(DocumentEvent arg0) { 
							// TODO 自动生成方法存根 
							jLabel6.setText("请输入查询序列号"); 
						} 
						}); 
		} 
		return jTextField1; 
	} 
 
	/** 
	 * This method initializes jComboBox1	 
	 * 	 
	 * @return javax.swing.JComboBox	 
	 */ 
	private JComboBox getJComboBox1() { 
		if (jComboBox1 == null) { 
			jComboBox1 = new JComboBox(); 
			jComboBox1.setBounds(new Rectangle(678, 41, 81, 25)); 
			jComboBox1.addItem(""); 
			jComboBox1.addItem("共进"); 
			jComboBox1.addItem("双翼"); 
			jComboBox1.addItem("智易"); 
			jComboBox1.addItem("总部"); 
		} 
		return jComboBox1; 
	} 
 
	/** 
	 * This method initializes jScrollPane	 
	 * 	 
	 * @return javax.swing.JScrollPane	 
	 */ 
	private JScrollPane getJScrollPane() { 
		if (jScrollPane == null) { 
			jScrollPane = new JScrollPane(); 
			jScrollPane.setBounds(new Rectangle(2, 101, 761, 230)); 
			jScrollPane.setViewportView(getJTable()); 
		} 
		return jScrollPane; 
	} 
 
	/** 
	 * This method initializes jTable	 
	 * 	 
	 * @return javax.swing.JTable	 
	 */ 
	private JTable getJTable() { 
		if (jTable == null) { 
			jTable = new JTable(); 
		} 
		return jTable; 
	} 
 
	/** 
	 * This method initializes jButton1	 
	 * 	 
	 * @return javax.swing.JButton	 
	 */ 
	private JButton getJButton1() { 
		if (jButton1 == null) { 
			jButton1 = new JButton(); 
			jButton1.setBounds(new Rectangle(604, 70, 77, 26)); 
			jButton1.setText("查询"); 
			jButton1.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) { 
					boolean value=false; 
					Connection con; 
					Statement sql; // 声明Statement对象 
					Connection conExcute; 
					Statement sqlExcute; 
					ResultSet rs; 
					String DateValues = ""; 
					Date NowTime = new Date(); 
					SimpleDateFormat TransFormatTime = new SimpleDateFormat( 
							"yyyy-MM-dd"); 
					DateValues = TransFormatTime.format(NowTime); 
					String SelectStr=CreateSelectStr(jTextField.getText(),jTextField1.getText(),jComboBox1.getSelectedItem().toString()); 
					tm.fireTableStructureChanged(); 
					try { 
						Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
						String url = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+FiberHomeDatabasePath; 
						con = DriverManager.getConnection(url); 
						sql = con.createStatement(); 
						rs = sql.executeQuery(SelectStr); 
						while (rs.next()) { 
							Vector<String> result = new Vector<String>(); 
							result.addElement(rs.getString(1)); 
							result.addElement(rs.getString(2)); 
							result.addElement(rs.getString(3)); 
							result.addElement(rs.getString(4)); 
							result.addElement(rs.getString(5)); 
							result.addElement(rs.getString(6)); 
							result.addElement(rs.getString(7)); 
							result.addElement(""); 
							vector.addElement(result); 
							tm.fireTableStructureChanged(); 
						} 
					} catch (ClassNotFoundException e1) { 
						// TODO 自动生成 catch 块 
						e1.printStackTrace(); 
						JOptionPane.showMessageDialog(null, e1.toString(), 
								"异常信息", JOptionPane.INFORMATION_MESSAGE); 
					} catch (SQLException e2) { 
						// TODO 自动生成 catch 块 
						e2.printStackTrace(); 
						JOptionPane.showMessageDialog(null, e2.toString(), 
								"异常信息", JOptionPane.INFORMATION_MESSAGE); 
					} 
				} 
			}); 
		} 
		return jButton1; 
	} 
	private String CreateSelectStr(String User,String SerialNumber,String Verder) 
	{ 
		String SelectStr=""; 
		if(User.equals("") && SerialNumber.equals("") && Verder.equals("")) 
		{ 
			SelectStr="select 设备类型,设备型号,序列号,厂家名称,测试故障,客户名称,返厂日期 from CustomProductReceAndDisReport"; 
		} 
		else if(User.equals("") && SerialNumber.equals("") && !Verder.equals("")) 
		{ 
			SelectStr="select 设备类型,设备型号,序列号,厂家名称,测试故障,客户名称,返厂日期 from CustomProductReceAndDisReport where 厂家 like '%"+Verder+"%'"; 
		} 
		else if(User.equals("") && !SerialNumber.equals("") && Verder.equals("")) 
		{ 
			SelectStr="select 设备类型,设备型号,序列号,厂家名称,测试故障,客户名称,返厂日期 from CustomProductReceAndDisReport where 序列号 ='"+SerialNumber+"'"; 
		} 
		else if(!User.equals("") && SerialNumber.equals("") && Verder.equals("")) 
		{ 
			SelectStr="select 设备类型,设备型号,序列号,厂家名称,测试故障,客户名称,返厂日期 from CustomProductReceAndDisReport where 客户名称 like '%"+User+"%'"; 
		} 
		else if(User.equals("") && !SerialNumber.equals("") && !Verder.equals("")) 
		{ 
			SelectStr="select 设备类型,设备型号,序列号,厂家名称,测试故障,客户名称,返厂日期 from CustomProductReceAndDisReport where  序列号 ='"+SerialNumber+"' and 厂家 like '%"+Verder+"%'"; 
		} 
		else if(!User.equals("") && SerialNumber.equals("") && !Verder.equals("")) 
		{ 
			SelectStr="select 设备类型,设备型号,序列号,厂家名称,测试故障,客户名称,返厂日期 from CustomProductReceAndDisReport where  客户名称 ='%"+User+"%' and 厂家 like '%"+Verder+"%'"; 
		} 
		else if(!User.equals("") && !SerialNumber.equals("") && !Verder.equals("")) 
		{ 
			SelectStr="select 设备类型,设备型号,序列号,厂家名称,测试故障,客户名称,返厂日期 from CustomProductReceAndDisReport where  客户名称 ='%"+User+"%' and 序列号 ='"+SerialNumber+"' and 厂家 like '%"+Verder+"%'"; 
		} 
		else if(!User.equals("") && !SerialNumber.equals("") && Verder.equals("")) 
		{ 
			SelectStr="select 设备类型,设备型号,序列号,厂家名称,测试故障,客户名称,返厂日期 from CustomProductReceAndDisReport where  客户名称 ='%"+User+"%' and 序列号 ='"+SerialNumber+"'"; 
		} 
		return SelectStr; 
	} 
 
	/** 
	 * This method initializes jButton2	 
	 * 	 
	 * @return javax.swing.JButton	 
	 */ 
	private JButton getJButton2() { 
		if (jButton2 == null) { 
			jButton2 = new JButton(); 
			jButton2.setBounds(new Rectangle(681, 70, 77, 26)); 
			jButton2.setText("返回"); 
			jButton2.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) { 
					TestToolsPing TestForm = new TestToolsPing(); 
					TestForm.setVisible(true); 
					setVisible(false); 
				} 
			}); 
		} 
		return jButton2; 
	} 
 
	/** 
	 * This method initializes jButton3	 
	 * 	 
	 * @return javax.swing.JButton	 
	 */ 
	private JButton getJButton3() { 
		if (jButton3 == null) { 
			jButton3 = new JButton(); 
			jButton3.setBounds(new Rectangle(527, 70, 77, 26)); 
			jButton3.setText("确定"); 
			jButton3.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) { 
					if(jTextField1.getText().equals("")) 
					{ 
						JOptionPane.showMessageDialog(null, "请输入设备序列号!","错误信息",JOptionPane.ERROR_MESSAGE); 
						jTextField1.grabFocus(); 
					} 
					else 
					{ 
						boolean value=false; 
						Connection con; 
						Statement sql; // 声明Statement对象 
						Connection conExcute; 
						Statement sqlExcute; 
						ResultSet rs; 
						String DateValues = ""; 
						Date NowTime = new Date(); 
						SimpleDateFormat TransFormatTime = new SimpleDateFormat( 
								"yyyy-MM-dd"); 
						DateValues = TransFormatTime.format(NowTime); 
						String SelectStr="select 设备类型,设备型号,序列号,厂家名称,测试故障,客户名称,返厂日期 from CustomProductReceAndDisReport where 序列号='"+jTextField1.getText()+"' and 返回用户日期=''"; 
						tm.fireTableStructureChanged(); 
						try { 
							Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
							String url = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+FiberHomeDatabasePath; 
							con = DriverManager.getConnection(url); 
							sql = con.createStatement(); 
							conExcute= DriverManager.getConnection(url); 
							sqlExcute=con.createStatement(); 
							rs = sql.executeQuery(SelectStr); 
							while (rs.next()) { 
								String UpdateTimeStr="update CustomProductReceAndDisReport set 返回用户日期='"+DateValues+"' where 返回用户日期='' and 序列号='"+jTextField1.getText()+"'"; 
								Vector<String> result = new Vector<String>(); 
								result.addElement(rs.getString(1)); 
								result.addElement(rs.getString(2)); 
								result.addElement(rs.getString(3)); 
								result.addElement(rs.getString(4)); 
								result.addElement(rs.getString(5)); 
								result.addElement(rs.getString(6)); 
								result.addElement(rs.getString(7)); 
								result.addElement(jComboBox2.getSelectedItem().toString()); 
								vector.addElement(result); 
								tm.fireTableStructureChanged(); 
								sqlExcute.executeUpdate(UpdateTimeStr); 
							} 
						} catch (ClassNotFoundException e1) { 
							// TODO 自动生成 catch 块 
							e1.printStackTrace(); 
							JOptionPane.showMessageDialog(null, e1.toString(), 
									"异常信息", JOptionPane.INFORMATION_MESSAGE); 
						} catch (SQLException e2) { 
							// TODO 自动生成 catch 块 
							e2.printStackTrace(); 
							JOptionPane.showMessageDialog(null, e2.toString(), 
									"异常信息", JOptionPane.INFORMATION_MESSAGE); 
						}					 
						jTextField1.setText(""); 
						jTextField1.grabFocus(); 
					} 
					 
				} 
			}); 
		} 
		return jButton3; 
	} 
 
	/** 
	 * This method initializes jButton4	 
	 * 	 
	 * @return javax.swing.JButton	 
	 */ 
	private JButton getJButton4() { 
		if (jButton4 == null) { 
			jButton4 = new JButton(); 
			jButton4.setBounds(new Rectangle(494, 335, 122, 23)); 
			jButton4.setText("导出"); 
			jButton4.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) { 
					WritableSheet sheet = null; 
					String selectvalue = ""; 
					File f = null; 
					JFileChooser fileChooser = new JFileChooser(); 
					fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); 
					fileChooser.removeChoosableFileFilter(fileChooser 
							.getAcceptAllFileFilter()); // 移去所有文件过滤器 
					fileChooser 
							.addChoosableFileFilter(new com.mervyn.testsource.MyFileFilter( 
									"xls", "Excel文件")); 
					int returnValue = fileChooser.showSaveDialog(null); 
					if (returnValue == JFileChooser.APPROVE_OPTION) { 
						f = fileChooser.getSelectedFile(); 
						selectvalue = f.getPath() + ".xls"; 
					} 
						try { 
							CreateExcelSub(selectvalue); 
						} catch (WriteException e1) { 
							// TODO 自动生成 catch 块 
							e1.printStackTrace(); 
						} 
					 
					 
				} 
			}); 
		} 
		return jButton4; 
	} 
	public void CreateExcelSub(String FileValue) throws WriteException { 
		WritableWorkbook book = null; 
		WritableSheet sheet = null; 
		WritableCellFormat cellFormat = new WritableCellFormat(); 
		cellFormat.setAlignment(Alignment.CENTRE); 
		WritableCellFormat integerFormat = new WritableCellFormat( 
				NumberFormats.INTEGER); 
		try { 
			// String url ="jdbc:odbc:driver={Microsoft Access Driver 
			// (*.mdb)};DBQ=//192.168.71.49/AcessDataBase/ponbackup.mdb"; 
			book = Workbook.createWorkbook(new File(FileValue)); 
			sheet = book.createSheet("厂家发货清单", 0); 
			int datacount = 0; 
			int DataCountValue = tm.getRowCount(); 
			Label label = new Label(0, 0, "设备类型"); 
			label.setCellFormat(cellFormat); 
			sheet.addCell(label); 
			Label label1 = new Label(1, 0, "设备型号"); 
			label1.setCellFormat(cellFormat); 
			sheet.addCell(label1); 
			Label label2 = new Label(2, 0, "序列号"); 
			label2.setCellFormat(cellFormat); 
			sheet.addCell(label2); 
			Label label3 = new Label(3, 0, "厂商名称"); 
			label3.setCellFormat(cellFormat); 
			sheet.addCell(label3); 
			Label label4 = new Label(4, 0, "维修故障"); 
			label4.setCellFormat(cellFormat); 
			sheet.addCell(label4); 
			Label label5 = new Label(5, 0, "客户信息"); 
			label5.setCellFormat(cellFormat); 
			sheet.addCell(label5); 
			Label label6 = new Label(6, 0, "送修日期"); 
			label6.setCellFormat(cellFormat); 
			sheet.addCell(label6); 
			Label label7 = new Label(7, 0, "维修结果"); 
			label7.setCellFormat(cellFormat); 
			sheet.addCell(label7); 
			sheet.setColumnView(0, 16);// 第一列的宽度 
			sheet.setColumnView(1, 18);// 第二列的宽度 
			sheet.setColumnView(2, 20);// 第三列的宽度 
			sheet.setColumnView(3, 12);// 第三列的宽度 
			sheet.setColumnView(4, 12);// 第三列的宽度 
			sheet.setColumnView(5, 30);// 第三列的宽度 
			sheet.setColumnView(6, 16);// 第三列的宽度 
			sheet.setColumnView(7, 16);// 第三列的宽度 
			for (datacount = 0; datacount < DataCountValue; datacount++) { 
				label = new Label(0, datacount + 1, tm.getValueAt(datacount, 0) 
						.toString()); 
				label.setCellFormat(cellFormat); 
				sheet.addCell(label); 
				 
				label1 = new Label(1, datacount + 1, tm.getValueAt(datacount, 1) 
						.toString()); 
				label1.setCellFormat(cellFormat); 
				sheet.addCell(label1); 
				label2 = new Label(2, datacount + 1, tm.getValueAt(datacount, 2) 
						.toString()); 
				label2.setCellFormat(cellFormat); 
				sheet.addCell(label2); 
				 
				label3 = new Label(3, datacount + 1, tm.getValueAt(datacount, 3) 
						.toString()); 
				label3.setCellFormat(cellFormat); 
				sheet.addCell(label3); 
				label4 = new Label(4, datacount + 1, tm.getValueAt(datacount, 4) 
						.toString()); 
				label4.setCellFormat(cellFormat); 
				sheet.addCell(label4); 
				label5 = new Label(5, datacount + 1, tm.getValueAt(datacount, 5) 
						.toString()); 
				label5.setCellFormat(cellFormat); 
				sheet.addCell(label5); 
				label6 = new Label(6, datacount + 1, tm.getValueAt(datacount, 6) 
						.toString()); 
				label6.setCellFormat(cellFormat); 
				sheet.addCell(label6); 
				label7 = new Label(7, datacount + 1, tm.getValueAt(datacount, 7) 
						.toString()); 
				label7.setCellFormat(cellFormat); 
				sheet.addCell(label7); 
				 
			} 
			book.write(); 
			book.close(); 
			JOptionPane.showMessageDialog(null, "查询的报表导出成功!!!路径为:" + FileValue, 
					"提示信息", JOptionPane.INFORMATION_MESSAGE); 
			jLabel7.setText(FileValue); 
		} catch (UnsupportedEncodingException unsupprot) { 
 
		} catch (RowsExceededException e4) { 
			// TODO 自动生成 catch 块 
			e4.printStackTrace(); 
		} catch (WriteException e5) { 
			// TODO 自动生成 catch 块 
			e5.printStackTrace(); 
		} catch (IOException e7) { 
			// TODO 自动生成 catch 块 
			e7.printStackTrace(); 
		} 
 
		//return sheet; 
	} 
 
	/** 
	 * This method initializes jButton5	 
	 * 	 
	 * @return javax.swing.JButton	 
	 */ 
	private JButton getJButton5() { 
		if (jButton5 == null) { 
			jButton5 = new JButton(); 
			jButton5.setBounds(new Rectangle(450, 70, 77, 26)); 
			jButton5.setText("清空"); 
			jButton5.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) { 
					vector.removeAllElements(); 
					tm.fireTableStructureChanged(); 
				} 
			}); 
		} 
		return jButton5; 
	} 
 
	/** 
	 * This method initializes jButton6	 
	 * 	 
	 * @return javax.swing.JButton	 
	 */ 
	private JButton getJButton6() { 
		if (jButton6 == null) { 
			jButton6 = new JButton(); 
			jButton6.setBounds(new Rectangle(390, 41, 43, 23)); 
			jButton6.setText("C"); 
			jButton6.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) { 
					jTextField1.setText(""); 
				} 
			}); 
		} 
		return jButton6; 
	} 
	/** 
	 * This method initializes jComboBox2	 
	 * 	 
	 * @return javax.swing.JComboBox	 
	 */ 
	private JComboBox getJComboBox2() { 
		if (jComboBox2 == null) { 
			jComboBox2 = new JComboBox(); 
			jComboBox2.setBounds(new Rectangle(516, 41, 112, 25)); 
			jComboBox2.addItem("已修复"); 
			jComboBox2.addItem("已报废"); 
		} 
		return jComboBox2; 
	} 
 
}  //  @jve:decl-index=0:visual-constraint="10,10"