www.pudn.com > TestToolsProject.rar > CompareDataSystem.java, change:2014-05-13,size:31388b


package com.mervyn.testtools; 
 
import javax.swing.JFileChooser; 
import javax.swing.JOptionPane; 
import javax.swing.JPanel; 
import javax.swing.JFrame; 
 
import java.awt.Color; 
import java.awt.Dimension; 
import java.awt.Toolkit; 
 
import javax.swing.JLabel; 
import java.awt.Rectangle; 
import java.io.File; 
import java.io.IOException; 
import java.sql.Connection; 
import java.sql.DriverManager; 
import java.sql.ResultSet; 
import java.sql.SQLException; 
import java.sql.Statement; 
//import java.text.DateFormat; 
import java.text.SimpleDateFormat; 
//import java.util.Date; 
import java.util.Vector; 
 
import javax.swing.JTextField; 
import javax.swing.JButton; 
 
 
import com.mervyn.testsource.MyFileFilter; 
import java.awt.Font; 
 
import jxl.Cell; 
import jxl.Sheet; 
import jxl.Workbook; 
import jxl.read.biff.BiffException; 
 
import javax.swing.JScrollPane; 
import javax.swing.JTable; 
import javax.swing.table.AbstractTableModel; 
import javax.swing.table.DefaultTableCellRenderer; 
 
public class CompareDataSystem extends JFrame implements Runnable { 
 
	private static final long serialVersionUID = 1L; 
 
	private JPanel jContentPane = null; 
 
	private JLabel jLabel = null; 
 
	private JTextField jTextField = null; 
 
	private JLabel jLabel1 = null; 
 
	private JTextField jTextField1 = null; 
 
	private JLabel jLabel2 = null; 
 
	private JTextField jTextField2 = null; 
 
	private JButton jButton = null; 
 
	private JLabel jLabel3 = null; 
 
	private JTextField jTextField3 = null; 
 
	private JButton jButton1 = null; 
	JFileChooser fc = new JFileChooser(); 
 
	private JLabel jLabel4 = null; 
 
	private JLabel jLabel5 = null; 
 
	private JTextField jTextField4 = null; 
 
	private JButton jButton2 = null; 
 
	private JButton jButton3 = null; 
 
	private JButton jButton4 = null; 
 
	private JScrollPane jScrollPane = null; 
	private boolean insertintoValue=false; 
 
	private JTable jTable = null; 
	String[] title = { "序列号", "设备类型", "厂商名称","RMA", "客户", "故障类型","检测状态" }; 
  //  @jve:decl-index=0: 
	Vector<Vector> vector; // @jve:decl-index=0: 
 
	AbstractTableModel tm; 
 
	private JLabel jLabel6 = null; 
 
	private JButton jButton5 = null; 
 
	private JButton jButton6 = null; 
 
	private JButton jButton7 = null; 
 
	private JButton jButton8 = null; 
	private String RemoteDatabasePath="",LocalDatabasePath="",LocalBackUPdatabasePath="";  //  @jve:decl-index=0: 
	 
	void initTable() { 
		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.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); 
		table.getColumnModel().getColumn(0).setPreferredWidth(200); 
		table.setBackground(Color.LIGHT_GRAY); 
		 
		// scroll=new JScrollPane(table); 
		jScrollPane.setViewportView(table); 
		// contentPane.add(scroll,null); 
 
	} 
 
 
	/** 
	 * This is the default constructor 
	 */ 
	public CompareDataSystem() { 
		super(); 
		initialize(); 
		initTable(); 
		setLocalDatabasePath(); 
		setRemoteDatabasePath(); 
	} 
	public void run(){ 
		 
	} 
 
	/** 
	 * This method initializes this 
	 *  
	 * @return void 
	 */ 
	private void initialize() { 
		this.setSize(884, 413); 
		this.setContentPane(getJContentPane()); 
		this.setTitle("ECC上传数据检测系统"); 
		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) { 
			jLabel6 = new JLabel(); 
			jLabel6.setBounds(new Rectangle(483, 358, 282, 18)); 
			jLabel6.setText(""); 
			jLabel5 = new JLabel(); 
			jLabel5.setBounds(new Rectangle(9, 35, 53, 20)); 
			jLabel5.setText("备    注:"); 
			jLabel4 = new JLabel(); 
			jLabel4.setBounds(new Rectangle(8, 87, 849, 8)); 
			jLabel4.setFont(new Font("Dialog", Font.PLAIN, 18)); 
			jLabel4.setText("--------------------------------------------------------------------------------------------------------------------------------------------"); 
			jLabel3 = new JLabel(); 
			jLabel3.setBounds(new Rectangle(410, 35, 65, 20)); 
			jLabel3.setText("检测文件:"); 
			jLabel2 = new JLabel(); 
			jLabel2.setBounds(new Rectangle(410, 10, 64, 20)); 
			jLabel2.setText("设备信息:"); 
			jLabel1 = new JLabel(); 
			jLabel1.setBounds(new Rectangle(205, 10, 53, 20)); 
			jLabel1.setText("RMA号:"); 
			jLabel = new JLabel(); 
			jLabel.setBounds(new Rectangle(9, 10, 53, 20)); 
			jLabel.setText("客    户:"); 
			jContentPane = new JPanel(); 
			jContentPane.setLayout(null); 
			jContentPane.add(jLabel, null); 
			jContentPane.add(getJTextField(), null); 
			jContentPane.add(jLabel1, null); 
			jContentPane.add(getJTextField1(), null); 
			jContentPane.add(jLabel2, null); 
			jContentPane.add(getJTextField2(), null); 
			jContentPane.add(getJButton(), null); 
			jContentPane.add(jLabel3, null); 
			jContentPane.add(getJTextField3(), null); 
			jContentPane.add(getJButton1(), null); 
			jContentPane.add(jLabel4, null); 
			jContentPane.add(jLabel5, null); 
			jContentPane.add(getJTextField4(), null); 
			jContentPane.add(getJButton2(), null); 
			jContentPane.add(getJButton3(), null); 
			jContentPane.add(getJButton4(), null); 
			jContentPane.add(getJScrollPane(), null); 
			jContentPane.add(jLabel6, null); 
			jContentPane.add(getJButton5(), null); 
			jContentPane.add(getJButton6(), null); 
			jContentPane.add(getJButton7(), null); 
			jContentPane.add(getJButton8(), null); 
		} 
		return jContentPane; 
	} 
 
	/** 
	 * This method initializes jTextField	 
	 * 	 
	 * @return javax.swing.JTextField	 
	 */ 
	private JTextField getJTextField() { 
		if (jTextField == null) { 
			jTextField = new JTextField(); 
			jTextField.setBounds(new Rectangle(66, 10, 125, 20)); 
			jTextField.setText(""); 
		} 
		return jTextField; 
	} 
 
	/** 
	 * This method initializes jTextField1	 
	 * 	 
	 * @return javax.swing.JTextField	 
	 */ 
	private JTextField getJTextField1() { 
		if (jTextField1 == null) { 
			jTextField1 = new JTextField(); 
			jTextField1.setBounds(new Rectangle(256, 10, 150, 20)); 
			jTextField1.setText(""); 
		} 
		return jTextField1; 
	} 
 
	/** 
	 * This method initializes jTextField2	 
	 * 	 
	 * @return javax.swing.JTextField	 
	 */ 
	private JTextField getJTextField2() { 
		if (jTextField2 == null) { 
			jTextField2 = new JTextField(); 
			jTextField2.setBounds(new Rectangle(480, 10, 261, 20)); 
			jTextField2.setEditable(false); 
		} 
		return jTextField2; 
	} 
 
	/** 
	 * This method initializes jButton	 
	 * 	 
	 * @return javax.swing.JButton	 
	 */ 
	private JButton getJButton() { 
		if (jButton == null) { 
			jButton = new JButton(); 
			jButton.setBounds(new Rectangle(746, 10, 63, 20)); 
			jButton.setText("浏览"); 
			jButton.addMouseListener(new java.awt.event.MouseAdapter() { 
				public void mouseClicked(java.awt.event.MouseEvent e) { 
					File f = null; 
					fc.setMultiSelectionEnabled(false);// 选择模式,可选择文件和文件夹 
					fc.setFileSelectionMode(JFileChooser.FILES_ONLY); 
					fc.setFileHidingEnabled(true); // 设置是否显示隐藏文件 
					fc.setAcceptAllFileFilterUsed(false); 
					fc.removeChoosableFileFilter(fc.getAcceptAllFileFilter());  //移去所有文件过滤器 
				    fc.addChoosableFileFilter(new MyFileFilter("xls","Excel文件")); 
				    int returnValue = fc.showOpenDialog(null); 
					if (returnValue == JFileChooser.APPROVE_OPTION) { 
						f = fc.getSelectedFile(); 
						jTextField2.setText(f.getPath()); 
					} 
					 
				} 
			}); 
		} 
		return jButton; 
	} 
 
	/** 
	 * This method initializes jTextField3	 
	 * 	 
	 * @return javax.swing.JTextField	 
	 */ 
	private JTextField getJTextField3() { 
		if (jTextField3 == null) { 
			jTextField3 = new JTextField(); 
			jTextField3.setBounds(new Rectangle(481, 35, 260, 20)); 
			jTextField3.setEditable(false); 
		} 
		return jTextField3; 
	} 
 
	/** 
	 * This method initializes jButton1	 
	 * 	 
	 * @return javax.swing.JButton	 
	 */ 
	private JButton getJButton1() { 
		if (jButton1 == null) { 
			jButton1 = new JButton(); 
			jButton1.setBounds(new Rectangle(746, 35, 63, 20)); 
			jButton1.setText("浏览"); 
			jButton1.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) { 
					File f = null; 
					fc.setMultiSelectionEnabled(false);// 选择模式,可选择文件和文件夹 
					fc.setFileSelectionMode(JFileChooser.FILES_ONLY); 
					fc.setFileHidingEnabled(true); // 设置是否显示隐藏文件 
					fc.setAcceptAllFileFilterUsed(false); 
					fc.removeChoosableFileFilter(fc.getAcceptAllFileFilter());  //移去所有文件过滤器 
				    fc.addChoosableFileFilter(new MyFileFilter("xls","Excel文件")); 
				    int returnValue = fc.showOpenDialog(null); 
					if (returnValue == JFileChooser.APPROVE_OPTION) { 
						f = fc.getSelectedFile(); 
						jTextField3.setText(f.getPath()); 
					} 
				} 
			}); 
		} 
		return jButton1; 
	} 
 
	/** 
	 * This method initializes jTextField4	 
	 * 	 
	 * @return javax.swing.JTextField	 
	 */ 
	private JTextField getJTextField4() { 
		if (jTextField4 == null) { 
			jTextField4 = new JTextField(); 
			jTextField4.setBounds(new Rectangle(66, 35, 252, 20)); 
		} 
		return jTextField4; 
	} 
 
	/** 
	 * This method initializes jButton2	 
	 * 	 
	 * @return javax.swing.JButton	 
	 */ 
	private JButton getJButton2() { 
		if (jButton2 == null) { 
			jButton2 = new JButton(); 
			jButton2.setBounds(new Rectangle(575, 61, 88, 20)); 
			jButton2.setText("导入"); 
			jButton2.addMouseListener(new java.awt.event.MouseAdapter() { 
				public void mouseClicked(java.awt.event.MouseEvent e) { 
					String FirstFilePath=jTextField2.getText(),SecondFilePath=jTextField3.getText(); 
					if(!FirstFilePath.equals("") /*&& !SecondFilePath.equals("")*/ && !jTextField.getText().equals("") /*&& !jTextField1.getText().equals("")*/) 
					{ 
						/*CompareDataSystem RunStateone=new CompareDataSystem(); 
						Thread t1=new Thread(RunStateone); 
						t1.start();*/ 
						InsertValueStr(FirstFilePath); 
						UpdateValueStr(SecondFilePath); 
						BooleanSetValues(); 
						ShowImportDataResultSub(); 
						JOptionPane 
						.showMessageDialog( 
								null, 
								"数据导入完成!", 
								"数据导入成功信息", JOptionPane.INFORMATION_MESSAGE); 
					} 
					else 
					{ 
							JOptionPane.showMessageDialog(null, "请填写需要导入的数据!!", "错误信息", 
									JOptionPane.ERROR_MESSAGE); 
					} 
				} 
			}); 
		} 
		return jButton2; 
	} 
	public void UpdateValueStr(String FilePathStr) 
	{ 
		Connection con=null; 
		Statement sql=null; // 声明Statement对象 
		ResultSet rs; 
		Workbook book; 
		try { 
			book = Workbook.getWorkbook(new File(FilePathStr)); 
			Sheet sheet = book.getSheet(0); 
			String BarCode="",DevType="",Vender="",ValidDate="",WarrantyState=""; 
			String ZTEState="",SecondReqair="",DetectionResult="",FailureInformation=""; 
			String Customer="",RMA=jTextField1.getText(),Remark=""; 
			int ID=1; 
			String UpdateStr=""; 
			int ResultValue=0; 
			 String url ="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+LocalDatabasePath; 
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
			con = DriverManager.getConnection(url); 
			sql = con.createStatement(); 
			 
			do{ 
				Cell cell1 = sheet.getCell(1, ID); 
				BarCode=cell1.getContents(); 
				if(BarCode=="") 
				{ 
					break; 
				} 
				Cell cell3 = sheet.getCell(3, ID); 
				Vender=cell3.getContents(); 
				Cell cell4 = sheet.getCell(4, ID); 
				ValidDate=cell4.getContents(); 
				Cell cell5 = sheet.getCell(5, ID); 
				WarrantyState=cell5.getContents(); 
				Cell cell6 = sheet.getCell(6, ID); 
				ZTEState=cell6.getContents(); 
				Cell cell7 = sheet.getCell(7, ID); 
				SecondReqair=cell7.getContents(); 
                
				UpdateStr = "update VSTDatabaseLocalBackup set Vender='" 
						+ Vender + "', ValidDate='" + ValidDate 
						+ "', WarrantyState='" + WarrantyState + "', ZTEState='" 
						+ ZTEState + "', SecondReqair='" + SecondReqair 
						+ "' where BarCode='" + BarCode + "' and  RMA='" + RMA + "'"; 
				 
				sql.addBatch(UpdateStr); 
				//ResultValue=sql.executeUpdate(UpdateStr); 
				ID++; 
				 
				insertintoValue=true; 
			}while(BarCode!=""); 
			sql.executeBatch(); 
			con.commit(); 
			con.close(); 
			sql.close(); 
			 
		}catch(ArrayIndexOutOfBoundsException ArrayIndex){ 
			//ArrayIndex.printStackTrace(); 
		} 
		catch (BiffException e) { 
			// TODO 自动生成 catch 块 
			e.printStackTrace(); 
		} catch (IOException e) { 
			// TODO 自动生成 catch 块 
			e.printStackTrace(); 
		} catch (ClassNotFoundException e) { 
			// TODO 自动生成 catch 块 
			e.printStackTrace(); 
		} catch (SQLException e) { 
			// TODO 自动生成 catch 块 
			e.printStackTrace(); 
		} 
		 
	} 
	public void DeleteValueStr() 
	{ 
		Connection con; 
		String Times=""; 
		Statement sql; // 声明Statement对象 
		SimpleDateFormat sDateFormat=new SimpleDateFormat("yyyy-MM-dd");    
		Times=sDateFormat.format(new java.util.Date()); 
		try { 
			int ID=1; 
			String DeleteDataStr=""; 
			int ResultValue=0;	 
                String url ="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+LocalDatabasePath; 
                DeleteDataStr = "delete from VSTDatabaseLocalBackup where  Times like '"+Times+"%'"; 
				Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
				con = DriverManager.getConnection(url); 
				sql = con.createStatement(); 
				ResultValue=sql.executeUpdate(DeleteDataStr); 
				System.out.println(ResultValue); 
				switch(ResultValue) 
				{ 
				case 0: 
					JOptionPane 
					.showMessageDialog( 
							null, 
							"数据库中不存在数据。", 
							"提示信息", JOptionPane.INFORMATION_MESSAGE); 
					break; 
				default: 
					JOptionPane 
					.showMessageDialog( 
							null, 
							"共清理数据"+ResultValue+"条", 
							"错误信息", JOptionPane.INFORMATION_MESSAGE); 
				 
				} 
				 
				con.close(); 
		} 
 
			 
		 catch (ClassNotFoundException e) { 
			// TODO 自动生成 catch 块 
			e.printStackTrace(); 
		} catch (SQLException e) { 
			// TODO 自动生成 catch 块 
			//e.printStackTrace(); 
			JOptionPane 
			.showMessageDialog( 
					null, 
					e.toString(), 
					"错误信息", JOptionPane.ERROR_MESSAGE); 
		} 
		 
	} 
	public void InsertValueStr(String FilePathStr) 
	{ 
		Connection con; 
		Statement sql; // 声明Statement对象 
		ResultSet rs; 
		Workbook book; 
		try { 
			book = Workbook.getWorkbook(new File(FilePathStr)); 
			Sheet sheet = book.getSheet(0); 
			int ID=1; 
			String BarCode="",DevType="",Vender="",ValidDate="",WarrantyState=""; 
			String ZTEState="",SecondReqair="",DetectionResult="",FailureInformation=""; 
			String Customer="",RMA="",Remark=""; 
			String Times=""; 
			String TestState=""; 
			//String StrStart=""; 
			/*int ResultCount=sheet.getRows();*/ 
			String InsertintoStr=""; 
			int ResultValue=0; 
			String url ="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+LocalDatabasePath; 
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance(); 
			con=DriverManager.getConnection(url); 
			/*con = DriverManager.getConnection( 
					"jdbc:odbc:VSTDatabaseLocal", "", "");*/ 
			sql = con.createStatement(); 
			con.setAutoCommit(false); 
			do{ 
				Cell cell1 = sheet.getCell(1, ID); 
				BarCode=cell1.getContents(); 
				if(BarCode=="") 
				{ 
					break; 
				} 
				Cell cell2 = sheet.getCell(2, ID); 
				DevType=cell2.getContents(); 
				Cell cell3 = sheet.getCell(3, ID); 
				Vender=cell3.getContents(); 
				Cell cell4 = sheet.getCell(4, ID); 
				ValidDate=cell4.getContents(); 
				Cell cell5 = sheet.getCell(5, ID); 
				WarrantyState=cell5.getContents(); 
				Cell cell6 = sheet.getCell(6, ID); 
				ZTEState=cell6.getContents(); 
				Cell cell7 = sheet.getCell(7, ID); 
				SecondReqair=cell7.getContents(); 
				Cell cell8 = sheet.getCell(8, ID); 
				DetectionResult=cell8.getContents(); 
				Cell cell9 = sheet.getCell(9, ID); 
				FailureInformation=cell9.getContents(); 
				Customer= new String(jTextField.getText().getBytes("GBK"),"gb2312"); 
				RMA= new String(jTextField1.getText().getBytes("GBK"),"gb2312"); 
				Cell cell10 = sheet.getCell(10, ID); 
				Remark=cell10.getContents(); 
				SimpleDateFormat sDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");    
				Times=sDateFormat.format(new java.util.Date());    
				InsertintoStr = "insert into VSTDatabaseLocalBackup values('" + ID 
						+ "','" + BarCode + "','" + DevType + "','" + Vender 
						+ "','" + ValidDate + "','" + WarrantyState + "','" 
						+ ZTEState + "','" + SecondReqair + "','" 
						+ DetectionResult + "','" + FailureInformation + "','" 
						+ Customer + "','" + RMA + "','" + Remark +"','"+Times+"','"+TestState+ "')"; 
				System.out.println(InsertintoStr); 
				sql.addBatch(InsertintoStr); 
				//InsertintoStr="create table 黄兵(status12 Text(20),time11 TEXT(20))"; 
				//System.out.println(InsertintoStr); 
				//ResultValue=sql.executeUpdate(InsertintoStr);///aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa 
				ID++; 
				//con.close(); 
				insertintoValue=true; 
			}while(BarCode!=""); 
			sql.executeBatch(); 
			con.commit(); 
			con.close(); 
			sql.close(); 
			ID=ID-1; 
			jLabel6.setText("已经导入"+ID+"条记录"); 
			System.out.println("程序执行结束!"); 
		} catch (BiffException e) { 
			// TODO 自动生成 catch 块 
			e.printStackTrace(); 
		} catch (IOException e) { 
			// TODO 自动生成 catch 块 
			e.printStackTrace(); 
		} 
        // 获得第一个工作表对象 
			catch (ClassNotFoundException e3) { 
			// TODO 自动生成 catch 块 
				e3.printStackTrace(); 
		} catch (SQLException e4) { 
	// TODO 自动生成 catch 块 
	e4.printStackTrace(); 
} catch (InstantiationException e) { 
			// TODO 自动生成 catch 块 
			e.printStackTrace(); 
		} catch (IllegalAccessException e) { 
			// TODO 自动生成 catch 块 
			e.printStackTrace(); 
		} 
         
        // 得到第一列第一行的单元格 
		//return ""; 
	} 
	 
	/** 
	 * This method initializes jButton3	 
	 * 	 
	 * @return javax.swing.JButton	 
	 */ 
	private JButton getJButton3() { 
		if (jButton3 == null) { 
			jButton3 = new JButton(); 
			jButton3.setBounds(new Rectangle(663, 61, 88, 20)); 
			jButton3.setText("检测结果"); 
			jButton3.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) { 
					boolean BooleanValue=false; 
					CreateTestResultSub(BooleanValue); 
					 
					 
				} 
			}); 
		} 
		return jButton3; 
	} 
	public void BooleanSetValues() 
	{ 
		String Times=""; 
		String BarCode=""; 
		SimpleDateFormat sDateFormat=new SimpleDateFormat("yyyy-MM-dd");    
		Times=sDateFormat.format(new java.util.Date());  
		/*vector.removeAllElements(); 
		tm.fireTableStructureChanged();*/ 
		int ResultCount = 0; 
		Connection con,conLocal; 
		Statement sql,sqlLocal; // 声明Statement对象 
		ResultSet rs; 
		String ExcuteCodeStateStr=""; 
		try { 
			String url ="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+LocalBackUPdatabasePath; 
			System.out.println(url); 
			String urlLocal ="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+LocalDatabasePath; 
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
			con = DriverManager.getConnection(url); 
			conLocal=DriverManager.getConnection(urlLocal); 
			sqlLocal=conLocal.createStatement(); 
			sql = con.createStatement(); 
			String SelectValue = "select BarCode from tb_product_result where  BeginDate like '"+ Times + "%'"; 
			rs = sql.executeQuery(SelectValue); 
			while (rs.next()) { 
				BarCode=rs.getString("BarCode"); 
				ExcuteCodeStateStr="update VSTDatabaseLocalBackup set TestState='已上传' where BarCode='"+BarCode+"' and Times like '"+Times+"%'"; 
				sqlLocal.addBatch(ExcuteCodeStateStr); 
				//UpdateTestState(BarCode,Times); 
				ResultCount = ResultCount + 1; 
			} 
			sqlLocal.executeBatch(); 
			conLocal.commit(); 
			sqlLocal.close(); 
			conLocal.close(); 
			rs.close(); 
			con.close(); 
			insertintoValue=true; 
		} catch (SQLException e2) { 
			JOptionPane 
					.showMessageDialog( 
							null, 
							e2.toString(), 
							"连接服务器错误信息", JOptionPane.ERROR_MESSAGE); 
		}catch (ClassNotFoundException e1) { 
			 
		} 
	} 
	public void BooleanSetValues1() 
	{ 
		String Times=""; 
		String BarCode=""; 
		SimpleDateFormat sDateFormat=new SimpleDateFormat("yyyy-MM-dd");    
		Times="2013-12-18";  
		/*vector.removeAllElements(); 
		tm.fireTableStructureChanged();*/ 
		int ResultCount = 0; 
		Connection con; 
		Statement sql; // 声明Statement对象 
		ResultSet rs; 
		try { 
			String url ="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+LocalBackUPdatabasePath; 
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
			con = DriverManager.getConnection(url); 
			sql = con.createStatement(); 
			String SelectValue = "select BarCode from tb_product_result where  BeginDate like '"+ Times + "%'"; 
			 
			rs = sql.executeQuery(SelectValue); 
			while (rs.next()) { 
				 
				BarCode=rs.getString("BarCode"); 
				UpdateTestState(BarCode,Times); 
				ResultCount = ResultCount + 1; 
			} 
			rs.close(); 
			con.close(); 
			insertintoValue=true; 
		} catch (SQLException e2) { 
			JOptionPane 
					.showMessageDialog( 
							null, 
							"数据源错误,具体信息:[Microsoft][ODBC Microsoft Access Driver], \n“(未知)”不是一个有效的路径。请检查服务器(192.168.71.49)是否已经打开!456", 
							"连接服务器错误信息", JOptionPane.ERROR_MESSAGE); 
		}catch (ClassNotFoundException e1) { 
			 
		} 
	} 
	private  void ShowImportDataResultSub() 
	{ 
		String Times=""; 
		SimpleDateFormat sDateFormat=new SimpleDateFormat("yyyy-MM-dd");    
		Times=sDateFormat.format(new java.util.Date());  
		Connection con; 
		Statement sql; // 声明Statement对象 
		ResultSet rs; 
		vector.removeAllElements(); 
		tm.fireTableStructureChanged(); 
		int TestCount=0; 
		try { 
			String url ="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+LocalDatabasePath; 
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
			con = DriverManager.getConnection(url); 
			sql = con.createStatement(); 
			String SelectValue = "select BarCode,DevType,Vender,RMA,Customer,FailureInformation,TestState from VSTDatabaseLocalBackup where  Times like '"+ Times + "%'"; 
			rs = sql.executeQuery(SelectValue); 
			while (rs.next()) { 
				Vector<String> Result = new Vector<String>(); 
				Result.addElement(rs.getString("BarCode")); 
				Result.addElement(rs.getString("DevType")); 
				Result.addElement(rs.getString("Vender")); 
				Result.addElement(rs.getString("RMA")); 
				Result.addElement(rs.getString("Customer")); 
				Result.addElement(rs.getString("FailureInformation")); 
				Result.addElement(rs.getString("TestState")); 
				vector.addElement(Result); 
				tm.fireTableStructureChanged(); 
				TestCount=TestCount+1; 
			} 
			rs.close(); 
			con.close(); 
		} catch (SQLException e2) { 
			JOptionPane 
					.showMessageDialog( 
							null, 
							"数据源错误,具体信息:[Microsoft][ODBC Microsoft Access Driver], \n“(未知)”不是一个有效的路径。请检查数据源是否存在!789", 
							"连接服务器错误信息", JOptionPane.ERROR_MESSAGE); 
		}catch (ClassNotFoundException e1) { 
			 
		} 
	} 
	private  void CreateTestResultSub(boolean ResultBoolean) 
	{ 
		String Times=""; 
		int CountUploadData=0; 
		SimpleDateFormat sDateFormat=new SimpleDateFormat("yyyy-MM-dd");    
		Times=sDateFormat.format(new java.util.Date());  
		Connection con; 
		Statement sql; // 声明Statement对象 
		ResultSet rs; 
		vector.removeAllElements(); 
		tm.fireTableStructureChanged(); 
		int TestCount=0; 
		try { 
			String url ="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+LocalDatabasePath; 
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
			con = DriverManager.getConnection(url); 
			System.out.println(con); 
			sql = con.createStatement(); 
			System.out.println(sql); 
			String SelectValue = "select BarCode,DevType,Vender,RMA,Customer,FailureInformation,TestState from VSTDatabaseLocalBackup where  Times like '"+ Times + "%' and TestState=''"; 
			rs = sql.executeQuery(SelectValue); 
			while (rs.next()) { 
				Vector<String> Result = new Vector<String>(); 
				Result.addElement(rs.getString("BarCode")); 
				Result.addElement(rs.getString("DevType")); 
				Result.addElement(rs.getString("Vender")); 
				Result.addElement(rs.getString("RMA")); 
				Result.addElement(rs.getString("Customer")); 
				Result.addElement(rs.getString("FailureInformation")); 
				if(rs.getString("TestState").equals("")) 
				{ 
					TestCount++; 
					Result.addElement("未上传检测数据"); 
				} 
				vector.addElement(Result); 
				tm.fireTableStructureChanged(); 
				//TestCount=TestCount+1; 
				ResultBoolean=true; 
			} 
			jLabel6.setText("检测到共有"+TestCount+"个记录未上传到服务器!"); 
			//System.out.println(ResultBoolean+""); 
			if(ResultBoolean==false) 
			{ 
				JOptionPane.showMessageDialog(null,"未检测到测试数据,请先上传当天的数据!!","错误信息", JOptionPane.ERROR_MESSAGE); 
			} 
			else 
			{ 
				if(TestCount>0) 
				{ 
					JOptionPane.showMessageDialog(null,"检测到共有"+TestCount+"个记录未上传到服务器!","错误信息", JOptionPane.ERROR_MESSAGE); 
				} 
				else 
				{ 
					JOptionPane.showMessageDialog(null,"所有的测试数据已经上传服务器!!","提示信息", JOptionPane.INFORMATION_MESSAGE); 
				} 
			} 
			 
			rs.close(); 
			con.close(); 
		} catch (SQLException e2) { 
			JOptionPane 
					.showMessageDialog( 
							null, 
							"数据源错误,具体信息:[Microsoft][ODBC Microsoft Access Driver], \n“(未知)”不是一个有效的路径。请检查数据源是否存在!88888", 
							"连接服务器错误信息", JOptionPane.ERROR_MESSAGE); 
		}catch (ClassNotFoundException e1) { 
			 
		} 
	} 
	private void UpdateTestState(String BarCode,String Times) 
	{ 
		Connection consecond; 
		Statement sqlsecond; 
		String ExcuteStr=""; 
		try { 
			String urlLocal ="jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+LocalDatabasePath; 
			Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); 
			consecond= DriverManager.getConnection(urlLocal); 
			sqlsecond=consecond.createStatement(); 
			ExcuteStr="update VSTDatabaseLocalBackup set TestState='已上传' where BarCode='"+BarCode+"' and Times like '"+Times+"%'"; 
			//sqlsecond.executeQuery(ExcuteStr); 
			sqlsecond.executeUpdate(ExcuteStr); 
			sqlsecond.close(); 
			consecond.close(); 
		} catch (ClassNotFoundException e) { 
			// TODO 自动生成 catch 块 
			e.printStackTrace(); 
		} catch (SQLException e) { 
			// TODO 自动生成 catch 块 
			e.printStackTrace(); 
		} 
	} 
 
	/** 
	 * This method initializes jButton4	 
	 * 	 
	 * @return javax.swing.JButton	 
	 */ 
	private JButton getJButton4() { 
		if (jButton4 == null) { 
			jButton4 = new JButton(); 
			jButton4.setBounds(new Rectangle(751, 61, 88, 20)); 
			jButton4.setText("返回"); 
			jButton4.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) { 
					TestToolsPing TestForm = new TestToolsPing(); 
					TestForm.setVisible(true); 
					setVisible(false); 
				} 
			}); 
		} 
		return jButton4; 
	} 
 
	/** 
	 * This method initializes jScrollPane	 
	 * 	 
	 * @return javax.swing.JScrollPane	 
	 */ 
	private JScrollPane getJScrollPane() { 
		if (jScrollPane == null) { 
			jScrollPane = new JScrollPane(); 
			jScrollPane.setBounds(new Rectangle(9, 101, 846, 252)); 
			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 jButton5	 
	 * 	 
	 * @return javax.swing.JButton	 
	 */ 
	private JButton getJButton5() { 
		if (jButton5 == null) { 
			jButton5 = new JButton(); 
			jButton5.setBounds(new Rectangle(487, 61, 88, 20)); 
			//jButton5.setVisible(false); 
			jButton5.setText("清空数据"); 
			jButton5.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) { 
					DeleteValueStr(); 
					ShowImportDataResultSub(); 
					 
				} 
			}); 
		} 
		return jButton5; 
	} 
 
 
	/** 
	 * This method initializes jButton6	 
	 * 	 
	 * @return javax.swing.JButton	 
	 */ 
	private JButton getJButton6() { 
		if (jButton6 == null) { 
			jButton6 = new JButton(); 
			jButton6.setBounds(new Rectangle(809, 10, 63, 20)); 
			jButton6.setText("清空"); 
			jButton6.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) { 
					jTextField2.setText(""); 
				} 
			}); 
		} 
		return jButton6; 
	} 
 
 
	/** 
	 * This method initializes jButton7	 
	 * 	 
	 * @return javax.swing.JButton	 
	 */ 
	private JButton getJButton7() { 
		if (jButton7 == null) { 
			jButton7 = new JButton(); 
			jButton7.setBounds(new Rectangle(809, 35, 63, 20)); 
			jButton7.setText("清空"); 
			jButton7.addActionListener(new java.awt.event.ActionListener() { 
				public void actionPerformed(java.awt.event.ActionEvent e) { 
					jTextField3.setText(""); 
				} 
			}); 
		} 
		return jButton7; 
	} 
 
 
	/** 
	 * This method initializes jButton8	 
	 * 	 
	 * @return javax.swing.JButton	 
	 */ 
	private JButton getJButton8() { 
		if (jButton8 == null) { 
			jButton8 = new JButton(); 
			jButton8.setBounds(new Rectangle(764, 359, 90, 17)); 
			jButton8.setText("导出数据"); 
		} 
		return jButton8; 
	} 
 
 
	public String getLocalDatabasePath() { 
		return LocalDatabasePath; 
	} 
 
 
	public void setLocalDatabasePath(){ 
		TestToolsPing Database=new TestToolsPing(); 
		LocalDatabasePath = Database.GetLocalDatabasePath(); 
		LocalBackUPdatabasePath=Database.GetLocalBackUPDatabasePath(); 
	} 
 
 
	public String getRemoteDatabasePath() {  
		return RemoteDatabasePath; 
	} 
 
 
	public void setRemoteDatabasePath() { 
		TestToolsPing Database=new TestToolsPing(); 
		RemoteDatabasePath = Database.GetRemoteDatabasePath(); 
	} 
 
}  //  @jve:decl-index=0:visual-constraint="-36,11"