0% found this document useful (0 votes)
6 views

Mini

Uploaded by

mayekarsai332
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Mini

Uploaded by

mayekarsai332
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

/* ################################################## START FROM HERE

############################################################################
#################### */

printf("Problem");
gotoxy(98,15);
printf("Prescribed Doctor\n");
printf("===================================================================
==========================");
row=17;
while(fscanf(ek,"%s %s %c %i %s %s %s %s
%s\n",p.First_Name,p.Last_Name,&p,Gender,&p.age,p.Address,p.Contact_no,p.Email,p.Proble
m,p.Doctor)!=EOF)
{
gotoxy(1,row);
printf("%s %s",p.First_Name, p.Last_Name);
gotoxy(20,row);
printf("%c,p.Gender);
gotoxy(32,row);
printf("%i",p.age);
gotoxy(37,row);
printf("%s",p.Address);
gotoxy(49,row);
printf("%s",p.Contact_no);
gotoxy(64,row);
printf("%s",p.Email);
gotoxy(88,row);
printf("%s",p.Problem);
gotoxy(98,row);
printyf("%s",p.Doctor);
row++;
}
fclose(ek);
getch();
MainMenu();
}
void Search_rec(void)
{
char name[20];
system("cls");
Title(); //call Title function
FILE *ek;
ek=fopen("Record2.dat","r");
printf("\n\n\t\t\t!!!!!!!!!!!!!!!!n Search Paqtients Record !!!!!!!!!!!!!!!!!!!\n");
gotoxy(12,8);
printf("\n Enter Patient Name to be viewed:");
scanf("%s",name);
fflush(stdin);
name[0]=toupper(name[0]);
while(fscanf(ek,"%s %s %c %i %s %s %s %s
%s\n",p.First_Name,p.Last_Name,&p.Gender,&p.age,p.Address,p.Contact_no,p.Email,p.Proble
m,p.Doctor)!=EOF)
{
if(strcmp(p.First_Name,name)==0)
{
gotoxy(1,15);
printf("Full Name");
gotoxy(25,15);
printf("Gender");
goto(32,15);
printf("Age");
gotoxy(37,15);
printf("Address");
gotoxy(52,15);
printf("Contact No.");
gotoxy(64,15);
printf("Email");
gotoxy(80,15);
printf("Problem");
gotoxy(95,15);
printf("Prescribed Doctor\n");

printf("===================================================================
======================================");
gotoxy(1,18);
printf(%s%s",p.First_Name,p.Last_Name);
goto(25,18);
printf("%c,p.Gender);
gotoxy(32,18);
printf("%i",p.age);
gotoxy(37,18);
printf("%s",p.Address);
gotoxy(52,18);
printf("%s",p.Contact_no);
gotoxy(64,18);
printf("%s",p.Email);
gotoxy(80,18);
printf("%s",p.Problem);
gotoxy(95,18);
printf("%s,p.Doctor);
printf("\n");
break;
}
}
if(strcmp(p.First_Name,name)!=0)
{
gotoxy(5,10);
printf("Record not found");
getch();
}
fclose(ek);
L;
getch();
printf("\n\n\t\t\tDo you want to view more[Y/N]??");
scanf("%c",&ans);
if(toupper(ans)=='Y')
{
Search_rec();
}
else if(toupper(ans)=='N')
{
printf("\n\t\t Thank you :) :)");
getch();
MainMenu();
}
else
{
printf("\n\tInvalide Input.\n");
goto L;
}

}
void Edit_rec(void)
{
FILE *ek,*ft;
int i,b,valid=0;
char ch;
char name[20];
system("cls");
Title();
ft=fopen("temp2.dat","wt");
ek=fopen("Record2.dat","r");
if(ek==NULL)
{
printf("\n\t Can not open file!! ");
getch();
MainMenu();
}
printf("\n\n\t\t\t!!!!!!!!!!!!!!!! Edit Patients Record !!!!!!!!!!!!!!!!!\n");
gotoxy(12,13);
printf(" Enter the First Name of the Patient : ");
scanf(" %s",name);
fflush(stdin);
name[0]=toupper(name[0]);
gotoxy(12,15);
if(ft==NULL)
{
printf("\n Can not open file");
getch();
MainMenu();
}
while(fscanf(ek,%s %s %c %i %s %s %s %s %s\n",p.First_Name, p.Last_Name,
&p.Gender,&p.age,p.Address,p.Contact_no,p.Email,p.Problem,p.Doctor)!=EOF)
{
if(strcmp(p.First_Name, name)==0)
{
valid=1;
gotoxy(25,17);
printf("*** Existing Record ***");
gotoxy(10,19)
printf(%s \t%s \t%c \t%i \t%s \t%s \t%s \t%s
\t%s\n",p.First_name,p.Last_Name,p.Gender,,&p.age,p.Address,p.Contact_no,p.Email,p.Proble
m,p.Doctor);
gotoxy(12,22);
printf("Enter New First Name: ");
scanf(%s",p.First_Name);
gotoxy(12,24);
printf("Enter Last Name: ");
scanf("%s",p.Last_Name);
gotoxy(12,26);
printf("Enter Gender: ");
scanf("%c",&p.Gender);
p.Gender=toupper(p.Gender);
gotoxy(12,28);
printf("Enter age: ");
scanf( %i",&p.age);
gotoxy(12,30);
printf("Enter Address: ");
scanf("%s",p.Address);
p.Address[0]=toupper(p.address[0]);
gotoxy(12,32);
printf("Enter Contact no: ");
scanf("%s",p.Contact_no);
gotoxy(12,34);
printf("Enter New email: ");
scanf("%s",p.Email);
gotoxy(12,36);
printf("Enter Problem: ");
scanf("%s",p.Problem);
p.Problem[0]=toupper(p.Problem[0]);
gotoxy(12,38);
printf("enter Doctor: ");
scanf(%s",p.Doctor);
p.Doctor[0]=toupper(p.Doctor[0]);
printf("\nPress U character for the updating operation : ");
ch=getche();
if(ch=='u'|| ch=='U')
{
fprintf(ft,"%s %s %c %i %s %s %s %s %s\n",p.First_Name,p.Last_Name,p.Gender,
p.age,p.Address,p.Contact_no,p.Email,p.Problem,p.Doctor);
{
printf("\n\n\t\t\tPatient record update successfully...");
}
}
else
{
fprintf(ft,"$s $s %c %i %s %s %s %s
%s\n",p.First_Name,p.Last_Name,p.Gender,P.age,p.address,p.Contact_no,p.Email,p.Problem,p
.Doctor);
}
}
if(!valid)
{
printf("\n\t\tNO RECORD FOUND...");
}
fclose(ft);
fclose(ek);
remove("Record2.dat");
rename("temp2.dat","Record2.dat");
getch();
MainMenu();

}
void Dlt_rec()
{
char name[20];
int found=0;
system("cls");
Title(); // call Title function
FILE *ek,*ft;
ft=fopen("temp_file2.dat","w+");
ek=fopen("Record2.dat","r");
printf("\n\n\t\t\t!!!!!!!!!!!!!!!!!!!! Delete Patients Record !!!!!!!!!!!!!!!!!!!\n");
gotoxy(12,8);
printf("\n Enter Patient Name to delete: ");
fflush(stdin);
gets(name);
name[0]=toupper(name[0]);
while (fscanf(ek,"%s %s %c %i %s %s %s %s
%s",p.First_Name,p.Last_Name,&p.Gender,&p.age,p.Address,p.Contact_no,p.Email,p.Problem,
p.Doctor)!=EOF)
{
if(strcmp(p.First_Name,name)!=0)
fprintf(ft,"%s %s %c %i %s %s %s %s
%s\n",p.First_Name,p.Last_Name,p.Gender,p.age,p.Address,p.Contact_no,p.Email,p.Problem,p
.Doctor);
else
{
printf("%s %s %c %i %s %s %s %s
%s\n",p.First_Name,p.Last_Name,p.Gender,p.age,p,Address,p.Contact_no,p.Email,p.Problem,p
.Doctor);
found=1;
}
} //while loop ends
if(found==0)
{
printf("\n\n\t\t\t Record not found....");
getch();
MainMenu();
}
else
{
fclose(ek);
fclose(ft);
remove("Record2.dat");
rename("temp_file2.dat","Record2.dat");
printf("\n\n\t\t\t Record deleted successfully :) ");
getch();
MainMenu();
}
}

You might also like