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

📄 set_cash.c

📁 BC3.1编译,小交换机计费系统.使用Dos做出如此好的界面,少有.
💻 C
📖 第 1 页 / 共 2 页
字号:

/* function  : do as input keys
 * called by : set_cash_pledge()
 * date      : 1993.9.23
 */
void input_cash_data(UC mode)
{
    UI input;
    UC *title = "注意:";
    UC *warn = "最多只能有这么多!";
    UC result;
    UNIT_STRUCT cur_unit;
    UI maxlen;

    maxlen = (mode == PHONE_CASH)? MAX_USERS:MAX_AUTHCD;

    while(1)
    {
	input=get_key1();

	get_current(&cur_unit);

	switch(input)
	{
	    case ESC:   /* QUIT */

		 result=select_1in3();
                 switch(result)
                 {
                     case 1:     /* DON'T QUIT */
                         break;

                     case 2:     /* SAVE AND QUIT */
                         save_cash_tbl(mode);
                         recover_screen(1);
                         return;

                     case 3:     /* QUIT AND DON'T SAVE */
                         recover_screen(1);
			 return;
                 }
                 break;

            case UP:    /* GO TO THE LAST ROW */
                move_finger(0,1);
                break;

            case DOWN:  /* GO TO THE NEXT ROW */
                 if(Count+cur_unit.unit_x == maxlen)
                 {
                      warn_mesg(title, warn);
                      break;
                 }

                 if((Count+cur_unit.unit_x) < Cash_len[mode])
                     move_finger(1,1);
                 else
                     sound_bell();
                 break;

            case LEFT:       /* go to the left colomn */
                 if(cur_unit.unit_y > 2)
                     move_finger(2,1);
                 else
                     sound_bell();
                 break;

            case RIGHT:      /* go to the right column */
                 if( strlen(Cash_top[mode][Count+cur_unit.unit_x-1].phone_no) )
                     move_finger(3,1);
                 else
                     sound_bell();
                 break;

            case PAGEUP:
		 pgup_cash_tbl(SET_CASH, mode);
                 break;

            case PAGEDOWN:
		 pgdn_cash_tbl(SET_CASH, mode);
		 break;

	    case F2:    /* SAVE THE cash TABLE */
		 message_disp(8,"正在存盘,请稍候...");      /* saving, please wait... */
		 save_cash_tbl(mode);
		 message_end();
		 break;

	    case F6:    /* locate according to the phone No input */
		 if(mode == PHONE_CASH)
		     message_disp(8," 输入分机号   Enter 确认");    /*phone no.*/
		 else
		     message_disp(8," 输入卡号   Enter 确认");    /*phone no.*/

		 loc_cash_tbl(SET_CASH);
		 message_end();
		 break;

	    case F7:    /* PAGE No. LOCATE */
                 message_disp(8," 输入页号   Enter 确认");      /*page no.*/
		 loc_cash_page(SET_CASH, mode);
                 message_end();
                 break;

            case ENTER:
                 message_disp(8," 输入数字   Enter 确认");      /*number*/
		 modi_cash_tbl(mode);    /* MODIFY THE cash TABLE */
                 message_end();
                 break;

            default:
                 sound_bell();
                 break;
        }/* END OF SWITCH */
    }/* END OF WHILE */
}

/* function  : modify the cash table
 * called by : input_cash_data()
 * date      : 1993.9.23
 */
void modi_cash_tbl(UC mode)
{
    UI xs, ye, x, y;
    UI result;
    UI back_in=8;
    UL value;
    UNIT_STRUCT cur_unit;

    hide_finger();

    get_current(&cur_unit);
    xs = cur_unit.dot_sx;
    ye = cur_unit.dot_sy;
    x = xs+8;
    y = ye+1;

    switch(cur_unit.unit_y)
    {
        case 2:
            if(Cash_top[mode][Count+cur_unit.unit_x-1].flag == CASH_ON)
            {
                 Cash_top[mode][Count+cur_unit.unit_x-1].flag = CASH_OFF;
                 DRAW_KEY;
            }
            else
	    {
                 Cash_top[mode][Count+cur_unit.unit_x-1].flag = CASH_ON;
                 CHANG_KEY;
            }
            move_finger(3,1);
            break;
        case 3:    /* cash preserved */
            set_get_color(0, 10, 10, BK_CLR, CHR_CLR);
	    result = get_money(xs,ye,18,72,back_in,4,&value,0x0);

	    if(result)
		Cash_top[mode][Count+cur_unit.unit_x-1].cash = value;

	    move_finger(3,1);
	    break;

	case 4:    /* cash bottom limit */
	    set_get_color(0, 10, 10, BK_CLR, CHR_CLR);
	    result = get_money(xs,ye,18,72,back_in,3,&value,0x0);

	    if(result)
                Cash_top[mode][Count+cur_unit.unit_x-1].limit = (UI)value;

            if( (Count+cur_unit.unit_x) < Cash_len[mode] )  /* not the last one */
            {
                move_finger(1,1);
                move_finger(2,2);
             }
            else
                echo_finger();
            break;
        default:
            sound_alarm();
            break;
    }/* END OF SWITCH */

    return;
}

/* function  : save the cash table
 * called by : input_cash_tbl()
 * date      : 1993.9.23
 */
void save_cash_tbl(UC mode)
{
    FILE *fp;

    fp = fopen(CashDataFile[mode], "wb");
    fwrite(Cash_top[mode], sizeof(CASH_PLEDGE), Cash_len[mode], fp);
    fclose(fp);

    return;
}

/* function  : locate according to phone_no
 * called by : input_cash_data()
 * date      : 1993.9.23
 * note      : using the binary-search method
 */
void loc_cash_tbl(UC mode)
{
    CASH_PLEDGE *tbl;
    UC locate_no[7] = "";
    UC result;
    UC *msg="定位号";
    UC *warn="没有号码!";

    pop_back(250, 295, 420, 335, 7);
    draw_back(345, 304, 410, 326, 11);
    outf(260, 308, 7, 0, "%s", msg);

    /***** LOCATE ACCODING TO THE PAGE No. USERS INPUT. *****/
    set_get_color(11, 0, 12, 11, 0);
    result = get_no(350, 306, 18, 24, 0, 6, locate_no, 0x00);

    rid_pop();

    if(!result)      /* IF USER TYPE "Esc", RETRUN. */
        return;

    /***** Locate the position in the cash table according
               to the phone number user typed. *****/
    tbl = binary_cash(locate_no, mode);
    if(tbl == NULL)     /* can not find the phone_number, then warn */
    {
        warn_mesg("", warn);
        return;
    }

    Count = ((UI)(tbl-Cash_top[mode])/16)*16+1;
    hide_finger();
    brush_tbl(5, 16, 7);
    disp_cash_tbl(&Cash_top[mode][Count-1], Count,SET_CASH, mode);
    locate_finger(tbl-Cash_top[mode]-Count+1, 2);       /* LOCATTED */

    return;
}

/*             Function:       Change a page towards up.
	       Calls:          clr_cash_tbl,disp_cash_tbl
               Called by:      input_cash_data
               Input:          None
	       Output:         None
	       Return:         None
	       Date  :         1993.9.23
 */
void pgup_cash_tbl(UC cmode, UC mode)
{
    /***** IF THE FIRST PAGE, RETURN. *****/
    if((Count-16) < 0)
    {
	sound_bell();
	return;
    }

    /***** DISPLAY THE LAST PAGE. *****/
    hide_finger();
    brush_tbl(5, 16, 7);
    Count = Count-16;
    disp_cash_tbl(&Cash_top[mode][Count-1], Count, cmode, mode);
    locate_finger(15,2);

    return;
}

/*             Function:       Change a page towards down.
	       Calls:          clr_cash_tbl,disp_cash_tbl
	       Called by:      input_data
	       Input:          None
	       Output:         None
	       Return:         None
	       Date  :         1993.9.23
 */
void pgdn_cash_tbl(UC cmode, UC mode)
{
    UC *title = "注意:";
    UC *warn  = "最多只能有这么多号码!";
    UI maxlen;

    maxlen = (mode == PHONE_CASH)? MAX_USERS:MAX_AUTHCD;

    /***** IF MORE THAN THE MAX LENGTH, WARN AND RETURN. *****/
    if( (Count+16) > maxlen)
    {
	warn_mesg(title, warn);
	return;
    }

    /***** IF END OF TABLE, RETURN. *****/
    if((Count+16) > Cash_len[mode])
    {
	sound_bell();
	return;
    }

    /***** DISPLAY THE NEXT PAGE. *****/
    Count = Count+16;
    hide_finger();
    brush_tbl(5, 16, 7);
    disp_cash_tbl(&Cash_top[mode][Count-1], Count, cmode, mode);
    locate_finger(0,2);

    return;
}

/*             Function:       Locate according to the page No..
	       Calls:          clr_cash_tbl,disp_cash_tbl
	       Called by:      input_cash_data()
	       Input:          None
               Output:         None
               Return:         None
               Date  :         1993.9.23
 */
void loc_cash_page(UC cmode, UC mode)
{
    UL locate_no=500;
    UI page_no;
    UC result;
    UC *msg="定位页号";
    UC *warn="没有该页号!";

    /***** DISPLAY THE PAGE LOCATE WINDOW. *****/
    pop_back(250, 295, 400, 335, 7);
    draw_back(330, 304, 390, 326, 11);
    outf(260, 308, 7, 0, "%s", msg);

    /***** LOCATE ACCODING TO THE PAGE No. USERS INPUT. *****/
    set_get_color(11, 0, 12, 11, 0);
    result=get_dec(335, 306, 18, 24, 0, 3, &locate_no, 0x00);

    rid_pop();

    if(!result)   /* "Esc" */
	return;

    if(!(Cash_len[mode]%16) && Cash_len[mode])
	 page_no = Cash_len[mode]/16;
    else
	 page_no = (UI)(Cash_len[mode]/16)+1;

    if(!locate_no || locate_no > page_no)
    {
	 warn_mesg("", warn);
	 return;
    }

    /***** DISPLAY THE PAGE. *****/
    hide_finger();
    brush_tbl(5, 16, 7);
    Count = (UI)(locate_no-1)*16+1;
    disp_cash_tbl(&Cash_top[mode][Count-1], Count, cmode, mode);
    locate_finger(0,2);       /* LOCATTED */

    return;
}

/* function  :    Locate the phone number using the binary search method
 * calls     :    None
 * called by :    loc_cash_tbl(), search_area_no()
 * input     :    input_no -- telephone number
 * return    :    The position of location. If not find, return NULL
 * note      :    using binary search method
 * date      :    1993.9.23
 */
CASH_PLEDGE *binary_cash(UC *input_no, UC mode)
{
    CASH_PLEDGE *tbl, *tbl_top;
    UI  tbllen;
    UI  top, bottom, middle;
    int result;

    tbl_top = Cash_top[mode];
    tbl = Cash_top[mode];
    if(Cash_len[mode] == 0)
        tbllen = cash_tbl_len(mode);
    else
        tbllen = Cash_len[mode];

    top = 0;
    bottom = tbllen-1;

    /***** Compare with the first item. *****/
    if(strcmp(    tbl->phone_no,input_no)<0    && \
       strcmp((tbl+1)->phone_no,input_no)>0)
            return(NULL);

    if(strcmp(tbl->phone_no,input_no) > 0)
            return(NULL);

    /***** Compare with the last item. *****/
    if(strcmp(tbl[bottom].phone_no,input_no) < 0)
            return(NULL);

    /***** Compare and locate in the cash table. *****/
    while(top <= bottom)
    {
        middle = (UI) (top+bottom)/2;
        tbl = &tbl_top[middle];
        result = strcmp(tbl->phone_no,input_no);

        if(!result)          /* find! */
            return(tbl);

        else if(result < 0)       /* tbl->phone_no < input_no */
            top = middle+1;
        else if(result > 0)       /* tbl->phone_no > input_no */
            bottom = middle-1;
    }

    return(NULL);                 /* not find! */
}


void indicator(UI x, UI y, UC ind_color)
{
    setcolor(ind_color);
    setfillstyle( SOLID_FILL, ind_color );
    pieslice( x, y, 0, 360, 2 );
    setcolor(8);
    arc( x, y, 45, 235, 5 );
    setcolor(15);
    arc( x, y, 236,44,  5 );
}

⌨️ 快捷键说明

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