You are on page 1of 3

#include<utility.

h>
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<conio.h>
#include<windows.h>

void screen4()
{
//screen 4
clearportion(49,10,85,21);
// line1(4,2,90,24);
line2(6,3,88,23);
line1(8,4,86,8);
center(5,"Polytechnic University of the Phils.");
center(6,"San Juan Campus");
center(7,"San Juan City");
line1(8,9,45,22);
line1(48,9,86,22);
printxy(60,16,"AAAAAAAAAAAAAAAAAA");
line1(15,10,38,12); //MAIN MENU
printxy(23,11,"Main Menu");
printxy(12,13,"A] Create a new file");
printxy(12,15,"B] Add a record");
printxy(12,17,"C] Browse");
printxy(12,19,"D] Close");
printxy(20,21,"Select an option");
line1(6,25,88,27);
center(26,"Reserve for error message");
getch();
system("cls");
}

void screen3()
{
//screen 3
center(2,"Polytechnic University of the Phils.");
center(3,"San Juan Campus");
center(4,"San Juan City");
printxy(2,6,"Page: ");
printxy(28,8,"#Student\t#Student name\t\tProgram");
center(10,"=====================================================");
getch();
system("cls");

char screen1()
{
char ans=' ';
//screen 1
// line1(4,2,90,24);
line2(6,3,88,23);
line1(8,4,86,8);
center(5,"Polytechnic University of the Phils.");
center(6,"San Juan Campus");
center(7,"San Juan City");
line1(8,9,45,22);
line1(48,9,86,22);
printxy(60,14,"Programmed");
printxy(60,16,"By: AJI");
line1(15,10,38,12); //MAIN MENU
printxy(23,11,"Main Menu");
printxy(12,13,"A] Create a new file");
printxy(12,15,"B] Add a record");
printxy(12,17,"C] Browse");
printxy(12,19,"D] Close");
printxy(20,21,"Select an option");
line1(6,25,88,27);
center(26,"Reserve for error message");
// getch();
// system("cls");
gotoxy(37,21);gets;
ans=toupper(getch());
}

main()
{
// struct Student_record

char sn[20];
char ln[20];
char fn[20];
char mi[10];
int pc;

char ans=' ';

int x;
ans=screen1();

if (ans =='A')
{
FILE *fnew;
fclose(fopen("new.txt", "w"));
screen1();
clearportion(7,26,89,26);
printxy(30,26,"Your file has now been reset");
fclose(fnew);
getch();
clearportion(7,26,85,26);
screen1();
}

else if(ans == 'B')


{
// screen 2
clearportion(49,10,85,21);

FILE *fnew;
fnew=fopen("new.txt","a");
for(x=0;x<=2;x++)
{
printxy(50,10,"Student Number:");
printxy(50,12,"Last Name:");
printxy(50,14,"First Name:");
printxy(50,16,"M.I:");
printxy(50,18,"Program Code: ");

gotoxy(65,10);scanf("\n");gets(sn);
gotoxy(60,12);scanf("\n");gets(ln);
gotoxy(61,14);gets(fn);
gotoxy(54,16);gets(mi);
gotoxy(63,18);scanf("\n");scanf("%d",&pc);

fprintf(fnew,"\n%d %s %s %s %d",sn,ln,fn,mi,pc);
clearportion(49,10,85,21);
}
fclose(fnew);
system("cls");
printxy(32,26,"Your file has now been updated");
// return 1;
screen1();

else if (ans =='C')


{
system("cls");

center(2,"Polytechnic University of the Phils.");


center(3,"San Juan Campus");
center(4,"San Juan City");
printxy(2,6,"Page: ");
printxy(28,8,"#Student\t#Student name\t\tProgram");
center(10,"=====================================================");

FILE *fnew;
fnew=fopen("new.txt","r");
while(fscanf(fnew,"\n%s %s %s %s %d",sn,ln,fn,mi,&pc)!=EOF)
{
printf("\n\t\t\t%s",sn);
printf("\t\t%s %s %s",ln,fn,mi);
printf("\t\t%d",pc);
}
fclose(fnew);
getch();
system("cls");
screen1();
}

else if (ans =='D')


{
screen4();

}
}

You might also like