/* Call Me : 9818957447*/ /*(c)Lateral Guys,2007*/
#include "stdio.h"
#include "conio.h"
#include "graphics.h"
#include "dos.h"
#include "iostream.h"
#include "fstream.h"
#include "string.h"
int CHOICE=1, LOOP=0, SR=500;
struct datm
{
int dd;
int mm;
int yy;
};
struct book
{
int rec_no;
char book_name[20];
char book_author[20];
char stu_name[20];
char stu_class[2];
struct datm issue;
struct datm back;
char flag;
};
void button(int in_xt, int in_yt, int color, char *msg)
{
int in_xf=in_xt+(strlen(msg)*9);
int in_yf=in_yt+30;
setfillstyle(1,WHITE);
bar(in_xt-2, in_yt-2,in_xf,in_yf);
setfillstyle(1,DARKGRAY);
bar(in_xt, in_yt, in_xf+2, in_yf+2);
if(color==0)
{
setfillstyle(1,LIGHTGRAY);
bar(in_xt,in_yt,in_xf,in_yf);
outtextxy(in_xt+10,in_yt+10,msg);
}
else
{
setfillstyle(1,LIGHTGREEN);
bar(in_xt,in_yt,in_xf,in_yf);
setcolor(BLACK);
outtextxy(in_xt+10,in_yt+10,msg);
setcolor(WHITE);
}
}
void disp(int in_xt, int in_yt, int bk_col, int txt_col, char *msg)
{
int in_xf=in_xt+(strlen(msg)*9);
int in_yf=in_yt+30;
setfillstyle(1,WHITE);
bar(in_xt-2, in_yt-2, in_xf, in_yf);
setfillstyle(1,DARKGRAY);
bar(in_xt, in_yt, in_xf+2, in_yf+2);
setfillstyle(1,bk_col);
bar(in_xt-2, in_yt, in_xf, in_yf);
setcolor(txt_col);
outtextxy(in_xt+10, in_yt+10,msg);
setcolor(WHITE);
}
void blank()
{
clrscr();
setfillstyle(1,BLACK);
bar(0,0,getmaxx(),getmaxy());
gotoxy(1,1);
}
void wait()
{
button(200,400,0," Press Any Key To Continue!! ");
getch();
}
void welcome()
{
int i, x1=20, x2=570, y=100;
char *m;
settextstyle(1,0,3);
setcolor(GREEN);
outtextxy(100,50, " (C) Sunil Rai International.... V1.1 ");
settextstyle(1,0,3);
setcolor(GREEN);
outtextxy(100,400," (R) Library Management FreeWare ");
for(i=0;i<=11;i++)
{
sprintf(m,"%d % ", (i-1)*10);
settextstyle(1,0,8);
disp(x1,y,i,7," ");
x1=x1+50;
disp(x2,y+250,i,7," ");
x2=x2-50;
settextstyle(1,0,8);
setcolor(BLACK);
outtextxy(100,200," Loading... ");
setfillstyle(1,BLACK);
bar(270,300,400,340);
delay(SR);
setcolor(i);
settextstyle(1,0,8);
outtextxy(100,200," Loading... ");
setcolor(WHITE);
settextstyle(3,0,4);
outtextxy(270,300,m);
delay(SR);
}
blank();
}
void bye()
{
blank();
button(130,400,0," (R)SR International... V1.1, Quiting..");
button(130,350,0," Press Any Key To Continue!! ");
while(!kbhit())
{
button(130,100,0," Thank's For Using ");
button(130,150,1," (C)SR International ");
delay(SR);
button(130,100,1," Thank's For Using ");
button(130,150,0," (C)SR International ");
delay(SR);
}
}
void add_book()
{
book b;
char ch='Y';
ofstream outfile;
outfile.open("BOOK.DAT", ios::out | ios::binary);
while(ch=='Y' || ch=='y')
{
blank();
cout<
cout<
b.flag='A';
b.issue.dd=0; b.issue.mm=0; b.issue.yy=0;
b.back.dd=0; b.back.mm=0; b.back.yy=0;
outfile.write((char *)&b, sizeof(b));
}
outfile.close();
blank();
}
void show_book(char kk, char *msg)
{
book b;
char ch='Y';
ifstream infile;
infile.open("BOOK.DAT", ios::out | ios::binary);
blank();
while(infile.read((char *)&b, sizeof(b)))
{
switch(kk)
{
case 'S' :
if(b.flag=='A')
{
cout<
else
{
cout<
break;
case 'R' :
if(b.flag=='C')
{
cout<
else
{
cout<
break;
}
}
wait();
infile.close();
blank();
}
void issue_book()
{
book b;
int temp=0, count=0, is_book=0;
long int pos;
struct date d3;
fstream file;
file.open("BOOK.DAT", ios::out | ios::in | ios::binary);
blank();
getdate(&d3);
cout<
file.seekg(0L, ios::beg);
while(file.read((char *)&b, sizeof(b)))
{
if(b.rec_no==is_book)
{
cout<
b.issue.dd=d3.da_day;
b.issue.mm=d3.da_mon;
b.issue.yy=d3.da_year;
if((b.issue.dd+7)>31)
{ b.back.dd=(b.issue.dd+7)-31; b.back.mm=b.issue.mm+1; b.back.yy=b.issue.yy; }
else
{ b.back.dd=(b.issue.dd+7); b.back.mm=b.issue.mm; b.back.yy=b.issue.yy; }
pos=count*sizeof(b);
file.seekp(pos,ios::beg);
file.write((char *)&b, sizeof(b));
temp=1;
}
count++;
}
if(temp==0)
{
cout<<"\n Book Not Found or Might be Issued !!!! "<
else
{
cout<<"\n Book number #"<
wait();
file.close();
blank();
}
void return_book()
{
book b;
int temp=0, count=0, is_book=0;
long int pos;
struct date d4;
fstream file;
file.open("BOOK.DAT", ios::out | ios::in | ios::binary);
blank();
getdate(&d4);
show_book('R', " Book Available ");
cout<
cout<
while(file.read((char *)&b, sizeof(b)))
{
if(b.rec_no==is_book)
{
if(d4.da_day>b.back.dd && d4.da_mon>=b.back.mm)
{
cout<
b.flag='A';b.issue.dd=0;b.issue.mm=0;b.issue.yy=0;b.back.dd=0;b.back.mm=0;b.back.yy=0;
pos=count*sizeof(b);
file.seekp(pos,ios::beg);
file.write((char *)&b, sizeof(b));
temp=1;
}
count++;
}
if(temp==0)
{
cout<<"\n Book Not Found or Might be Issued !!!! "<
else
{
cout<<"\n Book number #"<
wait();
file.close();
blank();
}
void main_menu(int x ,int y)
{
settextstyle(0,0,0);
button(x,y,0," SR International School Library Software ");
int x1=x+100;
button(x1,y+50,0, " [ MAIN MENU ] ");
button(x1,y+100,0," #1 Add Book ");
button(x1,y+150,0," #2 Show Book ");
button(x1,y+200,0," #3 Issue Book ");
button(x1,y+250,0," #4 Return Book ");
button(x1,y+300,0," #5 Exit ");
char ch=getch();
if(ch==80) CHOICE++;
if(ch==72) CHOICE--;
if(CHOICE<1) choice="5;">5) CHOICE=1;
switch(CHOICE)
{
case 1 : button(x1,y+100,1," #1 Add Book ");
if((ch=getch())==13) { add_book(); } break;
case 2 : button(x1,y+150,1," #2 Show Book ");
if((ch=getch())==13) { show_book('S'," Issued Book "); } break;
case 3 : button(x1,y+200,1," #3 Issue Book ");
if((ch=getch())==13) { issue_book(); } break;
case 4 : button(x1,y+250,1," #4 Return Book ");
if((ch=getch())==13) { return_book(); } break;
case 5 : button(x1,y+300,1," #5 Exit ");
if((ch=getch())==13) { LOOP=1; } break;
}
}
void main()
{
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
welcome();
while(LOOP==0)
{
main_menu(150,100);
}
bye();
closegraph();
restorecrtmode();
}
/*Coded and Compiled By: Sunil Rai (sunilplayer@gmail.com)*/
/*(c)Lateral Guys,2007*/
No comments:
Post a Comment