Bài giải Foxpro Học viện quân y
Giải Bài Tập FoxPro 2016 Bài 11 Cách 1: CLOSE ALL SET DATE fren SET CENTURY on SET STATUS on USE E:\QLDL\QLBN.dbf CALCULATE ALL MIN(Ngayvao) FOR Khoa='A1' AND Ngayra={} To N LIST Hoten FOR Khoa='A1' AND Ngayra={} AND Ngayvao=N Cách CLOSE ALL SET DATE fren SET CENTURY on SET STATUS on USE E:\QLDL\QLBN.dbf CALCULATE ALL MAX(DATE()-Ngayvao) FOR Khoa='A1' AND Ngayra={} To N LIST Hoten FOR Khoa='A1' AND Ngayra={} AND (DATE()-Ngayvao)=N 12 COUNT ALL FOR Gioi AND Khoa='A3' AND Dtuong='KBH' AND Ngayra={} to N COUNT ALL FOR !Gioi AND Khoa='A3' AND Dtuong='KBH' AND Ngayra={} to M ?IIF(N>M,'nam nhieu hon','nu nhieu hon') SUM Tienvp*IIF(Tuoi65,0.05,1)) TO N ?' Tong so tien vien phi duoc giam la ', N COUNT ALL FOR Tuoi65 TO A ?' So benh nhan duoc giam tien vien phi la ', M+A SUM ALL Tienvp FOR Khoa='A1' AND Ngayra{} To N COUNT ALL FOR Khoa='A1' AND Ngayra{} To M LIST Hoten,Que,Tienvp FOR Tienvp>(N/M) CALCULATE ALL MAX(Tuoi) FOR Khoa='A3' AND Ngayra={} TO N CALCULATE ALL MIN(Tuoi) FOR Khoa='A3' AND Ngayra={} TO M ?'Chenh lech tuoi lon nhat giua cac benh nhan dang dieu tri tai khoa A3 la ',N-M LIST Hoten,Tuoi FOR Khoa='A3' AND Ngayra={} AND Tuoi=N LIST Hoten,Tuoi FOR Khoa='A3' AND Ngayra={} AND Tuoi=M INDEX ON Mabn TO E:\QLDL\TOP2\MABNID.IDX INDEX ON Mabn TO E:\QLDL\TOP2\MABNID.IDX SORT TO E:\QLDL\SXBN.dbf ON Ngayvao/A USE E:\QLDL\SXBN.dbf BROWSE 13 14 15 16 17 Bài 4: 06 CLOSE ALL SET DATE FRENCH SET CENTURY on SET STATUS SET STATUS ON USE E:\QLDL\QLCB.dbf BROWSE REPLACE ALL Luong WITH (Hslg*750000) REPLACE ALL Pccv WITH 750000*IIF(Cv='GD',0.8,IIF(Cv='PDG',0.65,IIF(Cv='TP',0.45,IIF(Cv='PP',0.4,0)))) REPLACE ALL Tong WITH Luong+Pccv LIST Hoten,Cv,Tong 07 08 09 Cách COUNT ALL FOR Gioi AND MONTH(Ngaysinh)=MONTH(DATE()) TO N COUNT ALL FOR !Gioi AND MONTH(Ngaysinh)=MONTH(DATE()) TO M ?'So tien sinh nhat co quan phai chi la ', N*300000+M*500000 ,'vnd' Cách CALCULATE ALL SUM(IIF(Gioi,300000,500000)) FOR MONTH(Ngaysinh)=MONTH(DATE()) TO N ?'So tien sinh nhat co quan phai chi la ', N ,'vnd' 10 CALCULATE ALL MIN(Ngaysinh) TO N LIST Hoten FOR Ngaysinh=N COUNT NEXT FOR Gioi TO N COUNT NEXT FOR !Gioi TO M ?IIF(N>M,' Nam lon hon nu ',' Nu lon hon nam ') MODIFY STRUCTURE ( vào chèn thêm cột Tuoi ) BROWSE ( Xem chèn chưa ) REPLACE ALL Tuoi WITH YEAR(DATE())-YEAR(Ngaysinh) [ Tính tuổi tất thành viên ] LIST Hoten,Ngaysinh FOR Gioi AND Tuoi=60 LIST Hoten,Ngaysinh FOR !Gioi AND Tuoi>=55 COUNT ALL FOR Gioi AND Tuoi 11 12 13 14 15 16 17 18 19 LOCATE FOR Chucvu='TP' ?IIF(FOUND(),Hoten,' ') Bài : 02 CLOSE ALL SET DATE FRENCH SET CENTURY on SET STATUS ON SELECT D USE E:\QLDL\QLDIEN.dbf LIST Hoten,Cs1,CS2 FOR Kv=1 LIST Hoten FOR Sokw >=150 AND Sokw==151,20000,IIF(Sokw>=101,1000,600)) COUNT ALL FOR Kv=2 AND Sokw>200 AND Dtuong TO N ?'Co',N,' ho thuoc dien chinh sach o khu vuc dung tren 200Kw ' CALCULATE ALL MAX(Sokw) FOR !Dtuong TO N LIST Hoten FOR Sokw=N COUNT ALL FOR Kv=1 AND Dtuong TO N COUNT ALL FOR Kv=2 AND Dtuong TO M ?' Ti le ho thuoc dien chinh sach khu vuc va la ',N/M 03 04 05 06 07 08 09 10 11 Cách SUM ALL Tien TO N COUNT ALL TO M ?' So tien dien trung binh moi ho la',N/M LIST Hoten FOR Tien>(N/M) 12 SUM ALL Tien TO N SUM ALL Sokw TO M ?'Moi mot so dien gia',N/M,'vnd' 13 CALCULATE ALL MAX(Tien) FOR Kv=1 TO N CALCULATE ALL MIN(Tien) FOR Kv=1 TO M ?'chenh lech tien dien lon nhat la',N-M,'vnd' LIST Hoten FOR Tien=N OR Tien=M 14 CALCULATE ALL MIN(Sokw) FOR Kv=2 TO N LIST Hoten FOR Kv=1 AND Sokw>N 15 CALCULATE ALL MAX(Sokw) FOR Kv=1 AND Dtuong TO N LOCATE FOR Sokw=N AND Kv=1 AND Dtuong ?IIF(FOUND(),Hoten,'Khong co ho nao') 16 SORT TO E:\QLDL\TOP1\SXDIEN.dbf ON Sokw/D 17 INDEX ON Sokw TO E:\QLDL\KWID.IDX LIST Hoten,Sokw,Tien [Giải thích: Khi hiển thị danh sách họ tên, số KW tiêu thụ tiền điện số KW xếp từ nhỏ tới lớn tạo tệp số KWID.IDX trước đó] 18 LOCATE FOR Sokw>210 ?IIF(FOUND(),Hoten,'Khong co ho nao') Bài 6: 01 CLOSE ALL SET DATE FRENCH SET CENTURY on SET STATUS ON SELECT E USE E:\QLDL\QLTS.dbf BROWSE LIST Hoten,Diemm1,Diemm2,Diemm3 FOR Khuvuc='1' OR Khuvuc='2' LIST Hoten,Ngaysinh FOR YEAR(Ngaysinh)=17.5 AND Diemm1*Diemm2*Diemm30 REPLACE ALL Ketqua WITH 'Truot' FOR Diemtg24 ?IIF(FOUND(),Hoten,'Khong tim thay') ?IIF(FOUND(),Que,'Khong tim thay') ?IIF(FOUND(),Diemtg,'Khong tim thay') LIST Hoten,Que FOR Que='Ha Noi' OR Que='Ha Tay' AND YEAR(Ngaysinh)