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

📄 dataedit.java

📁 gpsLogger是一个基于手机或PDA的个人移动导航(车载导航)系统中记录gps信息的小工具
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
						previousRecord();
					}
				}break;
				case 6:{ // Next Record, (">>") button
					edAtual = getParentWindow().getFocus();
					if (edAtual != null) {
						nextRecord();
					}
				}break;
				case 7:{ // Last Record, (">>||") button
					edAtual = getParentWindow().getFocus();
					if (edAtual != null) {
						lastRecord();
					}
				}break;	            	 
				}	
			}      	
		}	 			    	           	
	}       	  
	public void firstRecord(){ 
		ResultSet rs = driver.executeQuery("select rowid,time_stamp,species,surveycount,location,terrain,latitude,latns,longitude,longew,sky,water,overall,live from surveyDB");		
		rs.first();   	  
		edTimestamp.setText(rs.getString("time_stamp"));
		edSpecies.setText(rs.getString("species"));
		edCount.setText(rs.getString("surveycount"));
		edLocation.setText(rs.getString("location"));
		edTerrain.setText(rs.getString("terrain"));
		edLatitude.setText(rs.getString("latitude"));
		edLatns.setText(rs.getString("latns"));
		edLongitude.setText(rs.getString("longitude"));
		edLongew.setText(rs.getString("longew"));
		edSky.setText(rs.getString("sky"));
		edWater.setText(rs.getString("water"));
		edOverall.setText(rs.getString("overall"));
		edLive.setText(rs.getString("live"));		
		edRowId.setText(rs.getString("rowid")); 
		rs.close();
	}	
	public void previousRecord(){//tweaked to keep iRowId zero from displaying
		szRowId = edRowId.getText();
		iRowId = Convert.toInt(szRowId);	
		ResultSet rs = driver.executeQuery("select rowid,time_stamp,species,surveycount,location,terrain,latitude,latns,longitude,longew,sky,water,overall,live from surveyDB where rowid <"+iRowId);
		if ((rs.getString("rowid").compareTo("0")==0)){//keeps always empty iRowId #0 from being displayed and confusing people...
			rs.close();
			rs = driver.executeQuery("select rowid,time_stamp,species,surveycount,location,terrain,latitude,latns,longitude,longew,sky,water,overall,live from surveyDB");//full recordset is returned							
		}
		else{//...if iRowId 1 or >...
			rs.last();
			edTimestamp.setText(rs.getString("time_stamp"));
			edSpecies.setText(rs.getString("species"));
			edCount.setText(rs.getString("surveycount"));
			edLocation.setText(rs.getString("location"));
			edTerrain.setText(rs.getString("terrain"));
			edLatitude.setText(rs.getString("latitude"));
			edLatns.setText(rs.getString("latns"));
			edLongitude.setText(rs.getString("longitude"));
			edLongew.setText(rs.getString("longew"));
			edSky.setText(rs.getString("sky"));
			edWater.setText(rs.getString("water"));
			edOverall.setText(rs.getString("overall"));
			edLive.setText(rs.getString("live"));		
			edRowId.setText(rs.getString("rowid"));
			rs.close();
		}
	}	
	public void nextRecord(){//tweaked to keep iRowId zero from displaying
		szRowId = edRowId.getText();
		iRowId = Convert.toInt(szRowId);
		ResultSet rs = driver.executeQuery("select rowid,time_stamp,species,surveycount,location,terrain,latitude,latns,longitude,longew,sky,water,overall,live from surveyDB where rowid >"+iRowId); //...returns all records greater than current, unless there are no more in which case zero is returned.
		
		if ((rs.getString("rowid").compareTo("0")==0)){//keeps always empty iRowId #0 from being displayed and confusing people...
			rs.close(); //dumps rs, below makes full rs
			rs = driver.executeQuery("select rowid,time_stamp,species,surveycount,location,terrain,latitude,latns,longitude,longew,sky,water,overall,live from surveyDB");//full recordset is returned	
			rs.last();	//only last record in rs is shown					
		}else{ 
			rs.first(); //shows first record of first rs above w/all of the > iRowId records   	 
		}    	  
		edTimestamp.setText(rs.getString("time_stamp"));
		edSpecies.setText(rs.getString("species"));
		edCount.setText(rs.getString("surveycount"));
		edLocation.setText(rs.getString("location"));
		edTerrain.setText(rs.getString("terrain"));
		edLatitude.setText(rs.getString("latitude"));
		edLatns.setText(rs.getString("latns"));
		edLongitude.setText(rs.getString("longitude"));
		edLongew.setText(rs.getString("longew"));
		edSky.setText(rs.getString("sky"));
		edWater.setText(rs.getString("water"));
		edOverall.setText(rs.getString("overall"));
		edLive.setText(rs.getString("live"));		
		edRowId.setText(rs.getString("rowid"));
		rs.close();
	}	
	public void lastRecord(){   	  
		ResultSet rs = driver.executeQuery("select rowid,time_stamp,species,surveycount,location,terrain,latitude,latns,longitude,longew,sky,water,overall,live from surveyDB");
		rs.last();   	  
		edTimestamp.setText(rs.getString("time_stamp"));
		edSpecies.setText(rs.getString("species"));
		edCount.setText(rs.getString("surveycount"));
		edLocation.setText(rs.getString("location"));
		edTerrain.setText(rs.getString("terrain"));
		edLatitude.setText(rs.getString("latitude"));
		edLatns.setText(rs.getString("latns"));
		edLongitude.setText(rs.getString("longitude"));
		edLongew.setText(rs.getString("longew"));
		edSky.setText(rs.getString("sky"));
		edWater.setText(rs.getString("water"));
		edOverall.setText(rs.getString("overall"));
		edLive.setText(rs.getString("live"));	
		edRowId.setText(rs.getString("rowid"));
		rs.close();		
	}
	private void doInsertUpdate(boolean isInsert){		
		String szTime_stamp = edTimestamp.getText();
		String szSpecies = edSpecies.getText();
		String szCount = edCount.getText();
		String szLocation = edLocation.getText();
		String szTerrain = edTerrain.getText();
		String szLatitude = edLatitude.getText();
		String szLatns = edLatns.getText();
		String szLongitude = edLongitude.getText();
		String szLongew = edLongew.getText();
		String szSky = edSky.getText();
		String szWater = edWater.getText();
		String szOverall = edOverall.getText();
		String szLive = edLive.getText();
		
		long lastUpdated = new Time().getTimeLong();
		int rows = -1;
		try{
			if (isInsert){
				//rows = driver.executeUpdate("insert into surveyDB values ('"+szTime_stamp+"','"+szLocation+"','"+szCount+"',"+lastUpdated+")");
				rows = driver.executeUpdate("insert into surveyDB values ('"+szTime_stamp+"','"+szSpecies+"','"+szCount+"','"+szLocation+"','"+szTerrain+"','"+szLatitude+"','"+szLatns+"','"+szLongitude+"','"+szLongew+"','"+szSky+"','"+szWater+"','"+szOverall+"','"+szLive+"',"+lastUpdated+")");				
			}else
				//rows = driver.executeUpdate("update surveyDB set time_stamp='"+szTime_stamp+"', location='"+szLocation+"', surveycount='"+szCount+"', lastUpdated="+lastUpdated+" where rowid="+iRowId);
				rows = driver.executeUpdate("insert into surveyDB values ('"+szTime_stamp+"','"+szSpecies+"','"+szCount+"','"+szLocation+"','"+szTerrain+"','"+szLatitude+"','"+szLatns+"','"+szLongitude+"','"+szLongew+"','"+szSky+"','"+szWater+"','"+szOverall+"','"+szLive+"',"+lastUpdated+")");
			
			if (rows == 1){
				gpsDataLogger.invalidateRS();
				clear();
			}else Sound.beep();
		} catch (Throwable t) {Vm.debug(t.getMessage());}
	}	
	private void doDelete(){   	  
		int rows = driver.executeUpdate("delete surveyDB where rowid="+iRowId);
		//new MessageBox("Debug","Made it past delete function.").popupModal();
		clear();
		if (rows == 1){
			//gpsDataLogger.invalidateRS();//WHY DO WE NEED THIS HERE???
			clear();
		}else Sound.beep();
	}
	public void clear(){
		edTimestamp.setText("");
		edSpecies.setText("");
		edCount.setText("");
		edLocation.setText("");
		edTerrain.setText("");
		edLatitude.setText("");
		edLatns.setText("");
		edLongitude.setText("");
		edLongew.setText("");
		edSky.setText("");
		edWater.setText("");
		edOverall.setText("");
		edLive.setText("");		
		edRowId.setText("");		
	}	
	/***************************************************************
	 *   TrackLog- Saves Lat/Long coordinates as survey progresses
	 *   in a separate trackLog table. Makes and saves a timestamp, 
	 *   and fetches and stores current Lat/Long coordinates. 
	 ***************************************************************/
	protected void trackLog(){
		//if (gpsDataLogger.iTrackLogFlag == 1){//set to 1 on menu dropdown
		String szLatitude = "";
		String szLongitude = "";
		String szLatns = "";
		String szLongew = "";
		szLatitude = gpsDataLogger.szLat;
		szLatns = gpsDataLogger.szLatNs;
		szLongitude = gpsDataLogger.szLong;
		szLongew = gpsDataLogger.szLongEw;
		
		//if szLattitude or szLongitude == "", resets string to "No GPS signal..."
		if ((szLatitude.compareTo("")==0) || (szLongitude.compareTo("")==0)){
			szLongitude = szLatitude = "No GPS signal...";
		}
		
		long T = new Time().getTimeLong();
		String szTime_stamp = Convert.toString(T,1);	   	        	   	        	            
		
		long lastUpdated = new Time().getTimeLong();	   	        
		int rows = -1;	            	   	        
		rows = driver.executeUpdate("insert into trackLog values ('"+szTime_stamp+"','"+szLatitude+"','"+szLatns+"','"+szLongitude+"','"+szLongew+"')");				
	}
	
	public void show(String rowid){//shows selected grid record in Data Entry form
		this.iRowId = Convert.toInt(rowid);
		ResultSet rs = driver.executeQuery("select * from surveyDB where rowid = "+this.iRowId);
		if (!rs.next()){
			status("Row id not found: "+this.iRowId);
			clear();
		}else{		
			edTimestamp.setText(rs.getString("time_stamp"));
			edSpecies.setText(rs.getString("species"));
			edCount.setText(rs.getString("surveycount"));
			edLocation.setText(rs.getString("location"));
			edTerrain.setText(rs.getString("terrain"));
			edLatitude.setText(rs.getString("latitude"));
			edLatns.setText(rs.getString("latns"));
			edLongitude.setText(rs.getString("longitude"));
			edLongew.setText(rs.getString("longew"));
			edSky.setText(rs.getString("sky"));
			edWater.setText(rs.getString("water"));
			edOverall.setText(rs.getString("overall"));
			edLive.setText(rs.getString("live"));	
			//	edRowId.setText(rs.getString("rowid"));   
			
			/*
			 * Convert other rowid to edRowId commands to below???
			 */
			
			edRowId.setText(Convert.toString(iRowId, 1));
			/*.....below code doesn't work...don't bother w/it.
			 "edRowId.setText(rs.getString("rowid"))" ;
			 */
			long lastUpdated = rs.getLong("lastupdated");
			Time t = new Time(lastUpdated);
			status("Last updated: "+new Date(t)+" "+t);
		}
	}	
	public void status(String msg){
		lbStatus.setText(msg);
	}	
}

⌨️ 快捷键说明

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