?? set_phon.c
字號:
warn_mesg(title, warn);
get_current(&cur);
xs = cur.dot_sx;
ys = cur.dot_sy;
xe = cur.dot_ex;
ye = cur.dot_ey;
setfillstyle(1, 7);
bar(xs, ys, xe, ye);
break;
}
tbl++;
num++;
}while (tbl->phone_no[0] && num < MAX_USERS);
}while (tbl->phone_no[0] && num < MAX_USERS);
if(result) {
Phone_top[pos-1].code = (UI)value;
Phone_top[pos-1].set_flag = 1;
}
}
else
{
if(Phone_top[Count+cur_unit.unit_x-1].flag == FALSE)
{
Phone_top[Count+cur_unit.unit_x-1].flag = TRUE;
outf(xs+8,ys+1,BK_CLR,CHR_CLR, "打");
}
else
{
Phone_top[Count+cur_unit.unit_x-1].flag = FALSE;
outf(xs+8,ys+1,BK_CLR,CHR_CLR, "否");
}
}
move_finger(3,1);
// echo_finger();
// message_end();
break;
case 3:
message_disp(8,"0-限撥 1-市話 2-農話 3-信息臺 4-國內 5-國際 Enter 確認"); /* input 0--5*/
value = 0;
do
{
set_get_color(0, 10, 10, 7, LIGHTRED);
res = get_dec(xs, ys, 18, 35, 6, 1, &value, 0x00);
}while(res && value>5 );
if(res)
{
Phone_top[pos-1].class = value;
Phone_top[pos-1].set_flag = 2;
move_finger(3,1);
}
echo_finger();
message_end();
break;
case 4:
case 5:
case 6:
case 7:
case 8:
Phone_top[pos-1].feeflag[cur_unit.unit_y-4] =
!(Phone_top[pos-1].feeflag[cur_unit.unit_y-4]);
if (!Phone_top[pos-1].feeflag[cur_unit.unit_y-4])
outf(xs+11, ys+1, BK_CLR, YELLOW, "否", 0);
else
outf(xs+11, ys+1, BK_CLR, CHR_CLR, "計", 0);
move_finger(3,1);
break;
case 9:
message_disp(8,"每次通話最長時間(0-不限 1--99分鐘) Enter 確認"); /* input 0--5*/
value = 0;
set_get_color(0, 10, 10, 7, 0);
res = get_dec(xs, ys, 18, 35, 2, 2, &value, 0x00);
if(res)
{
Phone_top[pos-1].max_min = value;
Phone_top[pos-1].set_flag = 3;
move_finger(3,1);
}
move_finger(1,1);
move_finger(2,ITEM_NUM-2);
echo_finger();
message_end();
break;
default:
sound_alarm();
break;
}/* END OF SWITCH */
return;
}
/* function : page up
* calls : clr_phone_tbl,disp_phone_tbl
* called by: input_data()
* date :
*/
void pgup_phone_tbl(UC mode)
{
/***** IF THE FIRST PAGE, RETURN. *****/
if((Count-16) < 0)
{
sound_bell();
return;
}
/***** DISPLAY THE LAST PAGE. *****/
hide_finger();
brush_tbl(ITEM_NUM, 16, 7);
Count = Count-16;
disp_phone_tbl(&Phone_top[Count-1], Count, mode);
locate_finger(15,1);
}
/* function : page down
* calls : clr_phone_tbl,disp_phone_tbl
* called by: input_data()
* date :
*/
void pgdn_phone_tbl(UC mode)
{
UC *title = "注意:";
UC *warn = "最多只能有這么多分機號碼!";
/***** IF MORE THAN THE MAX LENGTH, WARN AND RETURN. *****/
if(Count+15 >= MAX_USERS)
{
warn_mesg(title, warn);
return;
}
/***** IF END OF TABLE, RETURN. *****/
if((Count+15) > Newlen)
{
sound_bell();
return;
}
/***** DISPLAY THE NEXT PAGE. *****/
Count = Count+16;
hide_finger();
brush_tbl(ITEM_NUM, 16, 7);
disp_phone_tbl(&Phone_top[Count-1], Count, mode);
locate_finger(0,1);
}
/* function : Save the phone num table.
* calls : None
* called by: input_phone_num()
* input : status -- 0: no refresh, 1:refresh
* mode -- 0: no send 1:send
* date :
*/
void save_phone_tbl(UC status, UC mode)
{
UC flag;
FILE *fp;
PHONE_STRUCT newitem;
struct ffblk charg_fblk;
Newlen = phone_tbl_len();
if(Newlen == 0)
{
flag = findfirst(ChargeDataFile[PHONE_CASH],&charg_fblk,FA_RDONLY);
if(flag == 0)
remove(ChargeDataFile[PHONE_CASH]);
return;
}
message_disp(8,"正在存盤,請稍候..."); /* saving, please wait... */
/***** RESORT THE PHONE TABLE *****/
while(Oldlen < Newlen)
{
newitem = Phone_top[Oldlen];
sort_phone_tbl(&newitem);
Oldlen += 1;
}
/* Download the phones */
if(mode == SET_PCODE)
send_pcode_tbl();
/***** SAVE THE PHONE TABLE *****/
fp = fopen(ChargeDataFile[PHONE_CASH], "wb");
fwrite(Phone_top, sizeof(PHONE_STRUCT), Newlen, fp);
fclose(fp);
message_end();
if(status == REFRESH)
{
hide_finger();
hide_finger();
brush_tbl(ITEM_NUM, 16, 7);
disp_phone_tbl(&Phone_top[Count-1], Count, mode); /* REDISPLAY */
echo_finger();
}
if(Cashflg[PHONE_CASH]) /* refresh the cash table */
check_maint_cash(PHONE_CASH);
return;
}
/* function: Increase and resort the rate table.
* calls: maxnum()
* called by: input_phone_num()
* input: newitem -- a new item of phone number
*/
void sort_phone_tbl(PHONE_STRUCT *newitem)
{
int result;
UI num;
PHONE_STRUCT *tbl, *tblptr;
if(!strcmp(newitem->phone_no, "")) /* if it is null */
return;
tbl = Phone_top;
num = 0;
/**** If the rate table is empty, the new item is
the first one in the table. ****/
if(!Oldlen)
{
tbl[0] = *newitem;
return;
}
/**** The new item is inserted in middle of the table. ****/
do
{
result = strcmp(tbl->phone_no, newitem->phone_no);
if(!result) /* result=0 : the two strings are equal */
return;
if(result > 0) /* INSERT HERE */
{
tblptr = &Phone_top[Oldlen];
while(tblptr > tbl)
{
*tblptr = *(tblptr-1);
tblptr--;
}
*tblptr = *newitem;
return;
}
tbl++;
num++;
}while(strlen(tbl->phone_no) && num<MAX_USERS);
/**** The new item is the last one in the rate table. ****/
*tbl = *newitem;
}
/* function : Delete a item in the phone number table.
* calls : clr_phone_tbl,disp_phone_tbl
* called by: input_phone_num()
*/
void delete_num(UC mode)
{
UI x, y;
UI xs, ys, xe, ye;
UI pos,cur_pos;
UC result;
UNIT_STRUCT cur_unit;
PHONE_STRUCT *tbl;
get_current(&cur_unit);
pos = Count+ cur_unit.unit_x;
if(pos > Newlen)
{
sound_bell();
return;
}
/***** CLEAR THE ITEM DELETED WITH "- - -". *****/
hide_finger();
xs = cur_unit.dot_sx;
ys = cur_unit.dot_sy;
xe = cur_unit.dot_ex;
ye = cur_unit.dot_ey;
setfillstyle(1,0);
bar(xs,ys,xe,ye);
x = (cur_unit.dot_ex-cur_unit.dot_sx-8)/2+cur_unit.dot_sx;
y = (cur_unit.dot_ey-cur_unit.dot_sy-16)/2+cur_unit.dot_sy;
outf(x-20, y, 0, 14, "%s", "- - - -");
echo_finger();
/***** DISPLAY THE DELETE MENU. *****/
sound_alarm();
result = select_1in2(10);
/***** NOT DELETE *****/
if(!result || result==1)
{
hide_finger();
brush_tbl(ITEM_NUM, 16, 7);
disp_phone_tbl(&Phone_top[Count-1], Count, mode);
echo_finger();
return;
}
/***** DELETE A ITEM *****/
tbl = &Phone_top[pos-1];
cur_pos = pos;
while( (strlen(tbl->phone_no)) && (cur_pos<Newlen) )
{
*tbl= *(tbl+1);
tbl++;
cur_pos++;
}
memset(&Phone_top[Newlen-1], 0, sizeof(PHONE_STRUCT));
Newlen--;
if((pos-1) < Oldlen) /* equal to "pos <= Oldlen" */
Oldlen--;
hide_finger();
brush_tbl(ITEM_NUM, 16, 7);
disp_phone_tbl(&Phone_top[Count-1], Count, mode); /* REDISPLAY */
echo_finger();
return;
}
/* function : let phone no add one automaticaly
* date : 1993.11.19
*/
void auto_add_one(UC mode)
{
int result;
UC phone_buf[10] = "";
UC *title = "注意:";
UC *warn = "分機號碼或內碼已存在,內碼越界!";
UI pos;
UI num;
UI code;
UL phone;
PHONE_STRUCT *tbl;
UNIT_STRUCT cur_unit;
hide_finger();
get_current(&cur_unit);
pos = Count+cur_unit.unit_x;
if((pos==1) || (pos<=Oldlen) || pos>MAX_USERS)
{
sound_bell(); /* add only, do not change */
echo_finger();
return;
}
/* let phone no add one automaticaly */
phone = atol(Phone_top[pos-2].phone_no)+1;
ltoa(phone,phone_buf,10);
if(Phone_top[pos-2].code != UNUSED_CODE)
{
code = Phone_top[pos-2].code+1;
if(!Sys_mode.com_m[code/PhonesPerPort])
code = UNUSED_CODE;
}
else
code = UNUSED_CODE;
tbl = Phone_top;
num = 0;
do
{
result = ( strcmp(tbl->phone_no, phone_buf)
|| code==tbl->code || !Sys_mode.com_m[code/PhonesPerPort]);
/*** THE phone No. INPUTTED ALREADY EXIST, REINPUT ***/
/* Phone_top[pos-1] is the item being
* editted, so not judge it
*/
if((!result) && (tbl!=&Phone_top[pos-1]))
{
warn_mesg(title, warn);
echo_finger();
return;
}
tbl++;
num++;
}while(strlen(tbl->phone_no) && num<MAX_USERS);
ltoa(phone,Phone_top[pos-1].phone_no,10);
Phone_top[pos-1].code = code;
Phone_top[pos-1].class = Phone_top[pos-2].class;
Phone_top[pos-1].feeflag[0] = Phone_top[pos-2].feeflag[0];
Phone_top[pos-1].feeflag[1] = Phone_top[pos-2].feeflag[1];
Phone_top[pos-1].feeflag[2] = Phone_top[pos-2].feeflag[2];
Phone_top[pos-1].feeflag[3] = Phone_top[pos-2].feeflag[3];
Phone_top[pos-1].feeflag[4] = Phone_top[pos-2].feeflag[4];
Phone_top[pos-1].max_min = Phone_top[pos-2].max_min;
Phone_top[pos-1].set_flag = 2;
/* display the phone no */
disp_phone_tbl(&Phone_top[Count-1], Count, mode);
move_finger(1,1);
echo_finger();
Newlen = phone_tbl_len();
return;
}
UC select_1in3(void)
{
UC result;
UC *topic = " 您想退出嗎?";
UC *select[3] = {"不退出","存盤退出","不存盤退出"};
message_disp(8,"←↓→↑ 選擇 Enter 選中"); /*left up right down*/
set_menu(7, 0, FALSE, TRUE);
sound_alarm();
result = hv_menu(219, 257, 1, 3, topic, select);
message_end();
return result;
}
UC select_1in2(UC mode)
{
UC result;
UC *topic1 = " 您需要從話單庫中刪除已備份話單嗎?";
UC *topic2 = " 您確實需要刪除已備份話單話單嗎?";
UC *topic3 = " 您需要打印電話費用單據嗎?";
UC *topic4 = " 您需要打印電話話單嗎?";
UC *topic5 = " 話費結算是否成功?";
UC *topic6 = " 您確實需要清除話單存儲器嗎?";
UC *topic7 = " 您確實需要刪除全部話單嗎?";
UC *topic8 = " 您確實需要刪除所有分機話單嗎?";
UC *topic9 = " 您確實需要刪除所有授權人話單嗎?";
UC *topic10= " 您想刪除此項嗎?";
UC *select1[2] = {"確認","取消"};
UC *select2[2] = {"取消","確認"};
UC *select3[2] = {"取 消", "打 印"};
UC *select5[2] = {"打 印", "取 消"};
UC *select4[2] = {"成 功", "不成功"};
message_disp(8,"← → 移動 Enetr 確認");
set_menu(7, 0, TRUE, TRUE);
if(mode == 1)
result = hv_menu(H_BX, H_BY, 2, 2, topic1, select1);
else if(mode == 2)
result = hv_menu(H_BX, H_BY, 2, 2, topic2, select2);
else if(mode == 3)
result = hv_menu(H_BX, H_BY, 2, 2, topic3, select3);
else if(mode == 4)
result = hv_menu(H_BX, H_BY, 2, 2, topic4, select3);
else if(mode == 5)
result = hv_menu(H_BX, H_BY, 2, 2, topic5, select4);
else if(mode == 6)
result = hv_menu(H_BX, H_BY, 2, 2, topic6, select2);
else if(mode == 7)
result = hv_menu(H_BX, H_BY, 2, 2, topic7, select2);
else if(mode == 8)
result = hv_menu(H_BX, H_BY, 2, 2, topic8, select2);
else if(mode == 9)
result = hv_menu(H_BX, H_BY, 2, 2, topic9, select2);
else if(mode == 10)
result = hv_menu(H_BX, H_BY, 2, 2, topic10,select2);
else if(mode == 11)
result = hv_menu(H_BX, H_BY, 2, 2, topic3, select5);
message_end();
return result;
}
void send_pcode_tbl()
{
PHONE_STRUCT *tbl;
UC tmp[10];
int i;
/* shake hand with host */
if(ShakeHandAll() != 0)
return ;
tbl = Phone_top;
for(i=0; i<Newlen ; i++) {
if(tbl->set_flag && tbl->code != UNUSED_CODE) {
sprintf(tmp, "%02d%02d%02d", tbl->code%PhonesPerPort, (int)(tbl->class),(int)(tbl->max_min));
if(DownloadCode(tmp, 0, 6, 0xC0, tbl->code/PhonesPerPort) != 0) break;
tbl->set_flag = 0;
}
tbl++;
}
return;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -