del_all.c

来自「BC3.1编译,小交换机计费系统.使用Dos做出如此好的界面,少有.」· C语言 代码 · 共 517 行 · 第 1/2 页

C
517
字号
#include <string.h>
#include <stdlib.h>
#include <graphics.h>
#include <key.inc>
#include <bio.inc>
#include <menu.inc>
#include "feedef.h"

/* function  : delete all the telephone records in the sorting time range
 * called by : phone_record_proc()
 * date      : 1993.10.5
 */
void delete_all_record(UC isauthcd)
{
    UC   ratify, ret_val, flag;
    TIME_STRUCT  del_stime={0,0,0,0}, del_etime={0,0,0,24};

    flag = valid_pass(DEL_PWD);
    if(flag == 2)                 /* ESC */
        return;
    if(flag == FALSE)
    {
        message(PASS_ERR);
        return;
    }

    ratify = set_del_time(&del_stime,&del_etime);
    if((ratify==1) || (del_etime.year==0) || (del_etime.month==0) || (del_etime.day==0))
        return;

    /* Conform for deleting*/
    if(isauthcd == AUTH_CD)
        ret_val = select_1in2(9);
    else if(isauthcd == PHONE_NO)
        ret_val = select_1in2(8);
    else
        ret_val = select_1in2(7);

    if (ret_val!=2) return;

    message_disp(8,"正在进行删除, 请稍候...");   /* deleting, please wait */

    del_a_kind_file(IDD, CRNT_F, isauthcd, del_stime, del_etime);
    del_a_kind_file(IDD, HIST_F, isauthcd, del_stime, del_etime);
    del_a_kind_file(DDD, CRNT_F, isauthcd, del_stime, del_etime);
    del_a_kind_file(DDD, HIST_F, isauthcd, del_stime, del_etime);
    del_a_kind_file(LDD, CRNT_F, isauthcd, del_stime, del_etime);
    del_a_kind_file(LDD, HIST_F, isauthcd, del_stime, del_etime);

    message_end();

    return;
}

/* function  : set time for deleting
 * called by : delete_record()
 * output    : ratify=1: ESC
 *             ratify=2: F1
 * date      : 1993.10.5
 */
UC  set_del_time(TIME_STRUCT *del_stime,TIME_STRUCT *del_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+25,H_BY-45,"设 定 删 除 时 间 区 间",BLACK);  /* set deleting 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-2,sy+backy-4,ex+2,sy+backy+20,11);
                    break;
                case 3:
                    draw_back(sx-2,sy+backy-4,ex+2,sy+backy+20,11);
                    break;
                case 5:
                    draw_back(sx-2,sy+backy-4,ex+2,sy+backy+20,11);
                    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);

    ratify = input_del_time(del_stime,del_etime);

    rid_pop();
    message_end();
    return(ratify);
}

/* function  : input starting time and ending time for sorting
 * called by : set_del_time()
 * output    : del_stime -- starting time for deleting
 *             del_etime -- ending   time for deleting
 *             esc=1: ESC
 *             esc=2: ratify (F1)
 * date      : 1993.10.6
 */
UC  input_del_time(TIME_STRUCT *del_stime,TIME_STRUCT *del_etime)
{
    UC   esc=0,result=0;
    UC   backx=10,backy=20,high=20,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 */
                        do
                        {
                            hide_finger();
                            result = get_dec(sx,sy+backy,high,width,5,4,\
                                                            &value,0x00);
                            echo_finger();
                        }while(result  && (value < 1900) );

                        if(result)     /* valid input */
                        {
                            del_stime->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 &&  (value > 12) );

                        if(result)     /* valid input */
                        {
                            del_stime->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 > 31) );

                        if(result)     /* valid input */
                        {
                            del_stime->day = (UI)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<1993) || (value<del_stime->year) ));

                        if(result)     /* valid input */
                        {
                            del_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 && ((value<1) || (value>12) || \

⌨️ 快捷键说明

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