Last active
August 11, 2016 12:25
-
-
Save rhoit/8751997 to your computer and use it in GitHub Desktop.
old programs! you need dosbox!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Title: Date Handler (Library Manager) | |
| Version: 4 | |
| Started: 10 Nov 2006 | |
| Revised: 1 | |
| Program Status: perfect | |
| */ | |
| struct Date {int dd, mm, yy;} c;//current date | |
| void Dfetch() //fetch current date | |
| { | |
| struct date t; | |
| getdate(&t); | |
| c.dd = t.da_day; | |
| c.mm = t.da_mon; | |
| c.yy = t.da_year; | |
| } | |
| void Future_D(Date &d, int days) | |
| { | |
| void MM(Date &,int &); | |
| while(days>365) | |
| { | |
| d.yy++; | |
| days-=365; | |
| if(d.yy%4==0) days--; | |
| } | |
| while(days>30) MM(d, days); | |
| d.dd+=days; | |
| if(d.dd>28) MM(d, d.dd); | |
| } | |
| void MM(Date &d,int &days) | |
| { | |
| if(d.mm==2) | |
| { | |
| d.mm++; | |
| days-=28; | |
| if(d.yy%4==0) days--; | |
| } | |
| else | |
| if((d.mm%2!=0 && d.mm<=7) || (d.mm%2==0 && d.mm>=8)) //months having 31 days | |
| { | |
| d.mm++; | |
| days-=31; | |
| } | |
| else | |
| { | |
| d.mm++; | |
| days-=30; | |
| } | |
| if(d.mm>12) | |
| { | |
| d.yy++; | |
| d.mm-=12; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Title: File handler (Library Manager) | |
| Version: 3 | |
| Started: 27 Nov 2006 | |
| Revised: 1 | |
| Program Status: Good | |
| */ | |
| class Hfile | |
| { | |
| int Get(); | |
| public: | |
| char name[9]; | |
| char caption[18]; | |
| char path[30]; | |
| char lpath[40]; //Library path | |
| char mpath[40]; //Member Database path | |
| char tpath[40]; //Transaction Databse path | |
| char tempp[40]; //Temp path | |
| int Create(); | |
| int Open(); | |
| }CO; | |
| int Hfile::Create() | |
| { | |
| cleardevice(); | |
| gotoxy(1,1); | |
| cout<<"\n\tNew Library\n\n"; | |
| t1=Get(); | |
| if(!t1) return 0; | |
| ofstream n; | |
| n.open(lpath, ios::noreplace | ios::binary); | |
| if(!n) | |
| { | |
| cout<<"\nWARNING\nA file exist with a same name\n" | |
| <<"Do you want to overwrite \"" | |
| <<name | |
| <<".LIB\" (Y/N): "; | |
| char ans; | |
| ans=getche(); | |
| if(ans=='y'|| ans=='Y') | |
| { | |
| //delting existing support files | |
| remove(mpath); | |
| remove(tpath); | |
| n.open(lpath, ios::binary); | |
| } | |
| cout<<endl; | |
| } | |
| if(!n) | |
| { | |
| cout<<"\nFail to create file"; | |
| getch(); | |
| return 0; | |
| } | |
| cout<<"\nFile successfully created"; | |
| n.close(); | |
| return 1; | |
| } | |
| int Hfile::Open() | |
| { | |
| cleardevice(); | |
| gotoxy(1,1); | |
| cout<<"\n\tLoad Library\n\n"; | |
| t1=Get(); | |
| if(!t1) return 0; | |
| ifstream o; | |
| o.open(lpath, ios::nocreate | ios::binary); | |
| if(!o) | |
| { | |
| cout<<"\nWARNING\nA file doesn't exist." | |
| <<"\n\nFail to load file"; | |
| getch(); | |
| return 0; | |
| } | |
| cout<<"\nFile successfully loaded"; | |
| o.close(); | |
| return 1; | |
| } | |
| int Hfile::Get() | |
| { | |
| printf("\ | |
| Directory Path: %s\n\ | |
| (Default: current directory)\n\n\ | |
| Press F4 to change Directory Path" | |
| ,arg); | |
| re: | |
| cout<<"\n\nLibrary Name (max 8 letters): "; | |
| switch(fetch(name,9)) | |
| { | |
| case 9: | |
| cout<<"Bad File Name\n"; | |
| getch(); | |
| case 27: return 0; | |
| case 62: | |
| cout<<"\nPath: "; | |
| switch(fetch(path,30)) | |
| { | |
| case 9: | |
| cout<<"\n\tBad File Name"; | |
| getch(); | |
| case 27: return 0; | |
| } | |
| strupr(path); | |
| goto re; | |
| }; | |
| strupr(name); | |
| strcpy(caption, name); | |
| strcat(caption, " LIBRARY"); | |
| strcpy(lpath, path); | |
| strcat(lpath, name); | |
| strcpy(mpath, lpath); | |
| strcpy(tpath, lpath); | |
| strcpy(tempp, lpath); | |
| strcat(lpath, ".LIB"); | |
| strcat(mpath, ".MDB"); | |
| strcat(tpath, ".TDB"); | |
| strcat(tempp, ".tmp"); | |
| return 1; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Title: Graphitizer (Library Manager) | |
| Version: Test mode | |
| Initiated: 19 Dec 2007 | |
| Last Update: 9 Feb 2009 | |
| Revised: 1 | |
| //getmax() give the constant val change it to constant | |
| */ | |
| int xco, yco; //store x & y cordinate value | |
| int temp, tflag=NULL ; | |
| int mx, my, button; //mouse cordinate & values | |
| int xm, ym; //stores max value of x & y cordinate which will always be same | |
| int RESPOND; //return value | |
| void help(); | |
| union REGS i, o; | |
| class Layout | |
| { | |
| protected: | |
| void Frame_cut(int, int, int, int, int, int, char); //Draw Frame Outline | |
| public: | |
| void inti_screen(); //set variable values | |
| }; | |
| class Builder:public Layout | |
| { | |
| protected: | |
| int item_c; //items contains | |
| char *items_n[]; //items name container | |
| char *cap; | |
| void Form_component(char); | |
| void Menubox(int); | |
| public: | |
| void Form(); | |
| void Menu(char *, char *[]); | |
| void Reload(); | |
| }; | |
| int CFP=0; //current Focus position | |
| class Access : public Builder | |
| { | |
| void Focus(int); | |
| void intimouse(); | |
| void mousefocus(int *); | |
| void showmouseptr(int); | |
| void putpointer(int, int); | |
| void getmousepos(); | |
| void Clickstroke(int *); | |
| void Keystroke(); | |
| void Trackmouse(); | |
| public: | |
| int devices(); | |
| }A; | |
| void Layout::inti_screen() | |
| { | |
| setbkcolor(1); | |
| setlinestyle(0,0,0); | |
| xm=getmaxx(); //can't use constructor | |
| ym=getmaxy(); | |
| } | |
| void Layout::Frame_cut(int c, int l, int t, int r, int b, int ra, char cut = 'n') | |
| { | |
| setcolor(c); | |
| switch(cut) | |
| { | |
| case 'n': //rectangle no cut | |
| ra=0; | |
| case 'r': //right digonally cut | |
| line(l, t, r-ra, t); //top horizontal | |
| line(l, t, l, b-ra); //left vertical | |
| arc(l+ra, b-ra, 180, 270, ra); //left bottom arc | |
| line(l+ra, b, r, b); //bottom horizontal | |
| line(r, t+ra, r, b); //right vertical | |
| arc(r-ra, t+ra, 0, 90, ra); //right top arc | |
| break; | |
| case 'l': //left diagonallu cut | |
| line(l+ra, t, r, t); //top horizontal | |
| line(l, t+ra, l, b); //left vertical | |
| arc(l+ra, t+ra, 90, 180, ra); //left top arc | |
| line(l, b, r-ra, b); //bottom horizontal | |
| line(r, t, r, b-ra); //right vertical | |
| arc(r-ra, b-ra, 270, 0, ra); //right bottom arc | |
| } | |
| } | |
| void Builder::Form() | |
| { | |
| cleardevice(); //clear the screen for new form | |
| //creating the platform | |
| Frame_cut(14, 20, 20, xm-20, ym-20, 40, 'l'); | |
| setfillstyle(2, 15); | |
| floodfill(1,1,14); //outside | |
| //creating Outlines | |
| line(60, 20, 60, ym-100); //left vertical | |
| line(100, ym-20, 100, ym-60); //left bottom vertical | |
| arc(100, ym-100, 180, 270, 40); //left bottom arc | |
| line(20, ym-100, 60, ym-100); //left bottom horizontal | |
| line(100, ym-60, xm-20, ym-60); //bottom horizontal | |
| //Loading text | |
| settextstyle(1,2,4); | |
| outtextxy(18,70, "My Manager 1.2"); | |
| settextstyle(2,0,4); | |
| outtextxy(110, ym-40, "Programed By rho"); | |
| setcolor(15); | |
| settextstyle(2,0,5); | |
| outtextxy(110, ym-55, "F1: Help | Esc: Return Back | Enter: Open Menu"); | |
| } | |
| void Builder::Form_component(char c) | |
| { | |
| switch(c) | |
| { | |
| case 't': //Form Title box | |
| setfillstyle(1,15); | |
| bar(70, 30, xm-30, 75); | |
| break; | |
| case 'f': //Menu Frame | |
| setcolor(1); | |
| setlinestyle(0,0,0); | |
| setfillstyle(9,9); | |
| pieslice(100, ym-100, 180, 270, 30); //left bottom pie | |
| bar(70, 75, xm-30, ym-100); | |
| bar(100, ym-100, xm-30, ym-70); | |
| break; | |
| } | |
| } | |
| void Builder::Menubox(int P) | |
| { | |
| yco=(P+2)*50; | |
| Frame_cut(15, 150, yco, xm-120, yco+30, 15, 'r'); | |
| circle(157, yco+7, 3); //push pin left | |
| circle(xm-127, yco+23, 3); //push pin right | |
| setfillstyle(1,15); | |
| floodfill(165, yco+10,15); | |
| setcolor(9); | |
| outtextxy((xm/2)-120, yco-1, items_n[P]); //center text | |
| } | |
| void Builder::Menu(char *caption, char *list[]) | |
| { | |
| //addtional | |
| inti_screen(); | |
| Form(); | |
| //Loading Menu Caption | |
| Form_component('t'); | |
| setcolor(6); | |
| settextstyle(1,0,4); | |
| cap=caption; | |
| outtextxy((xm-textwidth(caption))/2, 30, caption); //center text | |
| //Setting up Menu(items) | |
| Form_component('f'); | |
| settextstyle(1,0,3); | |
| for(item_c=0; list[item_c]!='\0'; item_c++) | |
| { | |
| items_n[item_c]=list[item_c]; //coping to class's variable | |
| Menubox(item_c); | |
| } | |
| item_c--; | |
| } | |
| void Builder::Reload() | |
| { | |
| setbkcolor(1); | |
| setlinestyle(0,0,0); | |
| Form(); | |
| //Loading Menu Caption | |
| Form_component('t'); | |
| setcolor(6); | |
| settextstyle(1,0,4); | |
| outtextxy((xm-textwidth(cap))/2, 30, cap); //center text | |
| //Setting up Menu(items) | |
| Form_component('f'); | |
| settextstyle(1,0,3); | |
| for(int i=0; i<=item_c; i++) Menubox(i); | |
| } | |
| void Access::Focus(int NFP=0) //NFP(New Focus Position) | |
| { | |
| //rotator | |
| if(NFP>item_c) NFP=0; | |
| else | |
| if(NFP<0) NFP=item_c; | |
| //defocus not to execute in 1st run | |
| if(NFP!=CFP) | |
| { | |
| yco=(CFP+2)*50; | |
| setfillstyle(9,9); | |
| bar(149, yco-1, xm-119, yco+31); //Eraseing Bitmap | |
| setlinestyle(0,0,0); | |
| Menubox(CFP); | |
| } | |
| //focusing Mode | |
| yco=(NFP+2)*50; | |
| setfillstyle(9,9); | |
| bar(150, yco, xm-120, yco+30); //Eraseing Bitmap | |
| setlinestyle(0,0,3); | |
| Frame_cut(15, 150, yco, xm-120, yco+30, 15, 'l'); | |
| circle(158, yco+22, 2); //push pin left | |
| circle(xm-127, yco+7, 2); //push pin right | |
| setfillstyle(1,9); | |
| floodfill(165, yco+10,15); | |
| setcolor(15); | |
| outtextxy((xm/2)-120, yco-1, items_n[NFP]); //center text | |
| CFP=NFP; //update CFP | |
| } | |
| void Access::intimouse() | |
| { | |
| //Initializes the mouse | |
| i.x.ax=0; | |
| int86(0x33,&i,&o); | |
| if(o.x.ax==0) | |
| { | |
| printf("\nMouse driver not loaded"); | |
| getch(); | |
| exit(1); | |
| } | |
| } | |
| void Access::showmouseptr(int m) | |
| { | |
| i.x.ax=m; | |
| int86(0x33,&i,&o); | |
| } | |
| void Access::getmousepos() | |
| { | |
| i.x.ax=3; | |
| int86(0x33,&i,&o); | |
| button=o.x.bx; | |
| mx=o.x.cx; | |
| my=o.x.dx; | |
| } | |
| void Access::putpointer(int x, int y) | |
| { | |
| i.x.ax=4; | |
| i.x.cx=x; | |
| i.x.dx=y; | |
| int86(0x33,&i,&o); | |
| } | |
| void Access::mousefocus(int *c) | |
| { | |
| if(CFP!=*c) | |
| { | |
| delay(DELAY_TIME); | |
| showmouseptr(2); | |
| Focus(*c); | |
| showmouseptr(1); | |
| } | |
| } | |
| void Access::Clickstroke(int *c) | |
| { | |
| if(button==1&&tflag!=1) //avoid repetation | |
| { | |
| temp=9; | |
| tflag=1; | |
| upbutton: | |
| showmouseptr(2); | |
| setlinestyle(0,0,3); | |
| Frame_cut(temp, 150, yco, xm-120, yco+30, 15, 'l'); | |
| showmouseptr(1); | |
| } | |
| else | |
| if(button!=1&&tflag==1) | |
| { | |
| temp=15; | |
| tflag=NULL; | |
| RESPOND=*c; | |
| goto upbutton; | |
| } | |
| } | |
| void Access::Trackmouse() | |
| { | |
| getmousepos(); | |
| if(mx>150&&mx<xm-120) | |
| { | |
| for(int c=0; c<=item_c; c++) | |
| { | |
| yco=(c+2)*50; | |
| if(my>yco&&my<yco+30) | |
| { | |
| mousefocus(&c); | |
| Clickstroke(&c); | |
| } | |
| } | |
| } | |
| } | |
| void Access::Keystroke() | |
| { | |
| if(kbhit()) //lovely lock | |
| { | |
| showmouseptr(2); | |
| cho=getch(); | |
| if(cho>='0' && cho<='9') RESPOND=cho-48; | |
| else switch(cho) //monitor key stroke | |
| { | |
| case 13: //Enter | |
| RESPOND=CFP; break; | |
| case 27: //Esc | |
| RESPOND=27; | |
| break; | |
| case 0: | |
| case 224: | |
| switch(getch()) | |
| { | |
| case 59: | |
| help(); | |
| Reload(); | |
| break; | |
| case 80: //Down arrow | |
| Focus(CFP+1); break; | |
| case 72: //Up arrow | |
| Focus(CFP-1); break; | |
| } | |
| } | |
| showmouseptr(1); | |
| } | |
| } | |
| int Access::devices() | |
| { | |
| RESPOND=-1; | |
| intimouse(); | |
| Focus(); //Place selector | |
| putpointer(xm/2+200, (0+2)*50+15); | |
| showmouseptr(1); | |
| while(RESPOND==-1) | |
| { | |
| Keystroke(); | |
| Trackmouse(); | |
| } | |
| showmouseptr(0); | |
| return RESPOND; | |
| } | |
| void help() | |
| { | |
| clrscr(); | |
| cout<<"Help\n\n\ | |
| Library Manager is the Small Program for Keep track \ | |
| of your books collection.\n\n\ | |
| Explorer! it It's easy to use.\n\ | |
| "; | |
| getch(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Title: Intro (Library Manager) | |
| Version: 2 | |
| Started: 25 Nov 2006 | |
| Last Update: 5 Feb 2009 | |
| Revised: 2 | |
| Program Status: Cool | |
| */ | |
| #define PIXEL_COUNT 3000 | |
| #define DELAY_TIME 100 //in milliseconds | |
| int gdriver=DETECT, gmode; | |
| void Splash() | |
| { | |
| int i, x, y, color, seed, | |
| maxx=getmaxx()+1, | |
| maxy=getmaxy()+1, | |
| maxcolor=getmaxcolor()+1; | |
| while(!kbhit()) | |
| { | |
| //seed the random number generator | |
| seed=random(32767); | |
| srand(seed); | |
| for(i=0; i<PIXEL_COUNT; i++) | |
| { | |
| x=random(maxx); | |
| y=random(maxy); | |
| color=random(maxcolor); | |
| putpixel(x, y, color); | |
| } | |
| delay(DELAY_TIME); | |
| srand(seed); | |
| for(i=0; i<PIXEL_COUNT; i++) | |
| { | |
| x=random(maxx); | |
| y=random(maxy); | |
| color=random(maxcolor); | |
| if(color==getpixel(x, y)) putpixel(x, y, 0); | |
| } | |
| setcolor(14); | |
| settextstyle(10,0,4); | |
| outtextxy(50, maxy/2-80, "LIBRARY MANAGER 1.2"); | |
| settextstyle(2,0,4); | |
| outtextxy(maxx-180, maxy-30, "Press any Key to Continue..."); | |
| setcolor(15); | |
| settextstyle(7,0,3);outtextxy(300, maxy/2, "By"); | |
| settextstyle(4,0,4); | |
| outtextxy(190, maxy/2+25, "rho"); | |
| settextstyle(3,0,2); | |
| settextstyle(4,0,3); | |
| outtextxy(285, maxy/2+25+35+60, "2009"); | |
| } | |
| getch(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Project Name: Library Manager | |
| Version: 1.2 | |
| Started: 12 Nov 2006 | |
| Last Update: 03 Feb 2009 | |
| Revised: 5 | |
| Program Status: Cool | |
| */ | |
| #include <fstream.h> | |
| #include <conio.h> | |
| #include <string.h> | |
| #include <stdio.h> | |
| #include <dos.h> | |
| #include <stdlib.h> | |
| #include <graphics.h> | |
| int t1, flag; | |
| char cho, t2[30], t3[30]; | |
| int fetch(char *, int); | |
| char *arg; | |
| //Including the Library Componets | |
| #include "Date_H.cpp" | |
| #include "Intro.cpp" | |
| #include "File_H.cpp" | |
| #include "Gtizer.cpp" | |
| #include "Library.cpp" | |
| #include "Member.cpp" | |
| #include "Transact.cpp" | |
| #include "Server.cpp" | |
| int main(int argc, char *argv[]) | |
| { | |
| arg=argv[0]; | |
| initgraph(&gdriver, &gmode, "bgi"); | |
| Splash(); | |
| S.Main(); | |
| closegraph(); | |
| restorecrtmode(); | |
| return 0; | |
| } | |
| int fetch(char *ch, int i) | |
| { | |
| int a=i; | |
| for(;;) | |
| { | |
| t1=getch(); | |
| if((t1>='A' && t1<='Z') || | |
| (t1>='a' && t1<='z') || | |
| (t1>='0' && t1<='9') || | |
| (t1==':') || (t1=='\\') | |
| ) | |
| { | |
| if(i==1) continue; | |
| cout<<(char)t1; | |
| *ch=t1; | |
| ch++; | |
| *ch='\0'; | |
| i--; | |
| } | |
| else switch(t1) | |
| { | |
| case 8: | |
| if(a==i) continue; | |
| printf("\b \b"); | |
| i++; | |
| ch--; | |
| *ch='\0'; | |
| break; | |
| case 13: return i; | |
| case 27: return 27; | |
| case 0: return getch(); | |
| }; | |
| } | |
| return 0; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Title: Library Manager (Library Manager) | |
| Version: Bug Mode | |
| Initiated: 12 Nov 2006 | |
| Last Update: 9 Feb 2009 | |
| Revised: 1 | |
| */ | |
| class Library | |
| { | |
| public: | |
| int bno; | |
| struct | |
| { | |
| char title[50]; | |
| char author[50]; | |
| int year; | |
| char publication[50]; | |
| float price; | |
| }Tag; | |
| Date d_add; //date added to library: Auto | |
| char Ab; //book aviliability | |
| int is_no; //no of times booked issued | |
| void Add(); | |
| void Modify(); | |
| void Del(); | |
| int Search(); | |
| void Display(); | |
| void Load(); | |
| void Show(char); | |
| void Update(); | |
| }B; | |
| fstream lib; | |
| int lf_state=1; //0: blank file | 1: smooth | |
| int bsize=sizeof(Library); | |
| void Library::Add() | |
| { | |
| clrscr(); | |
| lib.open(CO.lpath, ios::nocreate | ios::in | ios::out | ios::binary); | |
| if(lf_state==0) | |
| { | |
| cout<<"Opening Library\n"; | |
| bno=lf_state=1; | |
| } | |
| else | |
| if(lf_state==1) | |
| { | |
| cout<<"Adding to Library\n"; | |
| lib.seekg(-bsize, ios::end); | |
| lib.read((char *) & B, bsize); | |
| bno++; | |
| } | |
| cout<<"\nBno: "<<bno; | |
| cout<<"\nEnter Details\n\n"; | |
| cout<<"Title: "; gets(Tag.title); | |
| cout<<"Author: "; gets(Tag.author); | |
| cout<<"Year: "; cin>>Tag.year; | |
| cout<<"Publication: "; gets(Tag.publication); | |
| cout<<"Price: "; cin>>Tag.price; | |
| Ab = 'Y'; | |
| Dfetch(); //Get Current Date | |
| d_add=c; | |
| is_no=0; | |
| lib.write((char *) & B, bsize); | |
| lib.close(); | |
| cout<<"\nBook Successfully added"; | |
| getch(); | |
| } | |
| void Library::Modify() | |
| { | |
| clrscr(); | |
| if(lf_state==0) | |
| { | |
| cout<<"\n\tNo Books In Library !!!"; | |
| getch(); | |
| return; | |
| } | |
| cout<<"Modify Book Details\n\n"; | |
| re: | |
| cout<<"Search for book - Zero '0'\n" | |
| <<"Bno : "; | |
| cin>>t1; | |
| if(t1==0) | |
| { | |
| Search(); | |
| goto re; | |
| } | |
| lib.open(CO.lpath, ios::nocreate | ios::in | ios::out | ios::binary); | |
| lib.read((char *) & B, bsize); | |
| flag=0; | |
| while(!lib.eof()) | |
| { | |
| if(t1==bno) | |
| { | |
| flag=1; | |
| break; | |
| } | |
| else flag=0; | |
| lib.read((char *) & B, bsize); | |
| } | |
| if(flag==0) | |
| { | |
| cout<<"\nThe Bno "<<t1<<" doesn't exist !!!"; | |
| getch(); | |
| lib.close(); | |
| return; | |
| } | |
| clrscr(); | |
| Show('t'); | |
| Show('d'); | |
| cout<<"\nTo Modify info Press <Space>"; | |
| //Modify Staments | |
| cout<<"\nTitle: "<<Tag.title; | |
| if(getch()==32) | |
| { | |
| gotoxy(8, wherey()); clreol(); | |
| gets(Tag.title); | |
| gotoxy(1, wherey()-1); | |
| } | |
| cout<<"\nAuthor: "<<Tag.author; | |
| if(getch()==32) | |
| { | |
| gotoxy(9, wherey()); clreol(); | |
| gets(Tag.author); | |
| gotoxy(1, wherey()-1); | |
| } | |
| cout<<"\nYear: "<<Tag.year; | |
| if(getch()==32) | |
| { | |
| gotoxy(6, wherey()); clreol(); | |
| cin>>Tag.year; | |
| gotoxy(1, wherey()-1); | |
| } | |
| cout<<"\nPublication: "<<Tag.publication; | |
| if(getch()==32) | |
| { | |
| gotoxy(14, wherey()); clreol(); | |
| gets(Tag.publication); | |
| gotoxy(1, wherey()-1); | |
| } | |
| cout<<"\nPrice: "<<Tag.price; | |
| if(getch()==32) | |
| { | |
| gotoxy(8, wherey()); clreol(); | |
| cin>>Tag.price; | |
| gotoxy(1, wherey()-1); | |
| } | |
| lib.seekp(-bsize, ios::cur); | |
| lib.write((char *) & B, bsize); | |
| lib.close(); | |
| cout<<"\n\n"; | |
| Show('t'); | |
| Show('d'); | |
| cout<<"\n\nBook Detail Successfully Modified"; | |
| getch(); | |
| } | |
| void Library::Del() | |
| { | |
| clrscr(); | |
| if(lf_state==0) | |
| { | |
| cout<<"\n\tNo Books In Library !!!"; | |
| getch(); | |
| return; | |
| } | |
| cout<<"Remove Book\n\n"; | |
| re: | |
| cout<<"Search for book - Zero '0'\n" | |
| <<"Bno: "; | |
| cin>>t1; | |
| if(t1==0) | |
| { | |
| Search(); | |
| goto re; | |
| } | |
| lib.open(CO.lpath, ios::nocreate | ios::in | ios::out | ios::binary); | |
| lib.read((char *) & B, bsize); | |
| flag=0; | |
| while(!lib.eof()) | |
| { | |
| if(t1==bno) | |
| { | |
| flag=1; | |
| break; | |
| } | |
| else | |
| flag=0; | |
| lib.read((char *) & B, bsize); | |
| } | |
| if(flag==0) | |
| { | |
| cout<<"\nThe Bno "<<t1<<" doesn't exist !!!"; | |
| getch(); | |
| lib.close(); | |
| return; | |
| } | |
| Show('t'); | |
| Show('d'); | |
| cout<<"\nAre you sure you wan't to remove the book(Y/N): "; | |
| cho=getch(); | |
| cout<<cho; | |
| if(cho=='Y' || cho=='y') | |
| goto end; | |
| else | |
| { | |
| lib.close(); | |
| return; | |
| } | |
| end: | |
| ofstream out; | |
| out.open (CO.tempp, ios::binary); | |
| lib.seekg(0); | |
| lib.read((char *) & B, bsize); | |
| while(bno!=t1) | |
| { | |
| out.write((char *) & B, bsize); | |
| lib.read((char *) & B, bsize); | |
| } | |
| lib.read((char *) & B, bsize); | |
| while(!lib.eof()) | |
| { | |
| out.write((char *) & B, bsize); | |
| lib.read((char *) & B, bsize); | |
| } | |
| lib.close(); | |
| out.close(); | |
| remove(CO.lpath); | |
| rename(CO.tempp, CO.lpath); | |
| Load(); | |
| cout<<"\nBook Successfully Removed"; | |
| getch(); | |
| } | |
| int Library::Search() | |
| { | |
| if(lf_state==0) | |
| { | |
| cout<<"\n\tNo Books In Library !!!"; | |
| getch(); | |
| return 0; | |
| } | |
| cout<<"\nEnter Search Criteria\n" | |
| <<"\t1: Bno | 2: Title | 3: Author | 4: Publication | 5: Year\n"; | |
| lib.open (CO.lpath, ios::nocreate | ios::in | ios::binary); | |
| int i=0; //search review | |
| cho=getch(); | |
| switch(cho) | |
| { | |
| case '1': //Bno can't be jump coz entires might be deleted | |
| //Impovement might be binary search | |
| cout<<"Bno: "; cin>>t1; | |
| lib.read((char *) & B, bsize); | |
| flag=0; | |
| while(!lib.eof()) | |
| { | |
| if(t1==bno) | |
| { | |
| flag=1; | |
| break; | |
| } | |
| else flag=0; | |
| lib.read((char *) & B, bsize); | |
| } | |
| if(flag==0) | |
| { | |
| cout<<"\nThe Bno "<<t1<<" doesn't exist !!!"; | |
| getch(); | |
| lib.close(); | |
| return 0; | |
| } | |
| Show('t'); | |
| Show('d'); | |
| break; | |
| case '2': | |
| case '3': | |
| case '4': | |
| if(cho=='2') cout<<"Title: "; | |
| else if(cho=='3') cout<<"Author: "; | |
| else cout<<"Publication: "; | |
| gets(t2); | |
| strlwr(t2); | |
| Show('t'); | |
| lib.read((char *) & B, bsize); | |
| while(!lib.eof()) | |
| { | |
| if(cho=='2') strcpy(t3, Tag.title); | |
| else if(cho=='3') strcpy(t3, Tag.author); | |
| else strcpy(t3, Tag.publication); | |
| strlwr(t3); | |
| if(strcmp(t2,t3)==0) | |
| { | |
| Show('d'); | |
| i++; | |
| } | |
| lib.read((char *) & B, bsize); | |
| } | |
| printf("%d Entries Found\n\n", i); | |
| break; | |
| case '5': | |
| cout<<"Year: "; | |
| cin>>t1; | |
| Show('t'); | |
| lib.read((char *) & B, bsize); | |
| while(!lib.eof()) | |
| { | |
| if(t1==Tag.year) | |
| { | |
| Show('d'); | |
| i++; | |
| } | |
| lib.read((char *) & B, bsize); | |
| } | |
| printf("%d Entries Found\n\n", i); | |
| break; | |
| case 27: return 27; | |
| } | |
| lib.close(); | |
| } | |
| void Library::Display() | |
| { | |
| clrscr(); | |
| if(lf_state==0) | |
| { | |
| cout<<"\n\tNo Books In Library !!!"; | |
| getch(); | |
| return; | |
| } | |
| Show('t'); | |
| lib.open (CO.lpath, ios::nocreate | ios::in | ios::binary); | |
| lib.read((char *) & B, bsize); | |
| while(!lib.eof()) | |
| { | |
| Show('d'); | |
| lib.read((char *) & B, bsize); | |
| } | |
| lib.close(); | |
| getch(); | |
| } | |
| void Library::Load() | |
| { | |
| lib.open(CO.lpath, ios::nocreate | ios::in | ios::binary); | |
| lib.seekg(0, ios::end); | |
| if(lib.tellp()==0) //becoz file exists | |
| lf_state=0; | |
| lib.close(); | |
| } | |
| void Library::Show(char t) | |
| { | |
| if(t=='t') | |
| { | |
| printf("%s", "Bno"); | |
| printf("%c%*s", 179, -16, "Title"); | |
| printf("%c%*s", 179, -16, "Author"); | |
| printf("%c%*s", 179, -4, "Year"); | |
| printf("%c%*s", 179, -15, "Publication"); | |
| printf("%c%*s", 179, -6, "Price"); | |
| printf("%c%c", 179, 'S'); | |
| printf("%c%*s", 179, -3, "I#"); | |
| printf("%c%*s", 179, -8, "Reg.Date"); | |
| for(t1=0;t1< 3;t1++) cout<<(char)205; | |
| cout<<(char)216; for(t1=0;t1<16;t1++) cout<<(char)205; | |
| cout<<(char)216; for(t1=0;t1<16;t1++) cout<<(char)205; | |
| cout<<(char)216; for(t1=0;t1< 4;t1++) cout<<(char)205; | |
| cout<<(char)216; for(t1=0;t1<15;t1++) cout<<(char)205; | |
| cout<<(char)216; for(t1=0;t1< 6;t1++) cout<<(char)205; | |
| printf("%c%c", 216, 205); | |
| cout<<(char)216; for(t1=0;t1< 3;t1++) cout<<(char)205; | |
| cout<<(char)216; for(t1=0;t1< 8;t1++) cout<<(char)205; | |
| } | |
| else if(t=='d') | |
| { | |
| printf("%03d", bno); | |
| printf("%c%-16.16s", 179, Tag.title); | |
| printf("%c%-16.16s", 179, Tag.author); | |
| printf("%c%4d", 179, Tag.year); | |
| printf("%c%-15.15s", 179, Tag.publication); | |
| printf("%c%6.2f", 179, Tag.price); | |
| printf("%c%c", 179, Ab); | |
| printf("%c%3d", 179, is_no); | |
| printf("%c%02d%02d%04d", 179, d_add.dd, d_add.mm, d_add.yy); | |
| } | |
| } | |
| void Library::Update() | |
| { | |
| Load(); | |
| char* list[]= { | |
| "Register Book", | |
| "Modify Book Details", | |
| "Remove Book", | |
| "Search Book", | |
| "List Books", | |
| '\0' | |
| }; | |
| for(;;) | |
| { | |
| A.Menu("Manage Library", list); | |
| switch(A.devices()) | |
| { | |
| case 0: Add(); break; | |
| case 1: Modify(); break; | |
| case 2: Del(); break; | |
| case 3: | |
| clrscr(); | |
| cout<<"Book Search\n"; | |
| if(27!=Search()) getch(); | |
| break; | |
| case 4: Display(); break; | |
| case 27: | |
| case -1: return; //Esc | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Title: Member's Profile Manager (Library Manager) | |
| Version: 3 | |
| Initiated: 10 Nov 2006 | |
| Last Update: 9 Feb 2009 | |
| Revised: 7 | |
| Limits: | |
| 01 Reg_no max capacity 32767 | |
| 03 Scroll View not build | |
| */ | |
| class Member | |
| { | |
| public: | |
| int reg_no; //unique var | |
| char name[30], address[50], contact[11]; | |
| int duration; | |
| char iss; //issued book flag | |
| Date d_reg, d_exp; //structure's object | |
| void Renew(); | |
| void Add(); | |
| void Modify(); | |
| void Del(); | |
| void Search(); | |
| void Display(); | |
| void Load(); | |
| void Show(char); | |
| void MDB(); | |
| }P; | |
| fstream mem; | |
| int mf_state=1, //0: blank file | 1: smooth | |
| psize=sizeof(Member); | |
| void Member::Add() | |
| { | |
| clrscr(); | |
| mem.open(CO.mpath, ios::nocreate | ios::in | ios::out | ios::binary); | |
| if(mf_state==0) | |
| { | |
| cout<<"Creating Database\n"; | |
| reg_no=mf_state=1; | |
| } | |
| else | |
| if(mf_state==1) | |
| { | |
| cout<<"Adding to Database\n"; | |
| mem.seekg(-psize, ios::end); | |
| mem.read((char *) & P, psize); | |
| reg_no++; | |
| } | |
| cout<<"\nReg_no: "<<reg_no | |
| <<"\nEnter Details\n\n" | |
| <<"Name: "; gets(name); | |
| cout<<"Address: "; gets(address); | |
| cout<<"Contact no: "; gets(contact); | |
| cout<<"Membership period(in mm): "; cin>>duration; | |
| Dfetch(); //Get Current Date | |
| d_reg=d_exp=c; | |
| Future_D(d_exp, duration*30); | |
| iss='N'; | |
| mem.write((char *) & P, psize); | |
| mem.close(); | |
| cout<<"\nProfile Successfully added"; | |
| getch(); | |
| } | |
| void Member::Modify() | |
| { | |
| clrscr(); | |
| if(mf_state==0) | |
| { | |
| cout<<"\n\tNo Members Found !!!"; | |
| getch(); | |
| return; | |
| } | |
| cout<<"Modify Profile\n\n"; | |
| re: | |
| cout<<"Search for profile - Zero '0'\n" | |
| <<"Reg no: "; | |
| cin>>t1; | |
| if(t1==0) | |
| { | |
| Search(); | |
| goto re; | |
| } | |
| mem.open(CO.mpath, ios::nocreate | ios::in | ios::out | ios::binary); | |
| mem.read((char *) & P, psize); | |
| flag=0; | |
| while(!mem.eof()) | |
| { | |
| if(t1==reg_no) | |
| { | |
| flag=1; | |
| break; | |
| } | |
| else flag=0; | |
| mem.read((char *) & P, psize); | |
| } | |
| if(flag==0) | |
| { | |
| cout<<"\nThe Reg no "<<t1<<" doesn't exist !!!"; | |
| getch(); | |
| mem.close(); | |
| return; | |
| } | |
| Show('t'); | |
| Show('d'); | |
| cout<<"\nTo Modify info Press 'Space'"; | |
| //Modify Staments | |
| cout<<"\nName: "<<name; | |
| cho=getch(); | |
| if(cho==32) | |
| { | |
| gotoxy(7, wherey()); clreol(); | |
| gets(name); | |
| gotoxy(1, wherey()-1); | |
| } | |
| cout<<"\nAddress: "<<address; | |
| cho=getch(); | |
| if(cho==32) | |
| { | |
| gotoxy(10, wherey()); clreol(); | |
| gets(address); | |
| gotoxy(1, wherey()-1); | |
| } | |
| cout<<"\nContact no: "<<contact; | |
| cho=getch(); | |
| if(cho==32) | |
| { | |
| gotoxy(13, wherey()); clreol(); | |
| gets(contact); | |
| gotoxy(1, wherey()-1); | |
| } | |
| mem.seekp(-psize, ios::cur); | |
| mem.write((char *) & P, psize); | |
| mem.close(); | |
| cout<<"\n\n"; | |
| Show('t'); | |
| Show('d'); | |
| cout<<"\n\nProfile Successfully Modified"; | |
| getch(); | |
| } | |
| void Member::Renew() | |
| { | |
| clrscr(); | |
| if(mf_state==0) | |
| { | |
| cout<<"\n\tNo Members Found !!!"; | |
| getch(); | |
| return; | |
| } | |
| cout<<"Renew Profile\n\n"; | |
| re: | |
| cout<<"Search for profile - Zero '0'\n" | |
| <<"Reg no: "; | |
| cin>>t1; | |
| if(t1==0) | |
| { | |
| Search(); | |
| goto re; | |
| } | |
| mem.open(CO.mpath, ios::nocreate | ios::in | ios::out | ios::binary); | |
| mem.read((char *) & P, psize); | |
| flag=0; | |
| while(!mem.eof()) | |
| { | |
| if(t1==reg_no) | |
| { | |
| flag=1; | |
| break; | |
| } | |
| else | |
| flag=0; | |
| mem.read((char *) & P, psize); | |
| } | |
| if(flag==0) | |
| { | |
| cout<<"\nThe Reg no "<<t1<<" doesn't exist !!!"; | |
| getch(); | |
| mem.close(); | |
| return; | |
| } | |
| Show('t'); | |
| Show('d'); | |
| Dfetch(); //Get Current Date | |
| if(c.yy>d_exp.yy) flag=0; | |
| else | |
| if(c.yy==d_exp.yy) | |
| { | |
| if(c.mm>d_exp.mm) flag=0; | |
| else | |
| if(c.mm==d_exp.mm) | |
| if(c.dd>=d_exp.dd) flag=0; | |
| } | |
| if(flag==1) | |
| { | |
| cout<<"\nThe membership period hasn't expired !!!" | |
| <<"\nDo you want to extend period (Y/N): "; | |
| cho=getch(); | |
| cout<<cho; | |
| if(cho=='Y'||cho=='y') | |
| { | |
| cout<<"\nAdditional period(in mm): "; cin>>t1; | |
| duration += t1; | |
| Future_D(d_exp, t1*30); | |
| goto ext; | |
| } | |
| mem.close(); | |
| return; | |
| } | |
| d_exp=c; | |
| cout<<"\nMembership period(in mm): "; cin>>duration; | |
| Future_D(d_exp, duration*30); | |
| ext: | |
| mem.seekp(-psize, ios::cur); | |
| mem.write((char *) & P, psize); | |
| mem.close(); | |
| Show('t'); | |
| Show('d'); | |
| cout<<"\nProfile Successfully Renewed"; | |
| getch(); | |
| } | |
| void Member::Del() | |
| { | |
| clrscr(); | |
| if(mf_state==0) | |
| { | |
| cout<<"\n\tNo Members Found !!!"; | |
| getch(); | |
| return; | |
| } | |
| cout<<"Remove Profile\n\n"; | |
| re: | |
| cout<<"Search for profile - Zero '0'\n" | |
| <<"Reg no: "; | |
| cin>>t1; | |
| if(t1==0) | |
| { | |
| Search(); | |
| goto re; | |
| } | |
| mem.open(CO.mpath, ios::nocreate | ios::in | ios::out | ios::binary); | |
| mem.read((char *) & P, psize); | |
| flag=0; | |
| while(!mem.eof()) | |
| { | |
| if(t1==reg_no) | |
| { | |
| flag=1; | |
| break; | |
| } | |
| else | |
| flag=0; | |
| mem.read((char *) & P, psize); | |
| } | |
| if(flag==0) | |
| { | |
| cout<<"\nThe Reg no "<<t1<<" doesn't exist !!!"; | |
| getch(); | |
| mem.close(); | |
| return; | |
| } | |
| Show('t'); | |
| Show('d'); | |
| if(iss=='Y') | |
| { | |
| cout<<"\nThe Reg no "<<t1<<" can't be deleted !!!" | |
| <<"\n\t \""<<name<<"\" has got Library's Books !!!"; | |
| getch(); | |
| mem.close(); | |
| return; | |
| } | |
| cout<<"\nAre you sure you wan't to remove the profile(Y/N): "; | |
| cho=getch(); | |
| cout<<cho; | |
| if(cho=='Y' || cho=='y') | |
| goto end; | |
| else | |
| { | |
| mem.close(); | |
| return; | |
| } | |
| end: | |
| ofstream out; | |
| out.open (CO.tempp, ios::binary); | |
| mem.seekg(0); | |
| mem.read((char *) & P, psize); | |
| while(reg_no!=t1) | |
| { | |
| out.write((char *) & P, psize); | |
| mem.read((char *) & P, psize); | |
| } | |
| mem.read((char *) & P, psize); | |
| while(!mem.eof()) | |
| { | |
| out.write((char *) & P, psize); | |
| mem.read((char *) & P, psize); | |
| } | |
| mem.close(); | |
| out.close(); | |
| remove(CO.mpath); | |
| rename(CO.tempp, CO.mpath); | |
| Load(); | |
| cout<<"\nProfile Successfully Removed"; | |
| getch(); | |
| } | |
| void Member::Search() | |
| { | |
| if(mf_state==0) | |
| { | |
| cout<<"\n\tNo Members Found !!!"; | |
| getch(); | |
| return; | |
| } | |
| cout<<"\nEnter Search Criteria\n" | |
| <<"\t1: Reg no | 2: Name | 3: Address | 4: Contact\n"; | |
| mem.open (CO.mpath, ios::nocreate | ios::in | ios::binary); | |
| cho=getch(); | |
| switch(cho) | |
| { | |
| case '1': | |
| cout<<"Reg no: "; cin>>t1; | |
| mem.read((char *) & P, psize); | |
| flag=0; | |
| while(!mem.eof()) | |
| { | |
| if(t1==reg_no) | |
| { | |
| flag=1; | |
| break; | |
| } | |
| else flag=0; | |
| mem.read((char *) & P, psize); | |
| } | |
| if(flag==0) | |
| { | |
| cout<<"\nThe Reg no "<<t1<<" doesn't exist !!!"; | |
| getch(); | |
| mem.close(); | |
| return; | |
| } | |
| Show('t'); | |
| Show('d'); | |
| break; | |
| case '2': | |
| case '3': | |
| case '4': | |
| if(cho=='2') cout<<"Name: "; | |
| else if(cho=='3') cout<<"Address: "; | |
| else cout<<"Contact no: "; | |
| int i=0; //search review | |
| gets(t2); | |
| strlwr(t2); | |
| Show('t'); | |
| mem.read((char *) & P, psize); | |
| while(!mem.eof()) | |
| { | |
| if(cho=='2') strcpy(t3, name); | |
| else if(cho=='3') strcpy(t3, address); | |
| else strcpy(t3, contact); | |
| strlwr(t3); | |
| if(strcmp(t2,t3)==0) | |
| { | |
| Show('d'); | |
| i++; | |
| } | |
| mem.read((char *) & P, psize); | |
| } | |
| cout<<"\nSearch Result: "<<i<<" Found\n\n"; | |
| break; | |
| case 27: return; | |
| } | |
| mem.close(); | |
| } | |
| void Member::Display() | |
| { | |
| clrscr(); | |
| if(mf_state==0) | |
| { | |
| cout<<"\n\tNo Members Found !!!"; | |
| getch(); | |
| return; | |
| } | |
| Show('t'); | |
| mem.open (CO.mpath, ios::nocreate | ios::in | ios::binary); | |
| mem.read((char *) & P, psize); | |
| while(!mem.eof()) | |
| { | |
| Show('d'); | |
| mem.read((char *) & P, psize); | |
| } | |
| mem.close(); | |
| getch(); | |
| } | |
| void Member::Load() | |
| { | |
| mem.open(CO.mpath, ios::nocreate | ios::in | ios::binary); | |
| if(!mem) //can't find file | |
| { | |
| cleardevice(); | |
| cout<<"\n\tNo File Found !!!"; | |
| mem.open(CO.mpath, ios::in | ios::out | ios::binary); | |
| cout<<"\n\tCreating New File !!!"; | |
| } | |
| mem.seekg(0, ios::end); | |
| if(mem.tellp()==0) //if file exists | |
| { | |
| cleardevice(); | |
| cout<<"\n\tNo Data in File !!!"; | |
| mf_state=0; | |
| getch(); | |
| } | |
| mem.close(); | |
| } | |
| void Member::Show(char t) | |
| { | |
| if(t=='t') | |
| { | |
| printf("%s", "Re#"); | |
| printf("%c%*s", 179, -20, "Name"); | |
| printf("%c%*s", 179, -30, "Address"); | |
| printf("%c%*s", 179, -11, "Contact"); | |
| printf("%c%c", 179, 'I'); | |
| printf("%c%*s", 179, -10, "Valid Till"); | |
| for(t1=0;t1< 3;t1++) cout<< |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Title: Server (Library Manager) | |
| Version: Bug Mode | |
| Initiated: 12 Nov 2006 | |
| Last Update: 9 Feb 2009 | |
| Revised: 5 | |
| */ | |
| class Server //Menu Creator and Interface | |
| { | |
| public: | |
| void Main(); //Main Menu | |
| void Operate(); | |
| void Credits(); | |
| }S; | |
| void Server::Main() | |
| { | |
| char* list[]= { | |
| "Load Library", | |
| "New Library", | |
| "Credits", | |
| "Exit", | |
| '\0' | |
| }; | |
| for(;;) | |
| { | |
| A.Menu("Main Menu", list); | |
| switch(A.devices()) | |
| { | |
| case 0: | |
| if(CO.Open()) Operate(); | |
| break; | |
| case 1: | |
| t1=CO.Create(); | |
| if(t1==1) Operate(); | |
| break; | |
| case 2: | |
| cleardevice(); | |
| Credits(); | |
| break; | |
| case 27: | |
| case 3: | |
| return; | |
| } | |
| } | |
| } | |
| void Server::Operate() | |
| { | |
| char* list[]= { | |
| "Transaction", | |
| "Manage Library", | |
| "Member Database", | |
| "Quick Status", | |
| '\0' | |
| }; | |
| for(;;) | |
| { | |
| A.Menu(CO.caption, list); | |
| switch(A.devices()) | |
| { | |
| case 0: R.Transact(); break; | |
| case 1: B.Update(); break; | |
| case 2: P.MDB(); break; | |
| case 3: | |
| cleardevice(); | |
| gotoxy(1,1); | |
| cout<<"Library Status\n\n"; | |
| lib.open(CO.lpath, ios::nocreate | ios::in | ios::binary); | |
| lib.seekg(0, ios::end); | |
| t1=lib.tellp()/bsize; | |
| lib.close(); | |
| cout<<"\tTotal Books:\t"<<t1; | |
| rec.open(CO.tpath, ios::nocreate | ios::in | ios::binary); | |
| rec.seekg(0, ios::end); | |
| flag=rec.tellp()/rsize; | |
| rec.close(); | |
| cout<<"\n\t\tBooks in:\t"<<t1-flag; | |
| cout<<"\n\t\tBooks out:\t"<<flag; | |
| mem.open(CO.mpath, ios::nocreate | ios::in | ios::binary); | |
| mem.seekg(0, ios::end); | |
| t1=mem.tellp()/psize; | |
| mem.close(); | |
| cout<<"\n\tTotal Members:\t"<<t1; | |
| getch(); | |
| break; | |
| case 27: return; | |
| } | |
| } | |
| } | |
| void Server::Credits() | |
| { | |
| gotoxy(1,25); | |
| cout<<"\n\ | |
| Credits\n\ | |
| =======\n\n\ | |
| Project Initiated:\n\ | |
| 10 Oct 2006\n\n\ | |
| Version:\n\ | |
| Partial Graphics ver 1.2\n\ | |
| Built 6\n\ | |
| 8 Feb 2009\n\n\ | |
| Author\n\ | |
| Rohit Man Amatya\n\n\n\n\ | |
| Press Any Key Continue...\n\n\n\n\n\n\n\n\n\n"; | |
| getch(); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Title: Library Transaction (Library Manager) | |
| Version: 2 | |
| Initiated: 10 Nov 2006 | |
| Last Update: 9 Feb 2009 | |
| Revised: 2 | |
| */ | |
| class Transaction | |
| { | |
| int sno, bno; | |
| char title[30]; | |
| int reg_no; | |
| char name[30], contact[11]; | |
| Date d_iss; //issue date | |
| Date d_due; //due date | |
| public: | |
| void Issue(); | |
| void Ret(); | |
| void Display(); | |
| void Show(char); | |
| int Load(); | |
| void Transact(); | |
| }R; | |
| fstream rec; | |
| int rf_state=1; //0: blank file | 1: smooth | |
| int rsize=sizeof(Transaction); | |
| void Transaction::Issue() | |
| { | |
| clrscr(); | |
| cout<<"Book Issue\n\n"; | |
| cout<<"Member's Reg no: "; | |
| cin>>t1; | |
| //cheaking for valid members | |
| mem.open(CO.mpath, ios::nocreate | ios::in | ios::out | ios::binary); | |
| mem.read((char *) & P, psize); | |
| flag=0; | |
| while(!mem.eof()) | |
| { | |
| if(t1==P.reg_no) | |
| { | |
| flag=1; | |
| break; | |
| } | |
| else flag=0; | |
| mem.read((char *) & P, psize); | |
| } | |
| if(flag==0) | |
| { | |
| cout<<"\nThe Reg no "<<t1<<" doesn't exist !!!"; | |
| getch(); | |
| mem.close(); | |
| return; | |
| } | |
| P.Show('t'); | |
| P.Show('d'); | |
| //scanning members records | |
| if(P.iss=='Y') | |
| { | |
| cout<<"\n\nSorry \""<<P.name<<"\" can't issue book !!!" | |
| <<"\n\tOnly one book can be issue at once !!!"; | |
| getch(); | |
| mem.close(); | |
| return; | |
| } | |
| cout<<"\nBno: "; | |
| cin>>t1; | |
| //cheaking for valid books | |
| lib.open(CO.lpath, ios::nocreate | ios::in | ios::out | ios::binary); | |
| lib.read((char *) & B, bsize); | |
| flag=0; | |
| while(!lib.eof()) | |
| { | |
| if(t1==B.bno) | |
| { | |
| flag=1; | |
| break; | |
| } | |
| else flag=0; | |
| lib.read((char *) & B, bsize); | |
| } | |
| if(flag==0) | |
| { | |
| cout<<"\nThe Bno "<<t1<<" doesn't exist !!!"; | |
| getch(); | |
| mem.close(); | |
| lib.close(); | |
| return; | |
| } | |
| B.Show('t'); | |
| B.Show('d'); | |
| //scanning book status | |
| if(B.Ab=='N') //checking book in library | |
| { | |
| cout<<"\n\nSorry Bno "<<t1<<" is not in library now !!!"; | |
| getch(); | |
| lib.close(); | |
| mem.close(); | |
| return; | |
| } | |
| //updating the book and member records | |
| B.Ab='N'; | |
| B.is_no++; //no of times booked issued | |
| lib.seekg(-bsize, ios::cur); | |
| lib.write((char *) & B, bsize); | |
| lib.close(); | |
| P.iss='Y'; | |
| mem.seekg(-psize, ios::cur); | |
| mem.write((char *) & P, psize); | |
| mem.close(); | |
| //updating records | |
| rec.open(CO.tpath, ios::nocreate | ios::in | ios::out | ios::binary); | |
| if(rf_state==0) | |
| { | |
| cout<<"\n\nCreating Transaction Record\n"; | |
| sno=rf_state=1; | |
| } | |
| else | |
| if(rf_state==1) | |
| { | |
| cout<<"\n\nAdding to Transaction Record\n"; | |
| rec.seekg(-rsize, ios::end); | |
| rec.read((char *) & R, rsize); | |
| sno++; | |
| } | |
| cout<<"\Sno: "<<sno<<endl; | |
| bno=B.bno; | |
| strcpy(title, B.Tag.title); | |
| reg_no=P.reg_no; | |
| strcpy(name, P.name); | |
| strcpy(contact, P.contact); | |
| Dfetch(); //Get Current Date | |
| d_iss=d_due=c; //Update date | |
| Future_D(d_due, 7); | |
| rec.write((char *) & R, rsize); | |
| rec.close(); | |
| cout<<"\nBook Successfully Issued"; | |
| getch(); | |
| } | |
| void Transaction::Ret() | |
| { | |
| clrscr(); | |
| if(rf_state==0) | |
| { | |
| cout<<"\n\tNo Records Found !!!"; | |
| getch(); | |
| return; | |
| } | |
| cout<<"Book Return\n\n"; | |
| cout<<"Member's Reg no: "; | |
| cin>>t1; | |
| //cheaking for valid members | |
| mem.open(CO.mpath, ios::nocreate | ios::in | ios::out | ios::binary); | |
| mem.read((char *) & P, psize); | |
| flag=0; | |
| while(!mem.eof()) | |
| { | |
| if(t1==P.reg_no) | |
| { | |
| flag=1; | |
| break; | |
| } | |
| else flag=0; | |
| mem.read((char *) & P, psize); | |
| } | |
| if(flag==0) | |
| { | |
| cout<<"\nThe Reg no "<<t1<<" doesn't exist !!!"; | |
| getch(); | |
| mem.close(); | |
| return; | |
| } | |
| //search member in record list | |
| rec.open(CO.tpath, ios::nocreate | ios::in | ios::out | ios::binary); | |
| rec.read((char *) & R, rsize); | |
| flag=0; | |
| while(!rec.eof()) | |
| { | |
| if(t1==reg_no) | |
| { | |
| flag=1; | |
| break; | |
| } | |
| else | |
| flag=0; | |
| rec.read((char *) & R, rsize); | |
| } | |
| if(flag==0) | |
| { | |
| cout<<"\nNo present transaction with Reg no "<<t1<<" !!!"; | |
| getch(); | |
| rec.close(); | |
| mem.close(); | |
| return; | |
| } | |
| Show('t'); | |
| Show('d'); | |
| //serch for books in list | |
| lib.open(CO.lpath, ios::nocreate | ios::in | ios::out | ios::binary); | |
| lib.read((char *) & B, bsize); | |
| flag=0; | |
| while(!lib.eof()) | |
| { | |
| if(t1==bno) | |
| { | |
| flag=1; | |
| break; | |
| } | |
| else flag=0; | |
| lib.read((char *) & B, bsize); | |
| } | |
| //updating the book and member records | |
| B.Ab='Y'; | |
| lib.seekg(-bsize, ios::cur); | |
| lib.write((char *) & B, bsize); | |
| lib.close(); | |
| P.iss='N'; | |
| mem.seekg(-psize, ios::cur); | |
| mem.write((char *) & P, psize); | |
| mem.close(); | |
| //removing form transaction record | |
| ofstream out; | |
| out.open (CO.tempp, ios::binary); | |
| rec.seekg(0); | |
| rec.read((char *) & R, rsize); | |
| while(reg_no!=t1) | |
| { | |
| out.write((char *) & R, rsize); | |
| rec.read((char *) & R, rsize); | |
| } | |
| rec.read((char *) & R, rsize); | |
| while(!rec.eof()) | |
| { | |
| sno--; | |
| out.write((char *) & R, rsize); | |
| rec.read((char *) & R, rsize); | |
| } | |
| mem.close(); | |
| out.close(); | |
| remove(CO.tpath); | |
| rename(CO.tempp, CO.tpath); | |
| if(sno==1) rf_state=0; | |
| cout<<"\nBook Successfully Retreved"; | |
| getch(); | |
| } | |
| void Transaction::Display() | |
| { | |
| clrscr(); | |
| if(rf_state==0) | |
| { | |
| cout<<"\n\tNo Records Found !!!"; | |
| getch(); | |
| return; | |
| } | |
| Show('t'); | |
| rec.open (CO.tpath, ios::nocreate | ios::in | ios::binary); | |
| rec.read((char *) & R, rsize); | |
| while(!rec.eof()) | |
| { | |
| Show('d'); | |
| rec.read((char *) & R, rsize); | |
| } | |
| rec.close(); | |
| getch(); | |
| } | |
| int Transaction::Load() | |
| { | |
| clrscr(); | |
| //scanning support files | |
| mem.open(CO.mpath, ios::nocreate | ios::in | ios::binary); | |
| if(!mem) | |
| { | |
| cout<<"\n\t\""<<CO.name<<".MDB\" not Found !!!"; | |
| mem.close(); | |
| getch(); | |
| return 0; | |
| } | |
| mem.seekg(0, ios::end); | |
| if(mem.tellp()==0) //if file exists | |
| { | |
| cout<<"\n\tNo Members Found !!!"; | |
| mem.close(); | |
| getch(); | |
| return 0; | |
| } | |
| mem.close(); | |
| lib.open(CO.lpath, ios::nocreate | ios::in | ios::binary); | |
| lib.seekg(0, ios::end); | |
| if(lib.tellp()==0) //if file always exist | |
| { | |
| cout<<"\n\tNo Books In Library !!!"; | |
| lib.close(); | |
| mem.close(); | |
| getch(); | |
| return 0; | |
| } | |
| lib.close(); | |
| rec.open(CO.tpath, ios::in | ios::out | ios::binary); | |
| rec.seekg(0, ios::end); | |
| if(rec.tellp()==0) | |
| rf_state=0; | |
| rec.close(); | |
| return 1; | |
| } | |
| void Transaction::Show(char t) | |
| { | |
| if(t=='t') | |
| { | |
| printf("%s", "Bno"); | |
| printf("%c%*s", 179, -19, "Title"); | |
| printf("%c%s", 179, "Rno"); | |
| printf("%c%*s", 179, -18, "Name"); | |
| printf("%c%*s", 179, -11, "Contact"); | |
| printf("%c%*s", 179, -10, "Iss.Date"); | |
| printf("%c%*s", 179, -10, "Due.Date"); | |
| for(t1=0;t1< 3;t1++) cout<<(char)205; | |
| cout<<(char)216; for(t1=0;t1<19;t1++) cout<<(char)205; | |
| cout<<(char)216; for(t1=0;t1< 3;t1++) cout<<(char)205; | |
| cout<<(char)216; for(t1=0;t1<18;t1++) cout<<(char)205; | |
| cout<<(char)216; for(t1=0;t1<11;t1++) cout<<(char)205; | |
| cout<<(char)216; for(t1=0;t1<10;t1++) cout<<(char)205; | |
| cout<<(char)216; for(t1=0;t1<10;t1++) cout<<(char)205; | |
| } | |
| else if(t=='d') | |
| { | |
| printf("%03d", bno); | |
| printf("%c%-19.19s", 179, title); | |
| printf("%c%03d", 179, reg_no); | |
| printf("%c%-18.18s", 179, name); | |
| printf("%c%11s", 179, contact); | |
| printf("%c%02d|%02d|%04d", 179, d_iss.dd, d_iss.mm, d_iss.yy); | |
| printf("%c%02d|%02d|%04d", 179, d_due.dd, d_due.mm, d_due.yy); | |
| } | |
| } | |
| void Transaction::Transact() | |
| { | |
| if(Load()==0) return; | |
| char* list[]= { | |
| "Book Issue", | |
| "Book Return", | |
| "View", | |
| '\0' | |
| }; | |
| for(;;) | |
| { | |
| A.Menu("Library Transaction", list); | |
| switch(A.devices()) | |
| { | |
| case 0: Issue(); break; | |
| case 1: Ret(); break; | |
| case 2: Display(); break; | |
| case 27: return; //Esc | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
