Anda di halaman 1dari 14

#include <stdio.

h>
#include <string.h>
#include <dos.h>
#include <conio.h>
#include <graphics.h>
#define SIZE 100
#define MAX 100
#define cls clrscr
void save(void), load(void), list(void);
int x=7, y=9;
int num=0,s=0,test,guard=0;
int ctr,j, k;
char sik[10];
struct bills
{
char code[10];
char name[35];
int present;
int previous;
float bill;
char status[10];
}record[SIZE];
int main()
{ clrscr();
int gd=DETECT,gm;
initgraph(&gd,&gm,"..\\bgi");
setbkcolor(6);
settextstyle(1,HORIZ_DIR,5);
outtext("K,E.R.A.L.A.State Electricity Board");
for(int b=0;b<=750;b++)
{setcolor(9);
circle(300,280,26);
circle(300,280,25);
circle(300,280,24);
circle(300,280,23);
circle(300,280,22);
circle(300,280,21);
setcolor(5);
arc(300,280,45-b,90-b,24);
arc(300,280,45-b,90-b,23);
setcolor(9);
circle(270,280,26);
circle(270,280,25);
circle(270,280,24);
circle(270,280,23);
circle(270,280,22);
circle(270,280,21);
setcolor(5);
arc(270,280,45-b,90-b,24);
arc(270,280,45-b,90-b,23);
setcolor(9);
circle(330,280,26);
circle(330,280,25);
circle(330,280,24);
circle(330,280,23);
circle(330,280,22);
circle(330,280,21);
setcolor(5);

arc(330,280,45-b,90-b,24);
arc(330,280,45-b,90-b,23);
setcolor(9);
circle(360,280,26);
circle(360,280,25);
circle(360,280,24);
circle(360,280,23);
circle(360,280,22);
circle(360,280,21);
setcolor(5);
arc(360,280,45-b,90-b,24);
arc(360,280,45-b,90-b,23);
setcolor(9);
circle(240,280,26);
circle(240,280,25);
circle(240,280,24);
circle(240,280,23);
circle(240,280,22);
circle(240,280,21);
setcolor(5);
arc(240,280,45-b,90-b,24);
arc(240,280,45-b,90-b,23);
delay(10);
}
int kwh;
char ans;
char* pass;
char user[10];
float sop, fxdr, vat, oth;
register int i=0;
int choice=0,num=0,guard=0;
closegraph();
gotoxy(22,7);
printf("Electricity Bill Record Maintaining System");
gotoxy(35,19);
printf(" Notification ");
for(int j=1;j<=3;j++)
{
if(j==3)
{
gotoxy(32,23);
printf("Checking files");printf("\a");
gotoxy(46,23);
printf(".");
sleep(1);
gotoxy(47,23);printf(".");
sleep(1);
gotoxy(48,23);printf(".");
sleep(1);
}
if(j==2)
{
gotoxy(32,22);
printf("Checking folders");printf("\a");

gotoxy(48,22);
printf(".");
sleep(1);
gotoxy(49,22);
printf(".");
sleep(1);
gotoxy(50,22);
printf(".");
sleep(1);
}
if(j==1)
{gotoxy(32,21);
printf("Loading System");printf("\a");
gotoxy(46,21);printf(".");
sleep(1);
gotoxy(47,21);
printf(".");
sleep(1);
gotoxy(48,21);
printf(".");
sleep(1);
}
}
gotoxy(28,24);
printf("Press Any Key To Continue");
getch();
int r=1;
do
{
r++;
clrscr();
gotoxy(22,7);
printf("Electricity Bill Record Maintaining System");
gotoxy(32,14);
printf("Username: ______");
gotoxy(32,15);
printf("Password: ****");
gotoxy(35,19);
printf(" Notification ");

gotoxy(42,14);
scanf("%s",user);
gotoxy(42,15);
pass=getpass("****");

if(strcmp(user,"anjitha")==0 && strcmp(pass,"kseb")==0)


{
gotoxy(32,21);
printf("Loading to Menu...\n");
gotoxy(32,22);
printf("Loaded succesfully\n");

gotoxy(28,24);
printf("Press any key to continue");
getch();
goto xy;
}
else
{ gotoxy(22,21);
printf("The username and password did not match!");
gotoxy(22,22);
printf("Press any key to continue");
getch();
}
}while(r<=100);

xy:
ctr=1;
load();
guard=ctr;
do
{
clrscr();
int gd=DETECT,gm;
initgraph(&gd,&gm,"..\\bgi");

setbkcolor(6);
gotoxy(19,2);printf("Electricity Bill Record Maintaining System");
gotoxy(34,4);
printf(" MAIN MENU ");
gotoxy(22,6);
printf("[1] Add Detail");
gotoxy(22,8);
printf("[2] Edit Detail");
gotoxy(22,10);
printf("[3] Delete Record");
gotoxy(22,12);
printf("[4] View One");
gotoxy(22,14);
printf("[5] View All");
gotoxy(22,16);
printf("[6] Cash Collection");
gotoxy(22,18);
printf("[7] List of Defaulters");
gotoxy(22,20);
printf("[8] List of Paid Customers");
gotoxy(22,22);
printf("[0] EXIT");
gotoxy(22,24);
printf("Choose an option(1,2,3,4,5,6,7,8,0): ");
scanf("%d",&choice);
closegraph();
switch(choice)

{
case 1:
{
num=i;
guard++;
clrscr();
gotoxy(19,4);printf("Electricity Bill Record Maintaining System");
gotoxy(22,7);printf(" Add Record ");
gotoxy(23,9);
printf("Code:");
gotoxy(23,11);
printf("Customer's Name:");
gotoxy(23,13);
printf("Present Reading:");
gotoxy(23,15);
printf("Previous Reading:");
gotoxy(23,17);
printf("Customer Status (Type d):");
gotoxy(37,19);
printf(" NOTE ");
gotoxy(25,21);
printf("Use underscore for spaces...");
gotoxy(29,9);
scanf("%s",&record[i].code);
gotoxy(40,11);
scanf("%s",&record[i].name);
gotoxy(40,13);
scanf("%d",&record[i].present);
gotoxy(41,15);
scanf("%d",&record[i].previous);
gotoxy(48,17);
scanf("%s",&record[i].status );
gotoxy(25,21);printf("Press any key to continue...");
getch();
kwh=record[i].present-record[i].previous;
sop=1.4545*kwh;
vat=0.5198*kwh;
oth=0.4441*kwh;
fxdr=100;
record[i].bill=sop+vat+oth+fxdr;
i=i+1;
save();
break;
}
case 2:
{
test=0;
clrscr();

gotoxy(34,8);
printf("CODE: ");
gotoxy(19,4);
printf("Electricity Bill Record Maintaining System");
gotoxy(33,6);
printf(" Edit Record ");
gotoxy(15,7);
printf(" CURRENT ");
gotoxy(55,7);
printf(" UPDATED ");
gotoxy(25,5);
gotoxy(40,8);
scanf("%s",&sik);
gotoxy(18,22);
printf("NOTE: You may use underscore for spacing...");
for(s=0;s<=num||s<=ctr;s++)
{
if(strcmp(record[s].code,sik)==0)
{
test=1;
gotoxy(9,11);
printf("Customer's Name: ");puts(record[s].name);
gotoxy(9,13);
printf("Present Reading: %d",record[s].present);
gotoxy(9,15);
printf("Previous Reading: %d",record[s].previous);
gotoxy(9,17);
printf("Total Bill: %.2f",record[s].bill);
getch();
gotoxy(44,11);
printf("Customer's Name: ");
gotoxy(44,13);
printf("Present Reading: ");
gotoxy(44,15);
printf("Previous Reading: ");
gotoxy(44,17);
printf("Total Bill: ");
gotoxy(61,11);
scanf("%s",&record[s].name[s]);
gotoxy(60,13);
scanf("%d",&record[s].present);
gotoxy(61,15);
scanf("%d",&record[s].previous);

kwh=record[s].present-record[s].previous;
sop=1.4545*kwh;
vat=0.5198*kwh;
oth=0.4441*kwh;
fxdr=100;
record[s].bill=sop+vat+oth+fxdr;

gotoxy(44,17);
printf("Total Bill: %.2f",record[s].bill);
gotoxy(25,24);printf("Press any key to continue...");
getch();
save();
break;
}
}
if(test!=1)
{
gotoxy(18,22);
printf("NOTE: The customer code %s is not in the list...",sik);
gotoxy(25,24);printf("Press any key to continue...");
getch();
}
break;
}
case 3:
{
clrscr();
gotoxy(19,4);
printf("Electricity Bill Record Maintaining System");
gotoxy(22,7);
printf(" Delete Record ");
gotoxy(23,21);
printf("Enter Customer's Code: ");
scanf("%s",&sik);
for(s=0;s<=i||s<=ctr;s++)
{
if(strcmp(record[s].code,sik)==0)
{
test=1;
gotoxy(23,9);
printf("Customer's Name: ");puts(record[s].name);
gotoxy(23,11);
printf("Present Reading: %d",record[s].present);
gotoxy(23,13);
printf("Previous Reading: %d",record[s].previous);
gotoxy(23,15);
printf("Total Bill: %.2f",record[s].bill);
gotoxy(23,21);
printf("Delete this record?(y/n): ");
scanf("%s",&ans);
if(ans=='n')
{
break;
}
if(ans=='y')
{
for(s=0;s<=num||s<=ctr;s++)
{
if(strcmp(record[s].code,sik)==0)
{
test=1;
record[s].code[0]='\0';

record[s].name[0]='\0';
record[s].present='\0';
record[s].previous='\0';
record[s].bill='\0';
guard=guard-1;
} }
gotoxy(23,21);
printf("NOTE: Deleted!!!!
gotoxy(23,23);
printf("Press any key to continue...");

");

getch();
save();
break;
}
}
}
if(test!=1 && ans=='y');
{
gotoxy(21,21);
printf("The customer code %s is not in the list.",sik);
getch();
}
closegraph();
break;
}
case 4:
{
test=0;
clrscr();
gotoxy(19,4);
printf("Electricity Bill Record Maintaining System");
gotoxy(22,7);
printf(" View Record ");
gotoxy(23,21);
printf("Customer Code: ");
scanf("%s",&sik);
for(s=0;s<=num||s<=ctr;s++)
{
if(strcmp(record[s].code,sik)==0)
{
test=1;
gotoxy(36,9);
printf("CODE: %s",record[s].code);
gotoxy(23,11);
printf("Customer's Name:%s",record[s].name);
gotoxy(23,13);
printf("Present Reading: %d",record[s].present);
gotoxy(23,15);
printf("Previous Reading: %d",record[s].previous);
gotoxy(23,17);
printf("Total Bill: %.2f",record[s].bill);
gotoxy(33,19);
printf(" Notification ");
gotoxy(23,21);
printf("Press any key to continue...");
getch();
save();

break;
}
}
if(test!=1)
{
gotoxy(20,21);
printf("The customer code %s is not in the list.",sik);
getch();
}
break;
}
case 5:
{
if(guard!=0)
{
y=9;
clrscr();
gotoxy(19,2);
printf("Electricity Bill Record Maintaining System");
gotoxy(7,5);
printf(" View Records ");
gotoxy(7,7);
printf("Code");
gotoxy(15,7);
printf("Name");
gotoxy(35,7);
printf("Present");
gotoxy(48,7);
printf("Previous");
gotoxy(64,7);
printf("Total Bill");
for(i=0;i<=num||i<=ctr;i++)
{
if(record[i].code[0]!='\0')
{
gotoxy(x,y);
printf("%s",record[i].code);
gotoxy(x+8,y);
printf("%s",record[i].name);
gotoxy(x+28,y);
printf("%d",record[i].present);
gotoxy(x+41,y);
printf("%d",record[i].previous);
gotoxy(x+57,y);
printf("%.2f",record[i].bill);
y=y+1;
}
}
printf("\nPress any key to continue...");
getch();
save();
break;
}
else
{
clrscr();
gotoxy(25,5);

printf("No record in the Structure!");


gotoxy(25,7);
printf("press any key....");
getch();
break;
}
}
case 6:
{
clrscr();
float amount;
float atbrtc;
gotoxy(19,4);
printf("Electricity Bill Cash Collection Section");
gotoxy(23,21);
printf("Enter Customer's Code: ");
scanf("%s",&sik);
for(s=0;s<=i||s<=ctr;s++)
{
if(strcmp(record[s].code,sik)==0)
{
test=1;
yz:
gotoxy(23,9);
printf("Customer's Name: ");puts(record[s].name);
gotoxy(23,11);
printf("Present Reading: %d",record[s].present);
gotoxy(23,13);
printf("Previous Reading: %d",record[s].previous);
gotoxy(23,15);
printf("Total Bill: %.2f",record[s].bill);
gotoxy(23,17);
printf("Enter the amount you want to pay:");
scanf("%f",&amount);
if(amount<record[s].bill)
{ clrscr();
printf("Enter amount more or equal to total bill");
goto yz;
}
else
{
gotoxy(23,19);
printf("Cash Paid:%f",amount);
atbrtc=amount-record[s].bill;
gotoxy(23,21);
printf("Amount to be returned to coustomer:%f",atbrtc);
gotoxy(23,23);
printf("Customer Status (Type p):");
scanf("%s",record[s].status);
gotoxy(23,25);
printf("\n\npress any key to continue...");
getch();
save();
}
break;

}
if(test!=1)
{
gotoxy(18,22);
printf("NOTE: The customer code %s is not in the list...",sik);
gotoxy(28,24);printf("Press any key to continue...");
getch();
}
}
break;}
case 7:
{
clrscr();

for(i=0;i<=num||i<=ctr;i++)
{
if(strcmp(record[i].status,"d")==0)
{
gotoxy(19,4);
printf("Electricity Bill Record Maintaining System");
test=1;
gotoxy(x,y);
printf("Code: %s",record[i].code);
gotoxy(x+10,y);
printf("Name: ");puts(record[i].name);
y=y+1;
save();
}

if(test!=1)
{
clrscr();
gotoxy(19,4);
printf("Electricity Bill Record Maintaining System");
gotoxy(18,12);
printf("The list is empty");
gotoxy(28,24);printf("Press any key to continue...");
getch();
break;
}
gotoxy(28,24);printf("Press any key to continue...");
getch();
break;
}
case 8:
{

clrscr();

for(i=0;i<=num||i<=ctr;i++)
{
if(strcmp(record[i].status,"p")==0)
{
gotoxy(19,4);
printf("Electricity Bill Record Maintaining System");
test=1;
gotoxy(x,y);
printf("Code: %s",record[i].code);
gotoxy(x+10,y);
printf("Name: ");puts(record[i].name);
y=y+1;
save();
}
}
if(test!=1)
{
clrscr();
gotoxy(19,4);
printf("Electricity Bill Record Maintaining System");
gotoxy(18,12);
printf("The list is empty");
gotoxy(28,24);printf("Press any key to continue...");
getch();
break;
}
gotoxy(28,24);printf("Press any key to continue...");
getch();
break;
}
case 0:
{
cls();
gotoxy(20,7);printf("Electricity Bill Record Maintaining System");
gotoxy(32,14);
printf("---Created By---");
gotoxy(34,16);
printf("TEAM A.R.A.B");
gotoxy(32,20);printf("EXITING SYSTEM");
save();
sleep(2);
return 0;
}
default:
{
clrscr();
gotoxy(25,5);
printf("Invalid Entry!");

gotoxy(28,24);printf("Press any key to continue...");


getch();
break;
}
}
} while(i<=100);
return 0;
}
void list(void)
{
register int t;
for(t=0; t<SIZE; t++)
{
*record[t].code ='\0';
}
}
void load(void)
{
FILE *fp;
register int i;
if((fp=fopen("bill1.dat","rb"))==NULL)
{
printf("Cannot Open File\n");
getche();
return;
}
list();
for(i=0;i<SIZE;i++)
{
if(fread(&record[i],sizeof(struct bills),1,fp)!=1)
{
if(feof(fp))
{
fclose(fp);
return;
}
printf("File read error\n");
}
ctr=ctr+1;
}
}
void save(void)
{
FILE *fp;
register int i;
if((fp=fopen("bill1.dat","wb"))==NULL)
{
printf("cannot open file\n");
getche();

return;
}
for(i=0;i<SIZE;i++)
{
if(*record[i].code)
{
if(fwrite(&record[i],sizeof(struct bills),1,fp)!=1)
{
printf("file write error\n");
getche();
}
}
}
fclose(fp);
}

Anda mungkin juga menyukai