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

📄 keypad.c

📁 欣技8000 资料 很适用的资料
💻 C
📖 第 1 页 / 共 3 页
字号:
			create_index(repeat_file, 1, 0, 20);
		}
		clr_scr();
		gotoxy(0, 1);
		if(SysParam.language == 1)
			puts("serial:");
		else 
			scputs("序号:");
		gotoxy(0,7);
		if(SysParam.language == 1)
			puts("left:");
		else 
			scputs("数量:");
		num = 0;
		while(1)
		{
			i = read_skey(0, 3, serial_code, 20, 0);
			if(i == -1)
			{
				//把临时的数据库删除
				remove("REPEAT");
				goto OUTPUTEND;
			}
			if(*serial_code == 0)
			{
				clr_scr();
				gotoxy(0, 1);
				puts("empty!");
				OSTimeDly(200);
				continue;
			}
			//判断序号是否重复
			//if(重复) continue
			//else 把序号回入到临时数据库中
			if(has_member(repeat_file, 1, serial_code))
			{
				clr_scr();
				gotoxy(0, 1);
				puts("repeat!");
				OSTimeDly(200);
				clr_scr();
				gotoxy(0, 1);
				if(SysParam.language == 1)
					puts("serial:");
				else 
					scputs("序号:");
				gotoxy(0,7);
				if(SysParam.language == 1)
					puts("left:");
				else 
					scputs("数量:");
				gotoxy(6,7);
				printf("%4d",num);
					continue;
			}
			else
			{
				add_member(repeat_file, serial_code);
			}
			get_time(curtime);
			sprintf(databuf, "%s,%s,%s,%s,1,%s,%s",oper_code, oshee_code, cust_code, good_code, serial_code, curtime);
			appendln(output_file, databuf);
			num++;
			gotoxy(6,7);
			printf("%4d",num);
		}//while
	}//else if

	if(SysParam.ocust == 1)
	{
		clr_scr();
		gotoxy(0, 3);
		if(SysParam.language == 1)
			puts("go on for");
		else 
			scputs("继续对该客户");
		gotoxy(0, 5);
		if(SysParam.language == 1)
			puts("the customer");
		else 
			scputs("出货吗");
		gotoxy(0, 7);
		scputs("1 YES  2 NO");
		while(1)
		{
			c = getchar();
			if(c == '1')
				goto INPUTGOOD;
			else if(c == '2')
			{
				break;
			}
			OSTimeDly (8);
		}//while
	}	
	if(SysParam.oshee == 1)
	{
		clr_scr();
		gotoxy(0, 3);
		if(SysParam.language == 1)
			puts("go on for");
		else 
			scputs("继续对该出");
		gotoxy(0, 5);
		if(SysParam.language == 1)
			puts("the sheet");
		else 
			scputs("货单操作吗");
		gotoxy(0, 7);
		scputs("1 YES  2 NO");
		while(1)
		{
			c = getchar();
			if(c == '1')
				goto INPUTCUST;
			else if(c == '2')
			{
				break;
			}
			OSTimeDly (8);
		}//while
	}
OUTPUTEND:
	;
}

/*
    int  x;         x position for display 
    int  y;         x position for display 
    char *s;	    returned string read from	keyboard 
    int	 num;	    number of	key to be read 
    int	 type;	    0/1, digit/alpha-num 
*/
int read_nkey(int x, int y, char *s, int num, int type)

{
    int index;
    int	l=0;
    char dummy[30];
    char c;
    dummy[0]=0x00;

    for (index=0; index <num; index++)
      {strcat(dummy," ");}
    gotoxy(x,y);
    printf("%s",dummy);
    gotoxy(x,y);

k1: SetCursor(1);
    while(1) 
	{   
        while( (c=getchar()) == 0x00 );
        if ( ((type != 0) && (isalnum(c))) || ((type==0) && (isdigit(c)))|| c=='+' || c=='$' ||c=='/' ||c=='*'||c=='-'||c=='%'||c==':'||c==' ' )
		{
            if(l==0)
            {
				gotoxy(x,y);
				printf("%s",dummy);
				gotoxy(x,y);
            }
            if (l >= num) 
			{
                beep_err();   /* correct type */
			} 
			else 
			{
                putchar(c);
				s[l++]=c;
			}
		} 
		else switch (c) 
		{
            case KEY_CR :       /*COMPLETE*/
				s[l]=0x00;
				SetCursor(0);
				return(0);
            case KEY_ESC :      /* abandom */
				SetCursor(0);
				s[0]=0x00;
                return(-1);
            case KEY_BS :       /* erase last key */
                if (l == 0) 
				{
					beep_err(); 
				}
				else 
				{
					l--;
                    s[l]=0x00;
                    gotoxy(x,y);
                    printf("%s",dummy);
                    gotoxy(x,y);
                    printf("%s",s);
				}
				break;
			default :
				break;
		}//else switch (c)
    }//while(1)
}

/*
	key input with laser scan 
    int  x;        x position for display 
    int  y;        x position for display 
    char *s;	   returned string read from	keyboard 
    int	 num;	   number of key to be read 
    int	 type;	   0/1, digit/alpha-num 
*/
int read_skey(int x, int y, char *s, int num, int type)
{
    int index;
    int	l=0;
    int pflag=0;
    char dummy[30];
    char c;
    dummy[0]=0x00;
    for (index=0; index <num; index++)
    {
		strcat(dummy," ");
	}
    SetCursor(1);
    gotoxy(x,y);
    InitScanner1 (); //test
k1: 
    while(1)
	{
		if(Decode())
        {
			if(strlen(CodeBuf)<=13)
			{
				beep_ok();
				gotoxy(x,y);
				printf("%s",CodeBuf);
				strcpy(s,CodeBuf);
				SetCursor(0);
				HaltScanner1 (); //test
				return(0);
			}
			else beep_err();
        }

		if ((c=getchar())!=0x00)
		{
			if (c == 32 || c== '-')  /* space */
           {
				if (l >= num)
				{
                //SetCursor(0);
                /*beep_err();*/   /* correct type */
				}
				else 
				{
					/*beep_ok();*/
					if(pflag==0)
					{
						pflag=1;
						gotoxy(x,y);
						SetCursor(1);
						printf("%s",dummy);
						gotoxy(x,y);
					}
					if(c==32)
					{
						putchar(' ');
						s[l++]=32;

					}
					else 
					{
						putchar('-');
						s[l++]=32;
					}
					if (l==num) 
						gotoxy(14,3);
				}//else
			}//if
			else if ( ((type!=0) && (isalnum(c))) || ((type==0) && (isdigit(c)))|| c=='+' || c=='$' ||c=='/' ||c=='*'||c=='%'||c==':' )
			{
				if (l >= num)
				{
                //SetCursor(0);
                //beep_err();   /* correct type */
				}
				else
				{
					if(pflag==0)
					{
						pflag=1;
						gotoxy(x,y);
						SetCursor(1);
						printf("%s",dummy);
						gotoxy(x,y);
					}
					putchar(c);
					s[l++]=c;        
				}
			} 
			else switch (c) 
			{
            case KEY_UP :       //QTY +
                SetCursor(0);
                return(-3);
            case KEY_DOWN :     //QTY -
                SetCursor(0); 
                return(-4);
            case KEY_CR :       /*COMPLETE*/
				s[l]=0x00;
				SetCursor(0);
                HaltScanner1 (); //test
				return(0);
            case KEY_ESC :      /*  abandom */
				SetCursor(0);
				s[0]=0x00;
                HaltScanner1 (); //test
                if(l==0) return(-1);
                else return(-8);
            case KEY_BS :           /* erase last key */
                if (l == 0) { beep_err(); }
                else
				{
					l--;
                    s[l]=0x00;
                    gotoxy(x,y);
                    printf("%s",dummy);
                    gotoxy(x,y);
                    printf("%s",s);
				}
				break;
			default :
                break;
			}//else switch (c)
		}//if ((c=getchar())!=0x00)
	}//while
}

void SetIOperInput(BYTE c)
{
	switch (c)
	{
	case KEY_UP:
		if (nSelection > 1)
			nSelection--;
		else 
			nSelection = 2;
		SetIOperMenu(0);
		break;
        
	case KEY_DOWN:
		if (nSelection < 2)
			nSelection++;
		else 
			nSelection = 1;

		SetIOperMenu(0);
		break;

	case KEY_CR:
		SetIOperInput((BYTE) nSelection+'0');
        break;

	case KEY_ESC:
		nSelection = 1;	
		IFlowMenu(1);
		break;
		    
	case '1': //include
		if(SysParam.ioper == 0 )//if is exclude
		{
			SysParam.ioper = 1;
			modify_flag = 1;
		}
		nSelection = 1;	
		IFlowMenu(1);
        break;

	case '2': //exclude
		if(SysParam.ioper  == 1)//if is include
		{
			SysParam.ioper = 0;//exclude
			modify_flag = 1;
		}
		nSelection = 1;	
		IFlowMenu(1);
        break;

    default:
        break;

	}
}
void SetIsheeInput(BYTE c)
{
	switch (c)
	{
	case KEY_UP:
		if (nSelection > 1)
			nSelection--;
		else 
			nSelection = 2;

		SetIsheeMenu(0);
		break;
        
	case KEY_DOWN:
		if (nSelection < 2)
			nSelection++;
		else 
			nSelection = 1;

		SetIsheeMenu(0);
		break;

	case KEY_CR:
		SetIsheeInput((BYTE) nSelection+'0');
        break;

	case KEY_ESC:
		nSelection = 2;	
		IFlowMenu(1);
		break;
		    
	case '1': //include
		if(SysParam.ishee == 0 )//if is exclude
		{
			SysParam.ishee = 1;
			modify_flag = 1;
		}
		nSelection = 2;	
		IFlowMenu(1);
        break;

	case '2': //exclude
		if(SysParam.ishee == 1)//if is include
		{
			SysParam.ishee = 0;//exclude
			modify_flag = 1;
		}
		nSelection = 2;	
		IFlowMenu(1);
        break;

    default:
        break;

	}
}

void SetProvInput(BYTE c)
{
	switch (c)
	{
	case KEY_UP:
		if (nSelection > 1)
			nSelection--;
		else 
			nSelection = 2;

		SetProvMenu(0);
		break;
        
	case KEY_DOWN:
		if (nSelection < 2)
			nSelection++;
		else 
			nSelection = 1;

		SetProvMenu(0);
		break;

	case KEY_CR:
		SetProvInput((BYTE) nSelection+'0');
        break;

	case KEY_ESC:
		nSelection = 3;	
		IFlowMenu(1);
		break;
		    
	case '1': //include
		if(SysParam.iprov == 0 )//if is exclude
		{
			SysParam.iprov = 1;
			modify_flag = 1;
		}
		nSelection = 3;	
		IFlowMenu(1);
        break;
	case '2': //exclude
		if(SysParam.iprov == 1)//if is include
		{
			SysParam.iprov = 0;//exclude
			modify_flag = 1;
		}
		nSelection = 3;	
		IFlowMenu(1);
        break;

    default:
        break;

	}
}

void SetINumInput(BYTE c)
{
	switch (c)
	{
	case KEY_UP:
		if (nSelection > 1)
			nSelection--;
		else 
			nSelection = 2;

		SetINumMenu(0);
		break;
        
	case KEY_DOWN:
		if (nSelection < 2)
			nSelection++;
		else 
			nSelection = 1;

		SetINumMenu(0);
		break;

	case KEY_CR:
		SetINumInput((BYTE) nSelection+'0');
        break;

	case KEY_ESC:
		nSelection = 4;	
		IFlowMenu(1);
		break;
		    
	case '1': //include
		if(SysParam.inum == 0 )//if is exclude
		{
			SysParam.inum = 1;
			modify_flag = 1;
		}
		nSelection = 4;	
		IFlowMenu(1);
        break;

	case '2': //exclude
		if(SysParam.inum == 1)//if is include
		{
			SysParam.inum = 0;//exclude
			modify_flag = 1;
		}
		nSelection = 4;	
		IFlowMenu(1);
        break;

    default:
        break;

	}
}

void SetISeriInput(BYTE c)
{
	switch (c)
	{
	case KEY_UP:
		if (nSelection > 1)
			nSelection--;
		else 
			nSelection = 2;

		SetISeriMenu(0);
		break;
        
	case KEY_DOWN:
		if (nSelection < 2)
			nSelection++;
		else 
			nSelection = 1;

		SetISeriMenu(0);
		break;

	case KEY_CR:
		SetISeriInput((BYTE) nSelection+'0');
        break;

	case KEY_ESC:
		nSelection = 5;	
		IFlowMenu(1);
		break;
		    
	case '1': //include
		if(SysParam.iserial == 0 )//if is exclude
		{
			SysParam.iserial = 1;
			modify_flag = 1;
		}
		nSelection = 5;	
		IFlowMenu(1);
        break;

	case '2': //exclude
		if(SysParam.iserial == 1)//if is include
		{
			SysParam.iserial = 0;//exclude
			modify_flag = 1;
		}
		nSelection = 5;	
		IFlowMenu(1);
        break;

    default:
        break;
	}
}

void SetOOperInput (BYTE c)
{
	switch (c)
	{
	case KEY_UP:
		if (nSelection > 1)
			nSelection--;
		else 
			nSelection = 2;
		SetOOperMenu(0);
		break;
        
	case KEY_DOWN:
		if (nSelection < 2)
			nSelection++;
		else 
			nSelection = 1;
		SetOOperMenu(0);
		break;

	case KEY_CR:
		SetOOperInput((BYTE) nSelection+'0');
        break;

	case KEY_ESC:
		nSelection = 1;	
		OFlowMenu(1);
		break;
		    
	case '1': //include
		if(SysParam.ooper == 0 )//if is exclude
		{
			SysParam.ooper = 1;
			modify_flag = 1;
		}
		nSelection = 1;	
		OFlowMenu(1);
        break;

	case '2': //exclude
		if(SysParam.ooper == 1)//if is include
		{
		SysParam.ooper = 0;//exclude
		modify_flag = 1;
		}
		nSelection = 1;	
		OFlowMenu(1);
        break;

    default:
        break;
	}
}

void SetOsheeInput (BYTE c)
{
	switch (c)
	{
	case KEY_UP:
		if (nSelection > 1)
			nSelection--;
		else 
			nSelection = 2;

		SetOsheeMenu(0);
		break;
        
	case KEY_DOWN:
		if (nSelection < 2)
			nSelection++;
		else 
			nSelection = 1;

		SetOsheeMenu(0);
		break;

	case KEY_CR:
		SetOsheeInput((BYTE) nSelection+'0');
        break;

	case KEY_ESC:
		nSelection = 2;	
		OFlowMenu(1);
		break;
		    
	case '1': //include
		if(SysParam.oshee == 0 )//if is exclude
		{
			SysParam.oshee = 1;
			modify_flag = 1;
		}
		nSelection = 2;	
		OFlowMenu(1);
        break;

	case '2': //exclude
		if(SysParam.oshee == 1)//if is include
		{
			SysParam.oshee = 0;//exclude
			modify_flag = 1;
		}
		nSelection = 2;	
		OFlowMenu(1);
        break;

    default:
        break;
	}
}

void SetCustInput (BYTE c)
{
	switch (c)
	{
	case KEY_UP:
		if (nSelection > 1)
			nSelection--;
		else 
			nSelection = 2;
		SetCustMenu(0);
		break;
        
	case KEY_DOWN:
		if (nSelection < 2)
			nSelection++;
		else 
			nSelection = 1;
		SetCustMenu(0);
		break;

	case KEY_CR:
		SetCustInput((BYTE) nSelection+'0');
        break;

	case KEY_ESC:
		nSelection = 3;	
		OFlowMenu(1);
		break;
		    
	case '1': //include
		if(SysParam.ocust == 0 )//if is exclude
		{
			SysParam.ocust = 1;
			modify_flag = 1;
		}
		nSelection = 3;	
		OFlowMenu(1);
        break;

	case '2': //exclude
		if(SysParam.ocust == 1)//if is include
		{
			SysParam.ocust = 0;//exclude
			modify_flag = 1;
		}
		nSelection = 3;	
		OFlowMenu(1);
        break;

    default:
        break;
	}
}

void SetONumInput (BYTE c)
{
	switch (c)
	{
	case KEY_UP:
		if (nSelection > 1)
			nSelection--;
		else 
			nSelection = 2;
		SetONumMenu(0);
		break;
        
	case KEY_DOWN:
		if (nSelection < 2)
			nSelection++;
		else 
			nSelection = 1;
		SetONumMenu(0);
		break;

	case KEY_CR:
		SetONumInput((BYTE) nSelection+'0');
        break;

	case KEY_ESC:
		nSelection = 4;	
		OFlowMenu(1);
		break;
		    
	case '1': //include
		if(SysParam.onum == 0 )//if is exclude
		{
			SysParam.onum = 1;
			modify_flag = 1;
		}
		nSelection = 4;	
		OFlowMenu(1);
        break;
	case '2': //exclude
		if(SysParam.onum == 1)//if is include
		{
			SysParam.onum = 0;//exclude
			modify_flag = 1;
		}
		nSelection = 4;	
		OFlowMenu(1);
        break;

    default:
        break;
	}
}

void SetOSeriInput (BYTE c)
{
	switch (c)
	{
	case KEY_UP:
		if (nSelection > 1)
			nSelection--;
		else 
			nSelection = 2;
		SetOSeriMenu(0);
		break;
        
	case KEY_DOWN:
		if (nSelection < 2)
			nSelection++;
		else 
			nSelection = 1;
		SetOSeriMenu(0);
		break;

	case KEY_CR:
		SetOSeriInput((BYTE) nSelection+'0');
        break;

	case KEY_ESC:
		nSelection = 5;	
		OFlowMenu(1);
		break;
		    
	case '1': //include
		if(SysParam.oserial == 0 )//if is exclude
		{
			SysParam.oserial = 1;
			modify_flag = 1;
		}
		nSelection = 5;	
		OFlowMenu(1);
        break;

	case '2': //exclude
		if(SysParam.oserial == 1)//if is include
		{
			SysParam.oserial = 0;//exclude
			modify_flag = 1;
		}
		nSelection = 5;	
		OFlowMenu(1);
        break;

    default:
        break;

	}
}

⌨️ 快捷键说明

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