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

📄 out_rang.c

📁 BC3.1编译,小交换机计费系统.使用Dos做出如此好的界面,少有.
💻 C
📖 第 1 页 / 共 2 页
字号:
	}
    }
    else if(mode == DDD)
    {
	fp = fopen("ddd.dbf","rb");
	if(fp==NULL)
	{
	    get_key1();
	    unload_rate_tab();
            if(Authflg == ON)
                unload_authcd_tbl();
	    return;
	}
    }
    else if(mode == LDD)
    {
	fp = fopen("ldd.dbf","rb");
	if(fp==NULL)
	{
	    get_key1();
	    unload_rate_tab();
            if(Authflg == ON)
                unload_authcd_tbl();
	    return;
	}
    }

    modi_flag = 0;
    rec_no = 0;
    for(i=0;i<MAXNUM;i++)
    {
	modi_no[i] = 0;
	modi_date[i].year = 0;
	modi_date[i].month= 0;
	modi_date[i].day  = 0;
	modi_date[i].hour = 0;
    }

    while(fread(&temp_list,sizeof(RECORD_STRUCT),1,fp) == 1)
    {
	rec_no++;                               /* record no in file    */
	in_flag = in_time_range(in_stime,in_etime);
	if(in_flag && !EndofRecFile(fp))        /* in the in-time range */
	    continue;

	if(in_flag == FALSE)
	{
            if(mode == IDD)
            {
	        rate_tmp = get_rate(&temp_list.callee[2],IDD);   /* get charge rate */
            }
            else if(mode == DDD)
            {
	        rate_tmp = get_rate(&temp_list.callee[1],DDD);   /* get charge rate */
            }
            else
	        rate_tmp = get_rate(temp_list.callee,LDD);   /* get charge rate */

            if(rate_tmp == NULL)              /* the area No. does not exist    */
	        strcpy(rate1.area_name, a_name);
	    else
	        rate1 = *rate_tmp;

            auth_usr_proc(auth_name);

	    disp_out_record(auth_name, position); /* display the out-of-range rec. */
	    out_no[position] = rec_no;
	    position++;
	}

	if( (position>=16) || (EndofRecFile(fp) && position>=1) )
	{
	    mes_disp(0,"选择序号: " );           /* input the row number */
	    GOTOxy(MES_LEFT+90,MES_TOP+1);

	    do
	    {
		re_do = 0;
		clr_scr(MES_LEFT+90,MES_TOP+1,MES_RIGHT-20,MES_BOTTOM-5,WHITE,11);

		key = get_key1();

		/* modify the date or delete some items in the tbl   */
		if( (modi<MAXNUM) &&                       \
		    ( ((key&0xff)>='0' && (key&0xff)<='9') ||
		      ((key&0xff)>='a' && (key&0xff)<='f') ))
		{
		    if(modi_flag == 0)      /* set the modifing flag */
			modi_flag = 1;

		    if(modi < MAXNUM)       /* if bigger than MAXNUM */
			re_do = 1;          /* do not handle it      */

		    ch[0] = (UC)(key&0xff);      /* NO in the table  */
		    outf(MES_LEFT+90,MES_TOP+1,11,WHITE,"%s",ch);
		    if((ch[0]>='0') && (ch[0]<='9'))
			tbl_no = ch[0]-'0';
		    else
			tbl_no = ch[0]-'a'+10;
		    if(tbl_no >= position)  /* out of the pos in tbl now */
			continue;

		    /* check whether the record No bas been modified/deleted
		     * or not. If has been, neglect it. That is to say,
		     * a record No can't be handled twice
		     */
		    res = 0;
		    for(i=0;i<modi;i++)
			if(out_no[tbl_no] == modi_no[i])
			{
			    res = 1;
			    break;
			}
		    if(res == 1)
			continue;

		    modi_no[modi] = out_no[tbl_no];

		    mes_disp(120,"1.修改日期  2.删除"); /* modify or del */
		    value = 0;
		    do
		    {
			res = get_dec(MES_LEFT+300,MES_TOP+1,18,20,0,1,\
					  &value,0x00);
		    }while((value!=1) && (value!=2));

		    if(value==2)       /* delete an item */
		    {
//			pass_flag = del_one_pass(); //out_del_pass();
			pass_flag = valid_pass(DEL_PWD); //out_del_pass();
			if(pass_flag == FALSE)           /* not right  */
			{
			    mes_disp(230,"口令错误!");
			    delay_10ms(80);
			    continue;
			}

			setcolor(12);  /* MAGENTA        */
			cur_unit.unit_x = tbl_no;
			cur_unit.unit_y = 1;
			get_certain(&cur_unit);
			line(cur_unit.dot_sx+2,cur_unit.dot_sy+9, \
					   620,cur_unit.dot_sy+9);
			modi_date[modi].year = 8000;
		    }
		    else               /* modify the date */
		    {
			mes_disp(140," 年    月    日");    /* year,mon,day */

			value = 0;
			do
			{
			    res = get_dec(MES_LEFT+120,MES_TOP+1,18,20,0,2,\
					      &value,0x00);
			}while((value<1) || (value>=100));
			modi_date[modi].year = (UI)value+1900;

			value = 0;
			do
			{
			    res = get_dec(MES_LEFT+170,MES_TOP+1,18,20,0,2,\
					      &value,0x00);
			}while((value<1) || (value>12));
			modi_date[modi].month = (UC)value;

			value = 0;
			do
			{
			    res = get_dec(MES_LEFT+220,MES_TOP+1,18,20,0,2,\
					      &value,0x00);
			}while((value<1) || (value>31));
			modi_date[modi].day = (UC)value;

			cur_unit.unit_x = tbl_no;
			cur_unit.unit_y = 4;
			get_certain(&cur_unit);
			outf(cur_unit.dot_sx+4,cur_unit.dot_sy+1,7,0, \
			     "%02u/%02u",\
			      modi_date[modi].month,modi_date[modi].day );
		    }        /* end of "else if (key=='1')" */

		    modi++;
		}  /* end of "if( ((key&0xff)>='0' && (key&0xff)<='9').." */

		else if((key==ESC) || EndofRecFile(fp))
		{
		    fclose(fp);

		    if(modi_flag)           /* modify or delete some items  */
		    {
			mes_disp(0,"正在存盘,请稍候...");  /* saving,wait...*/
			file_refresh(mode,modi);        /* refresh the file */
		    }

		    clr_scr(MES_LEFT,MES_TOP+1,MES_RIGHT-20,MES_BOTTOM-5,\
			    WHITE,11);
//		    message(MAIN_MES);
                    brush_tbl(9, 16, 7);
                    disp_num();
                    unload_rate_tab();
                    if(Authflg == ON)
                        unload_authcd_tbl();
		    return;
		}       /* end of "if(key == ESC)" */

		else
		{
                    brush_tbl(9, 16, 7);
                    disp_num();
		    position = 0;
		}

	    }while(re_do);
	}      /* end of "if( (position>=16) || (EndofRecFile(fp)) )" */
    }          /* end of "while(fread(...fp)==1)" */
    fclose(fp);

    if(modi_flag)           /* modify or delete some items  */
    {
	mes_disp(0,"正在存盘,请稍候...");  /* saving,wait...*/
	file_refresh(mode,modi);        /* refresh the file */
    }

    clr_scr(MES_LEFT,MES_TOP+1,MES_RIGHT-20,MES_BOTTOM-5,WHITE,11);
//    message(MAIN_MES);
    brush_tbl(9, 16, 7);
    disp_num();

    unload_rate_tab();
    if(Authflg == ON)
        unload_authcd_tbl();
    return;
}

/* function  : display a out-of-range record in the table
 * called by : out_range_proc()
 * input     : pos -- display position in the table
 * date      : 1993.10.5
 */
void disp_out_record(char *auth_name, UC pos)
{
    int  i, j, k, l;
    int  dh, dm, ds;
    UC   area_n[19];
    UC   tel_no[16];
    UI   x, y;
    UNIT_STRUCT cur_unit;

    cur_unit.unit_x = pos;
    for(j=1;j<10;j++)
    {
	cur_unit.unit_y = j;
	get_certain(&cur_unit);
	x = cur_unit.dot_sx+4;
	y = cur_unit.dot_sy+1;

	switch(j)
	{
	    case 1:
		outf(x,y,7,0,"%-lu",temp_list.caller2);
		break;
	    case 2:
	        if(temp_list.auth_code != 0xaaaaaa)
                    outf(x, y, 7, 0,"%-s",auth_name);
		break;
	    case 3:
/*		if( temp_list.callee[0] != 0 )    /* LDD */
		{
		     outf(x-2,y,7,0,"本地");
		     i=0;
		     while( (temp_list.callee[i] != 0xfd) && (i<14) )
		     {
			 tel_no[i] = temp_list.callee[i]+'0';
			 i++;
		     }
		     tel_no[i] = '\0';
		     outf(x+32,y,7,0,"%-s",tel_no);
		}
		else                                /* DDD IDD */
		{
*/
		     i=0;
		     while( (temp_list.callee[i] != 0xfd) && (i<14) )
		     {
			 tel_no[i] = temp_list.callee[i]+'0';
			 i++;
		     }
		     tel_no[i] = '\0';
		     l=(21-i)/2;
                     if(l > 4) l = 4;
		     for(k=0; k<l*2; k++)
			 area_n[k]=rate1.area_name[k];
		     area_n[k] = '\0';
		     outf(x-2,y,7,0, area_n);
		     outf(x+l*16,y,7,0,"%-s",tel_no);
//		}
		break;
	    case 4:
		outf(x,y,7,0,"%02u/%02u", temp_list.mon1,temp_list.day1);
		break;
	    case 5:
		outf(x,y,7,0,"%02u:%02u",temp_list.hour1, temp_list.min1);
		break;
	    case 6:
		 dh = temp_list.hour2 - temp_list.hour1;
		 dm = temp_list.min2  - temp_list.min1;
		 ds = temp_list.sec2  - temp_list.sec1;
		 if( ds < 0 )
		 {
		     ds += 60;
		     dm --;
		 }
		 if( dm < 0 )
		 {
		     dm += 60;
		     dh --;
		 }
		 if( dh < 0 )
		 {
		     dh += 24;
		 }

		 if(ds != 0)
		     dm++;
		 if(dm == 60)
		 {
		    dm = 0;
		    dh ++;
		 }

		 outf(x,y,7,0,"%02d:%02d", dh, dm);
		 break;
	    case 7:      /* add fee      */
		 outf(x,y,7,0,"%6.2f",(double)(temp_list.add)/100);
		 break;
	    case 8:
		outf(x,y,7,0,"%7.2f",(double)(temp_list.charge)/100);
		break;
	}     /* end of "switch(j)"        */
    }         /* end of "for(j=0;j<8;j++)" */
    return;
}


/* function  : refresh the *.dat according to the modified or deleted item
 * called by : out_range_proc()
 * input     : mode -- IDD,DDD,LDD
 *             modi -- all the number of records that have been modified
 *                     or deleted
 * date      : 1993.10.8
 */
void file_refresh(UC mode, UC modi)
{
    int  i;
    UC   num=0;
    FILE *fps,*fpd;
    UC   skip=FALSE;
    UL   counter=0;

    if(mode == IDD)
    {
	fps = fopen("idd.dbf","rb");
	fpd = fopen("idd.out","wb");
    }
    else if(mode == DDD)
    {
	fps = fopen("ddd.dbf","rb");
	fpd = fopen("ddd.out","wb");
    }
    else if(mode == LDD)
    {
	fps = fopen("ldd.dbf","rb");
	fpd = fopen("ldd.out","wb");
    }

    while(fread(&temp_list,sizeof(RECORD_STRUCT),1,fps) == 1)
    {
	skip = FALSE;
	counter++;

	if(num < modi)
	{
	    for(i=0;i<modi;i++)        /* compare */
	    {
		if(counter == modi_no[i])
		{
		    num++;
		    if(modi_date[i].year == 8000)     /* deleted  */
			skip = TRUE;
		    else                              /* modified */
		    {
			temp_list.year2 = modi_date[i].year;
			temp_list.mon2  = modi_date[i].month;
			temp_list.day2  = modi_date[i].day;
			temp_list.year1 = modi_date[i].year;
			temp_list.mon1  = modi_date[i].month;
			temp_list.day1  = modi_date[i].day;
		    }
		    break;
		}       /* end of "if(counter == modi_no[i])" */
	    }      /* end of "for(i=0;i<modi;i++)" */
	}     /* end of "if(num < modi)"  */

	if(skip != TRUE)
	    fwrite(&temp_list,sizeof(RECORD_STRUCT),1,fpd);
    }    /* end of "while(fread(...fps)==1)" */

    fclose(fpd);
    fclose(fps);

    if(mode == IDD)
    {
	fcopy("idd.out","idd.dbf");
	fcopy("idd.out","idd.tmp");
	remove("idd.out");
    }
    else if(mode == DDD)
    {
	fcopy("ddd.out","ddd.dbf");
	fcopy("ddd.out","ddd.tmp");
	remove("ddd.out");
    }
    else if(mode == LDD)
    {
	fcopy("ldd.out","ldd.dbf");
	fcopy("ldd.out","ldd.tmp");
	remove("ldd.out");
    }

    return;
}

/* function  : display  "msg" in the status window. The only method to
 *             retrieve the old message is to re_display the message
 * called by : out_rang_proc()
 * input     : back_in -- distance to MES_LEFT
 *             msg -- the message to be displayed
 * date      : 1993.10.8
 */
void mes_disp(UC back_in, UC *msg)
{
    clr_scr(MES_LEFT+back_in,MES_TOP+1,MES_RIGHT-20,MES_BOTTOM-5,WHITE,11);
    hz16_disp(MES_LEFT+back_in,MES_TOP+1, msg,0);

    return;
}

⌨️ 快捷键说明

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