常用傳票分錄(設定)
科目查詢 |
拷貝傳票 |
萬年曆 |
原始程式
原始檔-起始 /*---------( FSACPA11.C )---常用傳票-----*/ #include "W_FSAC.H" #define SX 3 /*左內框 */ #define SY 4 /*上內框 */ #define SC 76 /*內框寬, 多少行 */ #define ANO 120 /*ARRAY 陣列筆數*/ #define TNO 3 /*TITLE 抬頭項數*/ #define RNO 16 /*ROW 螢幕列數*/ #define CNO 4 /*COLUMM 各列項數*/ #define SNO 8 /*螢幕起始列數 */ void Field04(); void Del1Page(); char *ChainKI(char KI); char *ChainDC(int r); int SetCon(); void CopyACF011(); /*================================================================*/ FSACF001_T ACF001; FSACF011_T ACF011; FSACFA11_T ACFA11,ACFA11A[ANO]; char *Table="\ 常用編號:---- 名稱:---------------- 傳票別(123):---------------- \ ============================================================================\ 科目號 科 目 名 稱 摘 要 D/C 金 額 \ ------- -------------------- -------------------------- --- ----------- \ \ ============================================================================"; void main() { USetBXYN(Table,SX,SY,SC); UShowTable(3,4,78,SNO-1,Table,V_TABLE); for(I=0; I<RNO; I++) UShowSL(3,I+SNO,76,&Table[(SNO-4)*76],V_TABLE); UShowTable(3,I+SNO,78,strlen(Table)/76+RNO+1,&Table[(SNO-3)*76],V_TABLE); NamS=GET_NAME; USetXN(&Table[(SNO-5)*76]-2); UDrawBox(1,3,80,24,V_BLUE,NO,NO,2); OPEN_ACF001; OPEN_ACFA11; ACF001Tx(); OPEN_ACF011; Ugd_Open("F4:查科目 F8:拷備傳票 F10:刪除 PgDn:存入"); Ufk_ReadLast(ACFA11K,ACFA11.KEY); Read1Page(); while(1) { switch(Field) { case 1: if(UReadS(BXN(1),ACFA11.KEY,"NL",V_SHOW,V_READ)) Read1Page(); break; case 2: UReadS(BXN(2),ACFA11.NAM,"C",V_SHOW,V_READ); break; case 3: UReadTog(BXN(3),&ACFA11.KI,V_TOG,"123",ChainKI('1'),ChainKI('2'),ChainKI('3')); UShowSL(BXN(3),ChainKI(ACFA11.KI),V_SHOW); break; default: Field04(); break; } switch(RetKey) { case F8 : CopyACF011(); break; case F10 : Del1Page(); break; case PGUP : case PGDN: case C_PGUP: case C_PGDN: ACFA11.KEY[4]=NULL; L=atol(ACFA11.KEY)+1; Write1Page(); if(RetKey==ENTER) break; if(Ufk_PgUD(ACFA11K,ACFA11.KEY)==OFF) sprintf(ACFA11.KEY,"%04ld",L); Read1Page(); Field=1; break; case ESC : Write1Page(); Ufk_WriteLast(ACFA11K); if(RetKey==ENTER) break; else exit(0); break; default : UCtrField(ANO,TNO,RNO,CNO,V_SHOW); break; } if(Modify==ON) USetColor(SX,SY-1,6,V_MODIFY); } } /*===========================================================================*/ void Field04() { int col=(Field-TNO-1)%CNO, row=(Field-TNO-1)/CNO; int y=row+SNO, r=row+OffSet; switch(col) { case 0: UReadS(XN(0),ACFA11A[r].AC,"NL",V_SHOW,V_READ); if(Utx_Chain(Tx,ACFA11A[r].AC,X[0],y,28,V_SHOW)==OFF) UShowSL(3,y,76,&Table[(SNO-4)*76],V_SHOW); if(RetKey==F4) Utx_Pick(Tx,ACFA11A[r].AC,X[0],y,28," 科 目 查 詢 ",V_SHOW); break; case 1: UReadS(XN(2),ACFA11A[r].RM,"C",V_SHOW,V_READ); break; case 2: UReadTog(X[3],y,4,&ACFA11A[r].DC,V_TOG,"DC ","借","貸"," "); UShowSL(XN(3)+1,ChainDC(r),V_SHOW); case 3: UReadD(XN(4),&ACFA11A[r].AMT,",",V_SHOW,V_READ); break; } } /*===========================================================================*/ void Show1Page() { char *pS; int y,r; UShowSL(BXN(1),ACFA11.KEY,V_SHOW); UShowSL(BXN(2),ACFA11.NAM,V_SHOW); UShowSL(BXN(3),ChainKI(ACFA11.KI),V_SHOW); for(I=0; I<RNO; I++) { y=I+SNO; r=I+OffSet; if(Utx_Chain(Tx,ACFA11A[r].AC,XY(0),28,V_SHOW)==OFF) UShowSL(3,y,76,&Table[(SNO-4)*76],V_SHOW); else { UShowSL(XN(2),ACFA11A[r].RM,V_SHOW); UShowSL(XN(3)+1,ChainDC(r),V_SHOW); UShowD(XN(4),ACFA11A[r].AMT,",",V_SHOW); } } } /*===========================================================================*/ int DiskRec,Update; /*供Write1Page使用*/ void Read1Page() { ACFA11.KEY[ACFA11K->kmk]=NULL; memset(&ACFA11A,NULL,sizeof(ACFA11A)); /*讀資料時要先將Buffer清掉*/ for(DiskRec=0; DiskRec<ANO; DiskRec++) { sprintf(BufS,"%s%c",ACFA11.KEY,DiskRec+2); if(Ufk_Read(ACFA11K,&ACFA11A[DiskRec],BufS)==OFF) break; } if(DiskRec==0) { memset(&ACFA11.KEY[0]+sizeof(ACFA11.KEY),NULL,sizeof(ACFA11)-sizeof(ACFA11.KEY)); UShowS(SX,SY-1,"(新增)",V_CREATE); Update=OFF; } else { UShowS(SX,SY-1,"(修改)",V_EDIT); Update=ON; ACFA11=ACFA11A[0]; ACFA11.KEY[ACFA11K->kmk]=NULL; /*設給ACFA11以便操作*/ } Modify=OFF; OffSet=0; Show1Page(); /*讀入時一定要Modify=OFF*/ } /*===========================================================================*/ void Write1Page() { int i,rec; if(Modify==OFF) return; for(rec=i=0; i<ANO; i++) { if(ACFA11A[i].AC[0]==NULL) continue; sprintf(ACFA11A[i].KEY,"%s%c",ACFA11.KEY,rec+2); strcpy(ACFA11A[i].NAM,ACFA11.NAM); ACFA11A[i].KI=ACFA11.KI; Ufk_Write(ACFA11K,&ACFA11A[i]); rec++; } for(i=rec; i<DiskRec; i++) { sprintf(BufS,"%s%c",ACFA11.KEY,i+2); Ufk_Del(ACFA11K,BufS); } } /*===========================================================================*/ void Del1Page() { UWait(ON,"若 確 定 要 刪 除 本 筆 資 料 .請 再 按 F10"); if(RetKey!=F10) return; for(I=0; I<ANO; I++) { sprintf(BufS,"%s%c",ACFA11.KEY,I+1); if(Ufk_Del(ACFA11K,BufS)==OFF && I>0) break; } if(Ufk_PgUD(ACFA11K,ACFA11.KEY)==OFF) /*刪除後跳到下一筆*/ { memset(&ACFA11,NULL,sizeof(ACFA11)); memset(&ACFA11A,NULL,sizeof(ACFA11A)); } Read1Page(); } /*===========================================================================*/ char *ChainKI(char KI) { switch(KI) { case '1': return "現金收入傳票"; case '2': return "現金支出傳票"; case '3': return "轉 帳 傳 票 "; default : return " "; } } /*===========================================================================*/ char *ChainDC(int r) { switch(ACFA11A[r].DC) { case 'D': return " 借 "; case 'C': return " 貸 "; default : return " "; } } /*===========================================================================*/ int SetCon() { int i=1,md=Modify,x=21,y=SNO-1,no=2; /* no=設定項目 */ char Yn='N'; Wo=Uwo_Open(x-6,y,x+51,y+no*2+2); Uwo_DrawBar(Wo,V_WBOX,V_W_IN,YES,3); y+=2; UShowS(x,y,"傳票編號:",V_SHOW); y+=2; UShowS(x,y,"執行(YN): N",V_SHOW); x+=10; do { y = SNO-1+2*i; if(i==1) UReadS(x,y,6,SelKey,"NL",V_SHOW,V_READ); if(i==2) UReadC(x,y,1,&Yn,"YN",V_SHOW,V_READ); if(RetKey==LEFT || RetKey==UP) if(--i<1) i=no; if(RetKey==RIGHT || RetKey==DOWN) if(++i>no) i=1; }while(Yn!='Y' && RetKey!=ESC); Modify=md; Uwo_Close(Wo); return RetKey; } /*===========================================================================*/ void CopyACF011() { if(SetCon()==ESC) return; memset(&ACFA11A,NULL,sizeof(ACFA11A)); Modify=ON; Write1Page(); for(I=0; I<ANO; I++) { sprintf(BufS,"%s%c",SelKey,I+2); if(Ufk_Read(ACF011K,&ACF011,BufS)==OFF) break; strcpy(ACFA11A[I].AC,ACF011.AC); strcpy(ACFA11A[I].RM,ACF011.RM); ACFA11.KI=ACF011.KI; ACFA11A[I].DC=ACF011.DC; ACFA11A[I].AMT=ACF011.AMT; } Modify=ON; OffSet=0; Show1Page(); } 原始檔-結束
Byron Wey Oct.21.1998