Monday, February 22, 2010

Sunil Rai...Project For C++, Digital Clock

/*Coded and Compiled By: Sunil Rai (sunilplayer@gmail.com)*/
/*(c)Lateral Guys,2007*/
#include"iostream.h"
#include"conio.h"
#include"graphics.h"
#include"dos.h"
#define SIZE 40

void display(int def_x, int def_y, int k)
{
int arrlight[10][20]={ 0,1,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,1,1,1,
0,1,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,1,1,1,
0,1,1,1,0,0,0,1,0,1,1,1,0,1,0,0,0,1,1,1,
0,1,1,1,0,0,0,1,0,1,1,1,0,0,0,1,0,1,1,1,
0,1,0,1,0,1,0,1,0,1,1,1,0,0,0,1,0,0,0,1,
0,1,1,1,0,1,0,0,0,1,1,1,0,0,0,1,0,1,1,1,
0,1,1,1,0,1,0,0,0,1,1,1,0,1,0,1,0,1,1,1,
0,1,1,1,0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,1,
0,1,1,1,0,1,0,1,0,1,1,1,0,1,0,1,0,1,1,1,
0,1,1,1,0,1,0,1,0,1,1,1,0,0,0,1,0,1,1,1};
int arrx1[SIZE],arrx2[SIZE],arry1[SIZE],arry2[SIZE];
int x=0,y=0,i=0,j=0,pos=0,l=0;
x=def_x; y=def_y;
for(i=0;i<5;i++)
{
for(j=0;j<4;j++)
{
arrx1[pos]=x; arry1[pos]=y;
arrx2[pos]=x+10; arry2[pos]=y+10;
pos++;
x=x+15;
}
x=def_x;
y=y+15;
}

for(l=0;l<20;l++)
{
setfillstyle(1,BLACK);
bar(arrx1[l],arry1[l],arrx2[l],arry2[l]);
}
for(l=0;l<20;l++)
{

if(arrlight[k][l]==1)
{ setfillstyle(1,GREEN); }
else
{ setfillstyle(1,BLACK);}
bar(arrx1[l],arry1[l],arrx2[l],arry2[l]);
}
}

void main()
{
clrscr();
int hr,min;
cout<<"\n Enter Hours to set alaram (0 - 23) :"; cin>>hr;
cout<<"\n Enter Minute to set alaram (0 - 59) :"; cin>>min;
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc\\bgi");
struct time t;
int mdgt,mudgt,mtdgt,hdgt,hudgt,htdgt,sdgt,sudgt,stdgt;
while(!kbhit())
{
gettime(&t);
sdgt=t.ti_sec; stdgt=t.ti_sec/10; sudgt=sdgt-(stdgt*10);
mdgt=t.ti_min; mtdgt=t.ti_min/10; mudgt=mdgt-(mtdgt*10);
hdgt=t.ti_hour; htdgt=t.ti_hour/10; hudgt=hdgt-(htdgt*10);
if((sdgt%2)==0)
{
display(100,200,htdgt); display(180,200,hudgt);
setfillstyle(1,BLACK);
bar(245,200,255,225);bar(245,250,255,275);
display(260,200,mtdgt); display(340,200,mudgt);
setfillstyle(1,BLACK);
bar(405,200,415,225);bar(405,250,415,275);
display(420,200,stdgt); display(500,200,sudgt);
}
else
{
display(100,200,htdgt); display(180,200,hudgt);
setfillstyle(1,GREEN);
bar(245,200,255,225);bar(245,250,255,275);
display(260,200,mtdgt); display(340,200,mudgt);
setfillstyle(1,GREEN);
bar(405,200,415,225);bar(405,250,415,275);
display(420,200,stdgt); display(500,200,sudgt);
}
if(t.ti_min==min && t.ti_hour==hr)
{
sound(300);
delay(500);
nosound();
}
delay(1000);
}
closegraph();
restorecrtmode();
cout<<"\nPress Any Key to exit!";
getch();
}
/*Coded and Compiled By: Sunil Rai (sunilplayer@gmail.com)*/
/*(c)Lateral Guys,2007*/

Sunil Rai...Project For C++ Library

/*Coded and Compiled By: Sunil Rai (sunilplayer@gmail.com)*/
/* 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<>b.rec_no;
cout<cout<cout<>ch;
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<cout<cout<}
else
{
cout<cout<}
break;
case 'R' :
if(b.flag=='C')
{
cout<cout<cout<cout<cout<cout<}
else
{
cout<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<>is_book;
file.seekg(0L, ios::beg);
while(file.read((char *)&b, sizeof(b)))
{
if(b.rec_no==is_book)
{
cout<cout<b.flag='C';
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<>is_book;
cout<file.seekg(0L, ios::beg);
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*/