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

📄 print.c

📁 一款收款机C源代码!因为是几年前的代码了
💻 C
📖 第 1 页 / 共 5 页
字号:
	{
		Prn_InsStr(Str_Menu_Head1,1, NM_FONT_PRN, FLUSH_LEFT);
		LongPrnFmt_Ex((Idx+1)/10, 0, 21, RIGHTFLUSH, NM_FONT_PRN);
		LongPrnFmt_Ex((Idx+1)%10, 0, 22, RIGHTFLUSH, NM_FONT_PRN);
		Print_Ex(1);
	}	
	else if(ID == TS_MENU_REAR)
	{
		Prn_InsStr(Str_Menu_Sub_Qty, 1, NM_FONT_PRN, FLUSH_LEFT);
		Qty_Adjust(quantity);
		Prn_Adj_Q_Ex(Str_Null, adj_num, adj_dots, MAX_PRN_LEN, DESC_NEW);
		Prn_InsStr(Str_Menu_Sub_Amt, 1, NM_FONT_PRN, FLUSH_LEFT);
		LongPrnFmt_Ex(price, sysflag->sysdots, MAX_PRN_LEN, RIGHTFLUSH, NM_FONT_PRN);
		Print_Ex(1);
		prn_Line('*');
	}
    else if (ID == TS_COOK_MSG)
    {
        //...
    }
	#endif
	#ifdef AUTO_PER		/* Support the department auto percent function */
	else if((ID == TS_AUTO_PER_DEPT) || (ID == TS_AUTO_PER_PLU))		/* Auto Percent operation */
	{
		amount = price;			/* In Percent operation, the amount equal to the price */
        Prn_InsStr(Str_Per_Symbol, 6, NM_FONT_PRN, FLUSH_LEFT);
        LongPrnFmt_Ex(quantity, 3, 5, RIGHTFLUSH, NM_FONT_PRN);
		LongPrnFmt_Ex(amount, sysflag->sysdots, MAX_PRN_LEN, RIGHTFLUSH, NM_FONT_PRN);
	}
	#endif /* End AUTO_PER */
	else
	{
		round = (tsbf.flag)>>4;
		amount = Sale_Mul(price, sysflag->sysdots, quantity, 3, round, sysflag->sysdots);		/* Get the amount */
		;/* Judge the amount is illegal or not */
		price = labs(price);			/* Get the absolute value, for the print price is always positive */
		if((ID == TS_RF_SUBT) && (Subt_Prn_Flag == 0))					/* Print the total information */
		{
			Get_TVAT();						/* Calculate the VAT or tax value */
			prn_REG_TVAT();				/* Print the VAT or tax vaule */
			prn_Line('-');
			prn_Tot_Info_Ex(Var_Str_Subttl, tmpvars.netamt-amount, 0);
		}
		if((ID == TS_RF_ITEM_DEPT) || (ID == TS_RF_ITEM_PLU) || (ID == TS_RF_SUBT))
		{
			Prn_InsImpStr(refund.desc, 1, MAX_DESC_LEN, FLUSH_LEFT);
		}
		else if((ID == TS_DEPT) || (ID == TS_VD_DEPT) || (ID == TS_RM_DEPT))
		{
			Prn_InsImpStr(dept[Idx].desc, 1, MAX_DESC_LEN_EX, FLUSH_LEFT);
		}
		else //((ID == TS_PLU) || (ID == TS_VD_PLU) || (ID == TS_RM_PLU))
		{
			plink = plu[Idx].plink;
			if(sysflag->RPLDP_flag)		/* Print the Linked department when the flag is 1 */
			{
				Prn_InsImpStr(dept[plink - 1].desc, 1, MAX_DESC_LEN_EX, FLUSH_LEFT);
				Print_Ex(1);
			}
			Prn_InsImpStr(plu[Idx].desc, 1, MAX_DESC_LEN_EX, FLUSH_LEFT);
		}
		if((ID == TS_VD_DEPT) || (ID == TS_VD_PLU))		/* VOID operation */
		{
			Print_Ex(1);
			Prn_InsFmtStr(Str_VOID, 1, Get_Spec_Len(Str_VOID), NULL);
			LongPrnFmt_Ex(amount, sysflag->sysdots, RPOSI, RIGHTFLUSH, NM_FONT_PRN);
			Print_Ex(1);
		}
		else
		{
			if((ID == TS_DEPT) || (ID == TS_PLU))/* Print the data in one line */
			{
				LongPrnFmt_Ex(amount, sysflag->sysdots, RPOSI, RIGHTFLUSH, NM_FONT_PRN);
				Print_Ex(1);
			}
			else		/* Print the data in two lines */
			{
				Print_Ex(1);
				if((ID == TS_RM_DEPT) || (ID == TS_RM_PLU))		/* Print the Return Merchandise information */
					Prn_InsFmtStr(Var_Str_RM, 1, Get_Spec_Len(Var_Str_RM), NULL);
				else if((ID == TS_RF_ITEM_DEPT) || (ID == TS_RF_ITEM_PLU) || (ID == TS_RF_SUBT))		/* Refund operation */
				{
					if(ID == TS_RF_SUBT)
						Prn_InsFmtStr(Var_Str_SubTtl, 1, Get_Spec_Len(Var_Str_SubTtl), NULL);
					else
						Prn_InsFmtStr(Var_Str_Item, 1, Get_Spec_Len(Var_Str_Item), NULL);
				}
				LongPrnFmt_Ex(amount, sysflag->sysdots, RPOSI, RIGHTFLUSH, NM_FONT_PRN);
				Print_Ex(1);
			}
		}
	}

	Sale_Dsp(tsbf);
}
#endif

/* 
	Get the description
	This function is consider for the electronic journal, the journal's index number may be 
	larger than the current number. 
	注: 这种情况产生于可调整大小的数量上, 比如部门, PLU, 收银员等. 
*/
byte	cpy_esp_desc(char *dst, byte flag, word idx)
{
	byte	len;
    byte    Max_len = MAX_DESC_LEN;

	if(flag == DEPT)
	{
		if(idx < Max_Dept_No)
		{
			memcpy(dst, dept[idx].desc, MAX_DESC_LEN_EX);
		}
		else
		{
			len = desc_cpy(dept[idx].desc,Str_Dept_Desc,2);
			dst[len] = (idx+1)/10%10 + '0';
			dst[len+1] = (idx+1)%10 + '0';
		}
        Max_len = MAX_DESC_LEN_EX;
	}
	else if(flag == PLU)
	{
		if(idx < Max_Plu_No)
		{
			memcpy(dst, plu[idx].desc, MAX_DESC_LEN_EX);
		}
		else
		{
			len = desc_cpy(plu[idx].desc,Str_PLU_Desc,2);
			dst[len] = (idx+1)/10%10 + '0';
			dst[len+1] = (idx+1)%10 + '0';
		}
        Max_len = MAX_DESC_LEN_EX;
	}
	else if(flag == CLERK)
	{
		if(idx < Max_Clerk_No)
		{
			memcpy(dst, clerk[idx].desc, MAX_DESC_LEN);
		}
		else
		{
			len = desc_cpy(clerk[idx].desc,Str_Clerk_Desc,2);
			dst[len] = (idx+1)/10%10 + '0';
			dst[len+1] = (idx+1)%10 + '0';
		}
	}
	len = Get_Desc_Len(dst, Max_len);
	return (len);
}


/*----------------------------------------------------------------------*
					The reports data print.
			Parameter:
					src_str:		The source print string.
					Cnt_Qtt: 	The count or the quantity, indicated by
									the parameter 'flag'.
					flag:			Indicate the count or the quantity parameter.
									1: Count.
									0: Quantity.
					amount:		The print amount.
					dots:			The print amout's decimal dots.
			The reports print format:
				12345678901234567890123456789012
				--------------------------------
				Item Name     Cnt/Qty     Amount
				================================
				Department01       1Q    1234.56
				...
				Department24  123.45Q  123456.78
				--------------------------------
				Total       123456.7Q 1234567.89
				--------------------------------

 *----------------------------------------------------------------------*/
#ifdef OLD
void Rpt_Prn(char *src_str, byte str_len, long Cnt_Qtt, byte flag, long amount, byte dots)
{
	byte len1, len2, len3;
	byte bak_skip_flag;

	if(((CurrMode == XREPORT) || (CurrMode == ZREPORT)) && (zero_skip_flag == 1))
	{
		if(sysflag->zero_skip)
		{
			if((Cnt_Qtt == 0) && (amount == 0))
			{
				clr_Prn_Buf();
				return;
			}
		}
	}
	bak_skip_flag = zero_skip_flag;		/* Backup the skip flag */
	zero_skip_flag = 0;

	len1 = str_len;
	if(flag == 1)
		len2 = Cal_Len2(Cnt_Qtt, 0);
	else
	{
		Qty_Adjust(Cnt_Qtt);
		len2 = Cal_Len2(adj_num, adj_dots);
		len2 ++;					/* 'Q' */
	}
	len3 = Cal_Len2(amount, dots);

	memcpy(prn_Buf+1, src_str, len1);
	if((len3 > 10) || (len1 + len2 > 20))			/* Print in two lines */
	{
		if(len1+len2 > 20)
		{
			if(flag == 1)
				prn_Adj(Str_Null, Cnt_Qtt, 0, len1+len2+1);
			else
			{
				Qty_Adjust(Cnt_Qtt);
				prn_Adj_Q(Str_Null, adj_num, adj_dots, len1+len2+1);
			}
		}
		else
		{
			if(flag == 1)
				prn_Adj(Str_Null, Cnt_Qtt, 0, 21);
			else
			{
				Qty_Adjust(Cnt_Qtt);
				prn_Adj_Q(Str_Null, adj_num, adj_dots, 21);
			}
		}
		prn_Adj(Str_Null, amount, dots, RPOSI);
	}
	else				/* Print in one line */
	{
		if(flag == 1)
			LongPrnFmt(Cnt_Qtt, 0, 21, RIGHTFLUSH);
		else
		{
			Qty_Adjust(Cnt_Qtt);
			LongPrnFmt(adj_num, adj_dots, 20, RIGHTFLUSH);
			prn_Buf[21] = 'Q';
		}
		prn_Adj(Str_Null, amount, dots, RPOSI);
	}

	zero_skip_flag = bak_skip_flag;		/* Revert the skip flag */
}
#else
void Rpt_Prn(char *src_str, byte str_len, long Cnt_Qtt, byte flag, long amount, byte dots)
{
	byte len1, len2, len3;
	byte bak_skip_flag;

	if(((CurrMode == XREPORT) || (CurrMode == ZREPORT)) && (zero_skip_flag == 1))
	{
		if(sysflag->zero_skip)
		{
			if((Cnt_Qtt == 0) && (amount == 0))
			{
				clr_Prn_Buf();
				return;
			}
		}
	}
	bak_skip_flag = zero_skip_flag;		/* Backup the skip flag */
	zero_skip_flag = 0;

    if(flag == 1)
		len2 = Cal_Len2(Cnt_Qtt, 0);
	else
	{
		Qty_Adjust(Cnt_Qtt);
		len2 = Cal_Len2(adj_num, adj_dots);
	}
	len3 = Cal_Len2(amount, dots);
    len1 = str_len;
    
    memcpy(prn_Buf+1, src_str, str_len);
    if(len1 + len2 + 1 > 15 || len3 > 8) // prn two line
    {
        print();
        LongPrnFmt(amount,dots,RPOSI, RIGHTFLUSH);
        if(flag == 1)
        {
            if(len3 > 8)
                LongPrnFmt(Cnt_Qtt,0,RPOSI - len3 -1, RIGHTFLUSH);
            else
                LongPrnFmt(Cnt_Qtt,0,15, RIGHTFLUSH);
        }
        else
        {
            Qty_Adjust(Cnt_Qtt);
            if(len3 > 8)
               LongPrnFmt(adj_num,adj_dots,RPOSI - len3 -1, RIGHTFLUSH);
            else
               LongPrnFmt(adj_num,adj_dots,15, RIGHTFLUSH); 
        }
        print();
        return;
    }
    if(flag == 1) //prn in one line.
        LongPrnFmt(Cnt_Qtt,0,15, RIGHTFLUSH);
    else
    {
        Qty_Adjust(Cnt_Qtt);
        LongPrnFmt(adj_num,adj_dots,15, RIGHTFLUSH);
    }
    
    LongPrnFmt(amount,dots,RPOSI, RIGHTFLUSH);
    print();
    
	zero_skip_flag = bak_skip_flag;		/* Revert the skip flag */
}


#endif

/* Print the reports head */
void Rep_Head_Prn(void)
{
//	memcpy(prn_Buf+1, Str_Rpt_Head, MAX_PRN_LEN);
	xtr_strcpy(prn_Buf+1, Str_Rpt_Head);			/* Modified on 2004-04-07 17:17 */
	print();
	prn_Line('=');
}

/*	Calculate the long number's length, if the datais negative, only get the positive data's length */
byte Cal_Len(long num)
{
	long tmp;
	byte len;

	tmp = labs(num);
	for(len = 0; tmp > 0; len ++)
		tmp /= 10;
	return (len);
}


/*--------------------------------------------------------------------------------*
 *                   Print the recepits head information                          *
 *       When the transaction is not end, do not print it.                        *
 *--------------------------------------------------------------------------------*/
void  Receipt_Head_Prn(void)
{
    byte i;
    byte j;
    byte lines = 0;

    for(i = 0; i < MSG_HEAD_LINES; i ++)
    {
        j = Get_Desc_Len_Ex(&Wlcm_Msg[i][2],MAX_PRN_LEN,YES);		/* Get the descriptions length */
        if(j == 0)								/* If the content is null, skip to print the next line */
            continue;
        lines++;
        if (prePrnLine >= lines)
            continue;

        Prn_InsFmtStr(&Wlcm_Msg[i][2], 1, MAX_PRN_LEN, NULL);
        Prn_Str(1);
    }
    if(sysflag->Btm_Msg_Flag == 1)
    {
        for(i = 0; i < MSG_BTM_LINES; i ++)
        {
            j = Get_Desc_Len_Ex(&Btm_Msg[i][2],MAX_PRN_LEN,YES);
            if(j == 0)								/* If the content is null, skip to print the next line */
                continue;
            lines++;
            if (prePrnLine >= lines)
                continue;

            Prn_InsFmtStr(&Btm_Msg[i][2], 1, MAX_PRN_LEN, NULL);
            Prn_Str(1);
        }
    }
    if((Logo_Prn_Flag == 1) &&(sysflag->LogoPosi_Flag == HEAD) && (sysflag->PrnAdj_Flag))
        prn_Logo();
    
    Line_Feed(1);        /* Print one blank line */

    #ifdef	RCPT_REPRN
    if(Rcpt_Reprn_Flag)
    {
        xtr_strcpy(prn_Buf+1, Str_Reprn_Rcpt);
        print();
    }
    #endif

    if(CurrMode == TRAINING)
    {
        Prn_InsFmtStr(Var_Str_Trng_Head, 1, Get_Spec_Len(Var_Str_Trng_Head), FLUSH_LEFT);
        Print_Ex(1);
    }

    #if	SW_VER == SW_NE2
    prn_Date_Time(GetYear(), GetMonth(), GetDay(), GetHour(), GetMinute());
    prn_RcptNum();
    Line_Feed(1);
    #endif

#ifdef VER_RSNT		/* Support the restaurant function */
    if((work_mode == RSNT) && (currtable != NUL_VLU))
    {
        Flag_Prgm_Head = 1;

⌨️ 快捷键说明

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