C++ Gas Agency Project
C++ Gas Agency Project
#include<stdio.h>
#include<conio.h> #include<graphics.h> #include<iostream.h> #include<fstream.h> #include<dos.h> #include<stdlib.h> #include<string.h> void func(); void pass(); void gra(); void cpass(); void select(); class addition { private : char name1[40],fname[40],address[500],category[20], city[15],zone[30],cat2[20],acc_no[30]; char telp_no[20],mitt_no[10],due_date[20]; /*long double curr_read,pre_read,use_unit,due_amount,ele_tax; long double late_charge,fix_charge,y,amount; */ long double fix_charge,ele_tax; long gross,total_amount; struct date prev_del; struct date curr_date; public : void get_data(); void newb(); void bill(); void search(); void edit(); void remove(); void vw(); void view(); void dat1(); void condition(); }add; void addition::dat1() { struct date d; getdate(&d); int k=d.da_day,l=d.da_mon,n=d.da_year; int x=0,y=0,z=0; if((n%4)==0) { if(l==2) { if(k<=24) { x=k+5;y=l;z=n; } else { x=k-24;y=l+1;z=n;} } else { if(l==4|l==6|l==9|l==11) { if(k<=25) {x=k+5;y=l;z=n;} else {x=k-25;y=l+1;z=n;} } else { if(k<=26) {x=k+5;y=l;z=n;} else { if(l==12) {l=0;x=k-25;y=l+1;z=n+1;} else {x=k-26;y=l+1;z=n;} } } } } else { if(l==2) { if(k<=23) {x=k+5;y=l;z=n;} else {x=k-23;y=l+1;z=n;} } else { if(l==4|l==6|l==9|l==11) { if(k<=25) {x=k+5;y=l;z=n;} else {x=k-25;y=l+1;z=n;} } else { if(k<=26) {x=k+5;y=l;z=n;} else { if(l==12) {l=0;x=k-25;y=l+1;z=n+1;} else {x=k-26;y=l+1;z=n;} } } } } // cout<<"delivery Date"; gotoxy(25,23); cout<<x<<"/"<<y<<"/"<<z; } void addition::vw() { fstream fill1; int z=0; h: { gotoxy(15,1); cout<<"Press 'TAB' To Exit and Press 'SPACE' To Go Back"; gotoxy(20,5); cout<<"\t Enter Account No. : "; while(z<20) { char c2=getch(); if(c2==13) { if(z==0); else break; } if(c2=='\t') { exit(0); } if(c2==' ') { func(); } if(c2=='\b') { if(z>0) { z=z-1; gotoxy(45+z,5); cout<<" "; gotoxy(45+z,5); } } else { if(c2>=48&&c2<=57) { cout<<c2; acc_no[z]=c2; z++; } else { cout<<"\n \t \t \t Invalid Entry"; cout<<"\n \t \t \t Press Any key To Enter Again"; z=0; getch(); cleardevice(); goto h; } } } acc_no[z]='\0'; } fill1.open(acc_no,ios::nocreate|ios::in); if(fill1!='\0') { fill1.read((char *) & add,sizeof(add)); cleardevice(); line(0,20,639,20); line(0,0,639,0); line(0,460,639,460); settextstyle(1,1,2); line(0,0,0,479); line(639,0,639,479); settextstyle(7,0,2); gotoxy(15,4); cout<<"Name : "<<name1<<" s/o "<<fname; gotoxy(15,19); cout<<"Account No : "<<acc_no; gotoxy(15,7); cout<<"Address : "<<address; gotoxy(15,13); cout<<"Zone : "<<zone; gotoxy(15,10); cout<<"City : "<<city; gotoxy(15,16); cout<<"Telephone No : "<<telp_no; gotoxy(15,22); cout<<"Connection No : "<<mitt_no; gotoxy(15,25); cout<<"Connection Type : "<<category; } else { cout<<"\n\n\n\t\tAccount Does Not Exist "; p: { cout<<"\n \t \tPress 'y' To Go Back or Press 'n' To Enter Again"; int ch=getch(); if(ch=='y') { func(); } else { if(ch=='n') { cleardevice(); search(); } else { cout<<"\n \t \tInvalid Entry"; getch(); cleardevice(); goto p; } } } } } void addition::view() { int gd=DETECT,gm; struct date d; getdate(&d); int a=d.da_day,b=d.da_mon,c=d.da_year; initgraph(&gd,&gm,"c:\\tc\\bgi"); setbkcolor(1); setcolor(4); line(0,20,639,20); line(0,90,639,90); line(0,135,639,135); line(0,165,639,165); line(0,195,639,195); line(0,230,639,230); line(0,343,639,343); line(310,260,639,260); line(0,0,639,0); line(0,430,639,430); settextstyle(1,1,2); line(0,0,0,430); line(639,0,639,430); line(500,90,500,260); line(500,310,500,380); line(160,90,160,430); settextstyle(3,0,1); outtextxy(200,1,"INDANE GAS AGENCY"); gotoxy(70,1); cout<<a<<"/"<<b<<"/"<<c; gotoxy(5,3); cout<<"Name : "<<name1<<" s/o "<<fname; gotoxy(60,3); cout<<"Acc. No : "<<acc_no; gotoxy(5,5); cout<<"Address : "<<address; gotoxy(5,10); cout<<"Zone"; gotoxy(25,10); cout<<zone; gotoxy(5,8); cout<<"City"; gotoxy(25,8); cout<<city; gotoxy(5,12); cout<<"Telephone No"; gotoxy(25,12); cout<<telp_no; gotoxy(5,14); cout<<"Connection No"; gotoxy(25,14); cout<<mitt_no; gotoxy(5,16); cout<<"Connection Type"; gotoxy(25,16); cout<<category; /* gotoxy(5,19); cout<<"Supply Voltage"; gotoxy(25,19); cout<<"230 V"; */ settextstyle(1,1,2); line(310,90,310,430); gotoxy(5,21); cout<<"Booking date"; gotoxy(25,21); // cout<<pre_read; cout<<a<<"/"<<b<<"/"<<c; // cout<<curr_date.da_day<<"/"<<curr_date.da_mon<<"/"<<curr_date.da_year; gotoxy(5,23); cout<<"Delivary date"; gotoxy(25,23); dat1(); // cout<<curr_date.da_date<<"/"<<curr_date.da_mon<<"/"<<curr_date.da_year // gotoxy(5,25); /* cout<<"Total Units"; gotoxy(25,25); // cout<<use_unit; gotoxy(45,8); cout<<"Unit Charge"; gotoxy(67,8); cout<<amount; */ gotoxy(45,10); cout<<"Fixed Charge"; gotoxy(67,10); cout<<fix_charge; gotoxy(45,12); cout<<"service Tax"; gotoxy(67,12); cout<<ele_tax; /* gotoxy(45,14); cout<<"Due Amount"; gotoxy(67,14); cout<<due_amount; gotoxy(45,16); cout<<"Late Charge"; gotoxy(67,16); cout<<late_charge; */ gotoxy(45,18); cout<<"Total Amount"; gotoxy(67,18); cout<<total_amount<<".00"<<" only "; // gotoxy(45,19); //cout<<"(2 months)"; gotoxy(45,23); dat1(); gotoxy(45,21); cout<<"Isssuing Date"; gotoxy(67,21); cout<<a<<"/"<<b<<"/"<<c; /* gotoxy(45,25); cout<<"Late Amount"; gotoxy(67,25); cout<<gross<<".00"; */ line(0,310,639,310); line(0,280,310,280); line(0,380,639,380); settextstyle(1,0,1); outtextxy(50,440,"Press Any Key To Go Back To 'MAIN MENU '"); } void addition::get_data() { int y=0; char cat[]="industrial"; char cat2[]="domestic"; fstream fill1; int i=0,z=0; h: { gotoxy(20,5); cout<<"\t Enter Account No. : "; while(z<20) { char c2=getch(); if(c2==13) { if(z==0); else break; } if(c2=='\b') { if(z>0) { z=z-1; gotoxy(53+z,5); cout<<" "; gotoxy(53+z,5); } } else { if(c2>=48&&c2<=57) { cout<<c2; acc_no[z]=c2; z++; } else { cout<<"\n \t \t \t Invalid Entry"; cout<<"\n \t \t \t Press Any key To Enter Again"; z=0; getch(); cleardevice(); goto h; } } } acc_no[z]='\0'; } fill1.open(acc_no,ios::nocreate|ios::in); if(fill1!='\0') { cout<<"\n\t\t\t Account Already Exists"; s: { cout<<"\n\t\t\t press 'y' to go back press 'n' to enter again\n"; char c1=getch(); if(c1=='y') { func(); } else { if(c1=='n') { cleardevice(); get_data(); } else { cout<<"\n\t\t\tInvalid Entry"; goto s; } } } } else { fill1.close(); fill1.open(acc_no,ios::app); char c1; cout<<"\n \n \t \t \t Enter Name : "; gets(name1); cout<<"\n \t \t \t Enter Fathers Name :"; gets(fname); cout<<"\n \t \t \t Enter Address : "; gets(address); cout<<"\n \t \t \t Enter City Name : "; gets(city); cout<<"\n \t \t \t Enter Zone Name : "; gets(zone); prev_del.da_day=0; prev_del.da_mon=0; prev_del.da_year=0; getdate(&curr_date); o: { cout<<"\n \t \t \t Enter Telephone No : "; while(1) { char c=getch(); if(c=='\b') { i=0; continue; } if(c==13) { if(i>9) break; else { cout<<"\n\t\t\t Invalid Telephone No."; cout<<"\n\n\t\t\t Press Any Key To Enter Again"; i=0; getch(); goto o; } } if(c>=48&&c<=57) { cout<<c; telp_no[i]=c; i++; } else { cout<<"\n\t\t\t Invalid Entry"; cout<<"\n\n\t\t\t Press Any Key To Enter Again"; i=0; getch(); goto o; } } telp_no[i]='\0'; } int j=0; n: { cout<<"\n \n \t \t \t Enter Connection No. : "; while(j<20) { char c1=getch(); if(c1==13) { if(j==0); else break; } else { if(c1>=48&&c1<=57) { cout<<c1; mitt_no[j]=c1; j++; } else { cout<<"\n \t \t \t Invalid Entry"; cout<<"\n \t \t \t Press Any Key To Enter Again"; j=0; getch(); goto n; } } } mitt_no[j]='\0'; } cout<<"\n \n \t \t \t Enter Category : "; gets(category); int f=1; do { f=1; y=strcmp(category,cat2); int z=strcmp(category,cat); if(y==0); else if(z==0); else { f=0; cout<<"\t\t\t Enter Either domestic or commercial\n\n"; cout<<"\t\t\t Enter Category : "; gets(category); } }while(f==0); clrscr(); fill1.write((char *) & add,sizeof add) ; fill1.close(); } } void addition::newb() { fstream fout; char ch,x; int z=0; h: { gotoxy(15,1); cout<<"Press 'TAB' To Exit and Press 'SPACE' To Go Back"; gotoxy(20,5); cout<<"\t Enter Account No. : "; while(z<20) { char c2=getch(); if(c2=='\t') { exit(0); } if(c2==' ') { func(); } if(c2==13) { if(z==0); else break; } if(c2=='\b') { if(z>0) { z=z-1; gotoxy(46+z,5); cout<<" "; gotoxy(46+z,5); } } else { if(c2>=48&&c2<=57) { cout<<c2; acc_no[z]=c2; z++; } else { z=0; cleardevice(); goto h; } } } acc_no[z]='\0'; cout<<endl; } fout.open(acc_no,ios::nocreate|ios::in); if(fout!='\0') { fout.read((char*) &add,sizeof(add)); bill(); fout.close(); fstream f; prev_del=curr_date; getdate(&curr_date); f.open(acc_no,ios::trunc|ios::app); f.write((char*) &add,sizeof add); f.close(); } else { cout<<"\n\t\t\t Account Does Not Exist\n"; cout<<"\t\t\t Press Any Key To Go Back"; getch(); cleardevice(); newb(); } } void addition::bill() { fstream f; char cat[]="industrial"; char cat2[]="domestic"; int p=strcmp(category,cat2); int n=strcmp(category,cat); f.read((char*) &add,sizeof add); if(curr_date.da_year-prev_del.da_year==0) { if(curr_date.da_mon-prev_del.da_mon>1) { if(p==0) total_amount=320; else total_amount=520; } } else { prev_del=curr_date; if(p==0) total_amount=320; else total_amount=520; getdate(&curr_date); } /* cout<<" \n \t \t \t Enter Previous delivary date: "; cin>>pre_read; c: { cout<<"\n \t \t \t Enter Current Reading : "; cin>>curr_read; if(curr_read<pre_read) { cout<<"\t \t \t Current Reading Cant Be Less Then Previous"; goto c; } } cout<<"\n \t \t \t Enter The Due Amount : "; cin>>due_amount; use_unit=0; use_unit=curr_read-pre_read; if(p==0) { */ if(p==0) { fix_charge=285.71; ele_tax=34.29; } else { fix_charge=464.28; ele_tax=55.72; // amount=use_unit*(3.50); } /* } else { if(n==0) { if(use_unit<=100) { fix_charge=160; amount=use_unit*(4.50); } else { fix_charge=250; amount=use_unit*(4.90); } } } ele_tax=use_unit*(0.40); total_amount=fix_charge+amount+ele_tax+due_amount; late_charge=total_amount*(0.04); gross=total_amount+late_charge; */ f.write((char *) &add,sizeof add); f.close(); } void addition::search() { fstream fin; int z=0; h: { gotoxy(15,1); cout<<"Press 'TAB' To Exit and Press 'SPACE' To Go Back"; gotoxy(20,5); cout<<"\t\tEnter Account No. : "; while(z<20) { char c2=getch(); if(c2=='\t') { exit(0); } if(c2==' ') { func(); } if(c2==13) { if(z==0); else break; } if(c2=='\b') { if(z>0) { z=z-1; gotoxy(53+z,5); cout<<" "; gotoxy(53+z,5); } } else { if(c2>=48&&c2<=57) { cout<<c2; acc_no[z]=c2; z++; } else { cout<<"Invalid Entry"; z=0; getch(); cleardevice(); goto h; } } } acc_no[z]='\0'; } cleardevice(); fin.open(acc_no,ios::nocreate|ios::in); if(fin!='\0') { fin.read((char *) & add,sizeof(add)); view(); } else { cout<<"\n\n\n\t\tAccount Does Not Exist "; p: { cout<<"\n \t \tPress 'y' To Go Back or Press 'n' To Enter Again"; int ch=getch(); if(ch=='y') { func(); } else { if(ch=='n') { cleardevice(); search(); } else { cout<<"\n \t \tInvalid Entry"; getch(); cleardevice(); goto p; } } } } } void addition::edit() { fstream fout; char ch,x; int z=0; h: { gotoxy(15,1); cout<<"Press 'TAB' To Exit and Press 'SPACE' To Go Back"; gotoxy(20,5); cout<<"\t\tEnter Account No. : "; while(z<20) { char c2=getch(); if(c2=='\t') { exit(0); } if(c2==' ') { func(); } if(c2==13) { if(z==0); else break; } if(c2=='\b') { if(z>0) { z=z-1; gotoxy(53+z,5); cout<<" "; gotoxy(53+z,5); } } else { if(c2>=48&&c2<=57) { cout<<c2; acc_no[z]=c2; z++; } else { z=0; cleardevice(); goto h; } } } acc_no[z]='\0'; } fout.open(acc_no,ios::in|ios::nocreate); if(fout!='\0') { fout.read((char*) &add,sizeof(add)); fout.close(); fstream f; f.open(acc_no,ios::trunc|ios::app); a: { cleardevice(); gotoxy(20,2); cout<<"\t\t Press 'TAB' To Exit"; gotoxy(20,8); cout<<"\t\t1 Name"<<endl; gotoxy(20,10); cout<<"\t\t2 Fathes Name"<<endl; gotoxy(20,12); cout<<"\t\t3 City"<<endl; gotoxy(20,14); cout<<"\t\t4 Zone"<<endl; gotoxy(20,16); cout<<"\t\t5 Address"<<endl; gotoxy(20,18); cout<<"\t\t6 Telephone No"<<endl; gotoxy(20,20); cout<<"\t\tENTER YOUR CHOICE:"; x=getche(); if(ch=='\t') { exit(0); } if(x==49) { cleardevice(); gotoxy(20,10); cout<<"\n\t\t\t\tEnter New Name : "; gets(name1); } if(x==50) { cleardevice(); gotoxy(20,10); cout<<"\n\t\t\t\tEnter fathers name :"; gets(fname); } if(x==51) { cleardevice(); gotoxy(20,10); cout<<"\n\t\t\t\tEnter New City : "; gets(city); } if(x==52) { cleardevice(); gotoxy(20,10); cout<<"\n\t\t\t\tEnter New Zone : "; gets(zone); } if(x==53) { cleardevice(); gotoxy(20,10); cout<<"\n\t\t\t\tEnter New Address : "; gets(address); } if(x==54) { int i=0; o: { cleardevice(); gotoxy(20,10); cout<<"\n\t\t\t\tEnter New Telephone No : "; while(1) { char c=getch(); if(c=='\b') { i=0; continue; } if(c==13) { if(i>9) break; else { cout<<"\n\t\t\t\tInvalid Telephone No."; cout<<"\n\n\t\t\t\tPress Any Key To Enter Again"; getch(); goto o; } } if(c>=48&&c<=57) { cout<<c; telp_no[i]=c; i++; } else { cout<<"\n\t\t\t\tInvalid Entry"; cout<<"\n\n\t\t\t\tPress Any Key To Enter Again"; i=0; getch(); goto o; } } telp_no[i]='\0'; } } if(x>54) { cout<<"\n\t\t\t\tInvalid Option"; } cout<<"\n\t\t\t\tDo You Want To Edit More ? (y/any key):"; ch=getch(); cout<<ch; if(ch=='\t') { exit(0); } if(ch=='y') { goto a; } } f.write((char*) &add,sizeof(add)); } else { cout<<"\n\t\t\t Account Does Not Exist\n"; cout<<"\t\t\t Press Any Key To Go Back"; getch(); cleardevice(); edit(); } } void addition::remove() { int z=0; gotoxy(20,5); h: { gotoxy(15,1); cout<<"Press 'TAB' To Exit and Press 'SPACE' To Go Back"; gotoxy(20,5); acc_no[0]='\0'; cout<<"\t\tEnter Account No. : "; while(z<20) { char c2=getch(); if(c2=='\t') { exit(0); } if(c2==' ') { func(); } if(c2==13) { if(z==0); else break; } if(c2=='\b') { if(z>0) { z=z-1; gotoxy(53+z,5); cout<<" "; gotoxy(53+z,5); } } else { if(c2>=48&&c2<=57) { cout<<c2; acc_no[z]=c2; z++; } else { cout<<"Invalid Entry"; z=0; getch(); cleardevice(); goto h; } } } acc_no[z]='\0'; } fstream f; f.open(acc_no,ios::nocreate|ios::in); if(f=='\0') { cout<<"\n \t \tAccount Does Not Exist "; t: { cout<<"\n \t \tPress 'y' To Go Back or Press 'n' To Enter Again"; int ch=getch(); if(ch=='y') { func(); } else { if(ch=='n') { cleardevice(); remove(); } else { cout<<"\n \t \tInvalid Entry"; goto t; } } } } else { unlink(acc_no); cout<<"\n \t \t \tAccount No "<<acc_no<<" Is Deleted"; s: { cout<<"\n \t \t \tDO YOU WANT TO DELETE MORE (y/n):"; int ch2=getch(); if(ch2=='y') { cleardevice(); remove(); } else { if(ch2=='n') { func(); } else { cout<<"\n \t \tInvalid Entry"; goto s; } } } } } void addition::condition() { /* line(10,10,610,10); line(10,40,610,40); line(10,90,610,90); line(10,150,610,150); line(10,200,610,200); line(10,230,610,230); line(10,280,610,280); line(10,330,610,330); line(10,380,610,380); line(10,410,610,410); settextstyle(2,1,3); line(10,10,10,410); line(610,10,610,410); gotoxy(30,2); cout<<" CONDITIONS"; gotoxy(5,4); cout<<"1 Nigam will not be responsible if the bill is paid to any "<<endl; gotoxy(5,5); cout<<" unauthorised person."<<endl; gotoxy(5,7); cout<<"2 In condition of any controversy reagarding bill the full amount"<<endl; gotoxy(5,8); cout<<" have to be submited and the amount will be adjusted in the "<<endl; gotoxy(5,9); cout<<" next bill if required."<<endl; gotoxy(5,11); cout<<"3 In condition of not paying the bill before last date 2% of total "<<endl; gotoxy(5,12); cout<<" bill permonth will be applied as late charge." <<endl; gotoxy(5,14); cout<<"4 Total 4% of units will be applied as electric tax."<<endl; gotoxy(5,16); cout<<"5 If the last date of paying bill is a national holiday then the "<<endl; gotoxy(5,17); cout<<" next working day will be considered as last date."<<endl; gotoxy(5,19); cout<<"6 Please check the security amount.If any problem then Contact "<<endl; gotoxy(5,20); cout<<" the A.E.N."<<endl; gotoxy(5,22); cout<<"7 While correspondens with electricity distribution nigam do write "<<endl; gotoxy(5,23); cout<<" the account no."<<endl; gotoxy(5,25); cout<<"8 Your suggetions are priceless for us."; gotoxy(10,26); settextstyle(1,0,1); outtextxy(50,430,"Press Any Key To Go Back To 'MAIN MENU '"); } */ } void main() { clrscr(); select(); getch(); } void gra() { int gd=DETECT,gm,i,x,y; initgraph(&gd,&gm,"c:\\tc\\bgi"); setbkcolor(5); setcolor(14); int choice; settextstyle(1,0,4); outtextxy(230,50,"INDANE"); line(145,115,485,115); outtextxy(200,140,"GAS AGENCY"); line(90,205,565,205); setcolor(11); settextstyle(1,0,1); outtextxy(10,300,"Sumbited To :- Mr. Jitender Rathi"); setcolor(15); settextstyle(7,0,1); outtextxy(346,330,"Sumbited By :- SHARAD KUMAR"); outtextxy(475,350,":- NEHA TIWARI"); outtextxy(475,370,":- PRIYANKA SHEKHAWAT"); outtextxy(475,390,":- NITISH KUMAR"); setcolor(10); outtextxy(5,385,"Loading...."); setcolor(3); line(0,417,637,417); line(0,438,637,438); for(i=0;i<637;i++) { delay(3); rectangle(0+i,420,2+i,435); } clrscr(); initgraph(&gd,&gm,"c:\\tc\\bgi"); setbkcolor(13); setcolor(4); settextstyle(3,0,4); outtextxy(210,70,"WEL COME"); settextstyle(1,0,5); setcolor(4); outtextxy(110,250,"INDANE"); outtextxy(290,250,"GAS AGENCY"); settextstyle(1,0,3); setcolor(7); outtextxy(50,10,"****************************"); outtextxy(340,10,"****************************"); outtextxy(50,180,"****************************"); outtextxy(340,180,"***************************"); outtextxy(110,420,"####################################"); settextstyle(1,1,3); outtextxy(585,20,"*****************"); outtextxy(25,20,"*****************"); for(i=0;i<637;i++) { delay(3); } func(); } void func() { cleardevice(); int gd=DETECT,gm,a; char choice; initgraph(&gd,&gm,"c:\\tc\\bgi"); do { setbkcolor(9); setcolor(9); cleardevice(); settextstyle(2,0,7); gotoxy(15,3); cout<<"------------------------MAIN MENU------------------------"; gotoxy(20,7); cout<<"1 Add New Connection "; gotoxy(20,9); cout<<"2 BOOKING"; gotoxy(20,11); cout<<"3 Search Account"; gotoxy(20,13); cout<<"4 View Bill "; gotoxy(20,15); cout<<"5 Edit Connection"; gotoxy(20,17); cout<<"6 Delete Connection"; gotoxy(20,19); cout<<"7 View Conditions"; gotoxy(20,21); cout<<"8 Exit System"; gotoxy(20,23); cout<<"Enter Your Choice (1-8) "; choice=getche(); a=choice; if(a<49||a>56) { gotoxy(20,24); cout<<"Enter Choice Only Between 1 and 8"; gotoxy(20,25); cout<<"Press Any Key To Enter Again"; getch(); func(); } else { switch(a) { case 49: initgraph(&gd,&gm,"c:\\tc\\bgi"); setbkcolor(12); setcolor(6); add.get_data(); cleardevice(); break; case 50: initgraph(&gd,&gm,"c:\\tc\\bgi"); setbkcolor(1); setcolor(6); add.newb(); break; case 51: initgraph(&gd,&gm,"c:\\tc\\bgi"); setbkcolor(5); setcolor(6); add.vw(); getch(); break; case 52: initgraph(&gd,&gm,"c:\\tc\\bgi"); setbkcolor(9); setcolor(6); add.search(); getch(); break; case 53: clrscr(); initgraph(&gd,&gm,"c:\\tc\\bgi"); setbkcolor(12); setcolor(6); add.edit(); getch(); break; case 54: initgraph(&gd,&gm,"c:\\tc\\bgi"); setbkcolor(1); setcolor(6); add.remove(); getch(); break; case 55: initgraph(&gd,&gm,"c:\\tc\\bgi"); setbkcolor(5); setcolor(4); add.condition(); getch(); break; case 56: exit(0); } } }while(1); } void select() { int gd=DETECT,gm; initgraph(&gd,&gm,"c:\\tc\\bgi"); setbkcolor(1); setcolor(7); char ch; gotoxy(20,1); cout<<"Press 'TAB' To Exit"; gotoxy(20,5); cout<<"\n\n\n\t\t\t1.Enter The Password:"<<endl; cout<<"\n\t\t\t2.Change The Password:"<<endl; cout<<"\n\t\t\tEnter Your Choice(1 or 2):"; ch=getch(); if(ch=='\t') { exit(0); } if(ch==49) { pass(); } else { if(ch==50) { cpass(); } else { cout<<"\n\t\t\tEnter Only 1 or 2"; cout<<"\n\t\t\tPress Any Key To Enter Again"; getch(); select(); } } } void pass() { int gd=DETECT,gm; initgraph(&gd,&gm,"c:\\tc\\bgi"); setbkcolor(1); setcolor(14); fstream fout; int y=0,x=0,z=0; char line[20],ch,ch1,pas[20]; fout.open("pass.txt",ios::in); fout.seekg(0); while(!fout.eof()) { ch1=fout.get(); pas[z]=ch1; z++; } pas[z-1]='\0'; gotoxy(20,27); cout<<" Press 'SPACE' To Go To Main Menu and Press 'TAB' To Exit"; gotoxy(20,7); cout<<"Enter The Password :"; while(x<30) { ch=getch(); if(ch==13) { break; } else { if(ch==' ') { cleardevice(); select(); } if(ch=='\t') { exit(0); } if(ch=='\b') { if(x>0) { x=x-1; gotoxy(40+x,7); cout<<" "; gotoxy(40+x,7); } } else { cout<<"*"; line[x]=ch; x++; } } } line[x]='\0'; y=strcmp(pas,line); if(y==0) { gra(); } else { cout<<"\n \t\t\tWrong Password"<<endl; cout<<"\n \t\t\tPress Any Key To Enter Again"; getch(); pass(); } } void cpass() { int gd=DETECT,gm; initgraph(&gd,&gm,"c:\\tc\\bgi"); setbkcolor(5); setcolor(3); fstream fout; int y,x=0,p=0,t=0; char pas[20],ch2,ch3,ch4,line2[20],line1[20]; fout.open("pass.txt",ios::in); fout.seekg(0); while(!fout.eof()) { ch2=fout.get(); pas[p]=ch2; p++; } pas[p-1]='\0'; gotoxy(10,1); cout<<" Press 'SPACE' To Go To Main Menu and Press 'TAB' To Exit"; gotoxy(20,8); cout<<"Enter The Old Password :"; while(x<30) { ch3=getch(); if(ch3==13) { break; } else { if(ch3==' ') { cleardevice(); select(); } if(ch3=='\t') { exit(0); } if(ch3=='\b') { if(x>0) { x--; gotoxy(43+x+1,8); cout<<" "; gotoxy(43+x+1,8); } } else { cout<<"*"; line2[x]=ch3; x++; } } } line2[x]='\0'; y=strcmp(pas,line2); if(y==0) { gotoxy(20,10); cout<<"Enter The New Password :"; while(t<30) { ch4=getch(); if(ch4==13) { break; } else { if(ch4==' ') { cleardevice(); select(); } if(ch4=='\t') { exit(0); } if(ch4=='\b') { if(t>0) { t--; gotoxy(43+t+1,10); cout<<" "; gotoxy(43+t+1,10); } } else { line1[t]=ch4; cout<<"*"; t++; } } } line1[t]='\0'; fout.close(); fstream fin; fin.open("pass.txt",ios::out); fin.seekp(0); fin<<line1; fin.close(); pass(); } else { cout<<"\n\t\t Password Does Not Match"; cout<<"\n\t\t Press Any Key To Enter Again"; getch(); cpass(); } } |
Click to Link
Click On Source Code
|