總 分 類 帳
範圍選擇 |
總科目查詢 |
萬年曆 |
原始程式
原始檔-起始 /*---------( FSACR061.C )---------*/ #include "W_FSAC.H" #define SX 20 /*左內框 */ #define SY 10 /*上內框 */ #define SC 42 /*內框寬, 多少行 */ 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 R061Tx(); void ShowHead(); void ShowData(); void ShowEnd(); char *ChainYn(); /*================================================================*/ FSACF001_T ACF001; FSACF011_T ACF011; double Dsum,Csum,Rest; char Yn; DATE LastYM; char *Table="\ \ 總 分 類 帳 \ ======================================== \ 月份: ----- 至: ----- \ 總科目別> 自: ---- -------------------- \ 到: ---- -------------------- \ 連續列印: ------ \ \ 資料輸出裝置:-------- \ "; /*===========================================================================*/ void main() { USetBXYN(Table,SX,SY,SC); OPEN_ACF001; OPEN_ACF011; R061Tx(); 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); if(RetKey==F4) Utx_Pick(Tx,Skey,BXN(3)," 科 目 查 詢 ",V_WUSR); ShowACN(Skey,BXN(4)); } if(Field==4){ if(Ekey[0]<=SPACE) UShowSL(BXN(5),Skey,V_WUSR); UReadS(BXN(5),Ekey,"NL",V_WUSR,V_READ); if(RetKey==F4) Utx_Pick(Tx,Ekey,BXN(5)," 科 目 查 詢 ",V_WUSR); ShowACN(Ekey,BXN(6)); } if(Field==5){ UReadTog(BXN(7),&Yn,V_TOG,"YN","連續","換頁"); UShowSL( BXN(7),ChainYn(),V_WUSR); } if(RetKey==F4){ ACF001Tx(); Utx_View(Tx," 科 目 查 詢 ");} #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(p->KEY[4]>SPACE) continue; /*總科目*/ if(memcmp(p->KEY,Skey,4)<0) continue; if(memcmp(p->KEY,Ekey,4)>0) 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(memcmp(p->AC,Skey,4)<0 || memcmp(p->AC,Ekey,4)>0) continue; USprint(BufS,"%S--%M----",p->AC,p->YM); Usp_InsIp(Sp,BufS,L); } READ2 Ugd_Close(); /*------------------------------------------------------------------*/ Ugd_Open("列印中 Ctr_F7:結束列印"); Dsum=Csum=Rest=0.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,4,ON); /*連續印*/ else LevelBreak(ACF011.AC,4,OFF); /*換頁印*/ if(K0==0){ K0=1; ShowHead(); LastYM.D=0; } ShowData(); if(Psf=='S' && K0>=20){ 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) { sprintf(BufS,"%s ",s); if(Ufk_Read(ACF001K,&ACF001,BufS)==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 ACF001; #ifdef HP-5L /*1998/8/27*/ LockItemHead(2,"~I",NamS,"~Z2W1G2X16"); #else LockItemHead(2,"~IG2",NamS,"~Z1"); #endif strcpy(&LastKey[4]," "); if(Ufk_Read(ACF001K,&ACF001,LastKey)==OFF) memset(&ACF001,NULL,sizeof(ACF001)); UPrint("#自 %M--- 到 %M--- 第 %I-- 頁 ",Sday,Eday,P0); UPrint(" %S-- %S------------------ 列印:%M------",ACF001.KEY,ACF001.ACN,Day); UPrint("======================================================================================================================"); UPrint("傳票日期 摘 要 借方金額 貸方金額 餘額 科 目 名 稱 傳票號 兌現日期"); 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(Ufk_Read(ACF001K,&ACF001,ACF011.AC)==OFF) memset(&ACF001,NULL,sizeof(ACF001)); if(UHowDate(LastYM) == UHowDate(ACF011.YM)) ACF011.YM.D=0; else LastYM = ACF011.YM; if(ACF011.DC=='D') { Dsum+=ACF011.AMT; Rest+=ACF011.AMT; SetDC(Rest); UPrint("%M------ %S------------------------------- %F,-------- %S %F,-------- %S------------------ %S---- %M------",ACF011.YM,ACF011.RM,ACF011.AMT,TmpS,fabs(Rest),ACF001.ACN,ACF011.KEY,ACF011.CYM); } else { Csum+=ACF011.AMT; Rest-=ACF011.AMT; SetDC(Rest); UPrint("%M------ %S------------------------------- %F,-------- %S %F,-------- %S------------------ %S---- %M------",ACF011.YM,ACF011.RM,ACF011.AMT,TmpS,fabs(Rest),ACF001.ACN,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){ fprintf(Stream,"\n\n"); K0+=2; 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(""); K0=0; Vw.lhed=OFF; break; } } /*===========================================================================*/ void R061Tx() { if((fpNDX=fopen(NDXDISK,"r+b"))==NULL) UFatal("無科目索引"); L=filelength(fileno(fpNDX))/NDXL+30; /*計算配置個數*/ Tx=Utx_Open(45,4,76,23,L,5,OFF); while(1) { if(fread(TmpS,NDXL,1,fpNDX) < 1) break; if(TmpS[0]<=SPACE || TmpS[4]>SPACE || TmpS[0]>='Z') continue; Utx_Ins(Tx,"%S-- %S------------------",TmpS,&TmpS[8]); } } /*================================================================*/ char *ChainYn() { switch(Yn) { case 'Y': return "連續"; case 'N': return "換頁"; default : return " "; } } 原始檔-結束
Byron Wey Oct.21.1998