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

📄 seachresult.java

📁 自行开发的j2me小软件
💻 JAVA
字号:
 /*
 * 创建日期 2005-1-31
 *
 * TODO 要更改此生成的文件的模板,请转至
 * 窗口 - 首选项 - Java - 代码样式 - 代码模板
 */
package src;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.rms.RecordEnumeration;
import javax.microedition.rms.RecordStore;

/**
 * @author ryu-java
 *
 * TODO 要更改此生成的类型注释的模板,请转至
 * 窗口 - 首选项 - Java - 代码样式 - 代码模板
 */
public class SeachResult extends myScreen{
	
	Form SeachResult=new Form("*搜索结果*");
	Command Back =new Command("返回",Command.SCREEN,2);
	//Command NextPage =new Command("下一页",Command.SCREEN,1);
	//Command PreviousPage =new Command("上一页",Command.SCREEN,1);
	
	String tempDBname;
	int tempYear;
	int tempMonth;
	int tempDay;
	int tempOver;
	int tempUnder;
	String tempName;
	boolean ok=false;
	
	int moneySum=0;
	int rsSum=0;
	RecordEnumeration re;
	RecordStore DataS;
	MoneyData vd;
	
	public SeachResult(String DBname,int year,int month,int day,int over,int under,String name)
	{
	 tempDBname=DBname;
	 tempYear=year;
	 tempMonth=month;
	 tempDay=day;
	 tempOver=over;
	 tempUnder=under;
	 tempName=name;
	}
	
	public SeachResult()
	{
	 this(null,0,0,0,0,0,null);	
	}
	
	public void Init()
	{
		vd=new MoneyData();
	   	vd.setDBname(tempDBname);
		DataS=vd.openRS();
		try
		{
		re=DataS.enumerateRecords(null,null,false);
		
		int id;
		int tpDate;
		int tpMoney;
		String tpName;
		int tpY;
		int tpM;
		int tpD;
		String tpsum="";
		long start=System.currentTimeMillis();
		while(re.hasNextElement())
		{
			id=re.nextRecordId();
			byte tmp[]=DataS.getRecord(id);
			vd.decode(tmp);
			tpDate=vd.getDate();
			tpMoney=vd.getSum();
			tpName=vd.getName();
			tpY=tpDate/10000;
			tpM=(tpDate%10000)/100;
			tpD=tpDate%100;
			//System.out.println("year:"+tempYear+"month:"+tempMonth+"day:"+tempDay+"datatype:"+tempDBname);
			//System.out.println("zyear:"+tpY+"zmonth:"+tpM+"zday:"+tpD);
			if(tempYear==tpY){
				if(tempMonth==tpM||tempMonth==0){
					if(tempDay==tpD||tempDay==0){
						if(tpMoney>tempOver||tempOver==0){
							if(tpMoney<tempUnder||tempUnder==0){
								
								if(tempName.length()==0||(tpName.indexOf(".")==-1)&&(tpName.indexOf(tempName)!=-1)){
									tpsum=Integer.toString(vd.getSum()/100)+"."+ 
									(((vd.getSum()%100))>10?Integer.toString(vd.getSum()%100):
										("0"+Integer.toString(vd.getSum()%100)));	
			                      SeachResult.append("单号ID: "+id+"\n"+"日期:"+
			                      		vd.getDate()+"\n"+"名称:"+vd.getName()+
										" \n"+"金额:"+tpsum+"元\n"+
										"------------\n");
			                           rsSum++;
			                           moneySum+=tpMoney;
			                           
								}else {
									       	String st=tempName.toString();
									       	while(st.indexOf(".")!=-1&&(!ok)){
									     	int f=st.indexOf(".");
									     	String fs=st.substring(0,f);
									     	st=st.substring(f+1);
									     	if(tpName.indexOf(fs)!=-1)
									     		ok=true;
									     	  	}
									     	if(tpName.indexOf(st)!=-1)
									     		ok=true;
									     	if(ok)
									     	{
									     		tpsum=Integer.toString(vd.getSum()/100)+"."+ 
												(((vd.getSum()%100))>10?Integer.toString(vd.getSum()%100):
													("0"+Integer.toString(vd.getSum()%100)));	
						                      SeachResult.append("单号ID: "+id+"\n"+"日期:"+
						                      		vd.getDate()+"\n"+"名称:"+vd.getName()+
													" \n"+"金额:"+tpsum+"元\n"+
													"------------\n");
						                           rsSum++;
						                           moneySum+=tpMoney;	
						                           ok=false;
									     	}
									  								
								       }
							}
						}
					}
				}
			}
		}
		DataS.closeRecordStore();
		tpsum=Integer.toString(moneySum/100)+"."+ 
		(((moneySum%100))>10?Integer.toString(moneySum%100):
			("0"+Integer.toString(moneySum%100)));	
		long end=System.currentTimeMillis();
		SeachResult.setTitle("搜索结果"+rsSum+"个");
		SeachResult.append("$总金额:"+tpsum+"元");
		SeachResult.append("\n搜索用时:"+(end-start)+"ms");
		
		
		}catch(Exception e)
		{
			//System.out.println("\nerror!");
		}
		
		
		
		
		//this.addCommand(NextPage);
		//this.addCommand(PreviousPage);
		this.addCommand(Back);
		this.setMainForm(SeachResult);
		this.installCommands();
	}	
	
	public int handleCommand (Command cmd,Displayable s)
	{
		 if(cmd==Back)
		    {
		 	
			return myScreen.SEARCHFORM;
		    }
	
		 return myScreen.WITHOUT;
	}
	

}

⌨️ 快捷键说明

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