del_all.c
来自「BC3.1编译,小交换机计费系统.使用Dos做出如此好的界面,少有.」· C语言 代码 · 共 517 行 · 第 1/2 页
C
517 行
((del_stime->year==del_etime->year) && \
(value<del_stime->month)) ));
if(result) /* valid input */
{
del_etime->month = (UI)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 && ((value<1) || (value>31) || \
((del_stime->year ==del_etime->year) && \
(del_stime->month==del_etime->month)&& \
(value<del_stime->day)) ));
if(result) /* valid input */
del_etime->day = (UI)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 : judge whether the record is in the deleting time range or not
* called by : delete_record()
* input : del_stime -- starting time for deleting
* del_etime -- ending time for deleting
* output : TRUE -- in the deleting range
* FALSE -- not in the deleting range
* date : 1993.10.5
* note : only judge whether the ending time of the record is in the
* range or not
*/
UC in_time_range(TIME_STRUCT del_stime,TIME_STRUCT del_etime)
{
UC ok1=0, ok2=0;
if(temp_list.year2 > del_stime.year)
ok1 = 1;
else if(temp_list.year2 == del_stime.year)
if(temp_list.mon2 > del_stime.month)
ok1 = 1;
else if(temp_list.mon2 == del_stime.month)
if(temp_list.day2 > del_stime.day)
ok1 = 1;
else if(temp_list.day2 == del_stime.day)
if(temp_list.hour2 >= del_stime.hour)
ok1 = 1;
if(ok1 == 1)
{
if(temp_list.year2 < del_etime.year)
ok2 = 1;
else if(temp_list.year2 == del_etime.year)
if(temp_list.mon2 < del_etime.month)
ok2 = 1;
else if(temp_list.mon2 == del_etime.month)
if(temp_list.day2 < del_etime.day)
ok2 = 1;
else if(temp_list.day2 == del_etime.day)
if(temp_list.hour2 <= del_etime.hour)
ok2 = 1;
} /* if(ok1==1) */
if((ok1==1) && (ok2==1))
return(TRUE);
else
return(FALSE);
}
UC valid_pass(UC mode)
{
int i,cmp;
FILE *fp;
UC password0[7]="",password1[7]="";
UC input_num=0,flag;
if(mode == CLR_PWD)
{
fp = fopen("gfsdata\\clrpwd.dat","rb"); /* read the password */
}
else if(mode == DEL_PWD)
{
fp = fopen("gfsdata\\delpwd.dat","rb"); /* read the password */
}
else
{
fp = fopen("gfsdata\\cashpwd.dat","rb"); /* read the password */
}
if(fp == NULL)
flag = 0;
else
{
flag = 1;
fread(password0,sizeof(UC),7,fp);
fclose(fp);
}
if(mode == DEL_PWD)
message_disp(8," 输入话单备份/删除操作口令 Enter 输入");
else if(mode == CLR_PWD)
message_disp(8," 输入清除话单存储器操作口令 Enter 输入");
else
message_disp(8," 输入用户管理口令 Enter 输入");
pop_back(H_BX-40,H_BY-10,H_BX+260,H_BY+35,7); /* big frame */
draw_back(H_BX+132,H_BY,H_BX+250,H_BY+25,11);
if(mode == DEL_PWD)
hz16_disp(H_BX-20,H_BY+5,"备份/删除操作口令",BLACK); /* input password */
else if(mode == CLR_PWD)
hz16_disp(H_BX-25,H_BY+5,"清除缓存器操作口令",BLACK); /* input password */
else
hz16_disp(H_BX-17,H_BY+5,"用户管理操作口令",BLACK); /* input password */
input_num = get_pass(H_BX+138,H_BY+5,11,0,password1,6);
rid_pop();
message_end();
if(input_num == 0xFF) /* ESC */
return(2);
if(input_num != 6)
return(FALSE);
for(i=0;i<6;i++)
password1[i] += 0x10;
password1[6] = '\0';
if(flag == 0) /* the password is input the first time */
{
if(mode == DEL_PWD)
{
fp = fopen("gfsdata\\delpwd.dat","wb");
}
else if(mode == CLR_PWD)
{
fp = fopen("gfsdata\\clrpwd.dat","wb");
}
else
{
fp = fopen("gfsdata\\cashpwd.dat","wb");
}
fwrite(password1,sizeof(UC),7,fp);
fclose(fp);
return(TRUE);
}
else
{
cmp = strcmp(password0,password1);
if(cmp == 0) /* the same */
return(TRUE);
else
return(FALSE);
}
}
void del_a_kind_file(UC mode, UC is_hst, UC isauthcd, TIME_STRUCT del_stime,\
TIME_STRUCT del_etime)
{
FILE *fps, *fpd;
UC deled_file[15]="";
if(mode == IDD)
strcpy(deled_file, "idd");
else if(mode == DDD)
strcpy(deled_file, "ddd");
else
strcpy(deled_file, "ldd");
if(is_hst == HIST_F)
strcat(deled_file, ".hst");
else
strcat(deled_file, ".dbf");
fps = fopen(deled_file,"rb");
if(fps != NULL)
{
if(mode == IDD)
fpd = fopen("idd.del","wb");
else if(mode == DDD)
fpd = fopen("ddd.del","wb");
else
fpd = fopen("ldd.del","wb");
while(fread(&temp_list,sizeof(RECORD_STRUCT),1,fps) == 1)
{
if(in_time_range(del_stime, del_etime) /*&& temp_list.flag == FALSE*/) /* in deleting range */
{
if( (isauthcd == PHONE_NO) && (temp_list.auth_code != 0xaaaaaa) )
fwrite(&temp_list,sizeof(RECORD_STRUCT),1,fpd);
else if( (isauthcd == AUTH_CD) && (temp_list.auth_code == 0xaaaaaa) )
fwrite(&temp_list,sizeof(RECORD_STRUCT),1,fpd);
}
else
fwrite(&temp_list,sizeof(RECORD_STRUCT),1,fpd);
} /* end of "while(!feof(fps))" */
fclose(fpd);
fclose(fps);
if( mode == IDD && is_hst != HIST_F)
{
fcopy("idd.del","idd.dbf"); /* .del to .dat */
fcopy("idd.del","idd.tmp"); /* .del to .tmp */
remove("idd.del");
}
else if(mode == IDD && is_hst == HIST_F)
{
fcopy("idd.del","idd.hst"); /* .del to .dat */
remove("idd.del");
}
else if(mode == DDD && is_hst != HIST_F)
{
fcopy("ddd.del","ddd.dbf"); /* .del to .dat */
fcopy("ddd.del","ddd.tmp"); /* .del to .tmp */
remove("ddd.del");
}
else if(mode == DDD && is_hst == HIST_F)
{
fcopy("ddd.del","ddd.hst"); /* .del to .dat */
remove("ddd.del");
}
else if(mode == LDD && is_hst != HIST_F)
{
fcopy("ldd.del","ldd.dbf"); /* .del to .dat */
fcopy("ldd.del","ldd.tmp"); /* .del to .tmp */
remove("ldd.del");
}
else if(mode == LDD && is_hst == HIST_F)
{
fcopy("ldd.del","ldd.hst"); /* .del to .dat */
remove("ldd.del");
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?