📄 apsmp.c
字号:
/******************************************************************************
** System name : 盘点软件 **
** Detail : Main routine **
** File name : apsmp.C **
** Version : 2.00 (Chinese) **
** Author : Yan Hongxin **
*******************************************************************************
******************************************************************************/
/* Header files */
#include <stdio.h>
#include <string.h>
#include "itron.h"
#include "cmndef.h"
#include "bios1mac.h"
/*----------------------*
** Prototype define **
*----------------------*/
void MenuOpening( void );
void work(void);
void Stock(void);
void Comm(void);
void Initial(void);
void delfile(void);
void addzero(UB *str,H len);
/* Global variables */
UB fgoods[20];
extern H COM=COM0;
/******************************************************************************
** Routine name: apstart **
** Detail : Entry main function **
** Parameter : None **
** Return value: None **
** Author : Fuji Software Inc. **
******************************************************************************/
void ap_start( void )
{
Initial();
alert(3); /* sound 3 times */
MenuOpening(); /* display opening message */
Wait2( 20L ); /* Waiting for 20 unit time */
work(); /* main work function */
exit(0); /* end of program */
}
void Initial(void)
{
DAT_DSP_STR disp_set;
obr_change(0); /* set the kinds of barcode abled to be scanned */
dat_system( SYSD_FNC_READ, SYSD_DSP, &disp_set );
disp_set.font_md = FONT6_SET;
dat_system( SYSD_FNC_WRITE, SYSD_DSP, &disp_set );
strcpy(fgoods,"goods.txt");
}
/******************************************************************************
** Routine name: MenuOpening **
** Detail : opening message search and display **
** Parameter : none **
** Return value: none **
** Author : Fuji Software Inc. **
******************************************************************************/
void MenuOpening( void )
{
UB msg[][17]={
" 欢迎使用",
" DT-900 ",
" 手持终端机",
" 卡西欧浪潮公司"};
H cnt, x, y;
lcd_cls(); /* clear the display */
for( x=0,y=1,cnt=0; cnt<4; y+=2,cnt++ )
Dsp_str(msg[cnt],y,x); /* display the menu */
}
void work(void)
{
H x,y,cnt,code;
ER fn;
UB msg[][17]={" 盘点系统",
" ",
" 1:盘点",
" 2:数据上传",
" 3:删除" };
for(;;)
{
lcd_cls();
for( x=0,y=1,cnt=0; cnt<5; y+=2,cnt++ )
Dsp_str(msg[cnt],y,x);
code=getkey();
switch (code)
{
case '1':
Stock(); /* 盘点模块 */
break;
case '2':
if((fn = open( fgoods, O_RDONLY)) == E_LOWERR )
{
lcd_cls();
Dsp_str("文件无数据",3,0,1);
Wait2(40L);
close(fn);
break;
}
close(fn);
sendfile("goods txt"); /* send data to the computer */
break;
case '3':
delfile(); /* delete the data */
break;
default:
break;
}
}
}
void Stock(void)
{
ER i,j,ret,fn,num,numnew;
UB numstr[8],data[30],BarCode[20];
W lno;
H NumLen=5,KeyLen=18;
H Length;
Length=NumLen+KeyLen+2;
if(( fn = open(fgoods, O_CREAT | O_RDWR))== E_LOWERR )
{
lcd_cls();
Dsp_str("File Open Error!",0,1);
Wait2(15L);
close(fn);
return; /* No Files */
}
for(;;)
{
lcd_cls();
Dsp_str("扫描条码:",1,0);
memset(BarCode,0x0,14);
ret=read_str(3,0,0,BarCode,KeyLen); /* scan the barcode */
if (ret==E_KEY_CLR) break;
if ( strlen(BarCode)==0) continue;
Dsp_str(BarCode,3,0);
memset(data,0,20);
ret=dat_F_Search(fgoods,0L,Length,0,KeyLen,BarCode,data,&lno); /* search function for the certain record */
if(ret==E_OK)
{
for(i=KeyLen,j=0;j<NumLen;i++,j++) numstr[j]=data[i];
numstr[j]=0x0;
num=atoi(numstr);
Dsp_str("已有数量:",5,0);
Dsp_str(numstr,5,10);
Dsp_str("数量:",7,0);
memset(numstr,0x0,NumLen);
read_str(7,6,2,numstr,NumLen); /* entry the number */
numnew=atoi(numstr);
sprintf(numstr,"%5d",num+numnew);
lseek(fn,lno,0);
}
else
{
Dsp_str("已有数量: 0",5,0);
Dsp_str("数量:",7,0);
memset(numstr,0x0,NumLen);
read_str(7,6,2,numstr,NumLen);
numnew=atoi(numstr);
sprintf(numstr,"%5d",numnew);
lseek(fn,0L,2);
}
write(fn,BarCode,KeyLen);
write(fn,numstr,NumLen);
write(fn,"\x0d\x0a",2);
}
close(fn);
}
void delfile(void)
{
ER code;
ER fn;
if((fn = open( fgoods, O_RDONLY)) == E_LOWERR )
{
lcd_cls();
Dsp_str("文件无数据",3,0,1);
Wait2(20L);
close(fn);
return;
}
close(fn);
lcd_cls();
Dsp_str("上传文件删除?",1,0);
Dsp_str("ENT:确认",3,0);
Dsp_str("CLR:取消",5,0);
code=getkey();
if(code==12) return;
else
dat_fdel(fgoods); /* delete the file*/
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -