download another project bridge management

data-manager-for-education-centres.zip

Below is the Project of Address Management written in C with Menu

book.h

book.h

#include<conio.h>

#include<stdio.h>

#include<stdlib.h>

#include<string.h>
int getscancode(void)
{

int code;
code=getch();

if (code==0)
code=getch();
return(code);
}

int menuchoice(char menu[10][25],int numb)
{
int key,num=0,cont=1,posx=(10-(numb+1))/2,posy=(20-18)/2;
numb–;
_setcursortype(_NOCURSOR);

textattr(30);
gotoxy(posy,posx+1);
cprintf(“%s”,menu[0]);
cont=0;
while(cont<numb)
{
textattr(3);
gotoxy(posy,posx+2+cont);
cprintf(“%s”,menu[cont+1]);
cont++;
}

while(1)
{
key=getscancode();
switch(key)
{
case 72:
if (num<=0)
{
num=numb+1;
gotoxy(posy,posx+1);
textattr(3);
cprintf(“%s”,menu[0]);

}
else
{
gotoxy(posy,posx+num+1);
textattr(3);
cprintf(“%s”,menu[num]);
}
num=num-1;

gotoxy(posy,posx+num+1);
textattr(30);

cprintf(“%s”,menu[num]);
break;

case 80:
if (num>numb-1)
{
gotoxy(posy,posx+num+1);
num=0;
textattr(3);
cprintf(“%s”,menu[numb]);
}
else
{
gotoxy(posy,posx+num+1);
textattr(3);
cprintf(“%s”,menu[num]);
num=num+1;
}
gotoxy(posy,posx+num+1);
textattr(30);
cprintf(“%s”,menu[num]);
break;
case 27:
return(0);
case 13:
return(num+1);
}
}
}
void win(int c,int r,int c1,int r1)
{
int x;
window(1,1,80,25);
clrscr();
c=c-1;
r=r-1;
c1=c1+1;
r1=r1+1;
textcolor(WHITE);
textbackground(BLACK);
for (x=r;x<=r1;x++)
{
for(int y=c;y<=c1;y++)
{
gotoxy(y,x);
cprintf(” “);
}

}

for(int i=r;i<=r1;i++)
{
gotoxy(c,i);
putchar(‘º’);
}
for(i=r;i<=r1;i++)
{
gotoxy(c1,i);
putchar(‘º’);
}
/////////////////////////////////////////////
gotoxy(1,1);
for(i=c;i<=c1;i++)
{
gotoxy(i,r);
putchar(‘Í’);
}
for(i=c;i<=c1;i++)
{
gotoxy(i,r1);
putchar(‘Í’);
}
gotoxy(c,r);
putchar(‘É’);
gotoxy(c1,r);
putchar(‘»’);

gotoxy(c,r1);
putchar(‘È’);
gotoxy(c1,r1);
putchar(‘¼’);
window(c+1,r+1,c1-1,r1-1);
}

void printtext(char ch[],int len,int xpos,int ypos)
{

window(ypos,xpos,(ypos+len)-1,xpos);
clrscr();
puts(ch);
}

void textbox(char ch[],int len,int xpos,int ypos)
{

char che=’ ‘;
int i,j=0,max=0,mm;
window(ypos,xpos,(ypos+len)-1,xpos);
textbackground(RED);
textcolor(YELLOW);
clrscr();
gotoxy(1,1);
mm=strlen(ch);
for(i=mm;i<=len;i++)
{
ch[i]=’ ‘;
}
gotoxy(1,1);
for(i=0;1;)
{
if (i>max)
max=i;
if (i<(len)&&i>=0)
{
gotoxy(i+1,1);
che=getscancode();
if (che==13)
break;
if (che==8&&i!=0)
{

for(j=i-1;j<=len;j++)
{
ch[j]=ch[j+1];
gotoxy(j+1,1);
putchar(ch[j]);
}
i–;
max=max-1;
gotoxy(i,1);

}
else if(che==75)
{
i–;
gotoxy(i,1);
}
else if(che==77)
{
i++;
gotoxy(i,1);
}
else if (che==83)
{
for(j=i;j<=len;j++)
{
ch[j]=ch[j+1];
putchar(ch[j]);
}
gotoxy(i,1);
if( max>i)
max=max-1;
}
else if(che==71)
{
i=0;
gotoxy(i,1);
}
else if (che==79)
{
i=max;
gotoxy(max,1);
}
else
{
if(che!=8)
{
putchar(che);
ch[i]=che;
i++;

}
}
}
else
{
gotoxy(i,1);
che=getscancode();
if (che==13)
break;
if (che!=13)
{
if (che==8)
{
ch[i-1]=’ ‘;
i–;
gotoxy(i+1,1);
putchar(‘ ‘);
}
else if(che==75)
{
i–;
gotoxy(i,1);
}
else if (che==83)
{
ch[i-1]=’ ‘;
gotoxy(i+1,1);
putchar(‘ ‘);
gotoxy(i+1,1);
if( max>i)
max=max-1;
}
else if(che==71)
{
i=0;
gotoxy(i,1);
}

else
{
gotoxy(i,1);
putchar(che);
ch[len-1]=che;
}
}
}
}
ch[max]=’\0′;
ch[max+1]=’\n’;
window(1,1,1,1);
textbackground(BLACK);
textcolor(WHITE);
clrscr();
return;
}
int convint(char ch[])
{
int num;
sscanf( ch,”%d”,&num);
return(num);
}

int convfloat(char ch[])
{
float num;
sscanf( ch,”%f”,&num);
return(num);
}
int convdouble(char ch[])
{
double num;
sscanf( ch,”%ld”,&num);
return(num);
}
==============================================

sakmenu.c

#include”book.h”
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<string.h>
typedef struct
{
int id;
char name[30],radd[30],oadd[30],web[30],email[30],jobtitle[20],dept[30],company[30];
long int rtel,pagerno,mobile,fax,otel;
} ADD;

void main()
{
FILE *fp, *ft;
char another,sid;
ADD add;
int found=0,choice=0;
long int recsize;
char menu[6][25]={ ” Add Address “,
” List Address “,
” Modify Address”,
” Delete Address”,
” Search Address”,
” Exit ”
};

fp=fopen(“address.dat”, “rb+”);
if(fp==0)
{
fp=fopen(“address.dat”,”wb+”);
if(fp==0)
{
puts(“Can’t open the File”);
exit(0);
}
}
recsize=sizeof(add);
while(1)
{
clrscr();
win(30,8,50,15);
choice=menuchoice(menu,6);
textbackground(0);
textcolor(15);
switch(choice)
{
case 1:
fseek(fp,0,SEEK_END);
another=’y’;
while(another==’y’)
{
char ch[30];
win(10,4,60,19);
_setcursortype(_NORMALCURSOR);

gotoxy(1,1);
printf(“ID:”);
fflush(stdin);
scanf(“%d”,&add.id);
fflush(stdin);

window(1,1,80,25);
gotoxy(10,5);
printf(“Full Name:”);
scanf(“%[^\n]”,add.name);
fflush(stdin);

window(1,1,80,25);
gotoxy(10,6);
printf(“Res. Add:”);
scanf(“%[^\n]”,add.radd);
fflush(stdin);

window(1,1,80,25);
gotoxy(10,7);
printf(“Web Page: http://”);
scanf(“%[^\n]”,add.web);
fflush(stdin);

window(1,1,80,25);
gotoxy(10,8);
printf(“Email:”);
scanf(“%[^\n]”,add.email);
fflush(stdin);

window(1,1,80,25);
gotoxy(10,9);
printf(“Job Title:”);
scanf(“%[^\n]”,add.jobtitle);
fflush(stdin);

window(1,1,80,25);
gotoxy(10,10);
printf(“Deptment:”);
scanf(“%[^\n]”,add.dept);
fflush(stdin);

window(1,1,80,25);
gotoxy(10,11);
printf(“Off/Comp:”);
scanf(“%[^\n]”,add.company);
fflush(stdin);

window(1,1,80,25);
gotoxy(10,12);
printf(“Off Add:”);
scanf(“%[^\n]”,add.oadd);
fflush(stdin);

window(1,1,80,25);
gotoxy(10,13);
printf(“Res. Tel:”);
scanf(“%ld”,&add.rtel);
fflush(stdin);

window(1,1,80,25);
gotoxy(10,14);
printf(“Off. Tel:”);
scanf(“%ld”,&add.otel);
fflush(stdin);

window(1,1,80,25);
gotoxy(10,15);
printf(“Pager No:”);
scanf(“%ld”,&add.pagerno);
fflush(stdin);

window(1,1,80,25);
gotoxy(10,16);
printf(“Mobile No.:”);
scanf(“%ld”,&add.mobile);
fflush(stdin);

window(1,1,80,25);
gotoxy(10,17);
printf(“Fax No.:”);
scanf(“%ld”,&add.fax);
fflush(stdin);

fwrite(&add,recsize,1,fp);

window(1,1,80,25);
gotoxy(10,19);
printf(“Add another Record (y/n)”);
fflush(stdin);
another=getche();
}
break;
case 2:
rewind(fp); /* beinging of the file */
int ans=fread(&add,recsize,1,fp);
while(ans==1)
{
char you,re;
win(15,4,70,19);
gotoxy(1,1);
printf(“Id: %d\t”,add.id);
gotoxy(1,2);
printf(“Name: %s\t”,add.name);
gotoxy(1,3);
printf(“Res Add: %s\t”,add.radd);
gotoxy(1,4);
printf(“Web: http://%s\t”,add.web);
gotoxy(1,5);
printf(“Email: %s\t”,add.email);
gotoxy(1,6);
printf(“Job Title: %s\t”,add.jobtitle);
gotoxy(1,7);
printf(“Dept: %s\t”,add.dept);
gotoxy(1,8);
printf(“Company/Office: %s\t”,add.company);
gotoxy(1,9);
printf(“Off Add: %s\t”,add.oadd);
gotoxy(1,10);
printf(“Res Tel: %ld”,add.rtel);
gotoxy(1,11);
printf(“Off Tel: %ld”,add.otel);
gotoxy(1,12);
printf(“PagerNo: %ld”,add.pagerno);
gotoxy(1,13);
printf(“Mobile: %ld”,add.mobile);
gotoxy(1,14);
printf(“Fax: %ld”,add.fax);
gotoxy(1,16);
printf(“Next[n] Previous[p] Exit[e]:”);
fflush(stdin);
you=getch();
if(you==’p’)
{
fseek(fp,-(recsize*2),1);
re=fread(&add,recsize,1,fp);
if(re==0)
rewind(fp);
}
else if(you==’e’)
{
break;
}
else
{
fread(&add,recsize,1,fp);
}

}
break;
case 3:
another=’y’;
while(another==’y’)
{
win(15,4,70,19);
clrscr();
gotoxy(1,1);
printf(“Enter Id To Modify:”);
scanf(“%d”,&sid);
fflush(stdin);
rewind(fp);
found=0;
while(fread(&add,recsize,1,fp)==1)
{
if(add.id==sid)
{
found=1;
add.id=sid;
fflush(stdin);
gotoxy(1,2);
printf(“Full Name:”);
scanf(“%[^\n]”,add.name);
fflush(stdin);
gotoxy(1,3);
printf(“Res. Add:”);
scanf(“%[^\n]”,add.radd);
fflush(stdin);
gotoxy(1,4);
printf(“Web Page: http://”);
scanf(“%[^\n]”,add.web);
fflush(stdin);
gotoxy(1,5);
printf(“Email:”);
scanf(“%[^\n]”,add.email);
fflush(stdin);
gotoxy(1,6);
printf(“Job Title:”);
scanf(“%[^\n]”,add.jobtitle);
fflush(stdin);
gotoxy(1,7);
printf(“Deptment:”);
scanf(“%[^\n]”,add.dept);
fflush(stdin);
gotoxy(1,8);
printf(“Office/Company:”);
scanf(“%[^\n]”,add.company);
fflush(stdin);
gotoxy(1,9);
printf(“Enter Off Add: “);
scanf(“%[^\n]”,add.oadd);
fflush(stdin);
gotoxy(1,10);
printf(“Res. Tel:”);
scanf(“%ld”,&add.rtel);
fflush(stdin);
gotoxy(1,11);
printf(“Office. Tel:”);
scanf(“%ld”,&add.otel);
fflush(stdin);
gotoxy(1,12);
printf(“PagerNo:”);
scanf(“%ld”,&add.pagerno);
fflush(stdin);
gotoxy(1,13);
printf(“Mobile No:”);
scanf(“%ld”,&add.mobile);
fflush(stdin);
gotoxy(1,14);
printf(“Fax No:”);
scanf(“%ld”,&add.fax);
fseek(fp,-recsize,SEEK_CUR);
fwrite(&add,recsize,1,fp);
break;
}
}
gotoxy(1,2);
if(found==0)
printf(“Record Not Found”);
gotoxy(1,15);
printf(“Modify another Record (y/n)”);
fflush(stdin);
another=getche();
}
break;
case 4:
another=’y’;
while(another==’y’)
{
clrscr();
gotoxy(1,1);
printf(“Id To Delete:”);
scanf(“%d”,&sid);
found=0;
win(20,4,60,20);
clrscr();

rewind(fp); /* beinging of the file */
while(fread(&add,recsize,1,fp)==1)
{
if(sid==add.id)
{
found=1;
gotoxy(1,1);
printf(“%d\t”,add.id);
gotoxy(1,2);
printf(“%s\t”,add.name);
gotoxy(1,3);
printf(“%s\t”,add.radd);
gotoxy(1,4);
printf(“%s\t”,add.web);
gotoxy(1,5);
printf(“%s\t”,add.email);
gotoxy(1,6);
printf(“%s\t”,add.jobtitle);
gotoxy(1,7);
printf(“%s\t”,add.dept);
gotoxy(1,8);
printf(“%s\t”,add.company);
gotoxy(1,9);
printf(“%s\t”,add.oadd);
gotoxy(1,10);
printf(“%ld”,add.rtel);
gotoxy(1,11);
printf(“%ld”,add.otel);
gotoxy(1,12);
printf(“%ld”,add.pagerno);
gotoxy(1,13);
printf(“%ld”,add.mobile);
gotoxy(1,14);
printf(“%ld”,add.fax);
}
}
if(found==0)
{
gotoxy(1,14);
printf(“Record Not Found”);
getch();
break;
}
else
{
fflush(stdin);
gotoxy(1,15);
printf(“Delete Record:(y/n)”);
int del=getch();
if(del!=’y’)
break;
}

rewind(fp); /* beinging of the file */
ft=fopen(“taddress.dat”,”wb”);
while(fread(&add,recsize,1,fp)==1)
{
if(add.id!=sid)
fwrite(&add,recsize,1,ft);
}
fclose(ft);
fclose(fp);
remove(“address.dat”);
rename(“taddress.dat”,”address.dat”);
fp=fopen(“address.dat”,”rb+”);
gotoxy(1,16);
printf(“Delete another(Y/N):”);
fflush(stdin);
another=getche();
}
break;
case 5:
another=’y’;
while(another==’y’)
{
clrscr();
char text[30];
printf(“Search:”);
scanf(“%[^\n]”,text);
clrscr();
rewind(fp); /* beinging of the file */
found=0;
while(fread(&add,recsize,1,fp)==1)
{
if(strcmpi(text,add.name)==0||strcmpi(text,add.radd)==0||strcmpi(text,add.jobtitle)==0||strcmpi(text,add.dept)==0||strcmpi(text,add.company)==0||strcmpi(text,add.oadd)==0)
{
found=1;
win(20,4,60,19);
gotoxy(1,1);
printf(“Id: %d\t”,add.id);
gotoxy(1,2);
printf(“Name: %s\t”,add.name);
gotoxy(1,3);
printf(“Res Add: %s\t”,add.radd);
gotoxy(1,4);
printf(“Web: http://%s\t”,add.web);
gotoxy(1,5);
printf(“Email: %s\t”,add.email);
gotoxy(1,6);
printf(“Job Title: %s\t”,add.jobtitle);
gotoxy(1,7);
printf(“Dept: %s\t”,add.dept);
gotoxy(1,8);
printf(“Company/Office: %s\t”,add.company);
gotoxy(1,9);
printf(“Off Add: %s\t”,add.oadd);
gotoxy(1,10);
printf(“Res Tel: %ld”,add.rtel);
gotoxy(1,11);
printf(“Off Tel: %ld”,add.otel);
gotoxy(1,12);
printf(“PagerNo: %ld”,add.pagerno);
gotoxy(1,13);
printf(“Mobile : %ld”,add.mobile);
gotoxy(1,14);
printf(“Fax : %ld”,add.fax);
getch();
}
}
if(found==0)
{
gotoxy(1,3);
printf(“Record Not Found”);
}
clrscr();
gotoxy(1,5);
printf(“Again Search(Y/N):”);
fflush(stdin);
another=getche();
}
break;
case 6:
fclose(fp);
exit(0);
}
}
}

Leave a Reply