📄 viewdata.java
字号:
/*
* 创建日期 2005-1-28
*
* 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 ViewData extends myScreen{
Form ViewDataF=new Form("*收入单查看*");
Command Back =new Command("返回",Command.SCREEN,2);
Command NextPage =new Command("下一页",Command.SCREEN,1);
//Command PreviousPage =new Command("上一页",Command.SCREEN,1);
String tpsum="";
String DBname;
RecordEnumeration re;
RecordStore DataS;
MoneyData vd;
public ViewData(int tag)
{
switch(tag)
{
case myScreen.INCOMETAG:
DBname=myScreen.INCOME;
ViewDataF.setTitle("*收入单查看*");
break;
case myScreen.OUTGOTAG:
DBname=myScreen.OUTGO;
ViewDataF.setTitle("*支出单查看*");
break;
case myScreen.BORROWTAG:
DBname=myScreen.BORROW;
ViewDataF.setTitle("*借出单查看*");
break;
case myScreen.LENDTAG:
DBname=myScreen.LEND;
ViewDataF.setTitle("*借入单查看*");
break;
}
}
public ViewData()
{
this(myScreen.INCOMETAG);
}
public void Init()
{
vd=new MoneyData();
vd.setDBname(DBname);
DataS=vd.openRS();
try
{
re=DataS.enumerateRecords(null,null,false);
//RDsum=re.numRecords();
}catch(Exception e)
{
}
String tpsum="";
int j=0;
while(j<10)
{
try
{
int id=re.nextRecordId();
byte tmp[]=DataS.getRecord(id);
vd.decode(tmp);
tpsum=Integer.toString(vd.getSum()/100)+"."+ (((vd.getSum()%100))>10?Integer.toString(vd.getSum()%100):("0"+Integer.toString(vd.getSum()%100)));
ViewDataF.append("单号ID: "+id+"\n"+"日期:"+vd.getDate()+"\n"+"名称:"+vd.getName()+" \n"+
"金额:"+tpsum+" 元\n"+"------------\n");
j++;
}catch(Exception e)
{
break;
}
}
this.addCommand(NextPage);
//this.addCommand(PreviousPage);
this.addCommand(Back);
this.setMainForm(ViewDataF);
this.installCommands();
}
public int handleCommand (Command cmd,Displayable s)
{
if(cmd==NextPage)
{
NextPageM();
}
else if(cmd==Back)
{
try
{
DataS.closeRecordStore();
}catch(Exception e)
{
}
return myScreen.VIEWFORM;
}
// else if(cmd==PreviousPage)
{
// PreviousPageM();
}
return myScreen.WITHOUT;
}
private void NextPageM()
{
int tmpSize=ViewDataF.size();
if(re.hasNextElement())
{
for(int i=0;i<tmpSize;i++)
{
ViewDataF.delete(0);
}
int j=0;
boolean tag=true;
while(j<10&&tag)
{
try
{
int id=re.nextRecordId();
byte tmp[]=DataS.getRecord(id);
vd.decode(tmp);
//System.out.println("test");
tpsum=Integer.toString(vd.getSum()/100)+"."+ (((vd.getSum()%100))>10?Integer.toString(vd.getSum()%100):("0"+Integer.toString(vd.getSum()%100)));
ViewDataF.append("单号ID: "+id+"\n"+"日期:"+vd.getDate()+"\n"+"名称:"+vd.getName()+" \n"+
"金额:"+tpsum+" 元\n"+"------------\n");
j++;
}catch(Exception e)
{
break;
}
}
tag=re.hasNextElement();
}
}
/* private void PreviousPageM()
{
int tmpSize=ViewDataF.size();
if(re.hasPreviousElement())
{
for(int i=0;i<tmpSize;i++)
ViewDataF.delete(0);
if(re.hasPreviousElement())
{
int j=0;
boolean tag=true;
while(j<10&&tag)
{
try
{
int id=re.previousRecordId();
byte tmp[]=DataS.getRecord(id);
vd.decode(tmp);
//System.out.println("testP");
tpsum=Integer.toString(vd.getSum()/100)+"."+
(((vd.getSum()%100))>10?Integer.toString(vd.getSum()%100):
("0"+Integer.toString(vd.getSum()%100)));
ViewDataF.append("单号ID: "+id+"\n"+"日期:"+vd.getDate()+"\n"+
"名称:"+vd.getName()+" \n"+"金额:"+tpsum+" 元\n"+"------------\n");
j++;
}catch(Exception e)
{
break;
}
}
//System.out.println("test123");
}
}
}
*/
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -