📄 out_rang.c
字号:
#include <dir.h>
#include <dos.h>
#include <alloc.h>
#include <conio.h>
#include <string.h>
#include <graphics.h>
#include <key.inc>
#include <bio.inc>
#include <menu.inc>
#include "feedef.h"
#define MAXNUM 50
UL *modi_no; /* modified/deleted record No */
TIME_STRUCT *modi_date;
/* function : display and handle the out-of-range telephone records
* called by : phone_record_proc()
* date : 1993.10.5
*/
void out_of_range(void)
{
UC ratify;
TABLE_STRUCT record_tbl = { 0, 99, 20, 18, 16, 9,
{44, 85, 70, 175, 44, 44, 44, 52, 60},
GREEN
};
TIME_STRUCT in_stime={0,0,0,0}, in_etime={0,0,0,24};
ratify = set_in_time(&in_stime, &in_etime); /* set in-range time */
if(ratify == 1) /* ESC */
return;
modi_no = (UL *)farcalloc(MAXNUM, sizeof(UL));
if(modi_no == NULL)
exit_scr(1,"Out of memory %lu bytes!\n\nGFS system shutdown abnormally\n\n\n\n",sizeof(UL)*MAXNUM);
modi_date = (TIME_STRUCT *)farcalloc(MAXNUM, sizeof(TIME_STRUCT));
if(modi_date == NULL)
exit_scr(1,"Out of memory %lu bytes!\n\nGFS system shutdown abnormally\n\n\n\n", sizeof(TIME_STRUCT)*MAXNUM);
clr_DialWin(2);
draw_table(&record_tbl);
// draw_table(&record_tbl);
disp_out_head();
disp_num();
pop_back(MAX_X-S_XAD, D_BOTTOM+1, MAX_X, MAX_Y, 11);
hz16_disp(MES_RIGHT+15, MES_TOP+1,"按键继续", 0); /* press any key */
hz16_disp(220,80,"越 界 国 际 长 途 话 单", BLACK); /* Intern long call */
out_range_proc(IDD, in_stime, in_etime);
clr_scr(220,80,440,97,0,7);
hz16_disp(220,80,"越 界 国 内 长 途 话 单", BLACK); /* national long call */
out_range_proc(DDD, in_stime, in_etime);
clr_scr(220,80,440,97,0,7);
hz16_disp(220,80,"越 界 市 内 电 话 话 单", BLACK); /* local call */
out_range_proc(LDD, in_stime, in_etime);
farfree(modi_date);
farfree(modi_no);
rid_pop();
recover_screen(2);
return;
}
/* function : judge whether the file exists or not
* called by : a general purposed routine
* input : filename -- file name to be checked
* output : TRUE -- exist
* FALSE -- not exist
* date : 1993.10.12
*/
UC file_exist(UC *filename)
{
struct ffblk fblk;
if(findfirst(filename,&fblk,FA_RDONLY) == 0) /* find */
return(TRUE);
else
return(FALSE);
}
/* function : set in-range time
* called by : out_of_range()
* date : 1993.10.8
*/
UC set_in_time(TIME_STRUCT *in_stime, TIME_STRUCT *in_etime)
{
int i,j;
UC backx=10, backy=20;
UC ratify;
UI sx, sy, ex;
TABLE_STRUCT time_tbl = {H_BX-30,H_BY-30,0,40,2,7,\
{40,50,40,40,40,40,40},7};
UNIT_STRUCT cur_unit;
message_disp(8,"←↓→↑ 移动 Enter 输入 F1 确认"); /* move and input */
pop_back(H_BX-40,H_BY-70,H_BX+270,H_BY+80,7); /* big frame */
draw_table(&time_tbl);
hz16_disp(H_BX+50,H_BY-50,"设 定 界 内 时 间",BLACK); /* set range time */
for(i=0;i<2;i++)
for(j=0;j<7;j++)
{
cur_unit.unit_x = i;
cur_unit.unit_y = j;
get_certain(&cur_unit);
sx = cur_unit.dot_sx;
sy = cur_unit.dot_sy;
ex = cur_unit.dot_ex;
switch(j)
{
case 0:
if(i==0) /* from */
hz16_disp(sx+backx,sy+backy,"从",BLACK);
if(i==1) /* to */
hz16_disp(sx+backx,sy+backy,"到",BLACK);
break;
case 2: /* year */
hz16_disp(sx+backx,sy+backy,"年",BLACK);
break;
case 4: /* month*/
hz16_disp(sx+backx,sy+backy,"月",BLACK);
break;
case 6: /* day */
hz16_disp(sx+backx,sy+backy,"日",BLACK);
break;
case 1:
draw_back(sx+backx-12, sy+backy-4, ex+2, sy+backy+20,11);
outf(sx+5, sy+backy , 11, BLACK, "%4u", s_time.year);
if(i==1)
{
draw_back(sx+backx-12, sy+backy-4, ex+2, sy+backy+20, 11);
outf(sx+5,sy+backy,11,BLACK,"%4u",e_time.year);
}
break;
case 3:
draw_back(sx-2,sy+backy-4,ex+2,sy+backy+20,11);
outf(sx+backx,sy+backy,11,BLACK,"%2u",s_time.month);
if(i==1)
{
draw_back(sx-2,sy+backy-4,ex+2,sy+backy+20,11);
outf(sx+backx,sy+backy,11,BLACK,"%2u",e_time.month);
}
break;
case 5:
draw_back(sx-2,sy+backy-4,ex+2,sy+backy+20,11);
outf(sx+backx,sy+backy,11,BLACK,"%2u",s_time.day);
if(i==1)
{
draw_back(sx-2,sy+backy-4,ex+2,sy+backy+20,11);
outf(sx+backx,sy+backy,11,BLACK,"%2u",e_time.day);
}
break;
default:
sound_alarm();
break;
} /* end of "switch(j)" */
} /* end of "for(j), for(i) */
set_finger_color(Dsp_clr.fng_clr);
locate_finger(0, 1);
in_stime->year = s_time.year;
in_stime->month= s_time.month;
in_stime->day = s_time.day;
in_etime->year = e_time.year;
in_etime->month= e_time.month;
in_etime->day = e_time.day;
ratify = input_in_time(in_stime, in_etime);
rid_pop();
message_end();
return(ratify);
}
/* function : input starting time and ending time for sorting
* called by : set_in_time()
* output : in_stime -- starting time for deleting
* in_etime -- ending time for deleting
* esc=1: ESC
* esc=2: F1(ratify)
* date : 1993.10.6
*/
UC input_in_time(TIME_STRUCT *in_stime,TIME_STRUCT *in_etime)
{
UC esc=0, result=0;
UC backx=10, backy=20, high=18, width=40;
UI sx, sy;
UI key;
UL value;
UNIT_STRUCT cur_unit;
for(; ;) /* input data */
{
key = get_key1();
get_current(&cur_unit);
sx = cur_unit.dot_sx;
sy = cur_unit.dot_sy;
switch(key)
{
case ESC:
esc = 1;
break;
case F1:
esc = 2;
break;
case UP:
case DOWN:
if(cur_unit.unit_x == 0)
move_finger(1,1); /* down a step */
else
move_finger(0,1); /* up a step */
break;
case LEFT:
if(cur_unit.unit_y > 2)
move_finger(2,2); /* left two steps */
break;
case RIGHT:
if(cur_unit.unit_y < 4)
move_finger(3,2); /* right two steps */
break;
case ENTER:
if(cur_unit.unit_x==0) /* starting time */
{
switch(cur_unit.unit_y)
{
case 1: /* year */
hide_finger();
result = get_dec(sx,sy+backy,high,width,5,4,\
&value,0x00);
echo_finger();
if(result) /* valid input */
{
in_stime->year = (UI)value;
move_finger(3,2);
}
break;
case 3: /* month */
hide_finger();
result = get_dec(sx,sy+backy,high,width,backx,2,\
&value,0x00);
echo_finger();
if(result) /* valid input */
{
in_stime->month = (UC)value;
move_finger(3,2);
}
break;
case 5: /* day */
hide_finger();
result = get_dec(sx,sy+backy,high,width,backx,2,\
&value,0x00);
echo_finger();
if(result) /* valid input */
{
in_stime->day = (UC)value;
move_finger(1,1);
move_finger(2,4);
}
break;
default:
sound_alarm();
break;
} /* end of "switch(cur_unit.unit_y)" */
} /* end of "if(cur_unit.unit_x==0)" */
else if(cur_unit.unit_x==1) /* ending time */
{
switch(cur_unit.unit_y)
{
case 1: /* year */
do
{
hide_finger();
result = get_dec(sx,sy+backy,high,width,5,4,\
&value,0x00);
echo_finger();
}while(result && (value<in_stime->year));
if(result) /* valid input */
{
in_etime->year = (UI)value;
move_finger(3,2);
}
break;
case 3: /* month */
do
{
hide_finger();
result = get_dec(sx,sy+backy,high,width,backx,2,\
&value,0x00);
echo_finger();
}while(result && (in_stime->year==in_etime->year) \
&& (value<in_stime->month) );
if(result) /* valid input */
{
in_etime->month = (UC)value;
move_finger(3,2);
}
break;
case 5: /* day */
do
{
hide_finger();
result = get_dec(sx,sy+backy,high,width,backx,2,\
&value,0x00);
echo_finger();
}while(result && (in_stime->year==in_etime->year) \
&& (in_stime->year==in_etime->year) \
&& (value<in_stime->day) );
if(result) /* valid input */
in_etime->day = (UC)value;
break;
default:
sound_alarm();
break;
} /* end of "switch(cur_unit.unit_y)" */
} /* end of "else if(cur_unit.unit_x==1)" */
break; /* for "case ENTER:" */
default:
sound_alarm();
break;
} /* end of "switch(key)" */
if(esc != 0)
break;
} /* end of "for(;;)" */
return(esc);
}
/* function : display head for out-of-range records
* called by : out_of_range()
* date : 1993.10.8
*/
void disp_out_head(void)
{
outf(7, 103, 7,0, "序号"); /* sequence num */
outf(52, 103, 7,0, "分 机"); /* caller */
outf(133, 103, 7,0, "授权用户"); /* authorized user */
outf(207, 103, 7,0, "通达地区"); /* callee */
outf(281, 103, 7,0, "被 叫"); /* callee */
outf(386, 103, 7,0, "日期"); /* date */
outf(433, 103, 7,0, "起时"); /* starting time */
outf(478, 103, 7,0, "时长"); /* duration */
outf(518, 103, 7,0, "附加费"); /* main caller 2 */
outf(576, 103, 7,0, "话 费"); /* charge fee */
return;
}
/* function : display head for out-of-range records
* called by : out_of_range()
* date : 1993.10.8
*/
void disp_num(void)
{
int i;
for(i=0; i<16; i++) /* DISPLAY No. IN THE TABLE */
outf(20, i*19+123, 7, 0, "%x", i);
return;
}
/* function : handle the out-of-range records
* called by : out_of_range()
* input : mode -- IDD,DDD,LDD
* in_stime -- in_range starting time
* in_etime -- in_range ending time
* date : 1993.10.8
* procedure : first display the out-of-range records, when full of 16,
* ask whether to delete or modify some items. If not, go
* to display the next page, otherwise, remember the
* record No(the sequence No in *.dat) to modi_no[], and
* set the corresponding modi_date[]. The max number of
* records that can be deleted or modified is 50.
* In file_refresh(), compare the record No with modi_no[],
* if equal, reset the date or not copy it, according to
* modifying or deleting
* data : modi_no[] -- remember the record No of modified/deleted records
* in file (bei shan chu hua dan de ji lu hao)
* modi_date[] -- remember the modified date of modified/deleted
* records
* modi -- remember all the number of records modified or deleted,
* used for modi_no[] and modi_date[]
* tbl_no -- the row number in the table, transformed from
* '0'-'9' or 'a'-'f'
* out_no[] -- remember the record No in the file for the 16
* out-of-range records in the table
*/
void out_range_proc(UC mode, TIME_STRUCT in_stime, TIME_STRUCT in_etime)
{
FILE *fp;
char *a_name="不明";
UC auth_name[9];
UC position=0; /* for display in table */
UC re_do=0, ch[2]="\0\0";
UC modi=0, tbl_no;
UC res, in_flag, modi_flag, pass_flag, flag;
UI i, key;
UL rec_no;
UL out_no[16], value;
RATE_STRUCT huge *rate_tmp;
UNIT_STRUCT cur_unit;
flag = load_rate_tab();
if(flag != TRUE)
{
message(RATE_FILE_ERR);
return;
}
flag = load_authcd_tbl(0);
if(flag != TRUE)
Authflg = OFF;
else
Authflg = ON;
if(mode == IDD)
{
fp = fopen("idd.dbf","rb");
if(fp==NULL)
{
get_key1();
unload_rate_tab();
if(Authflg == ON)
unload_authcd_tbl();
return;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -