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

📄 inq_afe.c

📁 BC3.1编译,小交换机计费系统.使用Dos做出如此好的界面,少有.
💻 C
📖 第 1 页 / 共 2 页
字号:
/* function: print the notified authcd fee
 * called by:
 * caller:
 * date:
 */
UC prt_authcd_fee(AUTHCD_STRUCT *authcd, UI num)
{
    UI     i;
    double total_f, serv_fee = 0;
    UC	   aus_nam_buf[13];
    struct date now;

    if(check_prn() == FALSE)	    /* not ready */
	return(FALSE);

    if( num == 0 )
    {
	if(print_afehd() == FALSE)
	    return(FALSE);

	if(print_afetbl() == FALSE)
	    return(FALSE);
	if(print_afedtal() == FALSE)
	    return(FALSE);
    }
    else if( (num != 0) && ( (num)%Page_len == 0) /*&& Sys_mode.prt_m == LQ1600*/ )
    {
	getdate(&now);

	if(print_afetbl() == FALSE)
	    return(FALSE);

	if(prnf("汇总起止时间:%-4u年%2u月%2u日%2u时~%-4u年%2u月%2u日%2u时  制表时间:%-4u年%2u月%2u日\n",\
		 Ps_time.year, Ps_time.month, Ps_time.day,  Ps_time.hour,\
		 Pe_time.year, Pe_time.month, Pe_time.day,  Pe_time.hour, \
		 now.da_year, now.da_mon, now.da_day )\
		 == FALSE)
	    return(FALSE);

	/* new page */
        if(new_page() == FALSE)
	    return(FALSE);

	if(print_afehd() == FALSE)
	    return(FALSE);

	if(print_afetbl() == FALSE)
	    return(FALSE);
	if(print_afedtal() == FALSE)
	    return(FALSE);
    }

    for(i=0; i<10; i++)
	aus_nam_buf[i] = authcd->auth_usr_nam[i];
    aus_nam_buf[i] = '\0';

    total_f = (double)(authcd->local_charge)/100+\
	      ((double)(authcd->nation_charge)+(double)(authcd->intern_charge))/100+\
	      (double)(authcd->addfee)/100+\
	      (double)(authcd->month_lease)/100;

    if(prnf("%-4u %-12s %7.2f %4u %8.2f %4u  %7.2f %6.2f %7.2f %9.2f\n",\
		  num, aus_nam_buf, (double)(authcd->local_charge)/100,\
                  authcd->local_count,\
		  (double)(authcd->nation_charge+authcd->intern_charge)/100,\
		  (authcd->nation_count + authcd->intern_count),\
		  (double)(authcd->addfee)/100,\
		  (double)(authcd->month_lease)/100,\
		  serv_fee, total_f) == FALSE)
        return(FALSE);

    return(TRUE);
}


UC print_afehd(void)
{
    UC *head = "      授 权 用 户 话 费 汇 总 表" ;

    if(prnfd("\n%s\n\n", head) == FALSE)
        return(FALSE);
    return(TRUE);
}

UC print_afetbl(void)
{
    if(prnf("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\n")\
        == FALSE)
        return(FALSE);
    return(TRUE);
}

UC print_afedtal(void)
{
    if(prnf("     授权用户        市话 市话     长话 长话     附加   月租    服务\n")\
        == FALSE)
        return(FALSE);
    if(prnf("序号 户名称          话费 次数     话费 次数       费     费      费  费用合计\n")\
        == FALSE)
        return(FALSE);
    if(print_afetbl() == FALSE)
        return(FALSE);

    return(TRUE);
}



/* function  : print the detailed information for the authcds from the input one
 *	       to the end
 * called by : statistic()
 * date      : 1993.12.11
 */
void prtafee_part(void)
{
    UI	 i, idx;
    UI	 lenth, j;
    UC	 flag;
    UL	 auth_cd;
    double	   total_f;
    FILE	  *fp;
    AUTHCD_STRUCT *authcd;
    struct date    now;

    fp = fopen(TotTimeFileName,"rb");
    if(fp == NULL)
    {
	message(TFEE_FILE_ERR);
	return;
    }
    fread(&Ps_time, sizeof(TIME_STRUCT), 1, fp);
    fread(&Pe_time, sizeof(TIME_STRUCT), 1, fp);
    fclose(fp);

    if(check_prn() == FALSE)	    /* not ready */
	return;

    flag = inp_phid_num(&auth_cd, &lenth, PRINT, AUTH_CD);
    if(flag == 1)
	return;

    flag = load_authcd_tbl(0);
    if(flag == 0)		  /* charge.pho does not exist */
    {
       message(AUTHCD_FILE_ERR);
       return;
    }

    message_disp(8,"正在打印,请稍候...");   /* printing, please wait... */

    ANewlen = authcd_tbl_len();
    i = 0;

    authcd = binary_authcd(auth_cd);

    idx = i;
    if( (idx+lenth) >= ANewlen )
         idx = ANewlen;
    else
         idx += lenth;

    j=0;
    total_f = 0;
    for(; i<idx; i++)
    {
        if(prt_authcd_fee(authcd, j) == FALSE)
        {
	    unload_authcd_tbl();
	    message_end();
	    return;
	}
	total_f += (double)(authcd->local_charge)/100+\
	  (double)(authcd->nation_charge+authcd->intern_charge)/100+\
	  (double)(authcd->addfee)/100+\
	  (double)(authcd->month_lease)/100;
	authcd++;
	j++;
    }

    if( print_total( total_f ) == FALSE )
    {
       unload_authcd_tbl();
       message_end();
       return;
    }

    if(print_afetbl() == FALSE)
    {
	unload_authcd_tbl();
	message_end();
	return;
    }

    getdate(&now);

    if(prnf("汇总起止时间:%-4u年%2u月%2u日%2u时~%-4u年%2u月%2u日%2u时  制表时间:%-4u年%2u月%2u日\n",\
		 Ps_time.year, Ps_time.month, Ps_time.day,  Ps_time.hour,\
		 Pe_time.year, Pe_time.month, Pe_time.day,  Pe_time.hour, \
		 now.da_year, now.da_mon, now.da_day )\
		 == FALSE)
    {
	unload_authcd_tbl();
	message_end();
	return;
    }

    /* new page */
    if(new_page() == FALSE)
    {
	unload_phone_tbl();
	message_end();
	return;
    }

    unload_authcd_tbl();
    message_end();
    return;
}


/* function  : print the detailed information for all authcds
 * called by : sta_rpt()
 * date      : 1993.12.11
 */
void prtafee_all(void)
{
    UI	 i;
    UC	 flag;
    double	   total_f;
    FILE	  *fp;
    AUTHCD_STRUCT  *authcd;
    struct date    now;

    if(check_prn() == FALSE)	    /* not ready */
	return;
    fp = fopen(TotTimeFileName,"rb");
    if(fp == NULL)
    {
	message(TFEE_FILE_ERR);
	return;
    }
    fread(&Ps_time, sizeof(TIME_STRUCT), 1, fp);
    fread(&Pe_time, sizeof(TIME_STRUCT), 1, fp);
    fclose(fp);

    flag = load_authcd_tbl(0);
    if(flag == 0)		  /* charge.pho does not exist */
    {
       message(AUTHCD_FILE_ERR);
       return;
    }

    message_disp(8,"正在打印,请稍候...");   /* printing, please wait... */
    ANewlen = authcd_tbl_len();
    authcd = Auth_cd_top;

    total_f = 0;
    for(i=0; i<ANewlen; i++)
    {
        if(prt_authcd_fee(authcd, i) == FALSE)
        {
	    unload_authcd_tbl();
	    message_end();
	    return;
	}
	total_f += (double)(authcd->local_charge)/100+\
		  (double)(authcd->nation_charge+authcd->intern_charge)/100+\
		  (double)(authcd->addfee)/100+\
		  (double)(authcd->month_lease)/100;
	authcd++;
    }
    if(print_total(total_f) == FALSE)
    {
       unload_authcd_tbl();
       message_end();
       return;
    }
    if(print_afetbl() == FALSE)
    {
	unload_authcd_tbl();
	message_end();
	return;
    }
    getdate(&now);
    if(prnf("汇总起止时间:%-4u年%2u月%2u日%2u时~%-4u年%2u月%2u日%2u时  制表时间:%-4u年%2u月%2u日\n",\
		 Ps_time.year, Ps_time.month, Ps_time.day,  Ps_time.hour,\
		 Pe_time.year, Pe_time.month, Pe_time.day,  Pe_time.hour, \
		 now.da_year, now.da_mon, now.da_day )\
		 == FALSE)
    {
	unload_authcd_tbl();
	message_end();
	return;
    }

    /* new page */
    if(new_page() == FALSE)
    {
	unload_authcd_tbl();
	message_end();
	return;
    }

    unload_authcd_tbl();
    message_end();
    return;
}


/* function:  invoice
 * called by:
 * caller:    none
 * date:      1994.12.5
 */
UC inv_aone(AUTHCD_STRUCT *authcd, UC opflg2, UC opflg3)
{
    FILE *fp;
    double tch;
    UL	  th[4], tm[4], ttm, tcu;
    struct date now;
    UC *head[2] = {
	          "        用  户  话  费  收  据",
	          "        授  权  户  话  费  汇  总" };

    if(check_prn() == FALSE)	    /* not ready */
	return(FALSE);

    fp = fopen(TotTimeFileName,"rb");
    if(fp == NULL)
    {
	message(TFEE_FILE_ERR);
	return(FALSE);
    }
    fread(&Ps_time, sizeof(TIME_STRUCT), 1, fp);
    fread(&Pe_time, sizeof(TIME_STRUCT), 1, fp);
    fclose(fp);

	if(opflg3 != DETL)
	{
	    if(prnfd("\n%s\n\n", head[0])==FALSE)
		return(FALSE);
	}
	else
	{
	    if(prnfd("\n%s\n\n", head[1])==FALSE)
		return(FALSE);
	}

    if(prnf(" 授权户名: %-s\n", authcd->auth_usr_nam) == FALSE)
	return(FALSE);

    if(print_invtbl1() == FALSE)
	return(FALSE);

    if(print_invdtl1() == FALSE)
	return(FALSE);

    if(print_invtbl2() == FALSE)
	return(FALSE);

    tch = (double)(authcd->intern_charge + authcd->nation_charge +\
	   authcd->local_charge)/100;

    if(  prnf("┃  话  费  │     %9.2f  │   %9.2f  │     %9.2f  │   %9.2f┃\n",\
	      (double)(authcd->intern_charge)/100, (double)(authcd->nation_charge)/100,\
	      (double)(authcd->local_charge)/100,\
	      tch)==FALSE)
	return(FALSE);

    if(print_invtbl2() == FALSE)
	return(FALSE);

    ttm    = authcd->intern_time;

    if( ttm%60 != 0 )
	tm[0]  = (ttm/60 + 1) % 60;
    else
	tm[0]  = (ttm/60) % 60;
    th[0]  = (ttm/60 + 1) / 60;

    ttm    = authcd->nation_time;
    if( ttm%60 != 0 )
	tm[1]  = (ttm/60 + 1) % 60;
    else
	tm[1]  = (ttm/60) % 60;
    th[1]  = (ttm/60 + 1) / 60;

    ttm    = authcd->local_time;
    if( ttm%60 != 0 )
	tm[2]  = (ttm/60 + 1) % 60;
    else
	tm[2]  = (ttm/60) % 60;
    th[2]  = (ttm/60 + 1) / 60;

    ttm = authcd->intern_time + authcd->nation_time + authcd->local_time;
    if( ttm%60 != 0 )
	tm[3]  = (ttm/60 + 1) % 60;
    else
	tm[3]  = (ttm/60) % 60;
    th[3]  = (ttm/60 + 1) / 60;

    if(prnf("┃  时  长  │  %6lu时%2u分  │%6lu时%2u分  │  %6lu时%2u分  │%6lu时%2u分┃\n",\
	    th[0],(UI)tm[0],th[1],(UI)tm[1],th[2],(UI)tm[2],th[3],(UI)tm[3])==FALSE)
	return(FALSE);

    if(print_invtbl2() == FALSE)
	return(FALSE);

    tcu = (UL)(authcd->intern_count + authcd->nation_count +\
	  authcd->local_count);
    if(prnf("┃  次  数  │    %10u  │  %10u  │    %10u  │  %10lu┃\n",\
	      authcd->intern_count, authcd->nation_count,\
	      authcd->local_count, tcu)==FALSE)
	return(FALSE);

    if(print_invtbl3() == FALSE)
	return(FALSE);

    if(print_invdtl2() == FALSE)
	return(FALSE);

    if(print_invtbl4() == FALSE)
	return(FALSE);

    tch = (double)(authcd->month_lease)/100+\
	  (double)(authcd->addfee)/100;
    if(prnf("┃ %8.2f │        │        │        │        │ %8.2f │   %9.2f┃\n",\
	     (double)(authcd->month_lease)/100,\
	     (double)(authcd->addfee)/100,tch) == FALSE)
	return(FALSE);

    if(print_invtbl5() == FALSE)
	return(FALSE);

    if(opflg3 != DETL)
    {
        if(print_invdtl3() == FALSE)
	    return(FALSE);
    }
    else
    {
        if(print_invdtl4() == FALSE)
	    return(FALSE);
    }
    if(print_invtbl6() == FALSE)
	return(FALSE);

    tch  = (double)authcd->intern_charge + (double)authcd->nation_charge +\
	   (double)authcd->local_charge;
    tch += (double)authcd->month_lease;
    tch += (double)authcd->addfee;

    if(prnf("┃    人 民 币 元     │%-4u年%2u月%2u日%2u时│%-4u年%2u月%2u日%2u时  │   %9.2f┃\n",\
					  Ps_time.year, Ps_time.month,\
					  Ps_time.day,	Ps_time.hour,\
					  Pe_time.year, Pe_time.month,\
					  Pe_time.day,	Pe_time.hour, tch/100\
					  )==FALSE)
	return(FALSE);

    if(print_invtbl7() == FALSE)
	return(FALSE);

    getdate(&now);
    if(prnf(" 制表时间:%-4u年%-2u月%-2u日\n",now.da_year, now.da_mon, now.da_day ) == FALSE)
	return(FALSE);

    if(opflg2 == SINGLE)
    {
	/* new page */
        if(new_page() == FALSE)
	    return(FALSE);
    }
    else
    {
	if(prnf("\n\n\n\n") == FALSE)
	    return(FALSE);
    }
    return(TRUE);
}

UC print_total(double total_f)
{
    if(prnf("                                                         费用总计:   %9.2f\n", \
	     total_f) == FALSE)
        return FALSE;
    else
        return TRUE;
}

⌨️ 快捷键说明

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