#include #include #include #include #include #include #include #include #include #define N 20 #define SEMINGGU 7 #define SESSI 2 #define TIADA -1 #define PJG_KOD 10 #define PJG_NAMA 20 #define MAKS 20 int menu_utama ( void ); void buka_fail ( void ); void simpan_data ( void ); void buka_fail_tarikh ( void ); void simpan_data_tarikh ( void ); /* modul ini dibuat selepas exam */ void masukan_data ( void ); void masuk_data ( void ); /* modul ini dibuat selepas exam */ void masuk_tarikh_kursus ( void ) ; void input_bilangan_kelas ( int i ); void kemaskini ( void ); int menu_kemaskini ( void ); int menu_input_bilangan_kelas ( void ); int menu_hapus ( void ); int menu_papar_kursus ( void ); int menu_mencari (void); void paparan ( void ); void papar_rekod ( int i ); void paparan_jadual( void ) ; void paparTarikh (void); void hapus ( void ); void hapus_satu_rekod ( void ); void hapus_fail_jadual ( void ); void hapus_fail_data ( void ); void hapus_tarikh_lama ( void ) ; void cari ( void ); int cari_kod_kursus ( char *sasar, int bil ); int cari_nama_pensyarah ( char *sasar, int bil ); void cari_dengan_nama_pensyarah ( void ) ; void cari_dengan_kod_kursus ( void ) ; void uji_jadual ( void ); void set_subjek_dalam_jadual( void ); void baca_subjek_dalam_jadual( void ); void ralat2 ( void) ; void ralat ( void) ; void Scroll (); void Scroll2 (); void pusing (); void versi ( void ) ; void Jam ( void ); /* modul ini dibuat selepas exam */ /* struktur tarikh ini dibuat selepas exam */ struct tarikh_mula { char hari[3]; char bulan[3]; char tahun[5]; }t1[N]; struct tarikh_tamat { char hari[3]; char bulan[3]; char tahun[5]; }t2[N]; /* istihar tarikh */ struct tarikh_kursus { struct tarikh_mula t1; struct tarikh_tamat t2; }tarikh[N]; /* Istihar struktur data */ struct subjek { char kod_kursus[PJG_KOD]; char kuliah[3]; char makmal[3]; char tutoran[3]; char kelas[3]; char nama_pensyarah[PJG_NAMA]; } subjek[N]; struct jadual { char kod_kursus[PJG_KOD]; int kuliah; int makmal; int tutoran; char kelas; char nama_pensyarah[PJG_NAMA]; } jadual[N]; char *hari[SEMINGGU] = { "ISNIN" , "SELASA", "RABU" , "KHAMIS", "JUMAAT", "SABTU" , "AHAD" }; char *masa[SESSI] = { "HARI/ MASA PAGI TGH HARI", " PETANG MALAM" }; char *JAM[4] = { "08.00~11.00" , "11.00~02.00" , "3.00~06.00" , " 06.00~09.00" }; char *GARIS[7] = {""}; char MenuUtama[25][80] = {"ΫΫίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίΫίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίΫΫ", "ΊΜΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΉΊ", "ΊΊ ΊΊ", "ΊΊ ΊΊ", "ΊΊ ΊΊ", "ΊΊ [1] MASUK DATA ΊΊ", "ΊΊ ΊΊ", "ΊΊ [2] PENGEMASKINIAN ΊΊ", "ΊΊ ΊΊ", "ΊΊ [3] PENCARIAN ΊΊ", "ΊΊ ΊΊ", "ΊΊ [4] PENGHAPUSAN ΊΊ", "ΊΊ ΊΊ", "ΊΊ [5] PAPARAN ΊΊ", "ΊΊ ΊΊ", "ΊΊ ΊΊ", "ΊΊ ΊΊ", "ΊΜΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΉΊ", "ΊΊ ΊΊ", "ΊΊ [6] ΊΊ", "ΊΊ K E L U A R ΊΊ", "ΊΊ ΊΊ", "ΊΊ ΊΊ", "ΫΫάάάάάάάάάάάάάάάάάάάάάάάάάάάάάάάάάάάάάΫάάάάάάάάάάάάάάάάάάάάάάάάάάάάάάάάάάάάάάΫΫ"}; char kotakInput[14][51] = {" ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ» ", " ΜΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΉ ", " ΜΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΉ ", " Ί Ί ", " Ί Ί ", " Ί Ί ", " Ί Ί ", " Ί Ί ", " Ί Ί ", " Ί Ί ", " Ί Ί ", " Ί Ί ", " Ί Ί ", " ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ "}; char kotakTarikh[14][51] = {" ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ» ", " ΜΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΉ ", " ΜΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΉ ", " Ί Ί ", " Ί Ί ", " Ί Ί ", " Ί Ί ", " Ί Ί ", " Ί Ί ", " Ί Ί ", " Ί Ί ", " Ί Ί ", " Ί Ί ", " ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ "}; char kotakmesej1[7][65] = {"ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»", "Ί Kod subjek TELAH WUJUD Ί", "Ί Jika ingin terus input tekan Ί", "Ί atau takan untuk batal Ί", "ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ"}; char kotakmesej2[7][65] = {"ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»", "Ί Nama pensyarah TELAH WUJUD Ί", "Ί Jika ingin terus input tekan Ί", "Ί atau takan untuk batal Ί", "ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ"}; char kosong[7][70] = {" ", " ", " ", " ", " "}; char *p; int i; int bil; int bil_rekod = 0; int bil_tarikh = 0; int pilihan; int ruang_masa[SEMINGGU][SESSI]; FILE *stream; /* modul input */ char* input( int len ) { char buffer[83]; /* There's space for 80 characters plus the NULL terminator */ buffer[0] = len; textcolor(10); return cgets(buffer); } /* modul periksa disket */ int periksa_disket ( void ) { int i, strt, ch_out, sector; char buf[512]; sector = 0; clrscr(); _setcursortype(_NOCURSOR); if (absread(0, 1, sector, &buf) != 0) { gotoxy(17,12); textcolor(LIGHTRED+BLINK); cprintf("Sila masukkan disket ke drive A: terlebih dahulu\n"); textcolor(15); gotoxy(17,13); perror("Disket anda mempunyai masalah...."); gotoxy(22,14); cprintf(" Tekan untuk kelauar\n"); getch(); exit(1); } return(0); } /* tamat modul periksa disket */ /* modul mencari kewujudan fail */ int file_exists(char *filename) { return (access(filename, 0) == 0); } /* modul melihat size file */ long filesize(FILE *stream) { long curpos, panjang; curpos = ftell( stream ); fseek( stream, 0L, SEEK_END ); panjang = ftell( stream ); fseek( stream, curpos, SEEK_SET ); return panjang; } /* fungsi 'memeriksa" : melihat bait fail dan kewujudan fail */ void periksa(void){ textmode(BW80);// Mode skrin hitam-putih clrscr(); stream = fopen("a:kursus.dat", "r"); gotoxy (25,10);cprintf("kursus.dat: %ld bytes %s ", filesize(stream), file_exists("a:kursus.dat") ? "access" : "NO"); delay(2000); stream = fopen("a:jadual.dat", "r"); gotoxy (25,13);cprintf("jadual.dat: %ld bytes %s ", filesize(stream), file_exists("a:jadual.dat") ? "access" : "NO"); delay(2000); stream = fopen("a:tarikh.dat", "r"); gotoxy (25,16);cprintf("tarikh.dat: %ld bytes %s ", filesize(stream), file_exists("a:tarikh.dat") ? "access" : "NO"); delay(2000); fclose(stream); } /* tamat fungsi ' peirksa ' */ /* fungsi 'jam' */ void Jam ( void ) { do{ textcolor(YELLOW); struct date d; getdate(&d); /* input tarikh */ struct time t; gettime(&t); gotoxy(30,2); cprintf("[ %2d:%2d:%2d ",t.ti_hour,t.ti_min,t.ti_sec); cprintf("%2d/%2d/%4d ]",d.da_day,d.da_mon,d.da_year); delay(100); _setcursortype(_NOCURSOR); }while(!kbhit()); _setcursortype(_NORMALCURSOR); }/* tamat fungsi masa */ /*fungsi baca*/ int baca_rekod(struct jadual jadual[]) { int status,bil = 0; FILE *ff; ff = fopen("a:jadual.dat", "r"); int v; v = 0; while (( fscanf(ff, "%s%s\n", jadual[v].kod_kursus, jadual[v].nama_pensyarah)) != EOF) { bil = v; v++; } fclose( ff ); return( bil ); } /*tamat modul baca_rekod */ /* fungsi jadual*/ void jadual_baru (struct jadual jadual[],int bil ) { int h; clrscr(); flushall(); for( h = 0; h < bil; h++ ) { printf("%s\n %s\n", jadual[h].kod_kursus, jadual[h].nama_pensyarah); } getch(); } /****************************************/ /* Aturcara Utama */ /****************************************/ // Aturcara bermula di sini void main ( void ) { int status, i, n; int pilihan; char sasar; periksa_disket ( ); buka_fail(); /* baca fail data*/ buka_fail_tarikh (); /* baca fail tarikh */ periksa(); versi(); /* papar logo versi */ do { pilihan = menu_utama(); /* memanggil fungsi 'menu_utama' */ textbackground(0); switch (pilihan) { case 1 : fflush(stdin); masukan_data(); /* memanggil fungsi 'masukan data' */ break; case 2 : fflush(stdin); kemaskini (); /* memanggil fungsi 'kemaskini' */ break; case 3 : fflush(stdin); cari(); /* memanggil fungsi 'cari' */ break; case 4 : fflush(stdin); hapus (); /* memanggil fungsi 'hapus' */ break; case 5 : fflush(stdin); Scroll2(); /* memanggil fungsi 'paparan' */ break; case 6 : Scroll(); /* memanggil fungsi 'Scroll' */ break; } /* penutup switch */ } while (pilihan != 6); } /* penutup fungsi main */ /* modul menu_utama */ int menu_utama ( void ) { char a[4]; int pilihan, x, g; clrscr(); do { textcolor(2); for(g = 0; g < 25; g++) { textbackground(9); delay(30); gotoxy(1,1+g); cprintf("%s",MenuUtama[g]); } /* penutup for g */ textcolor(14); gotoxy(32,3); cprintf("M E N U U T A M A"); textcolor(13+BLINK); gotoxy(31,6);cprintf("[1]"); gotoxy(31,8);cprintf("[2]"); gotoxy(31,10);cprintf("[3]"); gotoxy(31,12);cprintf("[4]"); gotoxy(31,14);cprintf("[5]"); gotoxy(39,20);cprintf("[6]"); textbackground(13); textcolor(15); gotoxy(25,22);cprintf("Sila masukkan pilihan anda *> [ ]"); textcolor(7); Jam(); a[0] = 2; gotoxy(56,22); p = cgets ( a ); pilihan = atoi( p ); if ( pilihan < 1 || pilihan > 6 ) { ralat2(); } }while ( pilihan < 1 || pilihan > 6 ) ; textcolor( 7 ); return ( pilihan ); } /* tamat menu utama */ /* modul masukan_data: merupakan menu masukan */ void masukan_data ( void ) { int pilihan, g; do { _setcursortype(_NOCURSOR); clrscr(); for ( g = 0; g < 14; g++ ) { textbackground(9); delay(30); gotoxy(17,6+g); cprintf("%s",kotakInput[g]); } /* penutup for g */ textcolor(10); gotoxy(29,7); cprintf(" MENU INPUT DATA JADUAL "); gotoxy(22,11); cprintf(" F1 ώ INPUT TARIKH JADUAL KURSUS"); gotoxy(22,13); cprintf(" F2 ώ INPUT DATA KURSUS"); gotoxy(22,15); cprintf(" Esc ώ KEMBALI KE MENU UTAMA"); gotoxy(22,18); cprintf(" SILA BUAT FILIHAN ANDA"); pilihan = bioskey(0); if ( pilihan == 0x3b00 || pilihan == 0x3c00 || pilihan == 0x11b) { switch( pilihan ) { case 0x3b00 : masuk_tarikh_kursus(); break; case 0x3c00 : masuk_data(); break; case 0x11b : textbackground(0); return; }/* tutup switch */ }/* tutp if */ else { ralat2(); } clrscr(); } while ( pilihan != 0x11b ); _setcursortype(_NORMALCURSOR); textbackground(0); } /* tamat modul cari */ void hapus_tarikh_lama ( void ) { char ganti[25] = {" "}; int i, k, j; for ( i = 0; i < bil_tarikh; i++) { strcpy (tarikh[i].t1.hari , ganti); strcpy (tarikh[i].t1.bulan , ganti); strcpy (tarikh[i].t1.tahun , ganti); /* tarikh akhir */ strcpy (tarikh[i].t2.hari , ganti); strcpy (tarikh[i].t2.bulan , ganti); strcpy (tarikh[i].t2.tahun , ganti); } for ( j = i; j < bil_tarikh; j++ ) { k = j + 1; strcpy (tarikh[j].t1.hari , tarikh[k].t1.hari ); strcpy (tarikh[j].t1.bulan , tarikh[k].t1.bulan ); strcpy (tarikh[j].t1.tahun , tarikh[k].t1.tahun ); /* tarikh akhir */ strcpy (tarikh[j].t2.hari , tarikh[k].t2.hari ); strcpy (tarikh[j].t2.bulan , tarikh[k].t2.hari ); strcpy (tarikh[j].t2.tahun , tarikh[k].t2.tahun ); } /* penutup for */ bil_tarikh = bil_tarikh - 1; simpan_data_tarikh (); } /* modul masuk_tarikh_kursus */ void masuk_tarikh_kursus (void) { int g, k, z, j; int hadTarikh = 2; clrscr(); textbackground(0); if ( bil_tarikh != 0 ) { hapus_tarikh_lama (); } buka_fail_tarikh (); for ( g = 0; g < 14; g++ ) { textbackground(9); delay(30); gotoxy(17,6+g); cprintf("%s",kotakTarikh[g]); } /* penutup for g */ textcolor(15); gotoxy(34,7); cprintf(" INPUT TARIKH "); textbackground(12); gotoxy(34,11);cprintf("[ /"); gotoxy(38,11);cprintf(" /"); gotoxy(41,11);cprintf(" ]"); gotoxy(34,15);cprintf("[ /"); gotoxy(38,15);cprintf(" /"); gotoxy(41,15);cprintf(" ]"); for ( i = bil_tarikh; i < hadTarikh; i++) { _setcursortype(_NORMALCURSOR); textcolor(1); gotoxy(32,9); printf("Tarikh Mula Kursus "); gotoxy(32,13);printf("Tarikh Tamat Kursus "); /* tarikh awal */ gotoxy(35,11); strcpy (tarikh[i].t1.hari , input ( 3 )); if ( !*tarikh[i].t1.hari) { gotoxy(3,25);cprintf("Sistem keluar ke menu utama"); bil_tarikh = i; simpan_data_tarikh(); delay(200); break; } gotoxy(23,23); printf(" "); gotoxy(38,11); strcpy (tarikh[i].t1.bulan , input ( 3 )); gotoxy(41,11); strcpy (tarikh[i].t1.tahun , input ( 5 )); /* tarikh akhir */ gotoxy(35,15); strcpy (tarikh[i].t2.hari , input ( 3 )); gotoxy(38,15); strcpy (tarikh[i].t2.bulan , input ( 3 )); gotoxy(41,15); strcpy (tarikh[i].t2.tahun , input ( 5 )); textcolor(15); textbackground(1); // delay(1000); gotoxy(23,23); cprintf("Tekan sekarang untuk tamat "); } /* tamat for i */ _setcursortype(_NOCURSOR); } /* tamat modul masuk_tarikh_kursus*/ /* Masuk data ke dalam fail data */ void masuk_data ( void ) { int bil = 0; int jumpa_kod, jumpa_nama; char a[30], k[9],*s; int y, Y, key, m; textbackground(0); clrscr(); for ( i = bil_rekod; i < N; i++ ) { textbackground(0); textcolor(13); gotoxy(15,2); cprintf(" ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»"); gotoxy(15,3); cprintf(" Ί Sistem Masukan Data Kursus Ί"); gotoxy(15,4); cprintf(" ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ"); textcolor(10); _setcursortype(_SOLIDCURSOR); gotoxy(22,7); cprintf("Kod Kursus : "); gotoxy(22,9); cprintf("Nama Pensyarah : "); gotoxy(22,11); cprintf("[1] Bilangan Kuliah : "); gotoxy(22,13); cprintf("[2] Bilangan Makmal : "); gotoxy(22,15); cprintf("[3] Bilangan Tutoran: "); textcolor(1); window(10,23,80,10); textbackground(5); gotoxy(47,7); cprintf("[ ]"); gotoxy(47,9); cprintf("[ ]"); gotoxy(47,11); cprintf("[ ]"); gotoxy(47,13); cprintf("[ ]"); gotoxy(47,15); cprintf("[ ]"); textbackground(0); textcolor(7); gotoxy(37,24);cprintf("Bil : %d", bil); textcolor(15); textbackground(5); k[0] = 7; gotoxy(48,7); s = cgets( k ); /* input kod subjek */ jumpa_kod = cari_kod_kursus( s, N ); /* memanggil fungsi1 cari */ textcolor(LIGHTRED); textbackground(0); gotoxy(3,25); cprintf(" "); if ( !*s ) { /* arahan tamat modul */ gotoxy(3,25); cprintf("Sistem keluar ke menu utama"); bil_rekod = i; set_subjek_dalam_jadual(); delay(200); return; } textcolor(15); if ( !strcmp( s, subjek[jumpa_kod].kod_kursus )){ _setcursortype(_NOCURSOR); for ( m = 0; m < 7; m++ ) { delay(10); gotoxy(15,18+m); cprintf("%s",kotakmesej1[m]); } textbackground(0); key = bioskey(0); if ( key == 0x11b ) return; textbackground(0); } /* tamat if */ for ( m = 0; m < 7; m++ ) { _setcursortype(_NOCURSOR); delay(10); gotoxy(15,18+m); cprintf("%s",kosong[m]); } strcpy( subjek[i].kod_kursus, s ); textcolor(15); textbackground(5); _setcursortype(_SOLIDCURSOR); a[0] = 10; gotoxy(48,9); p = cgets ( a ); /* input nama pensyarah */ _setcursortype(_NOCURSOR); /* memanggil fungsi cari_nama_pensyarah */ jumpa_nama = cari_nama_pensyarah( p, N ); if ( !strcmp ( p, subjek[jumpa_nama].nama_pensyarah ) ){ textbackground(0); for ( m = 0; m < 7; m++ ) { delay(10); gotoxy(15,18+m); cprintf("%s",kotakmesej2[m]); } key = bioskey(0); if ( key == 0x11b ) return; textbackground(0); } /* penutup if */ for( m = 0; m < 7; m++ ) { delay(10); gotoxy(15,18+m);cprintf("%s",kosong[m]); } strcpy ( subjek[i].nama_pensyarah, p ); textcolor(2); textbackground(5); _setcursortype(_SOLIDCURSOR); /* memanggi fungsi input_bilangan_kelas */ input_bilangan_kelas( i ); textbackground(0); bil++; textcolor(LIGHTRED); textbackground(1); gotoxy(14,25); cprintf("tekan jika hendak berhenti ATAU teruskan input"); delay(2000); textbackground(0); _setcursortype(_SOLIDCURSOR); bil_rekod = i + 1; simpan_data(); /* memanggil modul simpan data */ clrscr(); } /* penutup for */ bil_rekod = i; simpan_data(); textbackground(0); return; } /* tamat fungsi masuk_data */ /* modul menu_oilih_kelas */ int menu_input_bilangan_kelas ( void ) { char no[3]; do { textcolor(15); gotoxy(8,17); cprintf(" ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»"); gotoxy(8,18); cprintf(" Ί PILIH JENIS KELAS KURSUS Ί"); gotoxy(8,19); cprintf(" ΜΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΉ"); gotoxy(8,20); cprintf(" Ί Ί"); gotoxy(8,21); cprintf(" Ί [1] [2] [3] [4] [5] Ί"); gotoxy(8,22); cprintf(" Ί KULLIAH MAKMAL TUTORAN SEMUA SEKALI BATAL Ί"); gotoxy(8,23); cprintf(" Ί Ί"); gotoxy(8,24); cprintf(" Ί MASUKKAN PILIHAN ANDA *> [ ] Ί"); gotoxy(8,25); cprintf(" ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ"); no[0] = 2; textcolor(10); gotoxy(55,24); p = cgets( no ); pilihan = atoi( p ); if ( pilihan < 1 || pilihan > 5 ) { ralat2 (); /* panggilan fungsi ralat2 */ } /* penutup if */ } while ( pilihan < 1 || pilihan > 5 ); return pilihan; } /* tamat fungsi 'menu_papar_gred' */ /* modul input_bilangan_kelas */ void input_bilangan_kelas ( int i ) { /* memanggil fungsi menu_input_bilangan_kelas */ pilihan = menu_input_bilangan_kelas(); do{ /* pilihan input */ switch( pilihan ) { case 1 : strcpy ( subjek[i].kelas, "K" ); gotoxy(48,11); strcpy( subjek[i].kuliah, input ( 3 ) ); return; case 2 : strcpy ( subjek[i].kelas, "M" ); gotoxy(48,13); strcpy( subjek[i].makmal, input ( 3 ) ); return; case 3 : strcpy ( subjek[i].kelas, "T" ); gotoxy(48,15); strcpy( subjek[i].tutoran, input ( 3 ) ); return; case 4: gotoxy(48,11); strcpy( subjek[i].kuliah, input ( 3 ) ); gotoxy(48,13); strcpy( subjek[i].makmal, input ( 3 ) ); gotoxy(48,15); strcpy( subjek[i].tutoran, input ( 3 ) ); textcolor(7); textbackground(0); return; case 5: break; }/* tamat switch */ } while ( pilihan != 5 ); } /* tamat modul input_bilangan_kelas */ /* modul menu_ kemaskini */ int menu_kemaskini ( void ) { char z[4]; do { clrscr(); textcolor(10); gotoxy(20,3); cprintf(" ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ» "); gotoxy(20,4); cprintf(" Ί PILIH DATA YANG HENDAK DIKEMASKINI: Ί "); gotoxy(20,5); cprintf(" ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ "); gotoxy(22,8); cprintf(" 1 * KOD SUBJEK "); gotoxy(22,10); cprintf(" 2 * BILANGAN KULLIAH "); gotoxy(22,12); cprintf(" 3 * BILANGAN MAKMAL "); gotoxy(22,14); cprintf(" 4 * BILANGAN TUTORAN "); gotoxy(22,16); cprintf(" 5 * NAMA PENSYARAH "); gotoxy(22,18); cprintf(" 6 * BATAL "); textcolor(3); gotoxy(20,21); cprintf("Sila masukkan pilihan anda *> [ ] "); z[0] = 2; textcolor(10); gotoxy(51,21); p = cgets( z ); pilihan = atoi( p ); if ( pilihan < 1 || pilihan > 6 ) { ralat2 (); /* panggilan fungsi ralat2 */ } /* penutup if */ } while ( pilihan < 1 || pilihan > 6); return pilihan; } /* penutup menu_kemaskini */ /* modul kemaskini */ void kemaskini ( void ) { int pilihan = 1; int dapat = 0; char kod[7]; clrscr(); textcolor(3); gotoxy(22,5); cprintf(" ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ» "); gotoxy(22,6); cprintf(" Ί KESAN KOD KURSUS UNTUK KEMASKINI Ί "); gotoxy(22,7); cprintf(" ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ "); textcolor(10); gotoxy(20,12); cprintf("Masukkan kod kursus yang hendak dikemaskini"); textbackground(LIGHTBLUE); gotoxy(36,14); cprintf("[ ]"); textbackground(0); kod[0] = 7; textcolor(4); gotoxy(37,14); p = cgets( kod ); /* input kod kursus */ textcolor(7); for( i = 0; i < bil_rekod; i++ ) { if( !strcmp ( p , subjek[i].kod_kursus ) ) { dapat = 1; /* memanggil fungsi 'menu_kemaskini' */ pilihan = menu_kemaskini(); /* memanggil fungsi 'papar_rekod' */ papar_rekod ( i ); if (pilihan != 1) { } /* penutup if */ textcolor(10); /* pilihan input baru */ switch ( pilihan ) { case 1: textbackground(9); gotoxy(45,7); cprintf(" "); fflush(stdin); gotoxy(46,7); strcpy( subjek[i].kod_kursus, input ( 7 ) ); textbackground(0); simpan_data(); /* memanggil fungsi 'simpan_data' */ break; case 2: textbackground(9); gotoxy(45,9); cprintf(" "); fflush(stdin); gotoxy(46,9); strcpy( subjek[i].kuliah, input ( 3 ) ); textbackground(0); simpan_data(); /* memanggil fungsi 'simpan_data' */ break; case 3: textbackground(9); gotoxy(45,11); cprintf(" "); fflush(stdin); gotoxy(46,11); strcpy( subjek[i].makmal, input ( 3 ) ); textbackground(0); simpan_data(); /* memanggil fungsi 'simpan_data' */ break; case 4: textbackground(9); gotoxy(45,13); cprintf(" "); fflush(stdin); gotoxy(46,13); strcpy( subjek[i].tutoran, input ( 3 ) ); textbackground(0); simpan_data(); /* memanggil fungsi 'simpan_data' */ break; case 5: textbackground(9); gotoxy(45,15); cprintf(" "); fflush(stdin); gotoxy(46,15); strcpy( subjek[i].nama_pensyarah, input ( 10 ) ); textbackground(0); simpan_data(); /* memanggil fungsi 'simpan_data' */ break; case 6: return; } /* penutup switch */ } /* penutup if */ } /* penutup for */ simpan_data(); /* memanggil fungsi 'simpan_data' */ if ( !dapat ) { ralat(); /* memanggil fungsi 'ralat' */ return; } /* penutup if */ /* memanggil fungsi set_subjek_dalam_jadual */ set_subjek_dalam_jadual(); } /* tamat fungsi 'kemaskini' */ /* MODUL cari_dengan_kod_kursus */ void cari_dengan_kod_kursus (void) { int dapat = 0; char kod[10]; clrscr(); textcolor(10); gotoxy(23,5); cprintf(" ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ» "); gotoxy(23,6); cprintf(" Ί KESAN DATA Ί "); gotoxy(23,7); cprintf(" ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ "); gotoxy(20,12); cprintf("Masukkan kod subjek yang hendak dipaparkan : "); textcolor(4); textbackground(3); gotoxy(36,14); cprintf("[ ]"); kod[0] = 7; gotoxy(37,14); p = cgets ( kod ); textcolor(7); textbackground(0); for ( i = 0; i < bil_rekod; i++ ) if ( !strcmp ( p , subjek[i].kod_kursus ) ) { papar_rekod (i); /* memanggil fungsi 'papar_rekod' */ dapat = 1; } /* penutup if */ if(!dapat) { ralat(); /* memanggil fungsi 'ralat' */ } return; } /* TAMAT MODUL cari_dengan_kod_kursus */ /* MODUL cari_dengan_nama_pensyarah */ void cari_dengan_nama_pensyarah (void) { int dapat = 0; char nama[15]; clrscr(); textcolor(10); gotoxy(23,5); cprintf(" ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ» "); gotoxy(23,6); cprintf(" Ί KESAN DATA Ί "); gotoxy(23,7); cprintf(" ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ "); gotoxy(20,12); cprintf("Masukkan nama pensyarah yang hendak dipaparkan : "); textcolor(4); textbackground(3); gotoxy(36,14); cprintf("[ ]"); nama[0] = 10; gotoxy(37,14); p = cgets ( nama ); textcolor(7); textbackground(0); for ( i = 0; i < bil_rekod; i++ ) if( !strcmp ( p , subjek[i].nama_pensyarah ) ) { papar_rekod ( i ); /* memanggil fungsi 'papar_rekod' */ dapat = 1; } /* penutup if */ if( !dapat ) { ralat(); /* memanggil fungsi 'ralat' */ } return; } /* tamat modul cari_dengan_nama_pensyarah */ /* modul cari */ void cari ( void ) { int pilihan; pilihan = menu_mencari(); /* memanggil fungsi menu_input_bilangan_kelas */ do { switch( pilihan ) { case 1 : cari_dengan_kod_kursus(); return; case 2 : cari_dengan_nama_pensyarah(); return; case 3 : return; }/* tamat switch */ } while ( pilihan != 3 ); return; } /* tamat modul cari */ /* modul menu_mencari */ int menu_mencari ( void ) { int pilihan; char z[4]; do { clrscr(); textcolor(10); gotoxy(20,5); cprintf(" ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ» "); gotoxy(20,6); cprintf(" Ί PILIH NOMBOR YANG HENDAK DICARI: Ί "); gotoxy(20,7); cprintf(" ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ "); gotoxy(21,11); cprintf(" 1 * MENCARI REKOD DENGAN KOD SUBJEK "); gotoxy(21,13); cprintf(" 2 * MENCARI REKOD DENGAN NAMA PENSYARAH "); gotoxy(21,15); cprintf(" 3 * BATAL ATAU KELUAR "); textcolor(12); gotoxy(24,22); cprintf("Sila masukkan pilihan anda *> [ ] "); z[0] = 2; textcolor(10); gotoxy(55,22); p = cgets( z ); /* input pilihan */ pilihan = atoi( p ); if ( pilihan < 1 || pilihan > 3 ) { ralat2 (); /* panggilan fungsi ralat2 */ } /* penutup if */ } while ( pilihan < 1 || pilihan > 3); return pilihan; } /* tamat modul menu_mencari */ /* modul hapus__satu_rekod data yang dipilih */ void hapus__satu_rekod ( void ) { int dapat = 0; int y,j,k; char x[1]; char kod[10]; char ganti[25] = {""}; clrscr(); textcolor(10); gotoxy(22,5); cprintf(" ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ» "); gotoxy(22,6); cprintf(" Ί Sistem Menghapuskan Rekod Data Ί "); gotoxy(22,7); cprintf(" ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ "); gotoxy(30,12); cprintf(" Masukkan kod kursus :"); window(35,14,84,35); textcolor(RED); textbackground(CYAN); gotoxy(36,14); cprintf("[ ]"); kod[0] = 8; gotoxy(37,14); p = cgets( kod ); textcolor(7); textbackground(0); clrscr(); for( i = 0; i < bil_rekod; i++ ) if ( !strcmp ( p , subjek[i].kod_kursus ) ) { dapat = 1; clrscr(); textcolor(LIGHTCYAN); gotoxy(20,3); cprintf(" ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ» "); gotoxy(20,4); cprintf(" Ί Rekod Data Yang Akan Dihapuskan Ί\n"); gotoxy(20,5); cprintf(" ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ "); textcolor(WHITE); gotoxy(22,7); cprintf("Kod Kursus : "); gotoxy(22,9); cprintf("Bilangan Kuliah : "); gotoxy(22,11); cprintf("Bilangan Makmal : "); gotoxy(22,13); cprintf("Bilangan Tutoran : "); gotoxy(22,15); cprintf("Nama Pensyarah : "); gotoxy(42,7); cprintf("%s",subjek[i].kod_kursus); gotoxy(42,9); cprintf("%s",subjek[i].kuliah); gotoxy(42,11); cprintf("%s",subjek[i].makmal); gotoxy(42,13); cprintf("%s",subjek[i].tutoran); gotoxy(42,15); cprintf("%s",subjek[i].nama_pensyarah); gotoxy(18,23); cprintf("Sila tekan untuk menghapus_rekodkan data..."); gotoxy(18,24); cprintf("ATAU tekan <1> jika tidak mahu"); gotoxy(50,24); gets( x ); y = atoi( x ); if( y != 1 ) { /* menghapus_rekodkan data */ strcpy ( subjek[i].kod_kursus , ganti ); strcpy ( subjek[i].kuliah , ganti ); strcpy ( subjek[i].makmal , ganti ); strcpy ( subjek[i].tutoran , ganti ); strcpy ( subjek[i].nama_pensyarah , ganti ); for ( j = i; j < bil_rekod; j++ ) { k = j + 1; strcpy ( subjek[j].kod_kursus , subjek[k].kod_kursus ); strcpy ( subjek[j].kuliah , subjek[k].kuliah ); strcpy ( subjek[j].makmal , subjek[k].makmal ); strcpy ( subjek[j].tutoran , subjek[k].tutoran ); strcpy ( subjek[j].nama_pensyarah , subjek[k].nama_pensyarah ); } /* penutup for */ /* memaparkan mesej hapus_rekod */ clrscr(); gotoxy(20,12); cprintf(" !!!!!! REKOD TELAH DIHAPUSKAN !!!!! "); bil_rekod = bil_rekod - 1; delay(1500); simpan_data(); /* memanggil fungsi 'memori' */ } /* penutup if */ else break; } /* penutup if */ if ( !dapat ) { ralat(); /* memanggil fungsi 'ralat' */ return; } /* memanggil modul 'set_subjek_dalam_jadual' */ set_subjek_dalam_jadual( ); } /* penutup fungsi */ /* fungsi 'menu_hapus'*/ int menu_hapus ( void ) { char n[3]; int tambah, d; clrscr(); do{ for ( d = 0; d < 14; d++ ) { textcolor(12); gotoxy(17,7+d);cprintf("%s",kotakInput[d]); } /* pentup for d */ textcolor(10); gotoxy(29,8); cprintf(" MENU INPUT DATA PELAJAR "); gotoxy(22,11); cprintf(" 1 ώ HAPUS SESUATU REKOD "); gotoxy(22,13); cprintf(" 2 ώ HAPUS FAIL jadual.dat"); gotoxy(22,15); cprintf(" 3 ώ HAPUS FAIL kursus.dat"); gotoxy(22,17); cprintf(" 4 ώ BATAL "); gotoxy(26,20); cprintf(" MASUKKAN PILIHAN ANDA *> [ ]"); n[0] = 2; gotoxy(53,20); p = cgets ( n ); tambah = atoi ( p ); if ( tambah < 1 || tambah > 4 ) { ralat2 (); /* panggilan fungsi ralat2 */ } /* penutup if */ } while ( tambah < 1 || tambah > 4 ); return tambah; } /* tamat fungsi 'tambah' */ /* fungsi 'papar_pilih_gred': Memaparkan data yang berkaitan dengan gred */ void hapus ( void ) { do { /* memanggil fungsi 'menu_papar_gred' */ pilihan = menu_hapus(); switch( pilihan ) { case 1 : hapus__satu_rekod(); break; case 2 : hapus_fail_jadual(); break; case 3 : hapus_fail_data(); break; case 4 : return; } /* penutup switch */ } while ( pilihan != 4); } /* tamat fungsai 'papar_pilih_gred' */ /* fungsi 'hapus_fail_jadual': Menghapuskan data */ void hapus_fail_jadual ( void ) { int y,j,k; char x[3]; char file[80]; clrscr(); textcolor(5+BLINK); gotoxy(20,12); cprintf("ADAKAH ANDA PASTI INGIN MENGHAPUSKANNYA ?"); textcolor(12); gotoxy(15,23); cprintf("Sila tekan untuk menghapuskan data..."); gotoxy(15,24); cprintf("ATAU tekan jika tidak mahu"); textcolor(10); y = bioskey(0); clrscr(); if( y == 0x11b ) //arahan escape return; /* delete the file */ else if ( remove("a:jadual.dat" ) == 0 ) { textcolor(4); gotoxy(26,12); printf("DATA TELAH DI HAPUSKAN"); delay (1000); } else { gotoxy(20,13); perror("remove"); } textcolor(14); gotoxy(20,12); cprintf("Tekan untuk kembali ke menu"); getch(); textcolor(7); delay(2000); buka_fail (); } /* tamat fungsi 'hapus_gred' */ /* fungsi 'hapus_fail_data': Menghapuskan data */ void hapus_fail_data ( void ) { int y,j,k; char x[3]; char file[80]; clrscr(); textcolor(5+BLINK); gotoxy(20,12); cprintf("ADAKAH ANDA PASTI INGIN MENGHAPUSKANNYA ? "); textcolor(12); gotoxy(15,23); cprintf("Sila tekan untuk menghapuskan data..."); gotoxy(15,24); cprintf("ATAU tekan jika tidak mahu"); textcolor(10); y = bioskey(0); if( y == 0x11b ) //arahan escape return; /* delete the file */ else if ( remove ("a:kursus.dat") == 0 ) { textcolor(4); gotoxy(26,12); printf("DATA TELAH DI HAPUSKAN "); delay (1000); } else { gotoxy(20,13); perror("remove"); } textcolor(14); gotoxy(20,12); cprintf("Tekan untuk kembali ke menu "); getch(); textcolor(7); delay(2000); buka_fail (); } /* tamat fungsi 'hapus_gred' */ /* Memaparkan menu_papar */ int menu_papar_kursus ( void ) { char no[3]; do { clrscr(); window(21,23,40,21); textbackground(3); textcolor(5); gotoxy(21,5); cprintf("ΫίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίίΫ"); gotoxy(21,6); cprintf("Ϋ M E N U P A P A R A N Ϋ"); gotoxy(21,7); cprintf("ΫΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΫ"); gotoxy(21,8); cprintf("Ϋ Ϋ"); gotoxy(21,9); cprintf("Ϋ 1 PAPAR JADUAL KURSUS Ϋ"); gotoxy(21,10); cprintf("Ϋ Ϋ"); gotoxy(21,11); cprintf("Ϋ 2 PAPAR KURSUS SATU PERSATU Ϋ"); gotoxy(21,12); cprintf("Ϋ Ϋ"); gotoxy(21,13); cprintf("Ϋ 3 PAPAR KURSUS YANG DIKEHENDAKI Ϋ"); gotoxy(21,14); cprintf("Ϋ Ϋ"); gotoxy(21,15); cprintf("Ϋ 4 MELIHAT UJIAN KEDUDUKAN DATA Ϋ"); gotoxy(21,16); cprintf("Ϋ Ϋ"); gotoxy(21,17); cprintf("Ϋ 5 MELIHAT DATA DALAM FAIL ASAL Ϋ"); gotoxy(21,18); cprintf("Ϋ Ϋ"); gotoxy(21,19); cprintf("Ϋ 6 KEMBALI KE MENU UTAMA Ϋ"); gotoxy(21,20); cprintf("Ϋ Ϋ"); gotoxy(21,21); cprintf("Ϋ Sila masukkan pilihan anda *> Ϋ"); gotoxy(21,22); cprintf("ΫάάάάάάάάάάάάάάάάάάάάάάάάάάάάάάάάάάάάάάάάΫ"); textcolor(4+BLINK); gotoxy(25,9); cprintf("["); gotoxy(27,9); cprintf("]"); gotoxy(25,11); cprintf("["); gotoxy(27,11); cprintf("]"); gotoxy(25,13); cprintf("["); gotoxy(27,13); cprintf("]"); gotoxy(25,15); cprintf("["); gotoxy(27,15); cprintf("]"); gotoxy(25,17); cprintf("["); gotoxy(27,17); cprintf("]"); gotoxy(25,19); cprintf("["); gotoxy(27,19); cprintf("]"); textcolor(11+BLINK); gotoxy(54,21); cprintf("["); gotoxy(56,21); cprintf("]"); textcolor(7); Jam(); no[0] = 2; gotoxy(55,21); p = cgets ( no ); pilihan = atoi( p ); if ( pilihan < 1 || pilihan > 6 ) { ralat2 (); /* panggilan fungsi ralat2 */ } /* penutup if */ } while ( pilihan < 1 || pilihan > 6 ); textbackground(0); return pilihan; } /* tamat fungsi menu_papar */ /* modul paparan : memapar pelbagai bentuk data kursus */ void paparan ( void ) { int dapat = 0; char kod[8]; do { pilihan = menu_papar_kursus(); /* memanggil fungsi 'menu_papar' */ switch( pilihan ) { case 1 : fflush(stdin); window(1,1,80,25); baca_rekod(jadual);// baca fail data paparan_jadual(); break; case 2 : for ( i = 0; i < bil_rekod; i++ ) { printf("%d", i); papar_rekod ( i ); /* memanggil fungsi 'papar_rekod' */ } /* penutup for i */ break; case 3 : clrscr(); textcolor(10); gotoxy(23,5); cprintf(" ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ» "); gotoxy(23,6); cprintf(" Ί KESAN DATA Ί "); gotoxy(23,7); cprintf(" ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ "); gotoxy(20,12); cprintf("Masukkan kod subjek yang hendak dipaparkan : "); textcolor(4); textbackground(3); gotoxy(36,14); cprintf("[ ]"); kod[0] = 7; gotoxy(37,14); p = cgets( kod ); textcolor(7); textbackground(0); for( i = 0; i < bil_rekod; i++ ) if( !strcmp ( p , subjek[i].kod_kursus ) ) { /* memanggil fungsi 'papar_rekod' */ papar_rekod ( i ); dapat = 1; } /* penutup if */ if( !dapat ) { ralat(); /* memanggil fungsi 'ralat' */ } break; case 4 : uji_jadual(); break; case 5 : baca_subjek_dalam_jadual(); break; case 6 : pusing(); break; } /* penutup switch */ }while( pilihan != 6 ); } /* tamat fungsi menu_papar_pel */ /* modul papar_rekod */ void papar_rekod( int i ) { clrscr(); textcolor(YELLOW); gotoxy(19,3); cprintf(" ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ» "); gotoxy(19,4); cprintf(" Ί Paparan Rekod Data Ί\n"); gotoxy(19,5); cprintf(" ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ "); textcolor(LIGHTBLUE); gotoxy(24,7); cprintf("KOD KURSUS : "); gotoxy(24,9); cprintf("BILANGAN KULLIAH : "); gotoxy(24,11); cprintf("BILANGAN MAKMAL : "); gotoxy(24,13); cprintf("BILANGAN TUTORAN : "); gotoxy(24,15); cprintf("NAMA PENSYARAH : "); gotoxy(46,7); cprintf("%s",subjek[i].kod_kursus); gotoxy(46,9); cprintf("%s",subjek[i].kuliah); gotoxy(46,11); cprintf("%s",subjek[i].makmal); gotoxy(46,13); cprintf("%s",subjek[i].tutoran); gotoxy(46,15); cprintf("%s",subjek[i].nama_pensyarah); textcolor(LIGHTCYAN); gotoxy(32,17); cprintf("Bilangan rekod = %d",bil_rekod); gotoxy(32,18); cprintf("Sila tekan enter..."); textcolor(0); getch(); } /* tamat modul papar_rekod */ /* modul paparan_jadual */ void paparan_jadual( void ) { int i,j,k,a,h, q; int ruang_masa[SESSI][SEMINGGU]; int bil_data; buka_fail(); /* baca fail data*/ buka_fail_tarikh ( ); clrscr(); flushall(); bil_data = 0; //Umpukkan 0 untuk menunjukkan ruang masa belum digunakan ruang_masa[SESSI][SEMINGGU] = 0; textcolor(YELLOW); bil=baca_rekod(jadual); for ( i = 0; i < SEMINGGU; i++ ) { gotoxy(4,4+3*i); cprintf("%s",hari[i]); } for ( i = 0; i < 7; i++ ) { delay (200); gotoxy(4,6+3*i); cprintf("ΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔ", GARIS[i]); } for ( i = 0; i < SESSI; i++ ) { flushall(); gotoxy(2+45*i,1); cprintf("%s",masa[i]); } for ( i = 0; i < 4; i++ ) { flushall(); gotoxy(16+16*i,2); cprintf("%s",JAM[i]); } textcolor(LIGHTGRAY); _setcursortype(_NOCURSOR); // Menentukan Dimensi Ruang Masa Secara Rawak q = 0;//Nilai awal q=0 do { flushall(); j = rand() % SESSI; //Nilai indeks j secara rawak k = rand() % SEMINGGU; //Nilai indeks k secara rawak /*mencari jika ruang masa belum diisi => laksanakan arahan2nya */ if ( ruang_masa[j][k] != 1 ) { gotoxy( 13 + 34 * j,4 + 3 * k ); flushall(); cprintf("%s", jadual[q].kod_kursus); gotoxy( 30 + 34 * j, 4 + 3 * k ); cprintf("%s", jadual[q].nama_pensyarah); /* Umpukkan 1 untuk menunjukkan ruang masa telah digunakan */ ruang_masa[j][k] = 1; gotoxy( 24 + 20 * j, 5 + 3 * k ); flushall(); delay(200); bil_data++; q++; } /*tamat if */ /* Jika bilangan data melebihi bilangan ruang masa =>mesej dipapar */ if ( bil_data > 13 ) { textcolor(LIGHTRED + BLINK); gotoxy(30,25); cprintf("!!KELAS TELAH PENUH!!"); break; } }while ( bil_data != bil + 1 ); for ( i = 1; i < 25; i++ ) { gotoxy(12,i); textcolor(12); cprintf("³"); gotoxy(29,i); textcolor(12); cprintf("³\r"); gotoxy(46,i); textcolor(12); cprintf("³\r"); gotoxy(63,i); textcolor(12); cprintf("³\r"); gotoxy(80,i); textcolor(12); cprintf("³\r"); delay (200); } textcolor(7); textbackground(0); paparTarikh (); /* memanggil modul papar tarikh */ getch(); return; } /* tamat modul paparan_jadual*/ /* modul paparTarikh_kursus*/ void paparTarikh ( void ) { i=0; textcolor(2); gotoxy(2,24);cprintf("Tarikh mula kursus "); gotoxy(21,24); cprintf ("%s/",tarikh[i].t1.hari ); gotoxy(24,24); cprintf ("%s/",tarikh[i].t1.bulan ); gotoxy(27,24); cprintf ("%s",tarikh[i].t1.tahun ); gotoxy(50,24);cprintf("Tarikh tamat kursus "); gotoxy(70,24); cprintf ("%s/",tarikh[i].t2.hari ); gotoxy(73,24); cprintf ("%s/",tarikh[i].t2.bulan ); gotoxy(76,24); cprintf ("%s",tarikh[i].t2.tahun ); i++; textcolor(7); textbackground(0); } /* tamat modul paparTarikh_kursus*/ /* modulset_subjek_dalam_jadual */ void set_subjek_dalam_jadual ( void ) { int p,q,r,s; int i,j,nombor; FILE *fpt; // Set fail jadual untuk simpan bilangan kelas sst subjek fpt = fopen("a:jadual.dat","w"); for ( i = 0; i < bil_rekod; i++ ) { jadual[i].kuliah = atoi ( subjek[i].kuliah ); jadual[i].makmal = atoi ( subjek[i].makmal ); jadual[i].tutoran = atoi ( subjek[i].tutoran ); for ( p = 0; p < jadual[i].kuliah; p++ ) { if ( jadual[i].kuliah > 0 ) fprintf(fpt," %s[K]%s \n", subjek[i].kod_kursus, subjek[i].nama_pensyarah); } for ( q = 0; q < jadual[i].makmal; q++ ) { if ( jadual[i].makmal > 0 ) fprintf(fpt," %s(M)%s \n", subjek[i].kod_kursus,subjek[i].nama_pensyarah); } for (r = 0; r < jadual[i].tutoran; r++) { if ( jadual[i].tutoran > 0 ) fprintf(fpt," %s(T)%s \n", subjek[i].kod_kursus,subjek[i].nama_pensyarah); } textcolor(YELLOW); gotoxy(35,25);printf("BILANGAN REKOD : "); gotoxy(55+i,25);printf("=%d", i+1); delay(200); }/* tamat for i*/ textcolor(0); bil_rekod = i; fclose( fpt ); } /* tamat modul set_subjek_dalam_jadual */ /* modul baca_subjek_dalam_jadual */ void baca_subjek_dalam_jadual( void ) { int i,j; FILE *fpt; // Set fail jadual untuk baca bilangan kelas sst subjek fpt = fopen ("a:jadual.dat","r"); clrscr(); while (( fscanf ( fpt,"%s\n%s\n", jadual[i].kod_kursus,jadual[i].nama_pensyarah )) != EOF ) { gotoxy(25+20*i,5+2*j); printf (" %s\n %s\n", jadual[i].kod_kursus,jadual[i].nama_pensyarah ); } getch(); fclose( fpt ); } /* tamat modul baca_subjek_dalam_jadual */ /* modul uji_jadual */ void uji_jadual( void ) { clrscr(); int i,j; int nombor,m,n; char *hari[7] = { "Isnin", "Selasa", "Rabu", "Khamis", "Jumaat", "Sabtu", "Ahad" }; gotoxy(25,3); cprintf("Pagi Petang malam"); for ( j = 0; j < 7; j++ ) { gotoxy(7,5+2*j); cprintf("%s",hari[j]); } // Set semua ruang = 0 for ( j = 0; j < SEMINGGU; j++ ) { for ( i = 0; i < 3; i++ ) { ruang_masa[i][j] = 0; } } for ( j = 0; j < SEMINGGU; j++ ) { for ( i = 0; i < 3; i++ ) { nombor = rand() % ( SEMINGGU * 3 ); gotoxy ( 25 + 20 * i, 5 + 2 * j); cprintf("R[%d][%d]= %d", i, j, nombor); } } getch(); } /* tamat modul uji_jadual */ /* fungsi : cari_kod_kursus */ int cari_kod_kursus( char *sasar, int n) { int i = 0 , jumpa = 0, lokasi; while ( !jumpa && i < n) { if ( strcmp ( subjek[i].kod_kursus, sasar ) == 0 ) jumpa = 1; else ++i; } /* penutup while */ if ( jumpa ) lokasi = i; else lokasi = TIADA; return ( lokasi ); } /* tamat modul cari_kod_kursus */ /* fungsi : cari_nama_pensyarah */ int cari_nama_pensyarah( char *sasar,int n) { int i = 0, jumpa = 0, lokasi; while ( !jumpa && i < n) { if ( strcmp ( subjek[i].nama_pensyarah, sasar ) == 0 ) jumpa = 1; else ++i; } if ( jumpa ) lokasi = i; else lokasi = TIADA; return( lokasi ); } /* tamat modul cari_nama_pensyarah */ /* Buka fail data & pengujian ke atas fail data */ void buka_fail ( void ) { FILE *fpt; /* menguji samada fail */ if (( fpt = fopen ("a:kursus.dat","r")) == NULL ) { clrscr(); gotoxy(24,12);printf(" Fail kursus.dat tiada "); sound(861); delay(1000); nosound(); delay(2000); gotoxy(24,12); printf(" continuing.......loading... "); delay(1000); return; } if( fread( &bil_rekod, sizeof bil_rekod, 1, fpt) != 1) { /* menguji samada data */ /* dapat dibaca dari fail */ gotoxy(20,12); printf("Pengujian pengiraan data kursus.dat rosak "); sound(861); delay(1000); nosound(); getch(); exit(1); } /* membaca samada data */ /* dapat dibaca dari fail */ if( fread( &subjek, sizeof subjek, 1, fpt) != 1) { gotoxy(20,12); printf("Data kursus.dat tidak dapat dibaca\n"); sound(861); delay(1000); nosound(); exit(1); } fclose( fpt ); } /* tamat mdul buka_fail */ /* Menulis data yang telah dimasukkan ke dalam fail data */ void simpan_data ( void ) { FILE *fpt; /*menguji samaada data */ /* dapat dibuka atau tidak */ if (( fpt = fopen ("a:kursus.dat","w")) == NULL) { gotoxy(24,12); printf(" Fail kursus.dat tiada "); sound(861); delay(1000); nosound(); delay(2000); gotoxy(24,12); printf(" continuing.......loading... "); delay(1000); exit(1); } if( fwrite ( &bil_rekod, sizeof(bil_rekod), 1, fpt) != 1) { gotoxy(20,12); printf("Pengujian pengiraan data kursus.dat rosak "); sound(861); delay(1000); nosound(); exit(1); } if ( fwrite ( &subjek, sizeof(subjek), 1, fpt) != 1) { gotoxy(20,12); printf("Data kursus.dat tidak dapat dibaca\n"); sound(861); delay(1000); nosound(); getch(); exit(1); } fclose ( fpt ); } /* tamat modul simpan_data */ /* Buka fail data & pengujian ke atas fail data */ void buka_fail_tarikh ( void ) { FILE *fpt; if(( fpt = fopen("a:tarikh.dat","r")) == NULL ) { clrscr(); gotoxy(24,12); printf(" Fail tarikh.dat tiada "); sound(861); delay(1000); nosound(); delay(2000); gotoxy(24,12); printf(" continuing.......loading... "); delay(1000); return; } if( fread( &bil_tarikh, sizeof bil_tarikh, 1, fpt) != 1) { gotoxy(20,12); printf("Pengujian pengiraan data tarikh.dat rosak "); sound(861); delay(1000); nosound(); exit(1); } if ( fread( &tarikh, sizeof tarikh, 1, fpt) != 1) { gotoxy(20,12); printf("Data tarikh.dat tidak dapat dibaca\n"); sound(861); delay(1000); nosound(); exit(1); } fclose(fpt); } /* tamat mdul buka_fail */ /* Menulis data yang telah dimasukkan ke dalam fail data */ void simpan_data_tarikh ( void ) { FILE *fpt; if (( fpt = fopen ("a:tarikh.dat","w")) == NULL) { gotoxy(24,12);printf(" Fail tarikh.dat tiada "); sound(861); delay(1000); nosound(); exit(1); } if( fwrite ( &bil_tarikh, sizeof(bil_tarikh), 1, fpt) != 1) { gotoxy(24,12); printf("Fail tarikh.dat tidak dapat ditulis"); sound(861); delay(1000); nosound(); exit(1); } if( fwrite ( &tarikh, sizeof(tarikh), 1, fpt) != 1) { gotoxy(20,12); printf("Data tarikh.dat tidak dapat dibaca\n"); sound(861); delay(1000); nosound(); exit(1); } fclose ( fpt ); } /* tamat modul simpan_data */ /* fungsi ralat: Memaparkan mesej ralat jika data tiada dalam fail */ void ralat ( void ) { clrscr(); sound(261); delay(150); nosound(); sound(183); delay(300); nosound(); _setcursortype(_NOCURSOR); textcolor(YELLOW); textbackground(RED); gotoxy(24,12); cprintf("ΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔ"); gotoxy(24,13); cprintf(" ???????? TIADA DALAM REKOD ????????"); gotoxy(24,14); cprintf("ΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔ"); delay(1500); textcolor(7); textbackground(0); _setcursortype(_NORMALCURSOR); }/* tamat fungsi ralat */ /* fungsi ralat2: memapar mesej ralat input pilihan kepada menu */ void ralat2 ( void ) { sound(451); delay(150); nosound(); sound(355); delay(300); nosound(); _setcursortype(_NOCURSOR); textcolor(YELLOW); textbackground(RED); gotoxy(24,12); cprintf("ΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔ"); gotoxy(24,13); cprintf(" PASTIKAN PILIHAN ANDA ADALAH TEPAT "); gotoxy(24,14); cprintf("ΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔΔ"); delay(1500); textcolor(7); textbackground(0); _setcursortype(_NORMALCURSOR); } /* tamat fungsi ralat2 */ /* fungsi 'Scroll': Keluar dari aturcara */ void Scroll() { unsigned a; textbackground(3); textcolor(0); for ( a = 2; a < 22; a++ ) { window(3,2,78,22); delline(); delay(30); } versi(); } /* tamat fungsi Scroll */ /* fungsi 'Scroll': Keluar dari aturcara */ void Scroll2() { unsigned a; textbackground(1); textcolor(0); for ( a = 2; a < 22; a++ ) { window(3,2,78,23); delline(); delay(30); } paparan(); window(1,1,80,25); } /* tamat fungsi Scroll */ /* fungsi 'Scroll': Keluar dari aturcara */ void pusing() { unsigned a; textbackground(0); textcolor(0); for ( a = 0; a < 25; a++) { gotoxy(1, 1); insline(); delay(30); } } /* tamat fungsi Scroll */ void versi (void) { int g; clrscr(); char kotakversi[10][65]= {"ΙΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝ»", "Ί SISTEM JADUAL WAKTU KURSUS Ί", "Ί versi 1.0 Ί", "Ί Copyright(C) 1999 Ί", "Ί by Ί", "Ί cyber group sdn bhd. Ί", "Ί this product is licensed to : Ί", "Ί SAL GROUPS OF COLLEGS Ί", "ΘΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΝΌ"}; _setcursortype(_NOCURSOR); flushall(); for ( g = 0; g < 10; g++ ) { window(10,10,40,5); textbackground(1); textcolor(13); delay(200); gotoxy(14,9+g);cprintf("%s",kotakversi[g]); } /* penutup for g */ textcolor(14); gotoxy(28,10); cprintf("SISTEM JADUAL WAKTU KURSUS"); gotoxy(36,11); cprintf("versi 1.0"); gotoxy(32,12); cprintf("Copyright(C) 1990"); gotoxy(38,13); cprintf("by"); gotoxy(30,14); cprintf("Cyber Group SDN. BHD."); gotoxy(27,15); cprintf("this product is licensed to :"); gotoxy(30,16); cprintf("SAL GROUPS OF COLLEGS"); delay(4000); textbackground(0); clrscr(); }