📄 apsmp.c
字号:
{
lcd_csr_put(9,0);
cputstr(LCD_ATTR_WIDTH," ");
return;
}
} */
void ap_collect(void) /* (要的) */
{
char unitno[7],typeno[2],invoice[12],no[22],buffer[40];
char sum[6],bar[21],invosum[6],flag[3],choice[2],engine[21];
int i,j,len,status,k;
ER ret;
H Length=40,KeyLen=8;
W start;
W fp;
H fhnd,fmode;
lcd_cls();
lcd_csr_put( 3, 0 );
cputstr(LCD_ATTR_WIDTH,msg[16]);
lcd_csr_put( 7, 0 );
lcd_csr_set( LCD_CSR_BLOCK );
while(1)
{
memset(invoice,0x0,7);
i=read_str(4,5,2,invoice,6);
if (i==E_KEY_CLR) return;
len=strlen(invoice);
if(len!=6)
{
lcd_csr_put(9,10);
cputstr(LCD_ATTR_WIDTH,msg[23]);
Wait2( 40L );
lcd_csr_put(9,10);
cputstr(LCD_ATTR_WIDTH," ");
continue;
}
else break;
}
strcpy(infohead[5],invoice);
lcd_csr_set( LCD_CSR_OFF );
lcd_cls();
lcd_csr_put( 1, 0 );
cputstr(LCD_ATTR_WIDTH,msg[18]);
lcd_csr_put( 7, 0 );
cputstr(LCD_ATTR_WIDTH,invoice);
strcpy(bar,"");
memset(bar,0x0,21);
strcpy(engine,"");
memset(engine,0x0,21);
s_sound( 2250, 5 );
Wait2( 5L );
s_sound( 2250, 5 );
k=0;
while (1)
{
lcd_csr_put(3,0);
cputstr(LCD_ATTR_WIDTH," ");
lcd_csr_put(5,0);
cputstr(LCD_ATTR_WIDTH," ");
strcpy(bar,"");
status=2;
i=read_str(0,3,0,bar,23);
len=strlen(bar);
if (i==E_KEY_CLR)
{
lcd_csr_put(9,0);
cputstr(LCD_ATTR_WIDTH,"终止任务?[1.是 2.否]");
memset(choice,0x0,2);
j=read_str(20,9,2,choice,1);
if (choice[0]=='1')
{
close(fhnd);
break;
}
else
{
lcd_csr_put(9,0);
cputstr(LCD_ATTR_WIDTH," ");
continue;
}
}
if (i==E_KEY_CLR)
{
lcd_csr_put(9,0);
cputstr(LCD_ATTR_WIDTH,"终止任务?[1.是 2.否]");
memset(choice,0x0,2);
j=read_str(20,9,2,choice,1);
if (choice[0]=='1')
{
close(fhnd);
break;
}
else
{
lcd_csr_put(9,0);
cputstr(LCD_ATTR_WIDTH," ");
continue;
}
}
lcd_csr_put( 5, 0 );
cputstr(LCD_ATTR_WIDTH," ");
lcd_csr_put( 5, 0 );
cputstr(LCD_ATTR_WIDTH,engine);
for(j=0;j<50;j++)
{
if (strcmp(bar,check[j])==0)
{
lcd_csr_put( 9, 10 );
cputstr(LCD_ATTR_WIDTH,msg[19]);
getkey();
status=1;
lcd_csr_put( 9, 10 );
cputstr(LCD_ATTR_WIDTH," ");
break;
}
}
if (status==1) continue;
if (strlen(bar)!=23)
{
lcd_csr_put( 9, 10 );
cputstr(LCD_ATTR_WIDTH,msg[23]);
Wait2( 40L );
lcd_csr_put( 9, 10 );
cputstr(LCD_ATTR_WIDTH," ");
lcd_csr_put(9,0);
cputstr(LCD_ATTR_WIDTH,"保存?[1.是 2.否]");
memset(choice,0x0,2);
j=read_str(20,9,2,choice,1);
if (choice[0]=='1')
{
lcd_csr_put(9,0);
cputstr(LCD_ATTR_WIDTH," ");
}
else
{
lcd_csr_put(9,0);
cputstr(LCD_ATTR_WIDTH," ");
continue;
}
}
if (k==0)
{
fmode = O_CREAT | O_RDWR ;
if(( fhnd = open("goods.txt", fmode ))== E_LOWERR )
{ lcd_cls();
lcd_csr_put( 1, 0 );
cputstr(LCD_ATTR_WIDTH,"文件打开错误! ");
getkey();
return;
}
else
{
infohead[3][1]=0x0d;
infohead[4][6]=0x0d;
infohead[5][6]=0x0d;
infohead[3][2]=0x0;
infohead[4][7]=0x0;
infohead[5][7]=0x0a;
flag[0]=0x0d;
flag[1]=0x0a;
flag[2]=0x0;
lseek(fhnd,0L,2);
write(fhnd,infohead[5],8);
k++;
m++;
strcpy(check[m % 50],bar);
len=strlen(bar);
bar[len]=0x0d;
bar[len+1]=0x0a;
lseek(fhnd,0L,2);
write(fhnd,bar,len+2);
if (k==atoi(invosum))
{
lcd_csr_put( 9, 10 );
cputstr(LCD_ATTR_WIDTH,"发货完毕");
s_sound( 2250, 5 );
Wait2( 5L );
s_sound( 2250, 5 );
getkey();
lcd_csr_put( 9, 10 );
cputstr(LCD_ATTR_WIDTH," ");
break;
}
continue;
}
}
infohead[3][1]=0x0d;
infohead[4][6]=0x0d;
infohead[5][11]=0x0d;
infohead[3][2]=0x0;
infohead[4][7]=0x0;
infohead[5][7]=0x0;
flag[0]=0x0d;
flag[1]=0x0a;
flag[2]=0x0;
k++;
m++;
strcpy(check[m % 50],bar);
len=strlen(bar);
bar[len]=0x0d;
bar[len+1]=0x0a;
lseek(fhnd,0L,2);
write(fhnd,bar,len+2);
if (k==atoi(invosum))
{
lcd_csr_put( 9, 10 );
cputstr(LCD_ATTR_WIDTH,"发货完毕");
s_sound( 2250, 5 );
Wait2( 5L );
s_sound( 2250, 5 );
getkey();
lcd_csr_put( 9, 10 );
cputstr(LCD_ATTR_WIDTH," ");
break;
}
}
close(fhnd);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -