明 細 分 類 帳

wpe2E.jpg (67498 bytes)

範圍選擇
wpe2F.jpg (6356 bytes)

科目查詢
wpe30.jpg (9239 bytes)

左右捲動
wpe31.jpg (9539 bytes)


原始程式

原始檔-起始
/*---------( FSACR069.C )---------*/
#include    "W_FSAC.H"
#define SX  20            /*左內框                             */
#define SY  10            /*上內框                             */
#define SC  48            /*內框寬, 多少行                     */

struct
{   char     KEY[8];
    char     ACN[21];
    double   AMT;       /* 上期結轉 */
    char     YN;        /* 使用否   */
} WORK;

void ShowACN(char *s,int x,int y,int len);
void SetDC(double amt);
void ShowLast();
void LevelBreak(char *str,int len,int sw);
void ShowHead();
void ShowData();
void ShowEnd();
char *ChainYn();
/*================================================================*/
FSACF001_T   ACF001;
FSACF011_T   ACF011;
double       Dsum,Csum,Rest;
int          Page;
char         Yn;
char        *Table="\
                                                \
                  明 細 分 類 帳                \
 ============================================== \
            月份: ----- 至: -----               \
  明細科目別> 自: ------- --------------------  \
              至: ------- --------------------  \
        連續列印: ------                        \
                                                \
 資料輸出裝置:--------                         \
                                                ";
/*===========================================================================*/
void main()
{  USetBXYN(Table,SX,SY,SC);
    OPEN_ACF001; OPEN_ACF011; R069Tx(); NamS=GET_NAME;
    while(1)
    {   Yn='N';
#define USER_GD
        Ugd_Open("F4:科目查詢       F7:開始列印        Ctr_F7:結束列印");
        #include <RPT1.H>
        if(Field==1) UReadM(BXN(1),&Sday,0,V_WUSR,V_READ);
        if(Field==2) UReadM(BXN(2),&Eday,0,V_WUSR,V_READ);
        if(Field==3){ UReadS(BXN(3),Skey,"NL",V_WUSR,V_READ); ShowACN(Skey,BXN(4));
                      if(RetKey==F4){  ACF001Tx(); Utx_Pick(Tx,Skey,BX[3],BY[3],28," 科 目 查 詢 ",V_WUSR); }
                    }
        if(Field==4){ if(Ekey[0]<=SPACE) UShowSL(BXN(5),Skey,V_WUSR);
                      UReadS(BXN(5),Ekey,"NL",V_WUSR,V_READ); ShowACN(Ekey,BXN(6));
                      if(RetKey==F4){  ACF001Tx(); Utx_Pick(Tx,Ekey,BX[5],BY[5],28," 科 目 查 詢 ",V_WUSR); }
                    }
        if(Field==5){ UReadTog(BXN(7),&Yn,V_TOG,"YN","連續","換頁");
                      UShowSL( BXN(7),ChainYn(),V_WUSR);
                    }
        #include <RPT2.H>  /*條件設定完畢*/
       /*------------------------------------------------------------------*/
        if((Sa=ChkYM(Sday,ON))==0) continue;    Sm=Sday.Y*12+Sday.M;
        if((Ea=ChkYM(Eday,ON))==0) continue;    Em=Eday.Y*12+Eday.M;
        Ugd_Open("檔 案 處 理 中 請 稍 候 ....."); /* Sort  FSACF011 */
       /*------------------------------------------------------------------*/
        OPEN_WORK;     /*上期結轉*/
        READ1(ACF001)
        {   if(memcmp(p->KEY,Skey,7)<0) continue;
            if(memcmp(p->KEY,Ekey,7)>0) continue;
            if(p->KEY[4]<=SPACE) continue;
            memset(&WORK,NULL,sizeof(WORK));
            strcpy(WORK.KEY,p->KEY);
            strcpy(WORK.ACN,p->ACN);
            if(Sa>=13 && p->KEY[0]>='4' && p->KEY[0]<='8') I=13; /*虛科目*/
            else I=0;
            for(; I<Sa; I++) WORK.AMT+=p->AMT[0][I]-p->AMT[1][I];
            Ufk_Write(WORKK,&WORK);
        }
        READ2
       /*------------------------------------------------------------------*/
        Sp=Usp_Open();
        READ1(ACF011)
        {   I=p->YM.Y*12 + p->YM.M;
            if(I<Sm || Em<I) continue;
            if(p->AC[4]<=SPACE) continue;
            if(memcmp(p->AC,Skey,7)<0 || memcmp(Ekey,p->AC,7)<0) continue;
            USprint(BufS,"%S-----%M----",p->AC,p->YM);
            Usp_InsIp(Sp,BufS,L);
        }
        READ2
        Ugd_Close();
       /*------------------------------------------------------------------*/
        Ugd_Open("列印中           Ctr_F7:結束列印");
        Page=0;
        while(RetKey!=ESC)
        {   if(Usp_GetIp(Sp,&L)==OFF) break;
            lseek(ACF011K->ffd,L*sizeof(ACF011),SEEK_SET);
            read(ACF011K->ffd,&ACF011,sizeof(ACF011));
            if(Yn=='Y') LevelBreak(ACF011.AC,7,ON);
            else        LevelBreak(ACF011.AC,7,OFF);
            if(K0==0){ K0=1; ShowHead(); }
            ShowData();
            if(Psf=='S' && K0>=21){ UWait(OFF,"Esc:重新選擇      任一鍵繼續"); UCls(); K0=0; }
            if(Psf=='P' && K0>=K1){ fprintf(Stream,"%c",12); K0=0; }
        }
        ShowLast(); ShowEnd();
        Usp_Close(Sp); LineReturn(ON); Ufk_Close(WORKK);
    }
}
/*===========================================================================*/
void ShowACN(char *s,int x,int y,int len)
{
    if(Ufk_Read(ACF001K,&ACF001,s)==OFF) memset(&ACF001,NULL,sizeof(ACF001));
    UShowSL(x,y,len,ACF001.ACN,V_WUSR);
}
/*===========================================================================*/
void SetDC(double amt)
{
    if(amt>=0) strcpy(TmpS,"借"); else strcpy(TmpS,"貸");
}
/*===========================================================================*/
void ShowHead()
{   FSACF001_T   F001;

    if(Ufk_Read(ACF001K,&F001,LastKey)==OFF) memset(&F001,NULL,sizeof(F001));
    if(K0<=3)
    {
#ifdef   HP-5L          /*1998/8/27*/
        LockItemHead(2,"~I",NamS,"~Z2W1G2X24");
#else
        LockItemHead(2,"~IG2Z2",NamS,"~Z1");
#endif
        UPrint("#自 %M--- 到 %M---                                                       列印:%M------   第%I- 頁 ",Sday,Eday,Day,++Page);
        UPrint("%S----- %S------------------                                                                      ",LastKey,F001.ACN);
        UPrint("==================================================================================================");
        UPrint("傳票日期       摘      要                     借方金額    貸方金額           餘額  傳票號 兌現日期");
        UPrint("-------- --------------------------------- ----------- ----------- -- -----------  ------ --------");
    }
    else
    {
#ifdef   HP-5L          /*1998/8/27*/
        LockItemHead(2,"~I",NamS,"~Z2W1G2X24");
#else
        LockItemHead(2,"~IG2","","~Z1");
#endif
        UPrint("%S----- %S------------------                                                                      ",LastKey,F001.ACN);
        UPrint("==================================================================================================");
    }
    if(P0==1)
    {   if(RetKey==ESC) return;
        if(Ufk_Read(WORKK,&WORK,LastKey)==OFF) memset(&WORK,NULL,sizeof(WORK));
        Rest=WORK.AMT;   SetDC(Rest);
        UPrint("                                                        (上期結轉) %S %F,-------- ",TmpS,fabs(Rest));
        WORK.YN='Y';  Ufk_Write(WORKK,&WORK);  /*表示已使用過*/
    }
}
/*===========================================================================*/
void ShowData()
{
    if(ACF011.DC=='D')
    {   Dsum+=ACF011.AMT;  Rest+=ACF011.AMT; SetDC(Rest);
        UPrint("%M------ %S------------------------------- %F,--------             %S %F,--------  %S---- %M------",ACF011.YM,ACF011.RM,ACF011.AMT,TmpS,fabs(Rest),ACF011.KEY,ACF011.CYM);
    }
    else
    {   Csum+=ACF011.AMT;  Rest-=ACF011.AMT; SetDC(Rest);
        UPrint("%M------ %S-------------------------------             %F,-------- %S %F,--------  %S---- %M------",ACF011.YM,ACF011.RM,ACF011.AMT,TmpS,fabs(Rest),ACF011.KEY,ACF011.CYM);
    }
}
/*===========================================================================*/
void ShowLast()
{
    SetDC(Dsum-Csum);
    UPrint("==================================================================================================");
    UPrint("                                           %F,-------- %F,-------- %S %F,--------  (不含上期結轉) ",Dsum,Csum,TmpS,fabs(Dsum-Csum));
    Dsum=Csum=0;
}
/*===========================================================================*/
void ShowEnd()
{   int    sw=ON;

    lseek(WORKK->kfd,0L,SEEK_SET);    /*有餘額,但本期未發生交易,則顯示餘額*/
    for(RetKey=ON; RetKey!=ESC && RetKey; )
    {   if(Ufk_SeqRead(WORKK,&WORK,"","")!=ON) continue;
        if(WORK.YN=='Y' || WORK.AMT==0f) continue;
        if(sw)
        {   K0=1; UPrint(""); UPrint("");  sw=OFF;
            UPrint("          有餘額, 但本期未發生交易者         ");
            UPrint("=============================================");
            UPrint("科目號     科  目  名  稱    DC      累計餘額");
            UPrint("------- -------------------- -- -------------");
        }
        if(WORK.AMT>0f) strcpy(TmpS,"借");
        else { strcpy(TmpS,"貸"); WORK.AMT=-WORK.AMT; }
        UPrint("%S----- %S------------------ %S %f,----------",WORK.KEY,WORK.ACN,TmpS,WORK.AMT);
    }
}
/*===========================================================================*/
void LevelBreak(char *str,int len,int sw)
{
    if(LastKey[0]==NULL) strcpy(LastKey,str);
    if(memcmp(LastKey,str,len)==0) return;
    ShowLast(); strcpy(LastKey,str); P0=0;
    switch(Psf)
    {   case 'P': if(sw){ for(I=0; I<3; I++) UPrint(""); ShowHead(); }
                  else  { fprintf(Stream,"%c",12); K0=0;               }  break;
        case 'S': if(K0<=23 && K0) UWait(OFF,"Esc:重新選擇      任一鍵繼續");
                  UCls();                    K0=0;                        break;
        case 'V': UPrint(""); UPrint(""); ShowHead();                     break;
    }
}
/*===========================================================================*/
R069Tx()
{
    if((fpNDX=fopen(NDXDISK,"r+b"))==NULL) UFatal("無科目索引");
    L=filelength(fileno(fpNDX))/NDXL+30;  /*計算配置個數*/
    Tx=Utx_Open(47,3,80,24,L,8,ON);
    while(1)
    {   if(fread(TmpS,NDXL,1,fpNDX) < 1) break;
        if(TmpS[0]<=SPACE || TmpS[4]<=SPACE || TmpS[0]>='Z') continue;
        Utx_Ins(Tx,TmpS);
    }
}
/*================================================================*/
char *ChainYn()
{  switch(Yn)
   {  case 'Y': return "連續";
      case 'N': return "換頁";
      default : return " ";
   }
}
原始檔-結束

Byron Wey  Oct.21.1998


回首頁C之城