#include<stdio.h>
#include<conio.h>
#include<dos.h>
#include<ctype.h>
#include<process.h>
#include<stdlib.h>
struct lib
{
int bid,rent,qun,year;
char bname[20],author[20],publi[20];
}s;
struct staff
{
char fname[10],mname[10],lname[10],mno[11],email[40],gender,jdate[10];
int age,otp;
}se;
struct member
{
char n[20],mno[11],email[40],add[30];
int age;
}me;
struct password
{
char username[20],ppass[20],petname[20],favorite[20];
}p;
void header(); //Header
void display(); //Display
void sdisp(); //display for search
void search(); //Search
void nsearch(); //Name search
void loading(); //Loading
void entry(); //Entry
void saccess(); //staff access
void homepage(); //BAJS library Design
void login(); //login menu
void aentry(); //admin entry
void staffe(); //staff Entry
void staffdis(); //staff Display
void aaccess(); //admin Access
void staffser(); //staff search By Name
void dissta(); //display for Staff Search
void mentry(); //member Entry
void mdisplay(); //member display
void mdisplays(); //member search display
void msearch(); //member search()
void apassword(); //admin password
void spassreg(); //staff password registration
void staffpass(); //staff password
void bdelete(); //Book Delete
void sdelete(); //staff delete
void mdelete(); //Member Delete
void bdelete()
{
FILE *book,*del;
char dbook[20];
book=fopen("bentry.dat","r");
del=fopen("del.dat","a");
printf("Which Book Do You Want to Delete ?: ");
fflush(stdin);
gets(dbook);
if(book==NULL)
printf("File doesn't exist..");
while(!feof(book))
{
fscanf(book,"%d %s %s %s %d %d %d\n",&s.bid,s.bname,s.author,s.publi,&s.year,&s.rent,&s.qun);
if(stricmp(dbook,s.bname)!=0)
{
fprintf(del,"%d %s %s %s %d %d %d\n",s.bid,s.bname,s.author,s.publi,s.year,s.rent,s.qun);
}
}
fclose(book);
fclose(del);
remove("bentry.dat");
rename("del.dat","bentry.dat");
}
void sdelete()
{
FILE *staff,*del;
char sname[20];
staff=fopen("staff.dat","r");
del=fopen("del.dat","a");
printf("Which Staff Member Do You Want to Delete ?: ");
fflush(stdin);
gets(sname);
if(staff==NULL)
printf("File doesn't exist..");
while(!feof(staff))
{
fscanf(staff,"%s %s %s %s %s %c %d %d\n",se.jdate,se.fname,se.lname,se.mno,se.email,&se.gender,&se.age,&se.otp);
if(stricmp(sname,se.fname)!=0)
{
fprintf(del,"%s %s %s %s %s %c %d %d\n",se.jdate,se.fname,se.lname,se.mno,se.email,se.gender,se.age,se.otp);
}
}
fclose(staff);
fclose(del);
remove("staff.dat");
rename("del.dat","staff.dat");
}
void mdelete()
{
FILE *mem,*del;
char mname[20];
mem=fopen("mem.dat","r");
del=fopen("del.dat","a");
printf("Which Member Do You Want to Delete ?: ");
fflush(stdin);
gets(mname);
if(mem==NULL)
printf("File doesn't exist..");
while(!feof(mem))
{
fscanf(mem,"%s %s %s %s %d\n",me.n,me.email,me.add,me.mno,&me.age);
if(stricmp(mname,me.n)!=0)
{
fprintf(del,"%s %s %s %s %d\n",me.n,me.email,me.add,me.mno,me.age);
}
}
fclose(mem);
fclose(del);
remove("mem.dat");
rename("del.dat","mem.dat");
}
void apassword()
{
char buffer[256] = {0},admin[20];
char password[] = "mostwanted";
char c;
int pos = 0,count=0,chance=1;
clrscr();
start:
printf("\n\n\n\n\n\t\t\tEnter password: ");
do {
c=getch();
if(isprint(c))
{
buffer[pos++]=c;
printf("%c",'*');
}
else if(c==8 && pos)
{
buffer[pos--]='\0';
printf("%s", "\b \b");
}
} while(c!=13);
if(!strcmp(buffer,password))
{
printf("\n%s\n","Logged on succesfully!");
loading();
aaccess();
count++;
}
if(count==0)
{
printf("\nwrong Password");
}
}
void staffpass()
{
char buffer[256] = {0},uname[20];
char password[20];
char c;
int pos = 0,count=0,chance=1;
FILE *pass;
pass=fopen("staffpass.dat","r");
clrscr();
start:
printf("\n\n\n\n\n\t\t\tEnter User Name:");
fflush(stdin);
gets(uname);
printf("\n\t\t\tEnter password: ");
do {
c=getch();
if(isprint(c))
{
buffer[pos++]=c;
printf("%c",'*');
}
else if(c==8 && pos)
{
buffer[pos--]='\0';
printf("%s", "\b \b");
}
} while(c!=13);
while(!feof(pass))
{
fscanf(pass,"%s %s %s %s",p.username,p.ppass,p.petname,p.favorite);
if(!strcmp(uname,p.username) && !strcmp(buffer,p.ppass))
{
count++;
loading();
saccess();
//count++;
}
}
if(count==0)
{
printf("\nUsername or Password is Wrong..");
}
}
void spassreg()
{
FILE *pass,*staff;
char ch,empname[20];//ppass[20],empname[20],username[20],favorite[20],petname[20];
int count=0,unique;
clrscr();
staff=fopen("staff.dat","r");
pass=fopen("staffpass.dat","a");
printf("Are You a Member of Staff? (Y/N):");
fflush(stdin);
scanf("%c",&ch);
if(ch=='Y'||ch=='y')
{
printf("Enter Your First Name:");
fflush(stdin);
gets(empname);
printf("Enter Unique Code Given By Admin:");
scanf("%d",&unique);
while(!feof(staff))
{
fscanf(staff,"%s %s %s %s %s %c %d %d\n",se.jdate,se.fname,se.lname,se.mno,se.email,&se.gender,&se.age,&se.otp);
if(stricmp(empname,se.fname)==0 && unique==se.otp)
{
printf("Enter User Name :");
fflush(stdin);
gets(p.username);
printf("Enter Your Password:");
gets(p.ppass);
printf("\n\n\n\nAnswer The Following Question\n");
printf("This Questions is For Your Security Purpose\n");
printf("\n\nWhat Is Your Pet Name?: ");
gets(p.petname);
printf("\n\nWho Is Your Favorite Actress/Actor?: ");
gets(p.favorite);
fprintf(pass,"%s %s %s %s\n",p.username,p.ppass,p.petname,p.favorite);
count++;
}
}
}
if(count==0)
{
printf("Sorry! You are not a Staff Member of BAJS Library..");
}
fclose(pass);
fclose(staff);
}
void homepage()
{
printf("********* * ********** * * * \n");
printf("** * * * * * * \n");
printf("** * * * * * \n");
printf("** * * * * * \n");
printf("********* * * * * \n");
printf("** * *********** * * \n");
printf("** * * * * * * \n");
printf("** * * * * * * * \n");
printf("********* * * * * * * * * \n");
login();
getch();
}
void aaccess()
{
int ac;
do
{
clrscr();
printf("Hello Admin\n\n\n");
printf("*********** Menu *************\n");
printf("*0. Log Out *\n");
printf("*1. Enter Staff Data *\n");
printf("*2. Display Staff Details *\n");
printf("*3. Search Staff Data *\n");
printf("*4. Delete Book *\n");
printf("*5. Staff Delete *\n");
printf("*6. Member Delete *\n");
printf("******************************\n\n\n");
printf("Enter Your Choice :");
scanf("%d",&ac);
switch(ac)
{
case 0:
clrscr();
login();
break;
case 1:
clrscr();
staffe();
break;
case 2:
clrscr();
staffdis();
break;
case 3:
clrscr();
staffser();
break;
case 4:
clrscr();
bdelete();
break;
case 5:
clrscr();
sdelete();
break;
case 6:
clrscr();
mdelete();
break;
default:
printf("Wrong Input..\nSelect From Above Menu..");
}
getch();
}while(ac);
}
void staffe()
{
FILE *staff;
staff=fopen("staff.dat","a");
printf("Enter Joining Date :");
fflush(stdin);
gets(se.jdate);
printf("Enter First Name :");
//fflush(stdin);
gets(se.fname);
printf("Enter Last Name :");
gets(se.lname);
printf("Enter Mobile Number :");
gets(se.mno);
printf("Enter E-Mail ID :");
//fflush(stdin);
gets(se.email);
start:
printf("Enter Gender(M/F) :");
fflush(stdin);
scanf("%c",&se.gender);
se.gender=toupper(se.gender);
if(!(se.gender=='M'||se.gender=='F'))
{
textcolor(RED+BLINK);
cprintf("Wrong input...\nEnter only M or F...\n");
textcolor(WHITE);
goto start;
}
printf("Enter Age : ");
scanf("%d",&se.age);
randomize();
se.otp=random(10000)-1;
printf("Your Unique Code is :");
textcolor(RED+BLINK);
cprintf("%d",se.otp);
textcolor(WHITE);
fprintf(staff,"%s %s %s %s %s %c %d %d\n",se.jdate,se.fname,se.lname,se.mno,se.email,se.gender,se.age,se.otp);
fclose(staff);
}
void staffdis()
{
FILE *staff;
staff=fopen("staff.dat","r");
if(staff==NULL)
printf("File Doesn't Exist..");
while(!feof(staff))
{
fscanf(staff,"%s %s %s %s %s %c %d %d\n",se.jdate,se.fname,se.lname,se.mno,se.email,&se.gender,&se.age,&se.otp);
printf("%-15s %-15s %-15s %-15s %-15s %-15c %-7d\n",se.jdate,se.fname,se.lname,se.mno,se.email,se.gender,se.age);
}
fclose(staff);
}
void staffser()
{
FILE *staff;
int count=0;
char Ename[20];
staff=fopen("staff.dat","r");
printf("Enter Employee Name to Search :");
fflush(stdin);
gets(Ename);
if(staff==NULL)
printf("File Doesn't Exist..");
while(!feof(staff))
{
fscanf(staff,"%s %s %s %s %s %c %d %d\n",se.jdate,se.fname,se.lname,se.mno,se.email,&se.gender,&se.age,se.otp);
if(stricmp(Ename,se.fname)==0)
{
dissta();
count++;
}
}
if(count==0)
{
printf("Employee is Not Available");
}
fclose(staff);
}
void dissta()
{
clrscr();
printf("Joining Date :%s\n",se.jdate);
printf("First Name :%s\n",se.fname);
printf("Last Name :%s\n",se.lname);
printf("Mobile Number :%s\n",se.mno);
printf("Email ID :%s\n",se.email);
printf("Gender :%c\n",se.gender);
printf("Age :%d\n",se.age);
}
void mentry()
{
FILE *mem;
mem=fopen("mem.dat","a");
printf("Enter Member Name :");
fflush(stdin);
gets(me.n);
printf("Enter Email ID :");
gets(me.email);
printf("Enter Address :");
gets(me.add);
printf("Enter Mobile Number :");
gets(me.mno);
printf("Enter Age :");
scanf("%d",&me.age);
fprintf(mem,"%s %s %s %s %d\n",me.n,me.email,me.add,me.mno,me.age);
fclose(mem);
}
void mdisplay()
{
FILE *mem;
int memcount;
mem=fopen("mem.dat","r");
if(mem==NULL)
printf("File Doesn't Exist...");
while(!feof(mem))
{
fscanf(mem,"%s %s %s %s %d\n",me.n,me.email,me.add,me.mno,&me.age);
//mdisplays();
printf("%-10s %-10s %-15s %-10s %-7d\n",me.n,me.email,me.add,me.mno,me.age);
}
fclose(mem);
}
void mdisplays()
{
clrscr();
printf("Member Name :%s\n",me.n);
printf("Member E-mail :%s\n",me.email);
printf("Member Add :%s\n",me.add);
printf("Member Mobile Number :%s\n",me.mno);
printf("Member Age :%d\n",me.age);
}
void msearch()
{
FILE *mem;
char memname[20],reply;
int count=0;
mem=fopen("mem.dat","r");
printf("Enter Member Name to Search :");
fflush(stdin);
gets(memname);
if(mem==NULL)
printf("File Doesn't Exist..");
while(!feof(mem))
{
fscanf(mem,"%s %s %s %s %d\n",me.n,me.email,me.add,me.mno,&se.age);
if(stricmp(memname,me.n)==0)
{
mdisplays();
count++;
}
}
if(count==0)
{
printf("\n\n%s is Not a Member of Library",memname);
printf("\nWant To Be a Member(Y/N):");
scanf("%c",&reply);
if(reply=='Y'||reply=='y')
{
clrscr();
mentry();
}
else
{
saccess();
}
}
fclose(mem);
}
void login()
{
int choose;
do
{
clrscr();
printf("\n\n\n\n\t\t\tWelcome to BAJS Library\n");
printf("\t\t=========================================\n");
printf("\t\t* 0. Exit *\n");
printf("\t\t* 1. Admin *\n");
printf("\t\t* 2. Staff *\n");
printf("\t\t* 3. Member *\n");
printf("\t\t* 4. Privacy Registration(staff) *\n");
printf("\t\t=========================================\n");
printf("\t\tEnter Your Choice:");
scanf("%d",&choose);
switch(choose)
{
case 0:
exit(0);
break;
case 1:
apassword();
break;
case 2:
clrscr();
staffpass();
break;
case 4:
spassreg();
break;
default:
printf("Wrong Input\nSelect From Above Menu(1-3)");
}
getch();
}while(choose);
}
void loading()
{
int j;
clrscr();
gotoxy(35,12);
printf("Signing in...");
gotoxy(1,14);
for(j=1;j<=80;j++)
{
gotoxy(j,14);
printf("%c",196);
}
for(j=1;j<=80;j++)
{
gotoxy(j,16);
printf("%c",196);
}
for(j=2;j<=79;j++)
{
gotoxy(j,15);
printf("%c",219);
delay(50);
}
printf("\n\n\nEnter Any Key To continue..");
getch();
}
void entry()
{
FILE *p;
clrscr();
p=fopen("bentry.dat","a");
printf("Enter Book ID :");
scanf("%d",&s.bid);
printf("Enter Book Name :");
fflush(stdin);
gets(s.bname);
printf("Enter Author Name :");
fflush(stdin);
gets(s.author);
printf("Enter Publisher Name :");
fflush(stdin);
gets(s.publi);
printf("Publishing Year :");
scanf("%d",&s.year);
printf("Enter Book Rent :");
scanf("%d",&s.rent);
printf("Enter Quantity :");
scanf("%d",&s.qun);
fprintf(p,"%d %s %s %s %d %d %d\n",s.bid,s.bname,s.author,s.publi,s.year,s.rent,s.qun);
fclose(p);
}
void display()
{
FILE *p;
clrscr();
p=fopen("bentry.dat","r");
header();
if(p==NULL)
printf("File Doesn't Exist..");
while(!feof(p))
{
fscanf(p,"%d %s %s %s %d %d %d\n",&s.bid,s.bname,s.author,s.publi,&s.year,&s.rent,&s.qun);
printf("%-5d%-20s%-15s%-15s%-7d%-7d %-7d %-7d\n",s.bid,s.bname,s.author,s.publi,s.year,s.rent,s.qun);
}
fclose(p);
}
void sdisp()
{
clrscr();
printf("Book ID : %d\n",s.bid);
printf("Book Name : %s\n",s.bname);
printf("Book Author : %s\n",s.author);
printf("Book Publisher : %s\n",s.publi);
printf("Book Year : %d\n",s.year);
printf("Book Rent : %d\n",s.rent);
printf("Book Quantity : %d\n",s.qun);
}
void header()
{
int i;
for(i=1;i<=80;i++)
{
printf("=");
}
printf(" B_Id\tBook_Name\tAuthor\tPublisher\tYear\tPages\n");
for(i=1;i<=80;i++)
{
printf("=");
}
//getch();
}
void saccess()
{
int choice,count;
do{
clrscr();
printf("\n\t\t*****************************\n");
printf("\t\t Menu\n");
printf("\t\t*****************************\n");
printf("\t\t0. Log Out\n");
printf("\t\t1. Add Book Data\n");
printf("\t\t2. Display Data\n");
printf("\t\t3. Search By ID\n");
printf("\t\t4. Search By Name\n");
printf("\t\t5. Add Member \n");
printf("\t\t6. Display Members\n");
printf("\t\t7. Member Search \n");
printf("\t\t8. Book Issue \n");
printf("\t\t*****************************\n");
printf("\t\tEnter Your Choice:");
scanf("%d",&choice);
clrscr();
switch(choice)
{
case 0:
login();
break;
case 1:
clrscr();
entry();
break;
case 2:
clrscr();
display();
break;
case 3:
clrscr();
search();
break;
case 4:
clrscr();
nsearch();
break;
case 5:
clrscr();
mentry();
break;
case 6:
clrscr();
mdisplay();
break;
case 7:
clrscr();
msearch();
break;
default:
printf("Wrong Input..");
break;
}
getch();
}while(choice>0);
}
void search()
{
FILE *p;
int sid,count=0;
p=fopen("bentry.dat","r");
printf("Enter Book ID to Search :");
scanf("%d",&sid);
if(p==NULL)
printf("File Doesn't Exist..");
while(!feof(p))
{
fscanf(p,"%d %s %s %s %d %d %d\n",&s.bid,s.bname,s.author,s.publi,&s.year,&s.rent,&s.qun);
if(sid==s.bid)
{
sdisp();
count++;
}
}
if(count==0)
{
printf("Book is Not Available");
}
fclose(p);
}
void nsearch()
{
FILE *p;
int sid,count=0;
char name[20];
p=fopen("bentry.dat","r");
printf("Enter Book Name to Search :");
fflush(stdin);
gets(name);
if(p==NULL)
printf("File Doesn't Exist..");
while(!feof(p))
{
fscanf(p,"%d %s %s %s %d %d %d\n",&s.bid,s.bname,s.author,s.publi,&s.year,&s.rent,&s.qun);
if(stricmp(name,s.bname)==0)
{
sdisp();
count++;
}
}
if(count==0)
{
printf("Book is Not Available");
}
fclose(p);
}
void main()
{
clrscr();
homepage();
getch();
}
#include<conio.h>
#include<dos.h>
#include<ctype.h>
#include<process.h>
#include<stdlib.h>
struct lib
{
int bid,rent,qun,year;
char bname[20],author[20],publi[20];
}s;
struct staff
{
char fname[10],mname[10],lname[10],mno[11],email[40],gender,jdate[10];
int age,otp;
}se;
struct member
{
char n[20],mno[11],email[40],add[30];
int age;
}me;
struct password
{
char username[20],ppass[20],petname[20],favorite[20];
}p;
void header(); //Header
void display(); //Display
void sdisp(); //display for search
void search(); //Search
void nsearch(); //Name search
void loading(); //Loading
void entry(); //Entry
void saccess(); //staff access
void homepage(); //BAJS library Design
void login(); //login menu
void aentry(); //admin entry
void staffe(); //staff Entry
void staffdis(); //staff Display
void aaccess(); //admin Access
void staffser(); //staff search By Name
void dissta(); //display for Staff Search
void mentry(); //member Entry
void mdisplay(); //member display
void mdisplays(); //member search display
void msearch(); //member search()
void apassword(); //admin password
void spassreg(); //staff password registration
void staffpass(); //staff password
void bdelete(); //Book Delete
void sdelete(); //staff delete
void mdelete(); //Member Delete
void bdelete()
{
FILE *book,*del;
char dbook[20];
book=fopen("bentry.dat","r");
del=fopen("del.dat","a");
printf("Which Book Do You Want to Delete ?: ");
fflush(stdin);
gets(dbook);
if(book==NULL)
printf("File doesn't exist..");
while(!feof(book))
{
fscanf(book,"%d %s %s %s %d %d %d\n",&s.bid,s.bname,s.author,s.publi,&s.year,&s.rent,&s.qun);
if(stricmp(dbook,s.bname)!=0)
{
fprintf(del,"%d %s %s %s %d %d %d\n",s.bid,s.bname,s.author,s.publi,s.year,s.rent,s.qun);
}
}
fclose(book);
fclose(del);
remove("bentry.dat");
rename("del.dat","bentry.dat");
}
void sdelete()
{
FILE *staff,*del;
char sname[20];
staff=fopen("staff.dat","r");
del=fopen("del.dat","a");
printf("Which Staff Member Do You Want to Delete ?: ");
fflush(stdin);
gets(sname);
if(staff==NULL)
printf("File doesn't exist..");
while(!feof(staff))
{
fscanf(staff,"%s %s %s %s %s %c %d %d\n",se.jdate,se.fname,se.lname,se.mno,se.email,&se.gender,&se.age,&se.otp);
if(stricmp(sname,se.fname)!=0)
{
fprintf(del,"%s %s %s %s %s %c %d %d\n",se.jdate,se.fname,se.lname,se.mno,se.email,se.gender,se.age,se.otp);
}
}
fclose(staff);
fclose(del);
remove("staff.dat");
rename("del.dat","staff.dat");
}
void mdelete()
{
FILE *mem,*del;
char mname[20];
mem=fopen("mem.dat","r");
del=fopen("del.dat","a");
printf("Which Member Do You Want to Delete ?: ");
fflush(stdin);
gets(mname);
if(mem==NULL)
printf("File doesn't exist..");
while(!feof(mem))
{
fscanf(mem,"%s %s %s %s %d\n",me.n,me.email,me.add,me.mno,&me.age);
if(stricmp(mname,me.n)!=0)
{
fprintf(del,"%s %s %s %s %d\n",me.n,me.email,me.add,me.mno,me.age);
}
}
fclose(mem);
fclose(del);
remove("mem.dat");
rename("del.dat","mem.dat");
}
void apassword()
{
char buffer[256] = {0},admin[20];
char password[] = "mostwanted";
char c;
int pos = 0,count=0,chance=1;
clrscr();
start:
printf("\n\n\n\n\n\t\t\tEnter password: ");
do {
c=getch();
if(isprint(c))
{
buffer[pos++]=c;
printf("%c",'*');
}
else if(c==8 && pos)
{
buffer[pos--]='\0';
printf("%s", "\b \b");
}
} while(c!=13);
if(!strcmp(buffer,password))
{
printf("\n%s\n","Logged on succesfully!");
loading();
aaccess();
count++;
}
if(count==0)
{
printf("\nwrong Password");
}
}
void staffpass()
{
char buffer[256] = {0},uname[20];
char password[20];
char c;
int pos = 0,count=0,chance=1;
FILE *pass;
pass=fopen("staffpass.dat","r");
clrscr();
start:
printf("\n\n\n\n\n\t\t\tEnter User Name:");
fflush(stdin);
gets(uname);
printf("\n\t\t\tEnter password: ");
do {
c=getch();
if(isprint(c))
{
buffer[pos++]=c;
printf("%c",'*');
}
else if(c==8 && pos)
{
buffer[pos--]='\0';
printf("%s", "\b \b");
}
} while(c!=13);
while(!feof(pass))
{
fscanf(pass,"%s %s %s %s",p.username,p.ppass,p.petname,p.favorite);
if(!strcmp(uname,p.username) && !strcmp(buffer,p.ppass))
{
count++;
loading();
saccess();
//count++;
}
}
if(count==0)
{
printf("\nUsername or Password is Wrong..");
}
}
void spassreg()
{
FILE *pass,*staff;
char ch,empname[20];//ppass[20],empname[20],username[20],favorite[20],petname[20];
int count=0,unique;
clrscr();
staff=fopen("staff.dat","r");
pass=fopen("staffpass.dat","a");
printf("Are You a Member of Staff? (Y/N):");
fflush(stdin);
scanf("%c",&ch);
if(ch=='Y'||ch=='y')
{
printf("Enter Your First Name:");
fflush(stdin);
gets(empname);
printf("Enter Unique Code Given By Admin:");
scanf("%d",&unique);
while(!feof(staff))
{
fscanf(staff,"%s %s %s %s %s %c %d %d\n",se.jdate,se.fname,se.lname,se.mno,se.email,&se.gender,&se.age,&se.otp);
if(stricmp(empname,se.fname)==0 && unique==se.otp)
{
printf("Enter User Name :");
fflush(stdin);
gets(p.username);
printf("Enter Your Password:");
gets(p.ppass);
printf("\n\n\n\nAnswer The Following Question\n");
printf("This Questions is For Your Security Purpose\n");
printf("\n\nWhat Is Your Pet Name?: ");
gets(p.petname);
printf("\n\nWho Is Your Favorite Actress/Actor?: ");
gets(p.favorite);
fprintf(pass,"%s %s %s %s\n",p.username,p.ppass,p.petname,p.favorite);
count++;
}
}
}
if(count==0)
{
printf("Sorry! You are not a Staff Member of BAJS Library..");
}
fclose(pass);
fclose(staff);
}
void homepage()
{
printf("********* * ********** * * * \n");
printf("** * * * * * * \n");
printf("** * * * * * \n");
printf("** * * * * * \n");
printf("********* * * * * \n");
printf("** * *********** * * \n");
printf("** * * * * * * \n");
printf("** * * * * * * * \n");
printf("********* * * * * * * * * \n");
login();
getch();
}
void aaccess()
{
int ac;
do
{
clrscr();
printf("Hello Admin\n\n\n");
printf("*********** Menu *************\n");
printf("*0. Log Out *\n");
printf("*1. Enter Staff Data *\n");
printf("*2. Display Staff Details *\n");
printf("*3. Search Staff Data *\n");
printf("*4. Delete Book *\n");
printf("*5. Staff Delete *\n");
printf("*6. Member Delete *\n");
printf("******************************\n\n\n");
printf("Enter Your Choice :");
scanf("%d",&ac);
switch(ac)
{
case 0:
clrscr();
login();
break;
case 1:
clrscr();
staffe();
break;
case 2:
clrscr();
staffdis();
break;
case 3:
clrscr();
staffser();
break;
case 4:
clrscr();
bdelete();
break;
case 5:
clrscr();
sdelete();
break;
case 6:
clrscr();
mdelete();
break;
default:
printf("Wrong Input..\nSelect From Above Menu..");
}
getch();
}while(ac);
}
void staffe()
{
FILE *staff;
staff=fopen("staff.dat","a");
printf("Enter Joining Date :");
fflush(stdin);
gets(se.jdate);
printf("Enter First Name :");
//fflush(stdin);
gets(se.fname);
printf("Enter Last Name :");
gets(se.lname);
printf("Enter Mobile Number :");
gets(se.mno);
printf("Enter E-Mail ID :");
//fflush(stdin);
gets(se.email);
start:
printf("Enter Gender(M/F) :");
fflush(stdin);
scanf("%c",&se.gender);
se.gender=toupper(se.gender);
if(!(se.gender=='M'||se.gender=='F'))
{
textcolor(RED+BLINK);
cprintf("Wrong input...\nEnter only M or F...\n");
textcolor(WHITE);
goto start;
}
printf("Enter Age : ");
scanf("%d",&se.age);
randomize();
se.otp=random(10000)-1;
printf("Your Unique Code is :");
textcolor(RED+BLINK);
cprintf("%d",se.otp);
textcolor(WHITE);
fprintf(staff,"%s %s %s %s %s %c %d %d\n",se.jdate,se.fname,se.lname,se.mno,se.email,se.gender,se.age,se.otp);
fclose(staff);
}
void staffdis()
{
FILE *staff;
staff=fopen("staff.dat","r");
if(staff==NULL)
printf("File Doesn't Exist..");
while(!feof(staff))
{
fscanf(staff,"%s %s %s %s %s %c %d %d\n",se.jdate,se.fname,se.lname,se.mno,se.email,&se.gender,&se.age,&se.otp);
printf("%-15s %-15s %-15s %-15s %-15s %-15c %-7d\n",se.jdate,se.fname,se.lname,se.mno,se.email,se.gender,se.age);
}
fclose(staff);
}
void staffser()
{
FILE *staff;
int count=0;
char Ename[20];
staff=fopen("staff.dat","r");
printf("Enter Employee Name to Search :");
fflush(stdin);
gets(Ename);
if(staff==NULL)
printf("File Doesn't Exist..");
while(!feof(staff))
{
fscanf(staff,"%s %s %s %s %s %c %d %d\n",se.jdate,se.fname,se.lname,se.mno,se.email,&se.gender,&se.age,se.otp);
if(stricmp(Ename,se.fname)==0)
{
dissta();
count++;
}
}
if(count==0)
{
printf("Employee is Not Available");
}
fclose(staff);
}
void dissta()
{
clrscr();
printf("Joining Date :%s\n",se.jdate);
printf("First Name :%s\n",se.fname);
printf("Last Name :%s\n",se.lname);
printf("Mobile Number :%s\n",se.mno);
printf("Email ID :%s\n",se.email);
printf("Gender :%c\n",se.gender);
printf("Age :%d\n",se.age);
}
void mentry()
{
FILE *mem;
mem=fopen("mem.dat","a");
printf("Enter Member Name :");
fflush(stdin);
gets(me.n);
printf("Enter Email ID :");
gets(me.email);
printf("Enter Address :");
gets(me.add);
printf("Enter Mobile Number :");
gets(me.mno);
printf("Enter Age :");
scanf("%d",&me.age);
fprintf(mem,"%s %s %s %s %d\n",me.n,me.email,me.add,me.mno,me.age);
fclose(mem);
}
void mdisplay()
{
FILE *mem;
int memcount;
mem=fopen("mem.dat","r");
if(mem==NULL)
printf("File Doesn't Exist...");
while(!feof(mem))
{
fscanf(mem,"%s %s %s %s %d\n",me.n,me.email,me.add,me.mno,&me.age);
//mdisplays();
printf("%-10s %-10s %-15s %-10s %-7d\n",me.n,me.email,me.add,me.mno,me.age);
}
fclose(mem);
}
void mdisplays()
{
clrscr();
printf("Member Name :%s\n",me.n);
printf("Member E-mail :%s\n",me.email);
printf("Member Add :%s\n",me.add);
printf("Member Mobile Number :%s\n",me.mno);
printf("Member Age :%d\n",me.age);
}
void msearch()
{
FILE *mem;
char memname[20],reply;
int count=0;
mem=fopen("mem.dat","r");
printf("Enter Member Name to Search :");
fflush(stdin);
gets(memname);
if(mem==NULL)
printf("File Doesn't Exist..");
while(!feof(mem))
{
fscanf(mem,"%s %s %s %s %d\n",me.n,me.email,me.add,me.mno,&se.age);
if(stricmp(memname,me.n)==0)
{
mdisplays();
count++;
}
}
if(count==0)
{
printf("\n\n%s is Not a Member of Library",memname);
printf("\nWant To Be a Member(Y/N):");
scanf("%c",&reply);
if(reply=='Y'||reply=='y')
{
clrscr();
mentry();
}
else
{
saccess();
}
}
fclose(mem);
}
void login()
{
int choose;
do
{
clrscr();
printf("\n\n\n\n\t\t\tWelcome to BAJS Library\n");
printf("\t\t=========================================\n");
printf("\t\t* 0. Exit *\n");
printf("\t\t* 1. Admin *\n");
printf("\t\t* 2. Staff *\n");
printf("\t\t* 3. Member *\n");
printf("\t\t* 4. Privacy Registration(staff) *\n");
printf("\t\t=========================================\n");
printf("\t\tEnter Your Choice:");
scanf("%d",&choose);
switch(choose)
{
case 0:
exit(0);
break;
case 1:
apassword();
break;
case 2:
clrscr();
staffpass();
break;
case 4:
spassreg();
break;
default:
printf("Wrong Input\nSelect From Above Menu(1-3)");
}
getch();
}while(choose);
}
void loading()
{
int j;
clrscr();
gotoxy(35,12);
printf("Signing in...");
gotoxy(1,14);
for(j=1;j<=80;j++)
{
gotoxy(j,14);
printf("%c",196);
}
for(j=1;j<=80;j++)
{
gotoxy(j,16);
printf("%c",196);
}
for(j=2;j<=79;j++)
{
gotoxy(j,15);
printf("%c",219);
delay(50);
}
printf("\n\n\nEnter Any Key To continue..");
getch();
}
void entry()
{
FILE *p;
clrscr();
p=fopen("bentry.dat","a");
printf("Enter Book ID :");
scanf("%d",&s.bid);
printf("Enter Book Name :");
fflush(stdin);
gets(s.bname);
printf("Enter Author Name :");
fflush(stdin);
gets(s.author);
printf("Enter Publisher Name :");
fflush(stdin);
gets(s.publi);
printf("Publishing Year :");
scanf("%d",&s.year);
printf("Enter Book Rent :");
scanf("%d",&s.rent);
printf("Enter Quantity :");
scanf("%d",&s.qun);
fprintf(p,"%d %s %s %s %d %d %d\n",s.bid,s.bname,s.author,s.publi,s.year,s.rent,s.qun);
fclose(p);
}
void display()
{
FILE *p;
clrscr();
p=fopen("bentry.dat","r");
header();
if(p==NULL)
printf("File Doesn't Exist..");
while(!feof(p))
{
fscanf(p,"%d %s %s %s %d %d %d\n",&s.bid,s.bname,s.author,s.publi,&s.year,&s.rent,&s.qun);
printf("%-5d%-20s%-15s%-15s%-7d%-7d %-7d %-7d\n",s.bid,s.bname,s.author,s.publi,s.year,s.rent,s.qun);
}
fclose(p);
}
void sdisp()
{
clrscr();
printf("Book ID : %d\n",s.bid);
printf("Book Name : %s\n",s.bname);
printf("Book Author : %s\n",s.author);
printf("Book Publisher : %s\n",s.publi);
printf("Book Year : %d\n",s.year);
printf("Book Rent : %d\n",s.rent);
printf("Book Quantity : %d\n",s.qun);
}
void header()
{
int i;
for(i=1;i<=80;i++)
{
printf("=");
}
printf(" B_Id\tBook_Name\tAuthor\tPublisher\tYear\tPages\n");
for(i=1;i<=80;i++)
{
printf("=");
}
//getch();
}
void saccess()
{
int choice,count;
do{
clrscr();
printf("\n\t\t*****************************\n");
printf("\t\t Menu\n");
printf("\t\t*****************************\n");
printf("\t\t0. Log Out\n");
printf("\t\t1. Add Book Data\n");
printf("\t\t2. Display Data\n");
printf("\t\t3. Search By ID\n");
printf("\t\t4. Search By Name\n");
printf("\t\t5. Add Member \n");
printf("\t\t6. Display Members\n");
printf("\t\t7. Member Search \n");
printf("\t\t8. Book Issue \n");
printf("\t\t*****************************\n");
printf("\t\tEnter Your Choice:");
scanf("%d",&choice);
clrscr();
switch(choice)
{
case 0:
login();
break;
case 1:
clrscr();
entry();
break;
case 2:
clrscr();
display();
break;
case 3:
clrscr();
search();
break;
case 4:
clrscr();
nsearch();
break;
case 5:
clrscr();
mentry();
break;
case 6:
clrscr();
mdisplay();
break;
case 7:
clrscr();
msearch();
break;
default:
printf("Wrong Input..");
break;
}
getch();
}while(choice>0);
}
void search()
{
FILE *p;
int sid,count=0;
p=fopen("bentry.dat","r");
printf("Enter Book ID to Search :");
scanf("%d",&sid);
if(p==NULL)
printf("File Doesn't Exist..");
while(!feof(p))
{
fscanf(p,"%d %s %s %s %d %d %d\n",&s.bid,s.bname,s.author,s.publi,&s.year,&s.rent,&s.qun);
if(sid==s.bid)
{
sdisp();
count++;
}
}
if(count==0)
{
printf("Book is Not Available");
}
fclose(p);
}
void nsearch()
{
FILE *p;
int sid,count=0;
char name[20];
p=fopen("bentry.dat","r");
printf("Enter Book Name to Search :");
fflush(stdin);
gets(name);
if(p==NULL)
printf("File Doesn't Exist..");
while(!feof(p))
{
fscanf(p,"%d %s %s %s %d %d %d\n",&s.bid,s.bname,s.author,s.publi,&s.year,&s.rent,&s.qun);
if(stricmp(name,s.bname)==0)
{
sdisp();
count++;
}
}
if(count==0)
{
printf("Book is Not Available");
}
fclose(p);
}
void main()
{
clrscr();
homepage();
getch();
}
Jordar bro...
ReplyDelete